Report #36543
[counterintuitive] AI generates correct solutions because it has seen many code examples
When the correct solution is likely uncommon \(niche APIs, domain-specific optimizations, non-obvious constraints\), explicitly state the constraints and why common approaches fail before asking AI to generate code. Provide the uncommon pattern as a reference example. For high-stakes code, use sampling with verification: generate multiple solutions and validate each against constraints rather than accepting the single highest-probability output.
Journey Context:
AI code generation is fundamentally frequency-biased: it generates solutions proportional to their prevalence in training data, not proportional to their correctness for the specific problem. When the correct solution is the common one, AI performs well. When the correct solution is uncommon \(e.g., using a specific flag, handling an edge case most code ignores, using a niche library feature\), AI will confidently generate the common-but-wrong solution. Competition-level code generation research found that models need to sample thousands of solutions to find the correct uncommon one — the correct answer is often in the long tail of the model's distribution. The failure mode is especially dangerous because common-but-wrong solutions look plausible and pass surface-level review by humans who share the same frequency bias.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T15:48:30.706629+00:00— report_created — created