liveBook · Manning

Query decomposition

As explained in Build an Advanced RAG Application (From Scratch)

Query decomposition transforms a compound information need into multiple atomic sub-queries that can be processed independently.

Query decomposition transforms a compound information need into focused atomic queries before retrieval. Each sub-query receives its own embedding, route classification, and retrieval call, improving precision across distinct information needs. section 7.4 section 7.4.3

A practical decomposer follows this flow:

  • Preserve entities and time periods, then route and retrieve each sub-query against the appropriate collection. section 7.4.3
  • Return a single-element array containing the original query when no decomposition is needed. section 7.4.3
  • Combine the focused retrieval results during final response synthesis. section 7.4.3

Comparing Uber and Lyft

The compound question “What was Uber's revenue in 2021, and how does its gross bookings growth compare to Lyft's?” becomes three queries: Uber's 2021 revenue, Uber's 2021 gross bookings growth, and Lyft's 2021 gross bookings growth. Separate embeddings and retrieval calls target the relevant filing chunks instead of producing one averaged ride-share embedding. section 7.4.3

How Build an Advanced RAG Application (From Scratch) covers it

How deep it goes
Explains embedding dilution, atomic splitting, independent routing and retrieval, synthesis, and simple-query pass-through.
Examples
Uses an Uber revenue-and-growth comparison, separate Uber and Lyft filings, and a single-query pass-through case.
What it assumes
Assumes a routing and retrieval pipeline, while teaching how to pass focused and simple queries through one decomposer.
What you can do after
Build it from scratch with Python and an OpenAI GPT-4o call that returns validated JSON sub-queries.
How it connects
Connects query decomposition with query rewriting, routing, semantic caching, retrieval, and response generation.

Also explained in

Compare how 3 books explain query decomposition →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build an Advanced RAG Application (From Scratch). The section links point to the parts of the book it draws on.