PIXELBANKv9.1.0
Menu

Build a few-shot prompt from examples and a query.

Given a system instruction, N example pairs (input → output), and a query, construct a prompt in the format:

{system}

Example 1:
Input: {example_input}
Output: {example_output}

Example 2:
...

Query:
Input: {query}
Output:

Input:

  • Line 1: System instruction
  • Line 2: N (number of examples)
  • Next 2N lines: alternating input/output for each example
  • Last line: Query input

Output: The formatted prompt string.

Example:

Input:
Classify sentiment as positive or negative.
2
I love this!
positive
This is terrible.
negative
Pretty good product.
Output:
Classify sentiment as positive or negative.

Example 1:
Input: I love this!
Output: positive

Example 2:
Input: This is terrible.
Output: negative

Query:
Input: Pretty good product.
Output:
Reasoning:
  • The system instruction Classify sentiment as positive or negative. is used as the header of the prompt.
  • The number of examples 2 indicates that two example pairs will be included in the prompt, with each pair consisting of an input and an output.
  • The example pairs are formatted into the prompt as Example 1 and Example 2, with their respective inputs and outputs: I love this! / positive and This is terrible. / negative.
  • The query input Pretty good product. is added to the prompt with a blank output, awaiting the user's response.

Constraints:

  • N >= 0 (zero-shot if N=0)
  • Each example has exactly one input line and one output line
  • Blank line between system instruction and first example
  • Blank line between each example
  • "Output:" at end has no trailing content
solution.py

Test Results

0/0
Run code to see test results.
Few-Shot Prompt Builder - Easy | PixelBank