Reading tools and contents
Production RAG & GraphRAG

Chapter 6 of 10

Global search and map-reduce synthesis

Corpus-wide reasoning

About 4 minutes · includes examples, an exercise, and references

Chapter at a glance

  • Map partial findings into a typed evidence-bearing schema before reduction.
  • Weight distinct primary evidence rather than repeated generated summaries.
  • Use hierarchy as an evaluated coverage-cost control.

Global search addresses questions whose answer is distributed across a corpus rather than centered on one entity. Examples include recurring operational risks, dominant stakeholder concerns, and differences among program areas. Retrieving the top few passages by semantic similarity can overrepresent common wording and miss diverse evidence. GraphRAG uses hierarchical community reports as a corpus map and applies a map-reduce procedure to synthesize across relevant regions.

The map stage sends the query and one or more authorized community reports to a model. Each mapper returns a typed partial result: candidate findings, support references, relevance, uncertainty, and optionally a no-evidence decision. Mappers should not see hidden communities or unrestricted reports. Their output schema must reject unreferenced findings and cap result count so verbosity does not become ranking weight.

The reduce stage combines partials under a second budget. It clusters duplicates, preserves disagreements, weighs evidence quality and diversity, and produces a supported response. Reduction is not a vote among fluent summaries. Several reports may repeat one upstream source, so count distinct evidence and source domains. A minority finding with strong direct evidence may be more important than a repeated generated phrase.

Hierarchy provides a cost-quality control. Coarse reports cover more of the corpus cheaply but blur detail. Fine reports preserve specifics but increase calls and redundancy. One plan starts at a coarse level, scores relevance and uncertainty, then descends into selected child communities. Another maps a fixed level chosen from offline evaluation. Record which reports were skipped; an answer’s coverage claim is meaningful only relative to examined scope.

Context window and call budgets can bias results. Processing the first communities until tokens run out privileges arbitrary ordering. Allocate budgets across partitions, rank within security scope, and reserve capacity for diversity. Parallel mapping lowers latency but requires deterministic identifiers and stable reduction inputs. Retries should not double-count a partial result.

Community reports are orientation, not final proof. For high-consequence findings, dereference report citations to claims and source units, retrieve representative primary spans, and verify that the synthesis does not strengthen modality or erase exceptions. This drill-down can occur during reduction or as a post-generation support pass. The answer should cite original units wherever practical and identify when a statement rests only on a generated report.

Contradictions are first-class results. If communities report opposing trends, preserve both with scope, time, and evidence rather than forcing one average story. Global queries often hide sampling differences: business units may use different reporting templates or have unequal source coverage. A synthesis should distinguish absence of a theme from lack of indexed evidence.

Evaluation needs reference sets that reward coverage and support, not exact wording. Label expected themes, critical minority findings, forbidden claims, and evidence groups. Measure theme recall, evidence precision, source diversity, contradiction preservation, citation correctness, and abstention. Compare against stratified lexical and dense retrieval, random or metadata-based sampling, and a no-graph hierarchical summarizer. Evaluate by corpus size and query class.

Global search is especially exposed to poisoning. A repeated planted narrative can influence many extracted edges, reports, and mappers. Deduplicate near-identical sources, cap contribution by source domain, flag coordinated novelty, and verify influential findings against trusted primary material. Prompt injection inside a community report is still untrusted content and cannot change reducer policy.

The result should include a coverage envelope: corpus and index release, authorization scope, community level, reports considered, reports mapped, source units verified, time window, and known gaps. Global synthesis becomes trustworthy when it is explicit about what “across the corpus” actually meant.

Key points

  • Map partial findings into a typed evidence-bearing schema before reduction.
  • Weight distinct primary evidence rather than repeated generated summaries.
  • Use hierarchy as an evaluated coverage-cost control.
  • Report the examined corpus, community level, security scope, and known gaps.

Map output contract

Read the expected behavior in the surrounding walkthrough, then copy and run this reference implementation.

Map output contractjson
{
  "communityReportId": "release-18:level-1:community-42",
  "relevance": 0.86,
  "findings": [
    {
      "statement": "Capacity planning recurs as a deployment risk.",
      "evidenceClaimIds": ["claim-19", "claim-203"],
      "sourceUnitIds": ["unit-8", "unit-77"],
      "confidence": "supported",
      "qualifiers": ["engineering division", "2024-2025"]
    }
  ],
  "noEvidence": false
}

Worked examples

Toy

Minority theme retained

Four communities mention cost; one mentions a severe safety exception with direct evidence.

The reducer does not rank only by frequency. It retains the safety finding because consequence and evidence strength are part of the rubric.

  • Distinct evidence
  • Minority importance
  • Reducer rule

System

Hierarchical enterprise synthesis

A query spans hundreds of communities across several access domains.

Run maps only over reports in the user’s authorized projection, descend into relevant children, verify top findings against source units, and return coverage by division without revealing excluded community counts.

  • Authorization before mapping
  • Adaptive descent
  • Coverage envelope

Exercise

Build a global-search reducer

Answer a corpus-wide question from at least six structured community reports.

  1. Define mapper and reducer schemas.
  2. Preserve contradictory and minority findings.
  3. Verify selected findings against primary units.
  4. Compare with a non-graph retrieval baseline.

Success criteria

  • Every final finding traces to distinct source evidence.
  • Budget allocation does not depend on input order.
  • The answer states its coverage boundary.
  • Poisoned repetition cannot dominate solely through frequency.

Reflect: Which reducer choice quietly changed a corpus description into a stronger generalization than the evidence allowed?

References and further reading