Inference Scaling › Inference-Optimal Model Selection
Language AI HandbookAll chapters Inference Scaling › Inference-Optimal Model SelectionOne section · Sections in this chapter5 / 11 ↓
Given expected inference demand, we can determine the optimal model size directly. This requires understanding how loss scales with both model size and training data, and then reformulating the optimization problem to account for total lifecycle costs rather than just training costs.
The Inference-Optimal Scaling Law
Building on the Chinchilla loss function from earlier chapters:
where:
- : the model's loss as a function of size and training data
- : the number of model parameters
- : the number of training tokens
- : empirically fitted scaling coefficients
- : empirically fitted exponents (typically around 0.34 and 0.28)
- : the irreducible error floor representing the entropy of natural language
This functional form captures two distinct pathways to reducing loss: adding more parameters (the first term) or training on more data (the second term). The irreducible error floor is the basic uncertainty in language. Even a perfect model cannot predict with certainty what word comes next in human text. Understanding this structure is needed for reasoning about the trade-offs between model size and training duration.
We can reformulate the optimization problem for inference-dominant scenarios. Rather than minimizing loss for a fixed training budget (the Chinchilla approach), we want to minimize loss for a fixed total budget that includes both training and expected inference. This reformulation shifts the optimization target from training efficiency to deployment efficiency.
The total compute over the model's lifecycle is:
where:
- : total compute over the model's entire lifecycle
- : training compute (approximately 6 FLOPs per parameter per token)
- : total inference compute (2 FLOPs per parameter per token generated)
- : expected total tokens generated during the model's deployment
This formulation captures the key insight: training cost is paid once, but inference cost accumulates with every token generated. The training term depends on both and (model size times data), while the inference term depends on and (model size times usage). This asymmetric structure drives the preference for smaller models in high-inference scenarios.
To minimize loss subject to a total compute budget, we take derivatives and solve. The resulting optimal allocation shifts toward smaller models as expected inference volume increases:
where:
- : the optimal model size (number of parameters) for the given deployment scenario
- : the total compute budget available across training and inference
- : expected total tokens to be generated during deployment
- : positive exponents derived from the scaling law parameters and . The exact values depend on the specific scaling law coefficients, but typical values yield and
The negative exponent on is the key result: it shows mathematically that optimal model size decreases as expected inference volume increases. This relationship emerges directly from the calculus of constrained optimization. When inference tokens grow, the cost of each parameter (which must be activated for every token) grows proportionally, pushing the optimum toward fewer parameters.
The intuition is clear: as inference demand grows, the optimal model size shrinks because each parameter incurs a cost at every inference, while training cost is amortized. A parameter that costs billions of FLOPs to train well might seem expensive, but if that parameter is then used trillions of times at inference, the training cost becomes negligible compared to the cumulative inference burden.
Practical Model Size Selection
For deployment planning, a simplified heuristic helps guide model selection. If you expect to generate inference tokens over the model's lifetime, compare the inference compute to training compute:
where:
- : total inference tokens expected over the model's deployment lifetime
- : number of tokens used for training
- : model parameters (which cancel out in the simplification)
Notice that cancels out. The inference factor depends only on the ratio of inference tokens to training tokens. This cancellation is mathematically elegant and practically useful because you can evaluate whether inference will dominate without even knowing the model size. When this factor exceeds 1, inference compute dominates. The larger this factor, the more aggressively you should favor smaller, over-trained models.
The inference factor gives a simple decision rule. Values below 1 indicate training-dominated scenarios where Chinchilla-optimal sizing remains appropriate. Values above 1 signal that inference costs will outweigh training costs, justifying investment in smaller, more heavily trained models. Values above 10 suggest aggressive over-training is warranted. Values above 100 indicate that inference efficiency should be the primary design consideration.
def compute_inference_factor(
training_tokens: float, inference_tokens: float
) -> float:
"""Calculate ratio of inference to training compute."""
return inference_tokens / (3 * training_tokens)
def recommend_model_strategy(
training_tokens: float, inference_tokens: float
) -> str:
"""Recommend training strategy based on expected inference load."""
factor = compute_inference_factor(training_tokens, inference_tokens)
if factor < 0.1:
return "Training-dominated: use Chinchilla-optimal sizing"
elif factor < 1:
return "Balanced: moderate over-training beneficial"
elif factor < 10:
return "Inference-heavy: significant over-training recommended"
else:
return "Inference-dominated: maximize over-training ratio"Deployment Scenario Analysis ================================================================= Research prototype: Training tokens: 1e+12 Inference tokens: 1e+11 Inference factor: 0.0x Recommendation: Training-dominated: use Chinchilla-optimal sizing Internal tool: Training tokens: 1e+12 Inference tokens: 1e+13 Inference factor: 3.3x Recommendation: Inference-heavy: significant over-training recommended Consumer product: Training tokens: 1e+12 Inference tokens: 1e+15 Inference factor: 333.3x Recommendation: Inference-dominated: maximize over-training ratio Major API service: Training tokens: 1e+12 Inference tokens: 1e+17 Inference factor: 33333.3x Recommendation: Inference-dominated: maximize over-training ratio
The output reveals how sharply the optimal strategy shifts based on expected usage. The research prototype shows an inference factor of just 0.03×, meaning training compute still dominates, so Chinchilla-optimal sizing remains appropriate. But as we move to consumer products (333×) and major API services (33,333×), inference compute overwhelms training by orders of magnitude. At these scales, every parameter becomes a recurring cost multiplied across trillions of tokens, making aggressive over-training the only economically rational choice. A research prototype with limited deployment can safely follow Chinchilla scaling, while a consumer-facing API should aggressively over-train smaller models.
