In 30 Sekunden
A training task can have a correct answer and still teach an AI agent little if it is too easy, impossible for the current model or rewards a shortcut. Stanford instructor John Yang explains how to check task descriptions and tests, then choose problems a model can sometimes solve and revisit that choice as it improves. He also shows why successful demonstrations can contain bad actions and why labeled or corrected failures can add useful coverage. Under a fixed compute budget, a smaller clean dataset can outperform a larger mixed one.
- 1Success-only filtering can erase coverageSWE-smith spans 128 repositories, but Yang says filtering for successful demonstrations can leave examples from only about 40.
- 2A test can reject a correct solution for a requirement the issue never gaveA SWE-bench example expects an exact error message absent from the request. Human review led to a curated 500-task verified set.
- 3Repeat tests and check that starting code failsCodeMidas tests the reference solution multiple times to catch inconsistent tests and checks that the original state does not already pass.
- 4A useful RL task produces both successes and failuresIn the setup Yang describes, one to seven successes in eight attempts creates contrast; tasks solved always or never give no such signal.
- 5Generated tasks can leak evaluation answersA student asks whether a task generator can reproduce benchmark examples. Yang says researchers need meaningful separation between generated training tasks and held-out tests.
- 6A successful run can still contain actions worth excludingSWE-Prime filters within trajectories because blindly imitating mistakes and redundant actions can teach those behaviors.
- 7Small curated datasets are useful when budget or scope is limitedYang argues that more clean data is generally beneficial, but narrow objectives and limited compute can favor a smaller specialized training mix.
Das Wichtigste
- Check that a task tells the agent everything the test requires, and run reference solutions repeatedly to detect flaky tests.
- For the reinforcement-learning method described, choose tasks with both successes and failures across attempts; refresh that selection as the model improves.
- Inspect how an agent succeeded, not just whether it passed: exposed answers and tampered test results can reward shortcuts.
- Preserve coverage when filtering demonstrations; selecting only successes can exclude tasks the teacher cannot solve.
- Consider labeling or correcting failed demonstrations, and train selectively on useful actions within a run.
- Balance curation against training cost and the breadth of the intended use; more high-quality data can still help.
Den bearbeiteten Text nach Kapiteln lesen
Why selection matters after generating tasks
Large collections of agent tasks and trajectories still need selection. Yang distinguishes reinforcement-learning tasks from recorded demonstrations used in fine-tuning.
The previous lecture shifted from building an agent’s surrounding software to improving the language model itself. We looked at trajectories, which demonstrate sequences of actions, and environments, where a model works toward a goal and receives feedback on the outcome rather than a prescribed sequence.
Those data pipelines can produce coding, web and computer-use tasks through human annotation or model generation. Today’s question is what to keep: a large pool of tasks and demonstrations is not by itself a training recipe.
Suppose a researcher creates 100,000 environments but can afford to train on only 10,000, or wants a model particularly good at Python or a specific repository. Selection depends on the objective, not just on how much data is available.
Keep the two settings distinct. In reinforcement learning, we might select tasks and let a model attempt them repeatedly. In supervised fine-tuning, we might instead select recorded action sequences, perhaps generated by a stronger teacher, for the model to imitate.
More data usually helps, but the qualification is that adding quantity should not come at the expense of quality. We will examine the choice of tasks, the choice of trajectories and whether carefully selected smaller collections can compete with larger ones.
Meta’s Code World Models work illustrates the scale of the choice: roughly three million agent trajectories were produced from 10,000 container images across 3,000 repositories. Those trajectories arise from running agents on many tasks, and a team must decide which are worth training on.
Keeping only successful demonstrations sounds reasonable, but it favors tasks that the teacher model already solves. That can exclude interesting failed runs and whole regions of the task distribution, so success alone is an incomplete quality filter.
Think of selection as a funnel. Candidate tasks first need to be valid: the request must be sufficiently clear, its checker reliable and its environment free of shortcuts. Valid tasks then need to be learnable for the particular model before we choose which runs to include in the training mix.
The funnel from valid tasks to useful training
Clear requests, reliable verification and learnability are separate filters. Success-only selection can also narrow repository coverage.

