← All models

feature-extraction · text (109 languages) · WASM · ~490 MB

LaBSE — one meaning space, trained to retrieve translations

LaBSE (Language-agnostic BERT Sentence Embedding) is a dual-encoder Google trained with a translation-ranking objective across 109 languages. Where the other embedders here learned meaning as a side effect, LaBSE was optimised for one thing: pull a sentence and its human translation to nearly the same 768-dimensional point, and push every unrelated sentence away with a margin. That makes it exceptional at bitext mining — given a pile of candidates in many languages, find the one that is the translation of a source sentence. Type mixed-language lines to build a cross-lingual cosine matrix, then watch it match sources to their translations across languages. Nothing leaves your device.

At a glance

ModelXenova/LaBSE (ONNX of sentence-transformers/LaBSE, from Google's LaBSE)
Task / pipelinefeature-extraction
ArchitectureBERT dual-encoder (12 layers, ~471M params) → 768-dimensional sentence embedding
Languages109 — trained with a translation-ranking (bitext) objective so translations share one space
What makes it distinctOptimised for translation retrieval / bitext mining, not just paraphrase similarity — same-meaning pairs get a large margin over distractors
Poolingsentence vector then L2-normalize — and no instruction prefix (embed query and doc identically, in any language)
Quantizationq8 (8-bit) ONNX
BackendWebAssembly (runs anywhere; no WebGPU needed)
Download~490 MB, cached after first load (a large model — first load takes a while)
LicenseApache-2.0 (sentence-transformers / Google LaBSE)
Web APIsWebAssembly, Web Workers — all Baseline widely available

Run it — cross-lingual cosine matrix

Put one sentence per line — mix languages freely. The matrix shows the cosine similarity between every pair (1.00 = identical direction). Because LaBSE was trained on translation ranking, a sentence and its translation light up bright even though the words share nothing.

Cross-language cosine matrix

2D map (PCA), coloured by language

Bitext mining — LaBSE's signature task

This is what LaBSE was built for. Give a column of source sentences and a shuffled pool of candidate translations (mixed languages, plus a distractor that matches nothing). LaBSE embeds both sides and pairs each source with its true translation by cosine — no language labels, no dictionary. The margin column is the gap between the correct match and the best runner-up: a big margin is the model saying "this is clearly the translation".

Each source is matched to its closest candidate by cosine. The extra candidate line matches no source — watch it stay unpicked, or picked only with a tiny margin.

See inside — the 768-d vector and the retrieval margin

LaBSE emits one 768-number vector per sentence. We L2-normalize it to a unit-length arrow, so cosine similarity is a plain dot product. Pick a sentence to see its real vector and pre-normalization magnitude.

Embed some sentences above to inspect a vector.

Why it matters

A translation-aware embedder turns "align the parallel data" and "find the matching passage across languages" from a pipeline of dictionaries and MT into a single vector lookup. LaBSE was literally used to mine billions of parallel sentence pairs from the web to train translation systems — and it runs, in full, in a browser tab.

Use cases

Basics

Is this a translation? One source, several languages, one cross-lingual cosine number each.

Practical

Bitext mining: align a column of sources to their shuffled translations across languages, with accuracy.

Wild

Cluster a mixed-language corpus by meaning — watch the groups ignore language entirely.

Multi-model

Retrieve cross-lingually with LaBSE, then translate the winning passage to English with NLLB-200.

Contrast with the smaller Multilingual MiniLM (384-d, paraphrase objective) and BGE-M3: LaBSE is bigger and tuned specifically for translation retrieval across 109 languages.

How the API works

The same feature-extraction recipe as any sentence embedder — the difference is entirely in the weights:

import { pipeline } from "@huggingface/transformers";

const extract = await pipeline(
  "feature-extraction",
  "Xenova/LaBSE",
); // downloads + caches ~490 MB once

// No instruction prefix — embed a source and a candidate IN ANY LANGUAGE the same way:
const out = await extract(["Where is the station?", "最寄りの駅はどこですか?"], {
  pooling: "mean",
  normalize: true,
});
const [q, d] = out.tolist();

// unit-length vectors → cosine similarity is just the dot product:
const sim = q.reduce((s, x, i) => s + x * d[i], 0); // high — the candidate is the translation

This page asks the worker for the un-normalized pooled 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 bitext mining never jank the page.

References