FastGPTFastGPT
App Building/Workflow/Nodes

Query Rewriting

FastGPT Query Rewriting node overview and usage

Deprecated: The Query Enhancement node can no longer be added to new workflows. Existing nodes remain runnable for compatibility.

Characteristics

  • Can be added multiple times
  • Has external input
  • Trigger-based execution

Background

In RAG, we perform embedding searches against the database based on the input query to find relevant content (Dataset search).

During search -- especially in multi-turn conversations -- follow-up questions often fail to retrieve useful results. One reason is that Dataset search only uses the "current" question. Consider this example:

When the user asks "What is the second point?", the system searches the Dataset for exactly that phrase and finds nothing. The actual intended query is "What is the QA structure?". This is why we need a Query Rewriting node to complete the user's current question so the Dataset search can return relevant results. With query rewriting applied:

What It Does

Calls an AI model to complete and refine the user's current question. It primarily resolves coreferences (pronouns and vague references), making search queries more complete and reliable. This improves Dataset search accuracy in multi-turn conversations.

The main challenge is that the model may not have a clear understanding of "completion" and often struggles to determine how to properly refine queries with long context.

Edit on GitHub

File Updated