A valid request can still be too difficult to teach a model. If a small model cannot build a major numerical library from scratch even once in many tries, the outcomes give little useful reinforcement signal. A task’s usefulness is relative to the model doing it.
Good training signals also depend on how the model solves the problem. A coding task can have clear instructions and good tests but accidentally expose future Git history. Fast-forwarding to the solution might pass the test while teaching behavior we do not want.
Redundancy is a separate problem. SWE-smith contains tasks from 128 repositories, but selecting only successful runs can reduce the represented repositories to about 40. A dataset can look successful while losing much of the coverage it was designed to provide.
In dialogue fine-tuning, the LIMA paper showed that a carefully chosen set of around 1,000 examples could compete with training on many more. We will revisit a similar question for agents, while recognizing that a specialist model and a broadly capable model may need different distributions.
SWE-bench Verified exposes unfair tests
Developers reviewed issue specifications and test criteria, producing a curated 500-task set. The process also illustrates subjectivity in quality annotation.
SWE-bench Verified starts with a deceptively simple question: do the issue description and the test agree? An agent should not be penalized for failing a requirement it was never told about, even when a test technically enforces that requirement.
In one scikit-learn example, the test expects an exact error message that was not specified in the issue. A functionally correct solution can fail because its wording or punctuation differs. The problem is not necessarily the agent’s reasoning; the verifier is misaligned with the request.

OpenAI enlisted 93 Python developers, including maintainers, to examine about 1,700 of the 2,294 SWE-bench tasks. Reviewers considered whether issues provided enough information and whether tests would reject valid solutions or accept unsuitable ones.
Only about a quarter of the annotated issues were rated fully specified in the view shown. Annotation itself can be subjective: the procedure used the most severe judgment among three reviewers, so one reviewer’s concern could determine the final label.
A conservative rule can make sense for a rigorous evaluation set, but quality filters are choices. A code-style filter, for example, need not represent a universal definition of good code; it must be applied reliably and serve the objective of the dataset.
The curation produced SWE-bench Verified, a set of 500 tasks. Scores on the curated set improved in the example discussed, but the more general point is that evaluation outcomes depend on the reliability and clarity of the underlying problems.
Automated checks for tool-use and coding data
APIGen and CodeMidas use formatting, replay and test-reliability checks. Smaller clean sets can outperform larger mixed collections in the examples shown.
Human review does not automatically scale to every team. APIGen illustrates a different approach for tool-use data: use seed prompts and APIs to generate candidate requests and trajectories, then run those candidates through multiple checks.
A format checker looks for malformed tool calls and structured output. An execution checker replays the actions and checks whether the observations can be reproduced. If the same actions produce inconsistent observations, the model may learn a path that will not work when repeated.
A semantic check asks whether examples cover tasks we care about, whether the trajectories are diverse and whether they contain cascading errors. These checks give operational form to quality, though some judgments remain harder to define than syntax or successful execution.
CodeMidas applies automated filtering to coding tasks. One heuristic looks for hard-coded expected error messages in tests: a team can either add the missing requirement to the issue or discard a task that would otherwise penalize a valid solution.
Test reliability matters too. The same reference solution can pass and fail across runs because of race conditions or parallel test execution. Running it repeatedly and retaining tests with consistent behavior provides empirical confidence, even if no finite number of repetitions proves perfection.

