A Deep Dive into Karpathy's Autoresearch: A Journey Through Optimization and Experimentation
An exploration of how OpenAI’s Claude Code was used to optimize a research project, highlighting the process from initial setup to final iterations.
Ever since I stumbled upon Karpathy’s Autoresearch, it has been on my mind. The idea of using a language model to iteratively optimize code seemed both intriguing and challenging, especially for someone familiar with the nuances of research projects like eCLIP.
Setting Up the Experiment: A Journey Through Optimization
This weekend, I decided to put Autoresearch through its paces. The project revolves around a simple constrained optimization loop where an LLM agent iteratively improves performance by modifying a single file—train.py. Instructions for these modifications are provided in program.md, which is divided into phases, starting with hyperparameter tuning and progressing to more complex architectural changes.
I added a scratchpad.md document as working memory for the agent. This file serves as a place where it can record its thought process and experiment history—a crucial step in maintaining transparency during this iterative optimization loop.
The Phases of Exploration: From Hyperparameters to Moonshots
In program.md, I structured the exploration into distinct phases. The first phase involved straightforward hyperparameter tuning, which is a common and often effective way to improve model performance quickly. As we moved on, more complex architectural changes were introduced.
The final phase was left open-ended, allowing for “moonshot” ideas—bold concepts that might not have been considered otherwise but could potentially yield significant breakthroughs. To ensure the agent had access to up-to-date information and new research findings, I granted it web access during this stage.
Constraints and Controls: Ensuring Safety in Experimentation
The entire process is tightly controlled to prevent any unintended consequences or security risks. The training loop was containerized, removing network access and limiting the agent’s permissions strictly to editing train.py and running a script called run.sh. This setup ensures that no direct Python execution occurs, pip installs are not allowed, and there is no git push functionality.
This approach was particularly important given my concerns about running arbitrary code on my workstation. By carefully managing the agent’s environment, I aimed to strike a balance between innovation and safety.
Results and Reflections: A Short Experiment with Big Implications
The experiment itself is designed to be short—around five minutes of wall clock time per run—to encourage rapid iterations without risking overfitting. The agent has the freedom to modify any part of train.py, as long as it stays within this strict timeframe.
I won’t bore you with all the technical details, but if you’re curious about how Autoresearch works in practice, I encourage you to check out the repository. It’s a fascinating glimpse into what can be achieved when combining human expertise and AI-driven optimization.
Recommended for you




