GetBestCategory
Single most relevant category index.
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.
GetBestCategorySingle most relevant category index.
GetTopCategoriesRanked list with confidence scores.
One unified API.
Manual sorting wastes time, introduces errors, and breaks down as content volume grows. Automate classification directly inside your .NET applications.
The Categorization engine delivers production-grade classification with a clean, flexible API designed for real-world workloads.
Multimodal
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
Every classification returns a Confidence score so you can set thresholds, escalate uncertain cases to human review, and audit decisions at scale.
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
Enable UseEmbeddingClassifier for ultra-fast, lightweight classification using vector similarity instead of generative inference. Ideal for high-throughput pipelines.
Guidance
The Guidance property lets you inject domain-specific instructions to steer classification behavior, fine-tuning how categories are interpreted without retraining.
Unknown
AllowUnknownCategory returns -1 when content does not match any predefined category, preventing forced misclassification on out-of-scope inputs.
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.
GetBestCategoryAsync for non-blocking workflowsAttachment, and ImageBuffer inputsvar 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);
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.
AllowUnknownCategory for safety filteringGetTopCategoriesAsyncvar 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);
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 processingMaxInputTokens controls how much content is analyzedImageBuffer overload for in-memory image classificationvar 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");
From NuGet install to production classification in minutes. No cloud accounts, API keys, or external services required.
Step 1
Add the LM-Kit.NET NuGet package to your C# or VB.NET project. Zero external dependencies.
Step 2
Call LM.LoadFromModelID to download and load a task-optimized model like lmkit-tasks:4b-preview.
Step 3
Create a list of category names, optionally paired with descriptions for higher accuracy.
Step 4
Call GetBestCategory or GetTopCategories with your content. Check the Confidence score for reliability.
Organizations across industries use LM-Kit content classification to automate workflows, improve routing, and extract structured labels from unstructured content.
Support
Automatically classify incoming tickets by topic, priority, and product area. Route to the right team instantly, cutting first-response time dramatically.
Documents
Sort invoices, contracts, reports, and correspondence. Classify PDFs and scans into document types for intelligent document processing pipelines.
Moderation
Classify user-generated content by topic, flag policy violations, and detect spam. Process text and images through one unified pipeline.
Media
Tag articles by topic, region, and relevance. Build automated news feeds, media monitoring dashboards, and content recommendation engines.
Classify incoming emails by intent, urgency, and department. Automate responses for common categories and escalate high-priority items.
Compliance
Classify documents and communications against regulatory categories. Identify sensitive content types and route for review before release.
See how LM-Kit's on-device approach compares to cloud-based classification services.
| Feature | LM-Kit.NET | Cloud APIs |
|---|---|---|
| Custom categories | Unlimited, no retraining | Often requires retraining or fine-tuning |
| Data privacy | 100% on-device | Data sent to third-party servers |
| Per-request cost | Zero | Per-token or per-request pricing |
| Offline support | Full offline | Requires internet |
| Multimodal (text + images + docs) | Native | Varies by provider |
| Embedding classifier mode | Built-in | Not available |
| Latency | Milliseconds (local) | Network-dependent |
Complete documentation, code samples, and live demos for the Categorization engine.
Core class
CategorizationThe main classification engine. Define categories, classify content, read confidence scores.
Single-category
GetBestCategoryClassify text, images, or documents into the single most relevant category from your list.
Multi-category
GetTopCategoriesGet a ranked list of the top matching categories with individual confidence scores.
Demo (CLI)
Console sample showing how to define custom categories and classify text with confidence scoring.
Demo (CLI)
Classify entire documents (PDF, DOCX) into categories using the Attachment input method.
Demo (CLI)
Process multiple documents in batch, classifying each against your predefined category set.
Working console demos on GitHub, step-by-step how-to guides on the docs site, and the API reference for the classes used on this page.
Console demo: classify text into a custom taxonomy with grammar-constrained output.
Open on GitHub → DemoConsole demo: high-throughput classification across many documents.
Open on GitHub → How-to guideMulti-label classification + custom policy on-device.
Read the guide → API referenceAPI reference for the Categorization class.
Open the reference →Unlimited custom categories. Multimodal input. Confidence scoring. 100% on-device. Start building intelligent .NET applications today.