Skip to content

LearnRetrieve

Query expansion

Query augmentation

Adding related terms or text to a query before searching, so passages that use different words for the same thing can still match.

In DocSlurpGlossary entry

On this page

Query expansion adds words or text to a query so it can match passages written in different vocabulary. The query “NRR forecast” might be expanded to “NRR OR net revenue retention forecast”, so a memo that never abbreviates still matches.

Expansions come from several places:

  • A curated list. Synonym expansion uses a glossary your team maintains. Precise, but limited to the pairs someone wrote down.
  • The corpus itself. Pseudo-relevance feedback runs the query once, takes frequent terms from the top results and searches again. Graph expansion adds entity names linked to the query in a knowledge graph.
  • A language model. Query rewriting restates the question; HyDE writes a whole hypothetical answer and searches with that.

The gotcha: drift

Every added term is another way to match, and some of those matches are wrong. Expand “office” with “location” for a question about the new London office, and retail location reports from the expansion model start ranking. Pseudo-relevance feedback is worst here: if the first results were off-topic, expansion makes the second round more off-topic. Keep expansions narrow, weight original terms above added ones where your engine allows it, and measure recall@k and precision before and after rather than assuming more terms is better.

In DocSlurp

In DocSlurp

Three expansions exist: project synonyms and a per-request glossary (core/server/src/search/synonym.ts), knowledge-graph entity names appended to the keyword query when graph expansion is on (core/server/src/search/graph-expansion.ts), and HyDE for the vector query (core/server/src/search/hyde.ts).

Sources

Jump to