Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to add examples to the prompt for few-shot learning.
Prompt Engineering / GenAI
prompt = "Translate English to French:\n" + [1] + "\nInput: How are you?\nOutput:"
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using greetings in other languages like Spanish or Italian.
Not formatting the example as 'English: ...\nFrench: ...'.
✗ Incorrect
The example must show English to French translation. 'Bonjour' is French for 'Hello'.
2fill in blank
mediumComplete the code to add multiple examples separated by newlines for few-shot prompting.
Prompt Engineering / GenAI
examples = "English: Hello\nFrench: Bonjour\n" + [1] + "\nInput: Thank you\nOutput:"
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using Spanish or Italian words instead of French.
Not separating examples with newlines.
✗ Incorrect
The second example must be a correct English to French pair. 'Au revoir' means 'Goodbye' in French.
3fill in blank
hardFix the error in the prompt construction to correctly format few-shot examples.
Prompt Engineering / GenAI
prompt = "Translate English to French:\n" + examples + [1] + "Input: Good night\nOutput:"
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a space or tab instead of a newline.
Not adding any separator causing formatting issues.
✗ Incorrect
A newline '\n' is needed to separate the examples from the new input prompt.
4fill in blank
hardFill both blanks to create a function that builds a few-shot prompt with given examples and input.
Prompt Engineering / GenAI
def build_prompt(examples, input_text): return "Translate English to French:\n" + [1] + "\nInput: " + [2] + "\nOutput:"
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Not adding a newline after examples.
Using a string literal 'input_text' instead of the variable.
✗ Incorrect
We add a newline after examples (C) and use the input_text variable (B) for the input.
5fill in blank
hardFill all three blanks to complete the few-shot prompt generation with multiple examples and input.
Prompt Engineering / GenAI
examples = [
"English: Hello\nFrench: Bonjour",
"English: Goodbye\nFrench: Au revoir",
"English: Thank you\nFrench: Merci"
]
prompt = "Translate English to French:\n" + [1] + "\nInput: " + [2] + "\nOutput:"
response = model.generate(prompt, max_tokens=[3]) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using commas instead of newlines to join examples.
Using a string literal instead of the input variable.
Setting max_tokens too high or too low.
✗ Incorrect
Join examples with newlines (A), use input_sentence variable (B), and set max_tokens to 50 (C) for output length.