The Lawfare Academy

Lawfare Group → Knowledge Institute → Lawfare Academy

← AI 320 — Applied AI, Retrieval and Reliable Automation

Weeks 6–8

Retrieval, chunking and evidence provenance

Learning objectives

  • Explain and trace the mechanisms in retrieval, chunking and evidence provenance.
  • Apply the method to the worked example and changed-condition exercise.
  • Identify assumptions, failure cases and the evidence needed to justify a result.

Retrieval selects material relevant to a question. Keyword methods match terms; embedding methods compare learned representations. Semantic similarity is not the same as factual support. A passage can be topically similar while answering a different question, applying to another jurisdiction or being superseded by a later version.

Chunking divides documents into retrieval units. Very small chunks can lose context; very large chunks can dilute relevant details and exceed useful context budgets. Preserve document ID, title, date, version, location and access restrictions with each chunk. Retrieval must respect authorization before content enters the model context; hiding a confidential citation after generation does not undo disclosure.

Measure retrieval separately from answer generation. If the relevant passage is absent, improving the prompt cannot recover missing evidence reliably. Create questions with known supporting passages and assess whether the retriever returns them. Then check whether the answer uses the evidence correctly. A similarity threshold is a heuristic, not a calibrated probability that the answer is true. Version filters, exact identifiers and source-aware reranking may matter more than using a larger model.

Worked reasoning This transparent lexical baseline counts distinct shared tokens. It has no synonym handling, weighting, phrase model or authorization filter. It can retrieve a passage containing the words refund and policy even when it describes an exception rather than the general rule. Its simplicity makes failure diagnosis easier before a more complex retriever is introduced.

Extended teaching and laboratory

Retrieval ranks candidate evidence; it does not decide what the evidence means. Chunk size can separate a rule from its exception, while keyword overlap can rank a negated or outdated statement highly. Evaluate retrieval on whether required evidence is present, and evaluate answering on whether the conclusion follows from that evidence.

Authorization should restrict the candidate corpus before inaccessible passages can influence the answer. Filtering only the displayed citation can still leak private information through generated text. Record stable source IDs, versions and passage locations for reconstruction.

Worked problem A policy chunk says returns are accepted within 30 days. The following chunk excludes custom orders. A custom-order question retrieves only the first chunk. Explain the failure and repair.

Step-by-step reasoning 1. The retrieved general rule omits an applicable exception. The answer cannot safely infer universal eligibility.

  1. Preserve section context or retrieve neighboring exception-bearing passages, then evaluate the complete rule for the actual order type.
  1. Create an evaluation case requiring both chunks and score evidence sufficiency separately from fluent answer quality.
  1. Restrict retrieval to the requester’s authorized documents first. A correct answer based on private unauthorized text is still a boundary failure.

Apply the idea

A policy chunk says returns are accepted within 30 days. The following chunk excludes custom orders. A custom-order question retrieves only the first chunk. Explain the failure and repair.

Two authorized passages of the same version conflict about the deadline. What should an evidence-bounded assistant do?

Read the worked reasoning

Identify and cite the conflict, avoid selecting a convenient deadline without a justified precedence rule, and route to clarification or review. Capture both locators in the result. A retrieval score is not an authority hierarchy, so the top-ranked passage does not automatically resolve contradictory policy.

Check understanding

Why must access filtering occur before model context construction?

  1. Because exposing a restricted passage to generation already crosses the boundary
    Feedback

    Authorization governs the data the system may use, not just displayed links.

  2. Because hiding the link afterward always removes the disclosure
    Feedback

    Generated text can reveal content even without its citation.

  3. Because semantic ranking itself grants permission
    Feedback

    Similarity and access rights are unrelated properties.

Further reading

Study the complete on-site source sections below, then work the original example, changed-condition problem and transfer laboratory. Study CS50 AI information retrieval material within Language; compare retrieval with the search and probability foundations. Use a small versioned fictional document collection.

My learning →