Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Principle:Ollama Ollama Modelfile Format

From Leeroopedia
Knowledge Sources
Domains Configuration, DSL
Last Updated 2026-02-14 00:00 GMT

Overview

A declarative configuration language for defining custom LLM models by specifying a base model, system prompt, parameters, adapters, templates, and licenses.

Description

The Modelfile format is Ollama's domain-specific language (DSL) for creating custom models. Inspired by Dockerfiles, it uses a series of directives to compose a model from existing components. Each directive specifies one aspect of the model configuration.

The format solves the problem of model customization without retraining: users can create specialized models by combining a base model with custom system prompts, adjusted inference parameters, LoRA adapters, chat templates, and preset conversation history.

Usage

Use this format when creating custom models that need specialized behavior: domain-specific assistants, parameter-tuned variants, or models with LoRA fine-tuning adapters. The Modelfile is authored by users and processed by the ollama create command.

Theoretical Basis

The Modelfile supports these directives:

  • FROM <model> — (Required) Specifies the base model name or path to a GGUF file.
  • SYSTEM <prompt> — Sets the system prompt for the model.
  • PARAMETER <key> <value> — Sets inference parameters (temperature, top_k, top_p, num_ctx, etc.).
  • TEMPLATE <template> — Overrides the chat prompt template (Go text/template format).
  • ADAPTER <path> — Adds a LoRA adapter from a local file path.
  • LICENSE <text> — Sets the model license text.
  • MESSAGE <role> <content> — Adds a preset message to the conversation history.

Example Modelfile:

FROM llama3
SYSTEM "You are a helpful coding assistant."
PARAMETER temperature 0.7
PARAMETER top_p 0.9
PARAMETER num_ctx 4096

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment