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.
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.
This creates a 4,096-token copy of bge-m3 named bge-m3-short-context. Save the following as a file named Modelfile in your working folder:
FROM bge-m3
PARAMETER num_ctx 4096
Then run these commands from that folder:
ollama pull bge-m3
ollama create bge-m3-short-context -f ./Modelfile
ollama run bge-m3-short-context
Run the example in Model-specific setup. While the model is loaded, run ollama ps in another terminal and check CONTEXT and PROCESSOR.
The recorded Ollama package is F16: 1.16 GB of model weights. Use Ollama 0.40.18 or a supporting newer release. A Hugging Face GGUF or MLX checkpoint is a separate representation; choose the matching source and runner in the memory calculator.
See Ollama context settings and the Modelfile instructions.
After downloading, send the text you want to index to Ollama’s embedding endpoint, using bge-m3 as the model.
Time a fixed set of passages at batch size 1, then measure the batch size you plan to use. Indexing time and query time are separate; reranking adds a second model call.
