mixle.task.compose module¶
Compose two models or teachers while carrying a per-stage ledger.
compose chains two models/teachers a: x -> y and b: y -> z into one
callable x -> z while preserving a per-stage evidence ledger that can be
reused by composition and belief-walk workflows.
a and b are any callables – a TaskModel, a
CalibratedTaskModel, a teacher LLM, or a plain function. A stage that
additionally exposes .score(input) -> float (a log-confidence or log-density) contributes that
number to the ledger; a stage without one contributes 0.0 (“unscored”, never fabricated).
The ledger is purely additive by construction – ComposedAnswer.check() asserts
sum(contributions) == total_contribution exactly, the same identity
mixle.inference.explain uses for a single model’s evidence.
- class ComposedAnswer(answer, intermediate, stages, total_contribution)[source]
Bases:
objectA composed
x -> zanswer plus the per-stage receipt that attributes it to both stages.- Parameters:
- class ComposedModel(a, b, *, name_a='stage_a', name_b='stage_b')[source]
Bases:
objectChain
a: x -> ythenb: y -> zas one callablex -> z.composed(x)returns the bare answerz(so aComposedModelcan stand in anywhere a plain teacher callable is expected – including as theaorbof anothercompose(), chaining further).composed.answer(x)returns the ledger-carryingComposedAnswerinstead.