what is a good way to give context to LLMs? Like saying "this is an example", "this is…
- User
what is a good way to give context to LLMs? Like saying "this is an example", "this is the resulting output of the example", "this is the specific input you should process" and so on ?
- Assistant
Great question! Providing clear context to large language models (LLMs) is crucial for getting accurate and relevant responses. Here are some effective strategies and phrasing patterns to give context clearly and explicitly:
1. Use explicit labels and structure
Clearly label each part of your input so the model understands the role of each segment.
Example:
Example Input: [Insert example input here] Example Output: [Insert example output here] Task: [Describe the specific input you want the model to process]
2. Use natural language instructions
LLMs respond well to natural language instructions that explicitly state what you want.
Example:
Here is an example of the task: Input: "Translate 'Hello' to French." Output: "Bonjour" Now, please translate the following input: Input: "Good morning"
3. Use delimiters or separators
Use clear separators like lines, bullet points, or special tokens to distinguish sections.
Example:
--- Example --- Input: "Add 2 and 3" Output: "5" --- End Example --- Now, process this input: Input: "Add 10 and 15"
4. Explicitly state the role of each part
You can say things like:
- "This is an example input."
- "This is the expected output for the example."
- "This is the new input you should process."
- "Your task is to generate the output for the new input."
5. Use few-shot prompting
Provide a few examples with input-output pairs, then give the new input and ask for the output.
Example:
Example 1: Input: "What is 2 + 2?" Output: "4" Example 2: Input: "What is 5 + 7?" Output: "12" Now, answer this: Input: "What is 10 + 15?" Output:
Summary of good phrases to use:
- "Here is an example:"
- "Example input:"
- "Example output:"
- "This is the input you should process:"
- "Your task is to generate the output for the input above."
- "Based on the examples, please provide the output for the following input:"
- "Now, given the input below, produce the corresponding output."
If you want, I can help you craft a prompt template tailored to your specific use case! Would you like that?
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.