Table of Contents

The Private Document Intelligence SDK for .NET

From documents to data, knowledge, and action. Privately.

LM-Kit.NET brings private AI for documents and internal knowledge to .NET. Extract structured data from PDFs and scans, answer questions over company knowledge with citations, and run governed agents that act on your documents. The complete stack, inference included, ships in one NuGet package and runs entirely in-process from C# or VB.NET, with zero cloud dependency and full control over data, latency, and cost.

100% Local No Signup Cross-Platform

What Do You Want to Build?


Why LM-Kit.NET

Add document intelligence to any .NET app in minutes. Install one NuGet package and start building. No Python runtimes, no containers, no external services, no dependencies to manage. LM-Kit.NET fits into your existing architecture and deployment pipeline.

Powered by Dynamic Sampling. Underneath every call sits an adaptive inference engine that steers each token in real time, so small local models deliver dependable results on extraction, classification, function calling, and structured generation. Our team ships the latest advances in generative AI, symbolic AI, and NLP research directly into the SDK; check the changelog to see the pace.

Outputs you can verify, operations you can govern. Extraction returns per-field confidence scores, retrieval-grounded answers carry their source passages, and permission policies put allow/deny rules and approval gates in front of every tool an agent can touch. Resilience policies and full observability turn prototypes into production systems.

Complete data sovereignty Sensitive information stays within your infrastructure
Zero network latency Responses as fast as your hardware allows
No per-token costs Unlimited inference once deployed
Offline operation Works without internet connectivity
Regulatory compliance GDPR, HIPAA, and data residency requirements by design

Core Capabilities

Documents lead, and the runtime is complete: the same engine that reads, extracts, and answers also sees, listens, analyzes, and writes, all from one package.

Document Intelligence

Turn documents into structured, verifiable data across PDF, DOCX, XLSX, PPTX, EML, MBOX, HTML, and image formats.

  • Universal Document-to-Markdown Engine - State-of-the-art converter that turns any supported format into clean, LLM-ready Markdown. Switchable strategies (TextExtraction, VlmOcr, Hybrid) with per-page routing, format-aware specialists for EML/MBOX/HTML/DOCX, streaming progress events, YAML front matter, and direct-to-disk output
  • VLM-Powered OCR - High-accuracy text extraction from images and scanned content using vision language models
  • Structured Extraction - Define extraction targets with JSON schemas, custom elements, and pattern constraints
  • Confidence Scoring and Validation - Per-field confidence scores, entity auto-detection, format validation, and human verification flags, so every extracted value tells you how much to trust it

  • Document Splitting - Detect logical document boundaries in multi-page files using vision-based analysis
  • PDF Toolkit - Split, merge, search, extract pages, render to image, and unlock password-protected files
  • PDF Redaction - Permanently remove sensitive content with true text removal; Smart Redaction adds AI-assisted detection of what to redact, ready for reviewer approval
  • PDF/A Conversion - Convert documents to archival-grade PDF/A for long-term storage and compliance
  • Layout-Aware Processing - Detect paragraphs and lines, support region-based workflows

Retrieval-Augmented Generation (RAG)

Turn documents into knowledge: ground responses in your organization's content with a flexible, extensible retrieval framework.

  • Grounded Answers with Citations - Retrieval carries the source back with the answer: the matching partitions, their documents, and the passages that support the response
  • Modular RAG Architecture - Use built-in pipelines or implement custom retrieval strategies
  • Built-in Vector Database - Store and search embeddings without external dependencies
  • PDF Chat and Document RAG - Chat and retrieve over documents with dedicated workflows
  • Multimodal RAG - Retrieve relevant content from both text and images
  • Advanced Chunking - Markdown-aware, HTML-aware, semantic, and layout-based chunking strategies
  • Reranking - Improve retrieval precision with semantic reranking
  • External Vector Store Integration - Connect to Qdrant, PostgreSQL (pgvector), and other vector databases

AI Agents and Orchestration

