LM-Kit.NET 2026.4.4

Released: Apr 23, 2026

Updates in 2026.4.4

Features

  • Introduced IKVCache public interface (LMKit.Inference): exposes residency, warmup, and hibernation capabilities on objects that own an inference KV-cache. Implemented by MultiTurnConversation, PdfChat, RagChat, and AgentExecutor (cast the instance to IKVCache to access).
    • Members:
      • KVCacheContent (textual projection of the cache).
      • Residency (current ContextResidency).
      • Warmup() (eagerly initializes the context or rehydrates it from disk so the first user-facing call is not penalized by lazy allocation).
      • HibernateAsync(string filePath = null) which serializes the full context state to disk, frees the in-memory handle, and rehydrates transparently on the next inference call. Background hibernation requests are coalesced and deferred while the context is actively in use.
  • Added ContextResidency enumeration (LMKit.Inference): lifecycle state of an inference context - NotCreated, InMemory, or Hibernated. Exposed via IKVCache.Residency.
  • Added ContextHibernationDirectory property to Configuration (LMKit.Global): folder used for auto-generated hibernation files when IKVCache.HibernateAsync is called without an explicit path. Defaults to the system temp folder (Path.GetTempPath()); the setter auto-creates the directory if it does not exist and throws ArgumentException on null/empty input.
  • Added the Markdown member to the TextOutputMode enumeration.
  • Introduced DocumentToMarkdownConverter (LMKit.Document.Conversion): end-to-end document - Markdown pipeline built for LLM ingestion. Accepts the full range of LM-Kit input modes (file path, byte[] + file name, Stream + file name, ImageBuffer, Uri, and pre-built Attachment) and exposes matching Convert / ConvertAsync overloads along with ConvertToFile / ConvertToFileAsync variants that write the Markdown directly to disk. Supports per-page observability and cancellation through the PageStarting and PageCompleted events.
  • Added DocumentToMarkdownStrategy enumeration (LMKit.Document.Conversion): selects how each page is converted. TextExtraction uses the embedded text layer (fast, no model required); VlmOcr rasterizes each page and transcribes it with a vision-language model; Hybrid applies a per-page decision, keeping born-digital pages on the text path while routing scanned pages through vision OCR; Auto resolves to the best available strategy based on the input and on whether a vision model is configured.
  • Added DocumentToMarkdownOptions (LMKit.Document.Conversion): exposes the full configuration surface of the converter, including strategy selection, 1-based PageRange filtering, TextOutputMode for the text-extraction path, VLM OCR tuning (VlmImageDetail, VlmMaximumCompletionTokens, VlmStripImageMarkup, VlmStripStyleAttributes), the hybrid HybridMinTextLength threshold, output shaping (IncludePageSeparators, PageSeparatorFormat, EmitFrontMatter, NormalizeWhitespace), and forwarded DOCX/EML options.
  • Added DocumentToMarkdownResult and DocumentToMarkdownPageResult (LMKit.Document.Conversion): carry the aggregated Markdown, per-page diagnostics (StrategyUsed, Elapsed, GeneratedTokenCount, QualityScore, Warning), requested vs. effective strategy, source name, and total elapsed time.
  • Added DocumentConversionPageStartingEventArgs and DocumentConversionPageCompletedEventArgs (LMKit.Document.Conversion): event payloads for the converter's page-level lifecycle, exposing PageIndex/PageNumber/PageCount, SourceName, PlannedStrategy, a Cancel flag, and the PageResult/Exception captured for each page.
  • Added encrypted GGUF model loading (LMKit.Cryptography, LMKit.Model): new static LM.LoadEncrypted(string path, GgufEncryptionScheme scheme, string password, ...) factory loads a GGUF model from an LM-Kit encrypted container, decrypting tensor bytes on the fly from disk. The plaintext GGUF is never materialized in memory nor written back to disk: only the metadata block (a few MB) plus one tensor's worth of bytes at a time are ever decrypted. Intended for commercial deployments that need to protect model-file copyright on-device.
  • Added EncryptedGguf static helper (LMKit.Cryptography): EncryptedGguf.Encrypt(plaintextGguf, outputLmke, scheme, password) streams a plaintext GGUF through AES-256-CTR (PBKDF2-HMAC-SHA256 key derivation, 100k iterations) into an .lmke container. EncryptedGguf.Reader.Open(path, password) exposes seekable, per-range decrypted reads for advanced scenarios.
  • Added GgufEncryptionScheme enumeration (LMKit.Cryptography): lists supported schemes. Ships with AesCtr256 (seekable stream cipher required for per-tensor decryption during load).
  • Added demo encrypted_model_loading (demos/console_net): end-to-end walkthrough that downloads a small model from the LM-Kit catalog, encrypts it to an .lmke container, loads it via LM.LoadEncrypted, and drives a multi-turn chat.