Upload optimized GGUF for embeddings.cpp
Browse files- .gitattributes +1 -0
- README.md +139 -0
- bge-m3.q4_k_mlp_emb_q8_attn.gguf +3 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
bge-m3.q4_k_mlp_emb_q8_attn.gguf filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
base_model: BAAI/bge-m3
|
| 3 |
+
library_name: embeddings.cpp
|
| 4 |
+
tags:
|
| 5 |
+
- gguf
|
| 6 |
+
- embeddings
|
| 7 |
+
- embeddings.cpp
|
| 8 |
+
- bge
|
| 9 |
+
- bge-m3
|
| 10 |
+
- cpu
|
| 11 |
+
pipeline_tag: sentence-similarity
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
# BAAI/bge-m3 GGUF for embeddings.cpp
|
| 15 |
+
|
| 16 |
+
This repository contains an optimized GGUF artifact for running
|
| 17 |
+
`BAAI/bge-m3` with
|
| 18 |
+
[`embeddings.cpp`](https://github.com/daandtu/embeddings.cpp).
|
| 19 |
+
|
| 20 |
+
The GGUF is intended for embedding inference. It is not a llama.cpp
|
| 21 |
+
text-generation model.
|
| 22 |
+
|
| 23 |
+
## File
|
| 24 |
+
|
| 25 |
+
| File | Quantization | Size | SHA256 |
|
| 26 |
+
|---|---|---:|---|
|
| 27 |
+
| `bge-m3.q4_k_mlp_emb_q8_attn.gguf` | `q4_k` MLP and vocabulary, `q8_0` attention | `365.77 MB` | `74fbdc71de72a6e60305c1f34b2ef810f23b650dbd5b09c417e324169ff8517e` |
|
| 28 |
+
|
| 29 |
+
Mixed quantization: the feed-forward weights and the 250k-token vocabulary
|
| 30 |
+
table are `q4_k`, attention stays `q8_0`. Compared with a plain `q8_0` file
|
| 31 |
+
(584 MB, same units as the table above):
|
| 32 |
+
|
| 33 |
+
- Retrieval quality is unchanged on a Chinese/English agent-history
|
| 34 |
+
benchmark (2040 documents: top-1 66%, recall@5 78–83%, both files).
|
| 35 |
+
- Cosine to the fp16 model: mean 0.990, min 0.988 (`q8_0`: 0.999).
|
| 36 |
+
- About 40% faster on x86 CPUs with AVX2 (Xeon E5-2673 v3, 12 threads:
|
| 37 |
+
2.0 vs 1.4 docs/s) and ~230 MB less RAM.
|
| 38 |
+
- Apple silicon: use Metal (default on macOS, see below). On an M4 this file
|
| 39 |
+
runs at 11.5 docs/s with Metal vs ~5.5 on the CPU, the same speed as
|
| 40 |
+
`q8_0`. Only CPU-only Apple builds favour `q8_0` (~18% faster there).
|
| 41 |
+
Build `q8_0` yourself (below) if you need strict alignment with Python.
|
| 42 |
+
|
| 43 |
+
## Python Usage
|
| 44 |
+
|
| 45 |
+
```python
|
| 46 |
+
from embeddings_cpp import load
|
| 47 |
+
|
| 48 |
+
model = load("BAAI/bge-m3")
|
| 49 |
+
vectors = model.batch_encode(["hello world", "你好,世界"])
|
| 50 |
+
```
|
| 51 |
+
|
| 52 |
+
Install the Hugging Face downloader extra when loading directly from this repo:
|
| 53 |
+
|
| 54 |
+
```bash
|
| 55 |
+
pip install "embeddings-cpp[hub]"
|
| 56 |
+
```
|
| 57 |
+
|
| 58 |
+
## Recommended embeddings.cpp Build
|
| 59 |
+
|
| 60 |
+
Linux and Windows (CPU):
|
| 61 |
+
|
| 62 |
+
```bash
|
| 63 |
+
cmake -S . -B build \
|
| 64 |
+
-DCMAKE_BUILD_TYPE=Release \
|
| 65 |
+
-DEMBEDDINGS_CPP_ENABLE_PYBIND=ON \
|
| 66 |
+
-DEMBEDDINGS_CPP_BUILD_WASM_TOOLS=OFF \
|
| 67 |
+
-DGGML_CPU_REPACK=ON \
|
| 68 |
+
-DGGML_BLAS=OFF \
|
| 69 |
+
-DGGML_OPENMP=OFF \
|
| 70 |
+
-DGGML_NATIVE=OFF \
|
| 71 |
+
-DGGML_CUDA=OFF \
|
| 72 |
+
-DGGML_VULKAN=OFF \
|
| 73 |
+
-DGGML_METAL=OFF
|
| 74 |
+
|
| 75 |
+
cmake --build build -j "$(nproc)"
|
| 76 |
+
```
|
| 77 |
+
|
| 78 |
+
On macOS (Apple silicon) use Metal instead: the PyPI wheels and a default
|
| 79 |
+
CMake configure enable it, and `embeddings.cpp` picks the Metal backend
|
| 80 |
+
automatically.
|
| 81 |
+
|
| 82 |
+
```bash
|
| 83 |
+
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release \
|
| 84 |
+
-DGGML_METAL=ON -DGGML_METAL_EMBED_LIBRARY=ON
|
| 85 |
+
cmake --build build -j "$(sysctl -n hw.ncpu)"
|
| 86 |
+
```
|
| 87 |
+
|
| 88 |
+
## Recommended CPU Runtime
|
| 89 |
+
|
| 90 |
+
The registry applies the recommended runtime environment automatically when
|
| 91 |
+
using `embeddings_cpp.load()`:
|
| 92 |
+
|
| 93 |
+
```bash
|
| 94 |
+
EMBEDDINGS_CPP_CPU_REPACK=1
|
| 95 |
+
```
|
| 96 |
+
|
| 97 |
+
By default, `embeddings.cpp` uses the detected CPU concurrency for model
|
| 98 |
+
inference. Set `EMBEDDINGS_CPP_THREADS=N` only when pinning a deployment to a
|
| 99 |
+
measured value for a specific CPU quota or host.
|
| 100 |
+
|
| 101 |
+
## Reproducing The GGUF
|
| 102 |
+
|
| 103 |
+
From an `embeddings.cpp` checkout:
|
| 104 |
+
|
| 105 |
+
```bash
|
| 106 |
+
uv pip install -r scripts/requirements.txt
|
| 107 |
+
|
| 108 |
+
uv run scripts/convert.py \
|
| 109 |
+
BAAI/bge-m3 \
|
| 110 |
+
models/bge-m3.f16.gguf \
|
| 111 |
+
f16
|
| 112 |
+
|
| 113 |
+
EMBEDDINGS_CPP_SKIP_QUANT_PATTERNS='attention.,position_embeddings' \
|
| 114 |
+
./build/quantize \
|
| 115 |
+
models/bge-m3.f16.gguf \
|
| 116 |
+
models/bge-m3.q4_k_mlp_emb_attnf16.gguf \
|
| 117 |
+
q4_k
|
| 118 |
+
|
| 119 |
+
./build/quantize \
|
| 120 |
+
models/bge-m3.q4_k_mlp_emb_attnf16.gguf \
|
| 121 |
+
models/bge-m3.q4_k_mlp_emb_q8_attn.gguf \
|
| 122 |
+
q8_0
|
| 123 |
+
```
|
| 124 |
+
|
| 125 |
+
For a plain `q8_0` file, quantize `models/bge-m3.f16.gguf` with `q8_0` in one
|
| 126 |
+
step.
|
| 127 |
+
|
| 128 |
+
The registry-driven artifact builder performs the same conversion and
|
| 129 |
+
quantization pipeline:
|
| 130 |
+
|
| 131 |
+
```bash
|
| 132 |
+
uv run scripts/build_gguf_artifact.py --model-id BAAI/bge-m3
|
| 133 |
+
```
|
| 134 |
+
|
| 135 |
+
## Notes
|
| 136 |
+
|
| 137 |
+
This model is derived from `BAAI/bge-m3`. Use the upstream model card and
|
| 138 |
+
license terms when deciding whether this artifact is appropriate for your use
|
| 139 |
+
case.
|
bge-m3.q4_k_mlp_emb_q8_attn.gguf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:74fbdc71de72a6e60305c1f34b2ef810f23b650dbd5b09c417e324169ff8517e
|
| 3 |
+
size 383532480
|