← All models

feature-extraction · text · WASM · ~118 MB

Multilingual E5 — one meaning space for 100 languages

Most search matches words. This model matches meaning — across languages. multilingual-e5-small turns any text from 100 languages into a 384-number vector placed in a single shared space, so "Bonjour le monde" lands next to "Hello world" and a Hindi question can retrieve its Spanish answer. Type below and watch the real cosine similarities come back from a model running entirely on your device.

Honest note: this runs Xenova/multilingual-e5-small, the ONNX q8 export of intfloat/multilingual-e5-small (XLM-RoBERTa base, ~118M params, MIT). E5 models expect a query: or passage: prefix on every input — the demo adds them for you, exactly as the model card prescribes.

At a glance

ModelXenova/multilingual-e5-small (ONNX q8 of intfloat/multilingual-e5-small)
Task / pipelinefeature-extraction (sentence embeddings)
Output384-dimensional vector per text, mean-pooled + L2-normalised → cosine similarity is a dot product
ArchitectureXLM-RoBERTa base (12 layers, ~118M params) contrastively trained on ~1B multilingual text pairs
Languages100 (XLM-R vocabulary; evaluated on MIRACL, Mr. TyDi, multilingual MTEB)
Input conventionprefix every text with query: or passage: (applied automatically here)
Quantizationq8 (8-bit) ONNX
BackendWebAssembly (runs anywhere; no WebGPU needed)
Download~118 MB, cached after first load
LicenseMIT
Web APIsWebAssembly, Web Workers — all Baseline widely available

Run it — cross-lingual meaning match

Write a query in any supported language. It is matched, by meaning alone, against five passages in other languages. The bar is the real cosine similarity the model produced.

See inside — the meaning space, measured

Each text becomes 384 real numbers. Below: the full cosine matrix between your query and every passage (and the passages against each other — near-duplicate meanings in different languages score high even with zero words in common), and a bar-strip of the query's raw embedding (blue = positive dimension, orange = negative).

Cosine matrix (1 = query, 2–6 = passages)

Your query's embedding (384 dims, every 2nd shown)

Why it matters

A shared multilingual embedding space collapses "translate, then search" into one step — and it runs offline on the device, so private text never has to leave.

Use cases

Basics

Embed two texts in any languages and read their real cosine similarity — plus a five-language meaning wall.

Practical

A working multilingual semantic search box over a mixed-language document set, ranked live.

Wild

Language-blind meaning clusters: throw ten sentences in six languages at the model and watch it group them by topic, not tongue.

How the API works

Embeddings are one pipeline call — remember the E5 prefixes:

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

const embed = await pipeline("feature-extraction", "Xenova/multilingual-e5-small");
const out = await embed(
  ["query: Comment faire une omelette ?", "passage: How to cook an omelette"],
  { pooling: "mean", normalize: true },
);
// out.dims → [2, 384]; out[0].data → Float32Array(384), L2-normalised
// cosine similarity = dot(out[0].data, out[1].data) ≈ 0.9

pooling: "mean" averages token vectors into one sentence vector and normalize: true unit-lengths it, so a plain dot product is the cosine similarity. The query:/passage: prefixes come from the model card — E5 was trained with them and scores measurably worse without. Everything runs in a Web Worker so typing stays smooth.

References