Spaces:
Sleeping
Sleeping
A newer version of the Gradio SDK is available:
6.2.0
FinGPT Migration Guide
Overview
This document describes the migration from Google Gemini 2.5 Pro to FinGPT model for the FinRobot Forecaster application.
Changes Made
1. Dependencies Updated
- Removed:
google-generativeai>=0.3.0 - Added:
transformers>=4.30.0torch>=2.0.0accelerate>=0.20.0peft>=0.4.0bitsandbytes>=0.39.0
2. Model Configuration
- Old:
GEMINI_MODEL = "gemini-2.5-pro" - New:
FINGPT_MODEL_NAME = "Starfish55/fingpt-complete"
3. API Key Changes
- Old:
GOOGLE_API_KEYSenvironment variable - New:
HF_TOKENenvironment variable for Hugging Face access
4. Model Loading
- Old: Google Generative AI client initialization
- New: Hugging Face Transformers with BitsAndBytesConfig for memory efficiency
5. Inference Function
- Old:
genai.GenerativeModel.generate_content() - New:
model.generate()with custom tokenization and decoding
Environment Variables Required
For Hugging Face Spaces:
HF_TOKEN=your_hugging_face_token_here
FINNHUB_KEYS=your_finnhub_api_keys_here
RAPIDAPI_KEYS=your_rapidapi_keys_here
Model Features
FinGPT Advantages:
- Specialized for Finance: Trained specifically on financial data
- Open Source: No API rate limits or costs
- Memory Efficient: Uses 4-bit quantization
- Real-time Updates: Can be fine-tuned with latest financial data
Performance Considerations:
- Memory Usage: ~4-8GB GPU memory (with quantization)
- Inference Speed: Slower than API calls but more reliable
- Model Size: ~7B parameters (much smaller than Gemini)
Testing
Run the test script to verify the integration:
python test_fingpt_integration.py
Deployment Notes
- Hugging Face Spaces: Ensure
HF_TOKENis set in secrets - GPU Requirements: Requires GPU with at least 8GB VRAM
- Model Loading: First run may take longer due to model download
- Fallback: App will use mock responses if model fails to load
Troubleshooting
Common Issues:
- Out of Memory: Reduce
MAX_LENGTHor use CPU inference - Model Loading Fails: Check
HF_TOKENand internet connection - Slow Inference: Consider using smaller model or CPU inference
Debug Mode:
Set debug=True in the app launch to see detailed error messages.
Migration Benefits
- Cost Effective: No API costs for inference
- Privacy: Data stays local, no external API calls
- Reliability: No rate limits or API downtime
- Customization: Can fine-tune for specific financial tasks
- Transparency: Full control over model behavior
Next Steps
- Test the application with real financial data
- Fine-tune the model if needed for specific use cases
- Monitor performance and adjust parameters
- Consider implementing model caching for faster startup