liveBook · Manning

Chapter 13: System prompts and parameter tuning

What you will learn in chapter 13 of Build Applications with Local AI Models on a Mac

Introduces the chatbot’s current generic behavior and previews ways the chapter will customize its personality and response style.

After this chapter you will be able to

What it builds on

Section by section

Introduction

Introduces the chatbot’s current generic behavior and previews ways the chapter will customize its personality and response style.

13.1 System prompts explained

Explains how a system prompt frames an LLM conversation and shapes responses without changing the model’s learned knowledge.

Key terms: user, assistant, system message, system prompt, rules, personality, boundaries, default behavior, model weights, underlying knowledge

13.2 Example system prompts: Personality presets

Introduces five system-prompt personality presets that readers can use or adapt to shape model behavior.

13.2.1 Preset 1: The professional consultant

13.2.2 Preset 2: The patient study buddy

This subsection describes the teaching style of the patient study buddy preset.

Key terms: patient study buddy, preset, everyday analogies

13.2.3 Preset 3: The pirate tutor

The pirate tutor preset changes the model’s teaching style without changing the accuracy of its explanations.

Key terms: preset, pirate dialect, delivery style

13.2.4 Preset 4: The strict coding mentor

This subsection describes a strict coding mentor preset that guides learners through problems instead of giving them solutions.

Key terms: strict coding mentor, Socratic method

13.2.5 Preset 5: The concise expert

Introduces a concise-expert preset for quick, accurate answers and shows how changing system prompts can specialize the same model.

Key terms: preset, concise expert, system prompts, specialized AI assistants

13.3 LLM temperature and creative parameters

13.3.1 What temperature does

This section explains how temperature changes an LLM’s next-token choices and why a middle setting suits most tasks.

Key terms: token, probabilities, temperature, sampling, creative, unpredictable, incoherent

13.3.2 Other important parameters

This section explains how top_k, top_p, and repeat_penalty control candidate selection and repetition beyond temperature.

Key terms: top_k, top_p, nucleus sampling, candidate words, probability mass, repeat_penalty

13.4 Creating custom models with Ollama Modelfiles

Introduces a Modelfile as a named recipe that combines a base model with system prompts and parameter settings.

Key terms: Modelfile, base model, system prompts, temperature, custom model definition

13.4.1 The Modelfile format

This section defines an Ollama Modelfile and distinguishes its required base-model instruction from optional customization settings.

Key terms: Modelfile, FROM, SYSTEM, temperature, top_p

13.4.2 Key Modelfile instructions

This section identifies the main Modelfile instructions and explains how the context-window setting affects conversation length and RAM use.

Key terms: FROM, PARAMETER, SYSTEM, base model, system prompt, num_ctx, context window, history trimming, tokens, RAM

13.4.3 Building a custom model step by step

Shows how to create and run a named Ollama model from a Modelfile, and explains what that custom model adds to the base model.

Key terms: Modelfile.studybuddy, studybuddy, base model, configuration layer, built-in personality, system prompts, parameter settings, Modelfile

13.4.4 Managing custom models

This subsection identifies how to manage a growing collection of custom models by listing, inspecting, and removing them.

Key terms: custom models, show command

13.5 Adding customization controls to the Streamlit UI

This section introduces Streamlit controls that let users customize chatbot behavior without editing code.

Key terms: system prompt, temperature controls, Streamlit chatbot

13.5.1 The enhanced chatbot

This section describes an enhanced Streamlit chatbot’s customization controls and how it sends those settings with each chat request.

Key terms: model selection, temperature slider, personality presets, Custom, system message, retained conversation history, Ollama Python library, local API, temperature

13.5.2 How the system prompt affects the pipeline

This subsection explains that the system prompt enters the chatbot’s message flow early and shapes the model’s response throughout generation.

Key terms: system prompt, pipeline, token

13.6 Exercises

13.7 Summary

Where this is used later

Concepts explained in this chapter

← Chapter 12: Comparing and selecting LLM models Chapter 14: Offline LLMs and their benefits →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.