IEPrompt

IEPrompt is the class for information extraction prompt. We are now supporting Named Entity Recognition (ner), Relation Extraction (re), Event Extraction (ee), Relational Triple Extraction (rte) and Data Augmentation (da) for re.

Constructor

__init__(self, task='ner')

Parameters

  • task(str): The task name, should be in one of ["ner", "re", "ee", "rte", "da"].

Example

from easyinstruct.prompts import IEPrompt
ie_prompt = IEPrompt("ner")

build_index

build_prompt(
    self, 
    prompt: str, 
    head_entity: str = None, 
    head_type: str = None, 
    tail_entity: str = None, 
    tail_type: str = None, 
    language: str = 'en', 
    instruction: str = None, 
    in_context: bool = False, 
    domain: str = None, 
    labels: List = None, 
    examples: Dict = None
)
  • In the Named Entity Recognition (ner) task, prompt parameter is the prediction text; domain is the domain of the prediction text, which can be empty; labels is the entity label set, which can also be empty.

  • In the Relation Extraction (re) task, prompt parameter is the text; domain indicates the domain to which the text belongs, and it can be empty; labels is the set of relationship type labels. If there is no custom label set, this parameter can be empty; head_entity and tail_entity are the head entity and tail entity of the relationship to be predicted, respectively; head_type and tail_type are the types of the head and tail entities to be predicted in the relationship.

  • In the Event Extraction (ee) task, prompt parameter is the prediction text; domain is the domain of the prediction text, which can also be empty.

  • In the Relational Triple Extraction (rte) task, prompt parameter is the prediction text; domain is the domain of the prediction text, which can also be empty.

  • The specific meanings of other parameters are as follows:

    • language indicates the language of the task, where en represents English extraction tasks, and ch represents Chinese extraction tasks;

    • in_context indicates whether in-context learning is used. When it is set to False, only the instruction prompt model is used for information extraction, and when it is set to True, in-context form is used for information extraction;

    • instruction parameter is used to specify the user-defined prompt instruction, and the default instruction is used when it is empty;

    • examples are the in-context examples used for in-context learning. The formats are defined as follows:

      • ner re ee

      • re da

Examples

(Please see Deepke llm for more details)

Last updated