ratulsikder.me / all projects

bangla.ratulsikder.me

bangla-llm-bench

Open benchmark of how LLM tokenizers, embedding models and LLMs handle Bangla: tokenization tax, conjunct breakage, retrieval and generation evals

  • bangla
  • benchmark
  • bengali
  • information-retrieval
  • llm-evaluation
  • low-resource-languages
  • nlp
  • tokenizer

An open, reproducible benchmark and toolkit for measuring how modern LLM tokenizers, embedding models and LLMs handle Bangla (Bengali), a language with hundreds of millions of speakers that is still low-resource for NLP tooling.

CI Python 3.12 License: MIT

It ships:

  • a tokenizer study (fertility, cost multiplier against English on parallel text, grapheme-cluster / conjunct breakage, mid-codepoint splits, encoding sensitivity);
  • Bangla text normalization (NFC, nukta forms, ZWJ/ZWNJ, khanda ta, digits, danda, visual-order vowel repair, standard-spelling variants), fully tested;
  • a retrieval eval (BM25 with Bangla-aware analyzers vs. multilingual embedding models, recall@k / MRR / nDCG with bootstrap CIs);
  • a YAML generation-task suite (summarization, reading-comprehension QA, topic classification, Banglish→Bangla transliteration) with Bangla-correct metrics, optional LLM-as-judge, and adapters for Anthropic, OpenAI-compatible servers, Ollama and local Hugging Face models.

Every number in this README was produced by the code in this repo on pinned data (see Reproduce). Nothing is estimated or copied from papers.

Why the Bangla tokenization tax matters

LLM APIs bill, rate-limit and truncate by tokens. If a tokenizer needs 5.9× more tokens to say the same thing in Bangla as in English, a Bangla user pays ~5.9× more per request, gets ~5.9× less effective context window, and waits longer for each response. Quality suffers too: when token boundaries cut through a juktakkhor (conjunct such as ক্ষ, ন্ত্র) or even through the UTF-8 bytes of a single letter, the model has to reassemble the script from fragments that carry no linguistic meaning.

Headline results

Measured on 2026-11-24 on the 488 unique FLORES-200 passages behind Belebele, aligned Bangla / English / romanized Bangla (full tables: results/SUMMARY.md).

  1. Older byte-level BPE vocabularies charge ~5–6× for Bangla. cl100k_base (GPT-4) needs 5.92× the tokens of the parallel English text, Llama 3 5.88×, Qwen 2.5 / Qwen 3 5.08×. o200k_base (GPT-4o / 4.1 / 5, gpt-oss) brings this down to 1.71×, Gemma 3 to 1.21×, and Indic-focused vocabularies (MuRIL, IndicBERT v2) reach parity.
  2. Those vocabularies contain no Bangla "words" at all. The cl100k_base, Llama 3.2 and Qwen 3 vocabularies contain zero tokens made of two or more complete Bengali codepoints (o200k_base has 1,985). As a result they split 100% of multi-codepoint aksharas, and 34–43% of their token boundaries fall inside a single 3-byte Bengali codepoint.
  3. Typing Banglish is cheaper than typing Bangla on those tokenizers: romanized Bangla costs 1.95–1.96× English on cl100k / Llama 3 / Qwen versus 5.1–5.9× for Bengali script.
  4. Encoding inconsistency is real and costs tokens. In Belebele's Bangla text, 443 of 488 passages mix precomposed (U+09DC/09DD/09DF) and decomposed (consonant + U+09BC) nukta letters for the same visible characters. Writing them precomposed changes the token count by +28.6% on Sarvam-1, +10.7% on Mistral NeMo and −8.6% on mBERT.
  5. Dense retrievers are strong on Bengali script but collapse on romanized Bangla. BGE-M3 reaches nDCG@10 0.915 on Bangla (English: 0.955), but only 0.583 on the same questions and passages written in romanized Bangla, where a character-4-gram BM25 gets 0.890. paraphrase-multilingual-MiniLM-L12-v2, whose model card does not list Bengali, scores 0.046 (≈ random).
  6. Bangla-aware lexical analysis matters. On Bangla, BM25 goes from nDCG@10 0.638 (whitespace split) to 0.696 (normalization + Bangla word segmentation), 0.799 (+ light suffix stripping) and 0.851 (character 4-grams).
  7. Standard ROUGE silently returns 0 for Bangla. rouge_score 0.1.2's default tokenizer keeps only [a-z0-9], so even an identical Bangla pair scores ROUGE-1 = 0.0. This repo's ROUGE tokenizes Bangla properly (see bangla_llm_bench.metrics).

