Today, Contextual AI announces the release of query reformulation and decomposition, allowing agent builders to ensure even the messiest and most complex queries are handled well. 

User queries come in all different forms: some are clear and unambiguous, others are underspecified, and still others span multiple topics and questions. In addition, based on the domain or content and structure of the underlying corpus, there may be ways to optimize raw queries to boost accuracy and response quality. Query reformulation and decomposition allow users to easily express query handling preferences through natural language prompts and few-shot examples. 

When reformulation is enabled, users can set instructions for when and how elements of the query should be rewritten. Use cases include:

  • Ensuring alignment between terminology and concepts found in the corpus and the wording of the query
  • Making explicit any background assumptions or ambiguous referents to entities or dates
  • Adding context-dependent tags or metadata that can steer downstream retrieval 

When query decomposition is enabled, Contextual automatically determines whether a given query should be decomposed into sub-queries. If there are multiple sub-queries, Contextual seamlessly handles the task of performing separate retrievals per sub-query and fusing the results together to construct the final set. Users can guide this process with examples on how they would like complex queries to be decomposed, which the system will then generalize from. 

To get started, simply toggle “Enable Query Expansion” or “Enable Query Decomposition” in the “Query Reformulation” section of the agent settings page, or through the agent creation or edit API.