FlagEmbedding
FlagEmbedding
What it is and what it does
FlagEmbedding is a toolkit for building semantic search and RAG systems using pre-trained embedding and reranking models. It wraps transformer-based models that convert text into dense vector representations, enabling similarity-based retrieval. The package integrates with torch, transformers, and sentence_transformers to handle model loading, inference, and fine-tuning workflows.
The toolkit supports multilingual queries, variable input lengths, and multiple retrieval strategies (dense, lexical, and multi-vector). It is commonly used to rank and retrieve relevant documents for LLM prompts, implement semantic search over document collections, and fine-tune embedding models on domain-specific data.
Use it for:
- Build a semantic search engine over a document corpus by encoding documents and queries into embeddings and finding nearest neighbors.
- Implement retrieval-augmented generation (RAG) by retrieving relevant documents to augment LLM context before generation.
- Re-rank top-k search results using reranker models to improve relevance of retrieved documents.
- Fine-tune embedding models on custom datasets to optimize for domain-specific or task-specific retrieval.
- Support multilingual search applications where queries and documents span multiple languages.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
FlagEmbedding provides embedding and reranking models for semantic search and retrieval-augmented generation (RAG), supporting dense retrieval, multilingual queries, and document ranking.
Yes, with conditions. FlagEmbedding is actively maintained with no known vulnerabilities. Install if you need semantic search or RAG capabilities and can accommodate the heavy ML dependencies (torch, transformers). Verify the license terms in the repository first, as the package metadata does not declare a clear license. Not suitable if you need a lightweight embedding solution or cannot install PyTorch.
Install
flagembedding on PyPI
pip
pip install flagembeddinguv
uv add flagembeddingpoetry
poetry add flagembeddingInstalling FlagEmbedding
Before you install
Low friction installation with a pure Python wheel. Active maintenance with recent commits and a large repository (12050 stars). Depends on heavy ML libraries (torch, transformers, sentence_transformers) that may require significant disk and memory.
License in practice
License status is unclear—no SPDX identifier or raw license text is available in the package metadata. Verify the actual license terms in the repository before use in proprietary or commercial projects.
Quickstart
pip install flagembedding
from flagembedding import FlagModel
model = FlagModel('BAAI/bge-small-en-v1.5')
embeddings = model.encode(['hello world'])
Requires torch and transformers; model downloads are large and may require significant disk space and network bandwidth on first use.
Verify before relying
- Exact Python version compatibility (requires_python not specified in metadata)
- Whether all 9 runtime dependencies are always required or only for specific use cases
- Performance characteristics and typical latency for embedding generation
Package facts
| License | not declared (unclear) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 9 — torch, transformers, datasets, accelerate, sentence_transformers, peft, ir-datasets, sentencepiece, protobuf |
| Maintenance | actively maintained — 114 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 632,761/month — #5,649 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: flagembedding-1.4.0-py3-none-any.whl
Tags
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to…
permissive · top 100 on PyPI
huggingface-hubClient library and CLI tool for downloading,…
permissive · top 100 on PyPI
langchainLangChain provides a framework for building…
permissive · top 1,000 on PyPI
hf-xethf-xet provides chunk-based deduplication and…
permissive · top 1,000 on PyPI
tokenizersTokenizers converts raw text into token…
permissive · top 1,000 on PyPI
transformersTransformers provides a unified framework for…
permissive · top 1,000 on PyPI
colpali-engineColPali-engine provides training and inference…
permissive · top 15,000 on PyPI
FlashRankFlashRank re-ranks search results using…
permissive · top 15,000 on PyPI
voyageaiProvides Python access to Voyage AI's embedding…
permissive · top 5,000 on PyPI
mtebMTEB evaluates text and multimodal embeddings…
permissive · top 5,000 on PyPI
fastembedFastEmbed generates vector embeddings for text,…
permissive · top 5,000 on PyPI
InstructorEmbeddingInstructorEmbedding generates task-specific…
permissive · top 15,000 on PyPI
sentence-transformersComputes embeddings and reranking scores for…
permissive · top 1,000 on PyPI
lightrag-hkuLightRAG is a retrieval-augmented generation…
permissive · top 15,000 on PyPI
colbert-aiColBERT is a BERT-based retrieval model that…
unclear · top 15,000 on PyPI
model2vecModel2Vec converts sentence transformers into…
permissive · top 5,000 on PyPI