0
0
NLPml~20 mins

Why text generation creates content in NLP - Challenge Your Understanding

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Text Generation Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Why does text generation produce new content?

Text generation models create new sentences instead of copying existing ones. Why is this possible?

ABecause the model stores all sentences from training and randomly selects one to output.
BBecause the model learns patterns and relationships in language, allowing it to predict and create new sequences.
CBecause the model uses a fixed dictionary of phrases and repeats them in order.
DBecause the model only copies the first sentence it saw during training.
Attempts:
2 left
💡 Hint

Think about how the model understands language structure rather than memorizing exact sentences.

Predict Output
intermediate
2:00remaining
Output of a simple text generation step

Given a trained language model that predicts the next word, what is the output of this code snippet?

NLP
import random

vocab = ['hello', 'world', 'machine', 'learning']

# Simulate next word prediction probabilities
probs = [0.1, 0.7, 0.1, 0.1]

next_word = random.choices(vocab, weights=probs, k=1)[0]
print(next_word)
ASyntaxError because random.choices is used incorrectly
B"hello" always because it is first in vocab
C"world" most likely, but could be any word from vocab
D"machine" always because it has the highest probability
Attempts:
2 left
💡 Hint

random.choices picks based on weights but can pick any word.

Model Choice
advanced
2:00remaining
Choosing a model type for creative text generation

You want to build a system that writes creative stories with varied vocabulary and style. Which model type is best?

AA simple Markov chain model based on word transitions
BA bag-of-words model that ignores word order
CA rule-based system with fixed sentence templates
DA large transformer-based language model trained on diverse text
Attempts:
2 left
💡 Hint

Consider which model can capture complex language patterns and creativity.

Metrics
advanced
2:00remaining
Evaluating text generation quality

Which metric best measures how well a text generation model produces fluent and coherent sentences?

ABLEU score comparing generated text to reference text
BMean squared error between predicted and actual word embeddings
CAccuracy of classifying text sentiment
DNumber of words generated per second
Attempts:
2 left
💡 Hint

Think about metrics that compare generated text to human-written examples.

🔧 Debug
expert
3:00remaining
Why does this text generation code produce repetitive output?

Consider this code snippet generating text word by word. It produces repetitive phrases like "the the the...". What is the most likely cause?

NLP
import random

vocab = ['the', 'cat', 'sat', 'on', 'mat']
probs = [0.9, 0.025, 0.025, 0.025, 0.025]

output = []
for _ in range(5):
    next_word = random.choices(vocab, weights=probs, k=1)[0]
    output.append(next_word)
print(' '.join(output))
AThe probability distribution is too skewed, causing the model to pick "the" repeatedly.
BThe vocab list is too small to generate varied text.
Crandom.choices is not suitable for text generation and causes repetition.
DThe loop runs only 5 times, so repetition is expected.
Attempts:
2 left
💡 Hint

Look at the probabilities assigned to each word.