An atomic query represents one information need extracted from a compound question. Decomposition gives each need its own embedding, route classification, and retrieval call, avoiding a blended embedding that returns partially relevant chunks. section 7.4.3
Compound question decomposed
The question “What was Uber's revenue in 2021, and how does its gross bookings growth compare to Lyft's?” becomes three independently answerable queries: Uber's 2021 revenue, Uber's 2021 gross bookings growth, and Lyft's 2021 gross bookings growth. section 7.4.3
A decomposer preserves entities and time periods, avoids overlap, and returns two to four focused queries for compound input. Simple input passes through unchanged as a one-element array. The resulting answers are synthesized after focused retrieval. section 7.4.3
def decompose_query(user_query: str) -> list:
decompose_prompt = f'''
Analyze the following query and determine if it contains
multiple distinct information needs. If it does, break it
into 2-4 focused atomic sub-queries. If it is already a
single focused question, return it unchanged.
Rules:
- Each sub-query must be independently answerable
- Sub-queries should not overlap or repeat each other
- Preserve specific entities (company names, time periods)
- Return ONLY a JSON array of strings
Query: {user_query}
'''
response = openai_client.chat.completions.create(
model="gpt-4o",
messages=[
{"role": "user", "content": decompose_prompt}
],
temperature=0,
)
try:
content = response.choices[0].message.content.strip()
json_match = re.search( #A
r"\[.*\]", content, re.DOTALL
)
return json.loads(json_match.group())
except (json.JSONDecodeError, AttributeError):
return [user_query] #B
Use the Python implementation to build a JSON-returning decomposer with independently answerable outputs and unchanged pass-through for simple questions. section 7.4.3
Within the enterprise RAG pipeline, decomposition follows cache filtering, routing, and query rewriting, then sends each atomic query to the selected collection or live search before response synthesis. section 7.5

