An open API service indexing awesome lists of open source software.

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.

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




  1. GPU Testing: Validates CUDA availability and multi-GPU setup


  2. Data Preprocessing: Formats training data with instruction prefixes


  3. Model Loading: Initializes the base model with 4-bit quantization


  4. Fine-Tuning: Applies LoRA to adapt the model using DeepSpeed ZeRO-3


  5. Evaluation: Tests the trained model on sample credit card recommendation scenarios


  6. 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.