Thoughts

Fine-tuning a model to beat GPTZero, and the variance problem that stalled it

← All thoughtsHomeAI markdown

Tutorbin has a Writing tools panel with /scan and /humanize. The humanize pass runs a draft through an LLM with a long rule list: cut em dashes, drop chatbot closers, kill template transitions, vary sentence length, keep the author’s meaning, do not add ideas the student did not write. It returns a rewritten version that reads noticeably less like a brochure.

Run that rewrite through GPTZero. Still 100% AI. Every time. The surface was never the problem. The detector is not reading the surface.

I wrote about the student side of this in ai-detection-writing. The conclusion there was simple: write first, model second. The detector follows that choice. For students, that is the whole answer.

This piece is the engineering counter-attempt. The question I could not leave alone: can you build a model that produces text the detector scores as human, without a human writing it first? On paper, fine-tuning was the only path that could. So I tried. The project stalled. Here is what I learned before it did.

Why fine-tuning was the only path

Off-the-shelf LLMs all produce text that detectors flag as 90 to 100 percent AI. I tested GPT-4o, Claude Opus, Mistral Small Creative, and a few local Ollama models with “write like Hemingway” prompts. Same floor every time.

The reason is structural. An LLM is a perplexity-minimizing machine. It picks the expected next token. Detectors measure exactly that property. No prompt changes the statistical signature, because the model is the signature.

Three paths exist in principle. Perturbation and padding, which degrades the text and is dishonest. Multi-variation generation with detector scoring, where you generate N and return the best. And fine-tuning against a detector, which is the only one that actually changes the underlying distribution.

I chose fine-tuning. Two stages: supervised fine-tuning on (AI, human) text pairs, then direct preference optimization against a detector score. The standard recipe.

Building the dataset, and the bug that taught the most

The dataset is the moat. I knew that going in. I did not know how many ways it could go wrong.

I started with my own ebook library and threw it out. Servbin and Vent Busters content is AI-touched, so it contaminates the human side. I needed outside sources: Project Gutenberg’s curated nonfiction bookshelf, 35 Wikipedia articles, and 994 essays from Ghostbuster (CC-BY-3.0, modern register). Public domain or permissive licensing, so the training output has no legal exposure.

The pipeline chunks each source into 300 to 500 word passages, scores every chunk with a local detector, drops anything that scores above 50 percent AI on the human side, then runs each surviving chunk through an LLM with a “rewrite this as a polished AI assistant” prompt. The output is a pair: AI text, human text.

The hard-won insight came at the AI-ify step. First version used rewrite mode. Ask the LLM to rewrite the human text in AI style. The AI side still scored human on GPTZero. The model preserves too much of the source’s perplexity distribution when it rewrites.

The fix was generate mode. Ask the LLM to produce fresh AI prose conveying the same facts. Different statistical signature. The AI side now scores 95 to 100 percent AI on manual GPTZero audits. Same length, same facts, completely fresh token distribution.

That distinction is the whole thing. A rewrite carries the source with it. A generation does not.

I ended with 6,134 training pairs. Most published humanizer work trains on 50k to 100k. I knew going in that 6k might not be enough. I went anyway to get the pipeline working before spending more on data.

The SFT run, and the bug that almost burned two hours of GPU time

Stage one was supervised fine-tuning on Mistral-Nemo-Instruct-2407, 12B, 4-bit QLoRA, on a rented A100 80GB at $1.60 an hour.

The framework churn nearly killed the run before it started. TRL changed its API three minor versions in a row: tokenizer= became processing_class=, max_seq_length= moved into SFTConfig, packing moved too. I pinned to TRL 0.21.0 with Unsloth 2026.7.2 and transformers 5.5.0, and that combo worked. The unsloth [cu121-bitsandbytes] extra name is broken, so I just installed unsloth.

The silent failure was the one to watch for. First real run, model loaded, training started, loss printed. Trainable parameters: 0 of 12,304,798,720. Training was doing nothing. SFTTrainer was stripping the LoRA somewhere in its init path. I added an assertion after get_peft_model that fails fast if trainable parameters is zero. Caught it before wasting two hours of GPU time. That check is in the recipe now.

Two other things worth saying out loud because they cost me time. Run training with python -u or PYTHONUNBUFFERED=1. Otherwise stdout buffers and you stare at a frozen log at step 8 of 384 wondering if the GPU is actually working. And don’t strip multi-megabyte prose with regex. I hit catastrophic backtracking on a 4.5MB Bible file and timed out the server. Switched to str.find("*** START OF") for slicing Gutenberg boilerplate. Worked instantly.

