MS-1 of multi-step composition. Turns the question into a Target = what the problem asks for, the search's pruning signal + stopping criterion (MS-3). Lexeme-level only (ADR-0165): the existing question parser returns nothing on these GSM8K questions, and 0165 forbids new question-shape grammar regex. Three robust signals: - quantities: numbers stated IN the question (0033's 'when she is 25') via the body's lexeme extractor — they participate in the derivation. - aggregation: presence of an aggregation lexeme (total/altogether/combined/sum/ 'in all'/'in total') — soft hint the final step is a sum. - units: asked units resolved by INTERSECTION with the body's known units (precise lexeme match, e.g. 'jumping'). Superordinates (weight<->pounds) are NOT faked — deferred to a curated superordinate-units pack; until then the unit signal is precise-but-incomplete and the search leans on completeness. Refuse-preferring: empty target field is not an error, just a weaker prune. generate/derivation/target.py: Target + extract_target(question, known_units=()). 12 MS-1 tests (question-quantity, aggregation, body-unit intersection, superordinate-not-faked, determinism, frozen). Verified: derivation suite 57/57; ruff clean; smoke 67. Not wired into serving (Target ready for MS-2/MS-3).
41 lines
1.2 KiB
Python
41 lines
1.2 KiB
Python
"""ADR-0175 Phase 3 — grounded derivation search + self-verification gate.
|
|
|
|
Phase 3a (this surface): the self-verification gate — grounded operands ∧
|
|
grounded operation cues ∧ unit consistency ∧ uniqueness. The wrong=0-critical
|
|
guard that keeps the (Phase 3b) bounded search honest.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from generate.derivation.comparatives import (
|
|
ComparativeScalar,
|
|
extract_comparative_scalars,
|
|
)
|
|
from generate.derivation.extract import extract_quantities
|
|
from generate.derivation.model import GroundedDerivation, Quantity, Step, VALID_OPS
|
|
from generate.derivation.search import MULTIPLICATIVE_CUES, search_multiplicative
|
|
from generate.derivation.target import Target, extract_target
|
|
from generate.derivation.verify import (
|
|
Resolution,
|
|
SelfVerification,
|
|
select_self_verified,
|
|
self_verifies,
|
|
)
|
|
|
|
__all__ = [
|
|
"ComparativeScalar",
|
|
"GroundedDerivation",
|
|
"MULTIPLICATIVE_CUES",
|
|
"Quantity",
|
|
"Resolution",
|
|
"SelfVerification",
|
|
"Step",
|
|
"Target",
|
|
"VALID_OPS",
|
|
"extract_comparative_scalars",
|
|
"extract_quantities",
|
|
"extract_target",
|
|
"search_multiplicative",
|
|
"select_self_verified",
|
|
"self_verifies",
|
|
]
|