Skip to content

Multi Query Retriever

The Multi Query Retriever lets you turn a single search question into several related questions. It then uses a language model to generate those variations and searches a vector database for documents that match any of them. The result is a richer set of documents that covers more angles of your original query.

How it Works

  1. Input your question – Type the query you want to search for.
  2. Choose a language model – The component uses the selected LLM to rewrite the question into several new, related questions.
  3. Generate multiple questions – By default it creates three different versions, but you can change that number.
  4. Search the database – All generated questions are sent to a base retriever that looks up documents in your vector database.
  5. Return results – You get a list of documents that match any of the generated questions, plus the original query if you choose to include it.

The component works entirely inside Nappai, so no external API calls are made beyond the LLM you provide.

Inputs

  • Search Query: The main question you want to find information about.
  • Include Original query: If checked, the original question is added to the list of queries sent to the database.
  • Base Retriever: The retriever that actually talks to your vector database. It handles compression and decompression of the data.
  • Model: The language model that rewrites the question into multiple variations.
  • Number of Questions: How many different versions of the question the LLM should create. The minimum is 2.
  • Number of Results: How many documents to return for each query. This can be set as a list to get different limits for different queries.

Outputs

  • Retriever: A ready‑to‑use retriever object that can be plugged into other components or workflows.
  • Search Results: A list of documents that match any of the generated queries. Each document is returned as a Data object that can be displayed or further processed.

Usage Example

  1. Add the component to your dashboard.
  2. Enter a search query such as “How to optimize database indexing?”
  3. Select a language model (e.g., GPT‑4).
  4. Choose a base retriever that points to your vector database.
  5. Set Number of Questions to 4 and Number of Results to 15.
  6. Run the component.
  7. View the Search Results – you’ll see a mix of documents that answer the original question and its variations.

You can then feed the Retriever output into another component that ranks or filters the documents further.

  • Retriever – Basic component for querying a vector database.
  • Language Model – Provides the LLM used for generating question variations.
  • Vector Database – Stores the documents that the retriever searches.

Tips and Best Practices

  • Keep Number of Questions at least 2 to ensure diverse search angles.
  • Enable Include Original query if you want to guarantee the exact wording is considered.
  • Adjust Number of Results based on how many documents you need; higher numbers can slow down the search.
  • Pair the retriever with a ranking component to surface the most relevant documents first.

Security Considerations

All data stays within your Nappai environment. The component only sends the query text to the chosen language model; no sensitive documents are exposed outside your system. Ensure that the LLM you use complies with your organization’s data‑handling policies.