Skip to main content

Model guide

BGE-M3

BGE-M3 turns text into search representations; it does not write answers to document questions. Its publisher provides dense, sparse and multi-vector retrieval modes, but an application may expose only one. Choose the mode your index supports and test whether a known relevant passage ranks above an unrelated one.

0.57BEmbedding8,192 token contextView the model card →

At a glance

Parameters
0.57B
Accepts
Text
Returns
Vectors
Published context limit
8,192 tokens
Model format
safetensors · ONNX · GGUF
Software and download hosts
sentence-transformers · PyTorch · Ollama. Follow the exact setup below; this list does not establish support for every format, input type or software version.
Suggested compression
Q4_K_M
Model-weight download
Q4_K_M weights · 0.44 GBlm-kit (community conversion)bge-m3-Q4_K_M.gguf
Languages
100+ working languages
License
MIT

Record memory while indexing a batch of your usual passage length. Time one query separately.

Best for

  • Index passages in more than one language. Query a known fact in another language and inspect which passage BGE-M3 returns.

Choose something else when

  • Choose a separate chat model if you want a written answer from the retrieved passages.

Using this model for document search

Select this model for the document-search step in an app that supports it. Keep the model that generates answers separate. Check document chunk length and any required query or document prefixes in the model’s instructions.

Changing the embedding model changes the document vectors. Rebuild the document index rather than mixing vectors from different models.

First setup

The Python workflow loads BAAI/bge-m3 (2.27 GB for pytorch_model.bin, plus tokenizer/configuration files). The 0.44 GB Q4_K_M GGUF is a separate download for a compatible GGUF model runner; the Python example does not load it. Loaded memory depends on dtype, input length, batch size and model runner.

Install sentence-transformers with python -m pip install -U sentence-transformers. This example uses CPU and short text.

from sentence_transformers import SentenceTransformer
model = SentenceTransformer("BAAI/bge-m3", device="cpu")
query = model.encode(["When does the meeting start?"], batch_size=1)
documents = model.encode(["The meeting starts at 10:30.", "Lunch is at noon."], batch_size=1)
print(query.shape, documents.shape)
print(model.similarity(query, documents))

Expect one query vector, two document vectors and two similarity values. Check whether the meeting passage ranks above the lunch passage. These values do not establish that a generated answer is correct. Keep query and document prompting consistent when building a real index; rebuild it when changing the model. BGE-M3 also has sparse and multi-vector modes; this example uses dense vectors only.

Save the Python example as example.py, then run python example.py in the environment where you installed its packages. The first run downloads model files; later local execution still needs the cached files. Start with these short inputs and batch size 1. If loading runs out of memory, close other model processes or use a smaller model; do not interpret missing output as an empty search result. See the publisher model card for the full workflow.

Other models for this task