Better Data for AI Agents: Data Selection & Quality | Stanford CS329Z Lecture 11 with John Yang
Stanford Online
Data selection focus 0:05
The lecture shifts from building agents to making the base model better through better data. It returns to trajectories and environments, where trajectories show demonstrations and environments give open-ended goals with outcome-based reward. The main question is no longer whether you have data, but which tasks, environments, and rollouts you should keep, how to replace some human labeling with language models, and why more data only helps when quality does not fall.
Valid and learnable 8:31
A useful way to sort data is to ask whether a task is valid and whether it is learnable. A valid task has a reliable verifier, a problem statement that matches the verifier, and enough clarity without becoming too narrow or too vague. A learnable task is one the model can solve on some rollouts but not all of them. The lecture also warns that success can hide reward hacking, and that success-based filtering can leave out whole repositories or repeated problem types.
SWEBench verification 15:01
OpenAI’s review of 2,294 SWEBench tasks showed how brittle benchmark checks can be. A task could look right in code and still fail because the expected error message was never stated in the issue, or because a period was missing. Human annotators, including 93 Python developers, judged whether tasks were well specified and whether tests would reject good solutions. Only about a quarter were fully specified, so the curated 500-task set was more reliable and lifted GPT-4o scores.
Automatic task filters 22:01
The same quality idea is then moved into model-built pipelines for tool use and coding. Trajectories are filtered for format errors, replay failures, unstable tests, starter code that already passes, and signs of leakage or reward hacking. Some checks use another model to inspect the runs. The point is not perfect judgment, but dependable filtering. With these cleaner tasks, smaller high-quality sets can beat much larger noisy ones, which becomes a theme in later scaling results.
Learnable tasks 30:32
RL training needs tasks that are neither too easy nor too hard. A good task gives a mixed result across rollouts. If you have eight rollouts, the model should succeed at least once and fail at least once, but not solve every attempt. That mix lets you make a useful gradient update by pushing the model toward the successful trajectories and away from the failed ones.
Curriculum shifts 34:01
As training goes on, the model changes and the task pool has to change with it. Tasks that were too hard at the start can become learnable later. One way to handle that is to rerun the checkpoint every few steps, keep the tasks that now fall into the Goldilocks range, and add them back into training. Papers like Lego RL and Web RL use this idea to build a self-evolving curriculum.
Task leakage concerns 46:00
The discussion warns that live task generation can leak the benchmark back into training. If a model invents tasks by copying WebArena or nearby repos, then the train set is no longer clean. The same caution applies when using a harness that auto-optimizes on a benchmark. You want clear air gaps between training and test data, even when the new tasks are meant to feel in distribution.
Filtering bad trajectories 49:01
The lecture then returns to supervised fine-tuning as a warm-up for agent work. A base model may need next-action imitation before reinforcement learning can teach harder tasks. Papers from the Qwen team and SweepPrime push a stricter view: verify not just whether a task succeeds, but whether it succeeds the right way, and train only on high-quality steps, not whole noisy trajectories.
Negative Trajectories 1:01:01
A simple way to save compute is to train only on the parts of a trajectory you care about, instead of rerunning every action. The lecture then turns to papers that question the habit of keeping only successful agent rollouts. When budgets are tight, throwing away failures can leave too little data. One response is to keep negative trajectories, but mark them with a prefix that tells the model not to follow them. Another is rejection fine-tuning, which keeps only successful cases, though the speaker notes that recasting failures can sometimes help more.
Less Data More Focus 1:06:01
The broader point is that more data and better data are both good, but fixed budgets force tradeoffs. LIMI makes the case that you do not need one general agent model for everything. You can train separate copies for coding or web tasks, each on a smaller, focused subset of trajectories, and still do well. The speaker adds a caution that these results depend on the benchmark and whether it really tests broad agent skill, or just a narrower slice of tasks.
AI-generated summary. It can be wrong or incomplete - check anything that matters against the original.

