Claude With Amazon Bedrock
← All lessons
Lesson 07Claude With Amazon Bedrock

System prompt exercise

Summary audio

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

Study notes

Prompt Engineering: Controlling AI Output

  • The Problem: Simple user prompts often result in verbose AI responses, including preambles, explanations, extensive comments, and closing statements, even when only a short piece of code is requested.
  • Goal: To force the AI to provide a highly concise output (e. g. , just the functional code).
  • Solution 1: Modifying the User Message (Negative Constraints)
  • Add explicit negative instructions to the user prompt.
  • Examples: "Do not add any comments," or "Respond just with the code. "
  • Solution 2: Using a System Prompt (Role Assignment)
  • A more effective method is to assign a specific role to the AI via the system prompt.
  • The system prompt dictates the AI's persona and writing style.
  • Example: "You are a Python engineer who writes very concise code. "
  • Key Takeaway: Assigning a role through the system prompt is generally easier and more reliable for controlling the output format and conciseness than adding numerous specific requirements to the user message.

Takeaways

  • Prompt engineering aims to force AI to provide highly concise output, avoiding verbose preambles and comments.
  • One method for controlling output is using negative constraints in the user message (e. g. , "Do not add comments").
  • A more effective solution is assigning a specific persona or role to the AI using the system prompt.
  • System prompts are generally more reliable than user message constraints for controlling output format and conciseness.
Flashcards 6 cards
Question
click to reveal · ←/→
Answer
click to flip back
Export to Anki (.tsv) ↓
Knowledge check 1 questions