Skip to content
expectedparrotPublic

About

Agent-first CLI for rubric evaluation, LLM ratings, and auditable scoring. Builds portable EDSL Jobs for ep to run.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Urteil

A green parrot operating a labeling gun beside the letter E

Urteil is an agent-facing toolkit for evaluating items against explicit standards. Define a codebook, collect criterion ratings from LLMs or people, check their quality, and apply transparent scoring rules. It also supports general-purpose data labeling, model comparisons, aggregation, and auditable exports.

Formerly Labeling; includes Rudin. Use urteil for new work. Existing labeling commands and Python imports remain available as compatibility aliases; existing labeling.yaml / .labeling/ projects are read in place. New projects use urteil.yaml / .urteil/. See the rename guide.

Run urteil guide for the workflow and urteil next in the project directory for the next step. The workflow guide is also available before installation.

Rubrics and scoring (formerly Rudin)

Urteil now includes Rudin's rubric design, manual and fitted scorecards, EDSL exports, visualizations, synthetic examples, and reproducible scoring manual. Use urteil scoring --help or urteil docs show scoring. Existing Rudin JSON files work unchanged; replace rudin with urteil scoring in commands and rudin with urteil.scoring in Python imports.

urteil scoring configure rubric.json --fields memo turns a codebook into LLM rating questions, including its anchors. After recording or importing labels, urteil scoring apply scorecard.json --source SOURCE --output scores.csv computes scores locally and preserves a complete scoring audit. Reweighting saved ratings requires no new inference. See the scoring guide and worked scoring manual (PDF).

Install

Use Python 3.11–3.13 and have Git available. The package pins a verified EDSL Git revision because released EDSL 1.0.8 does not include the required .ep artifact API. This pin also installs the compatible ep CLI.

Install from GitHub:

pip install "git+https://github.com/expectedparrot/urteil.git"

For local development:

git clone https://github.com/expectedparrot/urteil.git
cd urteil
python -m pip install -e ".[dev]"
pytest -q

The CLI is available as either urteil or python -m urteil.

Read the worked HTML tutorial for an end-to-end labeling project and the explicit Jobs.ep → ep run → Results.ep handoff.

Read the expanded mathematical PDF manual, From Messages to Measurements, for measurement definitions, classification metrics, coverage, sampling, correlated raters, paired comparisons, and error costs. New chapters cover the LLM annotation literature, blinded human validation, prompt sensitivity, and corrected prevalence and mean estimates with uncertainty. It includes an executed four-prompt experiment and an offline simulation study of bias, precision, and interval coverage, alongside the completed 100-message comparison (91% GPT-4o mini, 95% GPT-4.1, 98% GPT-5) and explains why that small public sample does not establish deployment accuracy. Build the packaged sources and recompute its tables offline:

urteil docs manual --output-dir urteil-book --pdf

Omit --pdf if TeX is unavailable. See urteil docs show manual for build requirements and the distinction between implemented metrics and teaching helpers.

For the research workflow, start with:

urteil docs show literature
urteil docs show validation

urteil validation sample freezes a full prediction table and draws a blinded human review sample with recorded inclusion probabilities. validation import preserves declared annotation provenance. metrics stability compares saved prompt variants; estimate prevalence and estimate mean correct finite-dataset estimates using complete independent human validation. These commands run offline and feed their evidence into urteil report context.

For verified recorded sources, metrics stability --sources a,b derives prompt and model controls from archived jobs and results, including reused pilots. urteil simulate --output-dir study compares estimators against known synthetic truth without model calls. See the prompt study and simulation study for results and replay instructions.

Give this to your coding agent

Copy this block into Codex or another coding agent from the repository that contains the dataset you want to label:

Help me build and run an auditable LLM-assisted data-labeling study with
Urteil and EDSL.

Install the current Urteil repository and its dependencies:

python -m pip install --upgrade \
  "urteil @ git+https://github.com/expectedparrot/urteil.git"

Verify that `urteil --help` and `ep --help` both work. Then run
`urteil docs show getting-started` and treat the bundled guidance as the
source of truth.

