Downloads · 30 days
0
mugwaneza/mbaza-model
mbaza-model is a question answering model from mugwaneza. Use it when the input is a question plus a passage. It is set up for sentence-transformers. The card lists the license as mit.
Multilingual Legal Assistant for Rwandan Laws - Supporting Kinyarwanda, English, and French.
Downloads · 30 days
0
Access
Public
Updated Oct 30, 2025
Repo size
3.1 MB
Likes
0
Public
Click a slice to open those files.
.npy3.1 MB · 46%
From the Hugging Face model README
Multilingual Legal Assistant for Rwandan Laws - Supporting Kinyarwanda, English, and French.
This model provides intelligent legal assistance for Rwandan laws, punishments, and legal procedures. It uses semantic search with sentence embeddings to match user queries with relevant legal articles and punishment information.
sentence-transformers/all-MiniLM-L6-v2import requests
API_URL = "https://api-inference.huggingface.co/models/mugwaneza/mbaza-model"
headers = {"Authorization": f"Bearer {YOUR_HF_TOKEN}"}
def query(prompt):
response = requests.post(API_URL, headers=headers, json={"inputs": [prompt]})
return response.json()
# Example usage
result = query("Ibihano by'ubujura ni ibihe?")
print(result["text"])
from huggingface_hub import InferenceClient
client = InferenceClient(token=YOUR_HF_TOKEN)
response = client.post(
"mugwaneza/mbaza-model",
json={"inputs": ["Kwinjira aho umuntu atuye bitemewe namategeko"]}
)
print(response)
curl -X POST \
-H "Authorization: Bearer YOUR_HF_TOKEN" \
-H "Content-Type: application/json" \
-d '{"inputs":["Mwaramutse neza"]}' \
https://api-inference.huggingface.co/models/mugwaneza/mbaza-model
// React Native / JavaScript
const API_URL = "https://api-inference.huggingface.co/models/mugwaneza/mbaza-model";
const HF_TOKEN = "your_token_here";
async function queryLegalAI(prompt) {
const response = await fetch(API_URL, {
method: "POST",
headers: {
"Authorization": `Bearer ${HF_TOKEN}`,
"Content-Type": "application/json"
},
body: JSON.stringify({ inputs: [prompt] })
});
return await response.json();
}
// Usage
const result = await queryLegalAI("What is the punishment for theft?");
console.log(result.text);
<?php
namespace App\Services;
use Illuminate\Support\Facades\Http;
class MbazaLegalAI
{
protected $apiUrl = 'https://api-inference.huggingface.co/models/mugwaneza/mbaza-model';
protected $token;
public function __construct()
{
$this->token = config('services.huggingface.token');
}
public function query($prompt, $userId = 'web_user')
{
$response = Http::withHeaders([
'Authorization' => "Bearer {$this->token}",
'Content-Type' => 'application/json'
])->post($this->apiUrl, [
'inputs' => [$prompt, $userId]
]);
return $response->json();
}
}
// Usage in Controller
$ai = new MbazaLegalAI();
$result = $ai->query("Ibihano by'ubujura ni ibihe?");
return response()->json($result);
# Kinyarwanda
query("Mwaramutse neza")
# Response: Mwaramutse neza, amakuru yawe?
# English
query("Good morning")
# Response: Good morning, how can I help you with legal matters?
# French
query("Bonjour")
# Response: Bonjour, comment puis-je vous aider?
# Kinyarwanda
query("Ibihano by'ubujura ni ibihe?")
# Returns: Punishment information for theft
# English
query("What are the laws about corruption in Rwanda?")
# Returns: Relevant legal articles on corruption
# Mixed
query("Kwinjira aho umuntu atuye bitemewe namategeko")
# Returns: Laws about trespassing and unauthorized entry
query("Igihano cy'umuntu wakubise undi")
# Returns: Punishment for assault
query("What is the penalty for fraud?")
# Returns: Detailed penalty information
{
"text": "Main response text (formatted for display)",
"intent": "greeting|law|punishment|fallback",
"laws": [
{
"article": "Article 166",
"description": "...",
"punishment": "...",
"similarity": 0.85
}
],
"punishments": [
{
"crime": "Theft",
"category": "Property crimes",
"penalty": "..."
}
]
}
The model uses the following datasets:
Legal Code Dataset (dataset-all.csv)
Penal Code (penal_code.csv)
Greetings (greetings.csv)
inference.py - Main inference endpointassistant.py - Core assistant logicretriever.py - Semantic search and embedding managementconfig.py - Configuration and utilitieslaw_embeddings.npy - Precomputed embeddings (384-dim vectors)law_meta.json - Metadata for legal articlesconversation_contexts.json - Context tracking storage# Clone the model repository
git clone https://huggingface.co/mugwaneza/mbaza-model
cd mbaza-model
# Install dependencies
pip install -r requirements.txt
# Test locally
python inference.py
For production with higher limits, consider:
MIT License - See LICENSE file for details
@misc{mbaza-legal-ai,
author = {Mugwaneza Manzi},
title = {Mbaza Legal AI: Multilingual Legal Assistant for Rwanda},
year = {2025},
publisher = {Hugging Face},
url = {https://huggingface.co/mugwaneza/mbaza-model}
}
For questions, issues, or collaboration:
Note: This model is designed for informational purposes. Always consult with a qualified legal professional for official legal advice.