A Systematic Methodology for Evaluating Failure Independence in LLM-Generated Code
This paper introduces a systematic methodology to evaluate failure independence in LLM-generated code, revealing that while heterogeneous models offer some diversity, their implementations frequently share root causes and fail on the same test cases, thereby violating the independence assumption required for effective N-Version Programming.
Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer
Imagine you are building a critical bridge. To make sure it doesn't collapse, you decide to hire five different engineering teams to design the exact same support beam. The idea is that if Team A makes a mistake, Team B might get it right, and if Team C also gets it right, you can just go with the majority opinion. This is called N-Version Programming. It's a safety net that relies on one big assumption: that the teams are independent enough that they won't all make the exact same mistake.
For decades, we've known that human teams often fail this test. They read the same blueprints, use the same textbooks, and end up making the same errors. But now, we have Large Language Models (LLMs)—AI systems that can write code instantly and cheaply. The hope was that since these AIs are "different" from each other, they might act like a perfect team of independent engineers, failing in different ways so we could always trust the majority.
This paper asks a simple, crucial question: Is that hope real? Do these AI models actually fail independently, or do they all trip over the same invisible banana peel?
The Experiment: A "Code Olympics"
The researchers set up a massive experiment, like a coding Olympics.
- The Athletes: They used 12 different AI models (some from big tech companies, some open-source, some very smart, some less so).
- The Events: They gave them 224 different coding problems to solve.
- The Rules: They asked the AIs to write solutions in 5 different programming languages (like Python, C++, Java) and tried 3 different ways of asking (simple prompts, step-by-step reasoning, or "be creative" prompts).
- The Judges: They didn't just look at the code; they ran the code against thousands of test cases to see where it broke.
The Findings: The "Echo Chamber" Effect
Here is what they discovered, broken down into simple concepts:
1. The "Same Brain" Problem (Structural Diversity)
When the researchers looked at the code itself, they found that if you ask one specific AI model to write the same solution five times, it writes almost the exact same code every time. It's like asking a single person to write five different essays on the same topic; they will likely use the same vocabulary and sentence structure.
- The Metaphor: If you ask five different people to draw a cat, they might draw different breeds. But if you ask the same person to draw a cat five times, they will draw the same cat five times.
- The Result: To get different-looking code, you must use different AI models. Using the same model with different "prompts" (instructions) didn't help much.
2. The "Shared Blind Spot" (Behavioral Diversity)
This is the most important part. Even when the code looked different, the researchers checked where the code failed.
- The Metaphor: Imagine five different drivers taking a test drive. Driver A and Driver B might drive different cars and take slightly different routes, but they both hit the same pothole at the exact same time.
- The Result: The AIs were not independent. They frequently failed on the exact same test cases. Even when using 12 different models, they tended to trip over the same logical traps. If one AI failed a specific math problem, a different AI was very likely to fail that same problem too.
3. The Safety Net Has Holes (Reliability Gains)
The researchers tried to use the "Majority Vote" strategy (if 3 out of 5 AIs say the answer is X, we go with X).
- The Result: It helped a little bit, but not nearly as much as the theory predicted.
- If the AIs were truly independent, combining five of them should have made the system almost perfect.
- In reality, the improvement was less than half of what was expected.
- The Hard Truth: No combination of multiple AIs was ever more reliable than just using the single best AI model on its own. The "safety net" had too many holes because everyone was falling through the same holes.
4. Why Did They Fail? (Fault Analysis)
The researchers dug deep into why the AIs failed. They found that even when the errors looked different on the surface, they often came from the same root cause.
- The Metaphor: One AI might fail because it forgot to check if a number was negative, while another fails because it got confused by a large number. But both are actually failing because they don't understand the concept of "boundaries" in the same way. They share the same "reasoning weakness."
- The Result: The AIs aren't just making random mistakes; they are making systematic mistakes based on how they were trained.
The Bottom Line
The paper concludes that current AI models are not independent enough to be used in a "safety net" system where you rely on a majority vote to catch errors.
- Using different models helps a little: It's better to mix models than to use the same one five times.
- Changing the language or the prompt doesn't help much: Asking the AI to "be creative" or writing in Python instead of Java didn't stop them from making the same mistakes.
- The "Independence" Assumption is Broken: The idea that "different AIs will fail in different ways" is currently a myth. They tend to fail together.
In short: If you are building a critical system and thinking, "I'll just ask five different AIs and go with the majority," this paper warns you: Don't do it. They are likely to all get the same thing wrong, and you won't be any safer than if you had just asked the smartest single AI once.
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.