Tokenizer cost and breakage

Bangla tokenization tax

Grapheme-cluster breakage

TokenizerBangla tokens/wordEnglish tokens/wordBangla cost × English (95% CI)Romanized × EnglishAkshara break rateConjunct break rateMid-codepoint splitsΔ tokens if ড়/ঢ়/য় precomposed
BanglaBERT1.392.040.60× (0.60–0.61)1.38×4.0%7.7%0.0%−2.6%
MuRIL1.431.251.01× (1.00–1.02)1.68×4.8%9.8%0.0%+2.6%
IndicBERT v21.411.221.02× (1.02–1.03)1.69×5.9%10.3%0.0%−1.4%
Sarvam-11.791.421.12× (1.11–1.13)2.06×14.2%23.2%0.4%+28.6%
Gemma 31.661.221.21× (1.20–1.22)1.77×11.0%20.7%0.0%−0.5%
XLM-R2.161.381.39× (1.37–1.40)1.57×14.8%32.2%0.0%+0.0%
o200k_base (GPT-4o/4.1/5)2.331.201.71× (1.70–1.73)1.79×39.2%50.1%0.7%−1.9%
gpt-oss (o200k_harmony)2.331.201.71× (1.70–1.73)1.79×39.2%50.1%0.7%−1.9%
Mistral NeMo (Tekken)2.741.251.94× (1.93–1.96)1.86×51.3%61.1%1.5%+10.7%
mBERT (cased)2.881.301.96× (1.94–1.98)1.75×38.6%63.5%0.0%−8.6%
DeepSeek-V32.761.212.02× (2.01–2.04)1.95×53.4%64.1%1.5%−0.4%
Qwen 2.57.091.245.08× (5.03–5.14)1.95×100.0%100.0%34.1%+0.0%
Qwen 37.091.245.08× (5.03–5.14)1.95×100.0%100.0%34.1%+0.0%
Llama 3.x8.061.215.88× (5.82–5.94)1.95×100.0%100.0%42.2%−2.8%
cl100k_base (GPT-4)8.121.215.92× (5.86–5.99)1.96×100.0%100.0%42.7%−2.8%

