How swagath18/rag-pdf-assistant works
Project Type and Purpose
• This is a local RAG-based PDF chatbot application – it uses Streamlit for the frontend/UI, processes uploaded PDF documents, uses FAISS for vector similarity search, leverages Hugging Face embeddings for converting text into vectors, and employs a local LLM (via Ollama’s Llama 2) for generating responses.
• The purpose is to allow users to upload PDFs, extract their content, generate and store embeddings, and subsequently query the content locally without any remote API calls.
Main Components
• User Interface (UI) / Frontend: Represented by Streamlit components as depicted in "pdf_chatbot/app.py".
• PDF Processing Module: Includes text extraction and chunking. This can be broken down into:
• PDF processing (similar to process_pdf.py and text_chunking.py).
• Utility configurations defined in config.py.
• Vector Store / FAISS Index Management: Responsible for creating, updating, and querying the FAISS vector database (faiss_index and vector_store.py).
• LLM Inference Module: Uses Ollama (Llama 2) for processing queries and generating answers (analogous to qa_system.py / llm_inference.py in the README structure).
• Auxiliary Components: Other utility modules that support configuration and integration between components.
Relationships and Data Flow
• User Interaction: The user uploads one or more PDFs and sets parameters (like chunk size) via the Streamlit UI.
• PDF Upload → PDF Processing: Documents are processed (extraction and chunking) within the PDF processing module.
• Processed Text → Embedding Generation: Text chunks are then converted to embeddings using Hugging Face models.
• Embeddings → FAISS Index: Generated embeddings are stored in or queried against the FAISS index – acting as the vector database.
• Query Handling: When the user asks a question, the system retrieves relevant text chunks from the FAISS vector store.
• Retrieved Data → LLM Inference: The retrieved chunks, along with the query, are sent to the local LLM module running Ollama (Llama 2) to generate the answer.
• Answer Display: The answer is then displayed in real time to the user via the Streamlit UI.
Architectural Patterns & Technologies
• Modular Design: The project is separated into distinct modules that encapsulate specific functions (PDF processing, vector store management, LLM inference).
• Separation of Concerns: UI, processing, and data management all reside in different parts of the project, ensuring clarity in roles.
• RAG Pattern: Clearly, the retrieval (FAISS vector search) and generation (LLM inference) are at the heart of the project, which is a classic RAG implementation.
• Technologies/Libraries in Use:
• Streamlit for interactive web UI.
• PyPDF2 for text extraction.
• FAISS for vector search capabilities.
• Hugging Face models for obtaining text embeddings.
• Ollama (Llama 2) for local inference that provides the chatbot’s response.