Skip to content

Hugging Face

% pip install novastack-embeddings-huggingface

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 novastack.embeddings.huggingface import HuggingFaceEmbedding

embedding = HuggingFaceEmbedding()

get_text_embeddings #

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

Embed one or more text strings.

Parameters:

Name Type Description Default
input str | list[str]

Single text string or list of text strings to embed

required

get_document_embeddings #

get_document_embeddings(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