The run finished in 47 minutes 39 seconds. Final loss 2.234, down from around 2.5. The 234MB LoRA adapter saved clean. Total SFT cost: $1.28.

Run the SFT model through GPTZero

The model produces text that reads human. Smooth, varied, no brochure tone.

Run it through GPTZero. 100 percent AI. Every detector. Every temperature from 0.3 to 1.1.

The SFT loss going down did not mean the model was learning to avoid AI patterns. It meant the model was learning to match the training data’s style. SFT teaches style imitation, not detector evasion. The two are not the same thing, and the loss curve does not know the difference.

This is the part of the project I want to be honest about, because it is the part most writeups skip. SFT alone does not beat detectors. It produces fluent text that retains the AI statistical fingerprint. The fingerprint is what the detector measures. The fingerprint is what SFT cannot remove.

DPO is supposed to fix this. It needs variance the SFT model does not have

Stage two was the whole point. Direct preference optimization against a detector score. Generate two rewrites per input at different temperatures, score each, build preference triples, train the model to prefer the lower-scoring output. Shape the model against the detector’s actual signal.

DPO needs variance in the reward signal. Some outputs have to score better than others, or there is nothing to optimize against.

I tested 11 detectors against the SFT model’s outputs. roberta-base-openai-detector (which correlates 100 percent with GPTZero on human vs AI) scored all 10 rewrites at 1.000. desklib/ai-text-detector-v1.01 loaded with ignore_mismatched_sizes=True, which silently reinitialized the classifier head, so its scores were random noise around 0.5. Hello-SimpleAI/chatgpt-detector-roberta had variance, but it was a false positive: it gave 0 percent AI on text GPTZero flags as 100 percent AI. It does not correlate with GPTZero. Don’t trust it for DPO.

No working detector could distinguish between temperature variants of the SFT model’s rewrites. The SFT model had converged to a single statistical pattern. Fluent, but uniformly AI by every detector’s measure. There was no preference signal. DPO could not run.

That is where the project stalled. Not for lack of budget. Not for lack of detector access. For lack of variance in the thing DPO is supposed to shape.

The wall, and what it actually is

Two ways to frame the wall, and both are true.

One: the dataset is the moat. 6,134 pairs is well under what the published humanizer work uses. More data, more diverse data, might produce an SFT model with enough output variance for DPO to find signal. That is a real hypothesis. It is also a multi-week dataset effort with no guarantee the variance shows up at the end.

Two: the official detectors are a moving target, and validating against them across a full dataset was out of budget. GPTZero’s API would have cost around $1,500 to scan the 14 million words in the corpus. I leaned on the local RoBERTa for filtering and iteration, then audited 20 random chunks in GPTZero by hand. The local detector correlated with GPTZero on the human vs AI call, but it could not distinguish “more AI” from “less AI” inside the SFT model’s output range. The detector I could afford to run on 14 million words was not the detector I needed to run on 14 million words.

This is the asymmetry nobody talks about. The detector and the humanizer are the same problem run in opposite directions, and the detector has more signal than the humanizer has degrees of freedom. Detectors measure statistical shape. Humanizers can redecorate the shape. They cannot rebuild the frame the model built. Chasing a clean detector score on AI-generated text is a loop you lose, and the loop gets more expensive the closer you want to get to the official detector’s actual verdict.

Where this leaves us

The Tutorbin humanize tool still ships. It just stopped being sold as “beats detectors.” It removes AI tells from a draft, in the student’s own voice when they have calibration samples. That is a real and useful thing, and it is what the tool actually does. The UI says it plainly: writing-quality signals, not proof of AI authorship. The detector score is not what it is for.

Writerbin is paused. The SFT adapter works, the dataset pipeline works, the cost works. The piece that does not work is the SFT-then-DPO recipe as I implemented it on Mistral Nemo 12B. The four paths forward are documented in the project: DPO directly on the base model, redo SFT with higher temperature, switch to Llama 3.1 8B, or wait for new research. I have not picked one. The project is worth resuming when one of those premises changes. It is not worth resuming just to retry the same approach with minor tweaks.

The actual answer is the same one I keep arriving at. You do not need a better detector. You need the human to write first. The Tutorbin sessions that scored clean were not the ones who found a better humanizer. They wrote first, badly if they had to, and brought real sentences to the model instead of asking the model to produce them. The detector followed that choice. So did the quality of the paper.

I built a fine-tuning pipeline and a 12B model and a dataset pipeline to test whether that was actually necessary. It was.


The student side of this story, including the production chat log pattern and the copyedit-only prompts we handed out, is in ai-detection-writing. The Tutorbin case study covers the platform and the rest of the production audit.