--- title: LexNepal AI API emoji: ⚖️ colorFrom: blue colorTo: indigo sdk: docker pinned: false license: apache-2.0 --- # 🇳🇵 LexNepal AI API Advanced Legal Intelligence API for Nepal Legal Code using Retrieval-Augmented Generation (RAG). ## 🚀 Features - **Hybrid Retrieval**: Dense vector search + keyword matching - **Cross-Encoder Reranking**: Precise relevance scoring - **Zero-Hallucination**: Answers only from verified legal texts - **Fast & Free**: Optimized for CPU inference ## 🏗️ Architecture - **Embedding Model**: all-mpnet-base-v2 (768D) - **Reranking**: MS-MARCO Cross-Encoder - **LLM**: Llama 3.3 70B (via Groq) - **Vector DB**: FAISS (L2 Index) ## 📡 API Endpoints - `GET /` - Interactive API documentation (Swagger UI) - `GET /health` - Health check - `GET /stats` - Database statistics - `POST /query` - Process legal query ## 💻 Usage Example ```bash curl -X POST "https://YOUR_USERNAME-lexnepal-api.hf.space/query" \ -H "Content-Type: application/json" \ -d '{ "query": "What are the penalties for theft in Nepal?", "max_sources": 10 }' ``` ## 🔒 Environment Variables Set `GROQ_API_KEY` in Space settings for custom API key. ## 📊 Dataset - **Total Provisions**: 6000+ - **Legal Documents**: 7 Nepal laws - **Vector Dimensions**: 768 ## 🛠️ Tech Stack - FastAPI - Sentence Transformers - FAISS - Groq API - Docker --- Built with ❤️ for Nepal's legal community