Africa's First Al
# African AI v4.1 π
**Built by Africans Β· Powered by African Knowledge**
By Anaase-Tech | Founder/CEO: Y.A B3rima
## What is African AI?
A RAG (Retrieval-Augmented Generation) chatbot built specifically for African knowledge β languages, history, philosophy, culture, music, food, leaders, spirituality, and more.
π **Live Demo:**
b3rima1-african-ai.hf.space
---
## Project Structure
```
african-ai/
βββ app.py # Gradio UI + launch (entry point)
βββ config.py # API keys, paths, model names
βββ knowledge.py # LOCAL_TERMS, PROVERBS, DATASET_TOPICS
βββ language.py # detect_language(), strict v4.1 mode
βββ retrieval.py # Wikipedia fetch, ChromaDB, BM25, hybrid search
βββ respond.py # respond() β the full chat pipeline
βββ requirements.txt # Dependencies
```
## Architecture
```
User Query
β
Local Dictionary (56 African terms) β instant exact match
β (if no match)
Hybrid Retrieval
βββ BM25 keyword search (40%) β exact names, rare terms
βββ Vector search (60%) β semantic meaning
β
Reciprocal Rank Fusion β merges both rankings
β
Diversity filter β no duplicate titles
β
Groq LLaMA 3.1 (streaming) β grounded answer
β
Response with sources
```
## Key Features
- **4,251 knowledge chunks** across 14 African categories
- **Multilingual embeddings** β `intfloat/multilingual-e5-base` handles Twi, Swahili, Yoruba, Hausa, Zulu
- **Strict language detection** β defaults to English, only switches on explicit request
- **Historical figures** skip local dict β use rich Wikipedia chunks instead
- **Exponential backoff** on Wikipedia fetches β near-zero skipped topics
- **Mobile-first UI** β designed for Samsung A04e, Pan-African gold/green theme
## v4.1 Fixes
- Language drift fixed β "Tell me about Kenya" no longer triggers Swahili mode
- NoneType crash fixed β `message=None` safely handled
- Fusion key collision fixed β MD5 hash replaces `doc[:120]`
- Diversity filter β same title can't fill all 3 result slots
- Exponential backoff β Wikiped β¦