A web application for fine-tuning Large Language Models (LLMs) through an intuitive user interface. This application allows users to select models, prepare datasets, and configure fine-tuning parameters through a browser-based interface.
- Select and download pre-trained language models
- Upload and prepare training datasets
- Configure fine-tuning parameters
- Real-time training progress monitoring
- Validation dataset splitting
- Model inference through chat interface
- Browser-based user interface
- Real-time progress tracking
- Error handling and feedback
- Configurable model selection
- Python 3.8 or higher
- Node.js 14 or higher
- npm 6 or higher
- Sufficient disk space for model storage
- GPU acceleration (one of the following):
- NVIDIA GPU with CUDA support
- AMD GPU with ROCm support (Linux only)
- CPU-only (significantly slower)
- Minimum 8GB GPU memory for medium-sized models
- Clone the repository:
git clone https://github.com/v912485/llm-finetuner.git
cd llm-finetuner- Set up the backend:
cd backend
# Create and activate virtual environment
# On Linux/Mac:
python -m venv venv
source venv/bin/activate
# On Windows:
python -m venv venv
.\venv\Scripts\activate
# Install backend dependencies based on your GPU:
## For NVIDIA GPU:
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124
## For AMD GPU (ROCm, Linux only):
# First install ROCm following instructions at: https://rocm.docs.amd.com/en/latest/deploy/linux/quick_start.html
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/rocm6.3
## For CPU only:
pip install torch torchvision torchaudio
# Install other backend requirements
pip install flask flask-cors transformers tqdm scikit-learn- Set up the frontend:
cd ../frontend
npm install-
Always activate the virtual environment before running the backend:
cd backend # On Linux/Mac: source venv/bin/activate # On Windows: .\venv\Scripts\activate
-
To deactivate the virtual environment when you're done:
deactivate
-
To save your environment requirements:
pip freeze > requirements.txt -
To install from requirements.txt:
pip install -r requirements.txt
Models are configured in backend/config.json. The configuration file specifies available models and their requirements:
{
"models": [
{
"id": "model-name",
"name": "Display Name",
"size": "small|medium|large",
"description": "Model description",
"requirements": {
"min_gpu_memory": "4GB",
"recommended_batch_size": 4
}
}
]
}Add or remove models by editing this configuration file.
- Start the backend server:
cd backend
python app.py- In a new terminal, start the frontend development server:
cd frontend
npm start- Open your browser and navigate to
http://localhost:3000
-
Model Selection
- Choose from available pre-trained models
- Models are downloaded automatically when selected
- System checks for GPU memory requirements
-
Dataset Preparation
- Upload training data files
- Configure input/output field mappings
- Automatic validation split (configurable percentage)
-
Training Configuration
- Set learning rate
- Configure batch size
- Set number of epochs
- Adjust validation split ratio
-
Training Monitoring
- Real-time progress tracking
- Loss metrics visualization
- Validation performance monitoring
- GPU memory usage tracking
The application accepts the following file formats:
- JSON (.json)
- JSONL (.jsonl)
- CSV (.csv)
- Text (.txt)
Your training data should be structured as follows:
{
"instruction": "Classify the sentiment of this text",
"input": "This movie was absolutely fantastic!",
"output": "positive"
}Your CSV should include headers and contain at least these columns:
instruction,input,output
"Classify the sentiment of this text","This movie was absolutely fantastic!","positive"-
Data Cleaning
- Remove any duplicate entries
- Ensure consistent formatting
- Check for and handle missing values
-
Data Size
- Minimum recommended: 100 examples
- Optimal range: 1,000-10,000 examples
- Balance different classes/categories
-
Quality Control
- Verify instruction-output pairs are correct
- Ensure consistent output format
- Check for any data leakage
-
Memory Management
- Consider GPU memory limitations
- Adjust batch size based on model size
- Use validation split appropriately
-
backend/app.py- Main Flask applicationconfig.json- Model configurationdownloaded_models/- Storage for downloaded modelsdatasets/- Storage for uploaded datasetsdataset_configs/- Dataset configuration storagelogs/- Training logs
-
frontend/src/App.js- Main React componentChat.js- Chat interface componentApp.css- Main stylesChat.css- Chat interface styles
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the GPL 2 License - see the LICENSE file for details.
- Built with React and Flask
- Uses Hugging Face Transformers library
- PyTorch for model training
- Inspired by the need for accessible LLM fine-tuning tools
The application supports three training methods:
-
Full Fine-tuning
- Traditional fine-tuning of all model parameters
- Requires the most GPU memory
- Best for high-memory GPUs (8GB+)
-
LoRA (Low-Rank Adaptation)
- Fine-tunes low-rank matrices instead of full model
- Requires ~50% less memory
- Good for medium-memory GPUs (4-8GB)
-
QLoRA (Quantized LoRA)
- Combines 4-bit quantization with LoRA
- Requires ~75% less memory
- Works on low-memory GPUs (2-4GB)
pip install bitsandbytes peftFor gated models like Gemma, set your Hugging Face token:
# Linux/Mac:
export HUGGING_FACE_TOKEN="your_token_here"
# Windows:
set HUGGING_FACE_TOKEN=your_token_hereGet your token from: https://huggingface.co/settings/tokens