mirror of
https://github.com/qdrant/fastembed.git
synced 2026-08-04 00:51:08 -05:00
prev -: https://qdrant.github.io/fastembed/examples/Retrieval%20with%20FastEmbed/ now -: https://qdrant.github.io/fastembed/examples/Retrieval_with_FastEmbed/
1.5 KiB
1.5 KiB
⚡️ What is FastEmbed?
FastEmbed is an easy to use -- lightweight, fast, Python library built for retrieval embedding generation.
The default embedding supports "query" and "passage" prefixes for the input text. The default model is Flag Embedding, which is top of the MTEB leaderboard.
Advanced user? Skip ahead to Retrieval with FastEmbed
To install the FastEmbed library, pip works:
pip install fastembed
📖 Usage
from fastembed.embedding import DefaultEmbedding
documents: List[str] = [
"passage: Hello, World!",
"query: Hello, World!", # these are two different embedding
"passage: This is an example passage.",
# You can leave out the prefix but it's recommended
"fastembed is supported by and maintained by Qdrant."
]
embedding_model = DefaultEmbedding()
embeddings: List[np.ndarray] = list(embedding_model.embed(documents))
🚒 Under the hood
Why fast?
It's important we justify the "fast" in FastEmbed. FastEmbed is fast because:
- Quantized model weights
- ONNX Runtime which allows for inference on CPU, GPU, and other dedicated runtimes
Why light?
- No hidden dependencies on PyTorch or TensorFlow via Huggingface Transformers
Why accurate?
- Better than OpenAI Ada-002
- Top of the Embedding leaderboards e.g. MTEB