AI ENGINEERING NOTES
PAGE 05Offline vs Online Evaluation
05 / 20
PAGE 05 • LLM EVALUATION

Offline vs Online Evaluation

How to validate an LLM application before release and continuously monitor it after deployment.

Offline evaluation and online evaluation solve two different but complementary problems. Offline evaluation tests an application in a controlled environment before deployment. Online evaluation observes the application after deployment using real production traffic.

This distinction is essential for production-grade AI engineering. A system can perform extremely well on a golden dataset and still fail when thousands of real users introduce unexpected inputs, new usage patterns, operational load, or changing data.

This page builds the complete mental model: release gates, version comparison, regression testing, production risks, reference-free evaluation, logging, captured and computed signals, dashboards, alerting, sampling, LLM-as-a-Judge, and the feedback loop that continuously improves the offline dataset.

At a Glance

OFFLINEBefore deployment
ONLINEAfter deployment
DATAGolden vs live traffic
MAIN GOALCorrectness vs normality
LOOPProduction → Dataset → Release

Course Recap

Before introducing offline and online evaluation, the lecture connects the topic to the earlier LLM evaluation framework.

Why do we need evaluations?LLM systems are probabilistic and can fail in many ways.
What are evaluations?Model-based and application-based evaluation were introduced.
What does an eval pipeline look like?A structured pipeline was introduced for testing an LLM application.
Why multiple pipelines?Applications have component, workflow, and application-level failure points plus different risk categories.
Risk categoriesQuality, safety, and operations such as latency and related metrics.
Evaluation methodsProgrammatic evaluation, LLM-as-a-Judge, and human evaluation.
Today's central distinction: offline evaluation asks whether the application works correctly; online evaluation asks whether the deployed application is behaving normally in production.

1. What Is Offline Evaluation?

Definition

Offline evaluation is the evaluation of an LLM-based application before it is deployed to production, usually using a controlled evaluation dataset and predefined evaluation criteria.

Simple Explanation

Build the application → prepare test cases → run the evaluation pipeline → inspect the results → decide whether the application is ready for release.

Example: UPSC Answer Grader

The lecture uses an LLM application that evaluates UPSC Mains-style answers like a human evaluator. A golden dataset is created, an LLM-as-a-Judge approach is used, and the automated scores are compared with human evaluation.

Because this happens after building the software but before deployment, it is an example of offline evaluation.

Golden Dataset
LLM Application
Evaluator
Score
Release Decision

2. Three Major Benefits of Offline Evaluation

1

Pre-Release Testing

You should not deploy an LLM application without first testing how it behaves against known cases. Offline evaluation gives a controlled way to determine whether the software is ready for production.

Release Gate

The evaluation score can become an automated CI/CD gate. For example, an organization might define a threshold of 95%.

  • Score ≥ 95% → deployment pipeline can proceed.
  • Score < 95% → deployment is blocked or the previous version is retained.
Interview point: Offline evaluation can become a quality gate inside CI/CD rather than remaining a manual testing step.
2

Version Comparison

When several implementation choices are available, run the same evaluation pipeline and same golden dataset against each version.

ModelsCompare Claude vs an OpenAI model, for example.
PromptsCompare different system prompts.
RerankersCompare retrieval/reranking strategies.
Vector DBsCompare different storage/retrieval systems.
ArchitecturesCompare alternative application designs.
Other componentsChange one component while holding the evaluation setup constant.

Because the evaluation conditions remain the same, the scores provide an objective basis for comparison.

3

Regression Testing

Regression testing checks whether a change that improves one behavior accidentally damages another existing behavior.

Imagine a CampusX chatbot that sounds too cold when students ask about refunds. You modify the system prompt to make the chatbot kinder and more polite. The new prompt may improve tone—but it might also make the chatbot less precise about prices.

If the old refund success rate was 90%, a healthy change should not unexpectedly reduce it to 80%.

Regression principle: Improving one metric should not silently destroy another important metric.

Regression Test Matrix

