# How Specializing the Vocabulary of SLMs Can Cut Inference Cost by 77% in Real Applications

DevFeed: [How Specializing the Vocabulary of SLMs Can Cut Inference Cost by 77% in Real Applications](<https://devfeed.tech/articles/how-specializing-the-vocabulary-of-slms-can-cut-inference-cost-by-77-in-real-applications-93065.md>)

Original publisher: [Read original article](<https://huggingface.co/blog/Dharma-AI/vocabx-vocabulary-specialization>)

Author: Bernardo França de Aguiar; Gabriel Pimenta de Freitas Cardoso; Bruno Duarte; Francisco de Almeida Rocha Alves

Published: 2026-10-21T17:35:36Z

Content type: article

Language: en

Sources: [Hugging Face](<https://devfeed.tech/sources/hugging-face-blog.md>)

Topics: [tokenization](<https://devfeed.tech/topics/tokenization.md>), [model-deployment](<https://devfeed.tech/topics/model-deployment.md>), [Compression](<https://devfeed.tech/topics/compression.md>), [AI Infrastructure](<https://devfeed.tech/topics/ai-infrastructure.md>)

Tags: [2026](<https://devfeed.tech/tags/2026.md>), [7-4](<https://devfeed.tech/tags/7-4.md>), [applications](<https://devfeed.tech/tags/applications.md>), [cost](<https://devfeed.tech/tags/cost.md>), [domain](<https://devfeed.tech/tags/domain.md>), [essay](<https://devfeed.tech/tags/essay.md>), [fine-tuning](<https://devfeed.tech/tags/fine-tuning.md>), [gemma](<https://devfeed.tech/tags/gemma.md>), [general](<https://devfeed.tech/tags/general.md>), [inference](<https://devfeed.tech/tags/inference.md>), [model](<https://devfeed.tech/tags/model.md>), [models](<https://devfeed.tech/tags/models.md>), [open-source](<https://devfeed.tech/tags/open-source.md>), [production](<https://devfeed.tech/tags/production.md>), [qwen](<https://devfeed.tech/tags/qwen.md>), [slms](<https://devfeed.tech/tags/slms.md>), [source](<https://devfeed.tech/tags/source.md>), [split](<https://devfeed.tech/tags/split.md>), [text](<https://devfeed.tech/tags/text.md>), [tokens](<https://devfeed.tech/tags/tokens.md>)

## AI overview

In a production Portuguese essay grader built on Qwen3-4B, replacing the general-purpose tokenizer with VocabX reduced average responses from 350 to 101 tokens and measured inference cost by 77%, while the bench score rose from 0.703 to 0.810. The comparison held the base model, data, training recipe and seed constant; tests used 500 requests on an RTX 5090 with vLLM. VocabX selects vocabulary changes by estimated serving cost, accounting for generated text being more expensive than input in this setup, and combines subword rebuilding with multiword macro tokens for repeated spans such as JSON structures. It also estimates gains for candidates missed by a sample. A fused macro that included grades was more compact but hurt quality and saved less cost; separating grade tokens improved both outcomes. Across five public domains and three model families, VocabX compressed more than the reference methods in all 15 combinations, though the paper is still under review and its results may change.

## Source excerpt

*Models specialized for a domain or a task by fine-tuning general open-source models, such as Qwen and Gemma, inherit a vocabulary built for many domains and general applications.* *In an essay grader we run in production, that vocabulary split the text the model writes most into many tokens.