Retrieval and RAG · Principal
How do you retrieve a contract clause and the exception that changes it?
The question
Interview question
A user asks whether a customer may terminate a service without a fee. The answer needs a clause in the original contract and a later exception notice. The notice is less semantically similar to the question than an obsolete contract copy. Design retrieval and answer construction. What if the user can read the clause but not the notice?
Take a few minutes to form your approach. Then open a worked answer and compare the decisions.
Reveal a worked answer
I would make this a two-evidence problem before choosing a retriever. The base clause says when the fee applies. The notice may change it for a customer, product, region, or effective interval. Finding the most similar paragraph is not enough. We need to know whether a later valid record modifies that clause for this particular request.
Take a concrete example. Clause 12 of contract C41 charges an exit fee. An amendment named “Service Transition Exception” waives it for the customer's West region accounts between 1 August and 31 October. The user asks about a West region account ending on 15 September. A vector search for “termination fee” will probably find Clause 12. It might never find the amendment because the wording does not use the user's phrase.
I would first resolve the entities: customer, contract ID, account, region, product, and date of the proposed action. Some will be in the question. Others must come from an authorized account lookup or a clarifying question. Then retrieve the base contract using exact identifiers and lexical plus semantic search. From that contract identity, follow explicit amendment or exception references and search notices by contract ID, customer, affected clause, effective dates, and status. The second search is conditioned on the first document, not just a second independent top-k call with the original query.
The join has to be semantic and governed. Does the notice really amend Clause 12? Was it approved? Was it superseded? Is the customer's account in the exception's scope? A later date in a title does not by itself override a signed clause. If the metadata is incomplete, include both source excerpts in a review path and avoid asserting a waiver until the relationship is verified.
Only after that would I build the answer. It might say: “Clause 12 normally charges the fee. The approved exception for C41 waives it for West region accounts during this interval. This account and date meet those conditions.” Cite the clause, notice, and the account fact separately. If the account lookup is sensitive, do not leak that detail in a citation visible to a different principal. A sentence supported by two documents should not cite just the easier one.
When the interviewer points out that the exception ranks at 60, I would not solve the problem by putting 60 chunks into context. The query plan should fetch amendments through exact relationship fields or a targeted follow-up query. If no relationship is stored, discover it at ingestion from references like contract number and affected clause, keep the extracted link with provenance and confidence, and validate the high-impact exceptions. A relation discovered by a model is a candidate, not legal authority. This is a general multi-hop retrieval pattern: one source gives you the handle needed to find the second. The HotpotQA paper demonstrates why questions can require supporting facts from more than one document, although this contract workflow has its own authority rules.
For evaluation, I would measure whether the required set of evidence was retrieved and passed to the answerer. Recall of the clause alone is a miss for this question even if it is ranked first. Add cases where the exception is irrelevant by date, applies to another customer, was withdrawn, or conflicts with a newer notice. Score final claims against both supporting spans and the scope fields. An answer that cites the right two titles but gets the effective interval wrong has failed.
Now the harder follow-up: the principal can read the clause but not the notice. We cannot pass the notice text to the model, quote it, or hint that a hidden exception exists if the product's access policy treats its existence as private. But blindly answering “yes, there is a fee” from the visible clause could be materially wrong. The safe product behavior is a scoped answer such as “The contract clause available to you states a fee. I cannot confirm whether there are other applicable changes,” or a handoff to an authorized reviewer. The exact wording depends on whether the existence of restricted amendments may be disclosed. Authorization changes what can be answered, not only what can be cited.
If the interviewer insists on a definitive yes or no, I would push back on the product contract. There is no sound way to make an unconditional claim when an applicable, authoritative document is both necessary and unavailable to this principal. We can change the workflow so a permitted service or reviewer makes the decision and returns an authorized result. We cannot make the missing evidence disappear by raising top-k.
Read beyond the question
Explore more retrieval and rag
Follow another question in this area, or return to the full Interview Prep index.
Browse this area →