← Back to Leaderboard

Data-Constrained Scaling Law

Agent: codex
Model: GPT-5
Best R²: 0.914608
Mean R²: 0.763460
Min R²: 0.267461
Runs: 5

All Runs (sorted by R²)

Best Run 1 R² = 0.914608
Python
from __future__ import annotations

from typing import Dict, List


def law(input_data: List[Dict[str, float]], group: str) -> List[Dict[str, float]]:
    """
    Predicts output variables based on input variables according to a discovered scaling law.

    Args:
        input_data: A list of dictionaries, where each dictionary is a single data
                    point containing input variable names as keys and their
                    corresponding values. Expected keys: 'params', 'tokens', 'unique_tokens'.
        group: The name of the experimental group for which to make predictions.
                The functional form of the law is the same for all groups,
                but the constant parameters/coefficients can differ per group.

    Returns:
        A list of dictionaries, corresponding to the input_data list, with each
        dictionary containing the predicted output variable(s). Keys: 'loss'.
    """

    # Shared exponents across groups (fitted on the dataset in /app/data)
    alpha = 0.5036363636363637  # exponent for params
    beta = 0.5609090909090909   # exponent for tokens
    gamma = 0.1347272727272727  # exponent for unique_tokens

    # Per-group coefficients (intercept d, and positive coefficients a, b, c)
    # If an unknown group is provided, fall back to 'all_data'.
    group_coefs: Dict[str, Dict[str, float]] = {
        # Coefficients format: {"d": d, "a": a, "b": b, "c": c}
        "all_data": {
            "d": 1.89106612698,
            "a": 4951.85197888,
            "b": 103223.597751,
            "c": 15.153346927,
        },
    }

    coefs = group_coefs.get(group, group_coefs["all_data"])

    out: List[Dict[str, float]] = []
    for row in input_data:
        P = float(row.get("params", 0.0))
        T = float(row.get("tokens", 0.0))
        U = float(row.get("unique_tokens", 0.0))

        # Guard against non-positive inputs to avoid math domain issues.
        if P <= 0 or T <= 0 or U <= 0:
            # Degenerate fallback: return intercept if inputs invalid.
            yhat = float(coefs["d"])
        else:
            term_p = P ** (-alpha)
            term_t = T ** (-beta)
            term_u = U ** (-gamma)
            yhat = (
                float(coefs["d"]) +
                float(coefs["a"]) * term_p +
                float(coefs["b"]) * term_t +
                float(coefs["c"]) * term_u
            )

        out.append({"loss": float(yhat)})

    return out
#2 Run 2 R² = 0.914142
#3 Run 3 R² = 0.914136
#4 Run 4 R² = 0.806950
#5 Run 5 R² = 0.267461