Negative Log-Likelihood (NLL) is a loss function that measures model performance by taking the negative logarithm of the predicted probability assigned to the correct class. As a proper scoring rule, it is minimized only when the predicted distribution perfectly matches the true distribution, encouraging honest, calibrated probability estimates rather than overconfident predictions.
Glossary
Negative Log-Likelihood (NLL)

What is Negative Log-Likelihood (NLL)?
Negative Log-Likelihood is a proper scoring rule that quantifies the divergence between a model's predicted probability distribution and the true data distribution, heavily penalizing confident misclassifications.
NLL heavily penalizes confident errors: a high-confidence wrong prediction incurs a disproportionately large loss, while a correct prediction with moderate confidence yields a smaller penalty. In practice, minimizing NLL is equivalent to maximizing the likelihood of the observed data under the model, making it the standard objective for training probabilistic classifiers and a direct measure of predictive uncertainty quality.
Key Properties of NLL
Negative Log-Likelihood (NLL) is a strictly proper scoring rule that serves as the standard loss function for probabilistic classification. It evaluates a model by taking the negative logarithm of the predicted probability assigned to the correct class, creating an asymmetric penalty landscape that heavily punishes confident errors.
Strictly Proper Scoring Rule
NLL is a strictly proper scoring rule, meaning its expected value is uniquely minimized when the model outputs the true conditional class probabilities. This property encourages honest probability estimates rather than merely correct classifications. A model cannot 'game' NLL by being overconfident on easy examples while hedging on difficult ones—the optimal strategy is always to report the true predictive distribution. This contrasts with improper metrics like accuracy, which can be maximized by miscalibrated models.
Asymmetric Penalty Structure
NLL imposes a severe asymmetric penalty on confident misclassifications. Consider a binary case where the true label is class 1:
- High-confidence correct: p=0.99 → NLL = -log(0.99) ≈ 0.01 (minimal penalty)
- High-confidence wrong: p=0.01 → NLL = -log(0.01) ≈ 4.61 (extreme penalty)
- Uncertain prediction: p=0.50 → NLL = -log(0.50) ≈ 0.69 (moderate penalty) This logarithmic scaling means the penalty approaches infinity as the predicted probability for the true class approaches zero, making NLL highly sensitive to catastrophic errors.
Relationship to Cross-Entropy
For classification tasks with one-hot encoded targets, NLL is mathematically equivalent to categorical cross-entropy. Given a true distribution q (one-hot) and predicted distribution p, cross-entropy H(q,p) = -Σ q(x)log(p(x)) reduces to -log(p_true_class). This equivalence means minimizing NLL is identical to minimizing the Kullback-Leibler divergence between the empirical data distribution and the model's predicted distribution, making it the maximum likelihood estimator under a categorical likelihood assumption.
Decomposition: Calibration + Refinement
The expected NLL can be decomposed into two interpretable components:
- Calibration loss: Measures how well predicted probabilities match observed frequencies across confidence bins. A perfectly calibrated model has zero calibration loss.
- Refinement loss: Measures the inherent discriminative power of the model—how well it separates classes regardless of probability calibration. This is bounded by the dataset's intrinsic uncertainty. This decomposition reveals that NLL simultaneously optimizes for both sharpness (concentrated predictions) and calibration (accurate probabilities), unlike metrics such as Brier Score which weight these components differently.
Gradient Behavior During Training
The gradient of NLL with respect to the logits exhibits a critical property for optimization: ∂NLL/∂z_i = p_i - y_i, where p_i is the softmax probability and y_i is the one-hot target. This elegant form means:
- The gradient signal is strongest when the model is confidently wrong
- The gradient vanishes when the model is confidently correct
- The gradient naturally implements hard example mining, focusing parameter updates on misclassified or uncertain examples This property makes NLL particularly effective with stochastic gradient descent, as it automatically balances the learning signal across easy and hard examples.
NLL as a Calibration Diagnostic
NLL serves as a summary statistic for calibration quality that complements visual tools like reliability diagrams. While Expected Calibration Error (ECE) only measures miscalibration within discrete bins, NLL captures the full continuous probability spectrum. A model with low ECE but high NLL indicates diffuse predictions (poor refinement)—the model is calibrated but unconfident. Conversely, low NLL requires both good calibration and sharp, discriminative predictions. This makes NLL a more comprehensive single-number metric for probabilistic model quality than binning-based alternatives.
Frequently Asked Questions
Clear, technically precise answers to the most common questions about Negative Log-Likelihood, its role as a proper scoring rule, and its relationship to cross-entropy and model calibration.
Negative Log-Likelihood (NLL) is a proper scoring rule that evaluates a probabilistic model by taking the negative logarithm of the predicted probability assigned to the correct class. For a single data point, the NLL is calculated as -log(p_hat), where p_hat is the model's predicted probability for the true label. Because the logarithm of a number between 0 and 1 is negative, the negative sign ensures the loss is always positive. The function is strictly convex, meaning it has a unique minimum when the predicted probability for the correct class is 1.0. This mathematical property heavily penalizes confident misclassifications: predicting a probability of 0.01 for the true class yields an NLL of 4.6, while a probability of 0.9 yields only 0.1. Minimizing the average NLL across a dataset is equivalent to performing Maximum Likelihood Estimation (MLE), making it the de facto standard loss function for training classification models.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
Core concepts and techniques for aligning a model's predicted probabilities with its actual empirical accuracy, ensuring trustworthy and reliable AI outputs.
Expected Calibration Error (ECE)
The primary empirical metric for measuring model calibration. ECE partitions predictions into M equally-spaced confidence bins and computes the weighted average of the absolute difference between accuracy and confidence within each bin.
- Formula: ECE = Σ (|B_m|/n) * |acc(B_m) - conf(B_m)|
- A perfectly calibrated model achieves an ECE of 0.
- Lower ECE indicates more reliable probability estimates.
Temperature Scaling
A post-hoc calibration method that uses a single scalar parameter T to soften or sharpen the output softmax distribution. T > 1 softens probabilities, reducing overconfidence; T < 1 sharpens them.
- Optimized on a held-out validation set using NLL.
- Does not alter the model's accuracy or ranking—only the confidence scores.
- The simplest and most effective modern calibration technique for neural networks.
Brier Score
A strictly proper scoring rule that measures the mean squared error between predicted probabilities and actual binary outcomes. It decomposes into refinement and calibration components.
- Formula: BS = (1/N) Σ (p_i - y_i)²
- Unlike NLL, the Brier Score is bounded between 0 and 1.
- Penalizes both overconfidence and underconfidence symmetrically.
Proper Scoring Rule
A loss function that is minimized uniquely when the predicted probability distribution matches the true data-generating distribution. This property encourages honest and calibrated forecasts.
- Negative Log-Likelihood (NLL) is the canonical strictly proper scoring rule.
- The Brier Score is also strictly proper.
- Improper rules incentivize the forecaster to lie about their true beliefs.
Reliability Diagram
A visual diagnostic tool that plots predicted confidence against observed accuracy across discrete bins. A perfectly calibrated model follows the identity diagonal (y = x).
- Bars above the diagonal indicate underconfidence.
- Bars below the diagonal indicate overconfidence.
- The gap between the curve and the diagonal is the visual representation of ECE.
Epistemic vs. Aleatoric Uncertainty
Aleatoric uncertainty is the irreducible noise inherent in the data (e.g., sensor error). Epistemic uncertainty is the reducible model uncertainty due to lack of knowledge.
- Epistemic uncertainty is high in out-of-distribution (OOD) regions.
- Collecting more data reduces epistemic, but not aleatoric, uncertainty.
- Calibration primarily addresses the quality of the predicted distribution, while uncertainty quantification decomposes its source.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us