Logo Lanfrica
  • Home
  • Atlas
  • Insights
  • Docs
  • Sign in

Β© 2026 Lanfrica. All rights reserved. All copyrights of the resources shown on the Lanfrica website belong to the original copyright holders, unless explicitly stated otherwise.

khair-eddine-ladhari/ai-tunisian-law-assistant

Domain:

natural language processing

Record type:

software
Creator:
kha
Host:
πŸ‡ΉπŸ‡³ AI-powered Q&A chatbot for the Tunisian Constitution using RAG (Pinecone + HuggingFace + Groq LLaMA 3) # πŸ‡ΉπŸ‡³ Tunisian Constitution Assistant A **Retrieval-Augmented Generation (RAG)** chatbot that answers questions about the **Tunisian Constitution** with precise, cited responses. Built with semantic search over the official constitutional text, the assistant grounds every answer in the exact article it comes from β€” reducing hallucination and giving users verifiable, trustworthy information about their legal rights and government structure. πŸ”— **Live demo:** Hugging Face Space --- ## ✨ Features - **Article-accurate citations** β€” every answer references the specific constitutional article it's based on (e.g. *"According to Article 40..."*) - **Strict grounding** β€” the model answers *only* from retrieved context and explicitly says when information isn't covered, instead of hallucinating - **Multilingual** β€” understands and responds in Arabic, French, and English - **Multi-article reasoning** β€” combines and explains multiple relevant articles when a question touches several provisions - **Semantic search** β€” retrieves relevant articles by meaning, not just keyword matching - **Resilient** β€” automatic retries with exponential backoff for transient API/network failures - **Token-safe** β€” pre-checks prompt size to avoid oversized requests - **Clean chat UI** β€” ChatGPT/Claude-style interface built with Gradio --- ## πŸ—οΈ Architecture ``` β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ PDF of │────▢│ Chunking by │────▢│ Embedding with β”‚ β”‚ Constitution β”‚ β”‚ Article number β”‚ β”‚ all-MiniLM-L6-v2 β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β–Ό β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Pinecone Vector β”‚ β”‚ Index β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ User question ──▢ Embed question ──▢ Semantic search β”€β”€β”€β”˜ β”‚ β–Ό Top-k articles (score > 0.45) β”‚ β–Ό β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Llama 3.3 70B (via Groq API) β”‚ β”‚ + strict system prompt β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β–Ό Cited, grounded answer (Gradio chat interfac …

Visit

github.com