Skip to content

About

A comprehensive Docker Compose project for training, customizing, and managing Ollama models

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Latest commit

ย 

History

34 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Ollama Model Training Guide

Documentation Test Validate License: MIT

๐ŸŒ English | Italiano

A comprehensive Docker Compose project for creating, customizing, and managing Ollama models. Everything you need to work with lightweight local language models in a containerized environment, from basic customization to advanced model management.

Buy Me A Coffee

โœจ Features

  • Docker Compose Setup: Easy-to-use containerized Ollama environment
  • ๐ŸŒ Chat Web UI: Modern web interface at http://localhost:8080
  • ๐Ÿง™ Modelfile Wizard: Guided model creation at http://localhost:8080/wizard
  • ๐Ÿ“Š Spreadsheet Converter: Convert Excel/CSV to JSONL training format
  • ๐Ÿ”„ Model Pulling UI: Pull models from Ollama library with real-time progress
  • ๐Ÿ“ Example Modelfiles: Pre-configured templates for common use cases
  • ๐Ÿ› ๏ธ Helper Scripts: Convenient automation for common tasks
  • ๐ŸŽจ Model Customization: Adjust parameters, prompts, and behavior
  • ๐Ÿ’พ Import/Export: Share and version control your custom models
  • โšก GPU Support: Optional NVIDIA GPU acceleration via make up-gpu
  • ๐Ÿ’ฟ Persistent Storage: Models survive container restarts

๐Ÿš€ Quick Start

New to Ollama? Read Essential Concepts first (5 min read).

git clone https://github.com/manzolo/ollama-model-train-guide.git
cd ollama-model-train-guide

make preflight      # 1. Check system requirements
make setup          # 2. Create .env and directories
make up             # 3. Start Ollama + Chat UI
make create-model   # 4. Create your first custom model (interactive)

Then pull a base model and start chatting:

docker compose exec ollama ollama pull llama3.2:1b
open http://localhost:8080

That's it! ๐ŸŽ‰

immagine immagine immagine immagine immagine immagine

๐Ÿ“– Documentation

Also browsable as a website at https://manzolo.github.io/ollama-model-train-guide/ (built with MkDocs from docs/).

Suggested reading order: start with Concepts, then follow the table top to bottom. Reference docs can be read as needed.

# Document What it covers
1 Essential Concepts โญ Models, Modelfiles, parameters, choosing a base model, which method to use โ€” start here
2 Installation Guide Prerequisites, setup, .env configuration, GPU support
3 Chat Web UI Web interface: chat, model management, converter, Modelfile wizard
4 Customization Guide System prompt vs few-shot vs fine-tuning โ€” pick the right method
5 Parameter Guide Copy-paste parameter presets and tuning advice (canonical reference)
6 Example Modelfiles Pre-configured templates: chatbot, code assistant, translator, support bot
7 Usage Guide Day-to-day CLI commands and model operations
8 Quick Reference Command cheat sheet and interactive menus
9 Personal Model Guide Build a personalized assistant that knows your own information
10 Dataset Training Example End-to-end example: build a support bot from a Q&A dataset
11 Fine-Tuning Guide Deep-dive: fine-tune externally (Unsloth/HF), export GGUF, import into Ollama
12 Modelfile Reference Complete Modelfile syntax reference
13 API Usage Guide Ollama REST API documentation
14 Deployment Guide Save, transfer, and deploy models between instances
15 Advanced Usage Templates, LoRA adapters, performance, monitoring, security
16 Troubleshooting Common issues and solutions

๐ŸŒ Web UI

make up starts a Flask web app alongside Ollama with three pages:

  • Chat: http://localhost:8080 โ€” chat with any installed model, pull new models with real-time progress, create/edit Modelfiles
  • Converter: http://localhost:8080/converter โ€” convert Excel/CSV spreadsheets to JSONL training data
  • Wizard: http://localhost:8080/wizard โ€” guided 6-step Modelfile creation: pick a use case, base model, personality, rules, and examples, then create the model in one click

See the Chat UI Guide for details. To run Ollama without the web UI, use make up-core.

๐Ÿ“ Project Structure

ollama-model-train-guide/
โ”œโ”€โ”€ docker-compose.yml      # Services: Ollama + Chat UI (profile "chat")
โ”œโ”€โ”€ docker-compose.gpu.yml  # NVIDIA GPU override (make up-gpu)
โ”œโ”€โ”€ .env                    # Ports, profiles, Ollama image tag
โ”œโ”€โ”€ Makefile                # Convenient commands
โ”œโ”€โ”€ LICENSE                 # MIT license
โ”œโ”€โ”€ chat/                   # Web UI application
โ”‚   โ”œโ”€โ”€ app.py             # Flask app (chat + converter + wizard)
โ”‚   โ””โ”€โ”€ templates/         # HTML templates
โ”œโ”€โ”€ models/
โ”‚   โ”œโ”€โ”€ examples/          # Pre-configured Modelfiles
โ”‚   โ”œโ”€โ”€ custom/            # Your custom Modelfiles
โ”‚   โ””โ”€โ”€ saved/             # Exported models
โ”œโ”€โ”€ data/
โ”‚   โ”œโ”€โ”€ gguf/             # External GGUF files
โ”‚   โ”œโ”€โ”€ adapters/         # LoRA adapters
โ”‚   โ””โ”€โ”€ training/         # Training datasets
โ”œโ”€โ”€ scripts/              # Helper scripts (shared library in scripts/lib/)
โ””โ”€โ”€ docs/                 # Documentation

