Challenge - 5 Problems
Code Generation Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of a simple code generation model snippet
What is the output of this Python code simulating a simple code generation model's token prediction?
Prompt Engineering / GenAI
tokens = ['def', ' ', 'add', '(', 'a', ',', ' ', 'b', ')', ':', '\n', ' ', 'return', ' ', 'a', ' ', '+', ' ', 'b'] predicted = ''.join(tokens) print(predicted)
Attempts:
2 left
💡 Hint
Look carefully at the tokens and how they join with spaces and newlines.
✗ Incorrect
The tokens include spaces and newline characters that format the function definition properly with indentation and line breaks.
❓ Model Choice
intermediate1:30remaining
Choosing the right model for code generation
Which model architecture is best suited for generating code snippets given a prompt?
Attempts:
2 left
💡 Hint
Consider models that handle long-range dependencies and context well.
✗ Incorrect
Transformer models excel at capturing long-range dependencies and context, making them ideal for code generation tasks.
❓ Hyperparameter
advanced1:30remaining
Effect of temperature on code generation output
In a code generation model, what is the effect of increasing the temperature parameter during sampling?
Attempts:
2 left
💡 Hint
Think about how temperature affects randomness in sampling.
✗ Incorrect
Higher temperature increases randomness, leading to more diverse but potentially less coherent outputs.
❓ Metrics
advanced2:00remaining
Evaluating code generation quality
Which metric is most appropriate to evaluate the functional correctness of generated code snippets?
Attempts:
2 left
💡 Hint
Think about measuring if the code actually works as intended.
✗ Incorrect
Execution accuracy tests if generated code produces correct outputs on inputs, directly measuring functional correctness.
🔧 Debug
expert2:30remaining
Debugging a code generation output error
A code generation model outputs this Python code snippet:
"def multiply(a, b):\nreturn a * b"
When running, it raises an IndentationError. What is the cause?
Prompt Engineering / GenAI
def multiply(a, b): return a * b
Attempts:
2 left
💡 Hint
Python requires code blocks to be indented properly.
✗ Incorrect
Python functions require the body to be indented; missing indentation causes IndentationError.