GuideRAGRetrievalEvaluationSecurity

The Production RAG Guide: Retrieval, Reranking and Evaluation

Debug RAG bottom-up: corpus, candidate recall, rank and cut, context use, answer shape, authorization. A sourced guide to chunking, hybrid search, reranking, evaluation and permissions, with five NKK models.

Author
NKK Innovations Research Team
Published
Reading time
19 min read
Guide

Key takeaways

  • Debug in pipeline order. Several of the seven documented RAG failure points start before generation, so fix retrieval and the corpus before tuning the prompt.
  • Hybrid retrieval plus a reranker is the best-supported default: on one 2026 finance benchmark Recall@5 rose from 0.587 (dense) to 0.816 (hybrid plus rerank).
  • Chunk-size defaults differ by 2-3x between vendors (about 300 versus 800 tokens) and independent evidence is thin. Sweep size and overlap on your own queries.
  • Anthropic's own test: 35% fewer failed top-20 retrievals from contextual embeddings, 67% with contextual BM25 and reranking added. One small independent chunk-level check and one indirect document-level result found modest gains.
  • Permissions belong in the retrieval layer: filter by caller identity inside the search, on every chunk, and fail closed. Prompt-level filtering is probabilistic.
  • For a small, stable corpus, try the whole thing in context with caching first. The long-context versus RAG evidence uses 2023-2024 models, so re-test.

In NKK's view, teams often debug RAG backwards: a wrong answer appears, so they rewrite the prompt or swap the model, when the evidence the model needed was never in front of it. Barnett and colleagues, drawing on three case studies, list seven failure points, and the first three (missing content, missed documents, evidence not in context) start before generation [1]. Their abstract's first lesson is that "validation of a RAG system is only feasible during operation" [1]. We read that as: build a starter evaluation set up front, then grow it from production failures.

This guide takes a position. In NKK's view, production RAG is a chain of stages whose pass rates multiply, so the cheapest fix is usually the earliest broken stage. We found no failure-rate data that says how often that is the case, and say so below. And authorization, the stage that is easiest to leave untested because it fails silently, is a property of retrieval, not of the prompt. We walk the pipeline in debugging order, cite what the evidence supports, say where it is thin, and finish with a decision flow and a debugging table.

Debug in pipeline order: the model is the last place to look

