0
0
Prompt Engineering / GenAIml~10 mins

Why Generative AI is transforming technology in Prompt Engineering / GenAI - Test Your Understanding

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

Complete the code to generate text using a simple generative AI model.

Prompt Engineering / GenAI
generated_text = model.[1](input_prompt)
Drag options to blanks, or click blank then click option'
Agenerate
Bpredict
Cclassify
Dtrain
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'predict' instead of 'generate' because prediction is for classification tasks.
Using 'train' which is for model learning, not generating output.
2fill in blank
medium

Complete the code to load a pretrained generative AI model.

Prompt Engineering / GenAI
model = GenerativeModel.[1]('pretrained-model-name')
Drag options to blanks, or click blank then click option'
Atrain
Bcompile
Csave
Dfrom_pretrained
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'train' which starts training instead of loading.
Using 'save' which stores the model, not loads it.
3fill in blank
hard

Fix the error in the code to generate text with a maximum length.

Prompt Engineering / GenAI
output = model.generate(input_ids, max_length=[1])
Drag options to blanks, or click blank then click option'
Amaxlen
Bmax_length
C'max_len'
Dlength_max
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect parameter names like 'max_len' or 'maxlen' which cause errors.
4fill in blank
hard

Fill both blanks to create a dictionary of word counts from generated text.

Prompt Engineering / GenAI
word_counts = [1]((word, text.split().count(word)) for word in [2](text.split()))
Drag options to blanks, or click blank then click option'
Adict
Blist
Cset
Dtuple
Attempts:
3 left
💡 Hint
Common Mistakes
Using list instead of dict causes a list of tuples, not a dictionary.
Using list instead of set for unique words causes repeated counts.
5fill in blank
hard

Fill all three blanks to filter generated sentences longer than 5 words and create a list of their lengths.

Prompt Engineering / GenAI
filtered_lengths = [len(sentence.split()) for sentence in sentences if len(sentence.split()) [1] [2] if len(sentence.split()) [3] 5]
Drag options to blanks, or click blank then click option'
A>
B5
C<
D==
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' or '==' which filter wrong sentences.
Mixing operators causing syntax errors.