MAGANA: The Hausa AI That Respects Culture
Inspiration
In the rapidly evolving world of Artificial Intelligence, African languages and cultures are often left behind. Most large language models are trained on Western data, leading to responses that are grammatically correct but culturally hollow. We realized that for an AI to truly serve the Hausa-speaking community—one of the largest in Africa—it needed more than just translation; it needed tarbiyya (good upbringing) and ladabi (respect).
We were inspired to build MAGANA (which means "speech" or "talk" in Hausa) to bridge this gap. We wanted an AI that doesn't just treat you as a "user," but recognizes you as an Elder (Baba/Mama) or a Peer (Aboki) and speaks with the wisdom of our ancestors through proverbs (Karin Magana).
What it does
MAGANA is a multimodal, culturally-aware AI assistant designed specifically for the Hausa language. It goes beyond simple text generation:
- Cultural Adaptation: MAGANA asks for your age and gender to dynamically adjust its honorifics. It addresses elders with "Ranka ya daɗe" and youths with "Abokina," ensuring every conversation strictly adheres to cultural norms of respect.
- Multimodal Interaction:
- Vision Mode (Mai Gani): Users can upload images, and MAGANA describes them in Hausa, identifying objects and cultural context.
- Voice Mode: Users can speak to MAGANA, and it replies with a natural-sounding Hausa voice (using unique voice profiles like Umar and Zainab).
- Document Analysis: Users can upload PDFs or Word documents, and MAGANA summarizes them into Hausa bullet points.
- Specialized Modes:
- Teacher Mode (Malam): Explains concepts simply using proverbs, acting as a wise tutor.
- Reasoning Mode (Tunani): Breaks down complex logic step-by-step (mataki-mataki) to help users solve problems.
- Web Search (Bincike): Fetches real-time information from the web to keep users updated.
How we built it
We built MAGANA using a modern, robust tech stack designed for speed and flexibility:
Backend: We used Python (Flask) to orchestrate the application logic. The core "Brain" is powered by Google's Gemini 1.5 Flash (preview), which offers superior multilingual understanding and a massive context window for handling documents.
- We implemented a custom
get_cultural_promptfunction that dynamically constructs the system prompt based on user metadata. - The core logic relies on a probabilistic determination of respect levels, which can be modeled as: $$ P(Respect) = \sum_{i=1}^{n} (w_i \cdot C_i) + \frac{\alpha}{Age_{user}} $$ Where $w$ is the cultural weight, $C$ represents context cues, and $\alpha$ is the age-normalizing factor.
- We implemented a custom
Frontend: The interface is built with HTML5 and TailwindCSS, featuring a "Glassmorphism" design that feels premium and modern. We used vanilla JavaScript to handle real-time audio recording (
MediaRecorderAPI) and dynamic DOM updates for a snappy experience on mobile devices.Voice & TTS: We integrated YarnGPT for high-quality Hausa Text-to-Speech, caching audio files on the server to reduce latency and API costs.
Deployment: The application is containerized and optimized for deployment on platforms like Vercel, using environment variables to securely manage API keys for Google and YarnGPT.
Challenges we ran into
- Cultural Nuance in AI: Getting the LLM to consistently use the correct honorifics was difficult. Initially, it would revert to standard, neutral Hausa. We had to engage in extensive Prompt Engineering, creating a rigid "Persona" structure that enforces a greeting rule and proverb usage in every turn.
- Audio Latency: Generating high-quality Hausa audio took time. We solved this by implementing an asynchronous "background fetch" on the frontend—text appears instantly, avoiding the feeling of lag, while the audio loads and plays automatically once ready.
- State Management: Managing different modes (Reasoning vs. Teacher vs. Vision) within a single session history was tricky. We implemented a
CONVERSATION_HISTORYdeque to manage context constraints while injecting specific "Task Instructions" for each mode dynamically.
Accomplishments that we're proud of
- Authentic Persona: We are incredibly proud of "Malam Magana." Reading the AI's responses feels like talking to a wise uncle in Kano. The automatic insertion of relevant proverbs (Karin Magana) adds a layer of depth that users love.
- Seamless Multimodality: Successfully integrating Image, Voice, and Document inputs into a single, cohesive chat interface without cluttering the UI.
- Educational Value: The "Reasoning Mode" actively helps students by showing the steps of logic, not just the answer, promoting learning over rote memorization.
What we learned
- Context is King: In AI, context isn't just previous messages; it's who the user is. By adding simple metadata (Age/Gender) to the system prompt, the quality of interaction improved by an order of magnitude.
- Hybrid AI Approaches: Combining live Web Search with a pre-trained LLM creates a much more useful assistant than an LLM alone.
- The Power of Simplicity: We learned that users don't need complex menus. A simple "Mode" switch (Teacher/Brain/Search) is enough to drastically change the utility of the tool for different use cases.
What's next for MAGANA
- Mobile App: We plan to wrap the web application into a Progressive Web App (PWA) or a native React Native application for better offline accessibility.
- Dialect Support: Hausa has many dialects (Sokoto, Kano, Katsina). We aim to fine-tune our models to understand and speak these specific variations.
- Community Contributions: functionality allows users to suggest better proverbs or corrections, creating a Reinforcement Learning from Human Feedback (RLHF) loop specific to Hausa culture.
Built With
- flask
- google-gemini
- html5
- javascript
- python
- request
- serper-api
- tailwindcss
- vercel
- yarngpt
Log in or sign up for Devpost to join the conversation.