How to read it: cost × is total Bangla tokens ÷ total English tokens for the same 488 passages (95% percentile bootstrap over passages, 1,000 resamples, seed 0). BanglaBERT is below 1× because its vocabulary is Bangla-first and English is the expensive language there. Akshara break rate is the share of multi-codepoint orthographic syllables (e.g. ক্ষু, র্থী) that at least one token boundary cuts; conjunct break rate restricts that to virama-joined clusters. UNK rates were ≤ 0.1% for every tokenizer and are in the full table. Llama 3 and Gemma 3 tokenizers were loaded from the ungated unsloth/* mirrors (identical tokenizer files). Claude's tokenizer is not public; --tokenizers claude measures it through the count_tokens API when an ANTHROPIC_API_KEY is set. It is not in the table because no key was available for this run.

Retrieval: same questions, three scripts

Belebele question → passage retrieval (900 questions, 488 passages; one relevant passage per question), identical items in Bangla script, romanized Bangla and English.

Retrieval results

SystemBangla nDCG@10Bangla R@1Romanized nDCG@10Romanized R@1English nDCG@10English R@1
bm25-whitespace0.638 (0.610–0.664)0.5390.664 (0.634–0.693)0.5700.686 (0.658–0.712)0.587
bm25-bangla0.696 (0.670–0.721)0.6110.754 (0.728–0.779)0.6680.881 (0.861–0.898)0.823
bm25-bangla-stem0.799 (0.776–0.821)0.7140.754 (0.728–0.779)0.6680.881 (0.861–0.898)0.823
bm25-char30.841 (0.820–0.861)0.7790.845 (0.824–0.864)0.7720.856 (0.836–0.875)0.786
bm25-char40.851 (0.831–0.870)0.7820.890 (0.873–0.908)0.8320.897 (0.880–0.914)0.846
minilm-l120.046 (0.035–0.058)0.0270.269 (0.244–0.295)0.1970.858 (0.839–0.877)0.779
mpnet-base0.472 (0.443–0.500)0.3340.279 (0.254–0.305)0.2020.885 (0.869–0.902)0.816
labse0.675 (0.647–0.701)0.5510.313 (0.286–0.342)0.2320.786 (0.764–0.808)0.670
e5-small0.838 (0.817–0.857)0.7420.408 (0.378–0.435)0.3060.949 (0.936–0.959)0.908
e5-base0.863 (0.845–0.881)0.7840.501 (0.473–0.531)0.4120.958 (0.947–0.968)0.921
e5-large0.907 (0.892–0.922)0.8420.523 (0.495–0.551)0.4180.965 (0.955–0.974)0.933
bge-m30.915 (0.899–0.930)0.8600.583 (0.554–0.611)0.4830.955 (0.945–0.965)0.913

nDCG@10 with a 95% bootstrap CI over queries. BM25 uses k1=1.2, b=0.75. bm25-bangla = normalization + Bangla word segmentation; -stem adds light suffix stripping (no-op on non-Bengali text); char3/char4 are within-word character n-grams. Embedding models run at pinned Hugging Face revisions with their documented query/passage prefixes (E5).

Generation (live local model + deterministic baselines)

Live outputs from gemma4:12b-it-qat (Gemma 4 12B, quantization-aware-trained weights) served locally by Ollama with greedy decoding and seed 0, zero-shot Bangla prompts from tasks/. The baseline column is the deterministic mock adapter, which is not a model: a seeded random pick for QA/classification, the first sentence (LEAD-1) for summarization, and the unchanged input for transliteration. Samples are seeded (seed 13).

TasknMetricgemma4:12b-it-qat (live, 95% CI)Mock baseline
Belebele reading-comprehension QA (4-way MC)200accuracy0.830 (0.775–0.880)0.295 (random pick)
SIB-200 topic classification (7-way)204accuracy0.853 (0.799–0.902)0.142 (random label)
SIB-200 topic classification (7-way)204macro-F10.8450.137 (random label)
XL-Sum summarization50chrF35.3 (32.6–38.1)27.5 (LEAD-1)
XL-Sum summarization50ROUGE-L (Bangla tokens)0.165 (0.137–0.196)0.130 (LEAD-1)
Aksharantar word transliteration200exact match0.385 (0.315–0.455)0.000 (copy input)
Aksharantar word transliteration200CER ↓0.285 (0.188–0.438)1.197 (copy input)
Belebele passage transliteration (romanized → Bengali)50chrF83.8 (78.9–87.5)0.8 (copy input)
Belebele passage transliteration (romanized → Bengali)50CER ↓0.099 (0.062–0.150)0.970 (copy input)

Notes from the per-item outputs (in results/generation/*.json): the model often answered SIB-200 items with the short label "technology"; the task maps that to science/technology through label_aliases (18 of 204 items, re-scored from the saved outputs with blb rescore, no new model calls). Word-level transliteration is where the model is weakest: it gets 38.5% of Aksharantar words exactly right, and a single degenerate repetitive output (CER 14.0) inflates the mean CER and widens its CI; the median CER is 0.134. LLM-as-judge (--judge) is implemented and tested with the mock adapter but was not used for these numbers: the only available live model is the one being evaluated, and self-judging is biased.

Architecture

flowchart LR
  subgraph data[Data, pinned + checksummed]
    BB[Belebele<br/>bn / en / romanized]
    SIB[SIB-200]
    XL[XL-Sum]
    AK[Aksharantar]
    FX[hand-written fixtures]
  end
  N[normalize.py<br/>NFC, nukta, ZWJ/ZWNJ,<br/>digits, spelling]
  S[script.py<br/>akshara segmentation]
  T[tokenizers.py<br/>tiktoken / HF / count_tokens]
  TS[tokenizer_study.py<br/>fertility, cost ×, breakage]
  R[retrieval.py<br/>BM25 analyzers + dense]
  G[generation.py<br/>YAML tasks, metrics, judge]
  A[adapters.py<br/>mock, Anthropic, OpenAI-compat,<br/>Ollama, HF]
  O[(results/*.json)]
  REP[report.py<br/>tables + charts]

  BB --> TS & R & G
  FX --> TS & R & G
  SIB & XL & AK --> G
  N --> TS & R & G
  S --> TS
  T --> TS
  A --> G
  TS & R & G --> O --> REP

Quickstart

bash
git clone https://github.com/RatulSikder97/bangla-llm-bench && cd bangla-llm-bench
uv sync --extra hf                    # core + Hugging Face tokenizers (no torch)
uv run blb tokenizers --corpus fixtures --tokenizers ci
uv run blb normalize "সময়ের মূল্য ২০২৬ |" --digits ascii
uv run blb segment "ক্ষুধার্ত শিক্ষার্থী"     # ক্ষু | ধা | র্ত |   | শি | ক্ষা | র্থী

Reproduce

All runs are seeded (bootstrap seed 0, task sample seed 13), data files are fetched by immutable commit and SHA-256 verified, model and tokenizer revisions are pinned, and dependencies are locked in uv.lock.

bash
uv sync --all-extras
uv run blb data fetch                                              # ~50 MB into ~/.cache/bangla-llm-bench
uv run blb data audit --corpus belebele                            # encoding audit
uv run blb tokenizers --corpus belebele --tokenizers all --figures docs/figures
for t in belebele-bn belebele-en belebele-bn-latn; do uv run blb retrieval --task $t --systems all; done
for f in tasks/*.yaml; do uv run blb generate $f --model mock; done
for f in tasks/*.yaml tasks/fixtures/*.yaml; do uv run blb generate $f --model ollama:gemma4:12b-it-qat; done
uv run blb report

Numbers above were produced on an Apple M4 Pro (24 GB, macOS) with Python 3.12.12, transformers 5.24.0, sentence-transformers 6.3.0, torch 2.15.0, tiktoken 0.14.0, and Ollama serving gemma4:12b-it-qat. Each result JSON records its own environment.

Running real models

AdapterSpecNotes
Anthropicanthropic:claude-sonnet-5-5 (default model)needs uv sync --extra anthropic and ANTHROPIC_API_KEY; server-side refusal fallback enabled; adaptive thinking at effort=low
OpenAI-compatibleopenai:<model>@<base_url>any /v1/chat/completions server (vLLM, llama.cpp, TGI, hosted APIs); OPENAI_API_KEY if required
Ollamaollama:<model>[@<host>]greedy decoding, seed=0, thinking off
Hugging Facehf:<repo>local transformers chat model, greedy
Mockmockdeterministic baselines for CI; never a model result
bash
uv run blb generate tasks/belebele-qa.yaml --model anthropic:claude-sonnet-5-5
uv run blb generate tasks/xlsum-summarization.yaml --model ollama:gemma4:12b-it-qat \
    --judge anthropic:claude-sonnet-5-5

Every result JSON carries "live": true|false and a provenance string, and blb report labels mock rows as MOCK baseline. No Anthropic or OpenAI results are included in this repository because no API keys were available when it was built; the only live LLM numbers come from the local Ollama model.

Extending

Add a tokenizer: one line in REGISTRY in src/bangla_llm_bench/tokenizers.py, e.g. _hf("my-tok", "org/repo", "My tokenizer"), plus its commit in HF_REVISIONS. Anything that can return token boundaries (or just counts) can implement the Tokenizer protocol.

Add an embedding model: a DenseSpec(key, repo, revision, query_prefix, doc_prefix) in retrieval.py.

Add a model provider: implement generate(GenerationRequest) -> Generation and set live, then register a prefix in build_adapter in adapters.py.

Add a task: write a YAML file; fields are validated by TaskSpec in generation.py:

yaml
name: my-task
type: qa_mc            # summarization | qa_mc | classification | transliteration
source: {name: belebele, limit: 200, seed: 13}   # or {name: fixture, split: my.jsonl}
prompt: |
  {passage}
  প্রশ্ন: {question}
  {choices_block}
max_tokens: 8

Metrics follow from type: chrF + Bangla ROUGE-1/2/L (summarization), accuracy (QA), accuracy + macro-F1 (classification), chrF + CER + exact match (transliteration), plus judge_score when --judge is given and the task defines judge_rubric.

Development

bash
uv sync --all-extras
uv run ruff check . && uv run ruff format --check .
uv run mypy            # strict
uv run pytest

CI (.github/workflows/ci.yml) runs lint, strict type checks and tests, then the tokenizer study, lexical retrieval and the mock generation suite on the hand-written fixtures, and uploads the results as an artifact.

Limitations

  • Corpus. The tokenizer study and retrieval use FLORES-200-derived Belebele passages: formal, translated, Wikipedia/Wikinews-style text. Conversational, social-media and dialectal Bangla (e.g. Sylheti, Chittagonian) will tokenize and retrieve differently.
  • Words. Fertility uses a regex word splitter, not a morphological analyzer, so tokens/word is comparable across tokenizers but not to numbers computed with other splitters.
  • Breakage ≠ quality. Cutting through an akshara is a proxy for how unnatural a segmentation is; it is not proven here to cause worse downstream accuracy.
  • Retrieval task. Belebele questions were written to be answerable from one passage and are short; 488 passages is a small corpus, so absolute nDCG values are higher than in realistic search. Relative gaps (script, analyzer, model) are the point.
  • Generation. The only live LLM run is one local quantized model (gemma4:12b-it-qat via Ollama) on seeded samples (200 / 204 / 200 / 50 / 50 items). Hosted models were not evaluated (no API keys). Prompts are zero-shot and in Bangla; prompt wording affects scores.
  • Transliteration references. Belebele's romanized passages and Aksharantar's romanized words follow particular romanization conventions, and chrF/CER penalize valid alternative spellings and punctuation.
  • Light stemmer. The suffix list is deliberately small and unvalidated against a morphological gold standard; it is a retrieval heuristic.

Data and licenses

Code: MIT (LICENSE). Data is not redistributed; each dataset is downloaded at runtime under its own license (CC BY-SA 4.0, CC BY-NC-SA 4.0, CC BY / CC0). See DATASETS.md for sources, pinned revisions, licenses and citations. The small fixtures in fixtures/ were written by hand for this repo.

Citation

If you use this benchmark, please cite it (see CITATION.cff) and the datasets in DATASETS.md.

bibtex
@software{sikder2026banglallmbench,
  author  = {Sikder, Ratul},
  title   = {bangla-llm-bench: measuring how LLMs, tokenizers and embedding models handle Bangla},
  year    = {2026},
  url     = {https://github.com/RatulSikder97/bangla-llm-bench},
  version = {0.1.0}
}