Solutions · Text Analysis · Classification

Custom content classification for .NET.

Classify text, images, PDFs, and Office documents into any categories you define. Get the single best match or a ranked list with confidence scores. Add category descriptions for precision. Handle unknown inputs gracefully. Runs 100% on-device with Dynamic Sampling for maximum accuracy on any hardware.

Multimodal input Confidence scoring Unlimited categories
Method

GetBestCategory

Single most relevant category index.

Method

GetTopCategories

Ranked list with confidence scores.

Inputs

Text, images, PDFs, DOCX, XLSX, PPTX, HTML

One unified API.

Problem

Stop routing content manually.

Manual sorting wastes time, introduces errors, and breaks down as content volume grows. Automate classification directly inside your .NET applications.

Without LM-Kit

  • Manual tagging that does not scale with volume
  • Rigid keyword rules that miss intent and context
  • Cloud API costs and latency that add up fast
  • Sending sensitive data to third-party servers
  • Separate pipelines for text, images, and documents
Capabilities

Everything you need to classify content.

The Categorization engine delivers production-grade classification with a clean, flexible API designed for real-world workloads.

Multimodal

Multimodal input

Classify plain text, images, PDFs, DOCX, XLSX, PPTX, and HTML through a single unified API. Automatic OCR extracts content from scanned documents and screenshots.

Confidence

Confidence scoring

Every classification returns a Confidence score so you can set thresholds, escalate uncertain cases to human review, and audit decisions at scale.

Sampling

Dynamic Sampling

LM-Kit's innovative sampling technology delivers up to 75% error reduction and 2x faster processing, even with smaller models on CPU-only hardware.

Embeddings

Embedding classifier mode

Enable UseEmbeddingClassifier for ultra-fast, lightweight classification using vector similarity instead of generative inference. Ideal for high-throughput pipelines.

Guidance

Custom guidance

The Guidance property lets you inject domain-specific instructions to steer classification behavior, fine-tuning how categories are interpreted without retraining.

Unknown

Unknown category handling

AllowUnknownCategory returns -1 when content does not match any predefined category, preventing forced misclassification on out-of-scope inputs.

Method

Single-category classification.

Use GetBestCategory to assign content to the single most relevant category from your predefined list. Provide optional category descriptions to improve accuracy when category names are ambiguous. Access the Confidence property after each call to verify classification reliability.

  • Pass categories as a simple list of strings
  • Optional descriptions list for each category improves precision
  • Returns index of the winning category (-1 if unknown)
  • Async overload: GetBestCategoryAsync for non-blocking workflows
  • Works with text, Attachment, and ImageBuffer inputs
SingleCategory.cs
var model = LM.LoadFromModelID("lmkit-tasks:4b-preview");
var classifier = new Categorization(model);

// Define categories with descriptions
var categories = new List<string> {
    "Billing Issue", "Technical Support",
    "Feature Request", "General Feedback"
};
var descriptions = new List<string> {
    "Payment problems, refunds, charges",
    "Bugs, errors, troubleshooting",
    "New features, improvements",
    "General comments and feedback"
};

int idx = classifier.GetBestCategory(categories, ticket, descriptions);
Method

Multi-category classification.

Use GetTopCategories to retrieve a ranked list of the most relevant categories, each with its confidence score. Perfect for content that spans multiple topics, for building recommendation systems, or for routing content to multiple downstream processes simultaneously.

  • Specify maximum number of categories to return
  • Results ranked by confidence from highest to lowest
  • Combine with AllowUnknownCategory for safety filtering
  • Async overload: GetTopCategoriesAsync
  • Apply to text, images, and document attachments
MultiCategory.cs
var model = LM.LoadFromModelID("lmkit-tasks:4b-preview");
var classifier = new Categorization(model)
{
    AllowUnknownCategory = true
};

var categories = new List<string> {
    "Technology", "Business", "Science",
    "Politics", "Entertainment", "Sports"
};

string article = "Apple unveils new AI chip " +
    "that could reshape the industry.";

// Get top 3 matching categories
var results = classifier.GetTopCategories(categories, article, maxCount: 3);
Inputs

