Spaces:
Sleeping
Sleeping
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,41 +1,4 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
Spaces:
|
| 6 |
-
yamraj047
|
| 7 |
-
/
|
| 8 |
-
lexnepal-api
|
| 9 |
-
|
| 10 |
-
like
|
| 11 |
-
0
|
| 12 |
-
|
| 13 |
-
App
|
| 14 |
-
|
| 15 |
-
Files
|
| 16 |
-
Community
|
| 17 |
-
Settings
|
| 18 |
-
lexnepal-api
|
| 19 |
-
/
|
| 20 |
-
README.md
|
| 21 |
-
|
| 22 |
-
yamraj047's picture
|
| 23 |
-
yamraj047
|
| 24 |
-
Update README.md
|
| 25 |
-
8e57c48
|
| 26 |
-
VERIFIED
|
| 27 |
-
Preview
|
| 28 |
-
Code
|
| 29 |
-
|
|
| 30 |
-
raw
|
| 31 |
-
|
| 32 |
-
Copy download link
|
| 33 |
-
history
|
| 34 |
-
blame
|
| 35 |
-
edit
|
| 36 |
-
delete
|
| 37 |
-
1.44 kB
|
| 38 |
-
metadata
|
| 39 |
title: LexNepal AI API
|
| 40 |
emoji: ⚖️
|
| 41 |
colorFrom: blue
|
|
@@ -43,58 +6,61 @@ colorTo: indigo
|
|
| 43 |
sdk: docker
|
| 44 |
pinned: false
|
| 45 |
license: apache-2.0
|
|
|
|
| 46 |
|
| 47 |
-
🇳🇵 LexNepal AI API
|
| 48 |
|
| 49 |
Advanced Legal Intelligence API for Nepal Legal Code using Retrieval-Augmented Generation (RAG).
|
| 50 |
|
|
|
|
| 51 |
|
| 52 |
-
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
-
|
| 55 |
-
Cross-Encoder Reranking: Precise relevance scoring
|
| 56 |
-
Zero-Hallucination: Answers only from verified legal texts
|
| 57 |
-
Fast & Free: Optimized for CPU inference
|
| 58 |
|
| 59 |
-
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
-
|
| 62 |
-
Reranking: MS-MARCO Cross-Encoder
|
| 63 |
-
LLM: Llama 3.3 70B (via Groq)
|
| 64 |
-
Vector DB: FAISS (L2 Index)
|
| 65 |
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
GET / -
|
| 69 |
-
|
| 70 |
-
GET /stats - Database statistics
|
| 71 |
-
POST /query - Process legal query
|
| 72 |
-
|
| 73 |
-
💻 Usage Example
|
| 74 |
|
|
|
|
|
|
|
| 75 |
curl -X POST "https://YOUR_USERNAME-lexnepal-api.hf.space/query" \
|
| 76 |
-H "Content-Type: application/json" \
|
| 77 |
-d '{
|
| 78 |
"query": "What are the penalties for theft in Nepal?",
|
| 79 |
"max_sources": 10
|
| 80 |
}'
|
|
|
|
|
|
|
|
|
|
| 81 |
|
| 82 |
-
|
| 83 |
|
| 84 |
-
|
| 85 |
|
|
|
|
|
|
|
|
|
|
| 86 |
|
| 87 |
-
|
| 88 |
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
|
|
|
|
|
|
| 92 |
|
| 93 |
-
|
| 94 |
|
| 95 |
-
FastAPI
|
| 96 |
-
Sentence Transformers
|
| 97 |
-
FAISS
|
| 98 |
-
Groq API
|
| 99 |
-
Docker
|
| 100 |
Built with ❤️ for Nepal's legal community
|
|
|
|
| 1 |
+
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
title: LexNepal AI API
|
| 3 |
emoji: ⚖️
|
| 4 |
colorFrom: blue
|
|
|
|
| 6 |
sdk: docker
|
| 7 |
pinned: false
|
| 8 |
license: apache-2.0
|
| 9 |
+
---
|
| 10 |
|
| 11 |
+
# 🇳🇵 LexNepal AI API
|
| 12 |
|
| 13 |
Advanced Legal Intelligence API for Nepal Legal Code using Retrieval-Augmented Generation (RAG).
|
| 14 |
|
| 15 |
+
## 🚀 Features
|
| 16 |
|
| 17 |
+
- **Hybrid Retrieval**: Dense vector search + keyword matching
|
| 18 |
+
- **Cross-Encoder Reranking**: Precise relevance scoring
|
| 19 |
+
- **Zero-Hallucination**: Answers only from verified legal texts
|
| 20 |
+
- **Fast & Free**: Optimized for CPU inference
|
| 21 |
|
| 22 |
+
## 🏗️ Architecture
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
+
- **Embedding Model**: all-mpnet-base-v2 (768D)
|
| 25 |
+
- **Reranking**: MS-MARCO Cross-Encoder
|
| 26 |
+
- **LLM**: Llama 3.3 70B (via Groq)
|
| 27 |
+
- **Vector DB**: FAISS (L2 Index)
|
| 28 |
|
| 29 |
+
## 📡 API Endpoints
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
+
- `GET /` - Interactive API documentation (Swagger UI)
|
| 32 |
+
- `GET /health` - Health check
|
| 33 |
+
- `GET /stats` - Database statistics
|
| 34 |
+
- `POST /query` - Process legal query
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
+
## 💻 Usage Example
|
| 37 |
+
```bash
|
| 38 |
curl -X POST "https://YOUR_USERNAME-lexnepal-api.hf.space/query" \
|
| 39 |
-H "Content-Type: application/json" \
|
| 40 |
-d '{
|
| 41 |
"query": "What are the penalties for theft in Nepal?",
|
| 42 |
"max_sources": 10
|
| 43 |
}'
|
| 44 |
+
```
|
| 45 |
+
|
| 46 |
+
## 🔒 Environment Variables
|
| 47 |
|
| 48 |
+
Set `GROQ_API_KEY` in Space settings for custom API key.
|
| 49 |
|
| 50 |
+
## 📊 Dataset
|
| 51 |
|
| 52 |
+
- **Total Provisions**: 6000+
|
| 53 |
+
- **Legal Documents**: 7 Nepal laws
|
| 54 |
+
- **Vector Dimensions**: 768
|
| 55 |
|
| 56 |
+
## 🛠️ Tech Stack
|
| 57 |
|
| 58 |
+
- FastAPI
|
| 59 |
+
- Sentence Transformers
|
| 60 |
+
- FAISS
|
| 61 |
+
- Groq API
|
| 62 |
+
- Docker
|
| 63 |
|
| 64 |
+
---
|
| 65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
Built with ❤️ for Nepal's legal community
|