How shaurya703/lawline-ai works
LawLine AI is an Indian-law information assistant. Its principal workflow takes a legal question through hybrid retrieval, prompt construction and LLM or extractive answering, then returns cited passages. The repository also includes corpus preparation, evaluation, a Streamlit interface and a documented 22-route React application. Retrieval internals are shown in sampled source; links from individual unsampled frontend pages to backend services are not asserted.
Main entry points: hybrid.py Hybrid retriever · engine.py Query engine · build_indices.py Search index build · knowledge_graph.py Legal knowledge graph
Components 23
User interfaces
- Streamlit command center
app.py - React application
frontend/src/App.tsx - Legal workspaces
frontend/src/pages - FastAPI service
lawline/api.py
Legal corpus
- Corpus ingestion
lawline/data/ingest.py - Document schema
lawline/data/schema.py - Passage chunking
lawline/data/chunking.py
Retrieval engine
- Search index build
scripts/build_indices.py - Semantic embeddings
lawline/index/embedder.py - FAISS index
lawline/index/faiss_index.py - BM25 index
lawline/index/bm25_index.py - Legal concept map
lawline/index/concepts.py - Legal knowledge graph
lawline/index/knowledge_graph.py - Rank fusion
lawline/retrieval/fusion.py - Cross-encoder reranking
lawline/retrieval/reranker.py - Hybrid retriever
lawline/retrieval/hybrid.py
Answer generation
- Query engine
lawline/engine.py - Grounding prompts
lawline/generation/prompts.py - LLM and fallback
lawline/generation/llm.py
Evaluation and training
- Retrieval analytics
lawline/ui/pages/analytics.py - Retrieval evaluation
lawline/eval/run_ablation.py - Bi-encoder training
lawline/training/train_biencoder.py
Other components
- Legal information seeker
Connections 26
- Legal information seeker → Streamlit command center: asks question
- Legal information seeker → React application: uses workspaces
frontend/src/App.tsx - Streamlit command center → Query engine: submits question
- Corpus ingestion → Document schema: creates documents
lawline/data/ingest.py - Corpus ingestion → Passage chunking: feeds corpus
README.md - Search index build → Semantic embeddings: builds indexes
README.md - Search index build → FAISS index: builds index
README.md - Search index build → BM25 index: builds index
README.md - Search index build → Legal knowledge graph: builds graph
README.md - Legal knowledge graph → Legal concept map: seeds concepts
lawline/index/knowledge_graph.py - Hybrid retriever → Semantic embeddings: encodes queries
lawline/retrieval/hybrid.py - Hybrid retriever → FAISS index: searches vectors
lawline/retrieval/hybrid.py - Hybrid retriever → BM25 index: searches terms
lawline/retrieval/hybrid.py - Hybrid retriever → Legal knowledge graph: retrieves entities
lawline/retrieval/hybrid.py - Hybrid retriever → Rank fusion: fuses rankings
lawline/retrieval/hybrid.py - Hybrid retriever → Cross-encoder reranking: reranks candidates
lawline/retrieval/hybrid.py - Query engine → Hybrid retriever: retrieves passages
lawline/engine.py - Query engine → Grounding prompts: formats context
lawline/engine.py - Query engine → LLM and fallback: generates answer
lawline/engine.py - Query engine → Legal information seeker: returns citations
- React application → Legal workspaces: routes requests
frontend/src/App.tsx - React application → FastAPI service: calls service
- Retrieval evaluation → FAISS index: evaluates retrieval
lawline/eval/run_ablation.py - Retrieval evaluation → BM25 index: evaluates retrieval
lawline/eval/run_ablation.py - Retrieval evaluation → Legal knowledge graph: evaluates retrieval
lawline/eval/run_ablation.py - Bi-encoder training → Semantic embeddings: trains encoder
lawline/training/train_biencoder.py