[Lane 2 · kotlin-core] tokenizer.json parity — match non-special added_tokens atomically and count them in vocabSize
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
Research direction
Read the added-token loop in QwenByteLevelBpeTokenizer.kt and TokenizerFactory.kt, then inspect the related tests in TokenizerFactoryDispatchTest.kt. Add a synthetic case where a non-special token would otherwise split, and check that it encodes atomically and vocabSize includes its id. Run ./gradlew :skainet-io:skainet-io-core:jvmTest; done means the test passes and the changelog records the vocabSize change.
Written by the indexing model from the issue text.
Description
Sub-issue of #1321 (HF tokenizer.json parity for BPE encoders).
Lane: 2 · Kotlin core
Skill needed: Kotlin. Helpful to have read how tokenizers matches added tokens (one page of docs, linked below). No tensor knowledge.
Size: s (a few hours)
Blocked by: nothing (independent of the merges lane; both touch the same file, so rebase once)
What to do
- Read how the reference matches added tokens: every entry of
added_tokensis matched atomically, before pre-tokenization, regardless ofspecial. Thespecialflag only decides whether the token is dropped bydecode(skip_special_tokens=True). See theAddedVocabularysection of thetokenizersdocs: https://huggingface.co/docs/tokenizers/api/added-tokens - In QwenByteLevelBpeTokenizer.kt#L257-L267 the loop skips entries with
"special": false. Register all entries in the atomic-match map. Keep a separateSet<Int>of the ids that are marked special so a later change can implementskip_special_tokens; nothing else needs that set today. - Make the same change in TokenizerFactory.kt#L155-L169 for the Unigram path (
wrapSentencePieceWithSpecialsFromJson). - Added tokens may have ids above
model.vocab(ModernBERT:[UNK]=50280 … and the whitespace runs up to 50367). Extend thetokensarray sovocabSizeequals the referenceget_vocab_size(with_added_tokens=True)— 50368 for ModernBERT instead of today's 50280 — and sodecodecan return their text. - Tests, in
TokenizerFactoryDispatchTest.kt: a synthetic file with onespecial: falseadded token whose content would otherwise BPE-split; assert it encodes to its id and thatvocabSizecounts it. Run./gradlew :skainet-io:skainet-io-core:jvmTest.
Acceptance
- Synthetic test: non-special added token encodes atomically;
vocabSizeincludes ids abovemodel.vocab - With the ModernBERT file (tokenizer/tokenizer.json) and merges loading (sibling lane),
" leading"encodes to[50275, 16378](reference:[' ', 'leading']) instead of[245, 4283, …], andvocabSize == 50368 -
CHANGELOG.mdnotes thevocabSizebehaviour change - Result reported back on #1321
Notes
The flags single_word, lstrip, rstrip, normalized exist on every entry. In the two Laya files they are all false except normalized: true on the non-special ModernBERT entries (and lstrip: true on one special token). Implement plain longest-match as the existing special-token code does; if a file you care about sets single_word or lstrip/rstrip, open a separate issue rather than growing this one. #912 asks for the same vocabSize fix on the SentencePiece side — closing that part here is fine, say so in the PR.
- Dominant language
- Kotlin
- Stars
- 52
- Forks
- 15
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 37
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from SKaiNET-developers/SKaiNET
-
coding good first issue platform size:xs skill:js sub-issue
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
SKaiNET-developers/SKaiNET#1232 ·
Maintainers usually reply within 1 day
-
compute-backend dsl/api enhancement size:m skill:kotlin-core skill:numerics
Difficulty 5/5 Over a week Newbie friendliness 18/100
SKaiNET-developers/SKaiNET#1343 ·
Maintainers usually reply within 1 day
-
skeep tracking
Difficulty 5/5 Over a week Newbie friendliness 15/100
SKaiNET-developers/SKaiNET#1331 · 1 comment ·
Maintainers usually reply within 1 day
-
assessment size:s skill:review sub-issue
Difficulty 4/5 1-2 days Newbie friendliness 18/100
SKaiNET-developers/SKaiNET#1330 ·
Maintainers usually reply within 1 day
-
documentation good first issue size:s skill:docs sub-issue
Difficulty 3/5 1-2 days Newbie friendliness 78/100
SKaiNET-developers/SKaiNET#1329 ·
Maintainers usually reply within 1 day
All issues in SKaiNET-developers/SKaiNET
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
SLNE-Development/surf-chat#134 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100