Fine-Tuning Local Models with Docker Offload and Unsloth
Gemma 3 270M, a sub-1GB local model, can be fine-tuned with LoRA via Unsloth to mask personally identifiable information. Before fine-tuning it returned only "[PERSON]"; afterward it correctly redacted names, ID numbers and dates. The walkthrough runs the official Unsloth Docker image on a cloud NVIDIA L4 GPU through Docker Offload from a MacBook, with Mutagen syncing files back to the laptop. It then trains on the ai4privacy pii-masking-400k dataset in under 20 minutes, converts the result to GGUF with llama.cpp, and packages and pushes the roughly 518MB model to Docker Hub for use with Docker Model Runner.
Related posts
- LoRA Explained: Faster, More Efficient Fine-Tuning with Docker
Docker mediumAdeptGemma 3 270M can be specialized into a compact PII-masking assistant using LoRA, which freezes the base weights and trains only small low-rank adapters, cutting compute and memory needs while avoiding catastrophic forgetting. The walkthrough covers formatting supervised examples with the model's chat template so training data matches inference input, configuring PEFT adapters (r=16, alpha=32 on q_proj/v_proj), training with TRL's SFTConfig via Unsloth, and merging adapters into a standalone 16-bit checkpoint. The merged model can then be packaged and shared through Docker Model Runner and Docker Hub.
- Run Gemma 3 with Docker Model Runner: Fully Local GenAI Developer Experience
Docker mediumAdeptDocker Model Runner (in Docker Desktop for macOS 4.40.0+) exposes an OpenAI-compatible API on localhost, so Gemma 3 can be pulled with `docker model pull ai/gemma3` and called through the standard OpenAI SDK by pointing baseURL at http://localhost:12434/engines/v1. A sample Comment Processing System uses it to generate synthetic user feedback, categorize sentiment, cluster comments with mxbai-embed-large embeddings, extract feature ideas as JSON and draft support replies, all with no external API calls. Per-task temperature and token limits can be tuned freely because local inference carries no per-token cost or rate limit.
- Fine-Tuning Gemma Models in Hugging Face
Hugging Face mediumAdeptGemma 2B and 7B can be fine-tuned cheaply with LoRA via the Hugging Face PEFT library, loading the base model in 4-bit NF4 with bitsandbytes (QLoRA) so it fits on free Colab GPUs. A worked example adapts all linear projection layers (r=8) and trains with TRL's SFTTrainer on an English quotes dataset, teaching the model to emit a "Quote/Author" format in just 10 steps. For Cloud TPUs, transformers now supports PyTorch/XLA FSDP via SPMD, enabled by adding an fsdp_config that wraps GemmaDecoderLayer with xla_fsdp_v2 and gradient checkpointing.
- Run LLMs Locally with Docker: A Quickstart Guide to Model Runner
Docker mediumAdeptDocker Model Runner, in beta with Docker Desktop 4.40 on Apple silicon, pulls LLMs packaged as OCI artifacts and serves them through an OpenAI-compatible API backed by llama.cpp. Unlike `docker container run`, `docker model run` starts no container. The inference engine runs as a native host process for GPU acceleration, loads models on demand, and unloads them after 5 minutes of inactivity. Containers reach it at model-runner.docker.internal, and host processes can use an optional TCP port (12434), so any OpenAI client such as LangChain4j can point at it by setting a base URL and a model tag of the form {model}:{parameters}-{quantization}.
- Welcome Gemma - Google’s new open LLM
Hugging Face mediumAdeptGoogle's Gemma open LLM family ships in 2B and 7B sizes, each with base and instruction-tuned variants and an 8K context. On the Open LLM Leaderboard Gemma 7B scores 63.75, comparable to Mistral 7B, while Gemma 2B trails Phi-2. Hugging Face supports it through Transformers 4.38, including bfloat16 inference in about 18 GB, 4-bit loading in about 9 GB, and a ~4x speedup with torch.compile. Other integrations include JAX/Flax weights, Vertex AI/GKE and Inference Endpoints deployment via Text Generation Inference with an OpenAI-compatible Messages API, and a QLoRA fine-tuning recipe with TRL that takes about 9 hours on one A10G.