Feedback

Chat Icon

Local AI Engineering with Ollama

Run, understand, customize, fine-tune, and build agentic apps on your own hardware

Building, Running, and Sharing Custom Models for Ollama (Modelfile)
59%

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:

  • temperature controls 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_ctx sets how many tokens the model can hold in view at once. The default window is small (4096), and a real git diff can 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. Raising num_ctx keeps 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 else

Local AI Engineering with Ollama

Run, understand, customize, fine-tune, and build agentic apps on your own hardware

Enroll now to unlock all content and receive all future updates for free.