Favicon of FlagEmbedding

FlagEmbedding

Python toolkit for semantic search and RAG with BGE embedding models, multilingual rerankers, fine-tuning and evaluation. MIT licensed.

FlagEmbedding is an open-source Python toolkit for developers building semantic search or retrieval-augmented generation (RAG) into their own applications. It runs BGE embedding and reranking models, with tools to fine-tune both and evaluate retrieval results. The library uses the MIT license.

Embedding models turn text into vectors so an application can find passages with similar meaning. Rerankers score the retrieved documents against a query to refine their order before an LLM uses them. FlagEmbedding covers both stages within the same toolkit, alongside training datasets and retrieval tutorials.

Its model choices cover different search needs:

  • BGE-M3 supports multilingual search and combines dense, sparse and ColBERT-style multi-vector retrieval. It also handles long text inputs.
  • BGE-VL supports searches across text and images, including text-to-image, image-to-text and queries that combine an image with a prompt.
  • BGE rerankers include multilingual models based on Gemma and MiniCPM. Some let developers trade computation for speed through layer selection or token compression.
  • BGE-EN-ICL uses task-specific examples to shape query embeddings, while bge-multilingual-gemma2 supports multiple languages and tasks.

The BGE family also includes small, base and large text embedding models for English and Chinese, giving developers a choice of model sizes. BGE models integrate with LangChain, and FlagEmbedding includes evaluation tools for comparing retrieval results. Model licenses vary by checkpoint. The MIT library license does not grant rights to every supported model; Gemma-derived releases retain the relevant Gemma terms. Check the exact embedding or reranking weights before commercial deployment.

Similar to FlagEmbedding