Exact-match final answer

1.0 when the last line reads ANSWER: <value> and the value matches the key. Math, lookups, short QA.

exact_match_answer.pyverify_environment
def verify_environment(completion: str, metadata: dict | None = None) -> float:
    """1.0 if the single ANSWER: line matches metadata["answer"] (case/space/comma-insensitive)."""
    import re

    expected = str((metadata or {}).get("answer", "")).strip()
    if not expected:
        return 0.0
    lines = re.findall(r"^\s*ANSWER:\s*(.+?)\s*$", completion, flags=re.M)
    if len(lines) != 1:
        return 0.0

    def norm(value: str) -> str:
        return re.sub(r"[\s,]+", "", value).rstrip(".").lower()

    return 1.0 if norm(lines[0]) == norm(expected) else 0.0
Exact-match final answer reward function (Python) — Reinforcement.tech