Hugging Face¶
- class HuggingFaceEmbedding¶
HuggingFace sentence_transformers embedding models.
- Parameters:
model_name (str) – Hugging Face model to be used. Defaults to sentence-transformers/all-MiniLM-L6-v2.
device (str, optional) – Device to run the model on. Supports cpu and cuda. Defaults to cpu.
Example
from pineflow.embeddings.huggingface import HuggingFaceEmbedding embedding = HuggingFaceEmbedding()
- get_documents_embedding(documents)¶
Compute embeddings for a list of documents.
- Parameters:
documents (List[Document]) – List of documents to compute embeddings.
- get_text_embedding(query)¶
Compute embedding for a text.
- Parameters:
query (str) – Input query to compute the embedding.
Example
embedded_query = embedding.get_text_embedding( "Pineflow is a data framework to load any data in one line of code and connect with AI applications." )
- get_texts_embedding(texts)¶
Compute embeddings for a list of texts.
- Parameters:
texts (List[str]) – A list of input strings for which to compute embeddings.