What Is Logarithmic Loss?
Logarithmic loss penalizes low predicted probability assigned to the true label, making it a probability-sensitive classification and LLM evaluation metric.
What Is Logarithmic Loss?
Logarithmic loss, usually called log loss, is an LLM-evaluation and classification metric that scores how much probability a system assigned to the true outcome. It appears in eval pipelines for intent classifiers, safety classifiers, router decisions, and agent steps that choose among labeled actions. A lower score means the system is both right more often and less overconfident when wrong. FutureAGI uses log loss as a custom scalar beside task-level evaluators and production trace signals.
Why logarithmic loss matters in production LLM and agent systems
Log loss catches a specific production failure: the system is wrong and confident. Accuracy, F1, and ROC-AUC can look acceptable while the model assigns 0.99 probability to a false intent, unsafe category, or failed tool route. That matters because downstream systems often treat high confidence as permission to skip escalation, bypass human review, or choose a cheaper route.
The pain is not limited to ML owners. Developers see brittle thresholds after a prompt or model update. SREs see fallback spikes, retry loops, and route-specific latency because the wrong branch was selected with high confidence. Product teams see confident misclassification of user intent. Compliance teams see moderation classifiers that are technically accurate on average but dangerously under-penalized on tail labels.
The common symptoms are visible in eval tables and traces: rising mean log loss, larger calibration gaps, more false positives above a confidence threshold, and an eval-fail-rate-by-cohort that only moves for one tenant, language, or product surface. In 2026-era agent pipelines, a single overconfident classification can poison several later steps. A support agent may misread “cancel” as a billing question, call the wrong tool, generate a plausible answer, and still pass a surface-level fluency check. Log loss gives that early wrong confidence a cost.
How FutureAGI handles log loss
FutureAGI’s approach is to treat log loss as a probability-quality signal, not a replacement for task success. Because log loss has no dedicated FutureAGI anchor, the practical workflow is conceptual: compute log_loss in the classifier or router harness, then attach it to the eval run as a CustomEvaluation-style scalar beside built-in evaluators such as GroundTruthMatch.
A real example: an engineer runs a regression eval for a support-intent classifier that feeds an agentic workflow. Each row has input, true_label, predicted_label, and predicted_probability_for_true_label. The harness records example_log_loss = -log(p_true) and aggregates mean_log_loss by prompt version, model name, tenant, and language. FutureAGI stores the scalar next to pass/fail task results and traceAI context from the OpenAI integration, including fields such as llm.token_count.prompt and model metadata.
The next action depends on the pattern. If mean_log_loss rises while GroundTruthMatch stays flat, the classifier may still choose the right label but with worse calibration, so the engineer reviews thresholds before changing user-facing behavior. If log loss rises with a worse false-positive rate on one cohort, the team creates a targeted regression eval and adjusts the decision threshold. If a router sends high-loss requests to an expensive model anyway, the owner can test an Agent Command Center fallback or routing policy before rollout.
Unlike accuracy-only dashboards, log loss keeps the probability distribution visible. A model that is 90 percent accurate but confidently wrong on the remaining 10 percent is riskier than the same accuracy with honest uncertainty.
How to measure or detect log loss
Measure log loss on labeled examples where the model outputs a probability for each class. For binary classification, use -(y * log(p) + (1 - y) * log(1 - p)). For multiclass classification, use -log(p_true_class). Then monitor it beside behavioral metrics:
- Mean log loss — average
-log(p_true)across the eval set; lower is better when label space and dataset stay fixed. - Calibration by cohort — compare log loss by tenant, language, prompt version, route, and class frequency before changing thresholds.
GroundTruthMatch— checks whether the predicted label matches the expected label; pair it with log loss to separate correctness from confidence quality.CustomEvaluation— records the manually computed scalar so dashboards can alert onmean_log_lossor percentile movement.- Trace signals — inspect
llm.token_count.prompt, p99 latency, fallback rate, and escalation rate when log loss rises after a model or prompt change.
Minimal pairing snippet:
from fi.evals import GroundTruthMatch
import math
p_true = max(predicted_probability_for_true_label, 1e-15)
log_loss = -math.log(p_true)
match = GroundTruthMatch().evaluate(response=predicted_label, expected_response=true_label)
print(log_loss, match.score)
Treat the scalar as comparable only within the same label set, tokenizer or classifier family, prompt template, and evaluation dataset.
Common mistakes
- Reporting accuracy alone. Accuracy hides whether the model was barely right or dangerously confident while wrong, so review confidence distributions beside pass/fail rates.
- Comparing across label spaces. A ten-class router and a binary classifier do not share a meaningful raw log-loss scale, even on the same dataset size.
- Ignoring class imbalance. Global log loss can hide severe overconfidence on rare safety, refund, or escalation labels; inspect per-class and cohort slices.
- Clipping probabilities after scoring. Clamp before
log(p)so zeros become bounded losses instead of NaN or infinity in the eval export. - Using text logprobs as classification log loss. For generated-token fit, use perplexity or token negative log likelihood; log loss needs labeled classes.
Frequently Asked Questions
What is logarithmic loss?
Logarithmic loss is an evaluation metric that penalizes a model when it assigns low probability to the true label. It is useful when confidence quality matters, not just whether the top label is correct.
How is log loss different from accuracy?
Accuracy counts correct labels after a threshold or argmax decision. Log loss uses the full predicted probability, so an overconfident wrong answer is punished much more than an uncertain wrong answer.
How do you measure log loss?
Compute the negative log of the probability assigned to the true label and average it across examples. In FutureAGI, store that scalar as a CustomEvaluation-style result beside GroundTruthMatch and trace fields such as llm.token_count.prompt.