Skip to content

Hugging Face

HuggingFaceEmbedding #

Bases: BaseEmbedding

HuggingFace sentence_transformers embedding models.

Attributes:

Name Type Description
model_name str

Hugging Face model to be used. Defaults to sentence-transformers/all-MiniLM-L6-v2.

device str

Device to run the model on. Supports cpu and cuda. Defaults to cpu.

Example
from beekeeper.embeddings.huggingface import HuggingFaceEmbedding

embedding = HuggingFaceEmbedding()

embed_documents #

embed_documents(documents: list[Document]) -> list[Document]

Embed a list of documents and assign the computed embeddings to the 'embedding' attribute.

Parameters:

Name Type Description Default
documents list[Document]

List of documents to compute embeddings.

required

embed_text #

embed_text(input: str | list[str]) -> list[Embedding]

Embed one or more text strings.

Parameters:

Name Type Description Default
input list[str]

Input for which to compute embeddings.

required