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:




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:


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