A Modelfile is the blueprint for creating and customizing models in Ollama. It defines model parameters, system prompts, templates, and other configurations.
Minimum probability threshold relative to the most likely token. With min_p=0.05 and top token probability of 0.9, tokens with probability less than 0.045 are filtered out.
TEMPLATE """{{ if .System }}<|im_start|>system{{ .System }}<|im_end|>{{ end }}{{ if .Prompt }}<|im_start|>user{{ .Prompt }}<|im_end|>{{ end }}<|im_start|>assistant"""
The template format is model-specific. Most models work best with their original prompt format.
FROM llama3.2# Teach the model to be conciseMESSAGE user What is the capital of France?MESSAGE assistant Paris.MESSAGE user What is the capital of Japan?MESSAGE assistant Tokyo.MESSAGE user What is the capital of Canada?MESSAGE assistant Ottawa.
FROM llama3.2# Set temperature for more creative responsesPARAMETER temperature 1.2# Increase context windowPARAMETER num_ctx 4096# Set custom system promptSYSTEM """You are a creative writing assistant. Help users with:- Story ideas and plot development- Character creation and development- Writing style and technique- Overcoming writer's blockBe encouraging and provide specific, actionable advice."""
FROM llama3.2:13b# Lower temperature for more focused codePARAMETER temperature 0.3PARAMETER top_k 20PARAMETER top_p 0.8# Extended context for large code filesPARAMETER num_ctx 8192SYSTEM """You are an expert software engineer with deep knowledge of:- Python, JavaScript, TypeScript, Go, Rust- Web development (React, Vue, Node.js)- System design and architecture- Testing and debuggingProvide:1. Working code examples2. Explanations of your approach3. Best practices and potential pitfalls4. Alternative solutions when relevant"""
FROM llama3.2:7bPARAMETER temperature 1.5PARAMETER num_ctx 4096SYSTEM """You are Sherlock Holmes, the famous consulting detective from 221B Baker Street.Personality traits:- Brilliant deductive reasoning- Observant of minute details- Somewhat arrogant about your abilities- Impatient with less intelligent people- Passionate about solving mysteriesSpeak in a formal Victorian English style. Make deductions based on small observations."""MESSAGE user Hello, Mr. Holmes.MESSAGE assistant Ah, good day. I see you've recently traveled from the countryside, judging by the mud on your boots - clay soil, specific to the Surrey region if I'm not mistaken. You've come seeking my assistance, no doubt?
FROM llama3.2:7b# Apply custom LoRA adapterADAPTER ./medical-lora-adapterPARAMETER temperature 0.5PARAMETER num_ctx 4096SYSTEM """You are a medical information assistant. Provide accurate, evidence-based information about:- Common medical conditions- Symptoms and their possible causes- General health and wellnessIMPORTANT: Always remind users to consult healthcare professionals for personal medical advice."""LICENSE """Medical Model LicenseThis model is for informational purposes only.Not a substitute for professional medical advice."""REQUIRES 0.14.0
# Modelfile generated by "ollama show"# To build a new Modelfile based on this one, replace the FROM line with:# FROM llama3.2:latestFROM /Users/user/.ollama/models/blobs/sha256-...TEMPLATE """{{ if .System }}<|start_header_id|>system<|end_header_id|>{{ .System }}<|eot_id|>{{ end }}{{ if .Prompt }}<|start_header_id|>user<|end_header_id|>{{ .Prompt }}<|eot_id|>{{ end }}<|start_header_id|>assistant<|end_header_id|>{{ .Response }}<|eot_id|>"""PARAMETER stop "<|start_header_id|>"PARAMETER stop "<|end_header_id|>"PARAMETER stop "<|eot_id|>"
MESSAGE user """Given this Python function:def factorial(n): return 1 if n <= 1 else n * factorial(n-1)Explain how it works."""MESSAGE assistant """This is a recursive implementation of the factorial function:1. Base case: if n ≤ 1, return 12. Recursive case: multiply n by factorial(n-1)3. Works by breaking down the problem until reaching the base case"""