FastEmbed Library

0.8.0 · active · verified Fri Apr 10

FastEmbed is a fast, light, and accurate Python library for generating retrieval embeddings, designed for efficiency with ONNX Runtime. It supports a variety of models including dense text embeddings, sparse embeddings, and rerankers. The current version is 0.8.0, and it maintains an active release cadence with frequent updates.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize a `TextEmbedding` model, download it if necessary, and then generate embeddings for a list of documents. It uses the `BAAI/bge-small-en-v1.5` model as an example.

from fastembed import TextEmbedding

# Initialize the embedding model. Model will be downloaded if not cached.
# Pass specific_model_path for local models, or use local_files_only=True
model = TextEmbedding(model_name="BAAI/bge-small-en-v1.5")

documents = [
    "This is a document about the weather in London. It's quite rainy.",
    "The quick brown fox jumps over the lazy dog.",
    "Python is a high-level, interpreted programming language."
]

# Embed the documents
embeddings = model.embed(documents)

print(f"Generated {len(embeddings)} embeddings.")
print(f"First embedding shape: {embeddings[0].shape}")
print(f"First embedding (first 5 values): {embeddings[0][:5]}")

view raw JSON →