Help me identify the input CSV, stable row-ID column, prompt-visible columns,
label questions, answer options, ambiguity policy, model configuration, and any
available human or gold labels. Prevent target leakage and preserve raw source
columns. Initialize the project, edit urteil.yaml, inspect the dataset, and
validate the spec.

Use Urteil to build portable EDSL Jobs artifacts. Urteil must never execute
model inference itself: `ep` is exclusively responsible for running Jobs.ep and
writing Results.ep. Inspect each generated job and show me its model, scenario
count, question count, output path, and cost risk before execution.

Always start with a small sample. Do not run any `ep run` command that may incur
model cost until I explicitly approve it. After the sample run, record the
Results.ep artifact with Urteil, preview representative labels and edge cases,
and revise the rubric if needed. Obtain separate approval before the full run.

After the full run, preserve the audit trail under .urteil/, evaluate against
gold labels or inter-rater disagreement when available, export the final labeled
CSV, and generate a report. Run `urteil status` after each completed phase and
follow its returned next actions. Never edit .urteil/ records by hand.

Start here

urteil docs show getting-started
urteil init <project-dir> --csv <dataset.csv> --id-column <id-column>
urteil status

When to use this

  • The user has rows of data and needs structured labels from one or more LLM raters.
  • The labeling task can be expressed as yes/no, multiple choice, list, free text, numeric, bounded-scale, or checkbox questions.
  • The user needs sampling, preview, gold labels, metrics, aggregation, or reproducible exports.
  • The agent should stage the job with sample approval before running at scale.

When this is a stretch (and how to adapt)

  • The categories are not clear yet. Use bewley on a small sample to develop a codebook, then encode it in urteil.yaml.
  • The user has no dataset, only documents or transcripts. Build a row-level dataset first, or use bewley directly for qualitative coding.
  • The task requires expert judgment. Use labeling to organize model labels, but include gold labels and report model-vs-expert metrics.
  • The model output is open-ended. Use free-text questions for exploration, then convert stable categories into multiple-choice questions for scalable labeling.
  • The user wants a calibrated persona population. Use manning after labels define target distributions.

Decision rule for the calling agent

Before using Urteil for labeling, confirm:

  1. There is a tabular dataset or a clear plan to create one row per item.
  2. Each row can be labeled by one or more explicit questions.
  3. The user needs reproducibility, sampling, metrics, aggregation, or export.
  4. The agent can review a sample before approving a full run.

If yes to the first three, labeling is the right method.

Inputs and elicitation

Dataset

What it is: the CSV or row-oriented data file to label, with stable row IDs and columns used by the rater prompt.

How the agent elicits this:

  • Ask where the dataset lives, what each row represents, and which column uniquely identifies rows.
  • Ask which columns the model should see and which should be hidden to prevent leakage.
  • Ask whether rows need cleaning, deduplication, or filtering before labeling.

Default to suggest: preserve a stable ID column, include only task-relevant text/context columns, and keep raw source columns unchanged.

Fallback: if no ID exists, create a deterministic row ID before initializing the labeling project.

Urteil questions and rubric

What it is: the questions the LLM rater answers for each row, including type, options, instructions, and examples.

How the agent elicits this:

  • Ask what decision each label will support.
  • Ask whether the label is binary, categorical, multi-label, numeric, or free text.
  • Ask for inclusion/exclusion rules and borderline examples.
  • Keep each question focused; split multi-part judgments into separate questions.

Default to suggest: start with one primary label question and one optional rationale/free-text field for sample review.

Fallback: if the rubric is vague, run a small exploratory sample and revise the spec before generating a full job.

For multi-criterion evaluation, use urteil scoring to define criteria, anchors, weights, and thresholds, then scoring configure to turn the codebook into study questions. scoring apply computes scores from a saved source. Scoring is distinct from aggregating multiple raters' answers to the same question.

Rater configuration

What it is: model(s), prompt style, number of raters or label sources, and any keyword-rule baselines.

How the agent elicits this:

  • Ask whether the user wants one model, multiple models, or comparison against human/gold labels.
  • Ask whether cost, latency, or accuracy is the binding constraint.
  • Suggest a cheap sample run before full-scale labeling.

Default to suggest: one strong model for the first sample; add a second model only when disagreement/robustness matters.