๐ŸŽฏ Common Commands

Environment Management

make preflight          # Check system requirements
make setup              # Initial setup (creates .env)
make up                 # Start services (Ollama + Chat UI)
make up-core            # Start Ollama only (no web UI)
make up-gpu             # Start with NVIDIA GPU support
make down               # Stop services
make restart            # Restart all services
make logs               # View logs

Model Operations

make pull-base          # Pull common base models
make create-model       # Create custom model (interactive)
make chat               # Chat with a model (interactive)
make list-models        # List all models
make save-model         # Save model for deployment (interactive)
make deploy-model       # Deploy saved model (interactive)
make publish-model      # Publish model to external registry (interactive)
make backup-models      # Backup all custom models
make export-full        # Export model WITH weights to tar (interactive)
make import-full        # Import a full model archive (interactive)

Testing

make quick-test         # Quick end-to-end test
make test               # Run validation tests

๐ŸŒŸ Popular Use Cases

1. Chat with Models

Open http://localhost:8080, select a model, and start chatting โ€” or use make chat from the CLI. See the Chat UI Guide.

2. Create Custom Models

  • Wizard (easiest): open http://localhost:8080/wizard and follow the steps
  • Interactive CLI: make create-model and pick a template
  • From scratch: write a Modelfile in ./models/custom/my-model/ and run bash scripts/create-custom-model.sh my-model ./models/custom/my-model/Modelfile

See Example Modelfiles and the Modelfile Reference.

3. Pull Models with UI

Open http://localhost:8080, click "Manage Models", enter a name (e.g. llama3.2:1b), and watch real-time progress. Browse models at the Ollama Library.

4. Convert Spreadsheets to Training Data

Open http://localhost:8080/converter, upload an Excel/CSV file, map the question/answer columns, and download or save the JSONL. See Chat UI Guide - Converter.

5. Train with Your Own Data

Prepare a JSONL dataset (or use the converter), add MESSAGE examples to a Modelfile, create the model, and iterate. See the Dataset Training Example and, for real fine-tuning, the Fine-Tuning Guide.

๐Ÿ”ง Example: Creating a Custom Chatbot

# 1. Create a Modelfile
mkdir -p ./models/custom/my-bot
cat > ./models/custom/my-bot/Modelfile << 'EOF'
FROM llama3.2:1b

PARAMETER temperature 0.7
PARAMETER num_ctx 4096

SYSTEM """
You are a friendly customer service assistant for ACME Corp.
Be helpful, professional, and concise.
"""

MESSAGE user "What are your hours?"
MESSAGE assistant "We're open Monday-Friday, 9am-6pm EST."
EOF

# 2. Create the model
bash scripts/create-custom-model.sh my-bot ./models/custom/my-bot/Modelfile

# 3. Test it
docker compose exec ollama ollama run my-bot "Hello!"

# 4. Use in Web UI: open http://localhost:8080 and select "my-bot"

๐Ÿงช Testing

make quick-test                          # Quick end-to-end test
make test                                # Validation tests
bash scripts/test-techcorp-example.sh    # Test TechCorp dataset example

GitHub Actions automatically run tests on every push. See .github/workflows/README.md for CI/CD details.

๐Ÿšจ Troubleshooting

Having issues? Check the Troubleshooting Guide for solutions to service startup problems, model creation errors, API connection issues, performance problems, disk space, and GPU configuration.

๐ŸŽฎ GPU Support

Enable NVIDIA GPU acceleration for 5-10x faster inference:

# 1. Install the NVIDIA Container Toolkit (see installation guide)
# 2. Start with the GPU override
make up-gpu

This layers docker-compose.gpu.yml on top of the base compose file โ€” no editing of docker-compose.yml required. See Installation Guide - GPU Support.

๐Ÿ“š Additional Resources

๐Ÿค Contributing

Contributions are welcome! Add example Modelfiles, improve documentation, report issues, or suggest enhancements. All pull requests are automatically tested via GitHub Actions.

๐Ÿงน Cleanup

Remove all containers and volumes (deletes all models):

make clean

๐Ÿ“„ License

This project is released under the MIT License โ€” see LICENSE.


Get started now: make preflight && make setup && make up then open http://localhost:8080


๐Ÿง  Local AI Lab

Local AI Lab

This project is part of manzolo's Local AI Lab โ€” a family of self-hosted AI projects (LLM, voice, vision & documents) that share the same conventions and can be wired together through the shared local-ai-net Docker network.

Explore the whole family: topic:local-ai

About

A comprehensive Docker Compose project for training, customizing, and managing Ollama models

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages