Skills Night › Introduction to AI

Lesson 4.3 — System Prompts & Custom Models (Modelfile)

Introduction to AI · Module 4: Local LLMs · About 60 min · Windows PC, PowerShell 5, Ollama 0.40.11

Goal: build your own model, brett-writer, that rewrites messages in your voice every time without being reminded.

A system prompt is a standing instruction the model sees before every message. A Modelfile saves a system prompt and settings as a named model.

Before you start

Step 1 · Baseline, no system prompt (⏱ 0:00–0:10)

foreach ($i in 1..3) {
  $p = "Rewrite this message: " + (Get-Content "m$i.txt" -Raw -Encoding UTF8)
  ollama run qwen3.8:27b $p | Out-File "before-$i.md" -Encoding utf8
}
dir before-*.md

You should see 3 files. Read them and note what you'd change:

Step 2 · Write your style rules (⏱ 0:10–0:20)

Edit the rules in the block below so they sound like you, then paste it. This writes the Modelfile without a BOM, so Ollama reads it cleanly.

$mf = @'
FROM qwen3.8:27b
SYSTEM """
You rewrite messages for Brett Bolton (Brisbane, Australia).
Style: Australian English spelling. Friendly, direct, short.
Keep every fact, date, number and name exactly.
Use short sentences. No corporate jargon. No emojis unless the original has them.
Output ONLY the rewritten message, nothing before or after.
"""
PARAMETER temperature 0.4
PARAMETER num_ctx 8192
'@
[IO.File]::WriteAllText("C:\llm-test\Modelfile", $mf)
Get-Content Modelfile
temperature 0.4 = steady and predictable (1.0 = more creative). num_ctx = how much text it can hold at once, measured in tokens.

Step 3 · Create the model (⏱ 0:20–0:25)

ollama create brett-writer -f Modelfile
ollama list

You should see success, then brett-writer:latest in the list. It's tiny, because it reuses the qwen weights.

Step 4 · Test it (⏱ 0:25–0:40)

foreach ($i in 1..3) {
  $p = Get-Content "m$i.txt" -Raw -Encoding UTF8
  ollama run brett-writer $p | Out-File "after-$i.md" -Encoding utf8
}
notepad after-1.md

Compare each before- and after- pair.

MsgBefore OK as-is? (Y/N)After OK as-is? (Y/N)What's still off
1
2
3

Step 5 · Tune and rebuild (⏱ 0:40–0:55)

If something's still off, add a rule to the SYSTEM text in Step 2, paste it again, then:

ollama create brett-writer -f Modelfile

and re-run Step 4. Aim for 3/3 usable with no edits. Two tuning rounds at most, so don't chase perfection.

✅ Pass check

Troubleshooting

ProblemFix
Error: ... unknown command when creatingThe Modelfile got mangled. Re-paste Step 2 exactly (it must start with FROM).
It adds "Here's your rewrite:"Add the rule: "Never add an introduction or explanation."
It changes factsAdd: "If unsure, keep the original wording." Lower the temperature to 0.2.
It shows its thinkingRun it with ollama run brett-writer --think=false (or --hidethinking).
Want to delete itollama rm brett-writer (the base model stays).
Stuck? Ask Skills Coach. Send a screenshot or paste the error plus the step number. Don't stay stuck on one step for more than 10 minutes.

Finish this lesson

← Previous (4.2)