TLDR: A new research paper introduces a reinforcement learning (RL) approach that enables smaller language models (LLMs) to learn and improve at machine learning engineering tasks. By addressing challenges like variable action durations and sparse rewards through “duration-aware gradient updates” and “environment instrumentation,” these RL-trained agents can significantly outperform larger, static LLMs that rely solely on prompting, demonstrating the power of learning from experience in complex agentic settings.
In the rapidly evolving world of artificial intelligence, a new research paper from Stanford University challenges the conventional wisdom that bigger language models always mean better performance. Authored by Sherry Yang, Joy He-Yueya, and Percy Liang, the paper, titled Reinforcement Learning for Machine Learning Engineering Agents, introduces a groundbreaking approach where smaller AI models, empowered by reinforcement learning (RL), can learn and improve to outperform much larger, static models in complex machine learning engineering (MLE) tasks.
Traditionally, AI agents designed for tasks like ML engineering rely on simply prompting powerful language models. While these large models can be impressive, they have a significant limitation: they don’t learn from experience. Running them for days might yield slightly better results, but their core behavior remains unchanged without gradient updates. This new research proposes a paradigm shift, suggesting that even weaker models can become superior by continuously learning and adapting through RL.
Overcoming Key Challenges with Learning Agents
The researchers identified two major hurdles when applying reinforcement learning to ML engineering agents:
First, actions taken by an ML engineering agent, such as executing code to train different models, can vary significantly in duration. This variability leads to a problem where faster actions, even if suboptimal, receive more frequent gradient updates in a distributed RL setup. This bias can cause the agent to converge on quick but ultimately less effective solutions. To combat this, the team introduced duration-aware gradient updates. This method re-weights policy gradient updates based on the actual execution time of an action. By doing so, slower but potentially high-reward actions are given fair consideration, preventing the agent from always favoring speed over quality.
Second, the feedback available to these agents is often too sparse. The most natural reward, test split performance, only tells an agent if its entire solution worked or failed. A program that almost succeeds but has a minor error is treated the same as one that fails at the very first step, like data loading. This limited feedback can trap agents in suboptimal behaviors. To address this, the researchers developed environment instrumentation. This involves using a separate, static language model to insert ‘print’ statements into the code generated by the agent. When the code executes, these print statements log progress (e.g., “loaded data,” “trained model”), allowing the system to extract partial credit as reward signals. This partial credit guides the agent away from basic errors and towards refining its ML techniques.
The Power of Self-Improvement
Beyond these core innovations, the paper also explores a multi-step RL approach that includes a self-improvement prompt. This means the agent isn’t just asked to solve a problem from scratch; it can also be explicitly instructed to improve a previously generated solution. By providing feedback from past executions, the agent learns to refine its strategies, leading to even better performance.
Also Read:
- Agentic Reinforcement Learning: Empowering LLMs as Autonomous Decision-Makers
- Guiding LLM Learning: Adapting Exploration Based on Task Difficulty
Impressive Results on Kaggle Tasks
The effectiveness of this RL-driven approach was demonstrated on 12 Kaggle tasks from MLEBench. A relatively small, open-weight model, Qwen2.5-3B, trained with the proposed RL framework, significantly outperformed much larger, closed-weight models like Claude-3.5-Sonnet and GPT-4o, which were relying on advanced prompting techniques and agent scaffolds. On average, the RL-trained Qwen2.5-3B showed a 22% improvement over Claude-3.5-Sonnet and a 24% improvement over GPT-4o. The ablation studies further confirmed that both duration-aware gradients and environment instrumentation were crucial for these performance gains, enabling faster learning and convergence.
This research marks a significant step forward for AI agents in machine learning engineering. It highlights that with the right learning mechanisms, even smaller models can achieve superior performance by leveraging experience, paving the way for more adaptive and capable AI systems in the future.