ChangeExpected ImprovementWhat Must Also Be Checked?
System promptBetter tonePricing accuracy, relevance, helpfulness
LLM modelBetter overall qualityLatency, cost, safety, regression cases
Vector databaseBetter retrievalExisting answer quality and latency
RerankerBetter context selectionFaithfulness and previously strong cases

3. What Can Go Wrong After Deployment?

Passing offline evaluation does not mean that production risk has disappeared. Production exposes the system to a much larger and less predictable environment.

01 — Unexpected Inputs

Users can ask questions that were never included in the golden dataset.

02 — Emergent Failures

Some failures appear only at scale or after thousands of interactions.

03 — Drift

The real-world data distribution and business context can change over time.

3.1 Unexpected Inputs

  • Hindi-English mixed conversations even when testing focused mainly on English.
  • Ambiguous or incomplete questions.
  • Angry messages containing an underlying question.
  • Adversarial prompt-injection attempts.
  • Unexpected edge cases.

3.2 Emergent and Systematic Failures

Some problems are difficult to reproduce offline because they depend on scale.

For example, a new course launch may suddenly bring thousands of concurrent users. The application may experience a large latency increase that was not visible during offline evaluation.

Another example is a subtle bias that becomes visible only after thousands of conversations reveal a pattern—for instance, noticeably different behavior toward users from different backgrounds.

3.3 Drift

Drift occurs when the real-world data, usage patterns, business information, or operating environment changes over time, making the existing evaluation setup less representative of current production.

Suppose a RAG chatbot is initially evaluated using documents containing course prices, curriculum, and policies. A year later, prices, policies, and curriculum have changed. If the golden dataset is never updated, the evaluation pipeline may continue producing good scores even though users are dissatisfied with the current chatbot.

Key insight: An outdated evaluation set can create a false sense of quality. The evaluation itself can become obsolete because of drift.

4. What Is Online Evaluation?

Online evaluation evaluates a deployed LLM application using live production traffic after deployment, while real users interact with the system.

The Biggest Difference

Online evaluation generally operates without a fixed golden answer key. The next user question is unknown, and the correct answer may not already exist in an evaluation dataset.

Core Purpose

Production Traffic
Observe Signals
Detect Abnormality
Investigate / Act

Online evaluation asks: “Is the deployed application behaving normally in production right now?”

5. Offline vs Online Evaluation

DimensionOffline EvaluationOnline Evaluation
TimingBefore deploymentAfter deployment; continuously
DataFixed golden datasetLive production traffic
Answer keyUsually available for reference-based evaluationUsually unavailable for newly arriving inputs
InputsAnticipated and selected casesAnything real users send
Best forRelease gating, version comparison, regression testingDrift, surprises, emergent bugs, production health
CostUsually cheaper and repeatableCan become expensive at scale
SpeedFast and controlledContinuous and potentially large-scale

They Are Complementary

Offline → Correctness

“Does my application work correctly on known evaluation cases?”

Online → Normality

“Is my deployed application behaving normally in the real world?”

Do not think of online evaluation as the replacement for offline evaluation. A production-grade LLM system needs both.

6. Correctness vs Normality

Correctness

Correctness asks whether the system's output is actually right according to an appropriate reference.

For the UPSC grader, correctness means checking whether the marks assigned by the LLM-based grader are close to the marks assigned by a human evaluator.

Why Direct Correctness Is Difficult in Production

After deployment, a new answer can arrive that has never been evaluated by a human. You know what the LLM produced, but you do not yet know what a human would have produced for that exact answer.

Therefore, you cannot directly calculate human-vs-model correctness for every new production interaction.

Alternative: Normality

When direct correctness is unavailable, compare current behavior with a known healthy baseline distribution.

Distribution Example

Suppose a UPSC grader historically produces the following score distribution:

Week 1
Mostly 500–700
Week 2
Similar pattern
Week 5
Suddenly 800–900

The change does not prove that the new scores are incorrect. Students may genuinely have improved. But a large distribution shift is a signal that something changed and should be investigated.

