At a glance
| Upstream & ONNX | BAAI/bge-small-zh-v1.5 → Xenova/bge-small-zh-v1.5 |
|---|---|
| Task / pipeline | feature-extraction (HF tag: sentence-similarity · pooling: "cls", normalize: true) |
| Architecture | BertModel · ~24M params · 4 layers · 8 heads · hidden_size: 512 · 2,048 FFN · 512 max tokens · 21,128 WordPiece vocab (do_lower_case: false) |
| Canonical query instruction | Queries prepend "为这个句子生成表示以用于检索相关文章:" for retrieval; passages remain unprefixed |
| Quantization & size | q8 WASM ONNX (onnx/model_quantized.onnx = 24,010,842 bytes = 24.01 MB + 0.44 MB tokenizer/config = 24.45 MB) |
| Backend | CPU WebAssembly (wasm) via shared lib/webai.js (@huggingface/transformers@3.7.5 — no WebGPU required) |
| License & browser APIs | MIT · Web Workers, WebAssembly, Cache Storage, Canvas 2D (Baseline Widely Available) |
CLS pooling + compact 512-d geometry: Per
1_Pooling/config.json
(pooling_mode_cls_token: true), BGE Small ZH v1.5 extracts token 0 ([CLS],
ID 101) from its 4-layer Chinese BERT encoder and L2-normalizes to 512 unit floats
(2,048 B FP32 / 512 B INT8 per doc). Toggle the canonical retrieval instruction below to observe how
asymmetric query framing affects cosine separation.
1. Client-Side Chinese Retrieval & 2D PCA Workbench
Latency–
Throughput–
Top-1 Cosine–
Dim · L2 Norm–
Query Tokens–
[UNK] Hits–
Health (NaN)–
2. See inside: 2D PCA Constellation & 512-d CLS Vector
2D PCA Semantic Constellation
Run inference above to project passages and query into 2D PCA space.
Active Query 512-d CLS Vector & Histogram
3. Why it matters & what you can build
- 24 MB cold-start Chinese RAG: At 24.45 MB quantized q8 WASM, BGE Small ZH v1.5 loads quickly even on mobile connections and indexes private Simplified/Traditional Chinese docs locally with zero API keys.
- Zero-egress enterprise search: Embed internal Chinese SOPs, medical guidelines, or financial disclosures directly inside the browser sandbox with deterministic 512-d L2 unit vectors.
- Cross-lingual chaining: Retrieve top Chinese passages natively in Stage 1, then feed only the Top-K hits into a local translator like
opus-mt-zh-enin Stage 2 for English briefs.
4. How the API works & Show the code
All inference runs inside a dedicated module Web Worker via shared ../../lib/webai.js
(@huggingface/transformers@3.7.5 — CPU WASM q8) with strict FIFO queueing and
epoch-safe disposal.