
Ultimate access to all questions.
Deep dive into the quiz with AI chat providers.
We prepare a focused prompt with your quiz and certificate details so each AI can offer a more tailored, in-depth explanation.
Which approach is most effective for improving the security of code generated by an LLM?
A
Provide recent secure-code examples and ask the LLM to generalize (few-shot)
B
Ask the LLM to "think step-by-step" using chain-of-thought
C
Role-play as a "Security Auditor" without examples
D
Use sampling temperature of 1.2 for creativity
Explanation:
Option A is correct because providing recent secure-code examples and asking the LLM to generalize (few-shot learning) is the most effective approach for improving code security. This method:
Provides concrete examples of secure coding patterns
Demonstrates real-world security practices that the LLM can learn from
Uses few-shot learning which is effective for teaching LLMs specific patterns
Generalizes from examples to apply security principles to new code
Why other options are less effective:
Option B (Chain-of-thought): While asking the LLM to "think step-by-step" can improve reasoning, it doesn't specifically teach secure coding practices unless security considerations are explicitly included in the reasoning chain.
Option C (Role-playing without examples): Simply role-playing as a security auditor without providing examples lacks concrete guidance on what constitutes secure code.
Option D (High temperature for creativity): Using a higher sampling temperature (1.2) increases randomness and creativity, which could actually lead to less secure code as the LLM might generate unconventional or untested patterns.
Best Practice: The most effective approach combines few-shot learning with security-focused examples, as this directly teaches the LLM secure coding patterns through demonstration rather than relying on abstract reasoning or role-playing alone.