GLiNER
NER task
This task uses GliNERPredictor by default. For more details, see:
GLiNERPredictorSubclass 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 GliNERPredictor 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: GliNERPreprocessor
postprocess (Optional[Component], optional): Component executed after predictor. If equals to None, default component will be used. Defaults to None. Default component: GliNERPostprocessor
input_class (Type[Input], optional): Class for input validation. Defaults to GliNERInput.
output_class (Type[NEROutputType], optional): Class for output validation. Defaults to GliNEROutput.
name (Optional[str], optional): Name for identification. If equals to None, class name will be used. Defaults to None.
GliNERInput
Subclass of IOModel.
__init__
Arguments:
text (str): Text to process.
labels (List[str]): Labels for classification.
GliNEROutput
Subclass of NEROutput. Type of NEROutput[ClassifiedEntity].
__init__
Arguments:
text (str): Input text.
output (List[ClassifiedEntity]): Classified entities.
GLiNERPreprocessor
Create prompts with providied text. 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;
Returns:
Dict[str, Any]: Expected keys:
"texts" (List[str]): Model inputs;
"chunks_starts" (List[int]): Chunks start positions. Used by postprocessor;
"threshold" (List[int]): Minimial score to put entities into the output;
GLiNERPostprocessor
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;
"text" (str): Processed text;
"chunks_starts" (List[int]): Chunks starts;
Returns:
Dict[str, Any]: Expected keys:
"text" (str): Processed text;
"output" (List[ClassifiedEntity]): Classified entities;
Last updated