A complete, beginner-friendly system for fine-tuning models compatible with Ollama using datasets in JSON, CSV, or Excel format.
- π€ Model Selection: Choose from popular models (LLaMA2, Mistral, Phi, etc.)
- π Multi-Format Support: Upload JSON, CSV, or Excel datasets
- βοΈ Easy Configuration: Interactive column mapping and parameter tuning
- π₯ Efficient Training: Uses Unsloth for fast, memory-efficient fine-tuning
- π Ollama Integration: Automatic model deployment to Ollama
- π₯οΈ Dual Interface: Both CLI and web-based interfaces
- π§ͺ Built-in Testing: Test your models with custom prompts
-
Install Ollama (if not already installed):
curl -fsSL https://ollama.com/install.sh | sh ollama serve # Start Ollama server
-
Clone and setup FineTune:
git clone <your-repo-url> cd FineTune pip install -r requirements.txt
streamlit run finetune_app.pyThen open your browser to http://localhost:8501 and follow the guided interface!
python finetune_cli.pyFollow the interactive prompts to:
- Select your dataset
- Configure column mappings
- Choose a model
- Start training
- Deploy to Ollama
Your dataset can be in any of these formats:
[
{
"question": "What is AI?",
"answer": "AI stands for Artificial Intelligence..."
},
{
"question": "How does ML work?",
"answer": "Machine Learning works by..."
}
]prompt,response
"Hello, how are you?","I'm doing well, thank you!"
"What's the weather like?","I don't have access to current weather data..."Create an Excel file with columns like:
Task|Context|Expected_OutputInput|TargetQuestion|Answer
Choose from these pre-configured models:
- LLaMA 2 7B - General purpose, good balance
- Mistral 7B - Fast and efficient
- Phi 3 Mini - Lightweight, great for beginners
- Code Llama 7B - Specialized for code
- Gemma 7B - Google's efficient model
Basic Settings (good defaults provided):
- Max steps: 60 (adjust based on dataset size)
- Learning rate: 2e-4
- Batch size: 2 (increase if you have more GPU memory)
Advanced Settings:
- LoRA rank: 16 (higher = more parameters, longer training)
- Sequence length: 2048 tokens
Training will:
- Process your dataset into the correct format
- Load the model with LoRA adapters
- Train efficiently using Unsloth
- Save the fine-tuned model
Training Time Estimates:
- Small dataset (100 examples): ~5-10 minutes
- Medium dataset (1000 examples): ~30-60 minutes
- Large dataset (10000 examples): ~2-5 hours
The system will:
- Generate a Modelfile for Ollama
- Register your model with Ollama
- Make it available for chat/API use
# Test with CLI
python test_model.py --model your-model-name --interactive
# Test with Ollama directly
ollama run your-model-name "Hello, how are you?"The project includes sample datasets in the datasets/ folder:
sample_qa.json- Question & Answer pairssample_chat.csv- Conversational responsessample_instruction.xlsx- Task-based instructions
Use these to test the system before using your own data!
# Interactive mode
python finetune_cli.py
# Test a deployed model
python test_model.py --model custom-llama2 --prompt "Hello!"
# Compare multiple models
python test_model.py --compare model1 model2 --file test_prompts.json
# Benchmark performance
python test_model.py --model custom-llama2 --benchmarkEdit config.yaml to customize:
- Default training parameters
- Supported models list
- File paths
- Ollama settings
For multi-column inputs, use templates:
"Question: {question} Context: {context}"
This combines multiple columns into a single input.
1. CUDA Out of Memory
- Reduce batch size to 1
- Enable 4-bit loading
- Use a smaller model (Phi 3 Mini)
2. Ollama Connection Failed
- Make sure Ollama is running:
ollama serve - Check if port 11434 is available
- Try restarting Ollama
3. Training Too Slow
- Use fewer training steps
- Increase batch size (if memory allows)
- Try gradient accumulation
4. Poor Model Performance
- Increase training steps
- Use more/better training data
- Try different learning rates
- Ensure data quality
- Check the example datasets for formatting
- Review the configuration in
config.yaml - Use the web interface for guided setup
- Test with small datasets first
FineTune/
βββ src/ # Core modules
β βββ config.py # Configuration management
β βββ dataset_processor.py # Dataset handling
β βββ model_manager.py # Model loading/management
β βββ trainer.py # Training engine (Unsloth)
β βββ ollama_integration.py # Ollama deployment
βββ datasets/ # Sample datasets
βββ models/ # Downloaded models
βββ outputs/ # Training outputs
βββ config.yaml # Main configuration
βββ finetune_app.py # Streamlit web interface
βββ finetune_cli.py # Command line interface
βββ test_model.py # Model testing script
βββ test_prompts.json # Sample test prompts
βββ requirements.txt # Dependencies
βββ README.md # This file
Contributions welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is open source and available under the MIT License.
- Unsloth - For efficient fine-tuning
- Ollama - For local model deployment
- Hugging Face - For model ecosystem
- Streamlit - For the web interface
Happy Fine-tuning! π
Need help? Check the examples, try the web interface, or create an issue on GitHub.