TL;DR
This paper introduces a novel LLM-based agent system, "Generator-Validator" (G-V), designed to automatically create high-quality test cases for competitive programming problems. By applying this system to the existing CodeContests dataset, they create CodeContests+, a new benchmark with significantly improved test case accuracy, which in turn leads to better performance in training large language models for code generation.
What Problem Does This Paper Address?
Competitive programming problems are a powerful tool for evaluating and training the reasoning and coding capabilities of Large Language Models (LLMs). While problem statements and solutions are often publicly available, the crucial test cases that verify correctness are frequently missing or of low quality. This lack of high-quality test data hinders the creation of robust datasets for training and evaluating LLMs, leading to inaccurate assessments and suboptimal model performance. Existing methods for generating test cases, such as mutation or direct LLM output, suffer from limited coverage and incorrectness, failing to capture complex constraints or edge cases.
Methods
The core innovation is the Generator-Validator (G-V) agent system. This system comprises two LLM agents:
- Generator Agent: This agent writes C++ programs (generators) that can produce diverse test cases (random, corner cases, tricky cases) based on problem descriptions. It's instructed to generate commands that cover a range of data sizes and special types.
- Validator Agent: This agent writes C++ programs (validators) to rigorously check if the generated test cases adhere to all problem constraints.
The G-V system operates in a loop: the Generator creates test cases, the Validator checks them, and any failures are fed back to the Generator for revision. This iterative process ensures both comprehensive coverage and high correctness of the generated test cases. They also developed a custom checker agent to handle problems with multiple valid solutions, a common challenge in competitive programming.
Datasets
- CodeContests: The original dataset used as a base.
- CodeContests+: The newly created dataset, which is a version of CodeContests with its test cases replaced by those generated by the G-V agent system. They also created a "CodeContests+-Verified" subset by further filtering problems with exceptionally high test case quality.
Key Insights and Ideas
- Test case quality is paramount: The paper strongly emphasizes that the accuracy of LLM evaluations and training is directly tied to the quality of the test cases used. Poor test cases can lead to false positives (incorrect solutions being marked correct) and false negatives, rendering the dataset unreliable.
- LLM agents can automate complex test case generation: The G-V system demonstrates that LLMs can be effectively employed to write both test case generators and validators, automating a previously labor-intensive process.
- Iterative refinement is key: The Generator-Validator loop is crucial for achieving high-quality test cases, as it allows for continuous feedback and correction of errors.
- Multi-solution problems require specialized checkers: The need for custom checkers for problems with multiple valid outputs is highlighted as a significant challenge that the G-V system addresses.
Key Results
- Improved Test Case Accuracy: CodeContests+ demonstrated significantly higher accuracy in evaluating submissions compared to the original CodeContests. Specifically, it achieved a notably higher True Positive Rate (TPR), indicating better identification of correct solutions.
- Enhanced RL Training: Experiments showed that training a 32B LLM using reinforcement learning (RL) with CodeContests+ yielded a clear advantage over training with CodeContests, demonstrating the practical impact of higher-quality test data.
- Scalability: The G-V system can generate a large number of test cases by running the generator program multiple times with different random seeds, offering flexibility for various training and evaluation needs.
- Dataset Statistics: CodeContests+ contains 11,690 problems, with an average of 101 test cases per problem, passing validation at a 67.1% rate (compared to 1.72 million submissions).
Limitations and Future Work
- Few-Shot Prompting Limitations: The current G-V agent is based on few-shot prompting, and its performance could be further improved by fine-tuning the underlying LLM or using more powerful foundation models. The authors note instances where the model incorrectly utilized utility functions or attempted prohibited operations.
- Potential for Errors: While the G-V system significantly reduces errors, the validator agent can still make mistakes, particularly in understanding complex constraints. The authors acknowledge that a small number of incorrect data points might still be generated.
- Future Work: The authors suggest that further fine-tuning of the agent or the development of more advanced foundation models could lead to even better performance. They also envision the G-V system enabling the full utilization of the vast number of publicly available coding problems, laying the groundwork for further advancements in LLM reasoning and coding capabilities.
Summary updated