sentence-similarity · 8K Rotary Transformer · text · WASM q8 · 146.54 MB

Alibaba GTE-Base EN v1.5 — 8K-Context 768-d Semantic Embedder

Run Alibaba-NLP/gte-base-en-v1.5 (Apache-2.0, ~137M params, 146.54 MB q8 ONNX) inside a dedicated Web Worker. Unlike classic 512-token BERT encoders, its 12-layer Rotary Position Embedding (RoPE) backbone scales to 8,192 tokens with [CLS] pooling and 768-d unit vectors.

At a glance

Model card Alibaba-NLP/gte-base-en-v1.5
Task & pooling sentence-similarity via feature-extraction (1_Pooling/config.json: pooling: "cls", normalize: true)
Architecture GteModel (model_type: "gte", 12 layers, 12 heads, 768-d hidden, 3072 FFN, linear RoPE rope_theta=1,000,000, ~137M params, 30,528 WordPiece vocab)
Context window 8,192 tokens (max_position_embeddings: 8192; worker raises tokenizer.model_max_length from tokenizer_config.json's max_length: 512)
Quantization & size q8 CPU WASM — 146.54 MB (onnx/model_quantized.onnx, 146,540,971 bytes)
License & runtime apache-2.0 · shared ../../lib/webai.js (WebAssembly + module Web Worker)

Run it — live 768-d sentence similarity explorer

[CLS] pooling contract, no query prefix needed: Per 1_Pooling/config.json, Alibaba-NLP/gte-base-en-v1.5 encodes the normalized [CLS] hidden state (pooling: "cls") into a [1, 768] vector with symmetric query/passage prompting. Use Audit CLS vs Mean below to inspect live ranking drift if mean pooling is mistakenly substituted.

Tip: drag and drop a file onto this zone or press Ctrl/⌘+V anywhere outside an input to replace the candidate passages.

Query → Candidate Cosine Ranking

  1. Waiting for live model inference…

Pairwise Candidate Cosine Heatmap

Cosine heatmap renders after embedding runs.

See inside — 768-d vector sparkline & 16-bin histogram

Inspect the actual L2-normalized 768-d [CLS] vector emitted by Alibaba-NLP/gte-base-en-v1.5 with truncation slice markers (128d, 256d, 512d), real countNonFinite() health checks, and top-magnitude coordinates.

Embed texts above to inspect vector coordinates.

Why it matters — 8K-context retrieval without a GPU

Most compact browser embedders clip at 512 tokens. GTE-Base EN v1.5 brings an 8,192-token rotary attention window and 768-d semantic fidelity into 146.54 MB of CPU WASM q8 weights under an Apache-2.0 license — indexing entire technical RFCs, multi-clause contracts, and long support threads in one local pass with zero data egress.

Use-case ladder

How the API works

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

const extractor = await pipeline(
  "feature-extraction",
  "Alibaba-NLP/gte-base-en-v1.5",
  { device: "wasm", dtype: "q8" },
);
extractor.tokenizer.model_max_length = 8192;

const output = await extractor(
  ["How does RoPE extend context?", "Rotary embeddings encode relative offsets up to 8,192 tokens."],
  { pooling: "cls", normalize: true },
);
// output.dims -> [2, 768] L2-normalized float32 embeddings

Show the code

Show the code: worker pipeline load & 8K model_max_length setup (worker.js)
Show the code: off-main-thread CLS-pooled 768-d extraction & NaN check (worker.js)
Show the code: 16-bin vector summary & non-finite health check (gte-core.mjs)

References