Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 8.5 — When Sources Disagree
RAG and Vector Search · Example 1 of 1

Labelling old and new versions in the prompt

The answer is scripted: a real model follows the prompt's rule only most of the time, so check that the current source is cited.

Real handbooks hold old and new versions of the same page, and near-duplicate passages score almost the same. Dates, status and authority must travel with each passage into the prompt, and a genuine conflict is shown, not hidden.

Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.

Ready for more? This phase has 5 hands-on exercises with automatic checks.

Practice questions

Write the code in the editor, run it, then open the model answer to compare.

01

Write label(hits) where hits is a list of (doc_id, topic, date) and the result is a list of (doc_id, status): current for the newest date per topic, superseded for the rest. Print the result for D16 (monthly-pass, 2024-03-01), D8 (monthly-pass, 2025-06-01), D1 (refunds, 2025-01-10).

02

Write has_tie(hits) returning True when two hits of the same topic have the same newest date. Print the result for the hits above, and for the same hits with D16's date changed to 2025-06-01.

Explain it without notes

01

Why can an old version of a page outrank the current one in retrieval?

02

What must the prompt contain for the model to handle versions correctly?

03

Name three ways to handle superseded documents and when to use each.

04

What should the system do when two current documents disagree?

Labelling old and new versions in the prompt
Sign in to run this example in your browser.

Expected output

topics with more than one version: monthly-pass
[1] Monthly pass (2024 price list) (effective 2024-03-01, superseded)
    The monthly pass costs 20 dollars and includes unlimited rides of up to 30 minutes.
[2] Monthly pass (effective 2025-06-01, current)
    The monthly pass costs 25 dollars and includes unlimited rides of up to 45 minutes.
[3] Refunds (effective 2025-01-10, current)
    A ride cancelled at least 2 hours before its start time is refunded in full. Later cancellations get ride credit instead.
answer: The monthly pass costs 25 dollars and includes unlimited rides of up to 45 minutes. [2] An older version [1] from 2024-03-01 said: the pass costs 20 dollars and includes unlimited rides of up to 30 minutes
drop-the-old-ones option keeps: D8, D1