Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a simple LLM wrapper that calls the model's generate method.
Prompt Engineering / GenAI
response = llm.[1](prompt) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'train' or 'fit' instead of 'generate'.
Trying to compile the model instead of generating text.
✗ Incorrect
The generate method is used to get the model's output for a given prompt.
2fill in blank
mediumComplete the code to initialize an LLM wrapper with a specific model name.
Prompt Engineering / GenAI
llm = LLMWrapper(model_name=[1]) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a number or boolean instead of a string.
Using None which means no model specified.
✗ Incorrect
The model_name must be a string identifying the model, like 'gpt-3.5-turbo'.
3fill in blank
hardFix the error in the code to correctly call the LLM wrapper's generate method with a prompt.
Prompt Engineering / GenAI
output = llm.[1](input_text=prompt) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'predict' which is common in ML but not for LLM wrappers.
Using 'fit' or 'train' which are for model training.
✗ Incorrect
The generate method accepts the prompt as input_text to produce output text.
4fill in blank
hardFill both blanks to create a dictionary comprehension that maps prompts to their generated outputs using the LLM wrapper.
Prompt Engineering / GenAI
results = {prompt: llm.[1](prompt) for prompt in prompts if len(prompt) [2] 0} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '==' instead of '>' to filter prompts.
Using a wrong method name instead of generate.
✗ Incorrect
We use generate to get outputs and filter prompts with length greater than zero.
5fill in blank
hardFill all three blanks to create a list comprehension that generates outputs for prompts longer than 5 characters using the LLM wrapper.
Prompt Engineering / GenAI
outputs = [llm.[1](prompt) for prompt in prompts if len(prompt) [2] 5 and prompt.[3]('!')]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'startswith' instead of 'endswith'.
Using '<' instead of '>' for length comparison.
✗ Incorrect
We generate outputs for prompts longer than 5 characters that end with '!'.