Label

Labeling

This page covers the labeling and data review tool: what can be labeled, the queue built today, the label data model, and how labels feed evals.

What it is for

Labeling is a generic tool for people to check and improve anything in the system. Records, chunks, transcripts, entities, relations, answers and eval rows are all labelable items. It covers:

  • Quality grading of records, chunks and answers, from S to F. Grades feed golden sets and filter out bad sources.
  • Tagging records and entities with the customer's own tags.
  • Metadata review. Canonical fields with their candidate values side by side, to accept or edit.
  • Entity linkage. Accept, reject or merge proposed links between mentions and canonical entities, and merge duplicate entities.
  • Relations. Review proposed relations between entities with their evidence spans.

Two views

Two views share one data model.

  • Queue view. Walks items one at a time across sources: the item list, the item with its mentions highlighted, and a labels panel for quality, tags, fields, entities and relations. Keyboard first.
  • Entity view. One canonical entity with everything that mentions it, its conflicting field values and its relations.

The queue view is built as a prototype. The entity view is a mockup in docs/2026-11-06-offering/labeling/.

The queue today

The prototype queue runs on a sample of the public domain art demo: a few dozen paintings each from the Art Institute of Chicago and the Met, with only CC0 fields kept. A handful of hand-written records from other sources a museum keeps (Postgres rows, Drive documents and segments of a recorded gallery talk) are mixed in, mentioning the same works and people by other names.

Build the sample, then the queue:

sh
deno task labeling:sample --download
deno task labeling:queue

labeling:sample reads the raw museum records from tmp/art (fetching them first with --download) and writes ingest records to fixtures/art-sample.json. labeling:queue runs those records and the mixed-source ones through the extractor and writes tmp/queue.json: the dataset name, the schema and one label item per record.

The extractor in src/labeling/extract.ts makes no model calls. A gazetteer built from the sample's own structured fields finds people, works, places and organizations in each record's text, regexes find dates, and a few sentence rules propose relations. Confidence scores are fixed by rule, so the queue has the same mix of sure and unsure proposals on every run. The schema, schema.art.v1 in src/labeling/schema.ts, defines the entity types, fields, relations and tags a reviewer can set.

The queue screen and the label forms live in the shared review mod (lib/om/mods/@/review), which runs as a screen in Greenfield Dev. That screen is waiting on review before it merges.

Label data model

Every label is stored in xgraph2 as a label ent with a labels rel to its target. The full model is in docs/2026-11-06-offering/labeling/data-model.ai.md.

ts
type LabelProps = {
  status: "proposed" | "accepted" | "rejected";
  author: { kind: "human" | "model"; id: string };
  at: string;
  schemaVersion: string;
  note?: string;
} & (
  | { kind: "grade"; grade: "S" | "A" | "B" | "C" | "D" | "F" }
  | { kind: "tag"; tag: string }
  | { kind: "field"; field: string; value: unknown; previous?: unknown; sourceId: string }
  | { kind: "link"; mentionSpan: Span; entityKey: string; candidates: Candidate[] }
  | { kind: "merge"; keep: string; drop: string; decision: "same" | "not-same" }
  | { kind: "relation"; relType: string; from: string; to: string; evidence: Evidence[] }
);

A few rules shape it:

  • Label keys follow label.<kind>.<target-key>.<author>, so a new grade from the same person replaces the old one and history lives in the store's version log.
  • A decision that changes the graph (accept a field, link a mention, merge two entities) is a label, and the pipeline applies it by writing the canonical value onto the target with provenance.
  • Labels are never stored only as properties on the target. The canonical value is a projection of the latest accepted labels and can be rebuilt from them.
  • A not-same merge decision is kept as a hard negative, so the pair is not proposed again.

Labels feed evals

This part is planned. Accepted labels become golden rows without extra work:

Label Golden row it produces
field, accepted A fact check: the question expects this value, citing the record and span
relation, accepted with evidence A support check: is the relation supported by this span
relation, rejected A negative: the answer must not assert it
link and merge An entity resolution set: mention to key, pair to same or not-same
grade on records Slices: scores by source and by grade, and F records dropped from the corpus

Rows become agreed when two people agree, or when one reviewer with the project's approver role accepts. Splits are assigned by hashing the target key, so every label about the same entity lands in the same split and the test split never leaks into tuning.

Labels also feed extraction: accepted field and relation labels become few-shot examples in the extraction prompt, rejected extractions become counterexamples, and human grades are the small set each model judge is calibrated against. See Evals and golden sets.

In the hosted API

The planned Python SDK grades records and links mentions directly:

py
df = gw.records.frame(tags="contracts", fields=["party", "effective_date", "premium"])
gw.labels.grade(df.id[0], "A")
gw.labels.link(mention="Delta Dental Ins. Co.", entity="carrier.delta-dental")

See Records in the API reference. The hosted API is in design.