Query Expansion

FlowHunt’s Query Expansion component boosts chatbot accuracy by expanding queries with synonyms and correcting spelling, ensuring precise and consistent AI responses.

Query Expansion

Component description

How the Query Expansion component works

Query Expansion Component

The Query Expansion component is designed to paraphrase a given input text into multiple alternative queries. Its primary purpose is to enhance semantic search within a knowledge base by generating various rewordings of the original query, thereby increasing the likelihood of matching relevant information during retrieval processes.

What Does the Component Do?

This component takes an initial input message and produces several alternative queries that express the same intent in different ways. By leveraging a language model, it can generate these paraphrased queries, making downstream search or information retrieval tasks more robust and comprehensive. This is particularly useful in AI workflows that involve searching large corpora or knowledge bases, as it mitigates the issue of semantic mismatches between user queries and stored documents.

Inputs

The component supports the following inputs:

FieldTypeRequiredDescription
InputMessageYesThe main text (query) to be expanded into alternative forms.
LLM (Model)BaseChatModelNoThe language model used to generate paraphrased queries. If not provided, a default model may be used.
Chat HistoryInMemoryChatMessageHistoryNoPrevious chat messages that provide context for generating more relevant query alternatives.
Number of Alternatives (Limit)IntegerYesHow many alternative queries to generate. Default is 5.
Include Original QueryBooleanNoOption to include the original query in the list of alternatives (default is true).
System MessageString (multiline)NoAdditional system-level instructions appended to the prompt to guide the model’s behavior.

Quick Input Reference

  • Input: The text to paraphrase (required)
  • LLM: Choose which AI model to use (optional)
  • Chat History: Contextual history to help model generate better queries (optional)
  • Number of Alternatives: How many variations to produce (required)
  • Include Original Query: Whether to keep the original in the output (optional)
  • System Message: Instructions for the model (optional, advanced)

Outputs

NameTypeDescription
MessageMessageA message containing the list of alternative queries.

The output is a message object that includes all generated alternative queries (and possibly the original, if specified). These alternatives can be used directly in downstream search or analysis components.

When and Why to Use

  • Improve Search Recall: By generating semantically diverse queries, you increase the chances of retrieving all relevant documents, even if they use different terminology.
  • Handle Ambiguity: Useful when user queries are vague or underspecified; alternative queries can cover multiple interpretations.
  • Enhance Conversational AI: Integrate into chatbots or virtual assistants to interpret user intents more flexibly.
  • Preprocessing for QA Systems: Before passing user input to a question-answering model, expand the query to cover more possible answers.

Example Use Case

Suppose a user asks, “How do I reset my password?” The Query Expansion component might generate alternatives like:

  • “What steps should I follow to change my password?”
  • “How can I recover a forgotten password?”
  • “Instructions for resetting a password”
  • “How to update account password?”

These expanded queries can then be used to search a knowledge base, improving the chances of finding the most relevant articles.

Summary Table

FeatureDescription
ParaphrasingGenerates multiple alternative queries for a single input
Customizable ModelSupports selection of different language models
Context-AwareCan use chat history to inform query generation
Output FlexibilityOptionally includes the original query in the output
Advanced PromptingAccepts a system message to tailor the model’s paraphrasing behavior

This component is a valuable building block for any AI workflow that requires robust, context-aware query expansion for improved search and retrieval capabilities.

Examples of flow templates using Query Expansion component

To help you get started quickly, we have prepared several example flow templates that demonstrate how to use the Query Expansion component effectively. These templates showcase different use cases and best practices, making it easier for you to understand and implement the component in your own projects.

Frequently asked questions

What is the Query Expansion component?

The Query Expansion finds synonyms or related words and fixes spelling mistakes to help the Bot understand your query.

What happens if I don’t use Query Expansion?

Users will have different language levels and vocabulary styles. Without using the expansion, your bot may occasionally misunderstand queries.

What’s the difference between Query Expansion and Task Decomposition?

Both help the bot understand the query better. Query Expansion appends incomplete or faulty queries, making them clear and complete. On the other hand, Task Decomposition takes complex or compound queries and breaks them down into smaller executable steps.

Try FlowHunt’s Query Expansion

Boost your chatbot's accuracy and user satisfaction with FlowHunt's advanced Query Expansion component.

Learn more