05. Add query rewrite module

Add query rewrite module

step

  1. Perform Naive RAG

  2. Check relevance for searched documents (Groundedness Check)

  3. Web Search

  4. (This tutorial) Query Rewrite

Reference

  • It's an extension from the previous tutorial, so there may be overlapping parts. Please refer to the previous tutorial for insufficient explanation.

Preferences

Basic PDF-based Retrieval Chain creation

Here, we create a Retrieval Chain based on PDF documents. Retrieval Chain with the simplest structure.

However, LangGraph creates Retirever and Chain separately. Only then can you do detailed processing for each node.

Reference

  • As covered in the previous tutorial, we omit the detailed description.

State definition

State : Defines the state of sharing between nodes and nodes in Graph.

Generally TypedDict Use format. This time, we add the results of the relevance check to the state. Reference

  • this time question Define it as list format. This is to store additional rewritten Query.

Node definition

  • Nodes : Nodes that handle each step. Usually implemented as a Python function. Input and output are state values.

Reference

  • State Updated after performing a defined logic with input State Returns.

Add Query Rewrite node

Rewrite existing questions by utilizing the prompts to rewrite Query.

Last updated