Skip to content

Repository files navigation

# 💼 Financial Intelligence Platform ## 🤖 CAMEL-AI Multi-Agent System for Financial Analysis [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Python 3.11+](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/downloads/) [![CAMEL-AI](https://img.shields.io/badge/CAMEL--AI-Multi--Agent-orange.svg)](https://github.com/camel-ai/camel) [![ERNIE 4.5](https://img.shields.io/badge/ERNIE-4.5-blue.svg)](https://cloud.baidu.com/product/wenxinworkshop) [![React 18](https://img.shields.io/badge/react-18-61DAFB.svg)](https://reactjs.org/) ## 🏆 Built For - **CAMEL-AI Multi-Agent Hackathon 2025** - Multi-Agent Financial Intelligence System - **ERNIE & PaddlePaddle Challenge** - AI Document Analysis with ERNIE-4.5 ## 🎯 Overview **A production-ready multi-agent system** built with **CAMEL-AI** that orchestrates 7 specialized agents to provide intelligent financial document analysis, risk assessment, and real-time monitoring. ### 🤖 Multi-Agent Architecture This system uses **CAMEL-AI framework** to coordinate specialized agents that communicate and collaborate: 1. **Orchestrator Agent** - Task planning and multi-agent coordination 2. **Document Processor Agent** - OCR extraction with PaddleOCR 3. **Financial Analyst Agent** - Metric extraction with ERNIE-4.5 4. **Risk Assessor Agent** - Risk scoring and alert generation 5. **Knowledge Manager Agent** - RAG-powered Q&A 6. **News Monitor Agent** - Autonomous real-time surveillance 7. **Critic Agent** - Quality assurance and validation ### 🔥 Key Technologies - 🤖 **CAMEL-AI** - Multi-agent coordination and communication - 📸 **PaddleOCR** - Extract text, tables, and charts from PDFs/images - 🧠 **ERNIE 4.5** - Advanced financial analysis and insights - 💬 **RAG Q&A** - Semantic search with ChromaDB ## ✨ Features ✅ **Document Upload & Processing** - PDF, PNG, JPG support (up to 50MB) - PaddleOCR text extraction (95%+ accuracy) - Table and chart detection - Multi-page document handling ✅ **AI Analysis** - Risk assessment (HIGH/MEDIUM/LOW) - Sentiment analysis with VADER + ERNIE - Key metrics extraction (revenue, profit, EPS, etc.) - Executive summary generation ✅ **RAG-Powered Q&A** - Ask questions about uploaded documents - Context-aware answers with source citations - ChromaDB vector search - Response confidence scoring ✅ **Document Comparison** - Compare 2-5 documents side-by-side - AI-generated comparison insights - Risk and sentiment benchmarking ✅ **Real-time News Monitoring** - Track company mentions across sources - Multi-factor risk scoring - WebSocket alerts for high-risk events ✅ **Fine-tuned Models** - ERNIE-Financial (LoRA fine-tuned on 10K reports) - PaddleOCR-Financial (QLoRA for tables/charts) - Hosted on HuggingFace Hub ## 🏗️ Multi-Agent Architecture ``` ┌─────────────────────────────────────────────────────────────┐ │ ORCHESTRATOR AGENT │ │ (CAMEL-AI Task Planning & Coordination) │ │ • Decomposes user requests into subtasks │ │ • Assigns tasks to specialized agents │ │ • Manages dependencies and workflow │ └──────────────┬──────────────────────────────────────────────┘ │ ┌───────┴────────┐ │ │ ▼ ▼ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │ Document │ │ Financial │ │ Risk │ │ Processor │ │ Analyst │ │ Assessor │ │ (PaddleOCR) │ │ (ERNIE-4.5) │ │ Agent │ └──────┬───────┘ └──────┬───────┘ └──────┬───────┘ │ │ │ ▼ ▼ ▼ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │ Knowledge │ │ News │ │ Critic │ │ Manager │ │ Monitor │ │ Agent │ │ (RAG) │ │ Agent │ │ (QA) │ └──────────────┘ └──────────────┘ └──────────────┘ │ │ │ └─────────────────┴─────────────────┘ │ Agent Communication Hub (CAMEL BaseMessage) ``` ### Agent Communication Flow 1. **User Request** → Orchestrator Agent 2. **Orchestrator** decomposes task using CAMEL conversation 3. **Agents execute in parallel** where possible (respecting dependencies) 4. **Agents communicate** via CAMEL BaseMessage format 5. **Critic validates** all outputs for quality 6. **Orchestrator aggregates** results and returns final analysis See [CAMEL_INTEGRATION.md](CAMEL_INTEGRATION.md) for detailed implementation. ## 🚀 Quick Start ### Prerequisites - Python 3.11+ - Node.js 18+ - Git ### 1. Clone Repository ```bash git clone https://github.com/phunkie24/financial-intelligence-platform.git cd financial-intelligence-platform ``` ### 2. Backend Setup ```bash cd backend # Create virtual environment python -m venv venv source venv/bin/activate # Windows: venv\Scripts\activate # Install dependencies pip install -r requirements.txt # Configure environment cp .env.example .env # Edit .env and add your ERNIE API keys # Initialize database python -c "from utils.db_manager import DatabaseManager; DatabaseManager()" # Optional: Generate sample data python scripts/generate_sample_data.py # Start backend uvicorn app:app --reload --port 8001 ``` Backend will be available at: `http://localhost:8001` ### 3. Frontend Setup ```bash cd frontend # Install dependencies npm install # Start development server npm run dev ``` Frontend will be available at: `http://localhost:3000` ### 4. Access Application - **Frontend**: http://localhost:3000 - **Backend API**: http://localhost:8000/api/health - **API Docs**: http://localhost:8000/docs ## 🎓 Fine-tuning ### Train LoRA Model (ERNIE) ```bash cd backend/fine_tuning python lora_trainer.py ``` Trains ERNIE 4.5 on financial analysis tasks: - Risk assessment - Sentiment analysis - Metrics extraction ### Train QLoRA Model (PaddleOCR) ```bash cd backend/fine_tuning python qlora_trainer.py ``` Trains PaddleOCR-VL on financial documents: - Table extraction - Chart recognition - Financial terminology ### Upload to HuggingFace ```python from huggingface_hub import HfApi api = HfApi() api.upload_folder( folder_path="./models/ernie-financial-lora", repo_id="your-username/ernie-financial-lora", repo_type="model" ) ``` ## 🐳 Docker Deployment ```bash # Build and run docker-compose up -d # Access # Backend: http://localhost:8000 # Frontend: http://localhost:3000 ``` ## ☁️ Production Deployment ### Option 1: Railway (Backend) 1. Push code to GitHub 2. Connect Railway to your repo 3. Add environment variables 4. Deploy automatically ### Option 2: GitHub Pages (Frontend) ```bash cd frontend npm run deploy ``` Deploys to: `https://your-username.github.io/financial-intelligence-platform` ## 📊 API Documentation ### Key Endpoints **Document Management** ``` POST /api/documents/upload - Upload document GET /api/documents/{id}/analysis - Get analysis POST /api/documents/{id}/ask - Ask question (RAG) POST /api/documents/compare - Compare documents ``` **News Monitoring** (Existing) ``` GET /api/companies - List tracked companies GET /api/company/{name} - Company details GET /api/alerts - Get alerts ``` Full API docs: `http://localhost:8000/docs` ## 📁 Project Structure ``` financial-intelligence-platform/ ├── backend/ │ ├── app.py # Main FastAPI app │ ├── config.py # Configuration │ ├── requirements.txt # Dependencies │ ├── models/ # SQLAlchemy models │ ├── ai/ # ERNIE, RAG, prompts │ ├── ocr/ # PaddleOCR wrappers │ ├── fine_tuning/ # LoRA/QLoRA scripts │ └── utils/ # Database, helpers ├── frontend/ │ ├── src/ │ │ ├── App.jsx # Main app │ │ ├── pages/ # Route pages │ │ ├── components/ # React components │ │ └── services/ # API clients │ ├── package.json │ └── vite.config.js ├── docker-compose.yml ├── Dockerfile └── README.md ``` ## 🎬 Demo Video [Watch on YouTube](#) - 5-minute project walkthrough ## 🧪 Testing ```bash # Backend tests cd backend pytest # Frontend tests cd frontend npm test ``` ## 📈 Performance - **OCR Accuracy**: 95%+ on financial documents - **Analysis Speed**: < 10 seconds per document - **RAG Response Time**: < 2 seconds - **Supported Languages**: 20+ ## 🤝 Contributing Contributions welcome! Please: 1. Fork the repository 2. Create a feature branch 3. Make your changes 4. Submit a pull request ## 📄 License MIT License - see [LICENSE](LICENSE) file ## 🙏 Acknowledgments - **Baidu** - ERNIE 4.5 & PaddleOCR - **Unsloth** - Fast LoRA training - **LLaMA-Factory** - Fine-tuning framework - **ChromaDB** - Vector database - **Anthropic** - Claude for development assistance ## 📧 Contact - GitHub: [@phunkie24](https://github.com/phunkie24) - HuggingFace: [@phunkie24](https://huggingface.co/phunkie24) - Demo: [Live Demo](https://phunkie24.github.io/financial-intelligence-platform) --- **Built with ❤️ for CodeCraze & ERNIE Challenge 2025** 🏆 Winning both hackathons with ONE project! 🏆# Test

About

AI-Powered Financial Document Analysis with ERNIE 4.5 & PaddleOCR

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages