init_embedding_model(
embedding_model: str,
embedding_engine: str
) → EmbeddingModel
Initialize the embedding model.
Basic implementation of an embeddings index.
It uses sentence-transformers/all-MiniLM-L6-v2
to compute the embeddings. It uses Annoy to perform the search.
__init__(embedding_model=None, embedding_engine=None, index=None)
add_item(item: nemoguardrails.embeddings.index.IndexItem)
Add a single item to the index.
add_items(items: List[nemoguardrails.embeddings.index.IndexItem])
Add multiple items to the index at once.
build()
Builds the Annoy index.
search(
text: str,
max_results: int = 20
) → List[nemoguardrails.embeddings.index.IndexItem]
Search the closest max_results
items.
Embedding model using sentence-transformers.
__init__(embedding_model: str)
encode(documents: List[str]) → List[List[float]]
Embedding model using OpenAI API.
__init__(embedding_model: str)
encode(documents: List[str]) → List[List[float]]
Encode a list of documents into embeddings.