Master

The tuning loop as a program

Tuning is a loop: propose a change, run it, measure, keep or revert. Written as a program with the eval harness as the referee, it stops being a set of manual runs and becomes a search that a person can read the log of.

What you will see

The config with 0.79 and its score - the artifact you ship is defined by this line, not by the last run.

About 1 min of reading

Quick check

Before this new lesson, one small question about the lesson you just finished. Recall it, do not look it up.

Try It

Track the best.

1

The log

runs = [({'ep':3},0.61), ({'ep':5},0.74), ({'ep':8},0.70), ({'ep':5,'lr':0.0001},0.79)] best = max(runs, key=lambda r: r[1]) print(best)

Before you run it, say out loud what it will print. Then open the answer.

What it prints
The config with 0.79 and its score - the artifact you ship is defined by this line, not by the last run.

Data Flow

A loop proposes and measures.
1 Start from the baseline config
↓
2 Propose one change
↓
3 Run and score
↓
4 Keep best, log, repeat until budget
Line by line

Read the first example one line at a time. A line that prints shows what appears on screen; the rest set things up quietly.

runs = [({'ep':3},0.61), ({'ep':5},0.74), ({'ep':8},0.70), ({'ep':5,'lr':0.0001},0.79)] sets nothing on screen
best = max(runs, key=lambda r: r[1]) sets nothing on screen
print(best) The config with 0.79 and its score - the artifact you ship is defined by this line, not by the last run.
Why this works
Log every step

Config, seed, score, and time for each run. That log is the difference between a tuned model someone can rebuild and one nobody can explain six months later.

Stop on a plateau

If several steps do not beat the best, stop. Continuing past a plateau spends budget on noise, and the noise is what makes a final number look better than it is.

Examples

One candidate per step

Each step changes one thing: a knob, a subset of the data, a template. The log of steps with scores is the record of what was tried, which is what stops the same run being repeated for a week.

Keep the best, not the last

Track the highest held out score and its config. A loop that keeps the last run keeps whatever the last experiment happened to be, which is usually worse than the best.

Budget the loop

Each run costs time and money. A budget of runs forces the search to be about the likely causes, and the budget is what makes the loop finish before it becomes a project.

Words this lesson uses

Each one is defined here on this site. Open the entry for the full definition and the other words it points at.

← An evaluation harness for a tuned model
Previous Lesson
An evaluation harness for a tuned model
Next Lesson
Shipping a tuned model safely
Shipping a tuned model safely →