Bird
Raised Fist0
Prompt Engineering / GenAIml~20 mins

Instruction formatting in Prompt Engineering / GenAI - Practice Problems & Coding Challenges

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Challenge - 5 Problems
🎖️
Instruction Formatting Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding Instruction Formatting Impact
Which of the following best describes why clear instruction formatting is important when using generative AI models?
AIt guarantees the model will always produce error-free code regardless of input.
BIt reduces the model's training time significantly by skipping data preprocessing.
CIt helps the model understand the task better, leading to more accurate and relevant outputs.
DIt allows the model to generate outputs without any need for user input.
Attempts:
2 left
💡 Hint
Think about how clear instructions affect the model's understanding.
Predict Output
intermediate
2:00remaining
Output of Instruction with Ambiguous Formatting
What will be the output of the following prompt given to a generative AI model? "Generate a Python function that adds two numbers and returns the result. Use clear variable names." Assuming the model follows instructions literally, what is the likely output?
Prompt Engineering / GenAI
def add_numbers(a, b):
    return a + b
A
def add_numbers(a, b):
    return a + b
B
def add(x, y):
    return x + y
C
def addNumbers(a,b):
    return a+b
D
def add_two_numbers(num1, num2):
    return num1 + num2
Attempts:
2 left
💡 Hint
Look for the exact variable names used in the prompt.
Model Choice
advanced
2:00remaining
Choosing Model Type Based on Instruction Complexity
You want to generate detailed step-by-step explanations for complex math problems using a generative AI. Which model type is best suited for this task?
AA model trained exclusively on code snippets without natural language understanding.
BA model specialized only in image recognition tasks.
CA small, fast model optimized for short text completions.
DA large language model trained on diverse datasets with strong reasoning capabilities.
Attempts:
2 left
💡 Hint
Consider the need for reasoning and detailed explanations.
Hyperparameter
advanced
2:00remaining
Effect of Temperature on Instruction Output
When generating text from a generative AI model, what is the effect of increasing the 'temperature' hyperparameter?
AThe output becomes shorter and more concise.
BThe output becomes more random and creative, with less predictable word choices.
CThe model runs faster but with lower accuracy.
DThe output is guaranteed to be grammatically correct.
Attempts:
2 left
💡 Hint
Think about randomness and creativity in text generation.
Metrics
expert
2:00remaining
Evaluating Instruction Following with BLEU Score
You want to measure how well a generative AI model follows instructions by comparing its output to a reference answer. Which metric is most appropriate for this task?
ABLEU score, which measures overlap of n-grams between generated and reference text.
BMean Squared Error, which measures numeric differences between outputs.
CAccuracy, counting exact matches only.
DConfusion matrix, showing true vs predicted classes.
Attempts:
2 left
💡 Hint
Consider metrics used for comparing text similarity.

Practice

(1/5)
1. What is the main purpose of instruction formatting when interacting with an AI?
easy
A. To help the AI understand your request clearly
B. To make the AI run faster
C. To change the AI's programming language
D. To limit the AI's response length

Solution

  1. Step 1: Understand the role of instruction formatting

    Instruction formatting is about how you write your request to the AI so it understands what you want.
  2. Step 2: Identify the correct purpose

    The main goal is to make the AI understand your request clearly, not to affect speed or language.
  3. Final Answer:

    To help the AI understand your request clearly -> Option A
  4. Quick Check:

    Instruction formatting = clear AI understanding [OK]
Hint: Think: Why do I write instructions clearly? To be understood [OK]
Common Mistakes:
  • Confusing formatting with AI speed
  • Thinking it changes AI's programming
  • Assuming it limits response length
2. Which of the following is the correct way to format an instruction for an AI to write a short story about a dog?
easy
A. Story dog short please write quickly
B. dog story short write
C. Write a short story about a dog.
D. Write dog story short and fast

Solution

  1. Step 1: Check clarity and grammar

    Write a short story about a dog. is a clear, simple sentence that tells the AI exactly what to do.
  2. Step 2: Compare other options

    Options B, C, and D are unclear or awkward, making it hard for AI to understand.
  3. Final Answer:

    Write a short story about a dog. -> Option C
  4. Quick Check:

    Clear, simple sentence = Write a short story about a dog. [OK]
Hint: Choose the option with clear, complete sentences [OK]
Common Mistakes:
  • Using incomplete or jumbled words
  • Adding unnecessary words that confuse AI
  • Ignoring sentence structure
3. Given the instruction: Summarize the following text in 2 sentences. What will the AI most likely produce?
medium
A. A detailed essay about the text
B. A summary in exactly two sentences
C. A list of keywords from the text
D. The original text repeated twice

Solution

  1. Step 1: Understand the instruction

    The instruction asks for a summary limited to 2 sentences.
  2. Step 2: Predict AI output

    The AI will produce a concise summary exactly in 2 sentences, not an essay or keywords.
  3. Final Answer:

    A summary in exactly two sentences -> Option B
  4. Quick Check:

    Instruction = summary in 2 sentences [OK]
Hint: Look for keywords like 'summarize' and '2 sentences' [OK]
Common Mistakes:
  • Confusing summary with essay
  • Expecting keywords instead of sentences
  • Thinking AI repeats text
4. You gave the AI this instruction: Explain machine learning simple. The AI gives a confusing answer. What is the best fix?
medium
A. Make the instruction shorter.
B. Add more technical terms to the instruction.
C. Ask the AI to explain in a different language.
D. Change instruction to 'Explain machine learning in simple words.'

Solution

  1. Step 1: Identify the problem with the instruction

    The original instruction is unclear and grammatically incomplete.
  2. Step 2: Choose the clearer instruction

    Change instruction to 'Explain machine learning in simple words.' improves clarity by adding 'in simple words', making it easier for AI to understand.
  3. Final Answer:

    Change instruction to 'Explain machine learning in simple words.' -> Option D
  4. Quick Check:

    Clear, complete instruction = Change instruction to 'Explain machine learning in simple words.' [OK]
Hint: Make instructions clear and grammatically correct [OK]
Common Mistakes:
  • Adding confusing technical terms
  • Shortening instructions too much
  • Changing language without reason
5. You want the AI to generate a list of 5 healthy breakfast ideas with calories under 300 each. Which instruction is best formatted?
hard
A. List 5 healthy breakfast ideas with calories under 300 each, including ingredients.
B. Give me breakfast ideas.
C. List 5 breakfast foods.
D. Tell me about healthy food.

Solution

  1. Step 1: Identify key details needed

    The instruction must specify number, healthiness, calorie limit, and ingredients.
  2. Step 2: Compare options for completeness

    List 5 healthy breakfast ideas with calories under 300 each, including ingredients. includes all details clearly; others are too vague or incomplete.
  3. Final Answer:

    List 5 healthy breakfast ideas with calories under 300 each, including ingredients. -> Option A
  4. Quick Check:

    Complete, detailed instruction = List 5 healthy breakfast ideas with calories under 300 each, including ingredients. [OK]
Hint: Include all details clearly in your instruction [OK]
Common Mistakes:
  • Giving vague or incomplete instructions
  • Missing calorie or quantity details
  • Not specifying required output format