CoolFace
Apppublic

vasiuuu/DGX_AI

sourceHugging Faceupdated 5mo agoView on Hugging Face
0likes
grader.py40 linesDownload Raw Back to codeforge
1from __future__ import annotations2 3_SANDBOX_WEIGHT = 0.64_GROUNDING_WEIGHT = 0.45_BRIER_CAP = 0.56_UNCERTAIN_CONFIDENCE_THRESHOLD = 0.37_UNCERTAIN_QUALITY_THRESHOLD = 0.58_UNCERTAIN_FLOOR = 0.509 10 11def compute_reward(12    *,13    sandbox_score: float,14    groundedness: float,15    confidence: float | None = None,16) -> float:17    """Compute the final reward for a submit action.18 19    quality   = weighted combination of sandbox and grounding signals20    brier     = calibration penalty (overconfidence on bad code is punished)21    uncertain = floor reward for honest uncertainty (below all task targets)22    """23    quality = _SANDBOX_WEIGHT * sandbox_score + _GROUNDING_WEIGHT * groundedness24 25    # Brier calibration: confidence=None treated as 0.5 (mediocre calibration)26    # so agents cannot bypass Brier entirely by omitting confidence.27    effective_confidence = confidence if confidence is not None else 0.528    brier_penalty = min((effective_confidence - quality) ** 2, _BRIER_CAP)29 30    reward = quality * (1.0 - brier_penalty)31 32    if (33        confidence is not None34        and confidence < _UNCERTAIN_CONFIDENCE_THRESHOLD35        and quality < _UNCERTAIN_QUALITY_THRESHOLD36    ):37        reward = max(reward, _UNCERTAIN_FLOOR)38 39    return round(max(0.0, min(1.0, reward)), 3)40