Reference-Free Signals Can Help

Some quality metrics do not require knowing the exact correct answer. For example, faithfulness in a RAG system can be evaluated by checking whether the generated answer is supported by the retrieved context.

User Feedback as a Proxy

Suppose a chatbot suddenly receives a large number of thumbs-down ratings during the last hour. This does not directly prove every answer is incorrect, but it is a strong production-quality signal that something may have gone wrong.

Important distinction: Online evaluation may estimate quality through reference-free metrics, baselines, and user signals when direct correctness is unavailable.

7. Production Signals

The lecture divides online signals into two categories: captured signals and computed signals.

Captured Signals

Values already available from the application, infrastructure, model provider, or user. They can be recorded directly.

Thumbs Up/DownLatencyToken UsageCostErrors

Computed Signals

Metrics that require an evaluator or additional computation.

FaithfulnessRelevanceCorrectnessHallucinationToxicityBias

8. Step 1 — Logging

Logging is the first step of online evaluation. If production conversations are not recorded, there is nothing reliable to evaluate later.

What Should Be Logged?

CategoryExamples
Conversation identityConversation ID, turn ID, user ID, session ID, timestamp
User inputThe question/message sent by the user
RAG contextRetrieved context used to generate the response
Model outputThe generated answer
Operational metricsLatency, prompt tokens, completion tokens, total cost
ErrorsError information and status codes
User behaviorThumbs up/down, escalation, repeated/rephrased questions, abandonment

Example Logging Record

{
  "conversation_id": "conv_123",
  "turn_id": "turn_08",
  "user_id": "user_456",
  "timestamp": "2026-08-13T10:30:00Z",
  "user_input": "...",
  "retrieved_context": ["..."],
  "model_output": "...",
  "latency_ms": 2030,
  "prompt_tokens": 850,
  "completion_tokens": 220,
  "cost": 0.012,
  "status": "success",
  "feedback": "thumbs_down"
}

LangSmith as an Example

The lecture uses LangSmith as an example of a tool that can store traces containing user inputs, outputs, metadata, and other production information.

Engineering Properties of Good Logging

1
Non-blocking

Logging should happen without unnecessarily increasing user-facing latency.

2
Durable and Queryable

Stored traces should remain available and be retrievable for future evaluation and debugging.

3
Late Signal Attachment

Signals that arrive later—such as an email escalation the next day—should be attached to the original conversation using identifiers such as conversation ID.

4
PII Handling

Phone numbers, addresses, card numbers, dates of birth, Aadhaar numbers, and similar sensitive information should be masked or removed before long-term storage where appropriate.

Privacy principle: Observability should improve system visibility without creating a new source of personal-data exposure.

9. Dashboarding & Alerting

Captured Quantity Flow

Log
Dashboard
Alert
Engineer Action

Dashboarding

Captured quantities such as latency can be sent directly to a monitoring dashboard. The dashboard aggregates values over time windows such as the last hour, 24 hours, week, or longer.

The important unit is usually not one isolated conversation but the aggregate behavior across many conversations.

Example: Sudden Traffic Spike

A new course launches and hundreds or thousands of users arrive simultaneously. Chatbot latency increases.

Traffic Spike
Latency Rises
Dashboard Shows Shift
Scale Resources

An engineering team might allocate additional compute, add instances, adjust load balancing, or otherwise manage traffic.

Alerting

Engineers cannot watch dashboards continuously. Alerts turn abnormal metrics into actionable notifications.

For example, an alert can be configured when a metric crosses a threshold during a defined time window and can notify a team through systems such as Slack, email, PagerDuty-style tools, or an internal API.

Captured signal flow: Log → Aggregate/Monitor → Dashboard → Threshold Alert → Engineer Action.

10. Computed Evaluation in Production

Computed metrics require an evaluator. A good example is hallucination rate.

Reference-Free Evaluation

A reference-free evaluation does not require a predefined golden answer for the current production input.

Hallucination Evaluation Pipeline