Fallback: use keyword rules as a transparent baseline when model calls are expensive or the label is simple.

Quality checks and aggregation

What it is: sample review, gold labels, metrics, multi-rater aggregation, and export rules.

How the agent elicits this:

  • Ask whether gold labels exist and which rows they cover.
  • Ask what metric matters: accuracy, precision, recall, F1, or qualitative acceptability.
  • Ask how to resolve multiple label sources: majority vote, authoritative source, or manual review.

Default to suggest: sample 20-50 rows, preview labels, revise the rubric, then run full labeling and export.

Fallback: if no gold exists, report inter-rater agreement or disagreement patterns rather than accuracy.

Outputs

Urteil produces:

  • urteil.yaml — project spec with dataset, questions, models, and output settings.
  • .urteil/ — append-only audit state for samples, plans, runs, imports, gold labels, rules, aggregates, metrics, exports, and reports.
  • Scoring audit bundles under .urteil/scores/, including rules, ratings, criterion contributions, and item scores.
  • Portable EDSL Jobs.ep artifacts under an edsl_jobs/ directory.
  • Sample manifests and run plans for staged approval.
  • Imported label results, previews, gold comparisons, rule baselines, aggregate labels, metrics, final exports, and report artifacts.

Workflow

Canonical sequence:

  1. urteil init — create project state and baseline spec.
  2. Edit urteil.yaml with dataset path, ID column, columns used, questions, and model(s).
  3. urteil inspect — profile the dataset and spec context.
  4. urteil validate — catch missing files, bad question specs, or invalid model settings.
  5. urteil generate — create the portable full-dataset Jobs.ep artifact.
  6. urteil sample — select a low-cost sample.
  7. urteil plan sample --latest — get the exact command and run plan for the latest sample.
  8. Run the returned ep run ... command outside Urteil when approved.
  9. Execute the plan’s record_after.argv, including --plan, to verify and normalize results as label sources.
  10. urteil preview — review sample quality with the user.
  11. Approve accepted sample labels with urteil approve sample; revise the spec instead when needed.
  12. urteil plan full --reuse-approved-sample — build Jobs only for rows not already approved.
  13. Optional: urteil gold, urteil rule, urteil metrics, and urteil aggregate.
  14. urteil export and urteil report context — create final data and a bounded handoff for the report agent.

Run urteil next at any point to recover source coverage, readiness, blockers, and exact next actions.

Worked examples

Building a policy-comment classifier

User: "I need to label public comments as supporting or opposing the rule."

Agent: "Urteil fits. I need the CSV path, the row ID column, and the text column. For the label, I suggest a multiple-choice question with support, oppose, mixed, and unclear, plus a short rationale for sample review. Do you have any gold labels?"

User: "CSV has comment_id and comment_text. No gold labels yet."

Agent: "I’ll initialize the project, define that rubric, sample 30 comments, and preview the model labels before any full run."

urteil init comments-labeling --csv data/comments.csv --id-column comment_id --columns-used comment_text
urteil inspect
urteil validate
urteil generate
urteil sample --n 30 --strategy random
urteil plan sample --latest

Output: a validated spec, generated EDSL job, sample manifest, and run plan for approval.

After running the plan command from the generated output, record the EDSL results:

# Execute the plan’s record_after.argv, including its exact --results and --plan paths.
urteil preview latest --human

record run loads Results.ep directly and returns a stable source ID such as sample_run or full_run. Multi-rater runs return separate label_sources for each model/agent/iteration. Metrics and exports accept those IDs immediately; no ep results export and re-import round trip is needed.

Comparing model labels to gold data

urteil labels import model_a results/model_a_labels.csv --id-column comment_id --label-columns topic
urteil gold import data/gold_labels.csv --id-column comment_id --label-columns topic
urteil metrics classification --reference gold --candidate model_a --question topic
urteil preview latest --human
urteil export --final-label-source model_a --output outputs/final_labels.csv

Output: imported labels, classification metrics against gold labels, preview rows, and a final labeled CSV.

Aggregating multiple model raters

