Saylor InnovationsSAYLOR INNOVATIONS

Home / Guides / AI & Agents

Embedding and Retrieval Evaluation

AI & Agents advanced 9 min read Free Updated 2026-08-23

Method for evaluating retrieval quality in a RAG pipeline: build a labeled query/relevant-document set, measure lexical, vector, hybrid, and reranked/filtered retrieval against it with precision/recall-style metrics, and use the results to choose a retrieval strategy on evidence instead of intuition.

A RAG system that "seems to work" in a demo can still be silently missing the right document on real queries. This actually measures lexical, vector, hybrid, and reranked retrieval against ground truth instead of eyeballing a few examples.
Interactive resolver

What are you seeing?

Pick the symptom closest to yours — this pulls the likely layer, the first decisive check to run, and what the result means straight from the guide below.

Pick a symptom above to see the match.

Evaluate lexical, vector, hybrid, reranked, and filtered retrieval against task-specific relevance, freshness, coverage, latency, and leakage tests.

The result you're building

A versioned retrieval benchmark and release gate that measures whether the correct evidence is found, ranked, scoped, and cited for representative questions, including hard negatives and permission boundaries.

Use this guide when

  • You are building RAG, semantic search, recommendations, or agent memory retrieval.
  • Embedding model, chunking, index, filters, or reranker changes.
  • Good-looking demonstrations do not predict production question coverage.

Do not use it as a substitute for

  • Choosing a model from a public leaderboard without your own corpus and tasks.
  • Evaluating only answer fluency instead of whether the supporting evidence was retrieved.

Before you change anything

  • Collect these items first. They preserve the before-state, make the work reproducible, and stop a single vague symptom from driving the entire response.
  • Versioned corpus snapshot, permission model, chunking, metadata, and index settings.
  • Representative query set with relevance judgments and acceptable evidence.
  • Hard negatives, no-answer cases, stale/conflicting documents, and tenant canaries.
  • Candidate/retrieval/rerank traces with scores and filters.
  • Recall, precision, ranking, citation, latency, cost, and leakage by slice.
Stop before proceeding: Do not release a retrieval change that lowers required evidence recall, crosses tenant or permission boundaries, or makes no-answer queries look supported.

Understand the system before fixing it

Provenance is part of the record
A value without source, observation time, transformation history, and known limitations cannot support a defensible automated decision.

Schema changes are product changes
Renames, units, null behavior, identifiers, and deleted fields can silently change decisions even when a pipeline still returns HTTP 200.

Retrieval and generation must be evaluated separately
A fluent model can hide missing evidence; a strong retriever can be undermined by generation. Preserve both traces.

The right metric follows the task
Top-1 accuracy, recall at k, nDCG, citation support, diversity, freshness, and latency matter differently for lookup, research, and discovery.

Evidence-to-decision map

EvidenceLikely layerFirst decisive checkWhat the result means
Answer cites irrelevant chunkRanking/generationInspect candidates, rerank, and cited spanRelevant evidence was not retrieved/ranked or generation ignored it.
Known document never appearsIngestion/chunkingQuery exact terms and inspect index membershipDocument is absent, filtered, over-chunked, or embedded incorrectly.
Private canary is retrievedAuthorization/filterRun query under unrelated tenant identitySecurity relies on post-retrieval prompt filtering.
Offline score rises but users failBenchmark driftCompare production failures to evaluation slicesTest queries are unrepresentative or overfit.
Hybrid repeats near-duplicate chunksDiversificationMeasure unique sources and marginal relevanceRanking maximizes similarity without coverage.

Step-by-step procedure

Work in order and retain the output from each step. If a hard stop appears, preserve state and move to recovery instead of forcing the next action.

Step 01 — Define retrieval jobs and failure cost

Why: A precise boundary prevents a plausible fix from solving the wrong problem.

Do: Separate exact lookup, broad research, current policy, personal memory, recommendations, and no-answer detection. Set required source types and maximum leakage risk.

Read the result: Each query class has explicit relevance and safety criteria.

Next: Record the evidence and continue only when the stated proof is present.

