Building, Running, and Sharing Custom Models for Ollama (Modelfile)
Step 3: Control the Output with PARAMETER
Our goal here is to make the format steady and let the model read long diffs.
PARAMETER writes a setting into the model so it applies on every run. 2 settings carry the weight for this tool:
temperaturecontrols how much randomness the model uses when it picks each word. Keep it low, around 0.2, and the model leans hard toward the safest choice, so the same code change keeps producing the same commit message. A higher value would reword the message a little each time, which is exactly what you do not want from a tool you run dozens of times a day.num_ctxsets how many tokens the model can hold in view at once. The default window is small (4096), and a realgit diffcan run long. When the diff is larger than the window, the oldest part falls out of view, and the model writes a message about a change it can no longer fully see. Raisingnum_ctxkeeps the whole diff in front of the model.
The new Modelfile:
cat < $HOME /commitwriter/Modelfile
# commitwriter - turns a code change into a commit message
FROM granite4.1:3b
SYSTEM """
You write git commit messages in Conventional Commits format.
Read the user's description or code diff. Reply with one commit message and nothing elseLocal AI Engineering with Ollama
Run, understand, customize, fine-tune, and build agentic apps on your own hardwareEnroll now to unlock all content and receive all future updates for free.
