def _build_few_shot_prompts(
    example: WinoDictExample,
    samples: Sequence[WinoDictExample],
    strategy: Callable[[WinoDictExample], Prompts],
) -> Prompts:
  """Builds a few-shot prompt given samples."""
  # For each sample used for ICL, we add the 2 prompts coming from both words.
  sample_prompts = ([], [])
  for sample in samples:
    prompt1, _, prompt2, _ = strategy(sample)
    # Concatenated *correct* input and output from the sample using both words.
    sample_prompt1 = ' '.join(prompt1)
    sample_prompt2 = ' '.join(prompt2)
    sample_prompts[0].append(sample_prompt1)
    sample_prompts[1].append(sample_prompt2)

  # Each sample is repeated for both the positive and negative example.
  prompt_parts = (sample_prompts[0], sample_prompts[0], sample_prompts[1],
                  sample_prompts[1])
  return tuple(('\n\n'.join(prompt_part + [part[0]]), part[1])
               for prompt_part, part in zip(prompt_parts, strategy(example)))
Builds a few-shot prompt given samples.
language/wino_dict/utils.py