A newer version of the Gradio SDK is available:
6.5.1
metadata
title: UAE Knowledge System
emoji: π¦
colorFrom: green
colorTo: yellow
sdk: gradio
sdk_version: 5.0.0
app_file: app.py
pinned: false
short_description: Information Retrieval system for UAE governance and safety
thumbnail: https://librai-uae-kb.hf.space/assets/preview.png
UAE Knowledge System
An Information Retrieval (IR) system designed to retrieve relevant knowledge about the United Arab Emirates from a curated knowledge base.
This is NOT an LLM chatbot - it retrieves pre-written factual content intended to be used as RAG context.
Version
- Current Version: 2.4.0
- Last Updated: February 2026
- IR Performance: 69% Precision@1, 88% Recall@5, ~30ms latency on GPU
Features
- 8 knowledge categories covering UAE governance, leadership, and policies
- Multilingual support (English, Arabic, Chinese)
- Dense retrieval using BGE-M3 embeddings
- Real-time translation via DeepL
Architecture
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β HF Spaces / Local β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β app.py (Entry Point) β
β βββ uvicorn.run("backend.api:app") β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β βββββββββββββββββββββββ βββββββββββββββββββββββββββββββββββ β
β β Frontend (HTML) β β Backend (FastAPI) β β
β β β β β β
β β frontend/ βββββΆβ backend/api.py β β
β β βββ index.html β β βββ GET / β β
β β βββ css/styles.css β β βββ GET /api/stats β β
β β βββ js/app.js β β βββ POST /api/search β β
β β β β βββ POST /api/feedback β β
β β (Static files β β βββ POST /api/translate β β
β β served by FastAPI)β β β β
β βββββββββββββββββββββββ β backend/services.py β β
β β βββ get_retriever() β β
β β βββ search_knowledge_base() β β
β βββββββββββββββββββββββββββββββββββ β
β β β
β βΌ β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β IR Module (ir/) β β
β β β β
β β retriever.py ββββββΆ retrievers/dense.py (BGE-M3) β β
β β β β β β
β β βΌ βΌ β β
β β knowledge_base.py cache/dense_index/ β β
β β β βββ faiss_index_bge-m3.bin β β
β β βΌ βββ chunk_metadata_bge-m3.json β β
β β uae_knowledge_build/data/unified_KB/ β β
β β βββ entities.json (5000+ entities) β β
β β βββ alias_index.json β β
β β βββ sensitive_topics.json β β
β β βββ category_metadata.json β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Project Structure
hf_uae_demo/
βββ app.py # Entry point (starts FastAPI server)
βββ requirements.txt # Python dependencies
βββ README.md # This file
β
βββ backend/ # FastAPI backend
β βββ __init__.py
β βββ api.py # API endpoints & version info
β βββ services.py # Retriever initialization
β
βββ frontend/ # Static frontend (served by FastAPI)
β βββ index.html # Main HTML (version in help modal)
β βββ css/styles.css # Styles
β βββ js/app.js # JavaScript (TRANSLATIONS object)
β βββ assets/ # Images (falcon.png, background.jpg)
β
βββ ir/ # Information Retrieval module
β βββ __init__.py
β βββ retriever.py # Main retriever interface
β βββ knowledge_base.py # KB loader
β βββ models.py # Data models
β βββ normalizer.py # Text normalization
β βββ sensitive_detector.py # Sensitivity detection
β βββ sheets_storage.py # Google Sheets feedback storage
β βββ retrievers/ # Retriever implementations
β β βββ dense.py # BGE-M3 dense retrieval (Level 4)
β β βββ bm25.py # BM25 keyword retrieval
β β βββ alias.py # Alias matching
β β βββ hybrid.py # Hybrid retrieval
β βββ cache/dense_index/ # FAISS index cache
β βββ faiss_index_bge-m3.bin
β βββ chunk_metadata_bge-m3.json
β
βββ uae_knowledge_build/data/unified_KB/ # Knowledge base
β βββ entities.json # Main entity data
β βββ alias_index.json # Entity aliases
β βββ sensitive_topics.json # Sensitivity info
β βββ category_metadata.json # Category metadata
β
βββ data/ # User feedback storage
βββ feedback.json
βββ ratings.json
βββ translations_cache.json
Update Guide
When updating Knowledge Base (unified_KB)
- Build new KB in
libra_shield/uae_knowledge_build/ - Copy KB files to
hf_uae_demo/uae_knowledge_build/data/unified_KB/ - Rebuild FAISS index on GPU (Spartan HPC):
python -m ir.evaluate_dense --model bge-m3 --save-index ir/cache/dense_index --debug - Copy index files to
hf_uae_demo/ir/cache/dense_index/
When updating Version Info
Files to update (in order of importance):
| File | What to update |
|---|---|
frontend/js/app.js |
TRANSLATIONS object (EN/AR/CN): helpDataText, helpIRText, helpVersion |
frontend/index.html |
Help modal content, footer copyright |
backend/api.py |
FastAPI version parameter |
Important: app.js TRANSLATIONS override index.html content at runtime via updateHelpModal(). Always update app.js first!
Version checklist
When releasing a new version, update these locations:
-
frontend/js/app.jsline 3:Version: X.X.X -
frontend/js/app.jsTRANSLATIONS.en.helpVersion -
frontend/js/app.jsTRANSLATIONS.en.helpDataText (Last updated date) -
frontend/js/app.jsTRANSLATIONS.en.helpIRText (Performance metrics) -
frontend/js/app.jsTRANSLATIONS.ar.helpVersion, helpDataText, helpIRText -
frontend/js/app.jsTRANSLATIONS.cn.helpVersion, helpDataText, helpIRText -
frontend/index.htmlline 240: Version in help modal -
frontend/index.htmlline 250: Footer copyright year -
backend/api.pyline 60: FastAPI version
Local Development
# Activate conda environment
conda activate libra_shield
# Run the server
cd hf_uae_demo
python app.py
# Open in browser
open http://localhost:7860
Deployment (HuggingFace Spaces)
cd hf_uae_demo
git add .
git commit -m "Update to vX.X.X"
git push
Powered by LibrAI