Now that you understand the basics of prompts, instructions, context, and temperature, it's time to put that knowledge into practice. This section guides you through simple exercises using your local LLM. The goal is to get comfortable interacting with the model and observing how different inputs influence its responses.
To follow along, you'll need your local LLM environment running, preferably using one of the tools discussed in the previous chapter, such as Ollama (via the command line) or LM Studio (using its graphical interface). For these initial exercises, a smaller model like phi3:mini
or a 3B/7B parameter model in GGUF format is often sufficient and provides quicker responses.
Let's start with the most straightforward interaction: asking questions.
ollama run phi3:mini
(replace phi3:mini
with your chosen model).What is the currency used in Japan?
Who painted the Mona Lisa?
What is 2 + 2?
Currency in Japan?
Tell me the currency of Japan.
Leonardo da Vinci painted which famous portrait?
Does the model give the same answer? Small changes in phrasing can sometimes lead to different responses or levels of detail.Now, let's move from asking questions to giving the LLM simple tasks to perform.
Write one sentence about a sunny day.
Compose a two-line poem about a robot.
Summarize this paragraph in a single sentence: Artificial intelligence research has progressed significantly over the past decade, driven by advances in computing power, large datasets, and algorithmic innovations. Many applications are now common, from virtual assistants to recommendation systems.
Rephrase this sentence: The meeting was postponed due to unforeseen circumstances.
List three types of fruit.
Provide two advantages of running LLMs locally.
The context window acts like the LLM's short-term memory during a conversation. Let's see it in action.
/bye
) and restart the ollama run
command.My favorite animal is the otter.
(Wait for the LLM's acknowledgment, often a simple "Okay" or similar).What is my favorite animal?
The model should correctly recall "otter" because your previous message is still within its context window.Prompt 1:
What's a common use for Python?
Prompt 2:
Tell me a joke.
What did I say my favorite animal was earlier?
Depending on the length of the intervening conversation and the model's specific context window size, it might still remember, or it might have "forgotten" the information about the otter. This demonstrates that the context window has a limited size. Information from much earlier in a long conversation might fall out of this window and become unavailable to the model for generating subsequent responses.As mentioned earlier, the temperature setting controls the randomness of the LLM's output. Higher values lead to more varied and sometimes creative responses, while lower values produce more predictable and focused text. Note: This setting is easily accessible in tools like LM Studio but may not be directly adjustable during a chat session in the basic Ollama command line.
Prompt:
Write a sentence describing a magical forest.
Prompt:
Write a sentence describing a magical forest.
Relationship between the temperature setting and the diversity or randomness observed in the LLM's generated text. Lower temperatures result in less randomness, while higher temperatures increase it.
This exercise helps illustrate how you can influence the LLM's output style. For tasks requiring factual accuracy or consistency, a lower temperature is generally preferred. For creative writing or brainstorming, a higher temperature might yield more interesting results.
These exercises provide a starting point for interacting with your local LLM. Don't hesitate to experiment further! Try different kinds of questions, instructions, and models. The more you practice, the better you'll become at formulating prompts that elicit the responses you need.
© 2025 ApX Machine Learning