maximus-slm-local-finetune
Skill1 starsChanged 4 months agoMITView on GitHub
Fine-tune a small model on hardware you own and ship it to Ollama: decide whether to fine-tune at all, build the dataset, run LoRA/QLoRA with Unsloth (NVIDIA/AMD/Intel/Mac) or MLX-LM (Apple Silicon), evaluate against the base model, then merge, export GGUF, quantize, and create an Ollama model with the training chat template. Use for 'fine-tune locally', 'LoRA on my GPU', 'QLoRA', 'Unsloth', 'MLX fine-tune', 'export to GGUF', 'put my fine-tune in Ollama'.
In this repository49 other files it gives its agents.
- core/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- file-opsSkill
- maximus-agent-designSkill
- maximus-ai-cost-controlSkill
- maximus-ai-data-pipelineSkill
- maximus-ai-fluency-for-buildersSkill
- maximus-ai-product-specSkill
- maximus-ai-safety-governanceSkill
- maximus-ai-ux-patternsSkill
- maximus-brainSkill
- maximus-build-featureSkill
- maximus-chain-of-verificationSkill
- maximus-code-reviewSkill
- maximus-contact-intelligenceSkill
- maximus-counterparty-discoverySkill
- maximus-debug-incidentSkill
- maximus-deep-research-proSkill
- maximus-deep-researchSkill
- maximus-design-specSkill
- maximus-devops-shipSkill
- maximus-eval-and-testSkill
- maximus-fine-tuningSkill
- maximus-fintech-paymentsSkill
- maximus-investigative-researchSkill
- maximus-k3-model-selectionSkill
- maximus-k3-self-hostingSkill
- maximus-literature-reviewSkill
- maximus-llm-model-selectionSkill
- maximus-local-research-assistantSkill
- maximus-local-research-assistantSkill
- maximus-mlops-deploySkill
- maximus-ollama-opsSkill
- maximus-openclaw-localSkill
- maximus-people-finder-recruiterSkill
- maximus-people-finderSkill
- maximus-plan-implementationSkill
- maximus-prompt-engineeringSkill
- maximus-python-scientificSkill
- maximus-rag-pipelineSkill
- maximus-replit-handoff-proSkill
- maximus-slm-evalSkill
- maximus-slm-local-stackSkill
- maximus-slm-tool-callingSkill
- maximus-transaction-analystSkill
- maximus-write-articleSkill
- memory-keeperSkill
- skill-templateSkill
- web-researchSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 42
If any are false, stop and say which one.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Maximus — SLM Local Fine-Tune
Fine-tuning is the most expensive way to discover that you needed a better
prompt. When it is the right tool, doing it locally is now practical: a 7B
QLoRA fits in single-digit gigabytes. This skill makes you earn the fine-tune,
then carries it all the way into ollama run without losing the chat template
on the way.
Purpose
Produce a local fine-tune that measurably beats the base model on the user's task, packaged as an Ollama model, with the evaluation that proves it and a record of every setting needed to reproduce it.
Scope boundary
| Need | Skill |
| LoRA/QLoRA on your own box → GGUF → Ollama | this skill |
| Fine-tune vs RAG vs prompt decision in general; hosted FT APIs; DPO | maximus-fine-tuning |
| Dataset curation, labeling, leakage | maximus-ai-data-pipeline |
| Proving the tune is better | maximus-slm-eval |
| Serving the result | maximus-ollama-ops |
Earn it first
Fine-tune locally only if all three are true:
- A prompt plus retrieval has been tried and measured, and it falls short on format, style, or a narrow skill. Fine-tuning teaches behavior. It is a poor way to teach facts that change, which is what RAG is for.
- There are at least a few hundred clean examples of the target behavior, or a plan to make them.
- There is a held-out eval set (
maximus-slm-eval) and a baseline score.
If any are false, stop and say which one.
Core workflow
- Baseline. Score the base model on the held-out set with the exact prompt format you will train on.
- Pick the toolchain by hardware. Unsloth covers NVIDIA (CUDA capability
7.0+), AMD, Intel, and Mac. MLX-LM is native on Apple Silicon. Check VRAM
against the dated table in
references/(for example, Unsloth lists about 5 GB for 7B QLoRA and 19 GB for 7B 16-bit LoRA). - Build the dataset in the chat format of the target model. JSONL with
messages(system/user/assistant), or MLX'schat/tools/completions/textformats. Deduplicate, strip PII, split train/valid/test before looking at the results, and never let test prompts leak into train. - Train small first. QLoRA on a 3-8B model with a short run. Watch validation loss. If it rises while training loss falls, you are overfitting. On OOM, reduce batch size before anything else.
- Evaluate adapter vs base on the held-out set, same prompt, same decoding. No gain means no ship. Also re-run a few general prompts to catch collapse elsewhere.
- Merge and export. Unsloth:
save_pretrained_ggufwith a quantization method, which also writes a Modelfile carrying the training chat template. MLX:mlx_lm.fuse --export-ggufexports fp16 only, and only for Mistral, Mixtral, and Llama-style models. For other architectures, fuse to safetensors and convert with llama.cpp. - Quantize and import. Ollama does not quantize GGUF on import, so
quantize first (
llama-quantize ... Q4_K_M). Thenollama createfrom a Modelfile whoseTEMPLATEmatches the one used in training. - Re-evaluate the quantized Ollama build. Quantization can erase a thin fine-tune gain. The number that counts is the one from the model you will actually serve.
- Record it. Base model and revision, dataset hash, hyperparameters,
toolchain versions, quant method, and all eval scores, in a
TRAINING.mdnext to the Modelfile.
Anti-patterns
- Fine-tuning facts in. They go stale and hallucinate at the edges. Use RAG.
- Mismatched chat template at inference. Unsloth names this "the most common cause" of broken exports.
- Evaluating the fp16 adapter, shipping the Q4 GGUF.
- No held-out set. Then the claimed improvement is a hope.
- Training on the eval set by accident via near-duplicates. Deduplicate across splits.
- Assuming MLX exports any architecture to GGUF. It does not.
Output
Dataset splits with hashes, the training config, an eval table (base, adapter,
quantized Ollama build), the Modelfile, and TRAINING.md. If the tune did not
beat the base, the output is that finding.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

