Examples in Your Prompt (k-shot / n-shot method)
Theoretical Approach
In theory, examples in your prompt should closely match the final Input and Output. However, this can lead to certain issues.
Practical Considerations
1. Long or Repeated Input Parameters
If one parameter in the Input is excessively long and repeated across every example, it can overshadow the rest of the content. This dilutes the relevance and clarity of the example.
2. Reasoning in Examples
While reasoning is useful for generating outputs, including it in examples can cause unnecessary distraction and increase cognitive load. This may reduce the overall effectiveness of the prompt. Idem with the Grounding parameters (useless once they played their role).
Adjusted Approach
To address these issues, I’ve started omitting GROUNDING and REASONING variables from the examples, focusing solely on the SOLUTION. Consider the problem as A-B-C: show A and C, while leaving out B if it doesn’t serve as an optimal intermediate step.
Handling Large or Irrelevant Input Parameters
For Input parameters that are irrelevant or too large for the examples, you can replace them with placeholders such as None
or null
. This maintains the structure of the Input while simplifying the example, making it easier to “relate examples.”
Example
Original Example:
Input:
paragraph: str
q1: str
q2: str
Output:
a1: str
a2: str
If the paragraph
is too large, the relationship between q1/q2
and a1/a2
becomes diluted.
Revised Example:
Input:
paragraph: None
summary: str # Here you provide a short text that acts as replacement for the long `paragraph`.
q1: str
q2: str
Output:
a1: str
a2: str
This adjustment preserves the Input’s structure while avoiding the distraction of overly lengthy parameters.
Key Principle
It’s crucial that all Inputs share the same structure, even if some variables are replaced with None
, null
, or NaN
. This approach is common in machine learning (ML) and deep learning (DL) systems and ensures consistency while reducing noise.
I know the Final Output has a few more parameters than all the Examples, but your interest is in HOW the variables that matter are generated, and that is what the Examples are there for, to show the Output = function (Input)
whatever function
is.
Other approach
If your k-shots have a common parameter, you could include it in the system_message
system:
- role
- task
- common_info
- examples of input / output (the common_info applies to all)
user:
- input
- output and format
A you build more and more verified examples, the new ones are surrounded by so many deeply-in-context examples, that doing the task wrong becomes difficult.
Some may say that this feels like overfitting. Somehow it is. But the fitting is done by the careful selection of examples close to the solution.