Production Trace
Sample
LLM-as-a-Judge
Hallucination Score
Dashboard
Alert

How the Evaluator Works

The evaluator can receive:

  • The user's question.
  • The retrieved context.
  • The generated answer.
  • A detailed rubric explaining how hallucination should be detected.

A stronger LLM can then act as a Judge and compute an evaluation score.

Cost consideration: If the production chatbot handles a large number of conversations, running an additional LLM judge on every conversation can become expensive.

Reference-Based vs Reference-Free

Reference-BasedReference-Free
Known answer/reference exists.No fixed answer key for the current input.
Common in controlled offline datasets.Useful for many live production cases.
Example: automated UPSC marks vs human marks.Example: checking whether an answer is supported by retrieved context.

11. Sampling: Controlling Evaluation Cost

If an application receives a large number of production conversations, evaluating every conversation with an LLM-as-a-Judge may be too expensive.

Random Sampling

A basic strategy is to randomly select a subset of conversations and evaluate only that subset.

Why Random Sampling Is Not Always Optimal

Not all conversations are equally informative. Most production conversations may be routine, while a small subset contains the highest-risk behavior.

Stratified Sampling

Stratified sampling divides production conversations into meaningful categories and intentionally samples more heavily from high-risk categories.

Thumbs Down

Users explicitly indicate dissatisfaction.

Abandoned Chats

Conversation ends abruptly.

Escalations

User asks for human support.

Repeated Questions

User rephrases the same question repeatedly.

Financial Topics

Pricing, fees, refunds, payments.

High-Risk Topics

Other categories known to be sensitive or failure-prone.

Why Stratification Helps

If a sample contains more conversations that are likely to contain failures, the evaluator has a higher probability of discovering meaningful problems with the same evaluation budget.

Practical rule: Sample for information value, not simply for mathematical convenience.

12. Evaluation Platform Example — LangSmith

The lecture demonstrates how a platform such as LangSmith can support both online and offline evaluation workflows.

Types of Evaluators

PII LeakagePrompt InjectionCode Injection ToxicityBias & FairnessHallucination CorrectnessRelevanceConciseness Conversation QualityAgent EvaluationMultimodal

How the Same Evaluator Becomes Online or Offline

Evaluator Runs OnModeMeaning
Production tracesOnlineThe evaluator analyzes live logged interactions.
Dataset / experiment examplesOfflineThe evaluator analyzes controlled evaluation data.

This is a powerful conceptual point: the evaluator type alone does not determine whether the evaluation is online or offline; the data it runs against matters.

Typical Evaluator Configuration

  1. Select the application.
  2. Select the evaluator type, such as hallucination.
  3. Select an LLM to act as the Judge.
  4. Configure model/API settings.
  5. Define the rubric and instructions.
  6. Specify the required output format.
  7. Choose whether the evaluator runs on traces or a dataset.

13. The Self-Improving Offline ↔ Online Loop

One of the most important ideas in the lecture is that online and offline evaluation should remain continuously connected.

Offline Dataset
Offline Evaluation
Release
Production
Online Monitoring
Failure
Dataset Update

Step-by-Step

1
Build a golden dataset

Start with representative evaluation cases.

2
Run offline evaluation

Check correctness, quality, safety, and regression before release.

3
Deploy

Release the version that satisfies the required evaluation gates.

4
Monitor production

Log traces, collect signals, run online evaluators, and monitor dashboards.

5
Identify meaningful failures

Find conversations where the system behaved incorrectly, unexpectedly, or unsafely.

6
Add failures to the offline dataset

Annotate the production conversation and make it part of future evaluation.

7
Repeat

Run the next release against the enriched dataset and continue the cycle.

Why This Creates a Better System

The offline dataset becomes progressively more realistic because it contains real production failure cases. Instead of relying only on what engineers predicted users might ask, the evaluation suite gradually incorporates what users actually did.

Self-improving loop: Production failures become future offline test cases.

Interview Questions

Q1. What is offline evaluation?