Classify any content type.

The Categorization engine accepts text, images, and full document files through the Attachment class. Pass PDFs, Word documents, Excel spreadsheets, PowerPoint presentations, HTML files, and images. LM-Kit automatically extracts text and visual content, then classifies against your categories. Use a vision-capable model for image inputs.

  • PreferredInferenceModality controls text, image, or multimodal processing
  • Automatic OCR for scanned documents and screenshots
  • MaxInputTokens controls how much content is analyzed
  • ImageBuffer overload for in-memory image classification
  • Combine with batch processing for high-volume document pipelines
ClassifyAttachment.cs
var model = LM.LoadFromModelID("lmkit-tasks:4b-preview");
var classifier = new Categorization(model);

var docTypes = new List<string> {
    "Invoice", "Contract", "Resume", "Report"
};

// Classify a PDF document
var pdf = new Attachment("document.pdf");
int pdfResult = classifier.GetBestCategory(docTypes, pdf);
Console.WriteLine($"PDF: {docTypes[pdfResult]}");

// Classify an image with vision-capable model
var img = new Attachment("screenshot.png");
Quick start

Up and running in 4 steps.

From NuGet install to production classification in minutes. No cloud accounts, API keys, or external services required.

Step 1

Install LM-Kit.NET

Add the LM-Kit.NET NuGet package to your C# or VB.NET project. Zero external dependencies.

Step 2

Load a model

Call LM.LoadFromModelID to download and load a task-optimized model like lmkit-tasks:4b-preview.

Step 3

Define categories

Create a list of category names, optionally paired with descriptions for higher accuracy.

Step 4

Classify content

Call GetBestCategory or GetTopCategories with your content. Check the Confidence score for reliability.

Applications

Real-world classification use cases.

Organizations across industries use LM-Kit content classification to automate workflows, improve routing, and extract structured labels from unstructured content.

Support

Support ticket routing

Automatically classify incoming tickets by topic, priority, and product area. Route to the right team instantly, cutting first-response time dramatically.

Documents

Document classification

Sort invoices, contracts, reports, and correspondence. Classify PDFs and scans into document types for intelligent document processing pipelines.

Moderation

Content moderation

Classify user-generated content by topic, flag policy violations, and detect spam. Process text and images through one unified pipeline.

Media

News & media categorization

Tag articles by topic, region, and relevance. Build automated news feeds, media monitoring dashboards, and content recommendation engines.

Email

Email triage

Classify incoming emails by intent, urgency, and department. Automate responses for common categories and escalate high-priority items.

Compliance

Compliance screening

Classify documents and communications against regulatory categories. Identify sensitive content types and route for review before release.

Comparison

LM-Kit vs. cloud classification APIs.

See how LM-Kit's on-device approach compares to cloud-based classification services.

FeatureLM-Kit.NETCloud APIs
Custom categoriesUnlimited, no retrainingOften requires retraining or fine-tuning
Data privacy100% on-deviceData sent to third-party servers
Per-request costZeroPer-token or per-request pricing
Offline supportFull offlineRequires internet
Multimodal (text + images + docs)NativeVaries by provider
Embedding classifier modeBuilt-inNot available
LatencyMilliseconds (local)Network-dependent
Developer Resources

API reference & demos.

Complete documentation, code samples, and live demos for the Categorization engine.

Core class

Categorization

The main classification engine. Define categories, classify content, read confidence scores.

View docs

Single-category

GetBestCategory

Classify text, images, or documents into the single most relevant category from your list.

View docs

Multi-category

GetTopCategories

Get a ranked list of the top matching categories with individual confidence scores.

View docs

Demo (CLI)

Text classification demo

Console sample showing how to define custom categories and classify text with confidence scoring.

View on CLI

Demo (CLI)

Document classification demo

Classify entire documents (PDF, DOCX) into categories using the Attachment input method.

View on CLI

Demo (CLI)

Batch document classification

Process multiple documents in batch, classifying each against your predefined category set.

View on CLI

Ready to classify your content?

Unlimited custom categories. Multimodal input. Confidence scoring. 100% on-device. Start building intelligent .NET applications today.

Download free API documentation