<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Ai on Shahid Shaikh</title><link>https://shaikhshahid.com/tags/ai/</link><description>Recent content in Ai on Shahid Shaikh</description><generator>Hugo</generator><language>en</language><lastBuildDate>Fri, 18 Sep 2026 13:56:17 +0000</lastBuildDate><atom:link href="https://shaikhshahid.com/tags/ai/index.xml" rel="self" type="application/rss+xml"/><item><title>Speculative Decoding</title><link>https://shaikhshahid.com/blog/speculative-decoding/</link><pubDate>Fri, 18 Sep 2026 13:56:17 +0000</pubDate><guid>https://shaikhshahid.com/blog/speculative-decoding/</guid><description>&lt;p>Speculative decoding is a technique in AI inference optimization where we combine a fast draft model usually smaller in parameter size with the actual large language model to help speed up token generation time.
It&amp;rsquo;s a very useful and widely adopted technique in inference engineering and optimization. Let&amp;rsquo;s look at how this works and tradeoff one needs to make in order to use speculative decoding in their inference pipeline.&lt;/p>
&lt;h2 id="how-speculative-decoding-works">How Speculative Decoding Works&lt;/h2>
&lt;p>Speculative decoding introduces a small parameter model that can work and generate next token faster than the large LLM model with reasoning capability. The small model is termed as &amp;ldquo;&lt;strong>Draft Model&amp;rdquo;&lt;/strong> in the diagram below. The draft model generates sequence of tokens and passes it to the actual model to evalulate and verify.
LLM evaluates the tokens and accepts the token which is correct and either replaces or rejects the tokens which are wrong. All of this happens in &lt;strong>one forward pass&lt;/strong> which saves times and improves performance.
&lt;img src="https://shaikhshahid.com/images/uploads/screenshot-2026-09-21-at-3-27-44-pm.png" alt="Screenshot 2026-09-21 at 3.27.44 PM.png">
Post verification stage LLM updates the KV cache with the accepted tokens and proceeds to generate more tokens required to process the prompt. This approach increases TPS (token per second) aggresively.&lt;/p></description></item></channel></rss>