fix(tokenizer): build a tokenizer from GPT-2 slow files (vocab.json + merges.txt)
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 57/100
Direzione di ricerca
Start in src/tokenizer/mod.rs: read the Qwen2 slow-tokenizer detection and builder, the shared vocab validation, and the load_tokenizer fallback order. Add GPT-2 fixture coverage for successful loading and conflicting added-token IDs, then compare encoding against the listed Transformers outputs. Remove the workaround sentence from docs/supported-models.md; it is done when the tokenizer tests pass and all acceptance examples match.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Problem
Nikity/lille-130m-instruct ships vocab.json, merges.txt and a tokenizer_config.json with "tokenizer_class": "GPT2Tokenizer", but no tokenizer.json. Loading it fails. Reproduced on main with a view of models/lille-130m-instruct that leaves out tokenizer.json: MLXCEL_DEVICE=cpu mlxcel generate -m <view> -p Hello prints No tokenizer found in ... (tried tokenizer.json, tokenizer.model, *.tiktoken, tokenizer.jsonl, and vocab.json + merges.txt). docs/supported-models.md:90 tells users to copy a tokenizer.json in by hand.
Cause
The vocab.json + merges.txt fallback (src/tokenizer/mod.rs:2112-2119) is Qwen2-only. is_qwen2_slow_tokenizer_dir (:1516-1530) accepts only Qwen2Tokenizer/Qwen2TokenizerFast, and the existing test detects_a_qwen2_slow_tokenizer_directory asserts that a GPT2Tokenizer directory is refused. That refusal is correct. build_qwen2_bpe_tokenizer (:1572) applies NFC and the Qwen2 split regex, so GPT-2 text would tokenize differently. It also refuses any added token whose id is inside the base vocab, and Lille's five specials (32763-32767) are already in vocab.json with those same ids.
Proposed Solution
Add is_gpt2_slow_tokenizer_dir (GPT2Tokenizer or GPT2TokenizerFast) and build_gpt2_bpe_tokenizer, and try them right after the Qwen2 fallback. The builder follows transformers' GPT2Converter:
- byte-level BPE, no normalizer
ByteLevel(add_prefix_space, trim_offsets=true, use_regex=true)pre-tokenizer and decoderByteLevel(trim_offsets=false)post-processor, or a BOS template whenadd_bos_tokenis true
add_prefix_space comes from tokenizer_config.json and defaults to false. Move the vocab/merges parsing and validate_dense_vocab_ids into a shared helper rather than copying them. Accept an added token inside the base vocab only when vocab.json maps that content to the same id. Refuse it otherwise.
Acceptance Criteria
- New failing unit test:
load_tokenizeron awrite_qwen2_slow_tokenizer_dir(&dir, "GPT2Tokenizer")fixture succeeds (fails today withNo tokenizer found), and a conflicting added-token id is refused - On the Lille view without
tokenizer.json, encoding matches transformers 5.24.1:Hello->[18435],Hello, world!->[18435, 11, 995, 0],<|user|>Hi there<|assistant|>->[32766, 15902, 612, 32765],naïve café 123->[12385, 26884, 303, 19945, 2634, 17031] - The workaround sentence is removed from
docs/supported-models.md:90
Verification
cargo test --lib tokenizer::tests
MLXCEL_DEVICE=cpu cargo run --release -- generate -m <view-without-tokenizer.json> -p Hello -n 8
- Lingua principale
- Rust
- Stelle
- 505
- Fork
- 81
- Merge medio
- 14h 2m
- PR unite (30g)
- 448
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di lablup/mlxcel
-
area:core priority:high status:ready type:security
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
priority:medium status:ready type:security
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
I maintainer di solito rispondono entro 1 giorno
-
area:models priority:low status:ready type:test
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
I maintainer di solito rispondono entro 1 giorno
-
area:models modeltype:omni priority:medium status:ready type:bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
I maintainer di solito rispondono entro 1 giorno
-
area:models platform:linux priority:medium status:ready type:bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di lablup/mlxcel
Issue simili
-
psmux-resurrect: restoring a session with a numeric name puts its windows into the wrong session (`new-window -t 4` is read as window 4)Forse già presa @ealwanlee l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
psmux/psmux-plugins#47 ·
-
Link Checker ReportApertaautomated issue report
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 76/100
ratatui/awesome-ratatui#598 ·
I maintainer di solito rispondono entro 1 giorno
-
release
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 75/100
github/gh-aw-mcpg#17603 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
C-Bug S-Needs-Triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
bevyengine/bevy#26718 ·
I maintainer di solito rispondono entro 2 giorni