A system prompt is an instruction placed in a conversation’s system message. It gives an AI assistant a job description: its role, tone, and rules. Without one, the model behaves like a generic helpful assistant. A prompt can make the same model answer as a study buddy, a concise expert, or a tutor with a distinctive voice. section 13.1 section 13.2
Messages have three roles: system for guiding behavior, user for the human’s request, and assistant for previous model responses. Put the system message first. It frames the responses that follow, but it does not change the model’s trained weights or give it new knowledge. section 7.2.1 section 13.1
import ollama
response = ollama.chat(
model="gemma3:4b",
messages=[
{
"role": "system",
"content": "You are a friendly science teacher who explains " #1
"concepts using fun analogies. Keep your answers "
"under 100 words."
},
{
"role": "user",
"content": "How does gravity work?"
},
],
)
print(response["message"]["content"])
This Python request puts a friendly science-teacher instruction before the gravity question. The instruction asks for analogies and an answer under 100 words. section 7.2.2
Change the instruction, keep the question
Ask “How does gravity work?” with the science-teacher prompt, then replace it with a prompt for a dramatic stage actor. Compare the answers’ style. If a small model ignores the instruction, make it more explicit or try a larger model. section 7.2.2 section 7.2.3
To use a system prompt in a chatbot:
- Choose instructions that fit the job, such as simple explanations for a study buddy or brief answers for a quick fact check. section 13.2.5 section 13.5.1
- Send the system message with the retained conversation history and each new user message on every request; the model does not manage that history for your code. section 13.5.1 section 7.6
- Keep the prompt’s job distinct from generation settings: the prompt guides the task and presentation, while temperature affects how predictable or creative the response is. section 13.3
Use a system prompt to change personality or answer format, not to supply a collection of reference facts. For specific knowledge, consider RAG; for a change to fundamental model behavior, consider fine-tuning. A prompt is an instruction, not a retraining step. section 16.6.1 section 13.1

