Why can one relevant article be insufficient?
A legal search can find the general rule and still miss the special rule that changes which evidence matters.
Which Spanish VAT sources should I check for an engineering service tied to a building in Spain?
In Jurisdictions, we test retrieval of Article 69, which contains general place-of-supply rules for services, and Article 70, which covers special rules. Article 69 points to Article 70, whose first special rule covers services connected with immovable property. The two checks use separate Spanish queries and require the expected article in the top eight results, scoped to Spain’s Boletín Oficial del Estado (BOE). BOE Article 69. BOE Article 70.
The question above combines those test scenarios into one walkthrough. It asks what to retrieve. Applying a provision to a transaction requires checking the facts and the version of the law in force. The diagram illustrates how parallel searches can feed an evidence check. LangGraph parallel workflow pattern. LangGraph retrieval workflow.
Where did a keyword baseline fail?
It missed a paraphrase, cited a superseded policy, and gave an incomplete answer despite retrieving both relevant sources.
In our 24-question evaluation of retrieval-augmented generation (RAG), the keyword retriever found all the expected sources in the top three for 16 of 17 answerable questions. The answer and citations each passed on 14 of 17. In the renewal case, the system found both the deadline and the ticket instructions, then quoted only the deadline. See the two-source failure.
The benchmark publishes its scoring rules and the outcome for every question. Read the scoring rules. Inspect the case-level results.
The Python examples use hand-built inputs based on the Jurisdictions walkthrough. Run them together with python3 rag-retrieval-examples.py. See the benchmark failures.
How does text become searchable?
An embedding model represents passages and questions as lists of numbers so search can match related wording.
When indexing, the system splits documents into passages and stores each vector with a source ID. At search time it encodes the question into the same vector space and compares it with passages the reader can access. That lets the phrase “service tied to a building” surface passages about services connected with immovable property. Sentence-BERT paper. Semantic search reference.
When does hybrid RAG help?
Hybrid RAG combines keyword and semantic search so it can find exact identifiers and match differently worded questions.
Exact searches can match “Article 69,” while semantic search can surface wording about property services. Reciprocal rank fusion gives a source credit for its position in each list. In these hand-built rankings, Article 70 comes first because both searches found it. A reranker can then score how closely candidates match the question. Original reciprocal rank fusion paper. See the missed paraphrase.
from collections import defaultdict
def fuse_ranks(keyword, semantic, k=60):
scores = defaultdict(float)
for ranking in (keyword, semantic):
for rank, doc_id in enumerate(ranking, start=1):
scores[doc_id] += 1 / (k + rank)
return sorted(scores, key=lambda doc_id: (-scores[doc_id], doc_id))
keyword = ["LIVA-69", "LIVA-70"]
semantic = ["LIVA-70", "property-services-guide"]
print(fuse_ranks(keyword, semantic))
When do filters and a graph help?
Use metadata filters for effective dates and permissions. Use a graph for questions that depend on relationships between records.
Filter for the right jurisdiction, authority and legal version before using the evidence. The Python example follows the place-of-supply topic to Article 69 and then uses its link to find Article 70. Graph retrieval connects sources, while the workflow diagram above connects processing steps. See the outdated-policy failure. How GraphRAG uses relationships and source text.
visible_edges = [
("place-of-supply", "general_rule", "LIVA-69"),
("LIVA-69", "subject_to", "LIVA-70"),
]
def neighbors(node, relation):
return [
target
for source, edge, target in visible_edges
if source == node and edge == relation
]
for general_rule in neighbors("place-of-supply", "general_rule"):
for special_rule in neighbors(general_rule, "subject_to"):
print(general_rule, special_rule)
When should an agent search again?
An agent can help when the first source reveals what to look for next.
If a query first surfaces the general rule, the next lookup may need to target the special rule. This fixed Python workflow reads one additional source when the question calls for it and returns None if the required source is unavailable. An agent becomes useful when it must choose among different follow-up searches based on what the retrieved evidence reveals.
def collect_sources(first, read_allowed):
required_id = first.get("required_provision")
if required_id is None:
return (first["id"],)
follow_up = read_allowed(required_id)
if follow_up is None:
return None
return first["id"], follow_up["id"]
general = {"id": "LIVA-69", "required_provision": "LIVA-70"}
sources = {"LIVA-70": {"id": "LIVA-70"}}
print(collect_sources(general, sources.get))
print(collect_sources(general, {}.get))
Leonardo Burbano suggests starting with hybrid search and a reranker, then using an agent when one pass falls short. The study he cites recorded an average of 3.6× as many input tokens for agentic retrieval across the tested models on one dataset. Output tokens and latency had separate ratios. Burbano’s post. Ferrazzi et al., Table 9.
How would we choose a method?
Test each method on the same questions, model, and permission rules. Measure answer quality, citations, abstention, latency, and cost.
Start with a single-pass answer that can cite multiple sources. Add graph retrieval or an agent one at a time so you can see which change fixes which failures. Include questions about exact IDs, revised policies, cross-document relationships, and evidence that is missing or restricted. The scores available today are for the keyword baseline. Rerun the synthetic benchmark.
For an internal assistant, the starting point is a set of questions your teams actually ask, with known answers and permission rules. Explore Company Brain.