Instructions to use Uncino/bge-m3-multivector-gguf with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use Uncino/bge-m3-multivector-gguf with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("Uncino/bge-m3-multivector-gguf") sentences = [ "The weather is lovely today.", "It's so sunny outside!", "He drove to the stadium." ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [3, 3] - llama-cpp-python
How to use Uncino/bge-m3-multivector-gguf with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="Uncino/bge-m3-multivector-gguf", filename="bge-m3-multivector-f16.gguf", )
output = llm( "Once upon a time,", max_tokens=512, echo=True ) print(output)
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use Uncino/bge-m3-multivector-gguf with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf Uncino/bge-m3-multivector-gguf:F16 # Run inference directly in the terminal: llama cli -hf Uncino/bge-m3-multivector-gguf:F16
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf Uncino/bge-m3-multivector-gguf:F16 # Run inference directly in the terminal: llama cli -hf Uncino/bge-m3-multivector-gguf:F16
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf Uncino/bge-m3-multivector-gguf:F16 # Run inference directly in the terminal: ./llama-cli -hf Uncino/bge-m3-multivector-gguf:F16
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf Uncino/bge-m3-multivector-gguf:F16 # Run inference directly in the terminal: ./build/bin/llama-cli -hf Uncino/bge-m3-multivector-gguf:F16
Use Docker
docker model run hf.co/Uncino/bge-m3-multivector-gguf:F16
- LM Studio
- Jan
- Ollama
How to use Uncino/bge-m3-multivector-gguf with Ollama:
ollama run hf.co/Uncino/bge-m3-multivector-gguf:F16
- Unsloth Studio
How to use Uncino/bge-m3-multivector-gguf with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for Uncino/bge-m3-multivector-gguf to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for Uncino/bge-m3-multivector-gguf to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for Uncino/bge-m3-multivector-gguf to start chatting
- Atomic Chat new
- Docker Model Runner
How to use Uncino/bge-m3-multivector-gguf with Docker Model Runner:
docker model run hf.co/Uncino/bge-m3-multivector-gguf:F16
- Lemonade
How to use Uncino/bge-m3-multivector-gguf with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull Uncino/bge-m3-multivector-gguf:F16
Run and chat with the model
lemonade run user.bge-m3-multivector-gguf-F16
List all available models
lemonade list
output = llm(
"Once upon a time,",
max_tokens=512,
echo=True
)
print(output)BGE-M3 GGUF β Dense + Sparse + ColBERT
This repository provides pre-converted GGUF files for the BAAI BGE-M3 embedding model, enhanced to output all three embedding types from a single inference call:
| Head | Output | Shape | Use Case |
|---|---|---|---|
| Dense | CLS pooling β L2 normalization | float[1024] |
Semantic similarity (cosine) |
| Sparse | linear β ReLU β log(1+x) per token |
[token_id, weight] pairs |
Lexical / hybrid search |
| ColBERT | linear β L2 norm per token |
n_tokens Γ float[1024] |
Token-level late interaction |
A single llama_decode() computes all three. No separate models, no external BM25.
Unlike the standard BGE-M3 GGUF (which only preserves the dense head), these files
contain the full cls.sparse and cls.colbert weights extracted from the original
sentence-transformers checkpoint.
Available Files
| File | Quantization | Size | Heads |
|---|---|---|---|
bge-m3-multivector-q8.gguf |
Q8_0 | ~600 MB | Dense + Sparse + ColBERT |
bge-m3-multivector-f16.gguf |
F16 | ~1.1 GB | Dense + Sparse + ColBERT |
Q8_0 is recommended for production β identical quality, half the size.
Usage
With llama.cpp-mv (recommended)
Use the companion llama.cpp-mv fork, which supports all three heads natively. Start the server:
llama-server --model bge-m3-multivector-q8.gguf \
--pooling cls --no-mmap --embedding \
--host 0.0.0.0 --port 8080 \
-c 8192 -b 8192 -ub 8192 -np 1 --fit off \
-ngl 99
Companion fork with inference code: [llama.cpp-mv](https://github.com/iz0eyj/llama.cpp-mv)
Default call returns dense + sparse:
curl -X POST http://127.0.0.1:8080/v1/embeddings \
-H "Content-Type: application/json" \
-d '{"input": "Samarcanda Γ¨ una cittΓ meravigliosa"}'
Add ?colbert=true (or "colbert": true in the JSON body) for all three:
curl -X POST "http://127.0.0.1:8080/v1/embeddings?colbert=true" \
-H "Content-Type: application/json" \
-d '{"input": "Samarcanda Γ¨ una cittΓ meravigliosa"}'
JSON Response Format
{
"data": [{
"embedding": [0.001, -0.023, ...], // dense: 1024 floats
"sparse_embedding": [ // sparse: [token_id, weight] pairs
[0, 0.116],
[121283, 0.154],
[2, 0.095]
],
"colbert_embedding": [ // colbert: n_tokens Γ 1024
[-0.768, -0.048, ...],
[ 0.312, 1.205, ...],
[-0.015, -0.823, ...]
],
"index": 0,
"object": "embedding"
}],
"model": "bge-m3-multivector-q8.gguf",
"usage": {"prompt_tokens": 5, "total_tokens": 5}
}
colbert_embeddingis only present when?colbert=trueis set- Sparse weights > 0 indicate lexically active tokens
- ColBERT vectors are L2-normalized per token (norm β 32, use dot product for similarity)
Per-Token ColBERT Similarity (Late Interaction)
import numpy as np
def colbert_score(vecs_a, vecs_b):
"""MaxSim per token, then average."""
sim = np.dot(vecs_a, vecs_b.T) # [n_a, n_b]
return np.mean(np.max(sim, axis=1))
# Example: "Samarcanda Γ¨ bella" vs "Samarcanda Γ¨ meravigliosa"
# score β 1010 (similar) vs β 330 (different topic)
How These GGUF Files Were Created
The standard llama.cpp converter strips tensors it doesn't recognize. BGE-M3's
sparse and colbert heads (sparse_linear.pt, colbert_linear.pt) are stored
separately from the main model checkpoint and were silently skipped.
Our converter patches (in llama.cpp-mv):
gguf-py/gguf/constants.pyβ AddedCLS_SPARSEandCLS_COLBERTtensor typesgguf-py/gguf/tensor_mapping.pyβ Mappedsparse_linearβcls.sparse,colbert_linearβcls.colbertconversion/bert.pyβ Load.ptfiles from model directory viagenerate_extra_tensors()
Command:
python convert_hf_to_gguf.py BAAI/bge-m3 --outtype q8_0 --outfile bge-m3-multivector-q8.gguf
Inference Architecture (llama.cpp-mv)
The companion C++ fork adds three separate output paths from the same hidden states:
Transformer (24 layers XLM-RoBERTa)
β
βΌ hidden_states [1024, n_tokens]
β
βββ [CLS] βββΊ L2 normalize βββΊ dense [1024]
βββ sparse_linear β ReLU β log1p βββΊ sparse [n_tokens] scalars
βββ colbert_linear β L2 norm βββΊ colbert [n_tokens Γ 1024]
Key design decisions:
log1pfor sparse is applied on CPU after GPU transfer (avoids new GGML op)- ColBERT uses
ggml_normfor per-token L2 normalization - Output buffers are sized for max batch size, zero overhead for small requests
Limitations
- ColBERT scales with token count β 1000 tokens = 4 MB per document. Best used on short text (search queries, titles, paragraphs). For long documents, pre-filter with dense search, then apply ColBERT to top-K candidates.
- CPU mode is unstable on some upstream llama.cpp versions due to F16/F32 mixed-type operations. Use Vulkan (`-ngl 99
Companion fork with inference code: llama.cpp-mv `) or CUDA.
- The ColBERT head is 1024Γ1024 (4 MB) β negligible compared to the 600 MB model body.
License
MIT β matches both BAAI/bge-m3 and llama.cpp.
Credits
- BAAI for BGE-M3 model
- llama.cpp by ggerganov
- GGUF conversion and inference patches by iz0eyj
- Companion fork: llama.cpp-mv
- Downloads last month
- 481
16-bit
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="Uncino/bge-m3-multivector-gguf", filename="", )