Logo Lanfrica

deji445/ai_10022300187

Domain:

socioeconomic

Record type:

software
Creator:
dej
Host:
A Retrieval-Augmented Generation (RAG) AI assistant for analyzing Ghana election results and budget data using hybrid retrieval and domain-specific scoring. # πŸ“Š RAG-Based AI Assistant for Ghana Election & Budget Analysis ## Project Overview This project implements a **Retrieval-Augmented Generation (RAG) AI assistant** that answers questions based on: * Ghana Election Results (CSV) * 2025 Budget Statement (PDF) The system retrieves relevant data and uses a Large Language Model (LLM) to generate **accurate, context-grounded responses**. --- ## Objectives * Build a **manual RAG pipeline** (no LangChain or pre-built frameworks) * Improve retrieval accuracy using: * Hybrid search * Query expansion * Domain-specific scoring * Reduce hallucination through structured prompting * Provide explainable outputs with retrieved context --- ## System Architecture ``` User Query ↓ Query Expansion ↓ Embedding Model ↓ Hybrid Retrieval (Vector + Keyword) ↓ Reranking (Domain-Specific Scoring) ↓ Top-K Relevant Chunks ↓ Prompt Builder ↓ LLM (OpenAI / Gemini) ↓ Final Answer (Streamlit UI) ``` --- ## Features ### Hybrid Retrieval * Combines: * FAISS vector similarity * Keyword matching * Improves both semantic and exact-match retrieval --- ### Query Expansion * Expands queries using synonyms * Example: * "winner" β†’ "won", "victor" * Improves performance on paraphrased questions --- ### Domain-Specific Reranking ⭐ * Boosts relevance using: * Vote percentage * Region matching * Year matching * Ensures correct identification of election winners --- ### Post-Processing Reasoning (Innovation) ⭐ * Automatically identifies the **top candidate** based on votes * Injects structured hint into prompt * Improves answer consistency and accuracy --- ### Multi-LLM Support Supports: * OpenAI (GPT models) * Google Gemini Switch using environment variables. --- ## Project Structure ``` project/ β”‚ β”œβ”€β”€ data/ β”‚ β”œβ”€β”€ Ghana_Election_Result.csv β”‚ └── 2025-Budget-Statement.pdf β”‚ β”œβ”€β”€ src/ β”‚ β”œβ”€β”€ data_loader.py β”‚ β”œβ”€β”€ chunking.py β”‚ β”œβ”€β”€ embedding.py β”‚ β”œβ”€β”€ retrieval.py β”‚ β”œβ”€β”€ pipeline.py β”‚ β”œβ”€β”€ prompt.py β”‚ └── llm. …