Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Changed

- **`skill novelty analyze --dry-run` prices calls from a token profile refit on 17 paid runs of 2026-11-28** — every profile entry now has an input and an output term per artifact token, fitted at every tier. Only the triage extractor's output grows with the artifact (it was a flat 2,359 tokens per call; it is now 1,908 plus 0.251 per artifact token); the answerer, judge and standard extractor outputs stay flat, at 350, 95 and 225 per call. At the same call counts `expected_usd` rises on 13 of the 17 measured runs, by up to 32% (large triage artifacts); it falls by at most 4% on the other four (a 640-token triage run and three standard and study runs of 4,000 tokens and more). `least_sure_role` names the role with the largest dollars at every tier, with the reason "the <role> has the most dollars, so an error in its call count or its token profile moves the figure most"; it replaces the rule of the #631 entry, under which `study` and an untiered run named the extractor as borrowing the standard profile.
2 changes: 1 addition & 1 deletion dokimi/docs/skill-novelty-walkthrough.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ prices, and is `null` when a model has no price; `usd_by_role` gives each role's
`least_sure_role` names the role the figure is least sure of. The probe term was validated to within 1–3% of
counted calls at nine (skill, tier) points, on content that did not escalate.

`expected_usd` is a projection, not a ceiling (held-out runs ran up to 33% low): a call's price
`expected_usd` is a projection, not a ceiling (held-out runs ran up to 14% low): a call's price
follows the artifact's length and the models. Pass `--max-usd <n>` to every step that calls a
model: the run stops once its calls across all roles have cost that much (calls already in
flight can overshoot it), and a call with no known price stops it too,
Expand Down
30 changes: 20 additions & 10 deletions dokimi/docs/skill-novelty.md
Original file line number Diff line number Diff line change
Expand Up @@ -1470,19 +1470,29 @@ the two totals (stages, every probe, and half the oracle pairs, split by `by_rol
`expected_usd`: those calls priced at list prices by role, `null` when a model has no
price. `usd_by_role` splits `expected_usd` into `extractor`, `answerer` and `judge` (panel judges
after the first count under `judge`), and `least_sure_role` names the role the figure is least
sure of with a reason; both are `null` with `expected_usd`, and `--estimate-only` prints the role and its
share on stderr. The rule, chosen without per-role error data: a run whose tier has no extractor
profile of its own (`study`, or no tier) names `extractor`, which borrows the standard profile;
`triage` and `standard` name the role with the largest dollars. The constants were fitted on 13 of the 25 measured runs; the other 12 are held out.
On those 12 every projection landed within 35%: calls within 13%, atoms within 11%, dollars
within 33%. The dollar projections ran high on 5 runs (up to +29%) and low on 7 (down to
-33%), so `expected_usd` is not a ceiling; the triage projection ran lower the larger the
artifact was (-4% at 1,153 tokens, -33% at 6,723). The largest artifact measured has 6,723
sure of with a reason; both are `null` with `expected_usd`, and `--dry-run` prints the role and its
share on stderr. One rule at every tier: the role with the largest dollars, a tie going to the
first of extractor, answerer, judge. Each priced at its own `--dry-run` call counts, 15 of the 17
paid runs of 2026-11-28 had their largest dollar error in that role; in the other two, triage runs, every
role was off by under $0.01. At standard, study and untiered the role furthest off was always the
extractor, mostly through its call count, not its tokens.
The token profile is fitted on 10 of those 17 runs: seven skills of 640 to 5,954 tokens, every
tier and one untiered run. Priced from their own calls, the other 7 land within 11% per run and
16% per role. Study and untiered runs were measured and share the standard extractor profile,
since the extractor does the same work per call at all three. The atom and call constants
(`TOKENS_PER_ATOM`, `ESCALATION_SHARE`) were fitted on 13 of the 25 October runs; the other 12 are
held out. On those 12 calls landed within 13% and atoms within 11%; dollars within 51%, the worst
being the 198-token standard run, below the smallest artifact of the token profile's fit (640),
whose projection counts 47 extractor calls against 34 measured (priced from the 34 it is +22%).
The dollar projections ran high on 6 runs (up to +51%) and low on 6 (down to -14%), so
`expected_usd` is not a ceiling; the triage projection ran lower the larger the artifact was
(-2% at 1,153 tokens, -14% at 6,723). The largest artifact measured has 6,723
tokens: above that the dollar figure extrapolates, and the payload says so
(`usd_extrapolated: true`, with a note on stderr). The answerer's artifact term is priced per
arm that carries the artifact (every arm but `no_artifact`), so a three-arm run costs more
per answerer call than a two-arm one; a `--placebo-text` of another length is not read. Only
three of the 12 are standard runs, so the standard profile rests on little data.
per answerer call than a two-arm one; a `--placebo-text` of another length is not read. On the
November runs the largest dollar errors at standard and study came from the atom count
(`TOKENS_PER_ATOM`), not the token profile.
The measured runs, the tier table above among them, predate the spread cap: their extraction
stopped at the cap. A capped run now asks every extraction batch, and the projection counts
one extraction call per batch of 25 spans, as the run asks them, while the probes stay at the
Expand Down
2 changes: 1 addition & 1 deletion dokimi/dokimi/commands/novelty_budget.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def print_run_estimate(args: argparse.Namespace, settings, text: str, estimate_u


def print_estimate_only(args: argparse.Namespace, settings, text: str, estimate_usd) -> None:
"""The ``--estimate-only`` output of ``analyze``: the projection as JSON, and what it rests on."""
"""The ``--dry-run`` output of ``analyze``: the projection as JSON, and what it rests on."""
from dokimi.novelty import cost
from dokimi.novelty.tiers import FITTED_TOKENS_MAX

Expand Down
27 changes: 12 additions & 15 deletions dokimi/dokimi/novelty/cost.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,23 +136,20 @@ def role_usd(args: argparse.Namespace, n_tokens: int, by_role: dict[str, int], t
return {role: round(split.get(role, 0.0), 6) for role in ROLES}


def least_sure_role(usd_by_role: dict[str, float], tier: str | None) -> dict[str, str]:
"""The role the dollar figure is least sure of, and why (#631).

A tier with no extractor profile of its own (``study``, an untiered run) borrows the
standard one, so the extractor is the least sure. Otherwise it is the role with the largest
dollars, where an error in the token profile moves the figure most; a tie goes to the first
of extractor, answerer, judge. There is no per-role error data behind this rule.
def least_sure_role(usd_by_role: dict[str, float]) -> dict[str, str]:
"""The role the dollar figure is least sure of, and why (#631, #1217).

The role with the largest dollars at every tier; a tie goes to the first of extractor,
answerer, judge. In 15 of the 17 paid runs of 2026-11-28, each priced at its own ``--dry-run``
call counts with the refit profile, the role with the largest estimated dollars had the
largest dollar error. The other two are triage runs where every role's error was under $0.01. At
standard, study and untiered the role furthest off was the extractor, mostly through its call
count.
"""
from dokimi.novelty.tiers import EXTRACTOR_TOKENS

if tier not in EXTRACTOR_TOKENS:
return {"role": "extractor",
"reason": "the extractor's token profile is the standard tier's, borrowed, "
"since no run of this tier was measured"}
role = max(ROLES, key=lambda name: usd_by_role[name])
return {"role": role,
"reason": f"an error in the {role}'s token profile moves the dollar figure most"}
"reason": f"the {role} has the most dollars, so an error in its call count or its "
"token profile moves the figure most"}


def add_role_usd(args: argparse.Namespace, estimate: dict, n_tokens: int, tier: str | None,
Expand All @@ -162,7 +159,7 @@ def add_role_usd(args: argparse.Namespace, estimate: dict, n_tokens: int, tier:
if estimate["expected_usd"] is not None:
split = role_usd(args, n_tokens, estimate["estimate"]["by_role"], tier, context_share)
estimate["usd_by_role"] = split
estimate["least_sure_role"] = None if split is None else least_sure_role(split, tier)
estimate["least_sure_role"] = None if split is None else least_sure_role(split)


def least_sure_line(estimate: dict) -> str | None:
Expand Down
40 changes: 19 additions & 21 deletions dokimi/dokimi/novelty/tiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,28 +293,23 @@ def resolve_settings(tier: str | None, flags: dict) -> RunSettings:
#: artifact) to 0.60, median 0.505.
ESCALATION_SHARE = 0.5

#: Per call, for the roles whose calls do not depend on the tier: (input tokens besides the
#: artifact, input tokens per artifact token, output tokens). The answerer's input carries the
#: artifact on the paired arm; the judge sees the answer and the question only. Pooled over the
#: fit half.
CALL_TOKENS: dict[str, tuple[float, float, int]] = {
"answerer": (-38, 0.789, 284),
"judge": (468, 0.004, 89),
#: Per call, tier-independent: (input base, input per artifact token, output base, output per
#: token). Fitted on 10 of the 17 runs of 2026-11-28 (``PROFILE_RUNS`` in the token-profile test).
CALL_TOKENS: dict[str, tuple[float, float, int, float]] = {
"answerer": (-104, 0.946, 350, 0.0),
"judge": (481, 0.014, 95, 0.0),
}

#: The extractor's calls, by tier, in the same shape. A triage extraction packs the capped
#: atom set into each of its calls and writes about 2,360 output tokens per call, where a
#: standard extraction writes about 195; the input follows the same split. Study and an
#: untiered run have no measurement of their own and take the standard profile.
EXTRACTOR_TOKENS: dict[str, tuple[float, float, int]] = {
"triage": (971, 0.045, 2359),
"standard": (267, 0.651, 195),
#: The extractor's calls by tier, fitted on the same 10 runs at every tier. Study and untiered
#: runs were measured: they do the same work per call as standard and share its profile.
EXTRACTOR_TOKENS: dict[str, tuple[float, float, int, float]] = {
"triage": (841, 0.186, 1908, 0.251),
"standard": (452, 0.54, 225, 0.0),
}


#: The largest artifact (in tokens) among the measured runs the profiles above were fitted
#: and checked on. A projection for a bigger artifact extrapolates: the triage figure ran
#: lower as the artifact grew (-4% at 1,153 tokens, -33% at 6,723).
#: The largest artifact (tokens) of the measured runs checked; a bigger one extrapolates, and
#: the triage figure ran lower as the artifact grew (-2% at 1,153 tokens, -14% at 6,723).
FITTED_TOKENS_MAX = 6723

#: The share of the answerer's calls whose context carries the artifact in the measured
Expand All @@ -338,12 +333,15 @@ def call_tokens(role: str, n_tokens: int, tier: str | None = None,
default two arms, 1.5 for ``no_artifact,full,placebo,shuffled``.
"""
if role == "extractor":
base, per_token, out = EXTRACTOR_TOKENS.get(tier or "", EXTRACTOR_TOKENS["standard"])
in_base, in_per, out_base, out_per = EXTRACTOR_TOKENS.get(
tier or "", EXTRACTOR_TOKENS["standard"])
else:
base, per_token, out = CALL_TOKENS[role]
in_base, in_per, out_base, out_per = CALL_TOKENS[role]
if role == "answerer":
per_token *= context_share / MEASURED_CONTEXT_SHARE
return max(0, round(base + per_token * n_tokens)), out
in_per *= context_share / MEASURED_CONTEXT_SHARE
return (max(0, round(in_base + in_per * n_tokens)),
# mutation-ok[bump-int]: every output base is at least 95 and no output slope is negative, so the floor never binds
max(0, round(out_base + out_per * n_tokens)))


def usd_by_role(
Expand Down
51 changes: 31 additions & 20 deletions dokimi/tests/test_novelty_estimate_roles.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (C) 2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

"""``skill novelty analyze --estimate-only`` splits its dollars by role and names the least sure one (#631)."""
"""``skill novelty analyze --dry-run`` splits its dollars by role and names the least sure one (#631)."""

from __future__ import annotations

Expand All @@ -11,11 +11,10 @@

from dokimi.cli import build_parser
from dokimi.llm_pricing import list_cost_usd
from dokimi.novelty.cost import role_models, role_usd
from dokimi.novelty.cost import least_sure_role, role_models, role_usd
from dokimi.novelty.tiers import call_tokens

ROLES = ("extractor", "answerer", "judge")
BORROWED = "the extractor's token profile is the standard tier's, borrowed, since no run of this tier was measured"


def _estimate(tmp_path, capsys, *flags):
Expand Down Expand Up @@ -47,24 +46,34 @@ def test_usd_by_role_prices_each_roles_calls_and_sums_to_expected_usd(tmp_path,
assert split[role] == pytest.approx(payload["estimate"]["by_role"][role] * cost, abs=1e-6)


@pytest.mark.parametrize("tier_flags", [("--tier", "study"), ()])
def test_a_tier_without_an_extractor_profile_names_the_extractor_as_borrowed(
tmp_path, capsys, tier_flags):
def _reason(role):
return (f"the {role} has the most dollars, so an error in its call count or its token "
"profile moves the figure most")


@pytest.mark.parametrize("tier_flags", TIERS)
def test_every_tier_names_the_role_with_the_largest_dollars(tmp_path, capsys, tier_flags):
_, payload, _ = _estimate(tmp_path, capsys, *tier_flags)
assert payload["least_sure_role"] == {"role": "extractor", "reason": BORROWED}
split, least = payload["usd_by_role"], payload["least_sure_role"]
assert split[least["role"]] == max(split.values())
assert least["reason"] == _reason(least["role"])


def test_triage_and_standard_name_the_role_with_the_largest_dollars(tmp_path, capsys):
named = {}
for tier in ("triage", "standard"):
_, payload, _ = _estimate(tmp_path, capsys, "--tier", tier)
split, least = payload["usd_by_role"], payload["least_sure_role"]
assert split[least["role"]] == max(split.values())
assert least["reason"] == (f"an error in the {least['role']}'s token profile "
"moves the dollar figure most")
named[tier] = least["role"]
# one of the two is not the extractor, so rule 2 is told apart from rule 1
assert set(named.values()) != {"extractor"}
def test_some_tier_names_a_role_other_than_the_extractor(tmp_path, capsys):
named = set()
for tier_flags in TIERS:
_, payload, _ = _estimate(tmp_path, capsys, *tier_flags)
named.add(payload["least_sure_role"]["role"])
assert named != {"extractor"}


def test_least_sure_role_is_the_largest_dollars_and_a_tie_goes_to_the_first_role():
judge = {"extractor": 0.2, "answerer": 0.1, "judge": 0.7}
assert least_sure_role(judge) == {"role": "judge", "reason": _reason("judge")}
# a tie goes to the first of ROLES
tied = {"extractor": 0.1, "answerer": 0.4, "judge": 0.4}
assert least_sure_role(tied)["role"] == "answerer"
assert least_sure_role({"extractor": 0.3, "answerer": 0.3, "judge": 0.3})["role"] == "extractor"


def test_panel_judges_after_the_first_count_under_judge(tmp_path, capsys):
Expand Down Expand Up @@ -96,7 +105,9 @@ def test_role_usd_is_none_for_an_unpriced_role(tmp_path, capsys):
def test_stderr_names_the_role_its_percent_and_the_reason_before_the_estimate_note(
tmp_path, capsys):
_, payload, err = _estimate(tmp_path, capsys, "--tier", "study")
percent = 100 * payload["usd_by_role"]["extractor"] / sum(payload["usd_by_role"].values())
line = f"Least sure of: extractor ({percent:.0f}% of expected_usd): {BORROWED}\n"
split = payload["usd_by_role"]
role = payload["least_sure_role"]["role"]
percent = 100 * split[role] / sum(split.values())
line = f"Least sure of: {role} ({percent:.0f}% of expected_usd): {_reason(role)}\n"
assert line in err
assert err.index(line) < err.index("Estimate only, nothing was measured.")
Loading
Loading