Skip to content

The platform for continuously improving AI agents.

6.8 KB
Raw Blame
from __future__ import annotations

CONSUMERS = {
    "decision_training": {
        "reads": ["decision"],
        "target": "Interpret targets through Workshop exploration and source/user evidence. Record per-family target meaning and evidence in retained transformation code and output metadata; known supervision uses decision.target_semantics and decision.target_provenance. Unknown meaning stays unknown. Preserve full probability distributions, tied maxima and weights; mean-only ordinal supervision uses target_mean plus an explicit option_values scale. Never invent votes or collapse soft targets to argmax. Decision/Jev training consumes typed decisions, not assistant answer messages.",
        "wire": "decision is an object with state (text), question (nonempty text), kind (choice/noul/score), options (2–255 distinct strings), target_probabilities (matching finite probabilities summing to one), and optional positive weight, target_semantics and target_provenance. Alternatively score rows use target_mean, increasing option_values and target_semantics=ordinal_mean, without target_probabilities. Known meanings are categorical_gold, annotator_distribution, posterior, ordinal_histogram, pairwise_preference and teacher_distribution. Preserve annotation counts in target_provenance when known. Flat noul targets expand to No/Yes options (false/true semantic order) and [1-p,p]. Before writing the transform, read the live primitive page for the kind being prepared (https://docs.typesafe.ai/primitives/choice.md, https://docs.typesafe.ai/primitives/noul.md, or https://docs.typesafe.ai/primitives/score.md) and use that page's instructions and criteria guidance. Leave the rest of the TypeSafe skill unread. Instructions are the judgment, criteria define the answers. A choice question keeps one shared criteria map on its own lines after the instruction, as `option: description`, in option order, and copies those same lines onto every row. Use a description the source already gives. When one option has several descriptions, keep the most common and apply it everywhere. When instructions or a description are missing, write them in that same pass: one judgment sentence, and one line per option that says what that existing label means. Do not generate a new sentence per row, do not add a decision field, do not invent options, and do not fail preparation for missing text. Noul criteria are the two outcome strings. Score criteria are the ordered level strings; when a level is only a bare token, add a one-line situation it stands for in the question.",
        "model_specific": "Training uses the pinned Unsloth decision encoder and retains question spans and named-option mappings. Keep model tokens out of Workshop data. Preserve source/license/group identities outside decision for auditing and splitting.",
    },
    "decision_evaluation": {
        "reads": ["input.decision"],
        "target": "expected_output.probabilities retains the full publisher distribution outside the request; mean-only references use expected_output={mean, values} without inventing a distribution. Use a native probability evaluator; chat generation is not a probability prediction.",
        "wire": "input.decision contains only state, question, kind and options. Option order must match reference probabilities. Keep the choice description lines training wrote into the question. Blank state is structurally valid; whether the question supplies enough evidence is a separate semantic claim.",
        "quality": "Validate schema, probability range/sum/dimensions and preservation over every row. Do not normalize, harden, deduplicate, rebalance or drop valid blank states automatically. Publisher references are not verified truth; semantic checks are opt-in and uncertainty remains visible.",
    },
    "sft": {
        "reads": ["messages", "tools (optional)"],
        "target": "Assistant turns in each conversation; coverage columns are not model input.",
        "instructions": "Preserve task-specific system/developer prompts. Binding a capability does not authorise replacing them.",
        "wire": "messages and tools are arrays, tool schemas are objects; tool-call arguments are JSON strings. JSON-encoded arrays are normalised at the shared handoff.",
        "model_specific": "Training applies the selected model's chat template, tokenization, loss masks and context checks. The workshop neither selects a model nor repairs data during training.",
    },
    "model_evaluation": {
        "reads": ["input.messages", "input.tools (optional)"],
        "target": "expected_output is the grading reference; model_expected_output separates a model response from an application-level reference when both exist.",
        "execution": "Calls the model, not the application. It cannot resolve record IDs or fetch documents. Include all evidence before the target; never copy the target into the request.",
        "tools": "Tool schemas advertise callable interfaces, not implementations. Tool replay needs recorded calls and results; it does not execute application tools. Missing replay evidence must be reported, never invented.",
    },
    "shared": {
        "workshop_execution": "The calling coding agent authors transformations and semantic checks. Save deterministic pipelines or import locally produced rows bound to source cells and fingerprints. derive_dataset copies the complete source; explore_dataset measures sampling allocations. Select samples externally and import their pinned source identities. Sampling does not establish train/eval disjointness.",
        "task_scope": "Infer distinct source tasks from prompts, payloads, targets and tool context. A selected capability is the intended target, not evidence that every row already performs it. Transform each family using supported evidence; a prompt-only relabel is not a task transformation.",
        "split": "Keep case, content, conversation and synthetic-seed families disjoint across train/eval. Do not combine evidence across held-out boundaries.",
        "readiness": "Technical format errors require repair. Semantic quality findings are advisory; apply supported repairs, then allow progression with remaining warnings.",
    },
}


def workshop_context(dataset) -> dict:
    """The consumer contracts, and the columns of the source and active versions."""
    versions = dataset.versions()
    profiles = {}
    for name, cell in (("source", dataset.source), ("active", dataset.active_cell)):
        if cell is None or not cell.ran:
            continue
        if name == "active" and profiles.get("source", {}).get("cell") == str(cell.id):
            continue
        profiles[name] = {
            "cell": str(cell.id),
            "version": versions.get(cell.id),
            "rows": cell.rows,
            "columns": cell.columns,
        }
    return {"consumers": CONSUMERS, "profiles": profiles}