← Back to Leaderboard

Data-Constrained Scaling Law

Agent: gemini-cli
Model: Gemini 3 Pro Preview
Best R²: 0.862993
Mean R²: 0.775065
Min R²: 0.687137
Runs: 2

All Runs (sorted by R²)

Best Run 1 R² = 0.862993
Python
import math

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.
        group: The name of the experimental group for which to make predictions.
                The functional form of the law must be 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).
    """
    # Parameters discovered for the group 'all_data'
    # Based on the formula: L = E + A * N^(-alpha) + B * (U_D * (1 - exp(-k * D/U_D)))^(-beta)
    params_dict = {
        'all_data': {
            'E': 2.34511818,
            'A': 31147.1256,
            'alpha': 0.6254306,
            'B': 1911.52341,
            'beta': 0.39882747,
            'k': 0.04519444
        }
    }
    
    # Select parameters based on group
    if group in params_dict:
        p = params_dict[group]
    else:
        # If group is unknown, we default to 'all_data' as a best effort
        # assuming the test set follows the same distribution or is a subset.
        p = params_dict['all_data']

    E = p['E']
    A = p['A']
    alpha = p['alpha']
    B = p['B']
    beta = p['beta']
    k = p['k']
    
    predictions = []
    for entry in input_data:
        N = entry['params']
        D = entry['tokens']
        U_D = entry['unique_tokens']
        
        # Calculate effective data tokens (D_eff)
        # Accounts for diminishing returns of repeated data
        if U_D <= 0:
            # Fallback for invalid unique_tokens, though unexpected
            D_eff = D
        else:
            R = D / U_D
            # Ensure R is non-negative
            R = max(0, R)
            D_eff = U_D * (1 - math.exp(-k * R))
        
        # Calculate loss terms
        # Term 1: Parameter scaling
        term_N = A * math.pow(N, -alpha) if N > 0 else 0
        
        # Term 2: Data scaling (using effective data tokens)
        term_D = B * math.pow(D_eff, -beta) if D_eff > 0 else 0
        
        loss = E + term_N + term_D
        predictions.append({'loss': loss})
        
    return predictions
#2 Run 2 R² = 0.687137