Table of Contents

Constructor RagEngine

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

RagEngine(LM, IVectorStore)

Initializes a new instance of the RagEngine class with a single embedding model.

public RagEngine(LM embeddingModel, IVectorStore vectorStore = null)

Parameters

embeddingModel LM

The embedding model to use for generating vector embeddings.

vectorStore IVectorStore

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

Examples

LM embeddingModel = LM.LoadFromModelID("embeddinggemma-300m");
RagEngine ragEngine = new RagEngine(embeddingModel);

Console.WriteLine("RagEngine created successfully.");

Exceptions

ArgumentNullException

Thrown if embeddingModel is null.

RagEngine(IEnumerable<LM>, IVectorStore)

Initializes a new instance of the RagEngine class with multiple embedding models.

public RagEngine(IEnumerable<LM> embeddingModels, IVectorStore vectorStore = null)

Parameters

embeddingModels IEnumerable<LM>

A collection of embedding models to register. Must contain at least one model.

vectorStore IVectorStore

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

Examples

// Multimodal RAG with text and vision models
LM textModel = LM.LoadFromModelID("embeddinggemma-300m");
LM visionModel = LM.LoadFromModelID("nomic-embed-vision");

RagEngine ragEngine = new RagEngine(new[] { textModel, visionModel });

Remarks

Use this constructor for multimodal retrieval-augmented generation when you need both text-only and vision-enabled embedding models.

Important: All provided models must share the same embedding space (same dimension and coordinate system); otherwise, similarity lookups will produce invalid results.

Exceptions

ArgumentNullException

Thrown if embeddingModels is null or empty.

ArgumentException

Thrown if the embedding models have different embedding dimensions.