How aiwithhassan/ai-lawyer-rag-with-deepseek works
Project Type and Purpose
• This is a Python‐based Retrieval‐Augmented Generation (RAG) application with a Streamlit front‐end.
• It ingests documents (e.g., PDFs), builds a FAISS vector database, and runs a three‐phase pipeline:
• Phase 1: Streamlit UI (“frontend.py” or “main.py”)
• Phase 2: Vector database creation (“vector_database.py”)
• Phase 3: RAG pipeline logic (“rag_pipeline.py”)
File Structure
• Top‑level scripts:
• frontend.py – Streamlit UI for Phase 1
• main.py – an all‑in‑one entry point (Streamlit)
• vector_database.py – builds FAISS vector store from documents
• rag_pipeline.py – retrieval + LLM inference pipeline
• Dependencies: Pipfile / requirements.txt manage Python packages (Streamlit, FAISS, OpenAI SDK, etc.)
• Data store: vectorstore/db_faiss/index.faiss (+ index.pkl)
• Assets: PDF documents used as source knowledge
README
• Describes environment setup (Pipenv, Conda, Pip)
• Explains how to run each phase:
• streamlit run frontend.py (Phase 1)
• python vector_database.py (Phase 2)
• python rag_pipeline.py (Phase 3)
a. Main Components
• User & Browser (end user)
• Streamlit UI (frontend.py or main.py)
• Vector DB Builder (vector_database.py + source PDFs)
• FAISS Vector Store (vectorstore/db_faiss)
• RAG Pipeline (rag_pipeline.py)
• External LLM Service (e.g., OpenAI API)
b. Relationships & Data Flows
1. User enters query into Streamlit UI.
2. UI forwards query to the RAG Pipeline module.
3. Pipeline embeds query (via embedding library), queries FAISS DB for similar docs.
4. Retrieved chunks + query are sent to the LLM API.
5. API returns generated answer, which the UI displays.
6. (Offline) Vector DB Builder ingests PDFs, computes embeddings, and writes to FAISS index.
c. Architectural Patterns
• Modular “phase” separation (ingest → store → query)
• Pipeline pattern in RAG (retrieve → augment → generate)
• Monolithic Python app organized into distinct modules
d. Key Technologies
• Streamlit for UI
• FAISS for vector similarity search
• Python embedding library (e.g., OpenAI embeddings)
• OpenAI or other LLM API for generation