Retrieval and Retrieval-augmented LLMs
News | Installation | Quick Start | Community | Projects | Model List | Contributor | Citation | License
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!
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:
BAAI/bge-reranker-base and BAAI/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. bge-*-v1.5 embedding model to alleviate the issue of the similarity distribution, and enhance its retrieval ability without instruction.bge-large-*(short for BAAI General Embedding) Models, rank 1st on MTEB and C-MTEB benchmark! :tada: :tada: BGE (BAAI General Embedding) focuses on retrieval-augmented LLMs, consisting of the following projects currently:
If you do not want to finetune the models, you can install the package without the finetune dependency:
pip install -U FlagEmbeddingIf you want to finetune the models, you can install the package with the finetune dependency:
pip install -U FlagEmbedding[finetune]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]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
[Bug] With negatives_cross_device and kd_loss_type=kl_div, the distillation weight grows with the number of GPUs
Tutorials/2_Metrics /2.1_Similarity_Metrics.ipynb 示例中的最终结论写反
Silent `trust_remote_code=True` enable in `FlagAutoModel.from_finetuned` via basename-only registry lookup
Colbert Interaction correct?
Consider using pre-built Flash Attention kernels via `kernels`
bge-reranker-v2-minicpm-layerwise微调报错
mac上使用omlx部署报错
Embedder for m3-memory
rerank微调数据格式
bge模型深入使用后思考与疑问