Module 9 Lesson 3: Output Control
·AI & LLMs

Module 9 Lesson 3: Output Control

Precision generation. Techniques to limit the model's verbosity and ensure it stays within character limits.

Output Control: The Art of Brevity

Users don't always want a 5-paragraph answer for a "Yes" or "No" question. Local models, by default, love to explain themselves. This wastes your CPU/GPU cycles and frustrates users.

Here is how to take control of the model's verbosity.

1. The Verbosity Scale

  • Verbose: "Sure, I can help with that. The answer to your question is..."
  • Moderate: "The answer is X. This happens because of Y."
  • Terse: "Answer: X."

2. Setting Word and Token Limits

LLMs aren't very good at counting (they process tokens, not words).

  • Bad: "Answer in exactly 10 words." (It will likely fail).
  • Good: "Answer in 1 sentence." or "Be as brief as possible."

3. Using "Post-Processing" instructions

Tell the model what to remove from its output.

  • "Provide the answer. Do not provide an introduction or an outro."
  • "Provide the SQL code ONLY. No text around it."

4. The num_predict Parameter

This is a technical guardrail you can set in a Modelfile (Module 5). PARAMETER num_predict 50

This tells Ollama: "No matter what the model wants, cut it off after 50 tokens." This is a "Hard Limit." It’s perfect for generating titles, category names, or sentiment tags where you know the answer should be very short.


5. Controlling Tones

You can control output by defining the "Level of Complexity."

  • "Explain it like I am 5 years old." (Short, simple words).
  • "Provide a technical summary for a PhD." (Long, complex data-rich sentences).

Key Takeaways

  • Brevity saves hardware resources and improves user experience.
  • Descriptions of length ("1 sentence") are better than number counts ("10 words").
  • Use negative constraints to remove "introductions" and "fillers."
  • Use the num_predict parameter in your Modelfile for guaranteed short outputs.

Subscribe to our newsletter

Get the latest posts delivered right to your inbox.

Subscribe on LinkedIn