> For the complete documentation index, see [llms.txt](https://utca.knowledgator.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://utca.knowledgator.com/tasks/gliner.md).

# GLiNER

NER task

This task uses[ ](/predictors/tokensearcherpredictor.md)[**GliNERPredictor**](/predictors/glinerpredictor.md)[ ](/predictors/comprehenditpredictor.md)by default. For more details, see:

{% content-ref url="/pages/kgWzfTNnWBcJy00z7TvK" %}
[GLiNERPredictor](/predictors/glinerpredictor.md)
{% endcontent-ref %}

Subclass of [**NERTask**](/tasks/task.md#nertask)**.**&#x20;

## Module: [implementation](/framework-structure.md#implementation).tasks

## Methods and properties

Main methods and properties

***

### <mark style="color:blue;">\_\_init\_\_</mark>

#### Arguments:

* <mark style="color:orange;">**predictor**</mark>**&#x20;(**[**Predictor**](/predictors/predictor.md)**\[Any, Any], optional):** Predictor that will be used in task. If equals to None, default [**GliNERPredictor**](/predictors/glinerpredictor.md) will be used. Defaults to None.
* <mark style="color:orange;">**preprocess**</mark>**&#x20;(Optional\[**[**Component**](/core/component.md)**], optional):** Component executed before predictor. If equals to None, default component will be used. Defaults to None.\
  \
  Default component: \
  [**GliNERPreprocessor**](#glinerpreprocessor)
* <mark style="color:orange;">**postprocess**</mark>**&#x20;(Optional\[**[**Component**](/core/component.md)**], optional):** Component executed after predictor. If equals to None, default component will be used. Defaults to None.\
  \
  Default component: \
  [**GliNERPostprocessor**](#glinerpostprocessor)
* <mark style="color:orange;">**input\_class**</mark>**&#x20;(Type\[**[**Input**](/core/schemas.md#input)**], optional):** Class for input validation. Defaults to [**GliNERInput**](#glinerinput)**.**
* <mark style="color:orange;">**output\_class**</mark>**&#x20;(Type\[**[**NEROutputType**](/tasks/task.md#neroutputtype)**], optional):** Class for output validation. Defaults to [**GliNEROutput**](#glineroutput)**.**
* <mark style="color:orange;">**name**</mark>**&#x20;(Optional\[str], optional):** Name for identification. If equals to None, class name will be used. Defaults to None.

***

***

***

## <mark style="color:green;">GliNERInput</mark>

Subclass of [**IOModel**](/core/schemas.md#iomodel)**.**

***

### <mark style="color:blue;">\_\_init\_\_</mark>

#### Arguments:

* <mark style="color:orange;">**text**</mark>**&#x20;(str):** Text to process.
* <mark style="color:orange;">**labels**</mark>**&#x20;(List\[str]):** Labels for classification.

***

***

***

## <mark style="color:green;">GliNEROutput</mark>

Subclass of [**NEROutput**](/tasks/task.md#neroutput). Type of [**NEROutput**](/tasks/task.md#neroutput)**\[**[**ClassifiedEntity**](/tasks/objects.md#classifiedentity)**].**

***

### <mark style="color:blue;">\_\_init\_\_</mark>

#### Arguments:

* <mark style="color:orange;">**text**</mark>**&#x20;(str):** Input text.
* <mark style="color:orange;">**output**</mark>**&#x20;(List\[**[**ClassifiedEntity**](/tasks/objects.md#classifiedentity)**]):** Classified entities.

***

***

***

## <mark style="color:green;">GLiNERPreprocessor</mark>

Create prompts with providied text. Subclass of [**Action**](/core/action.md). Type of [**Action**](/core/action.md)**\[Dict\[str, Any], Dict\[str, Any]].**

***

### <mark style="color:blue;">\_\_init\_\_</mark>

#### Arguments:

* <mark style="color:orange;">**sents\_batch**</mark>**&#x20;(int):** Chunks size in sentences. Defaults to 10.
* <mark style="color:orange;">**threshold**</mark>**&#x20;(float):** Minimial score to put entities into the output (used by predictor). Defaults to 0.5.
* <mark style="color:orange;">**name**</mark>**&#x20;(Optional\[str], optional):** Name for identification. If equals to None, class name will be used. Defaults to None.

***

### <mark style="color:blue;">execute</mark>

#### Arguments:

* <mark style="color:orange;">**input\_data**</mark>**&#x20;(Dict\[str, Any]):** \
  Expected keys:
  * <mark style="color:red;">**"text"**</mark>**&#x20;(str):** Text to process;

#### Returns:

* **Dict\[str, Any]:** \
  Expected keys:
  * <mark style="color:red;">**"texts"**</mark>**&#x20;(List\[str]):** Model inputs;
  * <mark style="color:red;">**"chunks\_starts"**</mark>**&#x20;(List\[int]):** Chunks start positions. Used by postprocessor;
  * <mark style="color:red;">**"threshold"**</mark>**&#x20;(List\[int]):** Minimial score to put entities into the output;

***

***

***

## <mark style="color:green;">GLiNERPostprocessor</mark>

Format output. Subclass of [**Action**](/core/action.md). Type of [**Action**](/core/action.md)**\[Dict\[str, Any], Dict\[str, Any]].**

***

### <mark style="color:blue;">execute</mark>

#### Arguments:

* <mark style="color:orange;">**input\_data**</mark>**&#x20;(Dict\[str, Any]):** \
  Expected keys:
  * <mark style="color:red;">**"output"**</mark>**&#x20;(List\[List\[Dict\[str, Any]]]):** Model output;
  * <mark style="color:red;">**"text"**</mark>**&#x20;(str):** Processed text;
  * <mark style="color:red;">**"chunks\_starts"**</mark>**&#x20;(List\[int]):** Chunks starts;

#### Returns:

* **Dict\[str, Any]:** \
  Expected keys:
  * <mark style="color:red;">**"text"**</mark>**&#x20;(str):** Processed text;
  * <mark style="color:red;">**"output"**</mark>**&#x20;(List\[**[**ClassifiedEntity**](/tasks/objects.md#classifiedentity)**]):** Classified entities;

***

***
