Sub Query With Langchain
image-searchvector-databasesemantic-searchmilvusembeddingsunstructured-dataquestion-answeringLLMmilvus-bootcampdeep-learningimage-recognitionimage-classificationaudio-searchPythonbootcampragadvanced_ragNLP
Export
Google Colab preparation[optional]
This is an optional step, if you want to run this notebook on Google Colab.
[ ]
[ ]
[ ]
Please prepare you OPENAI_API_KEY in your environment variables.

If you are running this notebook on Google Colab, you have to restart this session by Cmd/Ctrl + M, then press . to make the environment take effect.
[ ]
Get started

Prepare the data
We use the Langchain WebBaseLoader to load documents from blog sources and split them into chunks using the RecursiveCharacterTextSplitter.
[1]
Build the chain
We load the docs into milvus vectorstore, and build a milvus retriever.
[2]
Define the vanilla RAG chain.
[3]
Define the sub query chain.
[4]
Test the chain
[6]
sub_queries: ['What is MRKL?', 'What is HuggingGPT?'] [vanilla_result]: I'm sorry, but the provided context does not contain any information about MRKL, so I cannot provide a comparison between MRKL and HuggingGPT. [sub_query_result]: MRKL (Modular Reasoning, Knowledge and Language) and HuggingGPT are both systems that utilize large language models (LLMs), but they differ in their structure and functionality. MRKL, proposed by Karpas et al. in 2022, is a neuro-symbolic architecture for autonomous agents. It contains a collection of "expert" modules, and the LLM works as a router to route inquiries to the most suitable expert module. These modules can be neural, like deep learning models, or symbolic, like a math calculator or weather API. On the other hand, HuggingGPT, proposed by Shen et al. in 2023, is a framework that uses ChatGPT as a task planner to select models available in the HuggingFace platform according to the model descriptions. It then summarizes the response based on the execution results. In terms of differences, MRKL's structure is more modular, with the LLM directing inquiries to different expert modules, while HuggingGPT uses ChatGPT to plan tasks and select models from the HuggingFace platform. Furthermore, MRKL can incorporate both neural and symbolic modules, whereas HuggingGPT primarily interacts with other models on the HuggingFace platform.
The vanilla chain cannot answer this question. This is because the retrieved documents are limited and do not contain enough information to answer the question. The method of using sub query to answer questions can increase the number of queries, thereby increasing the retrieved document information to answer the question.
[ ]