Claude On Google Cloud
← All lessons
Lesson 11Claude On Google Cloud

Controlling model output

Summary audio

Spoken summary — press play to read along: the line being spoken stays near the top.

Study notes

Influencing LLM Output: Advanced Techniques

**I. Pre-filling Assistant Messages**

  • Purpose: To strongly steer or direct Claude's response toward a specific stance, conclusion, or direction.
  • Mechanism:
  • Assemble a message list containing the user prompt.
  • Add a final message designated as an "Assistant Message" (a Q&A format).
  • This Assistant Message contains a partial, directional statement (e. g. , "Coffee is better because... ").
  • How it Works: Claude assumes that the content in the Assistant Message was authored by it. It uses this partial text as a starting point and continues generating the rest of the response, effectively justifying the pre-filled text.
  • Key Consideration: The pre-filled text is not guaranteed to be a complete sentence. The model continues generating text from the very end of the provided string, which may require the user to stitch the final output together.
  • Application: Can be used to force a specific conclusion (e. g. , favoring tea) or a neutral/negative conclusion (e. g. , "neither is very good because... ").

**II. Stop Sequences**

  • Purpose: To force Claude to immediately halt response generation as soon as it produces a specific string.
  • Mechanism:
  • Provide a list of stop sequences as an argument to the chat function.
  • How it Works: When the model generates the exact sequence provided in the stop list, the entire generation process stops immediately.
  • Application: Useful for controlling the length or format of the output (e. g. , stopping a counting sequence at a specific number).
  • Note: If the goal is to stop before a sequence is fully generated, the stop sequence must include surrounding characters (e. g. , using "comma space five" to stop before the number five).

Takeaways

  • Pre-filling Assistant Messages steers LLM output by providing a partial, directional statement that the model assumes it authored and continues to justify.
  • Stop Sequences force the LLM to immediately halt response generation as soon as it produces a specified string.
  • The pre-filled text may not be a complete sentence, requiring the user to stitch the final output.
  • To stop generation before a sequence is fully produced, the stop sequence must include surrounding characters.
Flashcards 8 cards
Question
click to reveal · ←/→
Answer
click to flip back
Export to Anki (.tsv) ↓
Knowledge check 6 questions