The QAT System Chatbot is an advanced conversational AI application designed to assist users by answering questions based on retrieved documents. Utilizing state-of-the-art natural language processing (NLP) techniques and vector storage via FAISS, this chatbot is capable of generating responses and follow-up questions that enhance user understanding. The application is built using LangChain, Hugging Face embeddings, and various document loaders for flexible file handling.
- Document Retrieval: Efficiently loads and splits documents from various formats (PDF, DOCX, TXT).
- Conversational Memory: Maintains context through conversation history to provide relevant answers.
- Dynamic Follow-Up Questions: Generates follow-up questions based on user queries and chatbot responses.
- Bullet Point Summaries: Provides concise bullet points elaborating on answers for better comprehension.
- Similarity Evaluation: Evaluates user responses against expected answers using cosine similarity.
To get started with the Document Chatbot, follow these steps:
-
Clone the repository:
git clone https://github.com/DrUkachi/qatsystem.git cd qatsystem -
Install required packages:
Create a virtual environment (recommended) and install the necessary dependencies:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate` pip install -r requirements.txt
Ensure you have the following libraries installed:
langchain flask streamlit langchain_huggingface langchain_community faiss-cpu # or faiss-gpu for GPU support torch # Install compatible version based on your system -
Set Up the GROQ API Key:
To access the GROQ API, you will need an API key. Follow these steps to set it up:
-
Sign up for a GROQ account and obtain your API key.
-
Add the API key to your environment variables:
-
On Linux/MacOS:
export GROQ_API_KEY='your_api_key_here'
-
On Windows:
set GROQ_API_KEY='your_api_key_here'
-
Make sure to replace
your_api_key_herewith your actual GROQ API key. -
-
Download Hugging Face model:
The project uses the
sentence-transformers/all-mpnet-base-v2model for embeddings. Ensure you have access to Hugging Face models by installing thetransformerslibrary if not already included inrequirements.txt.
1.Install PostgreSQL:
-
On Ubuntu:
sudo apt update sudo apt install postgresql postgresql-contrib
-
On macOS (using Homebrew):
brew install postgresql
-
On Windows:
- Download the installer from the PostgreSQL official website.
- Follow the installation instructions and configure your PostgreSQL environment.
After installation, start the PostgreSQL service:
-
On Ubuntu:
sudo service postgresql start
-
On macOS:
brew services start postgresql
-
On Windows: Start the PostgreSQL service using the services management console.
- To create a PostgreSQL database with the provided details, follow these steps:
You can use the PostgreSQL command line (psql) or a GUI tool like PgAdmin. Here, is a step-by-step guide if you are using psql.
-
Login to PostgreSQL: Open your terminal and run the following command to log in to PostgreSQL:
psql -U postgres
You will be prompted to enter the password for the
postgresuser (the default superuser). -
Create a new database: Once logged in, create the database using the following SQL command:
CREATE DATABASE your_database;
This creates a new database named
your_database. -
Create a new user: Now, create the user with a password by executing:
CREATE USER your_username WITH PASSWORD 'your_password';
-
Grant privileges: Grant all privileges on the new database to the user:
GRANT ALL PRIVILEGES ON DATABASE your_database TO your_username;
-
Exit: Exit the PostgreSQL prompt by typing:
\q
-
Open PgAdmin: Connect to your PostgreSQL server.
-
Create a New Database:
- Right-click on the "Databases" node in the sidebar and select "Create" > "Database."
- In the dialog, enter
your_databaseas the name, and select the owner (either usepostgresor the new user you plan to create).
-
Create a New User (Role):
- Go to "Login/Group Roles," right-click and select "Create" > "Login/Group Role."
- Set the username (
your_username) and password (your_password). - Under the "Privileges" tab, grant the necessary permissions (e.g.,
CREATE,CONNECT).
-
Grant Privileges:
- Navigate to the newly created database.
- Under "Properties," assign the new user as the owner or grant them access through the "Privileges" tab.
Now, you have a PostgreSQL database your_database with the user your_username and the given password. You can use these credentials in your application configuration.
-
Start the Flask server:
python flask_app.py
You can decide to use the provided notebook with the
requestslibrary to test the created endpoints or use thestreamlitinterface that came with the project to further test and see the interaction. -
Start the Streamlit app You can choose the port number you prefer for this just indicate it in the command.
streamlit run --server.port 8501 QATSystem/streamlit_app.py
- Upload a Document using the upload interface
- The document will be used to create a docstore or knowledge database - this will take an average of 3-5 mins to load depending on whether you are using a GPU or CPU
- Once the docstore is created you can then go ahead to send in your query or ask a question related to the document you uploaded.
- When the query is sent a response is returned with 3 key bullet points and a follow-up question
- Then user is asked to answer the question and then an evaluation of the response is provided.
Contributions are welcome! If you have suggestions for improvements or additional features, feel free to fork the repository and submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
For any questions or inquiries, please contact:
- Ukachi Osisiogu: [email protected]
- GitHub: DrUkachi
Thank you for your interest in the QATSystem Chatbot! We hope you find it useful for your document processing and conversational AI needs.