Solutions · Text Generation

AI-powered text generation for .NET.

Generate structured content, summaries, corrections, and style transformations with on-device LLMs. Grammar-constrained outputs, Dynamic Sampling technology, multimodal support, and reasoning capabilities. 100% local processing, zero cloud dependency.

Grammar-constrained Multimodal Reasoning capable

Elevate .NET apps with AI-powered text generation.

LM-Kit.NET brings cutting-edge AI-driven text generation directly to your .NET applications. Generate coherent, contextually relevant text across various domains, from structured content creation and summarization to grammar correction and text enhancement. By leveraging compact Large Language Models (LLMs) that run entirely on-device, LM-Kit ensures fast, secure, and private processing without the need for cloud services.

Powered by Dynamic Sampling technology, LM-Kit achieves up to 75% error reduction and 2x faster inference speeds. With support for grammar-constrained outputs, multimodal inputs, and reasoning capabilities, you can build sophisticated text generation pipelines that meet enterprise requirements.

New in 2026: Agent templates for text generation tasks including WriterAgentTemplate, EditorAgentTemplate, and SummarizerAgentTemplate. Build agentic text generation workflows with planning strategies and tool integration.

Sampling

Dynamic Sampling

Proprietary technology ensuring accurate, constrained outputs with optimal performance.

Multimodal

Multimodal support

Generate text from images, documents, and attachments with VLM integration.

Reasoning

Reasoning capabilities

Chain-of-thought prompting and intermediate reasoning steps with ReasoningLevel control.

Local

100% local

On-device inference with no cloud dependency. Your data never leaves your infrastructure.

Structured content creation

Grammar-constrained text generation.

Generate outputs that strictly conform to predefined formats using custom grammars, JSON schemas, and BNF definitions. Powered by Dynamic Sampling technology for up to 75% error reduction.

JSON

JSON schema enforcement

Create Grammar objects from JSON schemas to ensure generated content aligns with structure and data types. Build JSON outputs directly from .NET types including complex structures like dates and arrays.

BNF

BNF grammar definitions

Define custom grammars using Backus-Naur Form (BNF) for domain-specific output formats. Enforce exact syntax requirements for code generation, queries, and structured documents.

Schema

TextExtractionElement

Define extraction schemas with typed elements including String, Float, Date, Boolean, and Arrays. Supports formatting hints, case modes, and required field validation.

Built-in

Predefined grammar types

Use built-in grammars for common formats: Json, JsonArray, Arithmetic, List, and Boolean. Rapid prototyping with zero grammar definition required.

Constrain

Whitelisted values

Constrain outputs to specific allowed values using the WhitelistedValues property. Perfect for classification tasks and controlled vocabulary generation.

Discovery

Schema discovery

Automatically discover extraction schemas from unstructured content using SchemaDiscovery. Let the AI identify relevant fields and data types.

Grammar factory methods

  • Create a Grammar object from a JSON schema string to enforce structured JSON output generation.
  • Build grammar from TextExtractionElement collection for typed data extraction with validation.
  • Generate grammar from a list of allowed string values for constrained classification outputs.
  • Create JSON grammar from field definitions for rapid schema development without full JSON schema.
StructuredOutput.cs
using LMKit.Model;
using LMKit.TextGeneration;
using LMKit.TextGeneration.Sampling;
using LMKit.Extraction;

// Load the model
var model = LM.LoadFromModelID("qwen3.5:4b");

// Define extraction elements for structured output
var elements = new List<TextExtractionElement>
{
    new TextExtractionElement("ProductName", ElementType.String, "Name of the product"),
    new TextExtractionElement("Price", ElementType.Float, "Price in USD"),
    new TextExtractionElement("ReleaseDate", ElementType.Date, "Product release date"),
    new TextExtractionElement("Features", ElementType.StringArray, "List of key features")
};

// Create grammar from extraction elements
var grammar = Grammar.CreateJsonGrammarFromExtractionElements(elements);

// Create conversation with grammar constraint
var chat = new SingleTurnConversation(model) { Grammar = grammar };

// Generate structured output
var result = chat.Submit("Extract product info: The SuperWidget Pro costs $299.99 and launches March 15, 2026.");
Console.WriteLine(result.Completion);
Content summarization

Intelligent text condensation.

Condense lengthy texts into concise, informative summaries. Extract key insights from any content size with adaptive overflow strategies and multilingual support.

Adaptive summarization engine

The LM-Kit Summarizer is a sophisticated NLP engine that employs innovative techniques to condense content of any size or language into coherent summaries. Multiple overflow strategies ensure reliable handling of massive inputs, from short articles to lengthy legal documents.

Overflow resolution strategies

  • Truncate: Process the first portion that fits within context limits
  • RecursiveSummarize: Iteratively summarize chunks then combine
  • Reject: Return error for content exceeding limits
  • Automatic title generation with GenerateTitle property
  • Configurable summary length via MaxContentWords
  • Target language detection and generation
  • Multimodal support: summarize from images
  • Confidence score for quality assessment
Summarizer.cs
using LMKit.Model;
using LMKit.TextGeneration;

var model = LM.LoadFromModelID("mistral-small3.2");

