Strict output format

1.0 when the whole output matches a regex you supply. Labels, IDs, dates, one-word classifications.

format_regex.pyverify_environment
def verify_environment(completion: str, metadata: dict | None = None) -> float:
    """metadata["pattern"]: a Python regex the entire stripped completion must fullmatch."""
    import re

    pattern = (metadata or {}).get("pattern")
    if not pattern:
        return 0.0
    try:
        return 1.0 if re.fullmatch(pattern, completion.strip()) else 0.0
    except re.error:
        return 0.0
Strict output format reward function (Python) — Reinforcement.tech