Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to generate text using a simple model.
NLP
generated_text = model.[1](input_sequence) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'fit' instead of 'predict' which trains the model rather than generating output.
Using 'compile' which prepares the model but does not generate output.
✗ Incorrect
The predict method is used to generate output from the model given an input sequence.
2fill in blank
mediumComplete the code to prepare input text for the model.
NLP
input_sequence = tokenizer.[1](raw_text) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'decode' which converts tokens back to text.
Using 'fit' which is for training the tokenizer.
✗ Incorrect
The encode method converts raw text into tokens the model can understand.
3fill in blank
hardFix the error in the code to generate text from the model.
NLP
output = model.predict([1]) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing raw text directly causes errors.
Passing the tokenizer or model object instead of input data.
✗ Incorrect
The model expects tokenized input, so we must pass input_sequence, not raw text.
4fill in blank
hardFill both blanks to convert model output tokens back to readable text.
NLP
decoded_text = tokenizer.[1](output_tokens, [2]=True)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'encode' instead of 'decode' reverses the process.
Not skipping special tokens results in extra symbols in output.
✗ Incorrect
Use decode to convert tokens to text and skip_special_tokens=True to remove special tokens.
5fill in blank
hardFill all three blanks to generate text and decode it properly.
NLP
input_seq = tokenizer.[1](text) output_tokens = model.[2](input_seq) result = tokenizer.[3](output_tokens, skip_special_tokens=True)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'fit' instead of 'encode' or 'predict'.
Decoding before prediction causes errors.
✗ Incorrect
First encode the text, then predict output tokens, finally decode tokens to text.