Table of Contents

Constructor DocumentRag

Namespace
LMKit.Retrieval
Assembly
LM-Kit.NET.dll

DocumentRag(LM, IVectorStore)

Initializes a new instance of the DocumentRag class with the specified embedding model.

public DocumentRag(LM embeddingModel, IVectorStore vectorStore = null)

Parameters

embeddingModel LM

The embedding model to use for generating vector embeddings from document text.

vectorStore IVectorStore

An optional IVectorStore for persisting embeddings. If null, an in-memory store is used.

Examples

// Basic setup for digital documents
LM embeddingModel = LM.LoadFromModelID("embeddinggemma-300m");
DocumentRag docRag = new DocumentRag(embeddingModel);

// Setup with OCR for scanned documents
DocumentRag docRagWithOcr = new DocumentRag(embeddingModel)
{
    OcrEngine = new OcrEngine()
};

// Setup with vision parser for complex layouts
LM visionModel = LM.LoadFromModelID("qwen3-vl:4b");
DocumentRag docRagWithVision = new DocumentRag(embeddingModel)
{
    VisionParser = new VlmOcr(visionModel)
};

// Setup with persistent storage
IVectorStore store = new SqliteVectorStore("documents.db");
DocumentRag persistentDocumentRag = new DocumentRag(embeddingModel, store);

Remarks

After construction, configure OcrEngine and/or VisionParser as needed for your document types. For simple text-based documents (e.g., digital PDFs with embedded text), no additional configuration is required.

Exceptions

ArgumentNullException

Thrown if embeddingModel is null.