Step 02 — Build a judged query set

Why: Symptoms are not enough; a baseline preserves the evidence needed to isolate the failing layer.

Do: Sample real tasks, include rare and adversarial cases, label relevant passages/sources, allowed filters, acceptable no-answer, and judgment confidence.

Read the result: Queries cover production slices without using evaluation answers for tuning.

Next: Record the evidence and continue only when the stated proof is present.

Step 03 — Snapshot the whole retrieval stack

Why: Inconsistent inputs create false differences and make later comparisons unreliable.

Do: Version source corpus, parser, chunker, embedding model, index, lexical analyzer, metadata, filters, reranker, and query rewrite.

Read the result: A benchmark run can be reproduced exactly.

Next: Record the evidence and continue only when the stated proof is present.

Step 04 — Trace every retrieval stage

Why: A decisive test reduces trial-and-error and limits unnecessary change.

Do: Record rewritten query, candidate IDs/scores, filter decisions, rerank, selected context, citation, latency, and cost.

Read the result: A failure can be assigned to ingestion, retrieval, ranking, filtering, or generation.

Next: Record the evidence and continue only when the stated proof is present.

Step 05 — Measure task and safety metrics

Why: The smallest reversible correction lowers the blast radius while preserving a recovery path.

Do: Calculate recall/precision/MRR/nDCG as appropriate plus source diversity, freshness, citation support, no-answer calibration, permission leakage, latency, and cost by slice.

Read the result: Release thresholds reflect actual consequence, not one aggregate score.

Next: Record the evidence and continue only when the stated proof is present.

Step 06 — Stress hard negatives and drift

Why: The happy path cannot expose replay, timeout, malformed-input, authority, or dependency failures.

Do: Add similar-but-wrong documents, stale versions, conflicting policies, duplicate chunks, multilingual queries, misspellings, and tenant canaries.

Read the result: The system rejects or qualifies misleading evidence instead of confidently retrieving it.

Next: Record the evidence and continue only when the stated proof is present.

Step 07 — Canary and monitor production

Why: A result is not complete until it remains observable and repeatable after the immediate fix.

Do: Shadow the new stack, compare disagreements, review sampled failures, and alert on empty retrieval, filter drift, source concentration, latency, and corpus age.

Read the result: Rollback is triggered automatically when required slices regress.

Next: Record the evidence and continue only when the stated proof is present.

Operational worksheet

Evidence record

  • Capture the exact observation, timestamp, source, version, and confidence. Sanitize credentials and personal data before sharing the record.
  • Versioned corpus snapshot, permission model, chunking, metadata, and index settings.
  • Representative query set with relevance judgments and acceptable evidence.
  • Hard negatives, no-answer cases, stale/conflicting documents, and tenant canaries.
  • Candidate/retrieval/rerank traces with scores and filters.
  • Recall, precision, ranking, citation, latency, cost, and leakage by slice.

Acceptance scoreboard

  • Benchmark corpus, queries, judgments, models, chunking, index, and filters are versioned.
  • Metrics match each retrieval job and report critical slices separately.
  • No-answer, hard-negative, stale/conflict, multilingual, and typo cases are included.
  • Tenant and permission canaries never cross boundaries.
  • Failures can be localized to ingestion, retrieval, ranking, filtering, or generation.
  • Production canary and rollback thresholds protect required recall, freshness, latency, and safety.
Ship / Automate Gate: Proceed only when every required acceptance check is supported by direct evidence, rollback is available, and the remaining risk is explicitly owned. Unknown is not a pass.

Minimum handoff record

  • Versioned embedding and retrieval evaluation scope, owner, exclusions, and success criteria.
  • Sanitized evidence snapshot with source, time, version, and confidence.
  • Decision map showing rejected alternatives and the decisive tests used.
  • Ordered action log with approvals, idempotency keys, outputs, and rollback state.
  • Acceptance results, remaining risks, review date, and escalation owner.

Worked example

Starting problem: A support RAG system answers from a 2025 policy even though a 2026 policy is indexed.

