// Sample texts written for this page, one per regime. The normalizer-only speedups in the // comments were measured with the two WASM builds (bert-base-uncased, 2026-10-13, df2d3fa93). export const EXAMPLES = [ { // Mostly ASCII, a few accents, curly quotes and an emoji: ~12×. key: "review", label: "English review", text: "Honestly the best café grinder I’ve owned!! ☕ Grinds fine enough for espresso, and shipping to Montréal took 3 days. 5/5 — would buy again.", }, { // Pure ASCII, lots of capitals and punctuation: ~90×. key: "code", label: "Code", text: `def embed_chunks(chunks: list[str], model: SentenceTransformer, batch_size: int = 64) -> np.ndarray: """Encode text chunks into L2-normalized vectors for the search index.""" if not chunks: return np.empty((0, model.get_sentence_embedding_dimension()), dtype=np.float32) vectors = model.encode(chunks, batch_size=batch_size, show_progress_bar=False) return vectors / np.linalg.norm(vectors, axis=1, keepdims=True) `, }, { // Machine-generated ASCII: ~89×. key: "log", label: "JSON logs", text: '{"ts":"2026-10-12T08:31:07Z","level":"ERROR","service":"checkout","user_id":48213,"msg":"Payment provider timeout after 30s","retry":true}\n{"ts":"2026-10-12T08:31:09Z","level":"INFO","service":"checkout","user_id":48213,"msg":"Retry succeeded","latency_ms":1840}', }, { // The string from the post's "Three kinds of characters" figure: ASCII, stable and unstable chars. key: "kinds", label: "CAFÉ crème in Москва", text: "CAFÉ crème in Москва 中文 for 42 BERTs", }, { // Lowercase Cyrillic is "stable" for BERT: the cache skips it, ~24×. key: "russian", label: "Russian", text: "Токенизатор разбивает текст на токены, прежде чем модель сможет его обработать.", }, // Harder cases: each one defeats a specific trick. Speedups measured like the ones above. { // BERT: every ideograph is unstable (spaced out), so every char takes the full chain: 1.2×. // (NFC: ideographs are stable, 5.3×.) key: "chinese", label: "Chinese", worst: true, text: "分词器把文本切成小块,再把每一块映射成一个编号。模型只看到这些编号。", }, { // BERT: almost every word carries one or two accents: many short unstable spans, 1.6×. key: "vietnamese", label: "Vietnamese", worst: true, text: "Tiếng Việt có rất nhiều dấu: mỗi chữ cái có thể mang hai dấu cùng một lúc.", }, { // NFC: every accent arrives decomposed (e + U+0301, like a macOS filename), so every one is rewritten. // The one case that got slower: NFC 0.92×, NFKC 0.94× (per-span overhead). BERT: 2.6×. key: "decomposed", label: "Decomposed accents", worst: true, text: "Re\u0301sume\u0301 de\u0301ja\u0300 vu: cre\u0300me bru\u0302le\u0301e, the\u0301, cafe\u0301.pdf", }, { // BERT pass 2: ESC (0x1B) is a control byte to drop, so those blocks take the byte loop: still 26×. key: "ansi", label: "Terminal log", worst: true, text: "\u001b[32mINFO\u001b[0m server started on :8080\n\u001b[33mWARN\u001b[0m slow request GET /search?q=bert 1.82s\n\u001b[31mERROR\u001b[0m upstream timeout after 30s\n", }, ];