0
0
NLPml~10 mins

Few-shot learning with prompts in NLP - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete 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'
AYes
BThanks
CPlease
DGoodbye
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing a word that doesn't fit the greeting pattern.
Leaving the blank empty.
2fill in blank
medium

Complete 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'
AMerci
BAu revoir
CS'il vous plaît
DOui
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Merci' which means 'Thank you'.
Using 'Oui' which means 'Yes'.
3fill in blank
hard

Fix 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'
Aprompt
Bfew_shot_prompt
Cprompt_text
Dinput_text
Attempts:
3 left
💡 Hint
Common Mistakes
Using an undefined variable name.
Confusing variable names for the prompt.
4fill in blank
hard

Fill 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'
Ainput_text
Boutput_text
Cexample_input
Dexample_output
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping input and output placeholders.
Using generic variable names that don't match the template.
5fill in blank
hard

Fill 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'
Aexample1_input
Bexample1_output
Cnew_input
Dexample2_input
Attempts:
3 left
💡 Hint
Common Mistakes
Putting the new input in the wrong blank.
Mixing up example inputs and outputs.