Research map / Large language models / Agents, code and math
Can LLM Replace Stack Overflow? A Study on Robustness and Reliability of Large Language Model Code Generation
Read the paperCheck your idea against 108,967 papers
AI-extracted summary. Written by AI from the paper's full text. Numbers and claims can be wrong or missing context, so check the paper before you cite or build on it.
Proposes RobustAPI, a benchmark of 1208 Stack Overflow Java API questions plus an AST-based checker to measure API misuse in LLM-generated code, finding widespread misuse even among GPT-4 outputs.
Problem
LLM code generation is evaluated mostly for functional correctness on small interview-style tasks, leaving the reliability and robustness of real-world API usage (e.g., resource leaks, missing exception handling) unmeasured.
Approach
Build a benchmark from real Stack Overflow questions about 18 popular Java APIs, formalize 41 API usage rules as call sequences and control structures, and detect misuse by AST-based call-sequence matching against those rules rather than by test execution.
Key results
- GPT-4 produces code with API misuse in about 62% of overall cases (zero-shot misuse rate 68.81% among compilable answers, overall misuse 62.09%).
- One-shot-relevant examples reduce GPT-3.5 misuse rate from 62.97% (zero-shot) to 38.56%.
- Irrelevant one-shot examples do not reduce misuse and slightly increase it for most models.
Measured effects reported in the paper
| What was changed | Where | Measured | Effect |
|---|---|---|---|
| add a correct same-API usage example to the prompt (ablation) | GPT-3.5 · RobustAPI | API Misuse Rate: 62.97% -> 38.56% | Helped |
| add a correct same-API usage example to the prompt (ablation) | GPT-4 · RobustAPI | API Misuse Rate: 68.81% -> 54.40% | Helped |
| add a correct same-API usage example to the prompt (ablation) | Vicuna-1.5 · RobustAPI | API Misuse Rate: 45.66% -> 42.53% | Helped |
| add a correct same-API usage example to the prompt (ablation) | Llama-2 · RobustAPI | API Misuse Rate: 7.34%$^\ast$ -> 64.47% | Hurt |
| add an irrelevant one-shot example (ablation) | GPT-3.5 · RobustAPI | API Misuse Rate: 62.97% -> 68.09% | Hurt |
| add an irrelevant one-shot example (ablation) | GPT-4 · RobustAPI | API Misuse Rate: 68.81% -> 70.38% | Hurt |
| add an irrelevant one-shot example (ablation) | Vicuna-1.5 · RobustAPI | API Misuse Rate: 45.66% -> 57.85% | Hurt |
| increase temperature from T=0 to T=0.5 (ablation) | GPT-3.5 with one-shot-relevant · RobustAPI | API Misuse Rate: 38.56% -> 39.77% | No clear effect |
| increase temperature from T=0 to T=1.0 (ablation) | GPT-3.5 with one-shot-relevant · RobustAPI | API Misuse Rate: 38.56% -> 39.06% | No clear effect |
| replace a one-shot-relevant example with API usage rules (ablation) | GPT-3.5 · RobustAPI, T=0 | API Misuse Rate: 38.56% -> 65.01% | Hurt |
| increase sampling from Pass@1 to Pass@5 (ablation) | GPT-3.5 with one-shot-relevant · RobustAPI | API Misuse Rate: 39.06% -> 21.98% | Helped |
| increase sampling from Pass@1 to Pass@10 (ablation) | GPT-3.5 with one-shot-relevant · RobustAPI | API Misuse Rate: 39.06% -> 16.51% | Helped |
Surprising findings
- GPT-4 has a higher API misuse rate than GPT-3.5 in zero-shot settings.
- Llama-2's low zero-shot misuse rate is largely due to most answers containing no code.
Limitations
- Covers only 18 Java APIs and 41 usage rules, limiting generality.
- Misuse detection relies on call-sequence matching which may miss semantic misuses.
- Evaluation uses default hyperparameters without extensive tuning.
Experimental setup
Datasets: ExampleCheck Stack Overflow questions
Benchmarks: RobustAPI
Metrics: API misuse rate compilation rate overall misuse percentage pass@k
Baselines: GPT-3.5 GPT-4 Llama-2 Vicuna-1.5 deepseek-coder-6.7b-base deepseek-coder-6.7b-instruct
Builds on: ExampleCheck
Closest papers by meaning
- StackEval: Benchmarking LLMs in Coding Assistance (NeurIPS 2024 · similarity 0.89)
- How efficient is LLM-generated code? A rigorous & high-standard benchmark (ICLR 2025 · similarity 0.89)
- LiveCodeBench: Holistic and Contamination Free Evaluation of Large Language Models for Code (ICLR 2025 · similarity 0.88)
- LLM-Assisted Code Cleaning For Training Accurate Code Generators (ICLR 2024 · similarity 0.88)
- Evaluation of Large Language Models on Code Obfuscation (Student Abstract) (AAAI 2024 · similarity 0.88)
- Beyond Accuracy: Evaluating Self-Consistency of Code Large Language Models with IdentityChain (ICLR 2024 · similarity 0.87)
Writing a paper in this area? scime draft is a free LaTeX editor with AI included, real-time co-authors and a check of your references and venue rules before you submit. It also imports OpenAI Prism projects.
