Tables
A source gives you tables of rows. A Harbor job hassteps, trials and tests:
.collect() or .to_pandas().
Language Model Map
lm_map makes one LLM call per row. You describe the call with a one-line
signature:
step on a steps table) gets the whole row: its message,
reasoning, tool calls and output. Outputs are strings unless you give a type (bool,
list[str], Literal['a', 'b'], …).
Two relatives of lm_map:
lm_filter("message -> is_error: bool")keeps only rows where the one bool output is true.lm_extract("step -> failures: list[str]")makes one new row per item of a list output.
filter and map work the same way without an LLM, which makes them the cheap
way to drop rows before you pay for calls:
Language Model Reduce
group_by(...).lm_reduce(...) makes one LLM call per group and returns one row per group:
is_mistake goes with which what_happened. An
input naming the group key, or a column with one value per group (like a trial’s reward),
gets that single value. Groups too big for one prompt are split into chunks and the
results merged.
Use group_by(...).reduce(fn, columns=...) for a plain-Python reduce, such as counting, and
group_by() with no names to reduce the whole table into one row.
Hierarchies
Every row carries a hierarchical key. A Harbor step is keyeddataset > task > trial > step.
A row built from other rows inherits their key: grouping steps by trial gives rows keyed
dataset > task > trial, and reducing those by task gives rows keyed dataset > task. So climbing the hierarchy is just reducing again:
group_by takes key levels ("trial") or any other column ("model").
Joins bring facts from one level down to another. join(other, on="trial") adds each
step’s trial columns (its instruction, reward, …) to the step, and in a reduce those columns
then bind as one value per trial:
Language Model Fold
group_by(...).lm_fold(...) walks a group’s rows in key order, one call per row, carrying
state. Fields on both sides of the arrow are the state:
progress and the newest step, and writes the new progress.
Folds are what you use to follow a run as it happens.
Batch and live run the same pipeline
Sources emit events: a row arrived, or a group closed (a trial finished). A stored source emits every row and then every close; a live one emits them as they happen. The engine can’t tell the difference, so every pipeline above runs unchanged on a live stream..collect() returns
final rows, and .events() streams every result as it’s produced. See
Live pipelines.
Reruns and the cache
LLM calls are cached, so rerunning a pipeline only pays for prompts that changed.table.rerun(edit=...) uses that to answer what-if questions: it returns the table as if some
rows upstream had been different, such as {("trial", "t1"): ("trial", "t2")} to make run t1
look like run t2. tp.last_run() shows the calls, tokens and cost of the latest run.
Next steps
Why did my runs fail?
The full step → trial → task pipeline.
Python SDK
Every operator and its arguments.