TDM 19000: Running, Timing, and Customizing the Ollama Model with Parameters

Running the Ollama Model

Assuming that you started an Ollama server as described at the-examples-book.com/projects/summer2026/19000/startingollama and also assuming that you setup a model called llama3.2-2 at the end of the instructions for setting up Ollama: the-examples-book.com/projects/summer2026/19000/settingupollama

You can now run the following in a separate terminal window (separate from the terminal where your Ollama model is running):

/anvil/projects/tdm/bin/ollama run llama3.2-2
Now you should be able to send the LLM a test prompt in the Terminal. Enter a message to begin working with the LLM.

Some starter ideas include:

  • "Why is the sky blue?"

  • "Tell me a joke about cats"

  • "What is 7 * 8?"

  • "What are the names of [singer’s name] albums?"

The response it gives you depends on the prompt you send it, and how you have configured the model.

The thread count is part of what determines the quality of the model’s responses.

To exit the currently active model, type '/bye' in the message prompt.

Testing the Ollama Model

One way of testing model quality is to measure how long it is running to write a response.

Adjusting the cores will vary the speed, accuracy, and quality of your model and its responses. Currently, we are working with 2 threads. Make versions of llama3.2 that use 4 and 1 threads, respectively.

%%bash
cat > ~/mymodel << HERE
FROM llama3.2
# we used 2 threads before
# now test with 1, then 4
PARAMETER num_thread ___
HERE

# create the models from a `mymodel` file using 1 and 4 threads, respectively (run in terminal):
# fill in [thread_count] with (for instance) 1 or 2 or 4, depending on how many threads that you want to use in your test
# /anvil/projects/tdm/bin/ollama create llama3.2-[thread_count] -f ~/mymodel

Run this in your terminal to test how thread count (1, 2, and 4) changes the output you are recieving:

time /anvil/projects/tdm/bin/ollama run llama3.2-[thread count] "Explain why the sky appears blue during the day and red during sunrise and sunset. Write about 200 words."

There is hopefully a very noticable time difference between running the model on 1 thread vs 2. This may be more subtle when comparing 2 cores to more (such as testing with 4 or 8 threads). The ideal number of threads tends to be around 1/2 as many cores as your server is running on - since we are using 4 cores, you should continue using 2 threads.

Customizing the Ollama Model with Parameters

A plain-text configuration file - a modelfile - in Ollama can be used to define a new model. The contents of this file specifies:

  • FROM: the base model

  • SYSTEM: prompt for model behavior

  • PARAMETER: set model parameters

The base model will be llama3.2. We could re-define that we want to use 2 threads by setting the PARAMETER, or we could just set the base model to llama3.2-2, as we have already worked with this model.

In the SYSTEM block, we can send the model a prompt on how to behave. This does not change the model’s quality itself, just defines how this model we are creating should style its responses.

You can reuse this general setup:

%%bash
cat > ~/mymodel << HERE
FROM [your_model_name]
SYSTEM """
[your model behavior prompt]
"""
HERE

A typical generative model’s tone and behavior is usually rather neutral until it has training to shape its behavior.

Now fill out a modelfile with personality and style for the model to use when writing responses.

Some ideas for this:

  • Explain everything written in the language Pig Latin.

  • You are a very grouchy elderly man who does not like people who ask questions. Explain rudely and like you strongly wish for this to end

  • Explain everything to a five-year-old child. Use very simple words and short sentences. Use comparisons and examples children would understand.

  • You are a pirate explaining things to your crew. Use pirate slang and nautical metaphors.

So far, we have been defining the modelfiles under the name mymodel each time. This is OK, as we are completing our model definitions and saving them each time before defining the next new model. However, you may find that you want to call your files distinct names if you have more than one model in the in-progress stage before running /anvil/projects/tdm/bin/ollama create [model_version]-[my_model_name] -f ~/[modelfile_name].

Between defining your model and then going to test it, do not forget to actually create it!

/anvil/projects/tdm/bin/ollama create [model_name] -f ~/mymodel

Try defining, creating, and running a few models with different system behavior definitions. In the terminal, use:

/anvil/projects/tdm/bin/ollama run llama3.2-[model_name]

…​to run each model.