EmbodiedExploreBench / eval /progress_scoring.py
fengshore04's picture
Upload folder using huggingface_hub
832f0f6 verified
Raw History Blame Contribute Delete
6.81 kB
"""Aggregate reviewed predicates; B uses agent text, while actions need runtime evidence.
This is a contract/aggregation layer, NOT a trajectory, vision or semantic judge.
Evidence reviewers must supply predicate verdicts with traceable evidence IDs.
"""
CONTRACTS = {'A': {'name': 'Information acquisition',
'predicates': {'successful_interaction': 'A real interaction succeeds under the '
'interaction-range rules used by the recorded run. '
'A final self-report cannot substitute for it.',
'correct_source': 'The actual responder is the required source. Room and '
'appearance identify and locate the source; they do not '
'earn separate visit credit.',
'complete_response_received': 'The complete required information or '
'materials are received from this source. '
'Repetition in the final answer is not '
'required.'}},
'B': {'name': 'Independent object facts in the final report',
'predicates': {'object_bound_record': 'Explicit facts about the object appear in the '
'specified single final answer or NPC report. Do not '
'use intermediate notes or combine separate reports.',
'required_facts_correct': "Assess semantic agreement between this object's "
'facts and the reference. Errors about other '
'objects do not invalidate this unit. Image '
'comparison is not required.'}},
'C': {'name': 'Spatial outcome',
'predicates': {'actual_spatial_event': 'Recorded evidence of a visit, registration, door '
'crossing, stop, or return satisfies the action '
'specified by this spatial subgoal.',
'target_geometry_correct': 'Position, floor, door side, or direction '
'satisfies the supported spatial criteria. '
'Without a calibrated reference, mark it unknown '
'rather than guessing distances.',
'required_spatial_properties': 'Check only the explicitly required stopping, '
'surrounding views, route retracing, or '
'applicable instruction version. Do not add '
'unstated conditions.'}},
'D': {'name': 'Independent decision',
'predicates': {'explicit_decision': 'The required final decision is explicit and bound to '
'the correct object or work order. An ambiguous list of '
'candidates is insufficient.',
'decision_correct': 'This decision is correct independently of whether other '
'units received credit.',
'required_local_reasoning': 'Explain the key reasons required for this '
'decision. Requirements shared across multiple '
'decisions are handled by the whole-task '
'evaluator.'}},
'E': {'name': 'Complete delivery',
'predicates': {'successful_delivery': 'A real delivery occurs. Delivery to an NPC requires '
'a successful report_to_npc; delivery to the user '
'requires a final answer.',
'correct_recipient_and_channel': 'The recipient, channel, and material '
'identity are correct. A final self-report '
'cannot replace the required NPC delivery.',
'one_complete_correct_message': 'A single delivery contains all required '
'content and reasoning. Do not combine '
'separate messages or infer success from a '
'fixed acknowledgement.'}}}
def reduce_predicates(contract_id, verdicts):
"""False requires counterevidence OR an explicitly complete negative search."""
expected = set(CONTRACTS[contract_id]['predicates'])
if set(verdicts) != expected:
raise ValueError('Predicate set must exactly match the shared contract')
states = []
for item in verdicts.values():
state = item['status']
if state not in {'pass', 'fail', 'unknown'}:
raise ValueError('Invalid predicate status')
if state == 'pass' and not item.get('evidence_ids'):
raise ValueError('A pass needs traceable evidence')
if state == 'fail' and not (item.get('evidence_ids') or item.get('complete_negative_search')):
raise ValueError('Missing evidence is not a failure')
states.append(state)
if 'fail' in states:
return 'failed'
if 'unknown' in states:
return 'evidence_insufficient'
return 'completed'
KNOWN = {'completed', 'failed'}
UNKNOWN = {'evidence_insufficient', 'definition_unresolved', 'not_recomputed'}
def summarize_task(definition, statuses):
ids = {u['id'] for u in definition['milestones']}
if len(ids) != len(definition['milestones']):
raise ValueError('Duplicate unit ID')
if set(statuses) != ids:
raise ValueError('Do not omit units from the denominator')
if not set(statuses.values()) <= KNOWN | UNKNOWN:
raise ValueError('Invalid unit status')
total = len(ids)
if not total:
raise ValueError('Empty task')
done = sum(s == 'completed' for s in statuses.values())
failed = sum(s == 'failed' for s in statuses.values())
unknown = total - done - failed
return {'task_id': definition['task_id'], 'units': total, 'completed': done,
'failed': failed, 'unknown': unknown, 'coverage': (done + failed) / total,
'progress': None if unknown else done / total,
'lower_bound': done / total, 'upper_bound': (done + unknown) / total}