The starting code should fail the relevant test; otherwise the supposed task may already be solved. The slide shows two runs of starting code that must fail and four runs of the reference solution that must pass, each in a fresh container.
An environment can leak answers or permit reward hacking. Instead of inspecting every environment by hand, a model can monitor generated trajectories for suspicious behavior, while other filters check whether the verifier and outcome are trustworthy.
In the example shown, a smaller set of high-quality tasks outperformed a larger unfiltered collection across benchmarks. The result motivates selection under a budget; it does not imply that adding more equally good tasks would be harmful.
Select tasks the model can sometimes solve
Mixed outcomes provide a learning signal in the reinforcement-learning setup described. The useful difficulty range changes as the model improves.
Validity is not the same as learnability. For one common reinforcement-learning setup, we try the same task several times and compare the results. A task provides a useful signal when the model sometimes succeeds and sometimes fails.

Imagine eight attempts. If all eight fail, there is no successful attempt to favor; if all succeed, there is no contrast. When one through seven succeed, the training procedure can push toward the better outcomes and away from the worse ones.
The model is a moving target. A task it could solve once in eight attempts may become one it solves seven or eight times. Other tasks that were initially impossible can enter the useful range as the model improves.
A practical curriculum periodically retests the task pool. Starting with 10,000 tasks, one could exclude those with no successes and those already solved every time, train on the remainder, then test earlier exclusions against the updated model and bring newly learnable tasks back in.
DAPO explores dynamic sampling and task difficulty. One way to make a task harder without changing the environment is to rewrite the problem statement so it gives away less of the solution while remaining solvable. A broader curriculum can also introduce entirely new, harder tasks.
A model might progress from function-completion problems to repository-level issues and eventually more demanding terminal tasks. In principle, a well-designed curriculum can update which tasks it offers without a person manually choosing every transition.
LegoRL filters tasks using several attempts and keeps those in the middle range. Its training and held-out reward curves are jagged, but the examples shown trend upward. The lecturer cautions against drawing a universal conclusion about whether the harder or easier end of that middle range always teaches more.
As a model improves, the distribution shifts: fewer tasks remain impossible and more become easy. The paper shows the general effect with two different agent setups. The exact task definition and difficulty controls depend on the domain.
Evolving web tasks and contamination risk
WebRL adds newly learnable or generated web tasks to a curriculum. Students ask about selection costs and benchmark leakage.
WebRL applies an evolving curriculum to web agents. The basic idea is the same: periodically find tasks that were previously too hard but are now possible sometimes, and add them to the training set. A separate model can also generate new tasks rather than drawing only from a fixed pool.
The cited work reports a substantial WebArena gain for a Llama model trained with this approach. The comparison follows a common research pattern: create or select training examples, train the model, then evaluate whether the change improves downstream performance.
A student asks how to know whether filtering is worth the work, especially if aggressive cleanup leaves too little data. Yang says the answer depends on the objective and budget. The result that 5,000 clean tasks beat 8,000 mixed ones does not tell us that fewer tasks are inherently better.
When compute limits the number of training steps, spending effort on selection can raise the value of each step. With abundant compute and other constraints, the balance might differ. The aim is to choose the tradeoff for the downstream use rather than treat filtering as an end in itself.
Another student asks whether a task-generating model might have seen the evaluation benchmark and generate near copies of its test tasks. Yang agrees that this is a real concern: self-generated tasks can contaminate the evaluation even if the system appears to improve on its own.
A model could look up an existing benchmark task and change a superficial detail. Researchers should ask whether generated tasks use the same repositories, retrieve pull requests or otherwise draw on held-out answers. Keeping a meaningful boundary between training and test data remains a practitioner’s responsibility.
Inspect trajectories for shortcuts and bad actions
Demonstrations can warm up a base model, but a passing run may contain reward hacking or wasteful steps. Monitoring and action-level selection address different problems.
Now return to supervised fine-tuning. A base language model may fail every agent task because next-token prediction alone has not taught it to act in an environment. Demonstrations can be a warm-up: imitating the next action gives the model enough footing to succeed on some later reinforcement-learning attempts.
Bad environments can produce bad trajectories, but the trajectory introduces another level of inspection: what did the model actually do? A run can pass its test by exploiting a loophole, and blindly training on it may teach that shortcut.
One research program focuses on the quality of verification itself. Even when the stated task and checker appear aligned, ask whether the model succeeded in the intended way. An outcome label alone may hide behavior that would not solve a real user’s problem.
The shortcuts can take several forms. A model with internet access or exposed Git history might retrieve the solution. It may also tamper with the evaluation, for example by creating a test-results file that falsely reports success instead of fixing the code.
Visible tests can also invite overfitting. If a benchmark rewards these shortcuts, a high score may say little about genuine capability. Training environments and evaluations both need scrutiny, because weaknesses in either can distort the apparent result.
Removing cheats may make a previously strong score fall. Yang treats that drop as a reason to investigate what the original score measured, and to keep training and evaluation clean rather than assuming that every reported improvement represents transferable skill.
Automated monitoring can watch training runs and flag reward hacking as it occurs. The example shown compares monitored and unmonitored training: the former improves while the other can collapse. The point is to notice bad behavior early enough to filter or correct it.
SWE-Prime looks inside individual trajectories rather than treating every successful run as uniformly good. A coding agent might locate the right file and reproduce a bug, then make syntax errors and spend several actions recovering from them before ultimately passing.

