Method CreateInMemoryDataSource
CreateInMemoryDataSource(string, LM, MetadataCollection)
Creates a new in-memory DataSource instance with the specified identifier and language model. This instance can subsequently be saved to a file using one of the Serialize methods.
public static DataSource CreateInMemoryDataSource(string identifier, LM model, MetadataCollection metadata = null)
Parameters
identifierstringThe unique identifier for the data source.
modelLMThe language model to be associated with the data source.
metadataMetadataCollectionOptional metadata to be associated with the data source.
Returns
- DataSource
A new in-memory DataSource instance that can later be persisted to disk via the Serialize(string) or Serialize(Stream) methods.
Examples
using LMKit.Model;
using LMKit.Data;
using System;
// Load an embedding model
LM embeddingModel = LM.LoadFromModelID("embeddinggemma-300m");
// Create in-memory data source
DataSource dataSource = DataSource.CreateInMemoryDataSource("my-docs", embeddingModel);
Console.WriteLine($"Created: {dataSource.Identifier}");
Console.WriteLine($"Embedding size: {dataSource.EmbeddingSize}");
// Later, save to file
dataSource.Serialize("my-docs.lmkds");
CreateInMemoryDataSource(string, int, MetadataCollection)
Creates a new in-memory DataSource instance with the specified identifier and embedding size. This instance can subsequently be saved to a file using one of the Serialize methods.
public static DataSource CreateInMemoryDataSource(string identifier, int embeddingSize, MetadataCollection metadata = null)
Parameters
identifierstringThe unique identifier for the data source.
embeddingSizeintThe dimensionality of the vector embeddings for this data source.
metadataMetadataCollectionOptional metadata to be associated with the data source.
Returns
- DataSource
A new in-memory DataSource instance that can later be persisted to disk via the Serialize(string) or Serialize(Stream) methods.
Exceptions
- ArgumentNullException
Thrown if
identifieris null or empty.