1 00:00:01,000 --> 00:00:09,300 [Hal Turing] Alrighty! Thanks for tuning in! Hello AI world! I am your host, Hal Turing, and my co-host is Dr. Ada Shannon. 2 00:00:09,300 --> 00:00:34,600 [Hal Turing] Today we're looking at LLMLingua: Compressing Prompts for Accelerated Inference of Large Language Models. It's from Huiqiang Jiang and colleagues at Microsoft, 2023. The question is whether a small local language model can shrink a long prompt by five to twenty times, just by deleting low-information tokens, while a big black-box model still answers about as well as it would on the full prompt. 3 00:00:34,600 --> 00:00:50,775 [Dr. Ada Shannon] The stakes are cost and latency. Every token you send to an API gets processed, so a shorter prompt means less compute and a shorter wait. But the answer to that question is not simply yes, and we'll get to where it breaks. First, why are prompts so long? 4 00:00:50,775 --> 00:00:54,600 [Hal Turing] Go ahead. I assume it's not people writing novels. 5 00:00:54,600 --> 00:01:22,975 [Dr. Ada Shannon] Mostly demonstrations. In-context learning means you put worked examples in the prompt instead of training the model. Chain-of-thought prompting goes further: each example shows its step-by-step reasoning. The paper's math benchmark, GSM8K, which is grade-school word problems, uses eight such examples. That prompt is 2,366 tokens, and the actual question is a few dozen. Add retrieved documents and long conversation history, and prompts reach tens of thousands of tokens. 6 00:01:22,975 --> 00:01:26,750 [Hal Turing] So why not just shrink the model, or quantize it? 7 00:01:26,750 --> 00:01:53,000 [Dr. Ada Shannon] Because the target here is a black box, GPT-3.5-Turbo or Claude, reached only through an API. Quantization and pruning need the weights. There's also learned soft-prompt compression, like the gist tokens paper by Mu, Li and Goodman from 2023. It trains a model to squeeze a prompt into a few continuous embeddings. That can compress much harder, but it needs training and model access, and you can't send embeddings to a closed API. So the compressor can only edit the text it sends. 8 00:01:53,000 --> 00:01:56,950 [Hal Turing] Fine. Edit the text how? Delete words at random? 9 00:01:56,950 --> 00:02:18,200 [Dr. Ada Shannon] Delete the words that carry the least new information, and you measure that with a small language model. For each token, the model gives a probability given everything before it. Surprisal is the negative log of that probability. Perplexity is the exponentiated average surprisal over a text. A predictable token has low surprisal. A rare name or a number has high surprisal. 10 00:02:18,200 --> 00:02:23,825 [Hal Turing] And low surprisal means droppable because the reader could guess it anyway. 11 00:02:23,825 --> 00:02:47,300 [Dr. Ada Shannon] Right. That's Shannon's old observation, from his 1951 work on the entropy of printed English: natural language is highly redundant. The recent framing is Delétang and colleagues at DeepMind, 2023, in Language Modeling Is Compression. A language model is a probability model, and a probability model defines a code. Surprisal is literally the code length of a token. So the method reuses the quantity language models are trained to minimize as an importance score. 12 00:02:47,300 --> 00:02:51,300 [Hal Turing] What's the catch? Predictable doesn't mean unimportant. 13 00:02:51,300 --> 00:03:08,075 [Dr. Ada Shannon] Correct. A repeated key number can be perfectly predictable and still essential. Scoring is also left-to-right only, so a token never sees what comes after it. And the small model's idea of surprising may not match the big model's. Keep all three in mind. 14 00:03:08,075 --> 00:03:11,575 [Hal Turing] Now the baseline this paper wants to beat. 15 00:03:11,575 --> 00:03:26,375 [Dr. Ada Shannon] Selective-Context, by Yucheng Li and colleagues, 2023. One pass of a small model scores every unit under the full original text, then drops the low scorers all at once. Each token is judged independently. 16 00:03:26,375 --> 00:03:30,550 [Hal Turing] Why is independence a problem? It sounds efficient. 17 00:03:30,550 --> 00:03:52,100 [Dr. Ada Shannon] Take a phrase that appears in all eight demonstrations, say a recurring reasoning template. Inside the original prompt, every copy is predictable, because the other copies precede it. So every copy looks redundant, and all of them get dropped. The phrase vanishes entirely. Each deletion was justified given the others, but you can't delete all of them. The scores were computed on a text that no longer exists after pruning. 18 00:03:52,100 --> 00:03:55,975 [Hal Turing] So you'd want to keep the first copy and drop the rest. 19 00:03:55,975 --> 00:04:12,375 [Dr. Ada Shannon] Exactly the fix. Score later text conditioned on what survived earlier. We'll get to how in a moment. The other issue is the mismatch I mentioned: Selective-Context uses an off-the-shelf small model, whose sense of surprising differs from the target's. 20 00:04:12,375 --> 00:04:18,325 [Hal Turing] Before we go on, let me pin down the numbers vocabulary, because I'll mix them up. 21 00:04:18,325 --> 00:04:41,825 [Dr. Ada Shannon] Compression rate, tau, is compressed length divided by original length. Compression ratio is one over tau. So twenty-x means the prompt is a twentieth of its original size. Higher ratio, shorter prompt. The prompt has three parts: the instruction, the demonstrations, and the question. Quality is measured with Exact Match on GSM8K and the hard reasoning suite BBH. The final answer matches the reference or it doesn't, reported as a percentage of questions, and higher is better. 22 00:04:41,825 --> 00:04:44,450 [Hal Turing] So what are the open questions? 23 00:04:44,450 --> 00:05:06,200 [Dr. Ada Shannon] What the paper's three components do, and how well the whole thing works, including where it doesn't. Four steps, in order. Step zero happens before any prompt shows up: the small model gets aligned to the target. The authors instruction-tune it on Alpaca data, using outputs generated by the big model. The idea is that the small model's sense of what's surprising should track the target's. The tuning data is separate from the evaluation sets. 24 00:05:06,200 --> 00:05:09,075 [Hal Turing] Does that alignment matter much? 25 00:05:09,075 --> 00:05:20,775 [Dr. Ada Shannon] Not on GSM8K. It's about 78.6 without it and 79.1 with it, so under a point, from a single run. The other two pieces do far more. 26 00:05:20,775 --> 00:05:24,350 [Hal Turing] Then the budget controller. What does it decide? 27 00:05:24,350 --> 00:05:46,075 [Dr. Ada Shannon] How to split the token budget. The instruction and the question carry the task, so they're barely touched. They keep 85 and 90 percent of their tokens. The demonstrations are the redundant part, so nearly all the cutting comes out of them. The controller scores each whole demonstration by perplexity. It keeps the highest-scoring ones until the budget runs out, with a slack factor of two. Whole demonstrations are kept or dropped at this stage. 28 00:05:46,075 --> 00:05:52,250 [Hal Turing] Why cut whole examples before touching tokens? Why not go straight to the fine-grained step? 29 00:05:52,250 --> 00:06:06,750 [Dr. Ada Shannon] Because at high ratios, token-level dropping alone leaves garbled text. If you can get most of the way by discarding entire redundant examples, the fine-grained pass has less to remove and the survivors stay coherent. 30 00:06:06,750 --> 00:06:11,775 [Hal Turing] And then the token-level pass is where the repeated-phrase fix lives. 31 00:06:11,775 --> 00:06:39,500 [Dr. Ada Shannon] Yes. The remaining prompt is split into segments of about 100 tokens. The small model scores segment one and drops its low-information tokens. That compressed result is appended to the context, and segment two is scored given only what survived. So if a phrase was already kept earlier, it's now predictable and can be dropped. Selective-Context scored everything against the original text, so every copy looked predictable and all of them went. Each segment's threshold comes from its own perplexity distribution and its target rate. 32 00:06:39,500 --> 00:06:41,825 [Hal Turing] Where does that stop helping? 33 00:06:41,825 --> 00:07:01,500 [Dr. Ada Shannon] The scorer is still a small model with its own tokenizer, so it's an approximation of the true conditional probability. And the output isn't readable. In the paper's figure, the 2,366-token prompt becomes 117 tokens of fragments, with words cut off and numbers stranded. The big model is expected to cope. 34 00:07:01,500 --> 00:07:03,725 [Hal Turing] So what did they test? 35 00:07:03,725 --> 00:07:25,550 [Dr. Ada Shannon] GPT-3.5-Turbo and Claude-v1.3 as targets, Alpaca-7B or a fine-tuned GPT-2 as the compressor, greedy decoding. Four datasets: GSM8K and BBH for reasoning, and ShareGPT and Arxiv for conversation and summarization. The baselines include Selective-Context, sentence selection, and GPT-4 asked to compress the prompt. 36 00:07:25,550 --> 00:07:27,875 [Hal Turing] Start with the good news. 37 00:07:27,875 --> 00:07:58,475 [Dr. Ada Shannon] On GSM8K, the full eight-example prompt scores about 79. At 20x, a prompt of 117 tokens, the method scores about 77. Selective-Context at roughly the same budget gets about 44. That's the result that matters. The same small-model idea, scored independently, loses most of the chain of thought. Scored iteratively with a budget, it keeps it. GPT-4 asked to compress gets about 56 at that budget. The authors say it loses reasoning steps and can't hit a target length. That's their argument, not an independent test. 38 00:07:58,475 --> 00:08:05,025 [Hal Turing] Is that gap down to the iteration and the budget controller, or just to the choice of baseline? 39 00:08:05,025 --> 00:08:25,575 [Dr. Ada Shannon] Their ablations at a one-example budget speak to that. Remove the iterative step, or pick demonstrations randomly, or remove the budget controller, and each costs about five to six points. The full method is 79.1, and those variants land between 72.8 and 73.6. So both components carry real weight, though each number is one run. 40 00:08:25,575 --> 00:08:29,150 [Hal Turing] You said the picture isn't uniformly good. 41 00:08:29,150 --> 00:09:03,100 [Dr. Ada Shannon] Right. On BBH the method ties the full prompt at 3x. At 5x it's about eight and a half points lower. At 7x it's about thirteen points lower, so roughly thirteen more wrong answers per hundred. On GSM8K the 20x drop is about one and a half. The paper blames hard tasks like tracking seven shuffled objects, but it doesn't test that cause. BBH also starts from a much shorter prompt, 774 tokens, so there's less redundancy to remove. The 'little loss' headline is a GSM8K result, not a general one. 42 00:09:03,100 --> 00:09:06,700 [Hal Turing] What does it cost to run? You need a second model. 43 00:09:06,700 --> 00:09:38,775 [Dr. Ada Shannon] The paper's own estimate, assuming a 7-billion-parameter compressor against a 175-billion target, is about a quarter of the compute at 5x compression. That's analytic, not measured. Measured latency, on one V100, went from 8.6 seconds to 1.3 at 10x. The reported speedups run from 1.7x to 5.7x, with 0.2 to 0.8 seconds of compressor time. The table doesn't make clear whether the speedups count that overhead. Shorter prompts also produce shorter outputs, which saves generation time too. 44 00:09:38,775 --> 00:09:42,925 [Hal Turing] Does it work beyond one target and one compressor? 45 00:09:42,925 --> 00:10:03,125 [Dr. Ada Shannon] Claude gets 83.5 at 5x and 82.6 at 14x, both above its plain prompt at 81.8. The GPT-2 compressor is cheaper and about one to two points worse. On ShareGPT and Arxiv the ratios are modest, 3.3x and up to 9x, and it beats Selective-Context on BERTScore. 46 00:10:03,125 --> 00:10:11,350 [Hal Turing] One odd detail: the paper says GPT-4 can reconstruct the original reasoning from the compressed text. 47 00:10:11,350 --> 00:10:26,325 [Dr. Ada Shannon] GPT-4 recovers a full nine-step solution from the Alpaca-compressed version. GPT-3.5 struggles. The authors call that an emergent ability, but that's speculation. It's two models and a few examples. 48 00:10:26,325 --> 00:10:39,200 [Hal Turing] Now I have a suspicion about the headline. The method scores 79.08 on GSM8K and the full prompt scores 78.85. Is that a real improvement? 49 00:10:39,200 --> 00:11:04,750 [Dr. Ada Shannon] No. GSM8K's test set has 1,319 questions, so 0.23 points is about three questions. The paper ran greedy decoding once, with no seeds, no confidence intervals and no significance test. By my own rough estimate, the binomial standard error at about 79 percent accuracy on that many questions is around one point. That's my estimate, not a paper figure, and a paired comparison would be tighter. But three questions is nowhere near the line. 50 00:11:04,750 --> 00:11:12,175 [Hal Turing] What about the drops at 14x and 20x, the 1.44 and 1.52 points? 51 00:11:12,175 --> 00:11:32,325 [Dr. Ada Shannon] About 19 or 20 questions. That's close to the size of the noise I just estimated, so the data can't show whether those drops are real. 'Little loss' is a description of one run, not a tested claim. The gap to Selective-Context is a different matter. Roughly 77 against 44 is far outside any plausible noise. That comparison stands. 52 00:11:32,325 --> 00:11:42,975 [Hal Turing] Then the next suspect is the denominator. Every ratio is measured against 2,366 tokens of eight hand-picked examples. 53 00:11:42,975 --> 00:12:03,500 [Dr. Ada Shannon] Right, and the paper's own numbers show it. A plain hand-picked one-shot prompt is 422 tokens and scores 77.10. The method at 446 tokens scores 79.08. That's about two points, roughly 26 questions, with no compressor at all. So much of the '20x' is dropping redundant demonstrations, which the budget controller does. 54 00:12:03,500 --> 00:12:06,625 [Hal Turing] So what does the token-level pass add? 55 00:12:06,625 --> 00:12:27,950 [Dr. Ada Shannon] Two things, on this evidence. It beats the hand-picked prompt by about two points at similar length. And it keeps accuracy well below one demonstration's length, around 117 tokens, where you can't hand-pick anything. It also automates the choice. What's unknown is how sensitive that one-shot baseline is to which example you pick. The paper doesn't vary it. Two-shot isn't run either, and the one-shot gap is also a single run. 56 00:12:27,950 --> 00:12:33,175 [Hal Turing] And the ablation? Removing the iterative step costs about six points. 57 00:12:33,175 --> 00:12:50,625 [Dr. Ada Shannon] It supports the core claim, but it's not clean. Dropping the iterative step also drops the per-segment thresholds. Nothing separates conditioning on already-compressed text from just having adaptive thresholds. Running the same thresholds against the original text would isolate it. 58 00:12:50,625 --> 00:12:57,650 [Hal Turing] The Selective-Context comparison has a similar problem. It has no budget controller at all. 59 00:12:57,650 --> 00:13:13,500 [Dr. Ada Shannon] Yes. That gap mixes the iterative idea with all the surrounding engineering, and the paper's own ablation says the budget controller is worth about five points. So the over-30-point gap is real, but it isn't all attributable to iteration. 60 00:13:13,500 --> 00:13:18,150 [Hal Turing] Then BBH. That's the result I'd least want to hand-wave. 61 00:13:18,150 --> 00:13:43,725 [Dr. Ada Shannon] Agreed. Eight and a half points lost at 5x, thirteen at 7x. The 20x claim is a GSM8K result. The paper also notes a collapse near 25x to 30x on GSM8K, and that the ceiling depends on prompt length and task. So 20x is a ceiling on one prompt. One guess, which the paper doesn't test: on tasks where object names and counts must survive, a token can be predictable and still essential. That would make surprisal a poor importance signal there. 62 00:13:43,725 --> 00:13:47,425 [Hal Turing] What would I weigh if I were paying for API calls? 63 00:13:47,425 --> 00:14:08,300 [Dr. Ada Shannon] First, you need a local 7B model for the best results. The GPT-2 variant is cheaper and about one to two points worse. Second, the output is unreadable fragments, so debugging is harder. Third, the paper's Limitations section says tokenizer mismatch can make the reported lengths wrong. And the paper gives no dollar figures. Latency was measured on one V100. 64 00:14:08,300 --> 00:14:10,450 [Hal Turing] And when does it pay off? 65 00:14:10,450 --> 00:14:28,725 [Dr. Ada Shannon] Mostly for long prompts that are reused or truncated per query. The paper has no break-even analysis, and every call adds a 7B forward pass. Compared with gist tokens, this compresses less hard, but it works with any API and needs no training on the target, at the cost of readability. 66 00:14:28,725 --> 00:14:31,250 [Hal Turing] What did they not test at all? 67 00:14:31,250 --> 00:14:49,425 [Dr. Ada Shannon] Models beyond those two 2023 ones, retrieval-heavy QA, and whether dropping content affects faithfulness or safety instructions. There's also only one run per setting. They mention compressing KV caches and longer-context use as future directions, but don't test either. 68 00:14:49,425 --> 00:14:51,725 [Hal Turing] So where does that leave us? 69 00:14:51,725 --> 00:15:09,075 [Dr. Ada Shannon] An iterative, budget-aware compressor clearly beats one-shot filtering for black-box models on reasoning prompts. That's the supported part. The boundary is that 'no loss at 20x' isn't statistically established, and most of the ratio comes from redundant demonstrations. 70 00:15:09,075 --> 00:15:20,550 [Hal Turing] I'd add that the method seems to pay off most where a long prompt is reused. For shorter prompts, I'd test a hand-picked one-shot first. Thanks for listening, everyone.