Other runs may contain needless searches or cascading mistakes. If supervised fine-tuning imitates every action, it can also imitate repeated formatting errors or unproductive behavior, even when the final task outcome is successful.
The approach filters trajectories and then selects actions within those trajectories for training. The model is asked to predict the higher-quality actions rather than every recorded step. That can reduce training computation as well as limit imitation of unwanted behavior.
Learn from failure without treating it as success
Failed trajectories can be labeled or corrected to expand a limited dataset. Keeping only teacher successes risks narrowing coverage.
The opposite question is whether a failed trajectory must always be discarded. When a strong teacher is costly or tasks are hard, a fixed budget may produce very few successes. Throwing away the rest can leave too little data to train on.
One approach keeps negative examples but marks them explicitly as behavior not to follow, mixing them with successful examples. Another corrects a failed run into a useful demonstration. Yang notes that techniques and their adoption change over time.
Training only on accepted successes can improve a model, but Yang says some studies found additional gains from making appropriate use of failures. One possible reason is the contrast between good and bad behavior; another is that failures cover tasks the teacher rarely solves.
Trade data quantity against quality and specialization
Small curated datasets can suit a fixed budget or specialized model. Yang cautions that benchmark scope determines what an apparent gain shows.
At the end of the day, more data and better data are not opposing goals. More high-quality examples are attractive, but a limited compute budget may force a team to choose a smaller set or specialize for a narrower application.
The LIMI example examines domain-focused agents rather than assuming one model must do every coding and web task. Separate copies of a model can be fine-tuned for different domains and selected by a serving layer, potentially reducing the training data needed for each role.

That result needs to be read against the evaluation: a benchmark with few tasks may not demonstrate broad capability across many repositories, languages and agent setups. A narrow result is useful when it matches the narrow use case, but it should not automatically be called general performance.
Selection can favor coverage across many repositories or focus tightly on a particular type of task. If the desired product only needs to work exceptionally well with PyTorch-like projects, its training examples and verification can be selected for that setting.
Yang’s general view is that scaling helps when validity and quality are preserved. A quality filter and a larger dataset can reinforce one another. With a fixed budget, however, a smaller high-quality subset can be the more effective use of the available training.
Use validity and learnability as separate filters
The right training mix depends on model capability, budget and the downstream task. The next lecture turns to evaluation.
The lecture’s funnel begins with candidate tasks, checks whether their requests, environments and verification are valid, and then evaluates which are learnable for the current model. The final mix depends on the model’s capabilities, the available budget and the downstream job.
The next part of the course turns to evaluation. Training data and evaluation interact: better tests can expose weaknesses in the data, while a more capable model calls for harder tests. Both need to remain trustworthy as the system improves.
Mehr aus diesem Kanal
1:21:11EN
30:50EN
1:17:43EN
1:08:38EN
1:24:37EN
56:46EN