ngupta949 commited on
Commit
fb8f15a
·
verified ·
1 Parent(s): 83659c6

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +121 -4
README.md CHANGED
@@ -10,10 +10,127 @@ tags:
10
  pinned: false
11
  short_description: Streamlit template space
12
  ---
 
13
 
14
- # Welcome to Streamlit!
15
 
16
- Edit `/src/streamlit_app.py` to customize this app to your heart's desire. :heart:
17
 
18
- If you have any questions, checkout our [documentation](https://docs.streamlit.io) and [community
19
- forums](https://discuss.streamlit.io).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  pinned: false
11
  short_description: Streamlit template space
12
  ---
13
+ # Ollama PDF RAG Streamlit UI
14
 
15
+ ## Overview
16
 
17
+ This application is a Retrieval-Augmented Generation (RAG) system that allows users to interact with PDF documents using natural language queries. It combines the power of local language models, efficient text embedding, and vector search to provide accurate and context-aware responses to user questions based on the content of uploaded PDFs.
18
 
19
+ ## Model Available :
20
+
21
+ ![PDF Upload](Model.png)
22
+
23
+ ## Model Used : Mistral
24
+
25
+ ![PDF Upload](MistralResponse.png)
26
+
27
+ ## Model Used : tinyllama
28
+
29
+ ![Question Answering](Question&Answer.png)
30
+
31
+ ## Features
32
+
33
+ - PDF upload and processing
34
+ - Question answering using local language models
35
+ - PDF viewer with zoom functionality
36
+ - Vector database for efficient information retrieval
37
+ - Multi-query retrieval for improved accuracy
38
+
39
+ ## How It Works
40
+
41
+ 1. **PDF Processing**: Users upload PDF documents which are then processed and converted into text.
42
+ 2. **Text Embedding**: The extracted text is split into chunks and converted into vector embeddings.
43
+ 3. **Vector Storage**: These embeddings are stored in a vector database for quick retrieval.
44
+ 4. **Query Processing**: User questions are processed using a language model to generate multiple query variations.
45
+ 5. **Retrieval**: Relevant text chunks are retrieved from the vector database based on the queries.
46
+ 6. **Answer Generation**: The language model uses the retrieved context to generate an accurate answer.
47
+
48
+ ## Components
49
+
50
+ ### Language Models
51
+
52
+ We use the following Ollama models:
53
+
54
+ 1. **LLaMA 2**: A powerful open-source language model developed by Meta AI, known for its strong performance across various NLP tasks.
55
+ 2. **Mistral**: An efficient and high-performance language model, offering a good balance between speed and accuracy.
56
+
57
+ These models are used for question understanding, query generation, and answer synthesis.
58
+
59
+ ### Embedding Model
60
+
61
+ - **Nomic Embed**: We use the `nomic-embed-text` model for generating text embeddings. This model is optimized for creating high-quality vector representations of text, which is crucial for accurate information retrieval.
62
+
63
+ ### Vector Database
64
+
65
+ - **FAISS (Facebook AI Similarity Search)**: An efficient similarity search and clustering library for dense vectors. We use FAISS as our vector database due to its high performance and ability to handle large-scale datasets.
66
+
67
+ ## Why These Components?
68
+
69
+ - **Local Language Models**: Using Ollama models allows for privacy-preserving, offline operation while maintaining high-quality language understanding and generation.
70
+ - **RAG System**: By combining retrieval with generation, we can provide answers that are both relevant to the user's question and grounded in the actual content of the PDFs.
71
+ - **Vector Embeddings and Search**: This allows for semantic understanding of both the document content and user queries, enabling more accurate and context-aware information retrieval.
72
+ - **Multi-Query Retrieval**: By generating multiple variations of the user's query, we increase the chances of finding relevant information, especially for complex or ambiguous questions.
73
+
74
+ ## Prerequisites
75
+
76
+ Before running the application, make sure you have the following installed:
77
+
78
+ - Python 3.8 or higher
79
+ - [Ollama](https://ollama.ai/) - for running local language models
80
+
81
+ ## Installation
82
+
83
+ 1. Clone this repository:
84
+
85
+ ```
86
+ git clone https://github.com/varun-soni-ai/RAG-Ollama-Chat-with-PDF.git
87
+ cd ollama-pdf-rag-streamlit
88
+ ```
89
+ 2. Create a virtual environment:
90
+
91
+ ```
92
+ python -m venv rag-ollama
93
+ source rag/bin/activate # On Windows, use `rag\Scripts\activate`
94
+ ```
95
+ 3. Install the required packages:
96
+
97
+ ```
98
+ pip install -r requirements.txt
99
+ ```
100
+ 4. Create a `.env` file in the project root and add any necessary environment variables (e.g., API keys if needed).
101
+ 5. Pull the required Ollama models:
102
+ Make sure you have Ollama installed and running, then execute the following commands:
103
+
104
+ ```
105
+ ollama pull nomic-embed-text
106
+ ollama pull llama2
107
+ ollama pull mistral
108
+ ollama pull tinyllama
109
+ ```
110
+
111
+ This will download and set up the necessary models for the application.
112
+
113
+ ## Running the Application
114
+
115
+ 1. Make sure Ollama is running on your system.
116
+ 2. Start the Streamlit application:
117
+
118
+ ```
119
+ streamlit run app.py
120
+ ```
121
+ 3. Open your web browser and go to `http://localhost:8501` (or the URL provided by Streamlit).
122
+
123
+ ## Usage
124
+
125
+ 1. Select a local language model from the dropdown menu.
126
+ 2. Upload one or more PDF files using the file uploader.
127
+ 3. Click the "Submit & Process" button to process the PDFs.
128
+ 4. Once processing is complete, you can view the PDF pages and adjust the zoom level.
129
+ 5. Enter your questions in the chat input at the bottom of the page.
130
+ 6. The system will provide answers based on the content of the uploaded PDFs.
131
+
132
+ ## Troubleshooting
133
+
134
+ - If you encounter any issues with Ollama or the language models, make sure Ollama is properly installed and running on your system.
135
+ - Check that you have successfully pulled all required models (`nomic-embed-text`, `llama2`, and `mistral`).
136
+ - Check the console output for any error messages or logs that might help identify the problem.