Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to initialize the agent's model with a transformer architecture.
Agentic AI
agent_model = TransformerModel([1]=512, num_layers=6)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'learning_rate' instead of 'hidden_size' here.
Confusing 'batch_size' with model architecture parameters.
✗ Incorrect
The 'hidden_size' parameter sets the size of the hidden layers in the transformer model.
2fill in blank
mediumComplete the code to tokenize input text before feeding it to the agent.
Agentic AI
tokens = tokenizer.[1](input_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 'generate' which is for producing output, not tokenizing.
✗ Incorrect
Tokenization converts text into tokens using the 'encode' method.
3fill in blank
hardFix the error in the code to correctly generate code output from the agent.
Agentic AI
generated_code = agent.[1](input_tokens) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'train' which is for learning, not generating output.
Using 'generate_code' which is not a standard method name.
✗ Incorrect
The 'predict' method is used to get the agent's output given input tokens.
4fill in blank
hardFill both blanks to create a dictionary comprehension that maps function names to their code strings if the code length is less than 50.
Agentic AI
code_map = {func_name: [1] for func_name, [2] in functions.items() if len(code) < 50} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using inconsistent variable names for the code string.
Confusing keys and values in the dictionary comprehension.
✗ Incorrect
The comprehension maps function names to their code strings stored in 'code', iterating over 'functions.items()' with 'func_name' and 'code'.
5fill in blank
hardFill all three blanks to filter and map functions with names starting with 'gen' and code length over 30.
Agentic AI
filtered_funcs = { [1]: [2] for [3], code in all_functions.items() if [3].startswith('gen') and len(code) > 30 } Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names inconsistently.
Not matching the loop variables with the condition variables.
✗ Incorrect
The comprehension uses 'func_name' as key and 'code' as value, iterating over 'func_name, code' in all_functions.items().
