Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to add an example prompt for few-shot learning.
NLP
prompt = "Translate English to French:\nEnglish: Hello\nFrench: Bonjour\nEnglish: [1]\nFrench:"
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing a word that doesn't fit the greeting pattern.
Leaving the blank empty.
✗ Incorrect
The example shows English 'Hello' translated to French 'Bonjour'. To continue the pattern, 'Goodbye' is a common next example to translate.
2fill in blank
mediumComplete the code to create a few-shot prompt with two examples.
NLP
few_shot_prompt = "Translate English to French:\nEnglish: Hello\nFrench: Bonjour\nEnglish: Goodbye\nFrench: [1]"
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Merci' which means 'Thank you'.
Using 'Oui' which means 'Yes'.
✗ Incorrect
The French translation of 'Goodbye' is 'Au revoir', so it completes the second example correctly.
3fill in blank
hardFix the error in the code to generate a prediction using the few-shot prompt.
NLP
response = model.generate(prompt=[1], max_length=50)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using an undefined variable name.
Confusing variable names for the prompt.
✗ Incorrect
The variable 'prompt' is defined and used to hold the few-shot examples. Using 'prompt' matches the variable name.
4fill in blank
hardFill both blanks to create a prompt template and add an example input.
NLP
template = "Translate English to French:\nEnglish: [1]\nFrench: [2]"
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping input and output placeholders.
Using generic variable names that don't match the template.
✗ Incorrect
The template uses placeholders for example input and output. 'example_input' fits English text, 'example_output' fits French text.
5fill in blank
hardFill all three blanks to generate a few-shot prompt with two examples and a new input.
NLP
few_shot_prompt = f"Translate English to French:\nEnglish: [1]\nFrench: [2]\nEnglish: [3]\nFrench:"
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Putting the new input in the wrong blank.
Mixing up example inputs and outputs.
✗ Incorrect
The prompt shows first example input and output, then a second example input. The model will predict the second example output.