Complete the code to generate a simple text output using a language model.
output = model.generate([1])The generate function needs the input text to start generating related text.
Complete the code to limit the length of generated text.
output = model.generate(input_text, [1]=50)
The max_length parameter controls how many tokens the model generates.
Fix the error in the code to generate text with controlled randomness.
output = model.generate(input_text, max_length=50, [1]=0.7)
The temperature parameter controls randomness in text generation; setting it to 0.7 adds some creativity.
Fill both blanks to create a dictionary of word counts from generated text.
word_counts = {word: [1] for word in output.split() if len(word) [2] 3}We count the length of each word and keep only words longer than 3 characters.
Fill all three blanks to filter and transform generated sentences.
filtered = [sentence.[1]() for sentence in output.split('.') if 'AI' [2] sentence and len(sentence) [3] 20]
We remove spaces with strip(), check if 'AI' is in the sentence, and keep sentences shorter than 20 characters.