← All models

feature-extraction Β· text Β· WASM Β· ~223 MB

NeoBERT β€” a next-generation BERT encoder

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.

At a glance

Modelonnx-community/NeoBERT-ONNX (ONNX build of chandar-lab/NeoBERT)
Task / pipelinefeature-extraction β€” the base encoder's token vectors, mean-pooled to a sentence embedding
ArchitectureNext-gen BERT encoder: RoPE positions, SwiGLU FFN, pre-norm, 28 layers Γ— 768 hidden β‰ˆ 250M params
Context length4,096 tokens (vs 512 for classic BERT), trained on RefinedWeb
TokenizerClassic BERT-uncased WordPiece (30,522 tokens) β†’ a drop-in modern backbone
PoolingMean of token vectors, then L2-normalize β†’ 768-d unit vector (this export is the base encoder, no fine-tuned embedding head)
Quantizationq8 (8-bit) ONNX (model_quantized.onnx)
BackendWebAssembly (runs anywhere; no WebGPU needed)
Download~223 MB, cached after first load
LicenseMIT
Web APIsWebAssembly, Web Workers β€” all Baseline widely available

Run it

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.

Cosine similarity matrix

2D map (PCA)

See inside β€” the vector, and the architecture behind it

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.

Embed some passages above to inspect a vector.

What makes it "next-gen"

Positions
RoPE

Rotary embeddings β€” relative, extrapolates past training length. Classic BERT used learned absolute positions capped at 512.

Feed-forward
SwiGLU

Gated activation in pre-norm blocks β€” the same stack modern LLMs use, replacing BERT's GELU MLP.

Shape
28 Γ— 768

Depth over width β€” 28 layers, ~250M params, a compute-optimal aspect ratio.

Context
4,096

8Γ— classic BERT's 512-token window, trained on the RefinedWeb corpus.


Three generations of encoder on the same pairs

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.

Why it matters

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.

Use cases

Basics

Two sentences in, one cosine out β€” the fundamental "how close in meaning?" measurement.

Practical

Semantic search over your own corpus, plus near-duplicate detection at a threshold.

Wild

Cluster a mixed pile of text into unlabeled groups by embedding proximity (k-means).

Multi-model

NeoBERT vs GTE-ModernBERT vs MiniLM β€” three encoder generations ranking the same corpus.

How the API works

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.

References