Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to initialize a chatbot model using a pre-trained transformer.
Prompt Engineering / GenAI
model = [1]('gpt-3.5-turbo')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a class name instead of a function to load the model.
Using an undefined function like 'initialize'.
✗ Incorrect
The function to load a pre-trained model is usually called load_model or similar. Here, load_model is the correct choice to initialize the chatbot.
2fill in blank
mediumComplete the code to generate a response from the chatbot given a user input.
Prompt Engineering / GenAI
response = model.[1](user_input) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'train' or 'fit' which are for model training, not response generation.
Using 'predict' which is common in ML but less typical for text generation.
✗ Incorrect
To get a chatbot's reply, we use the generate method which produces text based on input.
3fill in blank
hardFix the error in the code to correctly preprocess user input by converting it to lowercase.
Prompt Engineering / GenAI
processed_input = user_input.[1]() Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'lowercase' which is not a method.
Using JavaScript style 'toLowerCase'.
✗ Incorrect
In Python, the correct method to convert a string to lowercase is 'lower()'.
4fill in blank
hardFill both blanks to create a dictionary that maps user intents to responses.
Prompt Engineering / GenAI
responses = { [1]: 'Hello!', [2]: 'Goodbye!'} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using response words as keys instead of intent names.
Using informal keys like 'hello' or 'bye' which are less clear.
✗ Incorrect
The keys should be user intents like 'greeting' and 'farewell' to map to appropriate responses.
5fill in blank
hardFill all three blanks to filter user messages that contain the word 'help' and convert them to lowercase.
Prompt Engineering / GenAI
filtered = [msg.[1]() for msg in messages if '[2]' in msg.[3]()]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'lowercase' which is not a valid method.
Checking for 'Help' with uppercase H which misses lowercase matches.
✗ Incorrect
We convert messages to lowercase with 'lower()' and check if 'help' is in the lowercase message.