CoolFace
Modelpublic

Elsephire/Qwen3.6-27B-vocabulary-trimming-GGUF

sourceHugging Facemitupdated 3mo agoView on Hugging Face
2likes30downloads
Model Card

Qwen3.6-27B-Trimmed

A vocabulary-trimmed version of Qwen3.6-27B with 41.3% fewer tokens, keeping only Latin (EN, FR, DE, ES, IT, PT, NL, PL, RO, HU) and Greek scripts while preserving all original capabilities in those languages.


๐Ÿ“Š Trimming Statistics

MetricOriginalTrimmedGain
Vocabulary size248,077 tokens145,570 tokensโˆ’41.3%
File size19,381.0 MB17,378.9 MBโˆ’2002.1 MB (10.33%)
Parameters10,161.2 M10,161.2 Munchanged
ArchitectureDenseDenseunchanged

Original vocabulary distribution by script

Script / LanguageTokens% of vocabularyStatus
Latin (EN, FR, DE, ES, IT, PT, NL, PL, RO, HU)144,02958.1%โœ… Kept
Chinese / Japanese / Korean65,72226.5%โŒ Removed
Cyrillic (RU, UK, BG, SR, MK)18,5807.5%โŒ Removed
Arabic8,8173.6%โŒ Removed
Thai5,7412.3%โŒ Removed
Greek1,5430.6%โœ… Kept
Devanagari (Hindi, Nepali, Marathi)9590.4%โŒ Removed
Bengali5310.2%โŒ Removed
Hebrew5200.2%โŒ Removed
Tamil2680.1%โŒ Removed
Malayalam2050.1%โŒ Removed
Telugu1880.1%โŒ Removed
Georgian1860.1%โŒ Removed
Burmese1470.1%โŒ Removed
Kannada1440.1%โŒ Removed
Gujarati1160.0%โŒ Removed
Armenian880.0%โŒ Removed
Khmer790.0%โŒ Removed
Sinhala770.0%โŒ Removed
Gurmukhi (Punjabi)650.0%โŒ Removed
Lao370.0%โŒ Removed
Ethiopic (Ge'ez)250.0%โŒ Removed
Tibetan100.0%โŒ Removed
Braille20.0%โŒ Removed

๐ŸŽฏ Why Trim?

Eliminating random Asian characters

One of the most common issues with general multilingual models is the sporadic appearance of Chinese, Japanese, or Korean characters in outputs meant for Latin-script languages โ€” even when the prompt has nothing to do with those languages. This happens because the model occasionally explores parts of the vocabulary that are never actively used for the target task. By permanently removing those tokens, this issue is resolved at a structural level: the model simply cannot generate them anymore, as they no longer exist in its output space.

Faster generation and prompt processing

Reducing the vocabulary size has a direct and measurable impact on speed:

  • โ€”Prompt processing (prefill) โ€” The embedding matrix is smaller, which reduces load time and memory access during the prefill phase.
  • โ€”Token-by-token generation (decoding) โ€” The search for the best token in the output distribution (softmax + argmax) operates over a 41.3% smaller space. This translates into faster decoding, especially on hardware where the softmax computation is the bottleneck.

Reduced memory footprint

  • โ€”Storage โ€” The model file is 2002.1 MB smaller (10.33% reduction).
  • โ€”RAM / VRAM โ€” The embedding matrix (lm_head + embed_tokens) occupies proportionally less memory. On systems with tight memory constraints, this reduction can make it possible to run the model where it previously wouldn't fit, or free up memory for other processes.

Potential performance improvement (1โ€“3%)

Trimming the vocabulary may lead to a slight improvement in overall model performance on the retained languages. The hypothesis is that reducing the output space concentrates probability mass more effectively on relevant tokens, reducing the statistical noise introduced by thousands of tokens that are never used in the task context. Gains in the range of 1โ€“3% may be observed on Latin-language benchmarks (perplexity, answer accuracy, coherence).


๐Ÿ”ง Methodology

Trimming was performed using the [vocab-trimmer] release soon tool, which follows this pipeline:

  1. 1.Vocabulary analysis โ€” Each token in the original tokenizer is classified by Unicode script (Latin, CJK, Cyrillic, Arabic, etc.).
  2. 2.Selective filtering โ€” Only Latin and Greek scripts are kept. Special tokens (EOS, BOS, PAD, etc.) and multimodal tokens are always preserved.
  3. 3.ID remapping โ€” A continuous old_id โ†’ new_id mapping is built to compact the vocabulary with no gaps.
  4. 4.Weight slicing โ€” Only the rows of the embedding matrices corresponding to retained tokens are extracted. The lm_head and embed_tokens layers are recalibrated.
  5. 5.Configuration reconstruction โ€” tokenizer_config.json, tokenizer.json, config.json, and the vocabulary are rebuilt with the new IDs. Chat templates and special tokens are preserved verbatim.
  6. 6.Verification โ€” Consistency between tokenizer and weights is validated (special token IDs < vocab_size, functional chat template, etc.).

โš ๏ธ Limitations

  • โ€”Unsupported languages โ€” This model cannot generate text in Chinese, Japanese, Korean, Russian, Arabic, Thai, Hindi, Bengali, Hebrew, or any other language whose tokens were removed. Prompts in these languages will not be understood correctly.
  • โ€”Supported languages โ€” Functional languages include English, French, German, Spanish, Italian, Portuguese, Dutch, Polish, Romanian, Hungarian, and Greek.
  • โ€”Code & Math โ€” Programming and mathematical tokens are preserved (they primarily use Latin encoding). No loss of capability is expected in these domains.
  • โ€”Emojis & Symbols โ€” Common Unicode symbols and emojis are retained if they fall within the selected scripts.

๐Ÿ“ Model files

FileDescription
model.safetensorsModel weights (SafeTensors format)
config.jsonModel configuration
tokenizer_config.jsonTokenizer configuration
tokenizer.jsonAdded tokenizer (BPE)
tokenizer.modelOriginal SentencePiece model
merges.txtBPE merge operations

๐Ÿ’ก Usage

python
from transformers import AutoModelForCausalLM, AutoTokenizer

model_id = "your-namespace/Qwen3.6-27B-vocabulary-trimming"

tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto")

inputs = tokenizer("Explain quantum computing in simple terms.", return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=256)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))

๐Ÿ“ License

This model is derived from Qwen/Qwen3.6-27B and follows its original license. The trimming tool [vocab-trimmer] release soon is available under the MIT License.


๐Ÿ”— References