Summary audio
Spoken summary — press play to read along: the line being spoken stays near the top.
Study notes
Study Notes: Prompt Engineering with Stop Sequences and Message Prefilling
- Purpose of Techniques:
- Message Prefilling: Used to guide the Large Language Model (LLM) into a specific response format or content structure. It is not limited to just characters; it can include full instructions.
- Stop Sequences: Used to tell the LLM exactly when to cease generating output.
- Core Strategy for Clean Output:
- To prevent initial commentary, use a prefilled assistant message that starts with the desired formatting (e. g. , three backticks `).
- Set the stop sequence to the same formatting (e. g. , three backticks `) to ensure the LLM stops generating text once the code block is complete.
- Addressing Formatting Issues:
- Language Identifiers: When using code blocks (e. g. , three backticks), the LLM may automatically insert a language identifier (like bash) for syntax highlighting.
- Guiding Syntax: To prevent unwanted identifiers, explicitly include the desired language in the prefilled message (e. g. , bash `).
- Enforcing Output Structure: To prevent the LLM from adding extra commentary or generating multiple separate code blocks, use a highly specific prefilled instruction (e. g. , "Here are all three commands in a single block without any comments. ").
Takeaways
- Message prefilling guides the LLM into a specific response format or content structure, while stop sequences dictate exactly when the LLM must cease output generation.
- To achieve clean output, use a prefilled message that starts with the desired formatting and set the stop sequence to match that same formatting.
- To prevent the LLM from automatically inserting unwanted language identifiers in code blocks, explicitly include the desired language in the prefilled message.
- Highly specific prefilled instructions are required to enforce strict output structure and prevent the LLM from adding extra commentary or generating multiple blocks.
Flashcards 7 cards
Question
click to reveal · ←/→
Answer
click to flip back
Knowledge check 1 questions