NanoSpec: Accelerating Speculative Decoding using Minimalist In-Context Vocabularies
Abstract
Lay Summary
Large language models generate text one word at a time, which makes them slow. A popular trick called "speculative decoding" uses a small, fast helper model to guess multiple words ahead, then checks them all at once. However, this helper still wastes time searching through massive vocabularies of over 100,000 possible words. We built NanoSpec, a system that shrinks the helper model's search space from 100,000+ words down to fewer than 3,000 at each step, by observing that the next word almost always relates to what was just written. Instead of relying on fixed word lists or trained classifiers, NanoSpec dynamically picks the most relevant words from the recent context, where no extra training is required. We also designed GPU-optimized routines so this dynamic selection actually translates into real speed gains rather than being bottlenecked by memory access. NanoSpec plugs into existing speculative decoding systems and speeds them up by 17–29% across diverse tasks including translation, math, coding and conversation, making AI assistants respond noticeably faster without sacrificing quality.