How cosmicishan/ai-lawyer-chatbot works
Project type and purpose
• This is a full-stack AI-powered Q&A system (legal document chatbot).
• Users upload PDF legal texts, retrieve relevant content via a vector database, and generate answers with an LLM.
File structure
• Top-level scripts:
• frontend.py – Streamlit UI (web interface)
• vector_database.py – FAISS + LangChain wrapper for embedding storage & retrieval
• rag_pipeline.py – Retrieval-Augmented Generation pipeline using DeepSeek R1 + Groq
• PDFs/ – directory where uploaded documents are stored
• requirements.txt / README.md – configuration & documentation
README for additional insights
• Tech stack: Streamlit (UI), FAISS (vector DB), Ollama embeddings, DeepSeek R1 LLM
• Workflow summary: upload → vectorize & store → query → retrieve → answer
a. Main components
1. User Interface (Streamlit Frontend)
2. PDF Storage
3. Embedding Service (Ollama)
4. Vector Database (FAISS via LangChain)
5. RAG Pipeline (rag_pipeline.py with DeepSeek R1 + Groq)
6. External Services (if any, e.g., Ollama API or GPU inference endpoint)
b. Relationships & data flow
• User interacts with Streamlit UI → uploads PDF or submits a question
• On PDF upload:
• Streamlit calls vector_database.py
• vector_database.py invokes Ollama Embeddings to generate embeddings
• Embeddings are indexed and stored in FAISS
• On question submission:
• Streamlit triggers rag_pipeline.py
• Pipeline uses LangChain to query FAISS for similar chunks
• Retrieved chunks + user query feed into DeepSeek R1 model (via Groq accelerator)
• Model returns an answer → Streamlit displays it
c. Architectural patterns / design principles
• Separation of concerns: UI logic (frontend.py) vs. data/storage (vector_database.py) vs. AI logic (rag_pipeline.py)
• RAG pattern: decoupling retrieval (FAISS) from generation (LLM)
• Modular design: each script encapsulates a single responsibility
d. Key technologies & libraries
• Streamlit for front-end UX
• FAISS + LangChain for vector search
• Ollama Embeddings for text-to-vector
• DeepSeek R1 LLM + Groq for inference