Key figures
  • 5.7%

    of queries missed the relevant chunk in the top 20 (Anthropic's evaluation)

  • ~22 pts

    accuracy gap, answer first versus mid-context (GPT-3.5-Turbo, 20 documents)

  • 0.82

    Recall@5 with hybrid search plus a reranker, versus 0.59 dense-only

The first number is a vendor measurement: Anthropic's own evaluation across codebases, fiction, ArXiv and science papers, with embeddings-only retrieval (Gemini Text 004) as the baseline. The page does not state who built the datasets or whether they are public, so treat it as indicative. The mechanism is general, though: if the relevant chunk is not retrieved, nothing downstream recovers it [2]. The second is a 2023 result on 2023 models, in which GPT-3.5-Turbo scored 75.8 with the answer first and 53.8 mid-context; the paper itself says "more than 20%". Liu et al. found accuracy highest when relevant information sits at the beginning or end of the input and lower in the middle, even for long-context models [3]. Retrieval can succeed and the answer can still fail. The third is one 2026 preprint: Recall@5 rose from 0.587 for dense-only retrieval to 0.816 for hybrid retrieval plus a reranker on 23,088 finance queries [17].

Stages also multiply. Suppose five stages pass 95%, 90%, 92%, 93% and 97% of the time. End to end that is about 71%, even though no single stage looks alarming. The five rates in this chart are invented to show the arithmetic, and real stages are not independent, but the lesson holds: a weak early stage caps everything after it.

Why a pipeline of good stages still disappoints (illustrative)
NKK framework Illustrative
  • After corpus coverage
    95%
  • + candidate recall
    85.5%
  • + rank and cut
    78.7%
  • + context use
    73.2%
  • + answer shape
    71%
Illustrative arithmetic, not measured data. Five invented stage pass rates (95%, 90%, 92%, 93%, 97%) applied one after another leave 95, 85.5, 78.7, 73.2 and 71.0 percent of queries correct (0.95 x 0.90 x 0.92 x 0.93 x 0.97 = 0.71). It assumes the stages are independent, which real pipelines are not.

The NKK Retrieval Debug Ladder orders the checks so effort never goes into the prompt while the evidence is missing. It builds on the failure points above [1], Microsoft's retrieval metrics [4] and its generation diagnostics [5].

NKK Retrieval Debug Ladder
NKK framework
  1. Level 1: 1. Corpus

    Is the answer in the index at all, parsed correctly, in the current version? Fix ingestion before anything else.

    • Failure point 1: missing content
    • Test: search the exact passage text; index coverage
  2. Level 2: 2. Candidate recall

    Is the right chunk anywhere in the top K the retriever returns? This is a retrieval question, not a model question.

    • Failure point 2: missed top-ranked documents
    • Metric: recall@K on labelled queries
  3. Level 3: 3. Rank and cut

    Does the chunk survive merging, reranking and truncation into the final prompt?

    • Failure point 3: not in context
    • Metrics: MRR, recall@N after the cut
  4. Level 4: 4. Context use

    With the chunk in the prompt, does the model extract and use it? Position and volume matter.

    • Failure point 4: not extracted
    • Metrics: completeness versus utilization
  5. Level 5: 5. Answer shape

    Is the answer in the right format, at the right specificity, and complete?

    • Failure points 5-7: wrong format, incorrect specificity, incomplete
    • Metrics: correctness, completeness
  6. Level 6: 6. Authorization

    Should this user have seen any of the retrieved chunks? It fails silently, so it needs its own tests, run on every change alongside rungs 1-5.

    • Test: per-user permission cases
    • Metric: zero unauthorized chunks returned
Six rungs for debugging RAG from the evidence upward. Rungs 1-5 are sequential: do not climb until the one below passes its test. Rung 6, authorization, is a parallel always-on gate: its test cases run on every change, and it is numbered 6 only for symptom triage.

How to use it: take 50 failing examples (NKK's rule of thumb, not an evidence-based number), label each with the lowest rung that fails, and fix the most common rung first. Where it breaks: rungs interact (a new chunk size changes recall and rank at once), so treat the order as triage, not causal proof, and rungs 2 and 3 cannot be measured without labelled evidence.

Build the evaluation set before the pipeline

Microsoft's RAG design guidance defines a test case as a query, the context that answers it (actual text and page) and the expected answer, and prefers real content and real user questions over synthetic ones [6]. Questions generated per chunk by an LLM are acceptable if a subject-matter expert verifies them [6]. The least glamorous requirement matters most: gather queries the documents do not address, and decide in advance what the system should do, such as saying it does not know [6]. Models struggle here. The RGB benchmark found six LLMs showed some noise robustness but struggled with negative rejection, information integration and false information [7]. The SemEval-2026 multi-turn task includes unanswerable, underspecified and non-standalone questions, covering the same gap [8].

Measure each stage, then the whole. For retrieval use precision@K, recall@K and mean reciprocal rank; positive queries should score near 1 and negative queries near 0 [4]. For generation, Microsoft defines groundedness, completeness, utilization, relevance and correctness, and the pairings diagnose. High completeness with low utilization suggests lowering top-k. Low completeness with high utilization suggests larger chunks or higher top-k. High groundedness with low correctness means the answer is grounded in the wrong, or wrongly combined, context [5].

Automated judges need calibration. Ragas defines faithfulness as the share of answer statements supported by the context; on its WikiEval set, agreement with human annotators was 0.95 for faithfulness but 0.70 for context relevance [9]. That dataset is small and built by the authors, so treat it as indicative. ARES uses a few hundred human annotations to correct judge error [10]. Label a sample by hand before you trust any automated score.

Evaluation-set readiness
NKK framework
0 of 5 answered
Query realism

Where do your test questions come from?

Unanswerable cases

Does the set include questions the corpus cannot answer?

Evidence labels

Is the supporting passage labelled for each question?

Expert review

Who verified the expected answers?

Judge calibration

Have automated judges been checked against human labels?

Answer all 5 dimensions to see your score and where to start.

Five questions that decide whether your retrieval and generation metrics can be trusted. Pick the answer that matches today's reality; the lowest score is the first thing to fix.

Chunking: let document structure choose the method

Microsoft calls the chunking approach "a semipermanent choice" in the overall design, because changing it forces downstream changes, and matches methods to structure: layout analysis for semi-structured documents, custom code for law and patents, sentence-based or fixed-size chunks with overlap for plain prose [11]. There is no consensus size. OpenAI's managed file search defaults to 800 tokens with 400 overlap [12]; Amazon Bedrock's default is about 300 tokens, sentence-aware [13].

Evidence for any one answer is thin and mixed. In Chroma's vendor study, the 800/400 token splitter that Chroma assumes matches OpenAI's default (it ran TokenTextSplitter, not OpenAI's own implementation) scored lowest: precision 1.4 (IoU 1.4), against 1.5 for recursive splitting at the same 800/400 setting, 7.0 (IoU 6.9) for 200-token recursive chunks and 8.0 for 200-token cluster-semantic chunks, with the top 5 chunks and text-embedding-3-large. The gap at equal size is small; the large differences are against 200-token chunks. These are token-level metrics on LLM-generated queries, not answer accuracy [14]. On semantic chunking, a controlled comparison (Qu, Tu and Bao) found gains mainly on artificially stitched datasets; on original datasets fixed-size was usually equal or better (HotpotQA F1@5 90.59 against 87.37), and the authors call it the more efficient and reliable choice [15]. A 2026 preprint adds that the best strategy depends on the task: structure-based chunking (its term for fixed-size, sentence and paragraph splitting) beat LLM-guided chunking for in-corpus retrieval, while contextualized chunking helped there and hurt in-document retrieval [16].

The better-supported lever is restoring context a chunk loses. Anthropic prepends LLM-written context to each chunk; in its own test, failed top-20 retrievals fell from 5.7% to 3.7%, a 35% relative reduction [2]. Independent checks are smaller. On a 20% subset of NFCorpus, with Jina-V3 and a small open model (Phi-3.5-mini) writing the prefixes, nDCG@5 moved from 0.303 to 0.312 [18], the only independent chunk-level check we found. A finance preprint prepended summaries to whole, unchunked documents of about 920 tokens (Recall@5 0.587 to 0.615 dense, 0.695 to 0.717 hybrid) [17]; that is indirect evidence, and its authors caution that results may differ for chunked corpora. Late chunking, which embeds the full text before splitting, is the authors' claim and an alternative [19]. In the same NFCorpus study, late chunking scored 0.309 nDCG@5 on the subset, against 0.303 for the plain fixed-window baseline and 0.317 for the full contextual pipeline; the authors summarise late chunking as one that "offers higher efficiency but tends to sacrifice relevance and completeness" [18].

Two cautions. Layout-rich PDFs are a weak spot for text extraction; ColPali proposes embedding page images instead, but the evidence is the authors' own [20]. And permissions must travel with every chunk, a point we return to below.

Chunking methods: fit, cost, evidence
NKK framework
Fixed-size or other structure-based (sentence, paragraph)
Best fit
Unstructured prose
Cost
Low
Evidence
Often matched semantic on original datasets; beat LLM-guided in one 2026 preprint
Main risk
Splits ideas; vendor defaults vary 2-3x
Hierarchical (parent-child)
Best fit
Manuals, policies, law with headings
Cost
Medium; needs parsing
Evidence
Vendor feature description only; no independent evidence found
Main risk
May return fewer results than requested
Semantic (embedding breakpoints)
Best fit
Documents with topical overlap
Cost
High
Evidence
Gains mainly on synthetic stitched data
Main risk
Sentence embeddings lack context
LLM-guided chunking
Best fit
Lookups inside one long document
Cost
High
Evidence
Best for in-document retrieval in one preprint
Main risk
Weaker for in-corpus retrieval
Contextual prefixes
Best fit
Chunks that lose meaning alone
Cost
One LLM call per chunk
Evidence
35% fewer failures (vendor test); modest gain in one small chunk-level check, plus one indirect document-level result
Main risk
Can hurt in-document retrieval
Late chunking
Best fit
Long documents, long-context embedder
Cost
Medium
Evidence
Authors' claim; one comparison study
Main risk
Authors report lower relevance and completeness
Six chunking approaches compared on fit, cost, evidence strength and main risk. Evidence cells say where the data is a vendor test, a vendor description or a single preprint; none is a general result. Late chunking figures are in the text.SourceSourceSourceSourceSourceSourceSource

Hybrid search: BM25 is the floor, not the enemy

The 2021 BEIR benchmark, covering 18 datasets and 10 retrieval systems, found BM25 "a robust baseline"; re-ranking and late-interaction models had the best average zero-shot performance at high computational cost, and dense and sparse models often underperformed [21]. Those are 2021 models, but a 2026 benchmark points the same way for numeric, table-heavy finance documents. On 23,088 finance queries, BM25 beat a strong dense model on Recall@5 (0.644 against 0.587), hybrid retrieval with reciprocal rank fusion reached 0.695, and adding a Cohere reranker reached 0.816 [17]. That is one preprint, one domain and whole documents of about 920 tokens, so treat it as a data point, not a law. Vendors agree on the mechanism: keyword search wins for product codes, jargon, dates and names because it finds exact matches [22].

Average zero-shot performance versus BM25 (BEIR Table 2, 2021 models)
Comparison
BM25 + cross-encoder re-ranking
Average nDCG@10 versus BM25
+11%
Model family
Lexical retrieval plus re-ranking
ColBERT
Average nDCG@10 versus BM25
+2.5%
Model family
Late interaction
TAS-B
Average nDCG@10 versus BM25
-2.8%
Model family
Dense
ANCE
Average nDCG@10 versus BM25
-7.4%
Model family
Dense
DeepCT
Average nDCG@10 versus BM25
-27.9%
Model family
Sparse
DPR
Average nDCG@10 versus BM25
-47.7%
Model family
Dense
Average performance relative to BM25 across the BEIR datasets, from BEIR Table 2, six of the nine non-BM25 systems, best first. Negative values mean the model scored below BM25 on average. All are 2021 models, so read this as the shape of the finding, not a current ranking.Source
Recall@5 on 23,088 finance queries (2026 preprint)
Chart
  • Dense
    0.59
  • BM25
    0.64
  • Hybrid (RRF)
    0.7
  • Contextual hybrid
    0.72
  • Hybrid + rerank
    0.82

Values in Recall@5.

Recall@5 by retrieval strategy on one finance benchmark of text-and-table documents, ordered by score. Dense is text-embedding-3-large; hybrid fuses BM25 and dense with RRF; the reranker is Cohere's. The reranked configuration is built on plain hybrid, not on contextual hybrid, and contextual hybrid has no rerank. One domain, one dense model, un-reviewed preprint: indicative, not general.Source

Embedding choice needs the same humility. MTEB found that no embedding method dominates across tasks [23]. BRIGHT showed the top MTEB model scoring 59.0 nDCG@10 on MTEB but 18.3 on its reasoning-heavy queries [24]. Use the leaderboard to shortlist, then decide on your own eval set.

For fusion, start with reciprocal rank fusion. It sums 1/(k + rank) across result lists; Cormack et al. fixed k at 60 in a pilot, found it near-optimal but not critical, and reported average gains of 4% to 5% over Condorcet, CombMNZ and the best single system [25]. Azure's documentation also uses a k of about 60 [26]. Weaviate moved its default to score-based fusion and advises setting alpha explicitly [27]. We found no independent comparison, so switch only if your eval set shows a gain.

Reranking and how much context to pass

Retrieval optimizes for recall; reranking optimizes for precision. Microsoft describes a common four-step pattern: retrieve broadly (for example the top 50), merge with RRF, rerank with a cross-encoder, semantic ranker or LLM, then truncate to the top 5 to 10, starting the candidate set at 20 to 50 [4]. A cross-encoder scores each query-document pair jointly, which is too slow for a whole corpus, hence the two stages [28].

The gains are the largest in our sources. Reranking lifted hybrid Recall@5 by 12.1 points and MRR@3 by 17.2 points in the finance benchmark [17]. In Anthropic's test, adding contextual BM25 and reranking cut failures from 5.7% to 1.9%, a 67% relative reduction, from 150 candidates reranked to a top 20; passing 20 chunks beat passing 10 or 5 [2]. LLM rerankers are a credible alternative: a distilled 440M model outperformed a 3B supervised model on BEIR [29]. We found no primary-source latency figures for rerankers, only the warning that reranking adds latency to every query [4]. Measure it.

Failed top-20 retrievals as Anthropic added techniques
Chart
  • Baseline: embeddings only (Gemini Text 004)
    5.7%
  • Contextual embeddings
    3.7%
  • Contextual embeddings + contextual BM25
    2.9%
  • Plus reranking (top 150 to top 20)
    1.9%
Share of queries where the relevant chunk was missing from the top 20 (1 minus recall@20), starting from the top single embedding configuration (Gemini Text 004), from Anthropic's own evaluation across codebases, fiction, ArXiv and science papers (dataset provenance not stated). Reductions: 35%, 49% and 67% relative to the 5.7% baseline. Not independently replicated.Source

Two rules prevent common mistakes. First, use reranker scores for ordering, not thresholds: "Cross-encoder scores are relative, not absolute" [4]. If you want abstention, calibrate a cutoff on positive and negative test queries. Second, more context is not free. Going from 20 to 50 documents improved accuracy by only about 1.5% for GPT-3.5-Turbo and about 1% for Claude-1.3 while cost rose [3]. Tune candidate depth (recall) and final context size (precision) as separate dials.

Query rewriting and agentic retrieval: gate by query type

Rewriting is not a free upgrade. HyDE has an LLM write a hypothetical answer and searches near its embedding; the authors concede the document "may contain false details" [30]. Rewrite-Retrieve-Read trains a small rewriter with reinforcement learning from reader feedback and shows gains, but against a web search engine, so transfer to private corpora is unshown [31]. Self-RAG and Corrective RAG make retrieval adaptive, deciding when to retrieve or scoring retrieved documents; both are research systems [32][33].

The counter-evidence matters. In the finance benchmark HyDE (0.544) scored below plain dense retrieval (0.587), and multi-query fusion (0.640) did not beat BM25 (0.644) [17]. Precise numeric lookups do not need paraphrase. Where rewriting helps is conversational, vague or reasoning-heavy input: BRIGHT reports up to 12.2 points from explicit reasoning about the query [24], and multi-turn questions are non-standalone by nature [8]. Microsoft says to keep the original query and add context rather than replace it [4].

Agentic retrieval plans and decomposes queries with an LLM, runs subqueries in parallel and reranks each. Azure's documentation says it adds latency, bills tokens from two services, and, on the page we read (2026-09-16), LLM query planning is in preview [34]. GraphRAG targets a narrow case, whole-corpus questions such as "What are the main themes in the dataset?" [35].

Query-side techniques: when each earns its cost
NKK framework
Query rewriting
Helps with
Vague or keyword-poor questions
Can hurt
Precise lookups and identifiers
Cost
One small LLM call
Evidence
Gains vs a web search engine; private corpora unshown
HyDE
Helps with
Short queries with no keyword overlap
Can hurt
Numeric or identifier lookups; invented details in the draft
Cost
One LLM call plus embedding
Evidence
Underperformed plain dense in a 2026 finance benchmark
Decomposition
Helps with
Multi-part questions
Can hurt
Simple lookups
Cost
Several searches
Evidence
Vendor guidance; no independent numbers found
Reasoning about the query
Helps with
Reasoning-intensive retrieval
Can hurt
Latency-sensitive paths
Cost
LLM tokens per query
Evidence
Up to 12.2 points on BRIGHT
Agentic retrieval
Helps with
Complex, multi-ask, context-dependent queries
Can hurt
Anything latency-bound
Cost
Latency plus tokens from two services
Evidence
Vendor documentation; planning in preview
GraphRAG
Helps with
Whole-corpus summary questions
Can hurt
Fact lookups
Cost
Graph build and community summaries
Evidence
Authors report gains on datasets near 1M tokens
Six query-side techniques compared on what they help, where they hurt, cost and evidence. NKK's rule: gate each by query type, keep the original query, and prove the gain on your eval set.SourceSourceSourceSourceSourceSourceSource

When not to build RAG at all

Li et al. compared RAG with long-context models across public datasets and three models: long context won on average when resources allowed, but RAG was much cheaper, and a router, Self-Route, let the model choose per query and cut compute while keeping comparable performance [36]. Anthropic notes that a knowledge base under about 200,000 tokens (roughly 500 pages) can skip RAG and sit in the prompt [2]. NKK would add prompt caching to the trial to control cost. Every study here uses 2023-2024 models, so treat the thresholds as starting points and re-test per model generation.

The NKK RAG Fit Matrix turns this into a placement exercise. The points are NKK's judgement, illustrative, not measurements.

NKK RAG Fit Matrix
NKK framework Illustrative
Large or fast-changingCorpus size and volatilitySmall and stable
Hybrid search plus reranker
Contextual or hierarchical RAG with agentic retrieval
Whole corpus in context, cached
Long context plus decomposition
Policy FAQ
Product catalogue lookup
Contract repository
Engineering wiki
Single-product handbook
Single lookupQuery complexityMulti-part or conversational
Hybrid search plus reranker
Large corpus, simple lookups. Hybrid retrieval, a reranker and metadata filters are the workhorse.
Contextual or hierarchical RAG with agentic retrieval
Large corpus, hard questions. Add chunk context, decomposition and gated agentic retrieval; budget for latency.
Whole corpus in context, cached
Small and stable, simple questions. Try putting everything in the prompt first.
Long context plus decomposition
Small corpus, hard questions. Hypothesis, untested: long context with a planning step before reaching for a retrieval stack.
NKK's qualitative placement of five example use cases by query complexity and corpus size and volatility; permissions are handled in the decision flow, not on this chart. Placement is judgement and illustrative; the 200,000-token threshold behind the bottom row comes from one vendor note.

Where it breaks: the axes are qualitative, and we found no independent numbers for the bottom-right quadrant. Permissions are deliberately off the chart, because they would push almost every enterprise corpus upward: if different users may see different content, long-context stuffing needs the same filtering as retrieval.

Security and permissions are retrieval-layer problems

OWASP's 2026 Top 10 for LLM applications (published 2026-08-03 [37]) gives vector and embedding weaknesses their own entry, LLM09:2026. The 2025 edition numbered it LLM08 [38], and the 2026 LLM08 is now Hidden Context Exposure, so check which edition a citation means. The 2026 entry names RAG-relevant risks: cross-tenant leakage when similarity search runs across the full index before access control is applied, embedding inversion, retrieval-time data poisoning, retrieval jamming and membership inference through raw similarity scores. Its mitigations include enforcing tenant scoping inside the index query rather than as a post-retrieval filter, applying access control at the chunk level, tracking provenance for every embedding, withholding raw similarity scores from clients and keeping immutable logs of retrieval activity [37]. Prompt injection is a separate risk: the 2026 entry lists retrieved RAG passages as a delivery surface for indirect injection [37], and the 2025 entry states that RAG and fine-tuning do not fully mitigate prompt injection [39]. The PDF we read, linked from the 2026 resource page, still shows "Publication date to be set" on its cover.

The threats are not hypothetical. EchoLeak, CVE-2025-32711 in Microsoft 365 Copilot, enabled remote, unauthenticated data exfiltration through a single crafted email [40]; the NVD record, which describes it as AI command injection in M365 Copilot allowing an unauthorized attacker to disclose information over a network and does not use the name EchoLeak itself, shows a 9.3 rating from Microsoft and 7.5 from NVD, and does not state a patch date [41]. PoisonedRAG reached about 90% attack success by injecting five malicious texts per target question in a research setting, and the authors found the defences they tried insufficient [42]. Vectors are not anonymous either: Vec2Text recovered 92% of 32-token inputs exactly from their embeddings [43].

Enforcement therefore belongs inside the search. Azure AI Search applies the caller's identity at query time, and its documentation warns that permission changes reach results only after metadata is synchronized to the index; with chunking, permission metadata must be projected onto each chunk row or chunk-level references are not filtered [44]. On the page we read (2026-08-08), only security filters were generally available; ACL, Purview and SharePoint enforcement were preview. Elastic's document-level security shows the pattern and its limit: aggregate information about the whole index can still leak through crafted requests [45]. One preprint argues that prompt sanitisation and output filtering are probabilistic, and that retrieved content must be authorized for every participant in the interaction, deterministically [46]. The authors say Microsoft deploys it, a vendor claim.

The NKK Fail-Closed Retrieval Stack turns this into five layers. Each names the threat it answers and needs its own test cases in the eval set.

NKK Fail-Closed Retrieval Stack
NKK framework
  1. Audit

    An immutable log of who asked, what was retrieved and which chunks reached the model. Without it you cannot investigate a leak.

    Detection
  2. Output controls

    Treat retrieved text as untrusted input. Label provenance, constrain output format and links, and require approval for high-risk actions.

    Prompt injection
  3. Query-time authorization

    Apply the caller's identity as a filter inside the search. If the filter cannot be evaluated, return an error, never partial or unfiltered results.

    Leakage
  4. Index schema

    Permission or label fields on every chunk, tenants partitioned, vectors protected like the source text they can be inverted into.

    Inversion, cross-tenant
  5. Ingestion

    Capture permissions from the source, set a freshness target for permission sync, and validate content for hidden or injected text.

    Poisoning, stale access
Five layers of a permission-aware retrieval system, from the audit log down to ingestion. Each layer is tagged with the threat it answers. It is an architecture checklist, not proof of safety.
Fail-closed readiness
NKK framework
0 of 5 answered
Query-time identity filter

Is the caller's identity applied inside the search?

Chunk-level permissions

Does every chunk carry its source permissions?

Sync latency

Do you know how long a revocation takes to reach the index?

Retrieval logging

Can you reconstruct who retrieved what?

Adversarial tests

Do injection and poisoned-document cases run in CI?

Answer all 5 dimensions to see your score and where to start.

Five questions on the permission-aware retrieval controls above. The lowest-scoring dimension is the first one to fix.

What the evidence does not show

A guide built on public sources has blind spots, and you should know them before you copy a number.

  • No large independent replication of contextual retrieval. The 35% to 67% figures (the upper figure includes reranking) come from one vendor's own evaluation, whose dataset provenance the page does not state [2]; the only independent chunk-level check we found is small and reports a modest gain [18], and one document-level result is indirect [17].
  • No independent comparison of RRF against score-based fusion, and none of prompted query rewriting on enterprise corpora.
  • No primary-source reranker latency or cost figures. Budget by measuring, not by quoting.
  • Dated models. The long-context, lost-in-the-middle and BEIR results use 2021-2024 models [3][36][21].
  • No adoption or failure-rate statistics. We found none from a source that meets our standard, so this guide makes no claim about how many RAG projects fail.
  • Thin security quantification. PoisonedRAG and Vec2Text numbers come from research settings [42][43], and the OWASP entries describe risks and mitigations, not how often they occur [37].

The decision flow

The NKK models fit together as follows. The Fit Matrix scopes the build, the Decision Flow sequences what to build, the Debug Ladder diagnoses what went wrong, the Debugging Table maps symptoms to ladder rungs, and the Fail-Closed Stack details flow step 1 and ladder rung 6. Run the seven flow steps in order; each defaults to the best-supported choice in the sections above.

NKK RAG decision flow
NKK framework
  1. Step 1: 1. Permissions

    Different users see different content? Design the identity filter and chunk-level permissions before anything else.

  2. Step 2: 2. Size and volatility

    Under roughly 200,000 tokens, stable and visible to every user? Try the whole corpus in cached context first. Otherwise continue.

  3. Step 3: 3. Content type

    Identifiers, numbers, product codes or jargon? Use hybrid BM25 plus dense with RRF; benchmark BM25 alone as the floor.

  4. Step 4: 4. Recall gap

    Right chunk in the top 50 but not the final prompt? Add a reranker and tune candidates (20-50) and final N (5-10).

  5. Step 5: 5. Context loss

    Chunks meaningless alone? Add headings, titles or contextual prefixes before paying for semantic chunking.

  6. Step 6: 6. Query shape

    Conversational, vague or multi-part queries? Add rewriting or decomposition, gated by query type, keeping the original query.

  7. Step 7: 7. Regression gate

    Re-run the eval set, including negative and permission cases, on every change. Ship only if no rung of the ladder regresses.

A seven-step decision sequence from corpus size to regression gate. Each step names the evidence-backed default and the cheapest next change.

Debugging table: symptom, rung, test, fix

Match the symptom to a rung of the Debug Ladder, run the test, and try the first fix before changing anything else.

RAG debugging table
NKK framework
Says it does not know, but the document exists
Likely rung
1 Corpus, or 2 Candidate recall
Test to run
Search the exact passage text; check it is indexed and current
First fix
Fix parsing or ingestion; add the missing source
Metric
Index coverage; recall@K
Misses answers that hinge on codes, names or numbers
Likely rung
2 Candidate recall
Test to run
Compare BM25 alone against dense on labelled queries
First fix
Add BM25 and fuse with RRF; confirm the query uses the same embedding model as the chunks
Metric
recall@K
Right chunk found in top 50 but absent from the final prompt
Likely rung
3 Rank and cut
Test to run
Measure recall before rerank and after truncation
First fix
Add a reranker; raise final N; do not threshold raw scores
Metric
MRR; recall@N
Right chunk is in the prompt, answer ignores it
Likely rung
4 Context use
Test to run
Check completeness against utilization; move the evidence to the start or end
First fix
If completeness is high and utilization low, cut top-k [5]; if both are low, add context within chunks or enlarge fixed-size chunks [5]; move the evidence to the start or end [3]
Metric
Completeness; utilization
Well grounded but wrong
Likely rung
1 Corpus (stale or conflicting sources), or 3 Rank and cut
Test to run
Look for conflicting or outdated chunks
First fix
Version and date metadata; remove superseded sources
Metric
Groundedness vs correctness
Wrong format, too vague or too narrow
Likely rung
5 Answer shape
Test to run
Inspect failures by format and specificity
First fix
Fix the prompt contract (NKK suggestion)
Metric
Correctness; completeness
Confident answer to an unanswerable question
Likely rung
3 or 5
Test to run
Run negative queries; metrics should be near 0
First fix
Add an abstention path; calibrate a score cutoff empirically
Metric
Negative-query score
Follow-up questions fail
Likely rung
2 Candidate recall
Test to run
Test non-standalone multi-turn questions
First fix
Rewrite with chat history, keeping the original query
Metric
Recall@K on conversations
A user sees content they should not
Likely rung
6 Authorization
Test to run
Per-user permission tests on every chunk
First fix
Move the filter inside the search; fail closed
Metric
Zero unauthorized chunks
Nine symptoms mapped to the Debug Ladder rung, the test that exposes them, the first fix to try and the metric to watch. Failure-point names come from Barnett et al.; fixes are NKK's suggested order, with the cited fixes marked.SourceSourceSourceSourceSource

What to do next

  1. Build the evaluation set first. Use the sizing rule and readiness scorecard above, and have an expert verify the expected answers.
  2. Baseline with BM25, then climb the decision flow. Record recall@K and MRR for keyword search alone, then add dense retrieval, RRF and a reranker one at a time, keeping the metric for each stage.
  3. Sweep chunk size and overlap in tokens. Treat vendor defaults as hypotheses, and add contextual prefixes before semantic or LLM-guided chunking.
  4. Gate query rewriting and agentic retrieval by query type. Keep the original query and measure latency and token cost.
  5. Move permissions into the search. Put permission fields on every chunk, filter at query time, fail closed, and measure sync lag.
  6. Make the eval set a regression gate. Run it on every model, prompt, index or chunking change, and use the debugging table to triage failures.

Conclusion

RAG quality is the product of stages, so fix the earliest broken one. Hybrid retrieval, a reranker and an honest evaluation set have the best support in the evidence we read; much of the rest, from chunk size to query rewriting, is hypothesis to test on your own corpus. Authorization is the stage you cannot afford to find in production.

References

Every figure and regulatory statement in this piece traces to a numbered source below. Links open the original publisher in a new tab.

  1. Reference 1: Seven Failure Points When Engineering a Retrieval Augmented Generation System(opens in a new tab)
    arXiv (Barnett et al.)Published 11 Jan 2024Accessed 13 Oct 2026Tier 1: Primary source
  2. Reference 2: Introducing Contextual Retrieval(opens in a new tab)
    AnthropicPublished 19 Sept 2024Accessed 14 Oct 2026Tier 2: Research / official docs
  3. Reference 3: Lost in the Middle: How Language Models Use Long Contexts(opens in a new tab)
    Transactions of the Association for Computational Linguistics (TACL) 12, 2024 / arXivPublished 6 Jul 2023Accessed 13 Oct 2026Tier 1: Primary source
  4. Reference 4: Develop a RAG Solution on Azure - Information-Retrieval Phase(opens in a new tab)
    Microsoft Learn (Azure Architecture Center)Published 22 Jun 2026Accessed 14 Oct 2026Tier 2: Research / official docs
  5. Reference 5: Develop a RAG Solution on Azure - Large Language Model End-to-End Evaluation Phase(opens in a new tab)
    Microsoft Learn (Azure Architecture Center)Published 10 Oct 2025Accessed 14 Oct 2026Tier 2: Research / official docs
  6. Reference 6: Develop a RAG Solution on Azure - Preparation Phase(opens in a new tab)
    Microsoft Learn (Azure Architecture Center)Published 10 Oct 2025Accessed 14 Oct 2026Tier 2: Research / official docs
  7. Reference 7: Benchmarking Large Language Models in Retrieval-Augmented Generation(opens in a new tab)
    AAAI 2024 / arXivPublished 4 Sept 2023Accessed 13 Oct 2026Tier 1: Primary source
  8. Reference 8: SemEval-2026 Task 8: MTRAGEval: Evaluating Multi-Turn RAG Conversations(opens in a new tab)
    SemEval-2026, ACL AnthologyPublished Jul 2026Accessed 13 Oct 2026Tier 1: Primary source
  9. Reference 9: Ragas: Automated Evaluation of Retrieval Augmented Generation(opens in a new tab)
    arXiv (Es, James, Espinosa-Anke, Schockaert)Published 26 Sept 2023Accessed 13 Oct 2026Tier 1: Primary source
  10. Reference 10: ARES: An Automated Evaluation Framework for Retrieval-Augmented Generation Systems(opens in a new tab)
    NAACL 2024 / arXivPublished 16 Nov 2023Accessed 13 Oct 2026Tier 1: Primary source
  11. Reference 11: Develop a RAG Solution on Azure - Chunking Phase(opens in a new tab)
    Microsoft Learn (Azure Architecture Center)Published 27 May 2026Accessed 14 Oct 2026Tier 2: Research / official docs
  12. Reference 12: File search / Retrieval guide (OpenAI API documentation)(opens in a new tab)
    OpenAI API documentationPublished n.d.Accessed 13 Oct 2026Tier 2: Research / official docs
  13. Reference 13: How content chunking works for knowledge bases(opens in a new tab)
    Amazon Web Services (Amazon Bedrock User Guide)Published n.d.Accessed 14 Oct 2026Tier 2: Research / official docs
  14. Reference 14: Evaluating Chunking Strategies for Retrieval(opens in a new tab)
    Chroma technical reportPublished 3 Jul 2024Accessed 14 Oct 2026Tier 2: Research / official docs
  15. Reference 15: Is Semantic Chunking Worth the Computational Cost?(opens in a new tab)
    Findings of NAACL 2025 (Qu, Tu, Bao)Published Oct 2024Accessed 13 Oct 2026Tier 1: Primary source
  16. Reference 16: Beyond Chunk-Then-Embed: A Comprehensive Taxonomy and Evaluation of Document Chunking Strategies for Information Retrieval(opens in a new tab)
    arXiv preprint (Zhou, Wang, Koopman, Zuccon)Published 19 Feb 2026Accessed 14 Oct 2026Tier 2: Research / official docs
  17. Reference 17: From BM25 to Corrective RAG: Benchmarking Retrieval Strategies for Text-and-Table Documents(opens in a new tab)
    arXiv preprint (Akarsu, Karaman, Mierbach)Published 2 Apr 2026Accessed 13 Oct 2026Tier 2: Research / official docs
  18. Reference 18: Reconstructing Context: Evaluating Advanced Chunking Strategies for Retrieval-Augmented Generation(opens in a new tab)
    arXiv / ECIR 2025 workshop (Merola, Singh)Published 28 Apr 2025Accessed 14 Oct 2026Tier 2: Research / official docs
  19. Reference 19: Late Chunking: Contextual Chunk Embeddings Using Long-Context Embedding Models(opens in a new tab)
    arXiv (Gunther et al.)Published 7 Sept 2024Accessed 13 Oct 2026Tier 2: Research / official docs
  20. Reference 20: ColPali: Efficient Document Retrieval with Vision Language Models(opens in a new tab)
    ICLR 2025 / arXivPublished 27 Jun 2024Accessed 13 Oct 2026Tier 1: Primary source
  21. Reference 21: BEIR: A Heterogenous Benchmark for Zero-shot Evaluation of Information Retrieval Models(opens in a new tab)
    NeurIPS 2021 Datasets and Benchmarks / arXivPublished 17 Apr 2021Accessed 14 Oct 2026Tier 1: Primary source
  22. Reference 22: Hybrid search overview - Azure AI Search(opens in a new tab)
    Microsoft Learn (Azure AI Search)Published 31 Aug 2026Accessed 13 Oct 2026Tier 2: Research / official docs
  23. Reference 23: MTEB: Massive Text Embedding Benchmark(opens in a new tab)
    arXiv (Muennighoff et al.)Published 13 Oct 2022Accessed 13 Oct 2026Tier 1: Primary source
  24. Reference 24: BRIGHT: A Realistic and Challenging Benchmark for Reasoning-Intensive Retrieval(opens in a new tab)
    arXiv (Su et al.)Published 16 Jul 2024Accessed 13 Oct 2026Tier 1: Primary source
  25. Reference 25: Reciprocal Rank Fusion outperforms Condorcet and individual Rank Learning Methods(opens in a new tab)
    SIGIR 2009, ACM (Cormack, Clarke, Buttcher)Published Jul 2009Accessed 13 Oct 2026Tier 1: Primary source
  26. Reference 26: Hybrid search scoring (RRF) - Azure AI Search(opens in a new tab)
    Microsoft Learn (Azure AI Search)Published 8 Jun 2026Accessed 13 Oct 2026Tier 2: Research / official docs
  27. Reference 27: Hybrid search (concepts)(opens in a new tab)
    Weaviate documentationPublished n.d.Accessed 13 Oct 2026Tier 2: Research / official docs
  28. Reference 28: Retrieve & Re-Rank(opens in a new tab)
    Sentence Transformers documentationPublished n.d.Accessed 13 Oct 2026Tier 2: Research / official docs
  29. Reference 29: Is ChatGPT Good at Search? Investigating Large Language Models as Re-Ranking Agents(opens in a new tab)
    EMNLP 2023 / arXivPublished 19 Apr 2023Accessed 13 Oct 2026Tier 1: Primary source
  30. Reference 30: Precise Zero-Shot Dense Retrieval without Relevance Labels(opens in a new tab)
    arXiv (Gao, Ma, Lin, Callan)Published 20 Dec 2022Accessed 13 Oct 2026Tier 1: Primary source
  31. Reference 31: Query Rewriting for Retrieval-Augmented Large Language Models(opens in a new tab)
    EMNLP 2023 / arXivPublished 23 May 2023Accessed 13 Oct 2026Tier 1: Primary source
  32. Reference 32: Self-RAG: Learning to Retrieve, Generate, and Critique through Self-Reflection(opens in a new tab)
    arXiv (Asai et al.)Published 17 Oct 2023Accessed 13 Oct 2026Tier 1: Primary source
  33. Reference 33: Corrective Retrieval Augmented Generation(opens in a new tab)
    arXiv (Yan et al.)Published 29 Jan 2024Accessed 13 Oct 2026Tier 1: Primary source
  34. Reference 34: Agentic retrieval overview - Azure AI Search(opens in a new tab)
    Microsoft Learn (Azure AI Search)Published 16 Sept 2026Accessed 13 Oct 2026Tier 2: Research / official docs
  35. Reference 35: From Local to Global: A Graph RAG Approach to Query-Focused Summarization(opens in a new tab)
    arXiv (Edge et al.)Published 24 Apr 2024Accessed 13 Oct 2026Tier 1: Primary source
  36. Reference 36: Retrieval Augmented Generation or Long-Context LLMs? A Comprehensive Study and Hybrid Approach(opens in a new tab)
    EMNLP 2024 industry track / arXivPublished 23 Jul 2024Accessed 13 Oct 2026Tier 1: Primary source
  37. Reference 37: OWASP Top 10 for LLM Applications 2026(opens in a new tab)
    OWASP Gen AI Security Project (resource page and linked 2026 PDF; the PDF cover reads 'Publication date to be set')Published 3 Aug 2026Accessed 14 Oct 2026Tier 1: Primary source
  38. Reference 38: LLM08:2025 Vector and Embedding Weaknesses(opens in a new tab)
    OWASP Gen AI Security Project (2025 edition)Published 2025Accessed 13 Oct 2026Tier 1: Primary source
  39. Reference 39: LLM01:2025 Prompt Injection(opens in a new tab)
    OWASP Gen AI Security Project (2025 edition)Published 2025Accessed 13 Oct 2026Tier 1: Primary source
  40. Reference 40: EchoLeak: The First Real-World Zero-Click Prompt Injection Exploit in a Production LLM System(opens in a new tab)
    AAAI Fall Symposium Series 2025 / arXivPublished 6 Sept 2025Accessed 14 Oct 2026Tier 1: Primary source
  41. Reference 41: CVE-2025-32711 Detail(opens in a new tab)
    NIST National Vulnerability DatabasePublished 11 Jun 2025Accessed 14 Oct 2026Tier 1: Primary source
  42. Reference 42: PoisonedRAG: Knowledge Corruption Attacks to Retrieval-Augmented Generation of Large Language Models(opens in a new tab)
    USENIX Security 2025 / arXivPublished 12 Feb 2024Accessed 13 Oct 2026Tier 1: Primary source
  43. Reference 43: Text Embeddings Reveal (Almost) As Much As Text(opens in a new tab)
    EMNLP 2023 / arXivPublished 10 Oct 2023Accessed 13 Oct 2026Tier 1: Primary source
  44. Reference 44: Document-level access control - Azure AI Search(opens in a new tab)
    Microsoft Learn (Azure AI Search)Published 8 Aug 2026Accessed 13 Oct 2026Tier 2: Research / official docs
  45. Reference 45: Controlling access at the document and field level(opens in a new tab)
    Elastic documentationPublished n.d.Accessed 14 Oct 2026Tier 2: Research / official docs
  46. Reference 46: Enterprise AI Must Enforce Participant-Aware Access Control(opens in a new tab)
    arXiv preprint (Bhatt et al.)Published 18 Sept 2025Accessed 13 Oct 2026Tier 2: Research / official docs
WhitepaperData and Knowledge Foundations for Production AI
Whitepaper PDFKnowledge Platforms

Data and Knowledge Foundations for Production AI

NKK argues that much of RAG's headroom sits upstream of the model; no public source sizes the share. Four principal NKK models for readiness, pattern choice, trust and failure triage, built on cited evidence.

34 min read
Blog
BlogAgentic AI

Context Engineering: What Prompt Engineering Becomes

A bigger window did not solve the problem. Why context is a budget, what the evidence shows and does not, and NKK's layer stack and triage matrix, with a ledger and scorecard to apply them.

14 min read
Blog
BlogAgentic AI

Evaluating and Observing AI Agents in Production

A benchmark pass, a judge score and a green dashboard are different instruments with documented gaps. Here is what the evidence shows and a layered NKK model for evaluating agents in production.

14 min read