Query Expansion

If someone doesn’t understand what you’re saying, they ask you to rephrase. You then try different ways to say it until you’re sure you’re on the same page. That’s precisely what the Query Expansion does but for the Chatbot. How to connect the Query Expansion component to your Flow The Query Expansion should be connected…
Categories:
Query Expansion

If someone doesn’t understand what you’re saying, they ask you to rephrase. You then try different ways to say it until you’re sure you’re on the same page. That’s precisely what the Query Expansion does but for the Chatbot.

What is the Query Expansion component?

The Query Expansion finds related words and synonyms to help AI understand your query and retrieve the correct information. The same method is why Google always understands what you’re looking for, no matter how you say it.

Query Expansion component in FlowHunt

How to connect the Query Expansion component to your Flow

The Query Expansion should be connected right after the chat input. Thanks to this, all the subsequent components use the expanded query.

Input

  • Input (required): This is the human query that gets expanded.
  • Chat history (optional): Let previous messages give more context to the expansion.
  • LLM (optional): Connect an LLM component to change the model used for Query Expansion. By default, the component uses ChatGPT-4o.

TIP: Query Expansion works just as well with older LLMs. Switching to a less advanced model cuts costs and makes the chatbot faster.

Number of Alternatives

This setting limits the number of alternative phrases and words generated. Feel free to adjust this based on your use case. Remember that a higher limit will cost more, and too many alternatives may lower relevancy.

Output

The output is an augmented version of the original query. This component’s output is suitable for any component asking for Input or Context.

The difference Query Expansion makes

You can safely assume that users will find many ways to phrase the same question and make all sorts of spelling mistakes. To demonstrate, we’ll put the Query Expansion through a stress test.

Let’s try a query using an unlikely term. We’ll take it a bit further by making some heavy typos. Lastly, let’s not forget to botch the product name.

This is our final test query:

“What the expendatur of urslab?”

Let’s see how the bot fares without the Query Expansion first:

Example of bot's answer without Query Expansion in FlowHunt

It figured out we were talking about expenditures but struggled to find suitable information. It then opted to send us to the contact page instead.

Now let’s try with Query Expansion:

Example of bot's answer with Query Expansion in FlowHunt

This time, it understands the query and retrieves the correct information from linked knowledge sources.

Note: Even without Query Expansion, the chatbot is bound to figure out most queries, but the result may vary. Query Expansion ensures consistency.

Frequently Asked Questions

  • 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.

Our website uses cookies. By continuing we assume your permission to deploy cookies as detailed in our privacy and cookies policy.