{"id":28977169,"url":"https://github.com/theaifutureguy/AI-Lawyer---RAG-with-DeepSeek-R1","last_synced_at":"2026-04-13T12:02:07.936Z","repository":{"id":300252380,"uuid":"1005537037","full_name":"danieladdisonorg/AI-Lawyer---RAG-with-DeepSeek-R1","owner":"danieladdisonorg","description":" AI-powered legal chatbot that leverages Retrieval-Augmented Generation (RAG) with DeepSeek R1 for advanced legal reasoning and document analysis. It provides a sophisticated legal assistant that can process and analyze complex legal documents, retrieve relevant information using advanced vector search, and generate nuanced legal analysis.","archived":false,"fork":false,"pushed_at":"2025-06-20T16:26:50.000Z","size":1187,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-20T17:36:05.527Z","etag":null,"topics":["deepseek","faiss","faiss-vector-database","groq-api","langchain","pdfplumber","streamlit"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danieladdisonorg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-20T11:37:14.000Z","updated_at":"2025-06-20T16:25:54.000Z","dependencies_parsed_at":"2025-06-20T17:48:06.064Z","dependency_job_id":null,"html_url":"https://github.com/danieladdisonorg/AI-Lawyer---RAG-with-DeepSeek-R1","commit_stats":null,"previous_names":["danieladdisonorg/ai-lawyer---rag-with-deepseek-r1"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/danieladdisonorg/AI-Lawyer---RAG-with-DeepSeek-R1","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danieladdisonorg%2FAI-Lawyer---RAG-with-DeepSeek-R1","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danieladdisonorg%2FAI-Lawyer---RAG-with-DeepSeek-R1/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danieladdisonorg%2FAI-Lawyer---RAG-with-DeepSeek-R1/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danieladdisonorg%2FAI-Lawyer---RAG-with-DeepSeek-R1/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danieladdisonorg","download_url":"https://codeload.github.com/danieladdisonorg/AI-Lawyer---RAG-with-DeepSeek-R1/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danieladdisonorg%2FAI-Lawyer---RAG-with-DeepSeek-R1/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261700274,"owners_count":23196491,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deepseek","faiss","faiss-vector-database","groq-api","langchain","pdfplumber","streamlit"],"created_at":"2025-06-24T15:00:52.593Z","updated_at":"2026-04-13T12:02:07.890Z","avatar_url":"https://github.com/danieladdisonorg.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ⚖️ AI Lawyer - RAG with DeepSeek R1\n\n\u003cdiv align=\"center\"\u003e\n\n![Python](https://img.shields.io/badge/python-v3.8+-blue.svg)\n![Streamlit](https://img.shields.io/badge/streamlit-1.28+-red.svg)\n![License](https://img.shields.io/badge/license-MIT-green.svg)\n![Status](https://img.shields.io/badge/status-active-success.svg)\n\n**An AI-powered legal chatbot that leverages Retrieval-Augmented Generation (RAG) with DeepSeek R1 for advanced legal reasoning and document analysis.**\n\n[🚀 Live Demo](https://ai-lawyer-rag-with-deepseek.streamlit.app/) | [📖 Documentation](#-how-it-works) | [🛠️ Installation](#️-installation--setup)\n\n\u003c/div\u003e\n\n---\n\n## 📋 Table of Contents\n\n- [Overview](#-overview)\n- [Features](#-features)\n- [Demo](#-project-demo)\n- [Architecture](#-architecture)\n- [Installation \u0026 Setup](#️-installation--setup)\n- [Usage](#-usage)\n- [How It Works](#-how-it-works)\n- [API Configuration](#-api-configuration)\n- [Deployment](#-deployment)\n- [Contributing](#-contributing)\n- [Future Improvements](#-future-improvements)\n- [License](#-license)\n\n## 🎯 Overview\n\nAI Lawyer is a sophisticated legal assistant that combines the power of **DeepSeek R1's reasoning capabilities** with **Retrieval-Augmented Generation (RAG)** to provide accurate, context-aware legal insights. \n\n### Key Capabilities:\n- **Document Intelligence**: Process and analyze complex legal documents\n- **Contextual Retrieval**: Find relevant legal information using advanced vector search\n- **Reasoning-Based Responses**: Leverage DeepSeek R1's advanced reasoning for nuanced legal analysis\n- **Hallucination Reduction**: Ground responses in actual legal texts for enhanced reliability\n- **Report Generation**: Create comprehensive, downloadable legal analysis reports\n\n## ✨ Features\n\n| Feature | Description |\n|---------|-------------|\n| 📂 **Document Upload** | Support for PDF legal documents with intelligent text extraction |\n| 🔍 **Smart Retrieval** | FAISS-powered vector database for precise information retrieval |\n| 🤖 **AI Reasoning** | DeepSeek R1 integration via Groq API for advanced legal reasoning |\n| 📜 **Document Summarization** | Generate concise summaries of complex legal documents |\n| 📄 **Report Generation** | Create and download AI-generated legal analysis reports |\n| 💬 **Interactive Chat** | Conversational interface for legal Q\u0026A |\n| 🔒 **Secure Processing** | Local document processing with secure API integration |\n\n## 📸 Project Demo\n\n\u003cdiv align=\"center\"\u003e\n\n| Document Upload Interface | AI Chat Interface |\n|---------------------------|-------------------|\n| ![Screenshot 1](utils/photo1.png) | ![Screenshot 2](utils/photo2.png) |\n\n| Legal Analysis Results | Report Generation |\n|------------------------|-------------------|\n| ![Screenshot 3](utils/photo3.png) | ![Screenshot 4](utils/photo4.png) |\n\n\u003c/div\u003e\n\n## 🏗️ Architecture\n\n```\n┌─────────────────┐    ┌──────────────────┐    ┌─────────────────┐\n│   Streamlit UI  │────│  RAG Pipeline    │────│  DeepSeek R1    │\n│   (frontend.py) │    │ (rag_pipeline.py)│    │   via Groq      │\n└─────────────────┘    └──────────────────┘    └─────────────────┘\n         │                       │                       │\n         │              ┌──────────────────┐             │\n         └──────────────│ Vector Database  │─────────────┘\n                        │(vector_database.py)│\n                        │   FAISS Index    │\n                        └──────────────────┘\n```\n\n## 📁 Project Structure\n\n```\nAI-Lawyer---RAG-with-DeepSeek-R1/\n├── 📄 frontend.py              # Streamlit UI application\n├── 🔧 rag_pipeline.py          # RAG implementation with DeepSeek R1\n├── 🗄️ vector_database.py       # FAISS vector database management\n├── 📋 requirements.txt         # Python dependencies\n├── 📖 README.md               # Project documentation\n├── 🖼️ utils/                   # Screenshots and utilities\n│   ├── photo1.png\n│   ├── photo2.png\n│   ├── photo3.png\n│   └── photo4.png\n└── 📁 .streamlit/             # Streamlit configuration (if exists)\n    └── config.toml\n```\n\n## 🛠️ Technologies Used\n\n| Technology | Purpose | Version |\n|------------|---------|---------|\n| **DeepSeek R1** | Advanced AI reasoning model | Latest |\n| **Groq API** | High-speed LLM inference | - |\n| **LangChain** | LLM application framework | 0.1+ |\n| **Streamlit** | Web application framework | 1.28+ |\n| **FAISS** | Vector similarity search | Latest |\n| **pdfplumber** | PDF text extraction | Latest |\n| **Sentence Transformers** | Text embeddings | Latest |\n\n## ⚙️ Installation \u0026 Setup\n\n### Prerequisites\n- Python 3.8 or higher\n- Groq API key\n- Git\n\n### 1️⃣ Clone the Repository\n\n```bash\ngit clone https://github.com/danieladdisonorg/AI-Lawyer---RAG-with-DeepSeek-R1.git\n```\n\n```bash\ncd AI-Lawyer---RAG-with-DeepSeek-R1\n```\n\n### 2️⃣ Set Up Virtual Environment\n\n**On macOS/Linux:**\n```bash\npython -m venv venv\n```\n\n```bash\nsource venv/bin/activate\n```\n\n**On Windows:**\n```bash\npython -m venv venv\n```\n\n```bash\nvenv\\Scripts\\activate\n```\n\n### 3️⃣ Install Dependencies\n\n```bash\npip install -r requirements.txt\n```\n\n### 4️⃣ Configure Environment Variables\n\nCreate a `.env` file in the project root:\n\n```bash\necho \"GROQ_API_KEY=your_groq_api_key_here\" \u003e .env\n```\n\nOr set it as an environment variable:\n\n```bash\nexport GROQ_API_KEY=\"your_groq_api_key_here\"\n```\n\n## 🚀 Usage\n\n### Running Locally\n\n1. **Start the application:**\n```bash\nstreamlit run frontend.py\n```\n\n2. **Open your browser** and navigate to `http://localhost:8501`\n\n3. **Upload a legal document** (PDF format)\n\n4. **Ask questions** about the document using natural language\n\n5. **Download reports** generated by the AI analysis\n\n### Example Queries\n- \"What are the key terms and conditions in this contract?\"\n- \"Summarize the main legal obligations for each party\"\n- \"What are the potential risks mentioned in this document?\"\n- \"Explain the termination clauses in simple terms\"\n\n## 📜 How It Works\n\n### 1. Document Processing\n- **Upload**: User uploads PDF legal documents\n- **Extraction**: Text is extracted using pdfplumber\n- **Chunking**: Documents are split into manageable sections\n\n### 2. Vector Database Creation\n- **Embedding**: Text chunks are converted to vector embeddings\n- **Indexing**: FAISS creates searchable vector index\n- **Storage**: Vectors are stored for efficient retrieval\n\n### 3. Query Processing\n- **User Input**: Legal questions are received via Streamlit interface\n- **Retrieval**: Relevant document sections are found using vector similarity\n- **Context**: Retrieved information provides context for AI response\n\n### 4. AI Response Generation\n- **DeepSeek R1**: Advanced reasoning model processes query and context\n- **Groq API**: High-speed inference for real-time responses\n- **Structured Output**: Responses are formatted for legal clarity\n\n### 5. Report Generation\n- **Analysis**: AI generates comprehensive document analysis\n- **Formatting**: Results are structured in professional format\n- **Download**: Users can download PDF reports\n\n## 🔑 API Configuration\n\n### Groq API Setup\n\n1. **Get API Key**: Visit [Groq Console](https://console.groq.com/) and create an account\n2. **Generate Key**: Create a new API key in your dashboard\n3. **Configure**: Add the key to your environment variables or `.env` file\n\n### Supported Models\n- `deepseek-r1-distill-llama-70b` (Recommended)\n- `deepseek-r1-distill-qwen-32b`\n- Other DeepSeek R1 variants available via Groq\n\n## 🌐 Deployment\n\n### Streamlit Cloud Deployment\n\n1. **Push to GitHub:**\n```bash\ngit add .\n```\n\n```bash\ngit commit -m \"Deploy AI Lawyer application\"\n```\n\n```bash\ngit push origin main\n```\n\n2. **Deploy on Streamlit Cloud:**\n   - Visit [Streamlit Cloud](https://share.streamlit.io/)\n   - Connect your GitHub repository\n   - Set `GROQ_API_KEY` in Streamlit Secrets\n   - Click **Deploy!**\n\n### Environment Variables for Deployment\n```toml\n# .streamlit/secrets.toml\nGROQ_API_KEY = \"your_groq_api_key_here\"\n```\n\n### Alternative Deployment Options\n- **Docker**: Containerize the application\n- **Heroku**: Deploy with Procfile\n- **AWS/GCP**: Cloud platform deployment\n- **Local Server**: Run on dedicated hardware\n\n## 🤝 Contributing\n\nWe welcome contributions! Please follow these steps:\n\n1. **Fork** the repository\n2. **Create** a feature branch (`git checkout -b feature/AmazingFeature`)\n3. **Commit** your changes (`git commit -m 'Add some AmazingFeature'`)\n4. **Push** to the branch (`git push origin feature/AmazingFeature`)\n5. **Open** a Pull Request\n\n### Development Guidelines\n- Follow PEP 8 style guidelines\n- Add docstrings to functions\n- Include unit tests for new features\n- Update documentation as needed\n\n## 🎯 Future Improvements\n\n### Short Term\n- [ ] **Multi-format Support**: Add DOCX, TXT, and HTML document support\n- [ ] **Batch Processing**: Handle multiple documents simultaneously\n- [ ] **Advanced Search**: Implement semantic search with filters\n- [ ] **User Authentication**: Add user accounts and document history\n\n### Medium Term\n- [ ] **Legal Database Integration**: Connect to legal precedent databases\n- [ ] **Citation Tracking**: Automatic legal citation generation\n- [ ] **Multi-language Support**: Support for non-English legal documents\n- [ ] **API Endpoints**: RESTful API for programmatic access\n\n### Long Term\n- [ ] **Real-time Collaboration**: Multi-user document analysis\n- [ ] **Legal Workflow Integration**: Connect with legal practice management tools\n- [ ] **Advanced Analytics**: Document comparison and trend analysis\n- [ ] **Mobile Application**: Native mobile app development\n\n## 📊 Performance Metrics\n\n- **Response Time**: \u003c 3 seconds for typical queries\n- **Accuracy**: 90%+ for factual legal information retrieval\n- **Document Size**: Supports PDFs up to 50MB\n- **Concurrent Users**: Optimized for 10+ simultaneous users\n\n## 🔒 Security \u0026 Privacy\n\n- **Data Privacy**: Documents are processed locally and not stored permanently\n- **API Security**: Secure API key management\n- **No Data Retention**: User documents are not retained after session\n- **Encryption**: All API communications are encrypted\n\n## 📄 License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## 🙏 Acknowledgments\n\n- **DeepSeek** for the advanced reasoning model\n- **Groq** for high-speed inference infrastructure\n- **Streamlit** for the excellent web framework\n- **LangChain** for LLM application tools\n- **FAISS** for efficient vector search\n\n---\n\n\u003cdiv align=\"center\"\u003e\n\n**⚖️ AI Lawyer - Making Legal Analysis Accessible Through AI**\n\n[🌟 Star this repo](https://github.com/danieladdisonorg/AI-Lawyer---RAG-with-DeepSeek-R1) | [🐛 Report Bug](https://github.com/danieladdisonorg/AI-Lawyer---RAG-with-DeepSeek-R1/issues) | [💡 Request Feature](https://github.com/danieladdisonorg/AI-Lawyer---RAG-with-DeepSeek-R1/issues)\n\nMade with ❤️ by [Daniel Addison](https://github.com/danieladdisonorg)\n\n\u003c/div\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheaifutureguy%2FAI-Lawyer---RAG-with-DeepSeek-R1","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftheaifutureguy%2FAI-Lawyer---RAG-with-DeepSeek-R1","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheaifutureguy%2FAI-Lawyer---RAG-with-DeepSeek-R1/lists"}