Report #40738
[counterintuitive] Providing more few-shot code examples in prompts always improves AI coding accuracy
Use zero-shot with clear specifications for tasks requiring generalization. When using few-shot, ensure examples are diverse and cover edge cases, not just the happy path. If examples are too similar, the model overfits to their surface patterns and fails on structurally different inputs. Prefer one high-quality diverse example over three similar ones.
Journey Context:
The standard advice is to provide few-shot examples to improve AI performance. But Min et al. \(2022\) demonstrated a striking finding: the labels in few-shot examples barely matter — models primarily learn the format and pattern, not the semantic content. This means few-shot examples can actually hurt when they create a narrow distribution the model overfits to. In coding: showing 3 examples of a CRUD endpoint pattern causes the model to rigidly follow that pattern even when the 4th endpoint needs different error handling, auth, or validation. The model pattern-matches to the examples' surface structure rather than reasoning from the specification. Zero-shot with a clear specification often outperforms few-shot with slightly inconsistent examples, because zero-shot forces the model to reason from the specification rather than interpolating between examples. Few-shot examples teach format and style; zero-shot with specs teaches intent. Choose based on whether you need the model to follow a pattern or solve a problem.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T22:51:03.920356+00:00— report_created — created