Hello, I'm Maneshwar. I'm building git-lrc, a Micro AI code reviewer that runs on every commit. It is free and source-available on Github. Star git-lrc to help devs discover the project. Do give it a try and share your feedback.
A friendly, deep-ish dive into Consistency-based Self-adaptive Prompting (COSP), where LLMs build their own in-context examples with zero labels.
If you have ever tried to squeeze better reasoning out of a large language model, you have probably lived through one of these two nightmares.
Nightmare one: you go full few-shot.
You handcraft a few beautiful, worked-out examples, paste them into the prompt, and the model suddenly gets smart.
Except now you have to do that for every single task, and if you pick slightly different examples the accuracy wobbles like a shopping cart with one bad wheel.
Nightmare two: you go full zero-shot with the classic "Let's think step by step" trick.
No examples, no labor, very clean.
But without guidance the model sometimes wanders off into a reasoning path that sounds confident and is completely wrong.
So one path costs you effort. The other path costs you accuracy. Pick your poison.
Today I want to talk about a paper that basically said "why not neither" and got away with it.
It is called Consistency-based Self-adaptive Prompting, or COSP, from Wan and colleagues at Google. And the core idea is delightfully cheeky: let the model write its own in-context examples, using nothing but its own answers.
Let me walk you through it, because it is genuinely clever and you can steal the mental model even if you never touch the exact implementation.
The problem, illustrated by my own suffering
Before COSP, the "make my LLM reason better" toolbox mostly looked like a choice between doing a lot of manual work or accepting mediocre results.
The few-shot route is powerful but high maintenance.
You are not just writing examples once.
You are writing examples per task, re-checking them when the task shifts, and quietly praying your handpicked demos are representative.
It scales about as well as folding a fitted sheet.
The zero-shot route dodges all that labor, but it is flying blind.
There is no anchor telling the model what a good answer looks like, so it is easy for it to commit to a bad line of reasoning early and never recover.
COSP looks at both of these and asks a very good question: what if the examples do not have to come from us at all?
The big idea: the model is already generating great examples, we just do not use them
Here is the insight that makes the whole thing click.
When you ask a model a question several times, it does not always give you the same answer.
Sometimes it gives you the same answer four times out of five.
Sometimes it gives you five completely different answers.
That spread is not noise. That spread is information.
If the model keeps landing on the same answer across independent attempts, it is quietly telling you "I am pretty sure about this one."
If it is all over the place, it is telling you "I am guessing, please do not trust me here."
COSP uses that signal to pick which of the model's own responses are trustworthy enough to become in-context examples for a second pass.
The model produces the raw material, and consistency acts as the quality filter.
It is the best of both worlds fused into one move: zero-shot's zero-labor plus few-shot's guided accuracy.
How COSP actually works
COSP runs in two stages, then finishes with a vote. Here is the whole thing at a glance.
Let me break down the three scoring criteria, because this is where the paper earns its lunch.
1. Consistency. For each question, the model samples several reasoning paths.
COSP looks at how much the final answers agree.
Strong agreement means low uncertainty, which is a good sign the reasoning is solid.
The paper quantifies this with entropy over the answer distribution: low entropy means the answers cluster tightly, high entropy means chaos.
Low entropy responses are the candidates worth promoting to example status.
2. Repetition. Ever seen a model get stuck in a loop and repeat the same phrase like a scratched record? That kind of degenerate, repetitive output correlates with bad reasoning.
COSP penalizes it, so those responses do not sneak into the example set just because they happened to be "consistent" with themselves.
3. Diversity. If all your chosen examples are basically the same question in a trench coat, they do not teach the model much.
COSP encourages the selected demos to be varied, so the final prompt covers different flavors of the problem rather than four clones.
Put those together and you get a set of self-generated, self-vetted examples. COSP prepends them to the original questions, runs the model again, and takes a majority vote across the reasoning paths for the final answer.
It is essentially self-consistency wearing a nicer coat, with the added twist that the model's own confident answers become the teaching material.
Consistency as a confidence meter, with a worked example
Let me make the consistency idea concrete, because it is the heart of everything.
Say we ask this the classic way: "Henry had 11 dollars, got 18 more, then spent 10 on a game. How much does he have now?" We sample the model a few times and get a spread of answers.
Three out of four attempts land on 19.
That tight cluster is low entropy, which reads as high confidence, which makes this a trustworthy example to reuse.
The lone 27 gets outvoted and does not derail things.
Consistency did the quality control that a human labeler would normally have to do by hand.
But wait, is consistency the same as correctness?
No. And this is the part I want you to keep in the back of your head, because it is easy to get starry-eyed here.
Consistency is a proxy for confidence, not a guarantee of truth.
A model can be consistently, enthusiastically, repeatedly wrong.
If it has a systematic misconception, it will produce the same wrong answer over and over with total conviction, and COSP will happily hand that a gold star.
The reason COSP still works well in practice is that its criteria stack the odds in your favor rather than trusting any single signal.
Consistency, plus the repetition penalty, plus diversity, plus a final majority vote, together filter out a lot of the junk. It is not magic.
It is good statistics dressed as a prompting trick.
Does it actually help? The numbers
The honest answer: yes, meaningfully, and mostly for free.
Across the reasoning benchmarks in the paper, COSP reliably beats plain zero-shot chain-of-thought, and it often matches or edges past few-shot, without any handcrafted examples or labels.
The headline figure the authors report is an improvement of up to about 15 percent over zero-shot baselines, tested across three different LLMs.
A rough sense of the shape of the results on reasoning tasks:
| Task | Zero-shot CoT | Few-shot CoT | COSP |
|---|---|---|---|
| MultiArith | ~67% | ~81% | ~85% |
| AddSub | ~69% | ~72% | ~79% |
| GSM8K | ~21% | ~30% | ~30% |
| StrategyQA | ~57% | ~68% | ~65% |
Notice the pattern.
On several tasks COSP quietly overtakes even the few-shot setup that required human effort.
On the harder ones it lands in the same neighborhood.
Either way you are getting few-shot-tier results while paying zero-shot prices, which is a pretty good deal.
The takeaway
COSP's whole personality is that the model is already doing most of the work, we were just throwing the useful part away.
Instead of us curating examples, the model generates candidates, consistency filters them, and a vote seals the deal.
The mental model is worth keeping even outside this exact method: treat agreement across samples as a confidence signal, and let your best self-generated outputs bootstrap your next prompt.
That idea shows up all over modern LLM tooling now, and COSP is one of the cleaner places to first meet it.
If you take one thing away, let it be this: your model has opinions about which of its own answers are good. It would be rude not to ask.
AI agents write code fast. They also silently remove logic, change behavior, and introduce bugs โ without telling you. You often find out in production.
git-lrc fixes this. It hooks into git commit and reviews every diff before it lands. 60-second setup. Completely free.
Any feedback or contributors are welcome! It's online, source-available, and ready for anyone to use.
โญ Star it on GitHub:
HexmosTech
/
git-lrc
Free, Micro AI Code Reviews That Run on Git Commit
| ๐ฉ๐ฐ Dansk | ๐ช๐ธ Espaรฑol | ๐ฎ๐ท Farsi | ๐ซ๐ฎ Suomi | ๐ฏ๐ต ๆฅๆฌ่ช | ๐ณ๐ด Norsk | ๐ต๐น Portuguรชs | ๐ท๐บ ะ ัััะบะธะน | ๐ฆ๐ฑ Shqip | ๐จ๐ณ ไธญๆ | ๐ฎ๐ณ เคนเคฟเคจเฅเคฆเฅ |
git-lrc
Free, Micro AI Code Reviews That Run on Commit
GenAI today is a race car without brakes. It accelerates fast -- you describe something, and large blocks of code appear instantly. But AI agents silently break things: they remove logic, relax constraints, introduce expensive cloud calls, leak credentials, and change behavior -- without telling you. You often find out in production.
git-lrc is your braking system. It hooks into git commit and runs an AI review on every diff before it lands. 60-second setup. Completely free.
In short, git-lrc helps Prevent Outages, Breaches, and Technical Debt Before They Happen
At a glance: 10 risk categories ยท 100+ failure patterns tracked ยท every commitโฆ






Top comments (9)
Same blind spot as a self-consistency board dressed up as a check: three filters, still one model's prior underneath. A systematic misconception can land low-entropy, non-repetitive, and phrased four different ways without ever being a different opinion. All three criteria pass, and the wrongness gets a majority vote instead of getting filtered out. Worth measuring separately from accuracy: how often COSP's own confidence signal and ground truth diverge, since that number tells you when the filter is actively laundering a shared mistake rather than catching noise.
What I like here is the focus on the mechanism behind โCOSP: The Prompting Trick Where Your LLM Grades Its Own Homework.โ A useful follow-up would be one concrete before/after metric: what changed in latency, error rate, review time, or operator workload once the approach was applied?
Self consistency is a useful filter for "is the model sure," but it is a weak filter for "is the model right about this codebase." When we let the same family grade its own review comments, it tends to reward the answers it would have given anyway and miss the almost right bugs that only show up when a human opens the actual diff. For a commit time reviewer like git-lrc, I would treat COSP style agreement as a confidence score for which findings to surface first, not as evidence the finding is correct. The findings that survive a second model or a hard test still beat the ones that only agree with themselves.
The "spread is information, not noise" framing is the part worth stealing. One caveat I ran into using self-consistency as a confidence signal: it only holds when the errors are independent. If the model is systematically biased on a question type, confidently wrong the same way across all five samples, majority vote amplifies the bias, and COSP would happily promote a wrong answer into the demo set. Did the paper address filtering for that case, or is the entropy threshold the only guard?
Good writeup, and the entropy-as-proxy framing is the clearest I've read on this. My hesitation is with the proxy itself: consistency measures how strongly the model believes something, not whether it's true. Sample a confident wrong answer five times and you get five agreeing wrong answers and a very low entropy score.
We hit the same thing in reconciliation long before LLMs. Three systems agreeing on a number is not evidence the number is right. It's usually evidence they all read the same upstream source. Agreement only counts when the paths are actually independent, and self-consistency sampling shares a prior by construction.
Which doesn't kill it. It just means the low-entropy examples are the model's most confident region, not its most correct one, and those come apart exactly on the tasks where you needed the help. Have you seen it hold up on anything where the model's prior is wrong rather than just fuzzy?
Thanks bud
didnt know about this method, wonder if it works as well for complex logic or if it just fixes the easy stuff lol
Cool :D
Some comments may only be visible to logged-in visitors. Sign in to view all comments.