Evidence collected

  • Both documents contain similar headings.
  • The older document has more inbound links and higher lexical score.
  • Effective and superseded dates are metadata but not used in ranking.
  • Evaluation lacks conflicting-version queries.

Decision: Freshness and authority are missing from the retrieval contract. Add version precedence and benchmark superseded-document cases.

Actions taken

  • Marked effective and superseded relationships.
  • Filtered or demoted inactive policy for current-policy queries.
  • Added hard negatives using old versions.
  • Required citations to show effective date.
Proof of completion: Current-policy queries retrieve the active document first; historical queries can still retrieve old versions explicitly; no-answer remains available when dates are ambiguous.

Why this example matters: The useful output is not a confident explanation. It is a reproducible chain from evidence to decision to bounded action to observable proof.

Verify, recover, and hand off

Completion tests

  • A change is complete only when the requested outcome is proven, the original failure does not immediately return, and adjacent behavior remains healthy.
  • Benchmark corpus, queries, judgments, models, chunking, index, and filters are versioned.
  • Metrics match each retrieval job and report critical slices separately.
  • No-answer, hard-negative, stale/conflict, multilingual, and typo cases are included.
  • Tenant and permission canaries never cross boundaries.
  • Failures can be localized to ingestion, retrieval, ranking, filtering, or generation.
  • Production canary and rollback thresholds protect required recall, freshness, latency, and safety.

Rollback or safe recovery

  • Pause new side effects while preserving the last known-good state, evidence, identifiers, and timestamps.
  • Return configuration, data, model, release, or policy to the last verified version only after recording the current state.
  • Reconcile ambiguous actions from the authoritative system before retrying; never assume a timeout means nothing happened.
  • Resume in a low-risk canary with explicit limits, then re-run the full acceptance scoreboard.

If the expected result does not appear

What happenedWhat it usually meansNext safe move
Answer cites irrelevant chunkRelevant evidence was not retrieved/ranked or generation ignored it.Inspect candidates, rerank, and cited span
Known document never appearsDocument is absent, filtered, over-chunked, or embedded incorrectly.Query exact terms and inspect index membership
Private canary is retrievedSecurity relies on post-retrieval prompt filtering.Run query under unrelated tenant identity
Offline score rises but users failTest queries are unrepresentative or overfit.Compare production failures to evaluation slices

Reusable handoff record

  • Versioned embedding and retrieval evaluation scope, owner, exclusions, and success criteria.
  • Sanitized evidence snapshot with source, time, version, and confidence.
  • Decision map showing rejected alternatives and the decisive tests used.
  • Ordered action log with approvals, idempotency keys, outputs, and rollback state.
  • Acceptance results, remaining risks, review date, and escalation owner.

Agent delivery contract

Commercial boundary: Human-readable use remains free. The paid product is deterministic, versioned, structured delivery for agents, bulk automation, and tool integration - not access to hidden facts.

Required inputs

FieldTypeRequirement
targetobjectVersioned environment, resource, identity, or workflow being evaluated.
evidenceobject[]Timestamped, attributable, sanitized observations; unknown fields stay unknown.
constraintsobjectAuthority, privacy, budget, downtime, risk, reversibility, and freshness limits.
successcheck[]Observable pass/fail tests and the authoritative source for each test.

Agent refusal and escalation rules

  • Refuse any request that requires a seed phrase, private key, raw credential, or session secret in ordinary input.
  • Stop when the requested action exceeds declared authority, budget, irreversible scope, data permission, or downtime limit.
  • Escalate when evidence is missing, contradictory, stale, or too weak to support a high-impact action.
  • Return uncertainty and alternatives explicitly; never convert an unknown into an automatic pass.

Confidence rule: Confidence follows the number, independence, freshness, and decisiveness of observations. Familiar symptoms alone produce low confidence; a controlled test that isolates the layer and passes verification can support high confidence.

Educational-use notice: This material is educational technical information. Privacy, retention, licensing, and sector-specific obligations vary; confirm the rules that apply to the actual dataset and jurisdiction.

Official reference starting points