Discover / RAG & Knowledge
FlagEmbedding
by FlagOpenPython
Open source library for training and using state of the art text embedding models.
Maturity: active because commit 103d ago, latest release v1.4.0. Derived from release and commit history, not a rating.
- Stars
- 12k
- Forks
- 904
- Downloads / mo
- —
- Last commit
- 2026-04-22
- License
- MIT
- Open issues
- 908
Market and trust evidence
Edition not yet matchedNo exact skills.sh identity match is available for this repository. Repository adoption and freshness remain visible above; install momentum is not inferred.
Trust analysis is a screening signal, not a security warranty. Read the ranking and trust methodology.
In practice
Written by AI from this repository’s README · low confidenceBuilding search or RAG needs embedding and reranking models plus the code to run and fine tune them.
Use it when
Use it when you want BGE family embedding or reranker models, including multilingual and multimodal variants.
Not the right pick when
The README is a long news log rather than a guide, so installation and usage live in the external documentation.
Capabilities
- BGE embedding models for retrieval
- rerankers including lightweight gemma2 based variants
- BGE-VL multimodal embedding for visual search
- bge-en-icl embeddings with in context learning
- C-MTEB benchmark resources
- tutorials directory kept up to date
Cost: Free and open source
Install
Derived from the published package name in the repository, not from a model.
Video walkthroughs
Third-party YouTube uploads matched to this tool by title, channel and repository name on 2026-08-03. Not made, reviewed or endorsed by SkillPilot. View counts and publish months are as of the match date and the month is approximate. Nothing loads from YouTube until you press play.
What the repository ships
Detected from the actual files in the repository root.
Latest release v1.4.0
Published 2026-04-22
What's Changed
- update reranker inference by @545999961 in https://github.com/FlagOpen/FlagEmbedding/pull/1466
- add feature: support customized
train_group_sizeby @hanhainebula in https://github.com/FlagOpen/FlagEmbedding/pull/1491 - disable warning info: train_group_size is None by @hanhainebula in https://github.com/FlagOpen/FlagEmbedding/pull/1492
- Release BGE-Reasoner-preview by @hanhainebula in https://github.com/FlagOpen/FlagEmbedding/pull/1510
- fix bold values in README of BGE-Reasoner by @hanhainebula in https://github.com/FlagOpen/FlagEmbedding/pull/1511
- fix link in README of BGE-Reasoner by @hanhainebula in https://github.com/FlagOpen/FlagEmbedding/pull/1512
- Update BGE-Reasoner: new SOTA on BRIGHT by @hanhainebula in https://github.com/FlagOpen/FlagEmbedding/pull/1514
- Fix BGE-Reasoner Table & Results Sources by @hanhainebula in https://github.com/FlagOpen/FlagEmbedding/pull/1516
- Add Qwen3-Embedding-8B baseline for BGE-Reasoner by @hanhainebula in https://github.com/FlagOpen/FlagEmbedding/pull/1517
- Update BGE-Reasoner by @hanhainebula in https://github.com/FlagOpen/FlagEmbedding/pull/1522
- Update BGE-Reasoner and add
use_fast_tokenizerparam for finetuning by @hanhainebula in https://github.com/FlagOpen/FlagEmbedding/pull/1526 - fix abc/evaluation/runner.py: evaluate_metrics by @hanhainebula in https://github.com/FlagOpen/FlagEmbedding/pull/1527
- Update BGE-Reasoner: Release v0923 embedder by @hanhainebula in https://github.com/FlagOpen/FlagEmbedding/pull/1528
- Update modeling_mapping for embedder and update README of BGE-Reasoner by @hanhainebula in https://github.com/FlagOpen/FlagEmbedding/pull/1531
- fix bug: safe dist.get_rank() by @hanhainebula in https://github.com/FlagOpen/FlagEmbedding/pull/1532
- Support evaluation: BRIGHT by @hanhainebula in https://github.com/FlagOpen/FlagEmbedding/pull/1534
- update examples README: support BRIGHT evaluation by @hanhainebula in https://github.com/FlagOpen/FlagEmbedding/pull/1535
- fix bug: pytrec_eval installation issue by @hanhainebula in https://github.com/FlagOpen/FlagEmbedding/pull/1538
- add metric for evaluation: evaluate_recall_cap by @hanhainebula in https://github.com/FlagOpen/FlagEmbedding/pull/1553
- feat: add compatibility with transformers V5 by @therealmichaelberna in https://github.com/FlagOpen/FlagEmbedding/pull/1563
- Feat(embedder) use bf16 and fix the interface of attn_implementation in embedder.decode_only by @lnxtree in https://github.com/FlagOpen/FlagEmbedding/pull/1566
- fix(m3): make bf16 inference/train loading safe and unify numpy conversion by @lnxtree in https://github.com/FlagOpen/FlagEmbedding/pull/1567
- fix(eval): pass use_bf16 through AbsEvalRunner.get_model and COIR evaluator model initialization by @lnxtree in https://github.com/FlagOpen/FlagEmbedding/pull/1568
- feat: add use_mrl interface of finetune for embedder and truncate_dim for inference of embedder(MRL) by @lnxtree in https://github.com/FlagOpen/FlagEmbedding/pull/1570
- feat(embedder): Add decoder-only pseudo_moe inference with domain routing support by @lnxtree in https://github.com/FlagOpen/FlagEmbedding/pull/1572
- chore: update version to 1.4.0 in setup.py by @hanhainebula in https://github.com/FlagOpen/FlagEmbedding/pull/1575
New Contributors
- @therealmichaelberna made their first contribution in https://github.com/FlagOpen/FlagEmbedding/pull/1563
- @lnxtree made their first contribution in https://github.com/FlagOpen/FlagEmbedding/pull/1566
Full Changelog: https://github.com/FlagOpen/FlagEmbedding/compare/v1.3.5...v1.4.0
Tags
README
<img src="./imgs/FlagOpen.png">
<h1 align="center">⚡️BGE: One-Stop Retrieval Toolkit For Search and RAG</h1>
bge_logo
<p align="center">
<a href="https://huggingface.co/collections/BAAI/bge-66797a74476eb1f085c7446d">
<img alt="Build" src="https://img.shields.io/badge/BGE_series-🤗-yellow">
</a>
<a href="https://github.com/FlagOpen/FlagEmbedding">
<img alt="Build" src="https://img.shields.io/badge/Contribution-Welcome-blue">
</a>
<a href="https://github.com/FlagOpen/FlagEmbedding/blob/master/LICENSE">
<img alt="License" src="https://img.shields.io/badge/LICENSE-MIT-green">
</a>
<a href="https://huggingface.co/C-MTEB">
<img alt="Build" src="https://img.shields.io/badge/C_MTEB-🤗-yellow">
</a>
<a href="https://github.com/FlagOpen/FlagEmbedding/tree/master/research/baai_general_embedding">
<img alt="Build" src="https://img.shields.io/badge/FlagEmbedding-1.3.0-red">
</a>
</p>
<h4 align="center">
<p>
<a href=#news>News</a> |
<a href=#installation>Installation</a> |
<a href=#quick-start>Quick Start</a> |
<a href=#community>Community</a> |
<a href="https://github.com/FlagOpen/FlagEmbedding/tree/master/research">Projects</a> |
<a href=#model-list>Model List</a> |
<a href="#contributors">Contributor</a> |
<a href="#citation">Citation</a> |
<a href="#license">License</a>
<p>
</h4>
English | 中文
News
- 3/6/2025: :fire::fire: Introduce BGE-VL (HF repo), State-Of-The-Art multimodal embedding models to support Any visual search applications (everything, including text-to-image, image-to-text, image&prompt-to-image, text-to-image&text, and more)! They are released under the MIT license and are completely free for both academic and commercial use. We also release MegaPairs (repo, paper), a massive synthetic dataset which empowers BGE-VL!
- 12/5/2024: :book: We built the BGE documentation for centralized BGE information and materials!
- 10/29/2024: :earth_asia: We created WeChat group for BGE. Scan the QR code to join the group chat! To get the first hand message about our updates and new release, or having any questions or ideas, join us now!
- <img src="./imgs/BGE_WeChat_Group.png" alt="bge_wechat_group" class="center" width="200">
- 10/22/2024: We release another interesting model: OmniGen, which is a unified image generation model supporting various tasks. OmniGen can accomplish complex image generation tasks without the need for additional plugins like ControlNet, IP-Adapter, or auxiliary models such as pose detection and face detection.
- 9/10/2024: Introducing MemoRAG, a step forward towards RAG 2.0 on top of memory-inspired knowledge discovery (repo: https://github.com/qhjqhj00/MemoRAG, paper: https://arxiv.org/pdf/2409.05591v1)
- 9/2/2024: Start to maintain the tutorials. The contents within will be actively updated and eariched, stay tuned! :books:
- 7/26/2024: Release a new embedding model bge-en-icl, an embedding model that incorporates in-context learning capabilities, which, by providing task-relevant query-response examples, can encode semantically richer queries, further enhancing the semantic representation ability of the embeddings.
- 7/26/2024: Release a new embedding model bge-multilingual-gemma2, a multilingual embedding model based on gemma-2-9b, which supports multiple languages and diverse downstream tasks, achieving new SOTA on multilingual benchmarks (MIRACL, MTEB-fr, and MTEB-pl).
- 7/26/2024: Release a new lightweight reranker bge-reranker-v2.5-gemma2-lightweight, a lightweight reranker based on gemma-2-9b, which supports token compression and layerwise lightweight operations, can still ensure good performance while saving a significant amount of resources. :fire:
<details>
<summary>More</summary>
<!-- ### More -->
- 6/7/2024: Release a new benchmark MLVU, the first comprehensive benchmark specifically designed for long video understanding. MLVU features an extensive range of video durations, a diverse collection of video sources, and a set of evaluation tasks uniquely tailored for long-form video understanding. :fire:
- 5/21/2024: Release a new benchmark AIR-Bench together with Jina AI, Zilliz, HuggingFace, and other partners. AIR-Bench focuses on a fair out-of-distribution evaluation for Neural IR & RAG. It generates the synthetic data for benchmarking w.r.t. diverse domains and languages. It is dynamic and will be updated on regular basis. Leaderboard :fire:
- 4/30/2024: Release Llama-3-8B-Instruct-80K-QLoRA, extending the context length of Llama-3-8B-Instruct from 8K to 80K via QLoRA training on a few synthesized long-context data. The model achieves remarkable performance on various long-context benchmarks. Code :fire:
- 3/18/2024: Release new rerankers, built upon powerful M3 and LLM (GEMMA and MiniCPM, not so large actually :smiley:) backbones, supporitng multi-lingual processing and larger inputs, massive improvements of ranking performances on BEIR, C-MTEB/Retrieval, MIRACL, LlamaIndex Evaluation :fire:
- 3/18/2024: Release Visualized-BGE, equipping BGE with visual capabilities. Visualized-BGE can be utilized to generate embeddings for hybrid image-text data. :fire:
- 1/30/2024: Release BGE-M3, a new member to BGE model series! M3 stands for Multi-linguality (100+ languages), Multi-granularities (input length up to 8192), Multi-Functionality (unification of dense, lexical, multi-vec/colbert retrieval).
It is the first embedding model which supports all three retrieval methods, achieving new SOTA on multi-lingual (MIRACL) and cross-lingual (MKQA) benchmarks.
Technical Report and Code. :fire:
- 1/9/2024: Release Activation-Beacon, an effective, efficient, compatible, and low-cost (training) method to extend the context length of LLM. Technical Report
- 12/24/2023: Release LLaRA, a LLaMA-7B based dense retriever, leading to state-of-the-art performances on MS MARCO and BEIR. Model and code will be open-sourced. Please stay tuned. Technical Report and Code
- 11/23/2023: Release LM-Cocktail, a method to maintain general capabilities during fine-tuning by merging multiple language models. Technical Report
- 10/12/2023: Release LLM-Embedder, a unified embedding model to support diverse retrieval augmentation needs for LLMs. Technical Report
- 09/15/2023: The technical report of BGE has been released
- 09/15/2023: The massive training data of BGE has been released
- 09/12/2023: New models:
- New reranker model: release cross-encoder models
BAAI/bge-reranker-baseandBAAI/bge-reranker-large, which are more powerful than embedding model. We recommend to use/fine-tune them to re-rank top-k documents returned by embedding models. - update embedding model: release
bge-*-v1.5embedding model to alleviate the issue of the similarity distribution, and enhance its retrieval ability without instruction. - 09/07/2023: Update fine-tune code: Add script to mine hard negatives and support adding instruction during fine-tuning.
- 08/09/2023: BGE Models are integrated into Langchain, you can use it like this; C-MTEB leaderboard is available.
- 08/05/2023: Release base-scale and small-scale models, best performance among the models of the same size 🤗
- 08/02/2023: Release
bge-large-*(short for BAAI General Embedding) Models, rank 1st on MTEB and C-MTEB benchmark! :tada: :tada: - 08/01/2023: We release the Chinese Massive Text Embedding Benchmark (C-MTEB), consisting of 31 test dataset.
</details>
BGE (BAAI General Embedding) focuses on retrieval-augmented LLMs, consisting of the following projects currently:
projects
Installation
Using pip:
If you do not want to finetune the models, you can install the package without the finetune dependency:
pip install -U FlagEmbedding
If you want to finetune the models, you can install the package with the finetune dependency:
pip install -U FlagEmbedding[finetune]
Install from sources:
Clone the repository and install
git clone https://github.com/FlagOpen/FlagEmbedding.git
cd FlagEmbedding
# If you do not need to finetune the models, you can install the package without the finetune dependency:
pip install .
# If you want to finetune the models, install the package with the finetune dependency:
# pip install .[finetune]
For development in editable mode:
# If you do not need to finetune the models, you can install the package without the finetune dependency:
pip install -e .
# If you want to finetune the models, install the package with the finetune dependency:
# pip install -e .[finetune]
Quick Start
First, load one of the BGE embedding model:
from FlagEmbedding import FlagAutoModel
model = FlagAutoModel.from_finetuned('BAAI/bge-base-en-v1.5',
query_instruction_for_retrieval="Represent this sentence for searching relevant passages:",
use_fp16=True)
Then, feed some sentences to the model and get their embeddings:
sentences_1 = ["I love NLP", "I love machine learning"]
sentences_2 = ["I love BGE", "I love text retrieval"]
embeddings_1 = model.encode(sentences_1)
embeddings_2 = model.encode(sentences_2)
Once we get the embeddings, we can compute similarity by inner product:
similarity = embeddings_1 @ embeddings_2.T
print(similarity)
For more details, you can refer to embedder inference, reranker inference, embedder finetune, reranker fintune, evaluation.
If you're unfamiliar with any of related concepts, please check out the tutorial. If it's not there, let us know.
For more interesting topics related to BGE, take a look at research.
Community
We are actively maintaining the community of BGE and FlagEmbedding. Let us know if you have any suggessions or ideas!
Currently we are updating the tutorials, we aim to create a comprehensive and detailed tutorial for beginners on text retrieval and RAG. Stay tuned!
The following contents are releasing in the upcoming weeks:
- Evaluation
- BGE-EN-ICL
<details>
<summary>The whole tutorial roadmap</summary>
<img src="./Tutorials/tutorial_map.png"/>
</details>
Model List
bge is short for BAAI general embedding.
| Model | Language | Description | query instruction for retrieval |
|:--------------------------------------------------------------------------|:--------:|:-----------------------------------------------------------------------------------------------------------------------------------:|:----------------------------------------------------------------------------------------------:|
| BAAI/bge-en-icl | English | A LLM-based embedding model with in-context learning c
Truncated. Read the full README on GitHub ↗