Turn knowledge into action: build autonomous AI agents that reason, plan, and execute governed workflows inside your applications.

  • Agent Framework - Complete agent infrastructure with Agent, AgentBuilder, AgentExecutor, and AgentRegistry
  • Multi-Agent Orchestration - Coordinate multiple agents with PipelineOrchestrator, ParallelOrchestrator, RouterOrchestrator, and SupervisorOrchestrator
  • Planning Strategies - ReAct, Chain-of-Thought, Tree-of-Thought, Plan-and-Execute, and Reflection
  • Agent-to-Agent Delegation - Delegate tasks to specialized sub-agents with DelegationManager and DelegateTool
  • Agent Templates - Pre-built templates including Chat, Assistant, Code, Research, Analyst, Planner, and more

  • Extensive Built-in Tools - A growing catalog of ready-to-use tools across eight categories (Data, Text, Numeric, Security, Utility, Document, IO, Net), each following the 1 tool = 1 feature atomic design
  • Tool Governance - Centralized permission policies with allow/deny rules, category filters, risk levels, and approval gates for every tool an agent can invoke
  • MCP Client Support - Connect to Model Context Protocol servers for extended tool access, resources, and prompts
  • Function Calling - Let models dynamically invoke your application's methods with structured parameters

  • Resilience Policies - Retry, Circuit Breaker, Timeout, Rate Limit, Bulkhead, and Fallback
  • Streaming Support - Real-time response streaming with buffered, multicast, and delegate handlers
  • Agent Observability - Full tracing and metrics with AgentTracer, AgentMetrics, and JSON export
  • Agent Memory - Persistent memory across conversation sessions with RAG-based recall
  • Reasoning Control - Adjust reasoning depth for models that support extended thinking

Vision

Bring image understanding into the same runtime as your document and text workflows.

  • Vision Language Models (VLM) - Analyze images, extract information, answer questions about visual content
  • Image Embeddings - Generate semantic representations of images for similarity search and multimodal retrieval
  • Vision-Driven Document Workflows - VLM OCR, document splitting, and layout analysis build on the same vision stack

Text Analysis

Turn unstructured text into structured signals for compliance, routing, and analytics.

  • Named Entity Recognition (NER) - Extract people, organizations, locations, and custom entity types
  • PII Detection - Identify and classify personal identifiers for privacy compliance, paired with PDF redaction for end-to-end remediation
  • Sentiment and Emotion Analysis - Detect emotional tone from text and images
  • Custom Classification - Categorize text and images into your defined classes
  • Language Detection - Identify languages from text, images, or audio
  • Keyword Extraction - Identify key terms and phrases

Speech and Audio

Process audio entirely on-device.

  • Speech-to-Text - Whisper-powered transcription with voice activity detection and multi-language support
  • Real-Time Transcription - Stream audio in and get text out as it is spoken

Text Generation and Transformation

Generate and refine content with precise control.

  • Conversational AI - Build context-aware chatbots with multi-turn memory
  • Constrained Generation - Guide model outputs using JSON schemas, templates, or custom grammar rules
  • Translation - Convert text between languages with confidence scoring
  • Text Enhancement - Improve clarity, fix grammar, adapt tone
  • Summarization - Condense long content with configurable strategies

Model Optimization

Tailor models to your specific domain.


Supported Models

The model catalog curates 100+ ready-to-run models, including domain-tuned variants optimized for real-world tasks, across four modalities:

  • Text - Chat, reasoning, code generation, and tool calling
  • Vision - Image understanding, visual Q&A, and VLM-powered OCR
  • Embeddings - Semantic search and retrieval
  • Speech - Transcription with voice activity detection
Note

New model families are added continuously. Browse the full list in the Model Catalog, or load any compatible model directly from Hugging Face.


Performance and Hardware

Dynamic Sampling Engine

Every LM-Kit.NET call runs on Dynamic Sampling, an adaptive inference layer that steers each token in real time. It is always on, model-agnostic, and requires no retraining.

  • Constrained Output - Dynamic grammar guarantees that JSON, schemas, and tool-call shapes always parse, with a hybrid path measurably faster than classical grammar sampling
  • Adaptive Guidance - Per-token contextual signals and structural validation reduce hallucinations and recover malformed runs in place
  • Model-Agnostic - No architecture coupling, no fine-tuning, no per-model adapters; new open-weight releases work from day one

Hardware Acceleration

LM-Kit.NET automatically leverages the best available acceleration on any hardware:

  • NVIDIA GPUs - CUDA backends with optimized kernels
  • AMD/Intel GPUs - Vulkan backend for cross-vendor GPU support
  • Apple Silicon - Metal acceleration for M-series chips
  • Multi-GPU - Distribute models across multiple GPUs
  • CPU Fallback - Optimized CPU inference when GPU unavailable

Dual Backend Architecture

