feature-extraction · text · WASM · ~98 MB
IBM's Granite Embedding r2 is an Apache-2.0 retrieval embedder trained for enterprise search — and it is genuinely multilingual: a question in English lands right next to its French, Spanish, Chinese or Japanese equivalent in the same 384-dimensional space, so you can search one language and match another. The r2 generation sits on a ModernBERT backbone (rotary positions, local/global attention, a long context) rather than the classic 512-token BERT encoder. Paste passages in any mix of languages to build a live similarity matrix, search by meaning across languages, and inspect the vector. Nothing leaves your device.
| Model | onnx-community/granite-embedding-97m-multilingual-r2-ONNX (ONNX build of ibm-granite/granite-embedding-107m-multilingual-r2) |
|---|---|
| Task / pipeline | feature-extraction |
| Backbone | ModernBERT (~107M params) → 384-dimensional sentence embedding |
| Languages | Multilingual — English, German, Spanish, French, Italian, Portuguese, Dutch, Japanese, Korean, Chinese, Arabic, Czech and more (built for cross-lingual retrieval) |
| Context length | Long-context ModernBERT backbone (rotary positions + local/global attention) |
| Pooling | Mean over the token vectors, then L2-normalize — no instruction prefix |
| Quantization | q8 (8-bit) ONNX (onnx/model_quantized.onnx) |
| Backend | WebAssembly (runs anywhere; no WebGPU needed) |
| Download | ~98 MB, cached after first load |
| License | Apache-2.0 (IBM Granite) |
| Web APIs | WebAssembly, Web Workers — all Baseline widely available |
Put one passage per line — mix languages freely. The matrix shows cosine similarity between every pair (1.00 = identical direction); the scatter is a 2D PCA of the 384-d vectors. Then type a query in any language to rank the passages by meaning.
ModernBERT emits one 384-number vector per token. Granite Embedding mean-pools them into a whole-passage vector and this page L2-normalizes it — so cosine similarity is a plain dot product. Pick a passage to see its real vector, its pre-normalization magnitude, and how many tokens it spanned.
First 128 of 384 dimensions (blue = positive, orange = negative, brighter = larger magnitude):
The whole point of a multilingual embedder: identical meaning in different languages should map to nearly the same vector. Below, one sentence — "Where is the nearest train station?" — is embedded in five languages, plus one unrelated sentence as a control. The matrix should light up between the five translations and stay dark against the control. Real embeddings, computed on your device.
Embeddings power search, recommendations, deduplication, clustering and retrieval-augmented generation. Granite Embedding's pitch is cross-lingual retrieval under a permissive licence: index a knowledge base once and let users query it in their own language; deduplicate content that says the same thing in different languages; cluster a multilingual support inbox by theme — all in a tab, all private, all Apache-2.0.
Do two sentences mean the same thing — even in different languages? One cosine number.
Cross-lingual semantic search and near-duplicate detection over your own passages.
Cluster a pile of mixed-language passages into themes with k-means over the 384-d vectors.
Granite retrieves a shortlist across languages, then a cross-encoder reranks the top hits.
Feature-extraction with mean pooling is the whole recipe — no instruction prefix, works across languages:
import { pipeline } from "@huggingface/transformers";
const extract = await pipeline(
"feature-extraction",
"onnx-community/granite-embedding-97m-multilingual-r2-ONNX",
); // downloads + caches ~98 MB once
// Granite Embedding mean-pools the token vectors — pass texts in any language:
const out = await extract([
"How do I reset my password?",
"Comment réinitialiser mon mot de passe ?",
], { pooling: "mean", normalize: true });
const [en, fr] = out.tolist();
// unit-length vectors → cosine similarity is just the dot product:
const sim = en.reduce((s, x, i) => s + x * fr[i], 0); // high — same meaning, different language
This page asks the worker for the un-normalized vectors so "See inside" can show the real pre-normalization magnitude, then normalizes them in JS. Inference runs in a Web Worker, so the matrix, projection and search never jank the page.