GLiNERQandA

Q&A task

Default predictor

This task uses GliNERPredictor by default.

GLiNERPredictor(
    GLiNERPredictorConfig(model_name="knowledgator/gliner-multitask-large-v0.5")
)

For more details, see:

GLiNERPredictor

By default, the predictor uses the knowledgator/gliner-multitask-large-v0.5 model. Learn more about the model here:

Subclass of NERTask.

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

  • postprocess (Optional[Component], optional): Component executed after predictor.

    If equals to None, default component will be used. Defaults to None. Default component: GLiNERQandAPostprocessor

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

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

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




GLiNERQandAInput

Subclass of IOModel.


__init__

Arguments:

  • text (str): Text to use.

  • question (str): Question to answer.




GLiNERQandAOutput

Subclass of NEROutput. Type of NEROutput[Entity].


__init__

Arguments:

  • text (str): Input text.

  • question (str): Answered question.

  • output (List[Entity]): Answers.




GLiNERQandAPreprocessor

Preprocess inputs. Subclass of Action. Type of Action[Dict[str, Any], Dict[str, Any]].


__init__

Arguments:

  • sents_batch (int): Chunks size in sentences. Defaults to 10.

  • threshold (float): Minimial score to put entities into the output (used by predictor). Defaults to 0.5.

  • 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): Text to process;

    • "question" (str): Question to answer;

Returns:

  • Dict[str, Any]: Expected keys:

    • "texts" (List[str]): Model inputs;

    • "labels" (List[str]): Labels model inputs;

    • "chunks_starts" (List[int]): Chunks start positions. Used by postprocessor;

    • "threshold" (float): Minimal score for an entity to put into output;




GLiNERQandAPostprocessor

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


execute

Arguments:

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

    • "output" (List[List[Dict[str, Any]]]): Model output;

    • "chunks_starts" (List[int]): Chunks starts;

    • "text" (str): Processed text;

    • "question" (str): Answered question.

Returns:

  • Dict[str, Any]: Expected keys:

    • "text" (str): Processed text;

    • "question" (str): Answered question.

    • "output" (List[Entity]): Answers;



Last updated