42x faster prompt lookup drafting in llama.cpp A developer writing as jadidbourbaki reports making prompt lookup decoding drafting in llama.cpp up to 42x faster while using up to 2.6x less memory, through performance optimizations based on work by Daniel Lemire and Martin Ankerl. The post details llama.cpp's three n-gram caches — context, dynamic, and static — and the scoring formula that drafts the next k tokens by selecting the highest-scoring token y* subject to thresholds a_n and p_n. Prompt lookup decoding, also called n-gram speculation, is supported by inference engines including llama.cpp and vLLM and by Hugging Face's transformers library. homepage https://jadidbourbaki.github.io/ github https://github.com/jadidbourbaki twitter https://x.com/jadidbourbaki