Gaju19's picture
Update README.md
1d18078 verified
|
Raw
History Blame Contribute Delete
5.7 kB
---
title: MiniCPM Financial RAG
sdk: gradio
sdk_version: 5.34.0
python_version: "3.11"
app_file: app.py
pinned: false
tags:
- track:backyard
- sponsor:openbmb
- sponsor:modal
- achievement:offbrand
- achievement:fieldnotes
---
# πŸ’° MiniCPM Financial RAG
### πŸ“Š Financial Document Intelligence Powered by Retrieval-Augmented Generation
**Real-world Problem**
Financial reports, insurance documents, annual reports, SEC filings, balance sheets, and investment documents often contain hundreds of pages of complex information.
Finding specific financial insights manually is time-consuming and error-prone.
**MiniCPM Financial RAG** enables users to upload financial PDF documents and ask questions in natural language. The system retrieves the most relevant information from the document and generates accurate, context-aware answers using MiniCPM models.
---
## Build Small Hackathon Submission
Space:
https://huggingface.co/spaces/build-small-hackathon/MiniCPM_Financial_RAG
Demo:
https://youtu.be/0z1i5ESbgYk
Social:
https://x.com/gajanand2004/status/2066422082725163265
Article:
https://huggingface.co/blog/build-small-hackathon/minicpm-financial-rag
---
## πŸ‘₯ Team
| Name | Hugging Face Username |
|------|----------------------|
| Gajanan Deshmukh | Gaju19 |
---
## RAG architecture
![kids-education-ai](./Architecture.png)
# πŸ€– Models Used
| Task | Model | Parameters | Purpose |
|------|--------|------------|---------|
| Financial Question Answering | openbmb/MiniCPM-2B-128K | 2B | Financial reasoning and answer generation |
| Embedding Generation | openbmb/MiniCPM-Embedding-Light | Lightweight | Semantic retrieval and vector search |
---
# 🧠 Why MiniCPM?
| Model | Benefits |
|---------|----------|
| MiniCPM-2B-128K | Lightweight, fast inference, long-context understanding |
| MiniCPM-Embedding-Light | Efficient embeddings with strong retrieval performance |
---
# πŸš€ Features
| Feature | Description |
|----------|-------------|
| πŸ“„ PDF Upload | Upload financial reports and PDF documents |
| βœ‚οΈ Smart Chunking | Automatically split documents into meaningful chunks |
| πŸ”Ž Semantic Search | Retrieve the most relevant financial information |
| 🧠 Financial Question Answering | Ask questions in natural language |
| πŸ“š Retrieval-Augmented Generation | Generate context-grounded answers |
| ⚑ GPU Acceleration | Fast inference using Modal GPU infrastructure |
| πŸ“Š Financial Analysis | Analyze revenue, expenses, assets, and liabilities |
| 🎯 High Accuracy Retrieval | FAISS-based vector similarity search |
---
## 🎯 Example Questions
- What is the company's total revenue?
- What is the net income for this period?
- What are the major risk factors?
- Summarize the financial outlook.
- What liabilities are reported?
- What is the operating cash flow?
---
# πŸ“š Knowledge Pipeline
| Stage | Purpose |
|--------|----------|
| PDF Parsing | Extract text from PDF documents |
| Text Chunking | Break large documents into manageable sections |
| Embedding Generation | Convert text chunks into vector representations |
| FAISS Storage | Store vectors efficiently for retrieval |
| Similarity Search | Retrieve the most relevant document chunks |
| LLM Generation | Generate grounded answers from retrieved context |
---
# βš™οΈ Tech Stack
| Layer | Technology |
|--------|------------|
| Frontend | Gradio |
| Backend | Modal |
| LLM | MiniCPM-2B-128K |
| Embeddings | MiniCPM-Embedding-Light |
| Vector Database | FAISS |
| Framework | LangChain |
| PDF Processing | PyPDFLoader |
| Deep Learning | PyTorch |
| Deployment | Hugging Face Spaces |
---
# πŸ“ˆ Monitoring
The application is continuously monitored to ensure reliability and performance.
| Component | Monitoring Method |
|------------|------------------|
| Hugging Face Space | Build Logs & Runtime Logs |
| Modal Backend | Endpoint Monitoring |
| Retrieval Pipeline | Context Validation |
| Vector Search | Similarity Search Accuracy |
| Question Answering | Response Validation |
| System Health | Runtime Monitoring |
---
# 🌐 Deployment Architecture
```text
Hugging Face Spaces
β”‚
β–Ό
Gradio Frontend
β”‚
β–Ό
Modal Backend
β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”
β–Ό β–Ό
MiniCPM QA FAISS Retrieval
```
---
# πŸ“‚ Project Structure
```text
MiniCPM_Financial_RAG/
β”œβ”€β”€ app.py
β”‚
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ Architecture.png
└── README.md
```
---
# πŸ’» Installation
## Create Virtual Environment
```bash
python -m venv venv
```
## Activate Environment
### Windows
```bash
venv\Scripts\activate
```
### Linux / Mac
```bash
source venv/bin/activate
```
## Install Dependencies
```bash
pip install -r requirements.txt
```
---
# πŸš€ Run Application
```bash
python app.py
```
Application URL:
```text
http://localhost:8000
```
---
# 🎯 Target Users
| User Type | Use Case |
|------------|----------|
| Financial Analysts | Analyze reports and statements |
| Investors | Extract investment insights |
| Accountants | Review financial data quickly |
| Auditors | Validate financial information |
| Researchers | Analyze large financial documents |
| Students | Learn financial concepts interactively |
---
# πŸ“Š Benefits
| Benefit | Description |
|----------|-------------|
| Faster Analysis | Reduce manual document review time |
| Accurate Retrieval | Retrieve the most relevant financial information |
| Context-Aware Answers | Grounded responses from document content |
| Scalable Architecture | Handles large financial reports efficiently |
| Cost Effective | Uses lightweight MiniCPM models |
---