Inferensys

Glossary

Query Expansion

A technique that augments a user's original search query with related terms or synonyms to improve recall, often using legal thesauri or generated text to capture broader relevant documents.
Stylish WeWork-like workspace with hot desks and document wall, professional searching through enterprise knowledge base on a mounted ultrawide display, warm industrial pendants overhead.
INFORMATION RETRIEVAL TECHNIQUE

What is Query Expansion?

Query expansion is a technique that augments a user's original search query with related terms or synonyms to improve recall, often using legal thesauri or generated text to capture broader relevant documents.

Query expansion is an information retrieval technique that reformulates a seed query by adding semantically related terms, synonyms, or morphological variants to bridge the vocabulary gap between user intent and document indexing. In legal search, this process often leverages domain-specific resources like the West Key Number System or generated text from a language model to capture conceptually relevant documents that lack exact keyword overlap.

The mechanism typically operates through automatic local analysis—deriving expansion terms from top-ranked documents in an initial retrieval pass—or global analysis using pre-built legal thesauri and ontologies. When integrated with dense retrieval and hybrid search pipelines, query expansion mitigates the brittleness of sparse lexical matching, ensuring that a search for "slip and fall" also retrieves documents referencing "premises liability" or "trip hazard."

IMPROVING RECALL

Key Techniques for Legal Query Expansion

Query expansion augments a user's original search with related terms to bridge the vocabulary gap between lay queries and precise legal terminology, dramatically improving recall in dense document collections.

01

Synonym Expansion via Legal Thesauri

Leverages curated legal dictionaries and thesauri to map user terms to canonical legal concepts.

  • Mechanism: A lookup table maps 'car accident' to 'motor vehicle collision' and 'automobile tort'
  • Source: Resources like the Legal Thesaurus or Westlaw's Key Number System
  • Strength: High precision; terms are vetted legal synonyms
  • Limitation: Static lists cannot capture novel or slang terms
  • Example: Expanding 'slip and fall' to 'premises liability' and 'tortious negligence'
+35%
Typical Recall Gain
02

Generated Query Expansion with LLMs

Uses a language model to generate hypothetical legal questions or keywords that a relevant document would answer.

  • Mechanism: Prompt an LLM to produce n variations of the query in formal legal language
  • Technique: Often paired with HyDE (Hypothetical Document Embeddings) to generate a synthetic answer, then embed that answer for retrieval
  • Strength: Captures conceptual relationships beyond simple synonyms
  • Risk: Can introduce hallucinated legal concepts if not grounded
  • Example: User query 'boss didn't pay overtime' generates 'Fair Labor Standards Act overtime violation claim'
03

Relevance Feedback & Pseudo-Relevance Feedback

Iteratively refines the query by extracting key terms from initially retrieved documents assumed to be relevant.

  • Pseudo-Relevance Feedback (PRF): Automatically treats the top-k results from an initial search as relevant
  • Process: Extract distinctive terms (using TF-IDF or BM25 weights) from those top documents and append them to the original query
  • Strength: Adapts the query to the specific corpus vocabulary
  • Risk: Query drift if the initial top results are not actually relevant
  • Example: A search for 'patent infringement' might expand to include 'doctrine of equivalents' and 'claims construction' after PRF
04

Embedding-Based Query Expansion

Expands the query vector by traversing the embedding space to find semantically proximate legal concepts.

  • Mechanism: Encode the query, then find the nearest-neighbor terms in a legal-specific embedding space
  • Implementation: Use a Legal-BERT or BGE model fine-tuned on legal corpora to ensure domain alignment
  • Strength: Captures deep semantic relationships (e.g., 'indemnification' is close to 'hold harmless')
  • Nuance: Requires a high-quality legal embedding model to avoid spurious correlations
  • Example: A query vector for 'board fiduciary duty' pulls in 'duty of care', 'duty of loyalty', and 'business judgment rule'
05

Knowledge Graph Traversal

Expands queries by traversing relationships in a structured legal knowledge graph to include connected entities and doctrines.

  • Mechanism: Identify the entity in the query, then traverse 1-hop or 2-hop relationships in the graph
  • Graph Schema: Nodes are statutes, cases, doctrines; edges are 'cites', 'interprets', 'overturns'
  • Strength: Adds high-precision, logically connected legal concepts
  • Example: Querying 'Miranda rights' traverses to 'Fifth Amendment', 'custodial interrogation', and 'Miranda v. Arizona'
06

Contextual Query Expansion with Document Metadata

Augments the query using structured metadata filters like jurisdiction, date range, or court level to constrain and focus the expansion.

  • Mechanism: Pre-filter the corpus before expansion or append metadata tokens to the query string
  • Application: A query for 'non-compete clauses' is expanded differently if the jurisdiction filter is 'California' vs. 'Texas'
  • Strength: Prevents expansion into irrelevant legal domains
  • Implementation: Combine with hybrid search to apply metadata filters to both sparse and dense retrieval paths
  • Example: Adding '9th Circuit' and '2020-2024' to a query for 'privacy rights'
QUERY EXPANSION

Frequently Asked Questions

Answers to common questions about augmenting legal search queries with related terms and concepts to improve retrieval recall and precision.

Query expansion is an information retrieval technique that augments a user's original search query with additional, semantically related terms to improve recall. The process works by analyzing the initial query and appending synonyms, hypernyms, hyponyms, or conceptually linked phrases that appear in a controlled vocabulary or are statistically derived from a document corpus. In a legal context, a query for "breach of contract" might be automatically expanded to include "material breach," "anticipatory repudiation," "non-performance," and "fundamental breach." The expanded query is then submitted to the retrieval engine, which matches against a broader set of potentially relevant documents that use different terminology to describe the same legal concept. This is particularly critical in law, where practitioners use jurisdiction-specific jargon, Latin phrases, and statutory language that may not match the exact keywords a researcher initially types.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.