How abhinav281203/llama2-rag works
Project type and purpose
• This is a small, self-contained “Retrieval-Augmented Generation” (RAG) application built in Python.
• It provides a Streamlit-based UI that lets users query a Llama-2 model enriched by PDF documents via LangChain and LlamaIndex.
• The goal is to run locally (offline/private) and answer questions from your own PDFs.
File structure
• Top level:
• Llama2 RAG.py → the main Streamlit app
• Llama2 RAG.ipynb → exploratory/notebook version
• requirements.txt → Python dependencies (langchain, llama-index, streamlit, transformers, etc.)
• documents/ → folder with source PDFs (e.g., Guntur_Kaaram.pdf)
• README.md → project description & run instructions
• No separate “frontend” vs. “backend” folders; the Streamlit script handles both UI and orchestration.
• The documents folder is your local knowledge base.
README for additional insights
• Confirms the use of Llama-2-7b-chat-hf as the core LLM.
• Mentions typcial RAG pipeline: ingest PDFs, build index, handle user queries, retrieve relevant chunks, and call the LLM.
• Run command: streamlit run "Llama2 RAG.py".
Main components
a. User Interface (Streamlit Frontend)
b. RAG Orchestrator (the Python process in Llama2 RAG.py)
c. Document Loader & Index Builder (LlamaIndex component)
d. Vector Store / Retrieval Engine (e.g., FAISS or in-memory index)
e. Language Model API (Llama-2-7b-chat-hf via HuggingFace Transformers)
f. Local File System (documents/*.pdf)
Relationships and data flows
1. User enters a query in Streamlit UI →
2. RAG Orchestrator checks the Vector Store →
– If index not built or changed, the Document Loader reads PDFs, chunks them, and populates the Vector Store.
3. RAG Orchestrator sends query embeddings to Retrieval Engine → obtains top-k relevant document chunks →
4. RAG Orchestrator assembles prompt (query + retrieved context) → calls Llama-2 model →
5. Response flows back to Streamlit UI → displayed to user.
Architectural patterns and design principles
• Modular RAG pipeline: index build, retrieval, prompt construction, LLM inference.
• Single-process, event-driven: Streamlit reruns on each user action.
• Separation of concerns in code: document ingestion vs. retrieval vs. UI rendering.
Key technologies & frameworks
• Streamlit for UI
• langchain & llama-index for RAG abstractions
• HuggingFace Transformers for Llama-2 model
• Local vector store (e.g., FAISS or in-memory)
• Python 3.x (specified in requirements.txt)