PDF-RAG is a Streamlit application that allows users to upload PDF documents, process them for semantic search, and ask questions about their content. The system uses a Retrieval-Augmented Generation (RAG) approach to provide accurate, contextual answers based on the document content.
- PDF Upload: Upload one or multiple PDF documents
- Document Processing: Extract, chunk, and embed document content
- Semantic Search: Query your documents using natural language
- AI-Powered Responses: Get contextual answers generated by an LLM (Language Learning Model)
- Response Reasoning: View the AI's reasoning process for transparency
- Database Management: Clear the document database when needed
The system uses a Retrieval-Augmented Generation (RAG) architecture:
- Ingestion Pipeline: PDFs are processed, text is extracted and chunked semantically
- Vector Database: Chunks are embedded and stored in a Qdrant vector database
- Retrieval System: User queries retrieve the most relevant document chunks
- Generation: An LLM generates answers based on the retrieved context
- Python 3.8+
- Qdrant account (for vector database)
- Ollama (for local LLM access)
streamlit
qdrant-client
ollama
python-dotenv
pypdf2
scikit-learn
numpy
nltk
-
Clone the repository:
git clone https://github.com/mosmolov/rag-study-buddy.git cd rag-study-buddy -
Set up a virtual environment (optional but recommended):
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Create a
.envfile with your Qdrant credentials:QDRANT_URL=your_qdrant_url QDRANT_API_KEY=your_qdrant_api_key -
Make sure Ollama is installed and running with the required models:
# Install models ollama pull nomic-embed-text ollama pull deepseek-r1:1.5b
-
Start the Streamlit application:
streamlit run app.py
-
Open your browser and navigate to the displayed URL (typically http://localhost:8501)
-
Upload PDF files using the file uploader
-
Click "Process PDFs" to extract, chunk, and embed the document content
-
Enter your questions in the query field and click "Search"
-
View the AI's response, reasoning, and supporting context
You can adjust system parameters in config.py:
CHUNK_SIZE: Size of text chunks (default: 1024)CHUNK_OVERLAP: Overlap between chunks (default: 100)COLLECTION_NAME: Name of the Qdrant collection (default: "documents")RETRIEVAL_LIMIT: Number of chunks to retrieve per query (default: 7)EMBEDDING_MODEL: Model for generating embeddings (default: "nomic-embed-text")LLM_MODEL: Model for answering queries (default: "deepseek-r1:1.5b")STREAM_RESPONSE: Enable streaming responses (default: False)
- PDFs are uploaded and text is extracted
- Text is split into semantically meaningful chunks using NLTK
- Embeddings are generated for each chunk using the specified embedding model
- Chunks and their embeddings are stored in Qdrant
- The user enters a natural language question
- The query is embedded and used to search for relevant chunks in Qdrant
- Retrieved chunks are combined to create context for the LLM
- The LLM generates a response based on the retrieved context
- The system displays the answer, reasoning, and supporting context
app.py: Main Streamlit applicationconfig.py: Configuration parametersingestion.py: PDF processing and storagequery.py: Document retrieval and LLM query functionsutils.py: Utility functions for chunking and embeddingsrequirements.txt: Project dependencies