TokenSearcherRelationExtraction
Relation extraction task
This task uses TokenSearcherPredictor by default. For more details, see:
TokenSearcherPredictorSubclass of Task.
Module: implementation.tasks
Methods and properties
Main methods and properties
__init__
Arguments:
predictor (Predictor[Any, Any], optional): Predictor that will be used in task. If equals to None, default TokenSearcherPredictor will be used. Defaults to None.
preprocess (Optional[Component], optional): Component executed before predictor.
If equals to None, default component will be used. Defaults to None. Default component: TokenSearcherRelationExtractionPreprocessor
postprocess (Optional[Component], optional): Component executed after predictor.
If equals to None, default component will be used. Defaults to None. Default component: TokenSearcherRelationExtractionPostprocessor
input_class (Type[Input], optional): Class for input validation. Defaults to RelationExtractionInput.
output_class (Type[Output], optional): Class for output validation. Defaults to RelationExtractionOutput.
name (Optional[str], optional): Name for identification. If equals to None, class name will be used. Defaults to None.
TokenSearcherRelationExtractionPreprocessor
Create prompt with providied text. Subclass of Action. Type of Action[Dict[str, Any], Dict[str, Any]].
execute
Arguments:
input_data (Dict[str, Any]): Expected keys:
"text" (str): Text to process;
"relations" (List[Relation]): Relations parameters;
"entities" (List[ClassifiedEntity]): Entities to use;
Returns:
Dict[str, Any]: Expected keys:
"source_entities" (List[ClassifiedEntity]): Source entities to use;
"relations_labels" (List[str]): Corresponding relations labels;
"inputs" (List[str]): Model inputs;
"prompt_lengths" (List[int]): Prompt lenghts. Used by postprocessor;
TokenSearcherRelationExtractionPostprocessor
Format output. Subclass of Action. Type of Action[Dict[str, Any], Dict[str, Any]].
__init__
Arguments:
threshold (float): Relations threshold score. Defaults to 0.
name (Optional[str], optional): Name for identification. If equals to None, class name will be used. Defaults to None.
execute
Arguments:
input_data (Dict[str, Any]): Expected keys:
"text" (str): Processed text;
"output" (List[List[Dict[str, Any]]]): Model output;
"relations" (List[Relation]): Relations parameters;
"source_entities" (List[ClassifiedEntity]): Used source entities;
"relations_labels" (List[str]): Corresponding relations labels;
"entities" (List[ClassifiedEntity]): Entities to use;
"prompt_lengths" (List[int]): Prompt lenghts;
Returns:
Dict[str, Any]: Expected keys:
"output" (List[Triplets]): Extracted relations;
Last updated