This project integrates a language model (LLM) with a Retrieval-Augmented Generation (RAG) approach to enhance question-answering capabilities. It leverages the power of the Llama 2-7B model for generating responses and combines it with a retrieval system for fetching relevant information from a database created from PDF documents. The project demonstrates how to split, embed, and retrieve document data to support the LLM in generating accurate and informative answers.
Before running this project, ensure you have the following prerequisites installed or available:
- Python 3.9 or later
- Llama-2-7B-Chat model. Download the
llama-2-7b-chat.Q4_K_M.gguf
model file from HuggingFace.
- Install the required Python packages:
pip install -r requirements.txt
- Clone this repository
git clone https://github.com/lileetung/LLM-RAG.git
- Navigate to the project directory:
cd LLM-RAG
- Run the main script:
python RAG.py
After running the RAG.py
script, the system will prompt you to input a question. You can use the suggested questions or input your own. The system operates in two modes:
- LLMChain mode: Directly utilizes the LLM for answering questions.
- RetrievalQA mode: Uses a retrieval system to fetch relevant information which is then passed to the LLM for generating answers.
I'm currently developing a GUI for the project using Tkinter. Here's a screenshot:
![LLMGUI](https://private-user-images.githubusercontent.com/83776772/312934592-1d752b34-6179-4fb0-8036-01f34ee12625.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjUyMzQyNTcsIm5iZiI6MTcyNTIzMzk1NywicGF0aCI6Ii84Mzc3Njc3Mi8zMTI5MzQ1OTItMWQ3NTJiMzQtNjE3OS00ZmIwLTgwMzYtMDFmMzRlZTEyNjI1LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MDElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTAxVDIzMzkxN1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTdlYmI3ZGI3ZjJmNmY4NTExMzA4NmZlNTNhMTg0M2Q3ODZmNWFkZTg3M2FkOGZkOGUyOWVmYTBmOGJiZWU5N2EmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.ceA9pED4JUHZAK0c62aF6yvZmWuqBES2SOZHuzUydoM)