How akshatmittu/judgement-citation-retrieval-using-contextual-similarity works
Project type and purpose
• This is a full-stack, multi-page web application built in Streamlit.
• Purpose: legal practitioners log in/register, enter a case description, and retrieve the most relevant legal precedents using text‐similarity (Universal Sentence Encoder + cosine similarity + SVM). They can also download selected cases as a PDF.
File structure
• Top-level scripts:
– 1_Login.py (entry point for authentication)
– generate_pdf.py (PDF‐generation service)
– utils.py (ML pipeline, embedding loader, similarity functions)
– README.md
• Pages directory (Streamlit’s multipage feature):
– 2_Register.py
– 3_Case.py (main retrieval UI)
– 4_About Us.py
• No separate microservices or external config files—everything runs inside one Streamlit server.
Pull additional insights from README
• Backend uses pre-computed SCOTUS dataset and embeddings.
• Authentication appears file-based or in‐memory (no external auth service).
• Frontend UI & routing: Streamlit’s multipage API.
• Core ML stack: Universal Sentence Encoder + Support Vector Machine + cosine ranking.
Main components & interactions
a. User Interface (Client Browser)
– Streamlit front end (pages: Login, Register, Case Input, About Us)
b. Streamlit Server
– Page Router (loads the correct Python script based on navigation)
– Auth Module
• User credential store (e.g., JSON or SQLite file)
– Case Retrieval Module
• Text‐preprocessing & citation-extraction
• Embedding submodule (Universal Sentence Encoder)
• Similarity & ranking engine (cosine similarity + SVM)
– PDF Generation Module (generate_pdf.py)
c. Data Stores
– SCOTUS dataset files (CSV / JSON)
– Pre-computed embeddings (binary or serialized files)
– User datastore (credentials)
d. External services (none in this project—everything is hosted in one container/process)
Relationships & data flows
1. User → Streamlit front end (login/register navigation)
2. Auth Module ←→ User datastore (validate or create credentials)
3. User (post-login) → Case Input page → Case Retrieval Module
4. Case Retrieval Module → SCOTUS dataset & embeddings → compute top-5 citations
5. Module returns ranked citations → UI renders text + relevance bars
6. If “Download PDF” clicked → PDF Generation Module reads selected cases → streams PDF back to browser
Architectural patterns & design principles
• Layered separation: UI layer (Streamlit pages) vs. service layer (auth, retrieval, PDF) vs. data layer.
• Single‐process modularity: each Python module is its own component.
• Reusability: utils.py houses all ML/utility functions for retrieval.
• Stateless page handling: Streamlit reruns script on each interaction; state managed via Streamlit’s session_state.
Relevant technologies & libraries
• Streamlit (UI framework)
• TensorFlow Hub (Universal Sentence Encoder)
• scikit-learn (Support Vector Machine, cosine similarity tools)
• pandas / NumPy (data handling)
• reportlab or similar (PDF generation)
Final checklist
• All components (UI pages, modules, data stores) present
• Annotations for key libraries and frameworks