How Specializing the Vocabulary of SLMs Can Cut Inference Cost by 77% in Real Applications
VocabX rebuilds a fine-tuned small model's tokenizer by choosing tokens for the cost they save rather than how often they appear. Saved tokens are weighted by field, because a generated token cost 7.4x an input token in their setup. The method works at two layers under one criterion: sub-word merges plus multi-word "macro tokens" found by five span miners. It estimates gains for candidates that never appear in the sample rather than scoring them zero. On a Qwen3-4B Portuguese essay grader, responses shrank from 350 to 101 tokens and measured inference cost fell 77%, while bench score rose from 0.703 to 0.810. Fusing grades into JSON macro tokens hurt quality, so the decision tokens the model exists to make were kept separate.
Related posts
- Serving DeepSeek-V4: why million-token context is an inference systems problem
Together AI hardMasterDeepSeek-V4's 1M-token context comes from compressing the token axis of the KV cache: Compressed Sparse Attention (stride 4, top-k selection), Heavily Compressed Attention (stride 128, dense over ~8K entries) and a 128-token Sliding Window Attention path. The model leaves the serving engine to juggle multiple cache layouts with different sizes and lifetimes. In Together's bring-up on NVIDIA HGX B200, SWA state handling dominated capacity, and keeping only SWA states likely to be reused raised per-node KV capacity from ~1.2M to ~3.7M tokens. Prefix caching becomes a per-cache-type storage policy (full SWA store, checkpoints, or recompute-on-hit). Gains appear first in long-context decode-heavy workloads, while short-context prefill depends on kernel maturity, so teams should benchmark in their own regime and use workload-specific endpoint profiles.
- LLM Cost Optimization: 3 Patterns to Cut LLM Token Spend
Honeycomb mediumAdeptLLM token spend is best reduced by using traces to find three waste patterns: repeated input context that doesn't improve results, retry storms and runaway agent loops, and output tokens that don't lift outcomes. For each, compare expensive and normal cohorts on high-cardinality attributes (prompt version, model, workflow step, tenant, retries) and apply targeted fixes such as filtering retrieval, summarizing history, retry limits, tighter termination conditions and structured outputs. Treat every cost cut as a production change: baseline cost per successful outcome, change one pattern at a time, and roll back if quality guardrails like completion, acceptance or parsing success regress.
- Gisting: Compressing LLM Agent context to ↑ throughput and ↓ cost
Shopify Engineering hardMasterShopify compressed the ~6,000-token system prompt of its Sidekick GraphQL agent into ~1,500 learned gist tokens (4:1) without losing prediction quality. The gist embeddings are trained by knowledge distillation (KL divergence between full-prompt teacher logits and gist-prompt student logits) with model weights frozen, then written into the embedding matrix so serving needs no special path. Gisting complements prefix caching because decode still streams the whole KV cache per generated token. At 350 RPM, median TTFT fell 19%, end-to-end latency about 38%, and throughput rose 16%, allowing 14% fewer GPUs. Key recipe findings from an autoresearch loop: initialize gists from mean prompt-chunk embeddings, batch-level loss normalization, and precomputed teacher logits cutting training from 30 to 6 hours.
- Token Pooling-Aware Training for Multi-Vector Embedding Models
Hugging Face hardMasterPooling-aware training teaches a multi-vector (ColBERT-style) encoder to keep retrieval-relevant information when document token vectors are merged by Ward hierarchical clustering, improving quality at a fixed storage budget. On a ModernBERT-base model trained on 120k MS MARCO triplets, pool_factor=4 retains 94.6% of unpooled NanoBEIR nDCG@10 with ordinary training versus 97.8% with a loss that averages unpooled and pooled retrieval objectives, while cutting document vectors 4x. Sentence Transformers provides HierarchicalTokenPooling (pool_factor, max_tokens or calibrated distance_threshold), a straight-through estimator for gradients through clustering, a MultiVectorTokenPoolingLoss wrapper, and optional CUDA kernels that make Ward clustering 30-150x faster than SciPy.
- Bamba: Inference-Efficient Hybrid Mamba2 Model
Hugging Face hardMasterBamba-9B is a hybrid Mamba2 language model from IBM, Princeton, CMU and UIUC, trained on 2.2T tokens of fully open data. It interleaves full attention layers with Mamba2 layers to keep KV-cache growth small. In vLLM on an H100, it reaches about 2.5x the throughput and 2x lower latency of Llama 3.1 8B at larger batch sizes and sequence lengths. On benchmarks it trails SOTA transformers mainly on math and MMLU, which the team attributes to fewer training tokens and no benchmark-aligned annealing data, and it beats Olmo 7B trained on the same token budget. Checkpoints, training recipes, a stateful data loader and support in transformers, TRL, vLLM and llama.cpp are released.