Pull requests / #1963

#1963 setup: --draft-vocab latin ships a draft subset for accented Latin-script answers

closed · @ANBAL534 · 0 commentaires · Sur GitHub

BenchmarksSetup & installAMD / HIPModels & quantsDocumentation

Description

The draft layer proposes tokens from a subset (rt/draft_vocab.bin), so a token outside that subset can never be drafted. The shipped English/code subset (--draft-vocab en, 40,525 ids) holds 37,803 of the vocabulary's 138,517 Latin tokens, and 27 Han / 71 kana / 36 hangul / 34 cjk_punct / 142 Cyrillic ones - the shape #137 fixed for CJK and #597 for French. A Latin-script answer that leans on accents and diacritics (Spanish, French, German, Portuguese, Italian, Polish, Czech, Romanian, Turkish, Vietnamese) has its words in the subset and most of its accented pieces outside it.

--draft-vocab latin ships a subset for those languages: the English/code base with its dedicated non-Latin tokens removed and every non-ASCII Latin token of the vocabulary added - 54,262 ids. It is built with tools/draft_vocab.py --add latin, the same selector the Cyrillic subset uses, so anyone can rebuild it from the GGUF.

**TL;DR**

- a fifth shipped draft subset: --draft-vocab latin, English/code plus the vocabulary's non-ASCII Latin tokens
- 54,262 ids: 51,905 of the 138,517 Latin tokens, and 0 Han, 0 kana, 0 hangul, 0 cjk_punct, 0 Cyrillic
- 178 MiB of draft-head VRAM on IQ3_S, between fr (151) and cyrillic (193), and 170 MiB under the cjk default (348)
- opt-in, one value of an existing flag: no engine change, no new flag, no new dependency

## What changes

- data/draft_vocab_latin.bin (54,262 ids) joins the shipped subsets, and setup.py lists it in DRAFT_VOCABS, in DRAFT_VOCAB_MIB (178 MiB, the same size proportion the other subsets are measured by) and in the --draft-vocab help.
- tools/draft_vocab.py --add latin: the base's ids keep their order and its UTF-8 byte fragments stay (the fallback path keeps working), tokens belonging to another script are dropped, and every token carrying a non-ASCII Latin letter, or a combining mark on one, is added in id order. Unicode script properties do the work: Unicode's Latin script is not one block, so SCRIPTS["latin"] is an empty entry and the regexes decide.
- --add latin refuses to mix with another --add or with --corpus, and needs --base data/draft_vocab_en.bin: it is a whole-script selection over the English/code base, not a corpus selection.
- docs/DETAILS.md documents the subset next to the Cyrillic and French paragraphs.

## Why it helps

- **Accented words get drafted.** The subset carries 51,905 Latin tokens against the base's 37,803, and gives up the 310 dedicated non-Latin tokens the base held (27 Han, 71 kana, 36 hangul, 34 cjk_punct, 142 Cyrillic). A café, a Straße, a żółć answer has its own tokens in the draft head instead of being spelled out of byte fragments.
- **Cheaper than the default it replaces.** 178 MiB of draft-head VRAM on IQ3_S against the cjk default's 348, for a PC that answers in a Latin-script language and does not need Han at all.
- **Rebuildable, not a blob.** The file comes out of one command, so a user with a language the subset misses can rebuild it, and the shipped one can be checked against the GGUF:

    python tools/draft_vocab.py --gguf <model>-00001-of-0000N.gguf --base data/draft_vocab_en.bin --add latin --out data/draft_vocab_latin.bin

## The subsets today

| --draft-vocab | ids | draft head on IQ3_S | what it adds over English/code |
|---|---|---|---|
| cjk (default) | 106,299 | 348 MiB | Han, kana, hangul, CJK punctuation |
| cyrillic | 58,963 | 193 MiB | the whole Cyrillic script |
| **latin** | **54,262** | **178 MiB** | **every non-ASCII Latin token; the base's 310 non-Latin tokens dropped** |
| fr | 46,211 | 151 MiB | French corpus tokens (#597) |
| en | 40,525 | 133 MiB | - |

The ids column is each shipped file's size in int32 ids; the MiB column is setup.py's DRAFT_VOCAB_MIB, measured on IQ3_S, the largest.

## Testing

- tools/test_draft_vocab_latin.py (3 tests): the selector on a fixed token list - accents kept (café, Straße, façade, żółć, niño, e+U+0301), Han, kana, Cyrillic, Greek, ideographic comma and emoji dropped, byte fragments and punctuation kept; latin as a shared SCRIPTS entry through select_ids; and the two refusals (no --base, mixed with another --add or --corpus).
- tools/test_setup_draft_vocab.py: --draft-vocab latin replaces a shipped subset in the MTP folder and does nothing when run again; the small-card note accepts latin; DRAFT_VOCAB_MIB["latin"] is checked against the shipped file's size the way the other subsets are.
- Setup's own tests, which need no GPU and no download: test_setup_draft_vocab, test_draft_vocab, test_setup_choices, test_setup_golden, test_setup_pins and test_iq_pack all pass on this branch (merged with today's main).
- The subset's numbers above come from tools/draft_vocab.py --stats on the shipped file, read against the Swift 1.5 IQ3_S shard 1 vocabulary.
- Not measured: the acceptance rate and tokens/s per language. The subset is shipped and wired; the comparative run (the same prompts with en, latin and the language's own subset, on one card) is pending, and I will add the numbers here.

## Scope

Only the draft head reads this file. The main model answers in any language: a token outside the subset is written normally, it is simply never drafted. A later --draft-vocab cjk|en|cyrillic|fr replaces the file as it does for the other shipped subsets, and a subset made by hand is kept. Cyrillic, CJK, Greek and Arabic answers draft less than with their own subset, with the base's byte fragments as the fallback - the same trade --draft-vocab en already makes, in exchange for the accented Latin tokens.

Sur le site

Liens install, modèles, releases.