Use labeled prefixes and incomplete structures to guide the model’s response format and intent.
Prefixes are short phrases or labels you can attach to parts of a prompt to guide the model’s understanding and output. They serve different roles based on where they’re placed:
Input prefix: This helps the model interpret sections of the input by labeling them. For instance, using “English:” and “French:” can indicate that different languages are being used.
Output prefix: Even though the model generates the output, you can lead with a prefix like “JSON:” to show that the response should follow a specific format.
Example prefix: In few-shot prompts, labeling examples with prefixes makes it easier for the model to recognize patterns and generate consistent, easy-to-understand results.
For example, in the prompt: Text: signals the input section, and The answer is: signals the beginning of the expected output.
Example Prompt:
Response:
Language models function similarly to powerful autocomplete systems. When you supply the beginning of a sentence, structure, or task, the model can predict and continue the rest based on that starting point. If your prompt includes examples or additional context, the model can use that information to generate a more relevant and accurate continuation.
Example Prompt:
Response:
Although the model followed the instructions, describing the task in plain language can sometimes be tricky and may lead to varied interpretations. For instance, if someone says “Can I get two bananas and an orange?”, the model should generate a JSON object that includes only those items—banana and orange—and exclude fields like apple or grapes that weren’t mentioned. To make the task clearer and guide the output structure, it’s more effective to include a few-shot example with a response prefix like Output: so the model can complete the response by following the pattern shown.
Example Prompt:
Response:
Notice how “grapes” was excluded from the output because it wasn’t a part of the order.
You can also guide the model to structure its output by using a completion-based approach. For example, the prompt below asks the model to generate an outline for an essay.
Example Prompt:
Response:
The prompt didn’t include instructions about how the outline should be structured, so the model selected a format on its own. If you want the model to follow a specific structure, you can provide the beginning of the outline in your desired format. The model will then continue generating the rest to match the pattern you’ve started.
Example Prompt:
Response:
📝 Summary: