I trained a Gemma 4 31B LoRA on my pre-AI writing (Mac vs Colab Blackwell)

By

Tagged: AI, Mac

I extracted 1,816 pre-2025 posts from git, compared a local M4 Pro 7B LoRA against a Colab Blackwell Gemma 4 31B LoRA, and wired it into my workflow.

I was reading on Twitter that people were using the Google AI subscription perks on Colab to train models on their own writing, including Kitze training a Gemma 4 31B LoRA on a 98 GB Blackwell GPU.

That got me thinking. Until late 2024 I wrote every single post on this blog myself.

In 2026 I started using coding agents to help me research, test commands, and draft posts. The technical facts were solid, and I already had a flavioify skill to strip out obvious AI clichés.

But the posts started to feel a bit too uniform.

I wanted to train a model on everything I wrote before AI entered my workflow, straight from my git history, so it could pick up my real style. And I wanted to compare two setups head to head: training a small 7B LoRA 100% locally on my Mac, versus training a Gemma 4 31B LoRA on a Colab G4 Blackwell GPU and bringing the adapter back to my Mac.

The harder question was not how to run a LoRA fine-tune. It was how I would actually use the outcome every day without breaking my workflow.

Why a style fine-tune should not write posts from scratch

Now, let’s say you fine-tune a local model on your old blog posts, and you ask it to write a brand-new post about a 2026 tool. What will it write? It will hallucinate APIs, invent flags, and write outdated code in your voice.

Even a 31B local fine-tune is not going to replace frontier agents like Claude, Codex, or Gemini for researching docs, running commands in a terminal, or inspecting a codebase.

What it is great at is being a style layer at the end of the pipeline.

Let the frontier agent do the real work: run the commands, take the screenshots, check the numbers, and write the factual draft. Then pass only the plain prose through a local LoRA CLI (flavio-voice) that rewrites it in your rhythm while keeping every code block, heading, table, and link byte-identical.

Then let the agent (or you) review the git diff to make sure no technical detail shifted.

First, I measured how my writing actually drifted

I ran a Python script against the last 2024 commit in this repo (d9ae267fdc, December 22, 2024) and compared all 1,816 pre-2025 posts against the 552 posts published in 2026.

Pulling straight from a late-2024 git commit guarantees none of my later AI-assisted edits are mixed into the baseline.

Here is what the numbers showed:

MetricPre-2025 (1,816 posts)2026 (552 posts)Difference
1-sentence paragraphs76.2%37.6%Cut in half
3+ sentence paragraphs6.4%23.9%3.7x denser
Avg sentences per paragraph1.341.95Much heavier blocks
Sentence length median13 words14 wordsNearly identical
Sentence length stdev19.21 words8.26 words2.3x less variety
I/my per 1,000 words16.457.26Dropped 2.3x
we/let's per 1,000 words10.131.53Dropped 6.6x
Questions (?) per 1,000 words1.720.47Dropped 3.7x
Exclamations (!) per 1,000 words0.690.04Dropped 17x
Semicolons (;) per 1,000 words0.040.225.5x higher

Two things jumped out immediately.

First, my old flavioify skill told agents that paragraphs should be “1 to 4 sentences”. In reality, 93.6% of my pre-2025 paragraphs are 1 or 2 sentences, and 76% are a single sentence!

Second, look at sentence starters. In 2026 drafts, imperative openers (Watch, Keep, Give, Ask, Put, Never, Start) jumped 6x to 16x. The drafts were barking orders at the reader.

Meanwhile, my real pre-2025 posts opened sentences with But 12x more, We 10x more, Or 7x more, and And 4.5x more. The n-gram diff also surfaced 2026 phrase crutches that barely existed in my archive: "the exact same" (222 hits vs 4), "walks through" (100 vs 0), "side by side" (94 vs 2), "if you'd rather" (70 vs 0), "watch out for" (69 vs 1), and "which is why" (55 vs 0).

The whole pipeline

Here’s how the training pipeline (both local Mac and Colab Blackwell) connects to my daily writing workflow on an M4 Pro with 48 GB RAM:

Pre-AI LoRA training and blog rewrite pipelinePre-2025 posts are extracted from git, segmented into prose chunks, paired with synthetic AI drafts, trained as a Gemma 4 31B LoRA on Colab G4 Blackwell, converted to MLX format, and wired into flavio-voice, agent skills, and Raycast.1. Training pipeline2. Daily writing workflow on Mac2. Daily writing workflow on MacGit snapshot2024-12-221,816 pre-AI postsMarkdown segmenter2,792 prose chunksSynthetic AIdegradation3 rotating AI stylesPost-isolated splits1,516 train / 100val / 34 blindColab G4 98 GBBlackwellGemma 4 31B UnslothQLoRAConvert PEFT to MLX234 MB adapter, 820tensorsFrontier agentwrites factual draftflavio-voice rewrite--in-placeGemma 4 31B 4-bitMLXgit diff + scan.py +code-unchanged.shDraft ready forreviewAny copied textRaycast scriptpbpaste to pbcopy

Step 1: Isolate prose so code blocks can never break

Before thinking about training, I built a strict Markdown segmenter (flavio_voice/markdown_chunks.py) in a small Python project at ~/dev/flavio-voice.

I never want a rewriter model touching YAML frontmatter, fenced code blocks, headings, tables, images, HTML tags, blockquotes, or bullet lists.

The segmenter splits any Markdown file into alternating protected and prose segments, grouping consecutive plain paragraphs into chunks of up to 240 words.

Joining the segments back together reproduces the original file byte-for-byte. I verified this roundtrip invariant on 200 posts in src/posts/ before generating any data.

At rewrite time, each chunk also goes through a validator (validate_rewrite). It checks that the output is not empty, did not get wrapped in a code fence, stayed within reasonable word-count bounds, kept every Markdown link URL verbatim, and kept at least 80% of inline code spans intact. If a chunk fails, the CLI retries once at a lower temperature (0.15), and if it still fails it keeps the original paragraph untouched.

Step 2: Why paired data beats raw pretraining

If you dump raw pre-2025 Markdown posts into continued pretraining, you do not get an editor. You get a model that rambles like a 2019 JavaScript tutorial and ignores editing instructions.

To make the outcome work as a rewriter, the training examples have to match the exact task you will run at inference time:

  • Input: a generic, AI-sounding version of a passage
  • Output: the exact original pre-2025 passage I wrote

To avoid training the model against a single monotonous template, I rotated every chunk across 3 different AI degradation prompts:

  1. Formal ChatGPT prose (dense 3-sentence paragraphs, passive voice, “It is important to note that”, semicolons)
  2. 2026 coding-agent prose (imperative stacks, “Not X. Y.” contrasts, “which is why”, “the exact same”, aphoristic closers)
  3. Dry documentation prose (uniform medium-length sentences, zero personal pronouns, no questions)

Here is one real training pair generated from an old Swift post:

INPUT:
This marks the inaugural installment of a new series dedicated to Swift
and iOS application development tutorials. A previous introductory Swift
series is archived [here](/tags/swift/), providing foundational material
for subsequent learning.

TARGET:
This is the first of a new series of Swift and iOS application
development tutorials I will write.

I did a Swift introductory series a few months back, and you can see
it [here](/tags/swift/).

Step 3: Run 1 — 100% local on my M4 Pro (Qwen2.5-7B MLX)

First I wanted to see how far I could get completely offline on my M4 Pro with zero cloud GPUs.

I generated 185 validated pairs (153 train, 20 valid, 12 test) locally using Ollama with gemma3:4b. One quick snag along the way: my first validator rejected 28% of synthetic pairs because I capped the length ratio at 1.85x. When gemma3:4b turns a tight 75-word Flavio paragraph into verbose ChatGPT prose, it easily hits 160 words (2.2x). Raising the synthetic upper bound to 2.65x fixed that immediately.

Then I trained a 16-layer rank-8 MLX LoRA on mlx-community/Qwen2.5-7B-Instruct-4bit (4.0 GB on disk, 11.5M trainable params, --mask-prompt enabled):

flavio-voice train --iters 200 --batch-size 2 --grad-accum 2 --lr 3e-5 --num-layers 16 --max-seq-length 1024

It ran at 44 to 52 tokens/second (~25 minutes total). Watching the validation curve showed why intermediate checkpoints matter:

IterationTrain lossValidation lossWhat happened
1n/a2.876Untrained base model
501.580 (iter 40)1.887Big drop in 50 steps
1001.2701.780Best checkpoint (promoted)
1501.011 (iter 140)1.849Starting to overfit
2000.5402.220Memorizing the 153 train pairs

The iter-100 adapter (46 MB) worked surprisingly well on style: it stripped em dashes, broke dense paragraphs into 1–2 sentence beats, and even picked up writing "3 pieces" instead of "three pieces" straight from my pre-2025 posts.

But 153 pairs on a 7B model had clear limits. On harder technical passages it occasionally flipped subtle details or dropped Markdown link URLs.

Step 4: Run 2 — Scaling up to Gemma 4 31B on a Colab G4 Blackwell

Next I used the colab CLI (google-colab-cli) to run the same idea at 10x scale on a Colab G4 GPU.

