Downloads · 30 days
515
68% of all-time downloads
JoramMillenaar/all-MiniLM-L6-v2-vocab-quantized
all-MiniLM-L6-v2-vocab-quantized is a feature extraction model from JoramMillenaar. Use it when you need embeddings to search or compare text. It is set up for transformers.js. The card lists the license as apache-2.0.
sentence-transformers/all-MiniLM-L6-v2 as ONNX for Transformers.js, built for the WebGPU execution provider. Converted from Xenova/all-MiniLM-L6-v2.
Downloads · 30 days
515
68% of all-time downloads
All-time downloads
760
Public
Repo size
192 MB
Likes
0
Public
Click a slice to open those files.
.onnx192 MB · 100%
From the Hugging Face model README
sentence-transformers/all-MiniLM-L6-v2 as ONNX for Transformers.js, built for the WebGPU execution provider. Converted from Xenova/all-MiniLM-L6-v2.
Only the word-embedding (vocabulary) table is quantized. It is stored as block-quantized uint8 (com.microsoft::GatherBlockQuantized, asymmetric, with zero points, along the hidden axis). The rest of the network (attention, FFN, LayerNorm, position/token-type embeddings) stays in fp32 or fp16. Inputs are int64 and the output last_hidden_state is float32 in every variant.
| File | Vocab table | Rest of graph | Size | Load with | Min cosine vs fp32* |
|---|---|---|---|---|---|
onnx/model_vocab8.onnx | 8-bit (block 128) | fp32 | 55.7 MB | model_file_name: 'model_vocab8', dtype: 'fp32' | 0.99999 |
onnx/model_vocab8_fp16.onnx | 8-bit (block 128) | fp16 | 33.9 MB | model_file_name: 'model_vocab8', dtype: 'fp16' | 0.99999 |
onnx/model_vocab4.onnx | 4-bit (block 32) | fp32 | 51.0 MB | model_file_name: 'model_vocab4', dtype: 'fp32' | 0.99827 |
onnx/model_vocab4_fp16.onnx | 4-bit (block 32) | fp16 | 28.6 MB | model_file_name: 'model_vocab4', dtype: 'fp16' | 0.99827 |
onnx/model_quantized.onnx (CPU fallback) | int8 (dynamic) | int8 (dynamic) | 23.0 MB | dtype: 'q8' (default on device: 'wasm') | 0.97685 |
* Cosine similarity of the pooled, normalized sentence embedding against the original fp32 model, over 12 test sentences in English, German, French, Spanish, Chinese, Japanese and Russian.
The model_vocab* graphs contain no QuantizeLinear, DynamicQuantizeLinear, QLinearMatMul or MatMulInteger nodes. Checked with onnxruntime-web 1.31 (the version Transformers.js 4.3 ships): in those graphs every compute node is placed on WebGpuExecutionProvider. The only CPU nodes are the 7 small int64 shape nodes (attention-mask Unsqueeze/Cast, position-id Shape/Gather/Slice), which ORT always puts on CPU on purpose. The original fp32 export does the same.
import { pipeline } from '@huggingface/transformers';
const extractor = await pipeline('feature-extraction', '<your-namespace>/all-MiniLM-L6-v2', {
device: 'webgpu',
model_file_name: 'model_vocab4', // or 'model_vocab8'
dtype: 'fp16', // 'fp16' -> model_vocab4_fp16.onnx, 'fp32' -> model_vocab4.onnx
});
const output = await extractor(['This is a simple test.'], { pooling: 'mean', normalize: true });
Transformers.js builds the path as onnx/${model_file_name}${dtype === 'fp16' ? '_fp16' : ''}.onnx. There is no onnx/model.onnx, so for WebGPU always pass model_file_name. dtype: 'fp16' needs a GPU with the shader-f16 WebGPU feature; if the device lacks it, Transformers.js throws. Fall back to dtype: 'fp32' in that case.
onnx/model_quantized.onnx is the unmodified dynamic-int8 export from Xenova/all-MiniLM-L6-v2. It is fast on CPU/WASM but uses DynamicQuantizeLinear + MatMulInteger ops, so do not use it with device: 'webgpu'.
const extractor = await pipeline('feature-extraction', '<your-namespace>/all-MiniLM-L6-v2', {
device: 'wasm', // dtype defaults to 'q8' on wasm -> onnx/model_quantized.onnx
});
Its embeddings drift more from the fp32 model than the model_vocab* files do (see the table above). If you store vectors in one index, embed everything with the same file.