feature-extraction Β· text Β· WASM Β· ~223 MB
BERT is from 2018. NeoBERT (2025) rebuilds the encoder from scratch with the modern transformer stack: rotary position embeddings, SwiGLU feed-forwards, a depth-over-width shape (28 layers, ~250M params), and a 4,096-token context β 8Γ classic BERT's 512. It's the backbone you'd fine-tune into the next retriever or classifier. Here it turns text into 768-number vectors so you can measure meaning: build a similarity matrix, search a corpus, and see how a 2025 encoder differs from a 2024 and a 2020 one. Everything runs on your device.
| Model | onnx-community/NeoBERT-ONNX (ONNX build of chandar-lab/NeoBERT) |
|---|---|
| Task / pipeline | feature-extraction β the base encoder's token vectors, mean-pooled to a sentence embedding |
| Architecture | Next-gen BERT encoder: RoPE positions, SwiGLU FFN, pre-norm, 28 layers Γ 768 hidden β 250M params |
| Context length | 4,096 tokens (vs 512 for classic BERT), trained on RefinedWeb |
| Tokenizer | Classic BERT-uncased WordPiece (30,522 tokens) β a drop-in modern backbone |
| Pooling | Mean of token vectors, then L2-normalize β 768-d unit vector (this export is the base encoder, no fine-tuned embedding head) |
| Quantization | q8 (8-bit) ONNX (model_quantized.onnx) |
| Backend | WebAssembly (runs anywhere; no WebGPU needed) |
| Download | ~223 MB, cached after first load |
| License | MIT |
| Web APIs | WebAssembly, Web Workers β all Baseline widely available |
Put one sentence per line, then embed. The matrix shows the cosine similarity between every pair (1.00 = identical direction). The scatter is a 2D PCA projection of the 768-d vectors β a flattened map where near = similar. Then type a query below and rank the lines by meaning.
The encoder emits one 768-number vector per token; we mean-pool them into a single sentence vector and L2-normalize it, so every sentence becomes a unit-length arrow and cosine similarity is a plain dot product. Pick a passage to see its real vector and its pre-normalization magnitude.
First 96 of 768 dimensions (blue = positive, orange = negative, brighter = larger magnitude):
Rotary embeddings β relative, extrapolates past training length. Classic BERT used learned absolute positions capped at 512.
Gated activation in pre-norm blocks β the same stack modern LLMs use, replacing BERT's GELU MLP.
Depth over width β 28 layers, ~250M params, a compute-optimal aspect ratio.
8Γ classic BERT's 512-token window, trained on the RefinedWeb corpus.
NeoBERT (2025, RoPE/SwiGLU base encoder), GTE-ModernBERT (2024, contrastively fine-tuned) and MiniLM (2020 classic BERT, distilled). Each embeds the same queryβpassage pairs on your device. Read the GAP between "relevant" and "unrelated", not the absolute number: a base encoder like NeoBERT compresses cosines into a high, narrow band, while a fine-tuned embedder spreads them β different jobs, both real. Loads GTE-ModernBERT (~150 MB) and MiniLM (~25 MB) on demand.
Encoders are the quiet workhorses of NLP: retrieval, reranking, classification, clustering and RAG all start by turning text into a vector. Most production embedders still ride a 2018 BERT backbone. NeoBERT shows what a modern rebuild buys β a longer context, a better-scaling shape, and the same architectural tricks that powered the LLM era β in a package small enough to run in a tab. As a base model it's the foundation you fine-tune; seeing it embed zero-shot makes that foundation legible.
Two sentences in, one cosine out β the fundamental "how close in meaning?" measurement.
Semantic search over your own corpus, plus near-duplicate detection at a threshold.
Cluster a mixed pile of text into unlabeled groups by embedding proximity (k-means).
NeoBERT vs GTE-ModernBERT vs MiniLM β three encoder generations ranking the same corpus.
Feature-extraction with mean pooling β the base encoder gives token vectors, we pool + normalize:
import { pipeline } from "@huggingface/transformers";
const extract = await pipeline(
"feature-extraction",
"onnx-community/NeoBERT-ONNX",
); // downloads + caches ~223 MB once
const out = await extract(
["how do I sign in?", "the login page rejects my password"],
{ pooling: "mean", normalize: true },
);
const [a, b] = out.tolist();
// unit-length vectors β cosine similarity is just the dot product:
const sim = a.reduce((s, x, i) => s + x * b[i], 0);
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 comparison never jank the page.