Choose the optimal inference engine for your use case:

  • llama.cpp Backend - Broad model compatibility, memory efficiency
  • ONNX Runtime - Optimized inference for supported model formats

Observability

Gain full visibility into AI operations with comprehensive instrumentation:

  • OpenTelemetry Integration - GenAI semantic conventions for distributed tracing and metrics
  • Inference Metrics - Token counts, processing rates, generation speeds, context utilization, perplexity scores, and sampling statistics
  • Event Callbacks - Fine-grained hooks for token sampling, tool invocations, and generation lifecycle

Platform Support

Operating Systems

  • Windows - Windows 7 through Windows 11
  • macOS - macOS 11+ (Intel and Apple Silicon)
  • Linux - glibc 2.27+ (x64 and ARM64)

.NET Frameworks

Compatible from .NET Framework 4.6.2 through the latest .NET releases, with optimized binaries for each version.


Integration

Zero Dependencies

LM-Kit.NET ships as a single NuGet package with absolutely no external dependencies:

Tip
dotnet add package LM-Kit.NET

No Python runtime. No containers. No external services. No native libraries to manage separately. Everything runs in-process.

Ecosystem Connections

  • Microsoft Semantic Kernel - Use LM-Kit.NET as a local inference provider for Microsoft Semantic Kernel via the open-source LM-Kit.NET.SemanticKernel bridge package
  • Microsoft.Extensions.AI - Plug LM-Kit.NET into any .NET application that targets the standard IChatClient and IEmbeddingGenerator abstractions via the open-source LM-Kit.NET.ExtensionsAI bridge package
  • Vector Databases - Integrate with Qdrant and PostgreSQL (pgvector) via open-source connectors
  • MCP Servers - Connect to Model Context Protocol servers for extended tool access
  • LM-Kit One - Prefer a server you deploy over a runtime you embed? LM-Kit One delivers the same capabilities as a private AI server

Data Privacy and Security

Local inference is the foundation; verifiable outputs and governed operation complete the picture:

  • Private by architecture - Content never leaves your network, no third-party service processes your data, and air-gapped deployment is fully supported
  • Verifiable by output - Extracted fields carry confidence scores, grounded answers carry their sources, and every AI operation is fully auditable
  • Governed in operation - You choose the models, the tools, and the permission policies, with approval gates in front of the actions that matter

This architecture simplifies compliance with GDPR, HIPAA, SOC 2, and other regulatory frameworks.


Getting Started

Extract Structured Data from a Document

using LMKit.Data;
using LMKit.Extraction;
using LMKit.Model;

// Load a model from the catalog (downloaded and cached on first use)
var model = LM.LoadFromModelID("qwen3.5:4b");
var extractor = new TextExtraction(model);

extractor.Elements = new List<TextExtractionElement>
{
    new("invoice_number", ElementType.String),
    new("invoice_date",   ElementType.Date),
    new("total_amount",   ElementType.Double),
};

extractor.SetContent(new Attachment("invoice.pdf"));
var data = extractor.Parse();

Console.WriteLine(data.Json);

Ask Questions over Your Documents

using LMKit.Model;
using LMKit.Retrieval;

var chatModel  = LM.LoadFromModelID("qwen3.5:9b");
var embedModel = LM.LoadFromModelID("embeddinggemma-300m");

using var chat = new PdfChat(chatModel, embedModel);

await chat.LoadDocumentAsync("policies.pdf");

// Grounded answer with passage retrieval and page citations
var answer = await chat.SubmitAsync("What is our enterprise refund window?");
Console.WriteLine(answer.Response.Completion);

Run an Agent with Tools

using LMKit.Agents;
using LMKit.Agents.Tools.BuiltIn;
using LMKit.Model;

// Build an agent with built-in tools
using var model = LM.LoadFromModelID("qwen3.5:9b");

var agent = Agent.CreateBuilder(model)
    .WithPersona("Researcher")
    .WithInstruction("You are a helpful research assistant.")
    .WithTools(tools =>
    {
        tools.Register(BuiltInTools.WebSearch);
        tools.Register(BuiltInTools.CalcArithmetic);
        tools.Register(BuiltInTools.DateTimeNow);
    })
    .WithPlanning(PlanningStrategy.ReAct)
    .Build();

var result = await agent.RunAsync("What is the current population of Tokyo?");
Console.WriteLine(result.Content);
Share