Abstract
Large Language Models (LLMs) have demonstrated proficiency in isolated code generation tasks, yet their ability to navigate and utilize entire machine learning repositories remains under-explored. We introduce ML-BENCH, a comprehensive benchmark designed to evaluate LLMs and AI agents in real-world repository-level environments. ML-BENCH requires models to parse documentation, manage dependencies, and execute end-to-end machine learning tasks within a secure Linux sandbox. Our evaluation across 9,641 annotated examples from 18 prominent repositories reveals a significant performance gap between state-of-the-art models like GPT-4o and human experts, highlighting the challenges of repository-scale reasoning and the efficacy of iterative agentic workflows.
Introduction
While LLMs like GPT-4 have become remarkably adept at "function-level" code generation—writing standalone functions for benchmarks like HumanEval—they often stumble when faced with the complexities of a full repository. In professional software development, tasks are rarely isolated; they involve navigating hundreds of files, interpreting README instructions, and managing environment dependencies.
Current benchmarks often fail to capture two critical dimensions of real-world development. First is Contextual Complexity, where models must identify correct arguments and routines across multiple files in a large codebase. Second is Agentic Execution, where autonomous systems must iteratively refine their actions based on terminal feedback (e.g., resolving a ModuleNotFoundError by installing a package). ML-BENCH addresses these gaps by shifting the focus from simple code completion to repository-level task execution.
Methodology
The ML-BENCH framework comprises two distinct evaluation setups designed to test different aspects of model capability:
ML-LLM-BENCH (Text-to-Code)
This setup evaluates a model's ability to generate executable Python or Bash code given a user instruction and repository context. To understand the impact of context retrieval, it is tested in three scenarios:
- Oracle: Providing the exact relevant documentation needed for the task.
- Retrieval: Using BM25 to find relevant snippets from the repository.
- Code: Providing the raw repository files directly to the model.
ML-AGENT-BENCH (Autonomous Agents)
This "hardcore" setup places an AI agent in a secure Linux sandbox. The agent must autonomously explore the repository, set up the environment, download necessary datasets, and execute the task. It interacts with the system via a shell or Jupyter notebooks and must learn from execution errors.
Dataset Construction
The researchers constructed the ML-BENCH dataset, which includes 9,641 annotated examples derived from 18 prominent GitHub repositories, including BERT, Stable Diffusion, OpenCLIP, and the Deep Graph Library. The dataset features a mix of In-Distribution (ID) and Out-of-Distribution (OOD) repositories to test generalization across diverse domains such as Computer Vision, NLP, Graph Neural Networks, and Time-series analysis.
Key Insights and Results
Our evaluation yielded several critical observations regarding the current state of LLMs in software engineering:
- The "Needle in a Haystack" Problem: With repositories averaging 150,000 tokens, models frequently lose track of specific argument flags or file paths, struggling with "repository-scale" context.
- Bash as a Bottleneck: Interestingly, models found generating correct Bash scripts more challenging than Python code. They frequently hallucinated non-existent command-line arguments or misinterpreted how to chain commands.
- The Power of Iteration: In the agentic setup, models performed significantly better by utilizing "fail fast" loops. Seeing a traceback or a permission error allowed the agent to pivot and correct its course, mimicking a human developer's workflow.
- Human-AI Performance Gap: GPT-4o led the models with a Pass@5 rate of over 50% on the LLM benchmark, yet human experts (CS graduate students) achieved 86.76%. This indicates substantial room for improvement in repository-level reasoning. In the more demanding ML-AGENT-BENCH, GPT-4o (using the OpenDevin framework) achieved a 76.47% success rate, reflecting the efficacy of iterative feedback.
Conclusion and Future Work
ML-BENCH highlights that while LLMs are powerful, repository-level reasoning remains a significant hurdle. Documentation comprehension is a distinct skill, and the ability to "read the manual" (READMEs) is crucial for successful parameter configuration. The study underscores that open-source models like CodeLlama-7b still struggle significantly compared to proprietary models, even after fine-tuning.
Future work aims to expand the benchmark to include non-English repositories and more complex, multi-step research tasks that require deeper scientific reasoning beyond the instructions explicitly provided in README files.
Summary updated