urteil labels import gpt4o results/gpt4o.csv --id-column row_id --label-columns issue_category,urgency
urteil labels import claude results/claude.csv --id-column row_id --label-columns issue_category,urgency
urteil aggregate create --method majority-vote --raters gpt4o,claude
# Export using the aggregation ID returned in artifacts.aggregation.
urteil export --final-label-source <aggregation_id> --output outputs/majority_labels.csv

Output: an aggregate label source that can be exported or evaluated.

Use urteil labels import for CSV-style model, human, rule, or aggregate label files. Record EDSL Results.ep artifacts with urteil record run --kind sample --results ... or --kind full --results ...; do not pass them to labels import.

Quick command reference

For full options, run urteil <subcommand> --help.

Command Purpose
urteil init Create project state and initial spec.
urteil inspect Profile dataset/spec context.
urteil validate Validate the project spec and inputs.
urteil generate Generate EDSL labeling job files.
urteil sample Create reproducible sample sets.
urteil plan Show run plan and commands for generated jobs.
urteil record run Record executed run metadata.
urteil approve sample Approve reviewed sample labels for provenance-safe reuse.
urteil labels import Import model or human label results.
urteil preview Inspect labeled rows before scaling or exporting.
urteil gold ... Manage gold-standard labels.
urteil rule ... Create and run keyword-rule baselines.
urteil aggregate create Combine multiple label sources.
urteil metrics classification Compute classification metrics.
urteil export Export final labeled datasets.
urteil status / urteil next Show source coverage, readiness, blockers, and exact next actions.
urteil report context Produce bounded JSON evidence for an external report agent.
urteil report template Produce a noncanonical Markdown handoff template.
urteil report package Optionally render a package-owned analytical report.
urteil docs Read built-in guidance.

Common pitfalls

  • Running the full dataset before sample review can waste money and lock in a bad rubric.
  • Letting the model see target/leakage columns can inflate apparent quality.
  • Multi-label tasks should not be forced into single-choice questions unless categories are mutually exclusive.
  • Gold metrics are only meaningful if gold labels use the same rubric and row universe.
  • Aggregation can hide systematic disagreement; inspect disagreements before treating majority vote as truth.

Cross-references

  • Upstream: bewley develops qualitative codebooks; dewey can organize source documents before row-level labeling.
  • Downstream: messick validates model-mediated results; manning can use label distributions as calibration targets.
  • Reporting: gutenberg, tufte, and herndon create report, figure, and workbook deliverables from labels.

State contract

.urteil/ is the append-only audit store for project events, samples, generated jobs, run records, imported labels, gold labels, rule baselines, aggregates, metrics, exports, and reports. urteil.yaml is the editable project spec. Generated EDSL Jobs artifacts and exported CSVs are derived artifacts; preserve the audit store when rerunning or revising labels.

JSON output and error codes

Urteil commands use structured responses for agent workflows. Treat validation errors, missing dataset columns, invalid question specs, unknown label sources, missing gold labels, and export conflicts as recoverable project-state issues: fix the spec or import state, rerun urteil validate or urteil status, then continue.

License

Urteil is released under the MIT License.

Integrity guarantees

Use each plan's returned execution and recording commands together. Recording with --plan verifies the original job, scenario contents, model configuration, and required answers. Approval additionally checks that the current dataset and rubric still match. Unplanned imports remain available for analysis but cannot authorize sample reuse.

Each rater has a distinct source; a revised CSV import needs a new source ID. Exports reject accidental replacement; choose another --output or explicitly use --replace-output. Report context is bounded to 64 KiB with truncation metadata.

Joined exports and classification scores

Exports now preserve all original dataset rows, columns, and row order, then append labels. Coverage summaries identify missing labels; per-row details are saved alongside the audited export. Use --labels-only for the previous separate label-table behavior, or --label-prefix to avoid a source-column collision. Read urteil docs show exports for details.

Classification metrics include per-class precision/recall/F1, macro/micro/weighted averages, and matched-reference coverage. --zero-division null|0|1 explicitly controls undefined scores. Read urteil docs show metrics for formulas and averaging policies.

The public SMS spam example downloads a pinned UCI dataset with reference labels and exercises metrics and joined exports using a keyword baseline, without model calls.

About

Agent-first CLI for rubric evaluation, LLM ratings, and auditable scoring. Builds portable EDSL Jobs for ep to run.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages