TransformersEntityLinking

Entity linking task

Subclass of Task.

Module: implementation.tasks

Default predictor

This task uses TransformersModel by default with this configuration:

model = AutoModel.from_pretrained("openai-community/gpt2")
predictor = TransformersGenerativeModel(
    TransformersModelConfig(
        model=model,
        kwargs={
            "max_new_tokens": 512,
            "pad_token_id": self.pad_token_id,
            "return_dict_in_generate": True,
            "output_scores": True, 
        }
    ),
    input_class=TransformersEntityLinkingInput,
    output_class=TransformersEntityLinkingOutput,
)

See:

Methods and properties

Main methods and properties


__init__

Arguments:

  • labels (List[str]): Labels to link.

  • tokenizer (Optional[Union[str, PreTrainedTokenizer, PreTrainedTokenizerFast]], optional): Tokenizer to use. Defaults to None.

  • predictor (Predictor[Any, Any], optional): Predictor that will be used in task. If equals to None, default predictor 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: EntityLinkingPreprocessor

  • postprocess (Optional[Component], optional): Component executed after predictor. If equals to None, default component will be used. Defaults to None. Default component: EntityLinkingPostprocessor If default chain is used, EntityLinkingPostprocessor will use provided tokenizer or tokenizer from predictor model.

  • input_class (Type[Input], optional): Class for input validation. Defaults to EntityLinkingInput.

  • output_class (Type[Output], optional): Class for output validation. Defaults to EntityLinkingOutput.

  • name (Optional[str], optional): Name for identification. If equals to None, class name will be used. Defaults to None.




EntityLinkingInput

Subclass of IOModel.


__init__

Arguments:

  • texts (List[str]): Texts to process.

  • num_beams (int)

  • num_return_sequences (int)




EntityLinkingOutput

Subclass of IOModel.


__init__

Arguments:

  • classification_output (Any)




EntityLinkingPreprocessor

Prepare prompts for model. Subclass of Action. Type of Action[Dict[str, Any], Dict[str, Any]].


execute

Arguments:

  • input_data (Dict[str, Any]): Expected keys:

    • "texts" (List[str]): Texts to process;

Returns:

  • Dict[str, Any]: Expected keys:

    • "texts" (Any): Prompts;




EntityLinkingPostprocessor

Process model output. Subclass of Action. Type of Action[Dict[str, Any], Dict[str, Any]].


__init__

Arguments:

  • encoder_decoder (bool): Model configuration parameter.

  • 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:

    • "sequences" (Any): Model output;

    • "sequences_scores" (Optional[Any], optional): Used if num_beams > 1. Defaults to None;

    • "num_beams" (int);

    • "texts" (List[str]): Processed prompts;

Returns:

  • Dict[str, Any]: Expected keys:

    • "classification_output" (Any): Formatted output;



Last updated