liveBook · Manning

Modelfile

As explained in Domain-Specific Small Language Models

An Ollama configuration file that specifies how to package and serve a converted model, including template and generation parameters.

A Modelfile packages a converted custom model for Ollama and defines how it will be deployed and served locally for inference. It bundles the model reference with template and generation settings so the local server can run it as a single package. section 12.2 section 12.7

Typical contents include:

Minimal deployment flow

After converting a custom model to GGUF, create a Modelfile in the same directory, then run ollama create to register the model and ollama run to chat with it. section 12.2.1 section 12.2

FROM starcoder2-3b_instruct.gguf

PARAMETER num_ctx 4096
TEMPLATE """<|endoftext|>You are an exceptionally intelligent coding assistant that consistently delivers accurate and reliable responses to user instructions.
### Instruction
{{ .Prompt }}
### Response
"""

PARAMETER stop "###"
PARAMETER stop "<|endoftext|>"
PARAMETER stop "<file_sep>"

Shows a concrete Modelfile with FROM, TEMPLATE, context length, and multiple stop tokens. section 12.2.1

cd ./gguf_model
ollama create starcoder2-3b-instruct-new -f Modelfile

Shows the create command that turns the Modelfile into a local Ollama model. section 12.2.1

ollama run starcoder2-3b-instruct-new:latest

Shows the resulting run command used to start chatting with the created model. section 12.2.1

How Domain-Specific Small Language Models covers it

How deep it goes
Defines the core commands and parameters, but stops short of full syntax coverage or broader model conversion details.
Examples
Uses a StarCoder2 GGUF conversion, a sample Modelfile, and ollama create/run commands.
What it assumes
Assumes a converted GGUF model and explains the deployment file from that point onward.
What you can do after
Operate a converted model locally by packaging it with templates, stop tokens, and generation parameters.
How it connects
Connects to GGUF, Ollama, llama.cpp, and local inference.

Also explained in

Compare how 2 books explain Modelfile →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Domain-Specific Small Language Models. The section links point to the parts of the book it draws on.