Restricting LLM output to the expected content type
Key Takeaway
If the LLM writes about how it created the content instead of returning only the content, add a direct, strict instruction to the prompt template that tells it to generate only the expected type of content.
A prompt template can tell the LLM exactly what kind of content to return, such as only the email message to send to a customer. Without that instruction, the LLM can write about the task of creating the content instead of just creating the content. A direct, strict instruction keeps the output to the content type you expect.
Output about the task instead of the content
A prompt template asks the LLM for a specific type of content, such as an email message to send to a customer. Sometimes the LLM returns a response about the process of creating the content, when you wanted only the content itself.
When generated output includes talk about the writing task instead of just the deliverable, the likely fix is a direct, strict instruction in the prompt template. The instruction tells the LLM to generate only the expected type of content. Adding this kind of instruction is a best practice for prompt templates. For a template that drafts a customer email, the instruction can read: "Follow these instructions strictly to generate only the message to be sent to the customer."
A retail team builds a prompt template that writes product descriptions for its online store. They run it for a new hiking backpack. The LLM replies: "Here is a description for the Summit 40L backpack. I started with the waterproof shell because shoppers care about weather, and I kept the tone upbeat." The actual description comes after that commentary. The team wanted only the description for the product page, so someone has to delete the commentary by hand each time. They add one line to the template: "Follow these instructions strictly to generate only the product description." After the change, the reply holds just the description.
The only-the-content instruction is a meta instruction. You tell the prompt to write only the email message and nothing else. Saying so out loud may seem odd, but the instruction keeps the LLM doing the writing rather than describing it.