Constructor RagEngine
RagEngine(LM, IVectorStore)
Initializes a new instance of the RagEngine class with a single embedding model.
public RagEngine(LM embeddingModel, IVectorStore vectorStore = null)
Parameters
embeddingModelLMThe embedding model to use for generating vector embeddings.
vectorStoreIVectorStoreAn 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
embeddingModelisnull.
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
embeddingModelsIEnumerable<LM>A collection of embedding models to register. Must contain at least one model.
vectorStoreIVectorStoreAn 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
embeddingModelsisnullor empty.- ArgumentException
Thrown if the embedding models have different embedding dimensions.