Ollama conversation and generation parameters
This chapter dives into the details of conversational Ollama use: multiple conversation modes, generation parameters that control the model's "personality", context window, thinking mode, and multimodal conversation.
Three conversation modes: interactive, single-shot, and pipe
The same run command has different usages and different applicable scenarios.
Interactive mode: multi-turn chat
Run directly to enter a conversation; the model remembers the context within this session, suitable for follow-up questions:
Example
Enter a multi-turn interactive conversation
ollama run qwen3.5
Single-shot Q&A: one question, one answer
Put the question directly as an argument and exit immediately after getting the answer, suitable for one-off tasks:
Example
Single-shot Q&A, no interactive interface
ollama run qwen3.5
"Introduce RUNOOB Runoob Tutorial in one sentence"
Pipe input: embedding in scripts
Feed text to the model through a pipe, convenient for combining with other commands:
Example
Hand file contents to the model for summarization
cat
README.md
|
ollama run qwen3.5
"Summarize this content"
In addition, entering three double quotes in a conversation can wrap multi-line text, and pressing Enter won't be treated as a submission.
Generation parameters: controlling the model's "personality"
Before generating each word (token), the model goes through the same internal pipeline; generation parameters intervene at different stages of this pipeline.
temperature sharpens or flattens the probability distribution, top_k / top_p / min_p cut low-quality candidates, and finally random sampling selects the next token.
Common parameters are summarized below (defaults from official documentation):
| Parameters | Default value | Purpose | Typical usage |
|---|---|---|---|
| temperature | 0.8 | Higher is more creative, lower is more rigorous | Use 0~0.3 for code writing and information extraction; around 1.0 for creative writing |
| top_k | 40 | Sample only from the top k candidates by probability | Lower it for more conservative output |
| top_p | 0.9 | Sample only from candidates whose cumulative probability reaches p | Fine-tune using either this or top_k |
| min_p | 0.0 | Set a candidate floor as a ratio of the highest probability | 0.05 is often used as an alternative to top_p |
| repeat_penalty | 1.0 | Penalize repeated content | 1.1 alleviates repetitive circular talk |
| seed | 0 | Fix the random seed for reproducibility | Fix results during testing and debugging |
| stop | None | Stop generation immediately upon encountering a specified string | Trim excess pleasantries or fixed formats |
| num_predict | -1 | Maximum number of generated tokens, -1 for unlimited | Limit the output length of long answers |
Adjust at any time in interactive mode with built-in commands:
Example
/
set
parameter temperature
0.3
/
set
parameter seed
42
To make parameters permanent, write them into a Modelfile to create a "pre-tuned" model—this is the core use of Modelfile in the next article.
A small experiment to verify the seed effect: with a fixed seed, asking the same question twice gives identical output; with the seed released, every answer differs.
Context window num_ctx: the model's working memory
The context window determines how much content the model can "see" at once, including the system prompt, conversation history, and your question, measured in tokens.
Content that doesn't fit in the window is truncated—this is the root cause of the model "forgetting the beginning as the chat goes on".
Ollama automatically selects the default context length based on VRAM: below 24GiB defaults to 4K, 24~48GiB defaults to 32K, above 48GiB defaults to 256K. Cloud models run at maximum context by default.
There are three entry points for manual adjustment:
Example
Method 1: adjust the current session within interactive mode
/
set
parameter num_ctx
8192
Method 2: set a global default when starting the service
OLLAMA_CONTEXT_LENGTH
=
8192
ollama serve
Method 3: specify as needed in API requests (options.num_ctx, see the API chapter)
The cost of a larger window is higher memory usage; use ollama ps from the previous chapter and check the CONTEXT column to confirm the current value.
When integrating Ollama into agents, coding tools, or online search scenarios, the official recommendation is to set context to at least 64K, otherwise the large volume of content returned by tools will crowd out conversation space.
Thinking mode: let the model think before answering
Reasoning models (such as qwen3.5, deepseek-r1) support outputting a thinking process before the answer, suitable for math and logic tasks.
Ollama enables thinking by default and also provides full control switches:
Example
Force thinking on
ollama run qwen3.5
--think
"What is 17 times 23?"
Turn off thinking, give the answer directly
ollama run qwen3.5
--think
=
false
"Introduce RUNOOB in one sentence"
Think as usual, but don't display the thinking process in the terminal
ollama run qwen3.5
--hidethinking
"Which is larger, 9.9 or 9.11?"
In interactive mode, use /set think and /set nothink to switch at any time.
Some models support thinking-intensity levels; for example, gpt-oss only accepts low, medium, and high, specified in a form like --think=medium.
Turning off thinking noticeably reduces response time, but accuracy on reasoning tasks may drop; scenarios that prioritize response speed, such as coding assistants, often choose hidethinking—keeping thinking quality without flooding the terminal with the process.
Multimodal: let the model see images
qwen3.5 natively supports image input; in the command line just put the image path after the question:
Example
Image path + question, image Q&A in one line
ollama run qwen3.5 .
/
screenshot.png what page is this screenshot?
API and SDK usage is a bit more complex (base64 encoding), demonstrated in the vision capabilities chapter; it can also be combined with structured output for "image to structured data".
Structured output: make answers reliable JSON
When having a program parse model answers, the biggest fear is that the format differs every time. Ollama supports forcing the model to output according to a JSON Schema.
Example
curl http:
//
localhost:
11434
/
api
/
chat
-d
'{
"model": "qwen3.5",
"messages": [{ "role": "user", "content": "Introduce RUNOOB Runoob Tutorial" }],
"format": {
"type": "object",
"properties": {
"name": { "type": "string" },
"category": { "type": "string" },
"free": { "type": "boolean" }
},
"required": ["name", "category", "free"]
},
"stream": false
}'
The returned content is a JSON string strictly conforming to the schema, which can be deserialized directly into a program object.
In Python, defining a schema with Pydantic and then validating the result is the most convenient combination; the full practice is in the model capabilities chapter.
Two practical details: for structured output, lowering temperature to 0 is more stable; if you only write format without explaining the requirements in the prompt, effectiveness may suffer—it's best to also describe the field meanings in the prompt.
Context management and common pitfalls in multi-turn conversations
In each turn of interactive mode, Ollama assembles the full history into the context window and sends it to the model, which brings two consequences you must know.
First, the model has memory within a session, but memory resets after exiting (/bye): rerunning is a brand-new session and it doesn't remember what you said last time.
Second, when history gets too long, the oldest content is pushed out of the window first, showing up as the model suddenly "forgetting" the initial agreement.
Corresponding practical strategies:
| Symptom | Reason | Countermeasure |
|---|---|---|
| Model forgets everything after restarting the conversation | Session context isn't preserved across processes | Write important agreements into Modelfile's SYSTEM, or manage message history yourself via the API |
| Long conversations start "losing memory" in the latter half | Context window is filled up and old content is truncated | Increase num_ctx; or start a new session periodically, carrying only key conclusions |
| Answers get slower and worse after pasting a long document | Long content crowds out the context | Paste only relevant passages; hand whole documents to the RAG knowledge base solution |
To bypass these limitations for persistent memory, use the API to maintain the messages array yourself—that's the star of the API chapter.
Interactive mode built-in command quick reference
The built-in commands available directly at the conversation prompt are listed below; type /? at any time to see the actual list for the current version.
| Command | Purpose |
|---|---|
| /? | Show help and all available commands |
| /set parameter |
Adjust generation parameters, such as temperature, num_ctx |
| /set system " |
Temporarily change the system prompt |
| /set think / /set nothink | Turn thinking mode on / off |
| /clear | Clear the current session context and start over |
| /load |
Switch to another model without exiting the terminal |
| /save |
Save the current session (including system prompt and parameters) as a new model |
| /show info / /show parameters | View current model info / currently active parameters |
| /bye | Exit the conversation |
/save deserves a special mention: it directly solidifies a tuned conversation into a new model—equivalent to quick customization without writing a Modelfile. The next chapter compares it with the Modelfile approach.