nemoguardrails.embeddings.basic
Module Contents
Classes
Data
API
Bases: EmbeddingsIndex
Basic implementation of an embeddings index.
It uses the sentence-transformers/all-MiniLM-L6-v2 model to compute embeddings.
Annoy is employed for efficient nearest-neighbor search.
Get the cache configuration.
Get the size of the embeddings.
Get the computed embeddings.
Get the current embedding index
Compute embeddings for a list of texts.
Parameters:
The list of texts to compute embeddings for.
Returns: List[List[float]]
List[List[float]]: The computed embeddings.
Initialize the model used for computing the embeddings.
Runs the current batch of embeddings.
Add a single item to the index.
Parameters:
The item to add to the index.
Add multiple items to the index at once.
Parameters:
The list of items to add to the index.
Builds the Annoy index.
Search the closest max_results items.
Parameters:
The text to search for.
The maximum number of results to return. Defaults to 20.
Returns: List[IndexItem]
List[IndexItem]: The closest items found.