This is a solution for DevRev's Problem Statement at the 12th Inter IIT TechMeet aiming adepty address domain-specific user queries.
We developed a Large Language Model (LLM) powered chatbot, augmented by a set of tools (APIs), each accompanied by its detailed description. The chatbot intelligently recommends subset of tools that best match the unique context of the query, specifying precise tool arguments, and sequencing tool execution intelligently. Additionally, our solution incorporates features facilitating the seamless addition and modification of tools within our toolset.
We optimize the pipeline for performance, latency, and resource usage. The dynamically changing toolset and vastly different user queries make this task challenging. We analyse the performance of different LLMs and prompting strategies, and propose novel methods for handling LLM hallucinations. We also propose a new synthetic data generation methodology which we used to generate novel queries, enabling us to better understand the user's needs.
A Language model L has a set of tools T, and a user query Q is given. To answer query Q, we need to use existing tools. You need to output the subset of tools to be used to answer the query, the arguments that these tools should be called with, and how to compose the tools to answer the query. The user queries are conversational.
The set of tools T is dynamic, and new tools can be added, and existing ones could be modified or removed and the agent needs to be able to handle it gracefully.
Our final pipeline includes the following parts:
Retrieval-ICL - Retrieval of semantically similar query-answer pairs to serve as few-shot examples for the LLM.
Chain-of-Thought Prompting - COT prompting was used to enhance the reasoning capabilities of the LLM.
Hallucination Check - We detect all forseeable hallucinations that may occur.
Corrective Reprompting - If hallucinations are detected, we ensure they are removed reprompting the LLM.
Memory - To effectively manage the conversational aspects of the query.
- Install Dependencies: Install the required libraries using:
pip install -r requirements.txt
-
Download Seed Dataset: Download from this link: here
-
Configure File Paths:
- app.py:
Modify
retrieval_loader
with your CSV file path:retrieval_loader = CSVLoader(file_path=r"Your Path here", source_column='QUERY')
- retrieval.py:
Modify
loader
with your CSV file path:loader = CSVLoader(file_path=r"Your Path here")
- API Keys Setup: Add your API keys:
- Hugging Face API Key:
os.environ['HUGGINGFACEHUB_API_TOKEN'] = "Your Hugging Face API Key here"
- OpenAI API Key:
os.environ['OPENAI_API_KEY'] = "Your OpenAI Key here"
Get the Hugging Face API Keys from here.
- Run the Application: Execute the following command to run the app:
streamlit run app.py
-
Initial Setup: Upon launching, you'll land on the Chatbot page.
-
Navigate to Tools Management Page: Click the radio button in the sidebar to access the Tools Management Page.
-
Tool Management:
- Reset API Toolset: Click on "Reset API toolset" on the Tools Management Page.
- Add New Tools: Use the "Add New Tool" form to add tools to the API list. Multiple tools can be added.
- Update Tool Details: To update a tool's name or description, select it and make changes as needed.
- Delete Tool: Select a tool and click "Delete tool" to remove it.
- Argument Management:
- Add New Arguments: Fill in the details for new arguments in the provided form.
- Update/Delete Arguments: Select an argument to update or delete it.
- Bulk Delete: Choose multiple arguments to delete them at once.
- Finalize: Complete the necessary actions to fully utilize the interface.
- Parth-Agarwal216
- himanshu-skid19
- SpyzzVVarun
- prabhanjan-jadhav
- grgkaran03
- arush414
- aryansingh0909
- Jahnavikkk
- JAYESH1304