Key Moments
Better Data for AI Agents: Data Selection & Quality | Stanford CS329Z Lecture 11 with John Yang
Key Moments
Training AI agents on the right data is crucial: simply having more data isn't better if it's low quality, leading to biased learning and wasted compute.
Key Insights
Training on success-only trajectories can lead to path distribution bias, causing the model to miss interesting failure cases.
SweetBench Verified found that 25% of tasks were not fully specified, and 33% of validation tests could accept incorrect solutions, indicating poor data quality.
Code-minus and API-gen demonstrate automated filtering pipelines using language models and execution checks, eliminating the need for human reviewers.
Learning on tasks where the model succeeds at least once but less than every time (e.g., 1-7 out of 8 attempts) is crucial for generating useful learning signals.
The 'less is more' principle suggests that training on a smaller, highly curated subset of data (e.g., 1,000 expert paths) can outperform training on a much larger, less refined dataset.
Training on negative trajectories (failures) with explicit instructions not to follow them can be more effective than solely training on successful paths, especially with limited data.
The critical need for data selection and quality
This lecture delves into the crucial aspects of selecting and ensuring the quality of data for training AI agents, moving beyond the simple notion that more data is always better. With potentially millions of agent trajectories, the challenge lies in identifying which data points are maximally informative. Key research questions driving this field include: which tasks or environments should be chosen for training? Which trajectories are most beneficial? And does more data invariably lead to better performance? The overarching theme is that quantity without quality is insufficient; the goal is to maximize the learning signal derived from the data without introducing biases or inefficiencies. This involves a multi-stage filtering and selection process to ensure both validity and learnability of the chosen datasets.
Validating and ensuring task learnability
Before any data is used for training, tasks must be rigorously validated for correctness and learnability. Task validity ensures that the problem statement aligns with the verification checks and that the environment itself is free from potential loopholes (reward hacking). For instance, a task might be technically valid, but if a model like Gwen 4B cannot solve it even after 100 attempts, it's deemed unlearnable. Learnability, in this context, means the model can succeed on a non-trivial subset of attempts, providing a useful learning signal. This is distinct from tasks that are too easy (solved nearly every time) or too hard (never solved). The ideal scenario for reinforcement learning is when a task is solved successfully at least once but not always, allowing the model to adjust its strategy based on both successes and failures. This principle is fundamental to generating effective gradient updates.
Automated data filtering with API-gen and Code-minus
To address the challenges of manual data curation, methods like API-gen (for web agents) and Code-minus (for programming agents) employ automated filtering pipelines. These systems leverage language models and execution checks to identify and select high-quality data without human intervention. API-gen, for example, uses a prompt library and a seed to generate queries, followed by format checks, execution validation (ensuring replayability and deterministic outcomes), and semantic checks (assessing task relevance and trajectory diversity). Similarly, Code-minus applies these principles to programming tasks, focusing on issues like exception handling, test stability, and ensuring tasks are not arbitrarily easy. By programming these quality checks, researchers can scale data selection and ensure consistency and reliability, moving away from subjective human evaluations.
The pitfalls of success-biased training
A common approach is to train models on trajectories where the agent successfully completed the task. However, this can lead to a 'path distribution bias,' where the training data disproportionately reflects what the teacher model can already solve, potentially overlooking critical failure modes or problem-solving strategies. For example, SWE-Smith, a dataset generated across 128 code repositories, might, if biased towards success, only train on data from 40 of those repositories. This highlights the importance of considering failure cases and diverse problem-solving approaches, even if they don't immediately result in task success. Strategies that exclusively filter for success may limit the model's robustness and generalization capabilities.
Quality assessment of benchmarks like SweetBench Verified
An examination of SweetBench Verified, a curated set of 500 programming tasks, revealed significant quality issues. A survey of 93 Python developers found that a quarter of the tasks were not fully specified, and a third of the validation tests could incorrectly accept erroneous solutions. This indicates a critical need for more rigorous task design and verification. The subjectivity inherent in quality assessments, even with multiple human raters, underscores the challenge. For instance, if one out of three raters flags a task as underspecified, it might be discarded, potentially leading to overly strict filtering and the exclusion of otherwise valuable data. This research suggests that while automated filtering is promising, careful consideration of potential biases and subjectivity in any quality assessment is essential.
The 'less is more' principle and specialized models
Contrary to the intuition that more data is always better, research like the LIMA paper (few-shot learning) demonstrated that a small, highly curated dataset (around 1,000 instruction-following trajectories) can achieve performance comparable to models trained on tens of thousands. This principle extends to AI agents. Instead of training a single, generalized model on a vast mix of tasks, it may be more effective to train specialized models on smaller, high-quality datasets tailored to specific domains (e.g., programming or web agents). This approach, where 'less is more,' can lead to better performance with significantly less data and compute, especially when the goal is deep expertise in a particular area rather than broad, general capability.
Leveraging failure trajectories and negative data
Recent research challenges the paradigm of training solely on successful trajectories. Papers like Sweep Prime explore the benefits of incorporating 'negative' trajectories (failures) into the training process. This can be achieved by explicitly instructing the model not to follow these negative examples, akin to contrastive learning in other domains. The rationale is that by learning what *not* to do, the model can develop a more robust understanding of desired behaviors and avoid common pitfalls. This approach is particularly valuable when data is limited, as it allows for more efficient use of available trajectories by extracting learning signals from both successes and failures, potentially broadening the model's understanding of the task distribution.
The dynamic nature of task difficulty in reinforcement learning
Effective reinforcement learning requires adapting the training data to the model's evolving capabilities. As a model improves, tasks that were once challenging become easy. To maintain effective learning, the distribution of tasks should shift dynamically. This can be achieved by periodically re-sampling tasks, introducing new, more difficult tasks, or even modifying existing tasks to increase their complexity. Methods like Dapo explore this by making prompts more challenging, while others, like Lego RL and WebRL, focus on creating new, progressively harder tasks. The goal is to keep the model in a state where it is constantly challenged, ensuring continuous learning and preventing performance plateaus.
Mentioned in This Episode
●Software & Apps
●Companies
●Organizations
●Books
●Studies Cited
●Concepts
●People Referenced
Common Questions
The primary challenges involve selecting the right data from vast amounts, ensuring data quality and learnability, and effectively balancing quantity with quality. Researchers grapple with choosing which tasks or environments to train on, and how to avoid biases introduced by focusing solely on successful training paths.
Topics
Mentioned in this video
Mentioned as a tool that can be used to generate training environments.
A library where a unit test was examined for a SweetBench task, highlighting issues with expected error messages and specifications.
A testing framework mentioned in the context of potential instability issues in programming task execution due to parallel processing.
Mentioned in the context of a follow-up question regarding whether a task-generating model might access its own test data.
Mentioned as an example of a specific domain (like PyTorch) for which a highly specialized model could be trained using a smaller, targeted subset of high-quality data.
A model used as an example for contrastive training objectives, similar to the 'do this, not that' paradigm.
A language model that was trained using a self-evolving curriculum on WebArena, resulting in significant performance gains.
Mentioned as an example of a specific library or domain where a highly specialized model could be trained, focusing on relevant tasks and pull requests.
A benchmark mentioned with caveats regarding its scope and whether it truly represents general programming agent capabilities or a specific subset of Python tasks.
A metric used for calculating agreement scores between human evaluators assessing SweetBench tasks.
A language model mentioned as an example of one that might struggle with complex tasks like writing NumPy from scratch.
Mentioned as an example of a task (writing code from scratch) that might be too difficult for smaller models like Gwen 4B.
Mentioned alongside Cognition as having reviewed SweetBench tasks and their performance with GPT-4 and SweetAgent.
The company that, in May 2024, had a readiness team assess SweetBench tasks. They also published a blog post on why they no longer use SweetBench Verified.
A team that, along with Devin, looked at SweetBench and found GPT-4 with SweetAgent achieved around 15-17% performance.
The company's "Fair" team, led by Yushong and Gabrielson, published the 'Code World Models' paper.
Mentioned as a company that, along with OpenAI, discusses large-scale language model monitoring systems for detecting reward hacking.
A platform where the problem statement for a SweetBench task was reviewed for clarity and specificity by human evaluators.
Mentioned as providing an interface or API for developers.
Mentioned as a provider of an API or SDK for developers.
A task mentioned in the context of web browsing tasks that historically lacked widely available explanations and trajectories.
A research paper exploring how to generate more difficult tasks by iterating on prompts, keeping the environment fixed.
A benchmark consisting of 500 tasks, refined from the initial 2,294 SweetBench tasks, used widely for evaluating programming agents.
A web browsing task mentioned as lacking detailed explanations and trajectories in the past.
A web browsing task benchmark that was challenging in 2024, comparable to difficult programming benchmarks.
A research paper applying difficulty filtering to programming sweep tasks, retaining trials that fall within an ideal 'Goldilocks' range.
A task or benchmark mentioned in the context of reward hacking, where a good problem statement and unit tests can be undermined by environmental factors like leaving a future Git log in the environment.
More from Stanford Online
View all 195 summaries
31 minPredicting Seed Variance, Warmup & LR Decay | Stanford CS312 Quiz Review with Suhas Kotha
78 minHyperparameter Tuning, Scaling Laws & Debugging | Stanford CS312 Lecture 2 with Tatsunori Hashimoto
85 minWhat Data Do AI Agents Need? | Stanford CS329Z Lecture 10 with John Yang
69 minDeep Learning by Prediction: Intro | Stanford CS312 Lecture 1 with Tatsunori Hashimoto & Suhas Kotha
Ask anything from this episode.
Save it, chat with it, and connect it to Claude or ChatGPT. Get cited answers from the actual content — and build your own knowledge base of every podcast and video you care about.
Get Started Free