AIF-C01 ยท Prompt engineering
Prompt best practices and risks
Specificity, concision, experimentation and guardrails, versus prompt exposure, poisoning, hijacking and jailbreaking.
Key points
- Best practice: be specific and concise, give clear instructions, and experiment and iterate.
- Risks: exposure or leaking (revealing the prompt), poisoning (tainted data or examples steering outputs), hijacking or injection (user text overrides your instructions) and jailbreaking (bypassing safety behaviour).
- Guardrails help filter such attacks.
Source: https://docs.aws.amazon.com/bedrock/latest/userguide/prompt-management.html
Practice questions
Which habit most improves the quality of prompts over time?
- Testing variations and comparing the outputs
- Making every prompt as long as possible
- Reusing one wording for every model
- Avoiding specific details to stay flexible
Show answer
Answer: A. Testing variations and comparing the outputs
Experimenting with variations and comparing results is how prompts improve. Longer is not better, and fixed wording ignores model differences.
Which measures help defend a Bedrock-based application against prompt attacks?
- Attach a guardrail with the prompt attack filter
- Validate and sanitize user input before sending it
- Trust user input because the model is safe by default
- Merge user text directly into the system prompt unmarked
- Rely only on a longer prompt
Show answer
Answer: A. Attach a guardrail with the prompt attack filter, B. Validate and sanitize user input before sending it
Guardrails with prompt-attack filters and input validation are recommended defences. Hiding the prompt in the UI does not stop injection, and removing all instructions would remove the app's behaviour.
True or false: because AWS secures the Bedrock service, preventing prompt injection in your application is AWS's responsibility.
Show answer
Answer: False
False. Under the shared responsibility model, prompt injection is an application-level concern that the customer must address, much like SQL injection.
Practice 8 questions on this topic in Bitzu
Short lessons, instant explanations and spaced review of what you get wrong. Free on iOS and Android.
