Divooka.LLM.VectorEmbedding

Divooka.LLM.VectorEmbedding.IVectorObject

Represents an object that contains a vector representation.

Divooka.LLM.VectorEmbedding.IVectorObject.GetVector

Retrieves the vector representation of the object.

Returns

An array of floats representing the vector.

Divooka.LLM.VectorEmbedding.DataChunk

Represents a chunk of data containing text and its associated vector representation.

Divooka.LLM.VectorEmbedding.DataChunk.Text

Gets or sets the text content of the data chunk.

Divooka.LLM.VectorEmbedding.DataChunk.Vector

Gets or sets the vector representation of the data chunk.

Remarks

The vector is expected to correspond to the text in a meaningful way.

Divooka.LLM.VectorEmbedding.DataChunk.GetVector

Retrieves the vector representation of the data chunk.

Returns

An array of floats representing the vector.

Divooka.LLM.VectorEmbedding.InMemoryVectorDatabase`1

A quick implementation for in-memory vector database with querying capability.

Remarks

TODO: Pending abstraction and provide as a Zora package.

Divooka.LLM.VectorEmbedding.InMemoryVectorDatabase`1.VectorMath

Provides helper methods for vector mathematics.

Divooka.LLM.VectorEmbedding.InMemoryVectorDatabase`1.VectorMath.Length()

Computes the Euclidean length (magnitude) of the specified vector.

Parameters

NameDescriptionDefault
vector An array of floats representing the vector.

Returns

The Euclidean length of the vector.

Divooka.LLM.VectorEmbedding.InMemoryVectorDatabase`1.VectorMath.NormalizeVector()

Normalizes the specified vector so that it has a length of 1.

Parameters

NameDescriptionDefault
vector An array of floats representing the vector to normalize.

Returns

The normalized vector.

Divooka.LLM.VectorEmbedding.InMemoryVectorDatabase`1.VectorMath.DotProduct()

Computes the dot product of two vectors.

Parameters

NameDescriptionDefault
a The first vector.
b The second vector.

Returns

The dot product of the two vectors.

Divooka.LLM.VectorEmbedding.InMemoryVectorDatabase`1.Objects

The internal collection of vector objects.

Divooka.LLM.VectorEmbedding.InMemoryVectorDatabase`1.Dimensions

Gets the number of dimensions for the vectors in the database.

Divooka.LLM.VectorEmbedding.InMemoryVectorDatabase`1.#ctor()

Initializes a new instance of the Divooka.LLM.VectorEmbedding.InMemoryVectorDatabase`1 class with the specified number of dimensions.

Parameters

NameDescriptionDefault
dimensions The number of dimensions for the vectors.

Divooka.LLM.VectorEmbedding.InMemoryVectorDatabase`1.Add()

Adds a vector object to the database.

Parameters

NameDescriptionDefault
obj The vector object to add.

Divooka.LLM.VectorEmbedding.InMemoryVectorDatabase`1.AddRange()

Adds a collection of vector objects to the database.

Parameters

NameDescriptionDefault
objects The collection of vector objects to add.

Divooka.LLM.VectorEmbedding.InMemoryVectorDatabase`1.GetItem()

Retrieves the vector object at the specified index.

Parameters

NameDescriptionDefault
index The zero-based index of the vector object to retrieve.

Returns

The vector object at the specified index.

Divooka.LLM.VectorEmbedding.InMemoryVectorDatabase`1.FindNearest()

Finds the nearest vector objects to the specified query vector.

Parameters

NameDescriptionDefault
query The query vector to compare against.
count The maximum number of nearest vector objects to return. Default is 1.

Returns

An enumerable of the nearest vector objects ordered by similarity (highest dot product first).

Divooka.LLM.VectorEmbedding.InMemoryVectorDatabase`1.SaveToDisk()

Serializes the current vector database to a JSON file at the specified path.

Parameters

NameDescriptionDefault
path The file path where the JSON representation will be saved.

Divooka.LLM.VectorEmbedding.InMemoryVectorDatabase`1.LoadFromDisk()

Deserializes a vector database from a JSON file at the specified path.

Parameters

NameDescriptionDefault
path The file path from which to load the JSON representation.

Returns

An instance of Divooka.LLM.VectorEmbedding.InMemoryVectorDatabase`1 populated with the data from the file.

Divooka.LLM.VectorEmbedding.VectorStore

Represents a store for vector embeddings with associated names and texts.

Remarks

This class provides serialization and deserialization routines to persist and retrieve vector data.

Divooka.LLM.VectorEmbedding.VectorStore.Names

Gets or sets the array of names associated with the vectors.

Divooka.LLM.VectorEmbedding.VectorStore.Vectors

Gets or sets the array of vectors.

Divooka.LLM.VectorEmbedding.VectorStore.Texts

Gets or sets the array of texts associated with the vectors.

Divooka.LLM.VectorEmbedding.VectorStore.Dimensions

Gets the number of dimensions of each vector.

Divooka.LLM.VectorEmbedding.VectorStore.Count

Gets the count of vectors stored.

Divooka.LLM.VectorEmbedding.VectorStore.#ctor()

Initializes a new instance of the Divooka.LLM.VectorEmbedding.VectorStore class with specified names, vectors, and texts.

Parameters

NameDescriptionDefault
names An array of names for the vectors.
values A jagged array of float values representing the vectors.
texts An array of texts associated with the vectors.

Divooka.LLM.VectorEmbedding.VectorStore.Item()

Gets the vector store item at the specified index.

Parameters

NameDescriptionDefault
index The index of the item to retrieve.

Returns

A tuple containing the name, vector, and text associated with the specified index.

Divooka.LLM.VectorEmbedding.VectorStore.Deserialize()

Deserializes a Divooka.LLM.VectorEmbedding.VectorStore from a file.

Parameters

NameDescriptionDefault
filePath The file path from which to deserialize the vector store.

Returns

A new instance of Divooka.LLM.VectorEmbedding.VectorStore containing the deserialized data.

Divooka.LLM.VectorEmbedding.VectorStore.Deserialize()

Deserializes a Divooka.LLM.VectorEmbedding.VectorStore from a stream.

Parameters

NameDescriptionDefault
stream The stream containing the serialized vector store data.

Returns

A new instance of Divooka.LLM.VectorEmbedding.VectorStore containing the deserialized data.

Divooka.LLM.VectorEmbedding.VectorStore.Serialize()

Serializes the current Divooka.LLM.VectorEmbedding.VectorStore to a file.

Parameters

NameDescriptionDefault
filePath The file path where the vector store will be written.