A fine-tuned LLM system that recommends optimal credit cards for specific transactions based on rewards, APR, and other factors.
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.
- 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
| 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 |
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:
- Hugging Face API token with access to required models
- Modal cloud account configured with GPU access
- Python 3.8+ with required dependencies
# Create .env file with Hugging Face token echo "HUGGING_FACE_TOKEN=your_token_here" > .env # Run the script modal run capitalx.py
| 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 |
{
"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."
}
- 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
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.
For questions or contributions, please open an issue in the repository.