How theschoolofai/brahmictokenizer-131k works
1. This repository is a tokenizer research and reproduction package, not an application runtime. The central artifact is tokenizer.json, a 131,072-vocabulary byte-level BPE tokenizer intended as a drop-in replacement for o200k_base in downstream training or evaluation pipelines.
2. The architecture is centered on one immutable model artifact plus multiple verification and measurement layers around it. The tokenizer is treated as the source of truth; every script either validates structural constraints on that artifact or measures its behavior on benchmark corpora and tasks.
3. The core boundary is between the tokenizer artifact and external data/services. The repo itself does not ship training data; the evaluation scripts fetch public datasets and third-party tokenizers at runtime from Hugging Face or canonical dataset hosts. This means reproducibility depends on network access and accepted dataset/model licenses.
4. There are four lightweight structural verification scripts that operate directly on tokenizer.json. They check constraints such as no cross-script merges, maximum byte length, Kronecker-style structural conditions, and byte-identical structural identity against a reference tokenizer family. These are the fastest confidence checks and are designed for reviewer smoke testing.
5. The evaluation subsystem measures tokenizer efficiency on benchmark tasks. evaluate_fertility_flores.py and evaluate_fertility_in22.py compute fertility on FLORES-200 and IN22-Gen across multiple competing tokenizers, while evaluate_code_math.py targets code and math datasets such as HumanEval, MBPP, and GSM8K. These scripts are comparative benchmarks, not model inference pipelines.
6. The corpus tokenization subsystem is tokenize_full_indic_corpus.py. It reads large Indic corpora from multiple sources, tokenizes them with different tokenizer choices, and aggregates corpus-wide compression statistics. This is the heaviest data-processing path in the repo and is used to support the headline corpus-level claims in the README.
7. The audit subsystem under audit/ is a deeper diagnostic layer. audit/tokenizer_audit.py emits detailed reports, token frequency tables, vocabulary dumps, garbage-token analysis, and language/script-specific breakdowns. The committed CSVs and markdown/JSON outputs are the historical results of running this audit suite on the shipped tokenizer.
8. reference_outputs/ provides fixed outputs for the key benchmark scripts. These files act as a reproducibility boundary: rerunning the scripts should match the committed JSON exactly, making it easy to validate that the environment and artifact match the published results.
9. The repository also includes a clear separation between “paper claims” and “artifact integrity.” The verification scripts prove the tokenizer obeys structural constraints; the evaluation scripts prove compression/fertility behavior; the audit suite explains vocabulary quality and utilization. Together they cover correctness, performance, and interpretability.
10. The external dependencies matter architecturally because they define the evaluation surface. The repo expects tokenizers, transformers, tiktoken, datasets, pandas, and pyarrow, and it relies on Hugging Face model/tokenizer downloads plus public corpus downloads. In an architecture diagram, those should appear as out-of-repo inputs feeding the benchmark and audit scripts, while tokenizer.json remains the single internal artifact being tested and measured.
Main entry points: tokenizer.json Tokenizer · evaluate_fertility_flores.py FLORES fertility · evaluate_fertility_in22.py IN22 fertility · tokenizer_audit.py Tokenizer audit
Components 16
Core artifact
Primary tokenizer model artifact and repository boundary.
- Tokenizer · 131,072-vocabulary tokenizer used as the single source of truth.
tokenizer.json
Verification
Structural checks over the shipped tokenizer artifact.
- No cross merges · Validates merge constraints across scripts.
verify_no_cross_script_merges.py - Byte length · Checks maximum byte-length constraints.
verify_max_byte_length.py - Kronecker check · Checks unified structural constraints on tokenizer behavior.
verify_kronecker_constraints_unified.py - Identity check · Compares structural identity against the reference tokenizer family.
verify_sarvam_m_structural_identity.py
Evaluation
Comparative benchmark scripts for fertility and task efficiency.
- FLORES fertility · Measures token fertility on FLORES-200 across tokenizers.
evaluate_fertility_flores.py - IN22 fertility · Measures token fertility on IN22-Gen across tokenizers.
evaluate_fertility_in22.py - Code/math eval · Compares tokenizer efficiency on code and math corpora/tasks.
evaluate_code_math.py
Corpus processing
Large-scale corpus tokenization and compression measurement.
- Indic corpus · Tokenizes large Indic corpora and aggregates compression statistics.
tokenize_full_indic_corpus.py
Audit
Detailed vocabulary and token-usage diagnostics.
- Tokenizer audit · Generates token frequency, garbage-token, and script-specific audit outputs.
audit/tokenizer_audit.py - Audit outputs · Historical CSV, JSON, and markdown outputs from audit runs.
audit/report_hybrid_full
Reference outputs
Committed outputs used as reproducibility baselines.
- Refs · Committed benchmark outputs used to validate reproducibility.
reference_outputs
External inputs
Public datasets, model/tokenizer downloads, and runtime dependencies.
- Datasets · External benchmark and corpus downloads fetched at runtime.
- Tokenizer refs · External tokenizer and model artifacts used for comparison.
- Tokenizer libs · tokenizers, transformers, tiktoken, datasets, pandas, pyarrow.
- Network license · Reproducibility depends on accepted licenses and network access.
Connections 25
- Tokenizer → No cross merges: input · Structural validation reads the shipped tokenizer artifact.
- Tokenizer → Byte length: input · Checks tokenizer byte-length constraints.
- Tokenizer → Kronecker check: input · Checks structural constraints against expected rules.
- Tokenizer → Identity check: input · Compares against reference tokenizer identity.
- Tokenizer → FLORES fertility: measure · Benchmark script measures fertility of the artifact.
- Tokenizer → IN22 fertility: measure · Benchmark script measures fertility of the artifact.
- Tokenizer → Code/math eval: measure · Benchmark script measures compression/efficiency on tasks.
- Tokenizer → Indic corpus: tokenize · Corpus pipeline uses the tokenizer as the main encoder.
- Tokenizer → Tokenizer audit: audit · Audit pipeline analyzes the tokenizer vocabulary and usage.
- FLORES fertility → Datasets: fetch · Loads FLORES-200 data at runtime.
- FLORES fertility → Tokenizer refs: compare · Compares against third-party tokenizers.
- IN22 fertility → Datasets: fetch · Loads IN22-Gen data at runtime.
- IN22 fertility → Tokenizer refs: compare · Compares against third-party tokenizers.
- Code/math eval → Datasets: fetch · Loads code and math benchmarks at runtime.
- Indic corpus → Datasets: fetch · Reads large public Indic corpora.
- Tokenizer audit → Datasets: fetch · Consumes corpus inputs for token analysis.
- Tokenizer audit → Audit outputs: writes · Produces detailed audit artifacts and summaries.
- FLORES fertility → Refs: compare · Expected to match committed benchmark outputs.
- IN22 fertility → Refs: compare · Expected to match committed benchmark outputs.
- No cross merges → Tokenizer libs: depends on · Uses tokenizer runtime libraries.
- Code/math eval → Tokenizer libs: depends on · Uses benchmark and data-processing libraries.
- Indic corpus → Tokenizer libs: depends on · Uses corpus processing libraries.
- Tokenizer audit → Tokenizer libs: depends on · Uses analysis and data processing libraries.
- Datasets → Network license: gated by · External downloads depend on access and accepted licenses.
- Tokenizer refs → Network license: gated by · External downloads depend on access and accepted licenses.