- Introduction
- Setup Instructions
- How it works
- Prerequisites
- Installation
- Usage
- Docker Compose
- limitations
- Acknowledgments
This is a llama-based procurement chatbot that helps with unspc codes.
The chatbot integrates unspc data from data.gov
The repository contains all the necessary code and files to set up and run the Procurement Chatbot with Memory using the Llama-2-7B-Chat model. Here's a brief overview of how to set it up:
-
app.py
: The Streamlit web application code that allows users to interact with the chatbot through a simple user interface. -
llama-2-7b-chat.ggmlv3.q2_K.bin
: Quantized model weights provided by TheBloke. Can be downloaded via wget or manually
!wget https://huggingface.co/TheBloke/Llama-2-7B-Chat-GGML/resolve/main/llama-2-7b-chat.ggmlv3.q2_K.bin
Please keep the downloaded model inside the data/ folder
-
Dockerfile
: The Dockerfile used to containerize the application for easy deployment and management. -
docker-compose.yml
: A Docker Compose file that simplifies the deployment of the chatbot with memory as a Docker container. -
requirements.txt
: Contains a list of Python dependencies required to run the application.
The Procurement Bot is a retrieval augmented generation (RAG) based chatbot. The workflow is as follows:
- The user types the query to the bot.
- The relevant entity is extracted (as noun-phrases using spacy) and matched with the entities in the UNSPC database.
- Based on the detected entity, a relevant triple is extracted from the Database and fed to the llama model for creating a response using the data.
A sample conversation with the bot is shown below:
Before running the Streamlit Chatbot with Memory, you need to have the following installed:
- Python (version 3.6 or higher)
- Conda
- Docker (if you plan to use the Docker Compose setup)
To set up the chatbot locally, follow these steps:
- Copy the folder into local machine and go to the folder procurement-bot
cd procurement-bot
- Create a conda environment and activate it:
conda create -n procu-bot python=3.10
conda activate procu-bot
- Install the required Python packages:
pip install -r requirements.txt
- Install the spacy model for detecting noun phrases
python -m spacy download en_core_web_sm
To run the Procurement Chatbot for unspc, execute the following command:
streamlit run app.py
This will start the Streamlit server, and you can access the chatbot interface by opening your web browser and navigating to http://localhost:8501
.
Simply type your messages (preferably about unspc codes) in the input box and press "Enter" to send them to the chatbot. The chatbot will respond based on the context of the conversation, thanks to its memory capabilities.
If you prefer to deploy the chatbot using Docker Compose, follow these steps:
-
Make sure you have Docker and Docker Compose installed on your system.
-
Start the container using Docker Compose:
docker-compose up -d
The chatbot will be accessible at http://localhost:8501
in your web browser.
- The main limitations of the bot is it is very much domain-specific and goal-oriented but can also have some chit-chats with the user
- The entity detection relies on direct matching the entities in the unspc dataset, hence can't work on entities with spelling mistakes or needing partial matches.
- There is no controlled intent recognition hence the responses can be at times not consistent.
- The query is based on shallow parsing and has no deep semantic understanding whatsoever.
-
Streamlit Chatbot code credits go to streamlit-llama and data professor.
-
Quantized GGML version of Llama-2-7B-Chat credits go to TheBloke.