Evaluation of an LLM application before production deployment, typically using a controlled dataset and predefined evaluation criteria.

Q2. What are the three major benefits of offline evaluation?

Pre-release testing/release gating, version comparison, and regression testing.

Q3. What is a release gate?

An automated condition in the deployment pipeline that allows or blocks a release based on evaluation results.

Q4. What is regression testing in LLM applications?

Testing whether a change improves the intended behavior without degrading previously working behaviors.

Q5. What are three major production risks after offline evaluation?

Unexpected inputs, emergent/systematic failures, and drift.

Q6. What is online evaluation?

Continuous evaluation of a deployed application using live production traffic.

Q7. Why is online evaluation often reference-free?

Because new production questions are unknown and generally do not have pre-existing golden answers.

Q8. What is the difference between correctness and normality?

Correctness asks whether the output is actually right; normality asks whether current production behavior is consistent with a healthy baseline.

Q9. What are captured signals?

Signals that can be recorded directly, such as latency, cost, token usage, errors, and user feedback.

Q10. What are computed signals?

Metrics requiring additional evaluation or computation, such as faithfulness, hallucination, toxicity, relevance, and bias.

Q11. Why is logging the first step?

Because production evaluation requires access to the conversations and signals generated in production.

Q12. Why should production logging be non-blocking?

So observability does not unnecessarily increase user-facing application latency.

Q13. Why is sampling needed for LLM-as-a-Judge?

Running an additional LLM evaluator over every production conversation can be expensive.

Q14. Why can stratified sampling be better than random sampling?

It intentionally prioritizes categories that are more likely to contain failures.

Q15. How does an evaluator become online or offline?

An evaluator running against production traces is an online evaluator; the same type of evaluator running against a controlled dataset is an offline evaluator.

Q16. How do online and offline evaluation close the loop?

Production failures are added or annotated in the offline dataset, making future offline evaluation more representative.

Quick Revision

Offline Evaluation

  • Before deployment
  • Golden dataset
  • Controlled inputs
  • Usually reference-based
  • Release gating
  • Version comparison
  • Regression testing

Online Evaluation

  • After deployment
  • Live traffic
  • Unexpected inputs
  • Often reference-free
  • Drift detection
  • Normality monitoring
  • Production risk detection

Captured Signals

  • Latency
  • Tokens
  • Cost
  • Errors
  • Thumbs up/down
  • Escalations
  • Repeated questions

Computed Signals

  • Faithfulness
  • Relevance
  • Hallucination
  • Correctness estimates
  • Toxicity
  • Bias & fairness

One-Minute Mental Model

Build
Offline Eval
Release Gate
Production
Logging
Monitoring
Online Eval
Failures
Dataset Update

Key Takeaways

  1. Offline evaluation is mandatory before deploying an LLM application.
  2. Its three major benefits are release testing, version comparison, and regression testing.
  3. Production creates risks that a fixed golden dataset cannot fully predict.
  4. Online evaluation continuously monitors the deployed application using live traffic.
  5. Online evaluation often has no fixed answer key, so reference-free metrics and production signals become important.
  6. Correctness and normality are different concepts.
  7. Captured signals are recorded directly; computed signals require evaluators.
  8. Logging should be non-blocking, durable, queryable, capable of attaching late signals, and privacy-aware.
  9. Dashboards reveal aggregate behavior; alerts turn abnormal behavior into action.
  10. LLM-as-a-Judge can evaluate production traces, but sampling controls evaluation cost.
  11. Stratified sampling focuses evaluation capacity on high-risk conversations.
  12. Online and offline evaluation are complementary—not competing approaches.
  13. Production failures should become future offline evaluation cases.

Final Mental Model

A production-grade AI engineer does not stop at “I built the chatbot.” The complete mindset is:

Build → Evaluate → Release → Observe → Detect → Learn → Update Dataset → Re-evaluate → Release Again.

This is the shift from simply building an LLM application to engineering an LLM system that can operate reliably at real-world scale.