Skip to content

tools: add Indian-script fixtures to tokenizer parity - #1988

Merged
ashhart merged 4 commits into
ashhart:mainfrom
currencycaver29:indic-tokenizer-fixtures
Nov 17, 2026
Merged

ashhart merged 4 commits into
ashhart:mainfrom
currencycaver29:indic-tokenizer-fixtures

Conversation

@currencycaver29

Copy link
Copy Markdown
Contributor

What this changes

The tokenizer parity corpus covered Indic scripts with a single Devanagari phrase. This adds one IN22-Gen sentence in all 22 scheduled Indian languages, the canonical-composition exclusions in both forms (Devanagari qa, Bengali rra/yya, Gurmukhi khha, Oriya rra) and ZWJ/ZWNJ conjuncts, each as written, NFC and NFD. Test fixtures only; no engine change.

  • Issue: n/a. Test coverage for a development tool; no new family, backend or arithmetic.
  • Stacked on: main (bfc374f)
  • atc overlap --json: not run (ATC not installed in my environment); the diff touches only tools/zig/tokenizer_parity.py.

Checks on this head

  • Head commit: 8f43d55
  • Lean checker, python3 tools/zig/lean_check.py: not run.
  • Tests run: checker built with Zig 0.17.0 (zig build-exe zig/src/core/tokenizer/check.zig -O ReleaseSafe), then python3 tools/zig/tokenizer_parity.py --no-synthetic --tokenizer NAME=PATH for each tokenizer below. All pass on this head:
    • sarvam-1: encode 25851/25851, decode 27041/27041
    • gemma-3 (1B): encode 39705/39705, decode 43928/43928
    • llama-3.2 (1B): encode 2751/2751, decode 4881/4881
    • llama-4 (Scout): encode 8025/8025, decode 11294/11294
    • qwen3 (0.6B): encode 1371/1371, decode 3867/3867
    • deepseek-v3: encode 6123/6123, decode 8263/8263
    • mistral-nemo: encode 7215/7215, decode 9390/9390
    • gpt-4o tokenizer.json conversion (Xenova/gpt-4o): encode 1227/1227, decode 4480/4480
  • CI: pending.
  • Not run, and why: the synthetic feature tokenizers (default run) and the lean checker were not run in my environment.

Receipt

n/a: a fixture change to a development tool; it cannot reach inference.

  • Environment: TensorFold bfc374f, Zig 0.17.0, x86_64 Linux (CPU only), Python tokenizers 0.23.3.
  • Licence: the added sentence comes from IN22-Gen (AI4Bharat, CC BY 4.0), attributed in the fixture comment. Happy to add it to THIRD_PARTY_NOTICES.md or swap in original text if you prefer.

Notes

  • The new fixtures pass on main as well: they add coverage rather than fix a bug. I also checked the composition table in unicode_data.zig: all 940 pairs agree with Python's NFC, and the Indic exclusions are correctly absent.
  • Separately, tokenizer_parity.py stops at the first tokenizer the checker does not support (for example UnsupportedPreTokenizer for IndicBERT v2, UnsupportedRegex for BLOOM, UnsupportedNormalizer for XLM-R and mBERT) instead of reporting it and continuing. I can send that as a separate pull request if useful.
  • Prepared with the help of an AI assistant; I reviewed the change and the results.

Checklist

  • The title and description match the head commit, including the receipt and the stack.
  • New tests fail before the change, pass after it, and skip cleanly without their dependency. (They pass before and after: coverage, not a fix.)
  • Comments and docstrings are one line. No measurements or history in the source.
  • No personal data, machine names, internal hosts or local paths in the diff or its commits. No AI attribution lines.

@ashhart

ashhart commented Nov 3, 2026

Copy link
Copy Markdown
Owner

Thanks @currencycaver29. An independent review of this PR and #1989 on current main (d38bba3):
Verdict: keep #1988, CHANGES (two). CLOSE #1989 as superseded by #1988.

The two PRs:

Applying it: both apply cleanly on main d38bba3. The author line is a real GitHub identity
(@currencycaver29, noreply address). Only tools/zig/tokenizer_parity.py changes. No engine code.

The expected ids come from the reference tokenizer, not our own output. The tool stores no ids. reference()
calls Python tokenizers' encode(..., add_special_tokens=False) on each case at run time, and the decode check
calls its decode. Our checker's output is compared with those. The new fixtures are three strings appended to
FIXED: the text as written, its NFC form and its NFD form.

The fixture is what the body says. It holds 1,122 code points across Devanagari, Bengali, Arabic, Malayalam,
Tamil, Oriya, Ol Chiki, Telugu, Meetei Mayek, Kannada, Gujarati and Gurmukhi. The composition exclusions are
present in composed form (U+0958, U+09DC, U+09DF, U+0A59, U+0B5C) and are gone after NFC. ZWJ and ZWNJ survive
both forms. The author reports the new fixtures pass on main too, so this adds coverage rather than fixing a bug.

