https://github.com/ajagtapdev/capitalx_model
Data + model for CapitalX using Modal and HF.
https://github.com/ajagtapdev/capitalx_model
Last synced: about 1 year ago
JSON representation
Data + model for CapitalX using Modal and HF.
- Host: GitHub
- URL: https://github.com/ajagtapdev/capitalx_model
- Owner: ajagtapdev
- Created: 2025-03-29T22:41:33.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2025-03-29T22:55:12.000Z (about 1 year ago)
- Last Synced: 2025-03-29T23:25:21.587Z (about 1 year ago)
- Language: Python
- Homepage:
- Size: 0 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
CapitalX Credit Card Recommendation System
A fine-tuned LLM system that recommends optimal credit cards for specific transactions based on rewards, APR, and other factors.
📋 Overview
This system employs Parameter-Efficient Fine-Tuning (PEFT) to adapt foundation models for intelligent credit card recommendations, analyzing transaction details against multiple card options to maximize customer benefits.
🏗️ Architecture
-
Base Model: meta-llama/Meta-Llama-3-70B (70B parameter language model)
-
Distributed Training: Modal cloud with DeepSpeed ZeRO-3 optimization
-
Memory Optimization: QLoRA (Quantized Low-Rank Adaptation) with 4-bit quantization
-
Hardware Requirements: 8x H100 GPUs for training, 1x H100 for inference
⚙️ Technical Details
Training Configuration
Parameter
Value
Learning Rate
5e-6
Training Epochs
2
LoRA Rank (r)
16
LoRA Alpha
32
Batch Size Per Device
2
Gradient Accumulation Steps
4
Data Processing
Each training example follows a standardized instruction format:
You are a credit card recommendation assistant. Analyze the cards and transaction, then recommend the BEST card with a clear explanation.
Cards:
Freedom Flex: APR 15.0%, Credit Limit 5000, Rewards: base 1.0, dining 3.0%, groceries 5.0%
Sapphire Preferred: APR 18.0%, Credit Limit 10000, Rewards: base 1.0, travel 4.0%, dining 3.0%
Transaction:
Product: Dinner, Category: dining, Vendor: Restaurant, Price: 75.0
Output:
🚀 Implementation
Prerequisites
- Hugging Face API token with access to required models
- Modal cloud account configured with GPU access
- Python 3.8+ with required dependencies
Environment Setup
# Create .env file with Hugging Face token
echo "HUGGING_FACE_TOKEN=your_token_here" > .env
# Run the script
modal run capitalx.py
Command-line Options
Option
Description
--model_name
Specify a different base model (default: meta-llama/Meta-Llama-3-70B)
--test_auth
Test Hugging Face authentication only
--test_gpus
Test GPU setup and compatibility only
💡 Example Output
{
"test_case_1": "Best card: Freedom Flex. Explanation: Both cards offer the same 3% rewards on dining, but Freedom Flex has a lower APR (15.0% vs 18.0%), making it the better choice for this transaction.",
"test_case_2": "Best card: Freedom Flex. Explanation: Freedom Flex offers 5% cash back on groceries compared to no specific grocery rewards with Sapphire Preferred, resulting in $6.00 in rewards versus just $1.20 with the base rate."
}
🔍 System Workflow
-
GPU Testing: Validates CUDA availability and multi-GPU setup
-
Data Preprocessing: Formats training data with instruction prefixes
-
Model Loading: Initializes the base model with 4-bit quantization
-
Fine-Tuning: Applies LoRA to adapt the model using DeepSpeed ZeRO-3
-
Evaluation: Tests the trained model on sample credit card recommendation scenarios
-
Result Reporting: Displays recommendation results for validation
📝 License & Acknowledgements
This project uses the Meta-Llama-3-70B model from Meta under their model license. Please ensure you have proper access rights and comply with the model's usage terms.