๐ Try the demo:
https://github.com/LM-Kit/lm-kit-net-samples/tree/main/console_net/document-intelligence/document-classification/batch_document_classification
Batch Document Classification with AI in .NET Applications
๐ฏ Purpose of the Demo
Batch Document Classification demonstrates how to classify large volumes of heterogeneous documents using LM-Kit.NET. The sample processes files in parallel, assigns each document to the most relevant category, and automatically organizes outputs into category-based folders.
It supports images, PDFs, Office documents, text, and HTML files, making it suitable for real-world document pipelines.
๐ฅ Target Audience
- Enterprise & B2B Apps โ automate document intake and routing
- Back-office & Ops โ sort incoming documents at scale
- Compliance & Archiving โ pre-classify documents before review
- Demo & Benchmarking โ measure throughput and confidence at scale
๐ Problem Solved
- Manual sorting of mixed document folders
- Scalable classification with configurable parallelism
- Consistent taxonomy across thousands of files
- Automated organization of outputs by category
๐ป Sample Application Description
Console application that:
- Loads a local LM-Kit classification model.
- Scans an input directory recursively.
- Filters supported file types (images, PDFs, Office docs, text).
- Classifies each document into a predefined category list.
- Runs in parallel with configurable thread count.
- Copies files into category-based output folders.
- Displays real-time progress, confidence, and performance metrics.
๐ Supported File Types
- Images: PNG, JPEG (JPG, JPE, JFIF), GIF, BMP (DIB), TIFF (TIF, multi-page), WebP, HEIC/HEIF, AVIF, PSD, PIC, ICO (CUR), PNM (PBM, PGM, PPM, PAM), HDR, TGA, SVG
- Documents: PDF, DOCX, XLSX, PPTX, EML, MSG, MBOX
- Text: TXT, HTML
๐ท๏ธ Supported Categories
Examples include:
- Invoice, Receipt, Purchase Order
- Contract, Letter, Resume
- Bank Statement, Utility Bill, Pay Stub
- Passport, ID Card, Driver License
- Medical Record, Insurance Policy
- Shipping Document, Shipping Label
- Unknown (fallback)
โ๏ธ Key Features
- โก Parallel Processing โ configurable number of threads
- ๐ Auto-Sorting โ output folders per detected category
- ๐ง Confidence Scoring โ per-document confidence value
- ๐ Live Metrics โ throughput, average latency, docs per second
- ๐งฉ Mixed Inputs โ images and documents handled uniformly
- ๐ Thread-Safe Design โ shared model, per-thread categorizer
๐ ๏ธ Getting Started
๐ Prerequisites
- .NET 8.0 or later
๐ฅ Download
git clone https://github.com/LM-Kit/lm-kit-net-samples
cd lm-kit-net-samples/console_net/document-intelligence/document-classification/batch_document_classification
โถ๏ธ Run
dotnet build
dotnet run
You will be prompted for:
- Input folder containing documents
- Output folder for classified files
- Number of processing threads
๐ Runtime Output
During execution, the console displays:
- File name and detected category
- Confidence score
- Per-document processing time
- Global progress and average latency
At completion:
- Total documents processed
- Documents per second
- Average confidence
- Error count (if any)
๐ Notes
- The model is loaded once and shared across threads.
- Each worker thread uses its own
Categorizationinstance. - Unknown or ambiguous documents are routed to the unknown category.
- Output file names are auto-deduplicated.
๐ง Extend the Demo
- Customize the category taxonomy.
- Persist results to a database instead of folders.
- Add confidence thresholds for rejection or review queues.
- Integrate OCR preprocessing for scanned documents.
- Combine with RAG or extraction pipelines for downstream processing.
๐ Related Content
- How-To: Classify Documents with Custom Categories: Guide to defining custom category taxonomies for document classification.
- How-To: Classify and Extract Pipeline: Learn how to chain classification with structured extraction.
- Glossary: Classification: Explains AI-powered text and document classification concepts.
- Document Classification Demo: Single-file classification with confidence scoring and interactive commands.