Technology updates
Dharma-AI's VocabX Rebuilds the Vocabulary Around Decode Cost, Cutting Grader Inference Cost by 77%
Dharma-AI previews VocabX, a method that rebuilds a domain model's vocabulary around decode cost instead of token frequency, reporting a 77% inference cost cut for a Qwen3-4B Portuguese essay grader.
Dharma-AI has published a Hugging Face blog post describing VocabX, a vocabulary specialization method, with a measured result from a production system: inference cost for a Portuguese essay grader fell 77% without changing the base model, the training data or the training recipe. The authors say the figures come from the VocabX paper, which is still under review and will be published soon, so the numbers may change.
The starting point is the tokenizer. Domain- or task-tuned open models such as Qwen and Gemma inherit vocabularies built for many languages and domains. The grader uses one language and one response format, yet its vocabulary still held about 151,669 entries. That causes two kinds of waste: fragmentation, because every response opens with the same JSON envelope, competency names and evaluation phrases that get split into many tokens; and excess, because the model scores every vocabulary entry at every generated token even though most will never be used.
The post stresses that reading is cheap and writing is expensive. Prefill processes the whole input in one pass and is compute-bound; decode emits one token at a time, re-reading weights and the KV cache each step and is bound by memory bandwidth. In the grader case the authors measured, a generated token costs about 7.4 times a read token, a ratio they note varies with hardware, batch size and context length. The output matrix alone is nearly 10% of Qwen3-4B's parameters and is read in full for every generated token, so vocabulary size feeds directly into per-step memory traffic.
VocabX departs from earlier approaches such as fast vocabulary transfer, multi-word tokenization and Liquid AI's in-place tokenizer expansion in three ways. First, it ranks candidates by cost and time saved rather than frequency, multiplying each eliminated token by the price of the field it appears in — system prompt, user message or response — so a token saved in the response is worth 7.4 input tokens in the measured setup. Second, it works at both the sub-word and multi-word layers at once, rebuilding how domain words split and fusing repeated spans, from short expressions to whole lines and JSON envelopes, into single macro tokens under one cost criterion with separate budgets. Third, it handles sampling. Exactly measuring each candidate's marginal gain would require reprocessing the corpus after every choice, so the team splits a candidate's gain into an exactly countable corpus-wide saving and a part not yet covered by chosen tokens that must be estimated, using statistical inference rather than zero for candidates absent from the sample. They report that this change alone lifted token reduction on a contracts corpus from 44.7% to 52.8%.
For the measurement, seven grader variants were trained with identical base model, data, recipe and seed, differing only in tokenizer, then served 500 identical requests on one RTX 5090 with vLLM and costed from measured runtime. Average response length fell from 350 to 101 tokens, cost dropped 77.0% and a combined bench score covering grading accuracy and off-topic or rule-breaking screening rose from 0.703 to 0.810. The authors also record a correction: fusing each competency's grade with the surrounding JSON into one macro token was the most compact option but lowered the bench score to 0.689, below the production grader; giving the grade its own token added two tokens per response, raised the score to 0.810 and was even cheaper in the test, a 77.0% cut versus 73.3%. Their lesson is that compression should not swallow the decision the model exists to make.
Generalization tests covered five public domains — contracts, medical papers, scientific papers, news and Python code — and three model families, Qwen3, Llama-3.1 and Gemma-3, for fifteen combinations. VocabX compressed more than the strongest baseline in all fifteen and led on estimated inference cost in all fifteen. The authors are explicit that VocabX does not make a model smarter; it stops the model from paying piece by piece for text it need not write and from scoring a vocabulary it will never use. Specialization, they suggest, can begin with data and weights, or one layer earlier in the vocabulary.