← All models

feature-extraction · text · WASM · ~98 MB

Granite Embedding multilingual — a cross-lingual embedder from IBM

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.

At a glance

Modelonnx-community/granite-embedding-97m-multilingual-r2-ONNX (ONNX build of ibm-granite/granite-embedding-107m-multilingual-r2)
Task / pipelinefeature-extraction
BackboneModernBERT (~107M params) → 384-dimensional sentence embedding
LanguagesMultilingual — English, German, Spanish, French, Italian, Portuguese, Dutch, Japanese, Korean, Chinese, Arabic, Czech and more (built for cross-lingual retrieval)
Context lengthLong-context ModernBERT backbone (rotary positions + local/global attention)
PoolingMean over the token vectors, then L2-normalize — no instruction prefix
Quantizationq8 (8-bit) ONNX (onnx/model_quantized.onnx)
BackendWebAssembly (runs anywhere; no WebGPU needed)
Download~98 MB, cached after first load
LicenseApache-2.0 (IBM Granite)
Web APIsWebAssembly, Web Workers — all Baseline widely available

Run it

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.

Cosine similarity matrix

2D map (PCA)

See inside — the vector, and cross-lingual alignment

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.

Embed some passages above to inspect a vector.

Cross-lingual alignment — the same sentence in five languages

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.

Why it matters

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.

Use cases

Basics

Do two sentences mean the same thing — even in different languages? One cosine number.

Practical

Cross-lingual semantic search and near-duplicate detection over your own passages.

Wild

Cluster a pile of mixed-language passages into themes with k-means over the 384-d vectors.

Multi-model

Granite retrieves a shortlist across languages, then a cross-encoder reranks the top hits.

How the API works

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.

References