Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Hugging Face 6 min read Research hardMaster

Universal Assisted Generation: Faster Decoding with Any Assistant Model

Universal Assisted Generation (UAG) extends speculative decoding so the assistant model no longer needs the target's tokenizer. Draft tokens are translated in both directions through text, re-encoded with a window of preceding tokens, and aligned to the target sequence, and mismatched tokens are evicted from the assistant's KV cache. Benchmarks pair models such as gemma-2-9b, Mixtral-8x22B and Llama-3.1-70B with tiny cross-family assistants like vicuna-68m and Qwen2-0.5B and report 1.5x–1.9x speedups. UAG ships in Transformers 4.46 via the tokenizer/assistant_tokenizer arguments to generate(), and with sampling it currently supports only multinomial sampling, not speculative sampling.

Assumes: speculative decodingtokenizersKV cacheHugging Face Transformers

Related posts

  • Assisted Generation: a new direction toward low-latency text generation

    Hugging Face mediumAdept

    Assisted generation cuts autoregressive LLM latency by letting a much smaller assistant model with the same tokenizer greedily draft candidate tokens, then verifying them all in a single forward pass of the large model. The large model keeps matching tokens plus the first divergent one. The draft length adapts: it grows by 2 when every candidate matches and shrinks by 1 otherwise. The approach exploits the fact that forward passes are memory-bandwidth bound. In 🤗 Transformers it is exposed through an `assistant_model` argument to `generate` (batch size 1 only) and yields up to 2x speedups, 3x with INT8, and up to 10x when the model relies on memory offloading. It works best on input-grounded tasks like ASR and summarization, and with sampling only at low temperatures.

  • Faster Assisted Generation with Dynamic Speculation

    Hugging Face mediumAdept

    Dynamic speculative decoding stops the draft model's token generation as soon as its softmax confidence falls below a threshold (assistant_confidence_threshold), rather than always drafting a fixed or heuristically adjusted number of tokens before verification by the target model. An oracle analysis shows optimal speculation lookahead varies widely across iterations, so static values waste forward passes. On an RTX 4090 the dynamic schedule beat the heuristic in every tested model pair, reaching 2.71x on OPT-6.7B summarization and 1.52x for Llama-3.1-8B with Llama-3.2-1B where the heuristic gave no speedup. It is the default for assisted generation in Transformers 4.45.0 and can be tuned or reverted through generation_config parameters.

  • Speculative Decoding for 2x Faster Whisper Inference

    Hugging Face mediumAdept

    Speculative decoding speeds up Whisper transcription by about 2x while producing mathematically identical outputs. A fast assistant model drafts candidate tokens and the main model verifies them in a single forward pass. With Distil-Whisper (full encoder, 2 decoder layers) as assistant to Whisper large-v2, a 73-sample LibriSpeech benchmark dropped from 73s to 33s at the same 3.5% WER, with only about 8% extra VRAM from sharing the encoder. For multilingual use, a multilingual checkpoint such as Whisper tiny can serve as assistant, since the only hard constraint is an identical tokenizer. Note that large-v3's expanded vocabulary makes it incompatible with older checkpoints.

  • Faster Text Generation with Self-Speculative Decoding

    Hugging Face hardMaster

    Self-speculative decoding from the LayerSkip paper drafts tokens by exiting early from a model's own intermediate layers and verifies them with the remaining layers. Because no separate draft model is needed, weights, KV cache and compute for the first layers can be shared. It only speeds things up on checkpoints trained with the LayerSkip recipe (layer dropout plus early-exit loss), and Hugging Face transformers exposes it through the `assistant_early_exit` argument to `generate()`. On A100 benchmarks it reaches up to about 1.8x over autoregressive decoding and beats two-model speculative decoding for most Llama sizes except Llama2 70B. The best exit layer is a per-model tradeoff between draft accuracy and drafting cost.

  • Achieve state-of-the-art inference latencies with speculative decoding

    Modal hardMaster

    Speculative decoding is the dominant lever for low-latency LLM serving because decode steps dominate latency and speculation yields multiplicative speedups roughly linear in acceptance length. Working with Decagon's voice agents, Modal combined regional serving, SGLang host-overhead fixes, and open-source kernels with DFlash draft models that reuse target-model KV projections and draft tokens in parallel. Fine-tuning ("mid-training") the speculator on synthetic data generated by the target model from public prompts in the task's output grammar avoids exposing user data. The custom speculator cut about 100ms from a ~290ms p50 baseline, roughly 40% of server-side decode latency, and beat proprietary providers by over 60ms. Out-of-distribution evaluation was used to guard against overfitting.

The quest for software engineering knowledge.

Look:
Layout: