Models

What Is Out-of-Distribution Detection?

The task of flagging inputs that fall outside the data distribution a model was trained or evaluated on, so the system can route, fall back, or refuse.

What Is Out-of-Distribution Detection?

Out-of-distribution (OOD) detection is the task of flagging inputs that fall outside the data distribution a model was trained or evaluated on. A detector emits a per-input confidence-or-distance signal that is high for in-distribution inputs and low for OOD inputs. The system then takes action: route OOD inputs to a stronger fallback model, escalate to a human reviewer, or refuse with a graceful message. In LLM and agent stacks, OOD detection is the first-line defence against silent quality collapse when users ask in a new language, on a new topic, or with a novel input format.

Why It Matters in Production LLM and Agent Systems

LLMs do not refuse gracefully on inputs they were not trained for — they confabulate. Ask an enterprise customer-support agent a question about a product the company does not sell and you will get a confident, fluent answer that is fully fabricated. Ask the same agent in a low-resource language nobody on the team speaks and you will get fluent-sounding output that is wrong in subtle ways. Without OOD detection, those failures route to the user. With OOD detection, they route to a fallback or a refusal.

The pain is shared. Compliance officers see hallucinated responses on regulated topics the agent was never scoped to handle. Product managers see thumbs-down feedback concentrated on novel-topic queries. Backend engineers see eval-fail-rate climb in cohorts the team never trained for. SREs see runaway cost when OOD inputs trigger expensive long-context retrievals that produce nothing useful.

In 2026 agentic stacks, OOD detection is even more important because agents amplify novel-input damage across multiple steps. An OOD input at step 1 (planning) selects the wrong tool at step 2, retrieves irrelevant context at step 3, and produces a confidently wrong answer at step 5. Per-input OOD detection at the entry point prevents the cascade. The eval contract should include OOD-cohort regression metrics every release.

How FutureAGI Handles Out-of-Distribution Detection

FutureAGI’s approach is to treat OOD detection as a per-input scoring step that runs before the main model call and gates routing decisions. The pattern: build a reference-distribution embedding bank from your in-distribution training or eval data; compute the embedding for each new input; use EmbeddingSimilarity to compare it against the centroid (or k-nearest neighbours) of the bank. Below a threshold, the input is flagged OOD. Agent Command Center then takes over: a routing-policy directs OOD inputs to a stronger fallback model (gpt-4o instead of gpt-4o-mini, or claude-sonnet-4 if extra reasoning is needed) or to a refusal path that returns a graceful “I can’t help with that” message.

The evaluation surface ties this together. AnswerRefusal measures whether the system correctly refuses on OOD inputs that should be refused. Faithfulness and HallucinationScore measure whether the system that does respond on OOD inputs is at least grounded. We have found that production-grade OOD detection adds two dashboard signals: OOD-flag rate per cohort (rising trends predict drift) and OOD-handoff success rate (how often the fallback model resolves what the primary could not). Both are visible per agent.trajectory.step so the team can see exactly where the OOD branch fired in the trajectory.

How to Measure or Detect It

OOD detection has its own metrics, plus the downstream metrics it influences:

  • EmbeddingSimilarity (FutureAGI evaluator): the per-input score that drives the OOD threshold; pair with a reference-distribution embedding bank.
  • AnswerRefusal: scores whether the model correctly refused on OOD inputs that should be refused.
  • OOD-flag rate: percentage of incoming requests flagged OOD per cohort; sudden rises predict drift.
  • OOD-handoff success rate: percentage of OOD-flagged requests that get a successful answer from the fallback path.
  • false-positive OOD rate: percentage of in-distribution inputs incorrectly flagged OOD; should be measured on a frozen reference set.
  • per-cohort Faithfulness delta: faithfulness gap between flagged-OOD and not-flagged inputs that reached the model anyway.

Minimal Python:

from fi.evals import EmbeddingSimilarity, AnswerRefusal

sim = EmbeddingSimilarity()
refusal = AnswerRefusal()

ood_score = sim.evaluate(
    response=incoming_input,
    expected_response=reference_distribution_centroid,
)
is_ood = ood_score.score < 0.65  # tuned per use case

Common Mistakes

  • Tuning the OOD threshold once and forgetting it. The reference distribution drifts; rerun threshold tuning every release.
  • Using model-confidence as OOD score. LLMs are confidently wrong on OOD inputs; raw confidence is not a usable signal.
  • Skipping the fallback path. Detection without action is just a dashboard; route flagged inputs to a stronger model or a refusal.
  • Building one detector for all cohorts. Different user cohorts have different in-distribution profiles; per-cohort detectors outperform a single global one.
  • Treating “novel topic” and “novel format” as the same OOD class. They need different fallback strategies; tag them separately.

Frequently Asked Questions

What is out-of-distribution detection?

Out-of-distribution (OOD) detection is the task of flagging inputs that fall outside the data distribution a model was trained or evaluated on, so the system can route, fall back, or refuse.

How is OOD detection different from drift monitoring?

Drift monitoring tracks distribution shift in the input population over time. OOD detection makes a per-input decision: is this single request inside or outside the expected distribution?

How do you implement OOD detection in production LLM pipelines?

Compare each input embedding to the centroid of your training-input embeddings; flag inputs beyond a similarity threshold. FutureAGI's EmbeddingSimilarity evaluator returns the per-input score that drives routing decisions.