Changes

  1. Add IN22-Gen to THIRD_PARTY_NOTICES.md. The sentence is CC BY 4.0 text, and the notices file already lists
    other third-party test material (for example the DeepSeek V4 fixtures). The author offered this.

  2. Run the two default paths the fixture reaches. FIXED is more than the parity corpus:

    • synthetic() trains the six feature-coverage tokenizers on FIXED * 30, so their vocabularies change. The
      default run (without --no-synthetic) was not run.
    • tools/zig/k3_tokenizer_parity.py builds Kimi's parity corpus from tp.FIXED, so Kimi's parity check now
      covers these strings too. Kimi's files are untouched, but that run should be shown green.

    Ask: post tokenizer_parity.py with the synthetic tokenizers and k3_tokenizer_parity.py, with pass counts.
    Both are CPU only.

Small point: the body's note about the tool stopping at the first unsupported tokenizer is a fair separate PR.

Device run: none. Both runs above are CPU only.

I'll close #1989 in favour of this one.

@ashhart

ashhart commented Nov 10, 2026

Copy link
Copy Markdown
Owner

Hi @currencycaver29, thanks again for the Indian-script fixtures. Two small things from our review are still open:

  • an IN22-Gen entry in THIRD_PARTY_NOTICES.md, since the sentence is CC BY 4.0;
  • the two default runs the fixtures now reach, tokenizer_parity.py with the synthetic tokenizers and k3_tokenizer_parity.py, with their pass counts. Both run on the CPU.

If it's easier, we can add the notice line when we land it. The two runs are the part we'd need from you.

@ashhart
ashhart force-pushed the indic-tokenizer-fixtures branch from 8f43d55 to 5987715 Compare November 12, 2026 14:15
@ashhart

ashhart commented Nov 12, 2026

Copy link
Copy Markdown
Owner

Thanks @currencycaver29 for the Indian-script fixtures. We've added the notice on your branch and will run the two parity checks ourselves, so nothing more is needed from you.

  • Rebased onto current main. Your two commits are unchanged apart from their base: INDIC is still at tools/zig/tokenizer_parity.py:46, and the three forms (as written, NFC, NFD) are still in FIXED at :103-104.
  • Notice. THIRD_PARTY_NOTICES.md:499-504 has a new section, "Indian-script tokenizer fixture". It credits the sentence to IN22-Gen (AI4Bharat, CC BY 4.0) as given in your fixture, and says the composition-exclusion and ZWJ/ZWNJ strings after it are TensorFold's own. If you changed the dataset's sentence in any way, tell us and we'll say so in the notice.
  • The synthetic tokenizers still train with the new FIXED. With tokenizers 0.23.3, all six train on FIXED * 30 and encode the three new strings. Their vocabulary sizes are 707 (sentencepiece-bpe), 507 (metaspace-bpe), 307 (unk-bpe), 1,099 (wordpiece), 807 (bytelevel-regex) and 45 (wordlevel-splits). The lean count is the same as main's.

Before landing we'll post the pass counts of the two parity runs here: the default tokenizer_parity.py with the synthetic tokenizers, and k3_tokenizer_parity.py. We'll squash the commits when it lands, and it will carry your authorship.

  • Synthena (Ash's Agent)

@ashhart
ashhart force-pushed the indic-tokenizer-fixtures branch from 5987715 to 9646458 Compare November 17, 2026 11:47
@ashhart

ashhart commented Nov 17, 2026

Copy link
Copy Markdown
Owner

Thanks @currencycaver29. We rebased this onto today's main, keeping your commits under your name. In THIRD_PARTY_NOTICES.md your section now follows main's newer entries. CI is running; the two tokenizer parity runs are ours to do before it lands.

Please pull before you push again (git pull --rebase), so the rebase isn't lost.

  • Synthena

@ashhart

ashhart commented Nov 17, 2026

Copy link
Copy Markdown
Owner

/atc exchange 75702b255672b310039fd7e47b866c2510072dd77128ccfea5010aae304c9020

currencycaver29 and others added 4 commits November 17, 2026 21:38
The parity corpus covered Indic scripts with one Devanagari phrase. Add one
IN22-Gen sentence (AI4Bharat, CC BY 4.0) in all 22 scheduled Indian
languages, canonical-composition exclusions in both forms (Devanagari qa,
Bengali rra/yya, Gurmukhi khha, Oriya rra) and ZWJ/ZWNJ conjuncts, each as
written, NFC and NFD.
The fixture's sentence is IN22-Gen's (AI4Bharat), CC BY 4.0.

Co-authored-by: Divij Karanam <[email protected]>
@ashhart
ashhart force-pushed the indic-tokenizer-fixtures branch from 9646458 to 5e1c650 Compare November 17, 2026 21:39
@ashhart
ashhart merged commit 75f5161 into ashhart:main Nov 17, 2026
@ashhart

ashhart commented Nov 17, 2026

Copy link
Copy Markdown
Owner

Thank you @currencycaver29. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes.

@ashhart

ashhart commented Nov 18, 2026

Copy link
Copy Markdown
Owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants