#184Scaling laws — estimate the power-law exponentMediumLinear RegressionNeural NetworksLLMs
Scaling laws — estimate the power-law exponent
Background
Empirical scaling laws say test loss falls as a power law in model size:
So on log–log axes the loss-vs-parameters curve is a straight line whose slope is . Estimating the exponent is just fitting that line.
Problem statement
Implement scaling_exponent(ns, losses) that estimates from measured (n, loss) pairs via a log–log linear fit.
Input
ns— array-like of parameter counts (all ).losses— array-like of corresponding test losses (all ), same length.
Output
Returns a Python float: the estimated exponent (the negative slope of vs ).
Examples
Example 1 — a clean power law
Input: ns = [1, 4, 16, 100], losses = [10, 5, 2.5, 1.0]
Output: 0.5
Explanation: , so the log–log slope is and .
Example 2
Input: ns = [1, 2, 4, 8], losses = [2, 1, 0.5, 0.25]
Output: 1.0
Explanation: , slope , exponent .
Constraints
- Fit a line to
log(losses)vslog(ns)(natural log is fine). - Return as a
float.
Notes
- A larger means loss drops faster as you scale up — but the law only holds when data and compute scale alongside .
Python
Loading...
▶ Run executes the 3 visible sample tests below in your browser. Submit runs the full suite — including hidden tests — on the server for an official verdict.
- •Clean power law example L = 10 n^-0.5
- •Reference L = 2 n^-1 gives alpha 1.0
- •Sample three-point decade fit