var summarizer = new Summarizer(model)
{
    GenerateTitle = true,
    GenerateContent = true,
    MaxContentWords = 150,
    OverflowStrategy = OverflowResolutionStrategy.RecursiveSummarize,
    TargetLanguage = Language.English
};

var result = summarizer.Summarize(
    File.ReadAllText("annual-report.txt"));

Console.WriteLine($"Title: {result.Title}");
Console.WriteLine($"Summary: {result.Content}");

Summary modes

Mode

Briefing

Executive-style condensed overview

Mode

Key points

Extract main takeaways

Mode

Abstract

Academic-style summary

Grammar & spell correction

AI-powered text quality enhancement.

Identify and correct grammatical errors, typos, and inconsistencies. Real-time feedback for professional, polished content across multiple languages.

Grammar

Grammar correction

Fix subject-verb agreement, tense inconsistencies, and sentence structure issues automatically.

Spell

Spell checking

Detect and correct spelling mistakes with context-aware suggestions.

i18n

Multilingual support

Correct text in multiple languages with language-specific rules and conventions.

Realtime

Real-time processing

Instant corrections as users type with async support for responsive applications.

TextCorrection.cs
using LMKit.Model;
using LMKit.TextEnhancement;

var model = LM.LoadFromModelID("qwen3.5:4b");
var corrector = new TextCorrection(model);

string input = "My cat don't never flyed to the moon " +
    "because he too much tired from baking pizza.";

string corrected = corrector.Correct(input);

Console.WriteLine("Original: " + input);
Console.WriteLine("Corrected: " + corrected);
// Output: "My cat has never flown to the moon
// because he was too tired from baking pizza."

// Async support for real-time applications
var asyncResult = await corrector.CorrectAsync(input);
Text enhancement

Style transformation & tone adaptation.

Transform text into various communication styles while preserving meaning and structure. Tailor content for different audiences with predefined and custom styles.

Style

Concise

Clear, direct communication

Style

Professional

Business-appropriate tone

Style

Friendly

Warm, approachable style

Brand

Brand consistency

Ensure all communications align with your brand voice and style guidelines across different platforms.

Language

Language adaptation

Translate and rewrite text while maintaining context and nuance for global audiences.

Audience

Audience targeting

Tailor content to resonate with specific audience segments, improving engagement.

Async

Async processing

Asynchronous support for efficient, real-time rewriting in dynamic applications.

TextRewriter.cs
using LMKit.Model;
using LMKit.TextEnhancement;

var model = LM.LoadFromModelID("qwen3.5:4b");
var rewriter = new TextRewriter(model);

string casual = "Hey! So basically the project's done and it works great!";

// Transform to professional style
string professional = rewriter.Rewrite(casual, WritingStyle.Professional);
Console.WriteLine("Professional: " + professional);
// "The project has been completed successfully and is functioning as expected."

// Transform to concise style
string concise = rewriter.Rewrite(casual, WritingStyle.Concise);
Console.WriteLine("Concise: " + concise);
// "Project complete. Fully operational."
Demos

Get started with examples.

Explore working code samples demonstrating text generation capabilities.

Web content extractor

Extract and summarize web page information to structured JSON using grammar constraints.

View demo

Text summarizer

Condense lengthy text into concise summaries with optional title generation.

View demo

Text corrector

Fix grammar and spelling errors with AI-powered correction.

View demo

Text rewriter

Transform text into different communication styles.

View demo

Keyword extraction

Extract key terms and topics from text content.

View demo

Multi-turn chat

Build conversational AI with context-aware responses.

View demo

Developer Resources

Key classes & methods.

Core components for building text generation pipelines.

SingleTurnConversation

One-shot text generation with grammar constraints, system prompts, and sampling configuration.

View documentation

MultiTurnConversation

Context-aware chat with memory, tools, skills, and reasoning support.

View documentation

Summarizer

Intelligent text condensation with overflow strategies and multilingual support.

View documentation

Grammar

Grammar-constrained output with BNF, JSON schema, and extraction element support.

View documentation

TextCorrection

Grammar and spelling correction with real-time feedback and async support.

View documentation

TextRewriter

Style transformation with predefined and custom writing styles.

View documentation

KeywordExtraction

Extract key terms and topics with configurable count and target language.

View documentation

TextExtraction

Extract structured data from unstructured content with schema definition.

View documentation

New

Compose prompts like programs.

Every prompt LM-Kit produces, including the system prompts driving conversations, agents, and skills, can flow through a full templating engine. Three syntaxes, filters, conditionals, loops, custom helpers. Compiled once, reused everywhere.

LM-Kit.NET pillars

Seven pillars, one foundation.

The seven pillars of LM-Kit.NET, plus the local runtime they share. Highlighted card is where you are now.

The foundation

Every capability above runs on this runtime.

Foundation

Local Inference

The runtime all seven pillars sit on. The LM-Kit.NET NuGet ships the complete inference system: open-weight LLMs, vision-language models, embeddings, on-device speech-to-text, OCR and classifiers, accelerated on CPU, AVX2, CUDA 12/13, Vulkan or Metal. One package, zero cloud calls, predictable latency, full data and technology sovereignty.

Explore the foundation

Ready to build AI-powered text generation?

Full control over content creation, summarization, and enhancement. 100% local, 100% your infrastructure.

Download free API documentation