0
0
Prompt Engineering / GenAIml~10 mins

LLM wrappers in Prompt Engineering / GenAI - Interactive Code Practice

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

Complete 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'
Afit
Bgenerate
Ctrain
Dcompile
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'train' or 'fit' instead of 'generate'.
Trying to compile the model instead of generating text.
2fill in blank
medium

Complete 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'
ATrue
B12345
C'gpt-3.5-turbo'
DNone
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a number or boolean instead of a string.
Using None which means no model specified.
3fill in blank
hard

Fix 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'
Atrain
Bpredict
Cfit
Dgenerate
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.
4fill in blank
hard

Fill 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'
Agenerate
B>
C==
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using '==' instead of '>' to filter prompts.
Using a wrong method name instead of generate.
5fill in blank
hard

Fill 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'
Agenerate
B>
Cendswith
Dstartswith
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'startswith' instead of 'endswith'.
Using '<' instead of '>' for length comparison.