One honest hiccup: on Saturday evening, all four Colab GPU tiers (G4, H100, A100, L4) returned 503 Service Unavailable on /tun/m/assign, while a plain CPU session allocated in 3 seconds. Clearly the Twitter rush had saturated the GPU pool. I retried Sunday morning at 09:30 CET and landed a 98 GB NVIDIA RTX PRO 6000 Blackwell (CUDA 13.0, 236 GB disk) on the first try:

colab new -s flavio-voice --gpu G4

I extracted 2,792 candidate chunks from d9ae267fdc and split them strictly by post so train, val, and eval_blind have zero overlapping articles.

First, I ran Qwen/Qwen2.5-14B-Instruct in BF16 (batch_size=32) right on the Blackwell GPU to generate 1,650 validated pairs (1,516 train, 100 val, 34 blind eval) in about 20 minutes (~1.5 pairs/second, 83.5% accept rate).

Then I restarted the kernel for a clean 98 GB VRAM slate and fine-tuned google/gemma-4-31B-it using Unsloth 4-bit QLoRA (r=16, lora_alpha=32, response-only loss via train_on_responses_only, enable_thinking=False) for 2 epochs (190 steps, effective batch size 16):

StepTraining lossValidation loss
0n/a3.4555
401.28581.2994
801.19041.2296
1201.10251.2116
1601.09581.2010
1901.01671.2001

Validation loss dropped monotonically all the way to 1.2001 with zero overfitting in 15 minutes 49 seconds.

The entire Colab session (generating 1,650 pairs with a 14B model, training Gemma 4 31B for 2 epochs, and running 42 blind evaluations) cost 8.99 compute units (my balance moved from 2,463.05 to 2,454.06). I downloaded the 498 MB adapter and stopped the VM immediately with colab stop -s flavio-voice.

Head-to-head blind benchmark (20 unseen pre-2025 posts)

I ran all four setups on the same 20 unseen blind posts from eval_blind.jsonl (zero post overlap with training) and measured them with scan.py and the same style metrics:

Modelscan.py hits1-sent parasSents / paraI/we per 1kEm dashes / ;Link URLs keptInline code kept
Input (AI-degraded)4323.5%3.320.04 / 25100.0%100.0%
Real Flavio (ground truth)1174.1%1.3029.60 / 0100.0%100.0%
Local Qwen2.5-7B MLX LoRA (153 pairs)963.2%1.6930.70 / 085.7%100.0%
Base Gemma 4 31B (0-shot prompt)1035.6%1.748.30 / 0100.0%100.0%
Colab Gemma 4 31B LoRA (1,516 pairs)680.8%1.3223.80 / 0100.0%100.0%

The gap is obvious even before you read the text:

  • Base Gemma 4 31B with the same system prompt stayed stuck at 35.6% single-sentence paragraphs (1.74 sents/para) and only 8.3 I/we per 1,000 words. Prompting alone did not capture the cadence.
  • Local Qwen2.5-7B LoRA got much closer on rhythm (63.2% 1-sentence paras), but dropped 14.3% of Markdown link URLs on the blind set.
  • Colab Gemma 4 31B LoRA hit 1.32 sentences/paragraph (vs my real 1.30), cut scan.py hits from 43 to 6, restored I/we from 0.0 to 23.8/1k, and preserved 100% of link URLs and inline code spans.

Reading a real blind test item (src/posts/how-to-set-alias-shell.md) makes the difference even clearer.

Here is the AI-degraded input:

Assuming one has [VS Code](https://flaviocopes.com/vscode/) installed,
which provides the `code` command, it is important to note that if
`~/.bash_profile` does not exist, it can be created; in this scenario,
the shell will automatically recognize and utilize it. Alternatively,
the `~/.bashrc` file, if available, can also be used for configuration.

Local Qwen2.5-7B LoRA drifted on the meaning (telling the reader to install VS Code and flipping “otherwise”):

If you don't have it already, [install VS Code](https://flaviocopes.com/vscode/),
which comes with the `code` command.

If you don't have `~/.bash_profile`, create it. Otherwise, the shell will
automatically use it.

Now look at the Colab Gemma 4 31B LoRA output:

Assuming you have [VS Code](https://flaviocopes.com/vscode/) installed,
which gives you the `code` command.

If `~/.bash_profile` does not exist, you can create it. The shell will
automatically pick it up.

You can also use `~/.bashrc` if it exists.

Compare that to my actual pre-2025 post: "If ~/.bash_profile does not exist, you can create it, and the shell will pick it up. You can also use the ~/.bashrc file, if present." It even picked up "pick it up" without inventing anything.

Step 5: Bring the Colab Gemma 4 31B adapter back to my Mac (MLX)

I did not want to pay for cloud hosting or wait on a 62 GB BF16 merge just to run my adapter locally.

Because mlx-lm supports gemma4 natively and mlx-community/gemma-4-31b-it-4bit (17.18 GB) fits comfortably in my M4 Pro’s 48 GB memory, I wrote a 40-line converter (scripts/convert_peft_to_mlx.py) that maps all 820 HuggingFace PEFT tensors directly into MLX LoRA format (lora_A.T -> lora_a, lora_B.T -> lora_b, scale = 32 / 16 = 2.0, cast to bfloat16).

That turned the 498 MB Colab download into a 234 MB local MLX adapter in 2 seconds with zero retraining and zero merge loss.

Now flavio-voice defaults to Gemma 4 31B 4-bit + my Colab LoRA, with a --fast flag whenever I want the smaller Qwen2.5-7B MLX LoRA for instant turnaround:

Output of flavio-voice status and flavio-voice capabilities showing the Gemma 4 31B 4-bit base model, the ready MLX adapter, 1,650 dataset pairs from commit d9ae267fdc, and the rewrite commands

Here is flavio-voice rewrite --diff running locally on my M4 Pro against a real 2026 post (Use 1Password Developer Environments with Cursor):

Output of flavio-voice rewrite --diff running Gemma 4 31B locally on a real 2026 post, keeping frontmatter, headings, bullet lists, code blocks, and links untouched while rewriting dense prose into 1-2 sentence Flavio paragraphs

Step 6: Upgrade flavioify and wire it into my workflow + Raycast

Using the metrics from Step 1, I also updated my writing Agent Skill (flavioify) and its regex linter scan.py to flag the exact drift we measured:

  • Dense paragraph runs (3+ consecutive paragraphs with 3+ sentences) and file-level high-paragraph-density
  • low-personal-voice when a 400+ word post has fewer than 6 I/we pronouns per 1,000 words
  • Prose semicolons (;)
  • imperative-stack (3+ imperative sentence starters in a single paragraph)
  • The 2026 phrase crutches (walks through, watch out for, if you'd rather, the exact same, which is why, side by side, all three)

Running the updated scanner on that same 2026 post catches them right away:

Output of flavioify scan.py on 1password-cursor.md flagging low-personal-voice (4 I/we pronouns in 1533 words), walks through, watch out for, and two triplet hits

Then I connected flavio-voice into three places so I do not have to remember to invoke it:

  1. docs/blog-post-guide.md (the guide every agent reads before writing a post in this repo): after drafting and running scan.py, the agent runs flavio-voice rewrite src/posts/<slug>.md --in-place, inspects git diff, and verifies code blocks are unchanged.
  2. flavioify and /post skills: both the Write/Rewrite workflows and my publishing skill now include flavio-voice rewrite as a local pass.
  3. Raycast Script Command (~/dev/raycast-scripts/flavio-voice-clipboard.sh): for quick snippets outside an agent session, I copy any text, trigger “Rewrite Clipboard in Flavio’s Voice” in Raycast, and get the rewritten text straight back in the clipboard:
#!/bin/bash

# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Rewrite Clipboard in Flavio's Voice
# @raycast.mode silent

# Optional parameters:
# @raycast.packageName Writing
# @raycast.icon ✍️

set -euo pipefail

INPUT="$(pbpaste)"
if [ -z "${INPUT// /}" ]; then
  echo "Clipboard is empty"
  exit 1
fi

OUTPUT="$(printf '%s' "$INPUT" | /Users/flaviocopes/.local/bin/flavio-voice rewrite -)"
if [ -z "${OUTPUT// /}" ]; then
  echo "Rewrite returned empty output (clipboard unchanged)"
  exit 1
fi

printf '%s' "$OUTPUT" | pbcopy
echo "Rewrote clipboard in Flavio's voice"

Where the limits are

Even with Gemma 4 31B and 1,516 pairs, there are real boundaries:

  • Always review git diff. Because my pre-2025 posts are very personal, the 31B LoRA can occasionally inject extra personal color (like "I've used it for years") on a generic paragraph. Reviewing the diff catches that in seconds and keeps every claim honest.
  • 31B takes longer to load than 7B. Loading a 17 GB model on an M4 Pro takes a few seconds and runs slower per token than a 4 GB 7B model. For full blog drafts that tradeoff is completely worth it, and for quick one-line clipboard tweaks I kept --fast pointing at the 7B LoRA.
  • Voice cannot fix a hollow post. You still need real commands, real numbers, and real screenshots first, and only then run the style pass on top.

If you want to go deeper into how local models and training loops work under the hood, see How to build an LLM from scratch and AI fundamentals. If you want to build similar reusable workflows for Claude Code or Codex, check out How to write an Agent Skill.

Want me to talk about your product? You can sponsor this site.

Related posts about ai: