--- title: Financial_RAG emoji: 📘 colorFrom: blue colorTo: green sdk: gradio sdk_version: 6.1.0 app_file: app.py pinned: true --- # Financial RAG Question Answering System This project implements a **Retrieve–Rerank–Generate (RAG)** pipeline for financial question answering using the **FinQA dataset**. --- ## System Overview The pipeline works in three stages: 1. **Document Retrieval** - Options: **BM25**, **Dense embeddings (SentenceTransformer)**, **Hybrid** - FAISS is used for dense vector search. 2. **Reranking** - Cross-Encoder (**ms-marco-MiniLM-L-6-v2**) reranks the top documents for relevance. 3. **Answer Generation** - Uses **Groq Llama 3.3 (70B)** to generate answers based only on retrieved context. --- ## Features - Accurate financial question answering - Handles numeric and multi-step reasoning - Supports hybrid retrieval for best results - Lightweight FAISS index for fast semantic search - Optional BM25 for exact-match numeric queries --- ## Installation Install dependencies: ```bash pip install -r requirements.txt ``` --- ## Running Locally Paste in console ```bash python app.py ``` Open your browser at the local URL shown in the console (usually http://127.0.0.1:7860). --- ## Usage in the App 1. Enter your **Groq API Key** 2. Type your financial question 3. Choose a retrieval mode: `hybrid`, `bm25`, or `semantic` 4. Press **Ask** to get the answer and view the top retrieved documents