Spaces:
Sleeping
Sleeping
A newer version of the Gradio SDK is available:
6.4.0
OpenFinancial Chatbot - HF Space Trainer
This is a self-contained training script designed to run in a Hugging Face Space.
π Quick Setup Instructions
1. Create a New HF Space
- Go to https://huggingface.co/new-space
- Choose Gradio as the SDK
- Set hardware to CPU Basic (free) or T4 GPU (paid)
- Name it something like
openfinancial-trainer
2. Upload Files to Your Space
Upload these files to your HF Space:
hf_space_trainer.pyβ rename toapp.pyrequirements_hf_space.txtβ rename torequirements.txt- Your training CSV files (from the
trainingDatafolder)
3. Training Data Format
Your CSV should have columns like:
QuestionandAnswer, ORInputandOutput, ORPromptandResponse
The script will automatically detect the column names.
4. Start Training
- Wait for the space to build (2-3 minutes)
- Click "π Start Training"
- Monitor progress in real-time
- Training takes 15-30 minutes on CPU, 5-10 minutes on GPU
5. Download Your Model
After training completes:
- Go to your space's Files tab
- Download the entire
trained_modelfolder - Copy it to your local project
π― What This Does
- Loads your training data automatically
- Trains TinyLlama model for financial Q&A
- Saves model locally in the space
- Provides simple web interface
- Works on both CPU and GPU
π‘ Pro Tips
- Free Option: Use CPU Basic (slower but free)
- Fast Option: Use T4 GPU (~$0.60/hour, much faster)
- Multiple Files: Script tries common CSV names automatically
- Resume Training: Refresh status to see if training completed
π Expected Output
After training, you'll have a trained_model folder containing:
config.json- Model configurationpytorch_model.bin- Trained weightstokenizer.json- Tokenizer files- Other supporting files
Copy this folder to your local backend directory and use it with your chatbot!