<< Home | Prompting craft
Stop unwanted intro filler and force clean output
| Area | Prompting craft |
| AI used | Llama3 8b |
| Source | Reddit thread |
| Posted | unknown |
The move
Prepend the AI response with a fixed starting prefix and set a matching stop word.| When this works | When it doesn't |
|---|---|
| When an LLM like Llama3 8b adds conversational filler, intro sentences, quotes, or unexpected list formatting, and setting up complex grammars like GBNF or Guidance is too much hassle. | When your API platform does not permit prefilling assistant messages, or when the task requires dynamic multi-step output formats. |
Key details
- Here is the summary:\n```\n
- ``` as a stopping word
- GBNF or Guidance
Prompt for your AI
When generating output, eliminate all conversational filler, introductory sentences, markdown titles, and formatting wrapping.
You must strictly output raw content by following a forced prefix and stop sequence pattern:
1. Response Prefill / Anchoring:
Begin the generation immediately following the enforced prefix string:
`Here is the summary:\n```\n`
Do not repeat the prefix string. Treat the opening code block delimiter as already written, leaving zero room for conversational intros like "Here is the summary:" or extra text before the main content.
2. Generation Rule:
Provide only the requested answer directly inside the code block container. Do not add quotation marks around the output, bullet lists, or extra explanatory notes unless explicitly requested.
3. Termination:
End the output generation immediately with the stop sequence:
```` `
Stop generating tokens as soon as the closing markdown delimiter is reached.
If full grammar constraints such as GBNF or Guidance are unavailable or too complex to implement, use this prefilling technique to lock the output format without relying on negative prompting.
Before you give me the final result, check with me:
- Confirm that your API or runtime supports prefilling the AI assistant response prefix.
- Verify that '```' is registered as an active stop word parameter in the request.
- Check that negative prompting is removed or minimized so it does not conflict with the anchored prefix.
What happened
A user struggled with Llama3 8b adding unwanted intros like 'Here is the summary:' and random bullet formatting. Negative prompting failed to control it. They prepended the model response with 'Here is the summary:\n```\n' and set '```' as a stop word, forcing the model to output only the clean summary.Who confirmed it
The user noted this is the 'easiest way' to control output when grammar constraints like GBNF are too much of a hassle.Give it to your agent
Read https://howtheyuse.ai/p/force-raw-output-format-using-prefix-anchoring.md and help me do this.