EasyInstruct
  • Overview
  • Installation
  • Documentations
    • Prompts
      • BasePrompt
      • ICLPrompt
      • CoTPrompt
      • IEPrompt
      • IndexPrompt
      • MMPrompt
      • BatchPrompt
    • Engines
      • BaseEngine
      • Llama2Engine
      • ChatGLM2Engine
    • Generators
      • BaseGenerator
      • SelfInstructGenerator
      • BacktranslationGenerator
      • EvolInstructGenerator
      • KG2InstructGenerator
    • Selectors
      • BaseSelector
      • Deduplicator
      • LengthSelector
      • RougeSelector
      • GPTScoreSelector
      • PPLSelector
      • MTLDSelector
      • CodeSelector
      • MultiSelector
Powered by GitBook
On this page
  1. Documentations
  2. Prompts

ICLPrompt

ICLPrompt is the class for in-context learning prompts. You can desgin a few task-specific examples as prompt for instructing LLM, and then LLM can quickly figures out how to perform well on that task.

build_prompt

build_prompt(
    self, 
    prompt: str, 
    in_context_examples: List[Dict] = None, 
    n_shots: int = 2
)

Description

Build a prompt from a given string input and a list of in-context examples.

Parameters

  • prompt (str): The prompt string.

  • in_context_examples (List[Dict]): A list of in-context examples. Defaults to None.

  • n_shots (int): The number of in-context examples to use. Defaults to 2.

Example

from easyinstruct import ICLPrompt
prompts = ICLPrompt()
prompts.build_prompt(
     "Identify the animals mentioned in the sentences.", 
     in_context_examples = [{"text": "The cat is on the mat.", "label": "cat"}, {"text": "The dog is on the rug.", "label": "dog"}], 
     n_shots = 2
)
PreviousBasePromptNextCoTPrompt

Last updated 1 year ago