HuggingFace¶
Computing text embeddings using HuggingFace models.
API Reference
from spyder_index.embeddings import HuggingFaceEmbeddings
HuggingFaceEmbeddings(model_name, device)
Initialize a HuggingFaceEmbeddings.
model_name
(str, optional): Name of the HuggingFace model to be used. Defaults tosentence-transformers/all-MiniLM-L6-v2
.device
(Literal[“cpu”, “cuda”], optional): Device to run the model on. Defaults tocpu
.
get_query_embedding(query)
Compute embedding for a query.
text
(str): Input query to compute embedding.
get_embedding_from_texts(texts)
Compute embeddings for a list of texts.
texts
(List[str])
get_documents_embedding(documents)
Compute embeddings for a list of Documents.
documents
(List[Documents])