> 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/glinerrelationextraction.md).

# GLiNERRelationExtraction

Relation extraction task

## Default predictor

This task uses[ ](/predictors/tokensearcherpredictor.md)[**GliNERPredictor**](/predictors/glinerpredictor.md)[ ](/predictors/comprehenditpredictor.md)by default.&#x20;

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

For more details, see:

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

By default, the predictor uses the [**knowledgator/gliner-multitask-large-v0.5**](https://huggingface.co/knowledgator/gliner-multitask-large-v0.5) model. Learn more about the model here:

{% embed url="<https://huggingface.co/knowledgator/gliner-multitask-large-v0.5>" %}

Subclass of [**Task**](/tasks/task.md)**.**&#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 predictor**](#default-predictor) will be used. Defaults to None.
* <mark style="color:orange;">**preprocess**</mark>**&#x20;(Optional\[**[**Component**](/core/component.md)**], optional):** Component executed before predictor.&#x20;

  If equals to None, default component will be used. Defaults to None.\
  \
  Default component: \
  [**GLiNERPreprocessor**](/tasks/gliner.md#glinerpreprocessor) **|** [**GLiNERRelationExtractionPreprocesso**r](#glinerrelationextractionpreprocessor)
* <mark style="color:orange;">**postprocess**</mark>**&#x20;(Optional\[**[**Component**](/core/component.md)**], optional):** Component executed after predictor.&#x20;

  If equals to None, default component will be used. Defaults to None.\
  \
  Default component: \
  [**GLiNERRelationExtractionPostprocessor**](#glinerrelationextractionpostprocessor)
* <mark style="color:orange;">**input\_class**</mark>**&#x20;(Type\[**[**Input**](/core/schemas.md#input)**], optional):** Class for input validation. Defaults to [**RelationExtractionInput**](/tasks/relation-extraction-tasks-utilities.md#relationextractioninput)**.**
* <mark style="color:orange;">**output\_class**</mark>**&#x20;(Type\[**[**Output**](/core/schemas.md#output)**], optional):** Class for output validation. Defaults to [**RelationExtractionOutput**](/tasks/relation-extraction-tasks-utilities.md#relationextractionoutput)**.**
* <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;">GLiNERRelationExtractionPreprocessor</mark>

Create labels for relation extraction. 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;">**"relations"**</mark>**&#x20;(List\[**[**Relation**](/tasks/relation-extraction-tasks-utilities.md#relation)**]):** Relations parameters;
  * <mark style="color:red;">**"entities"**</mark>**&#x20;(List\[**[**ClassifiedEntity**](/tasks/objects.md#classifiedentity)**]):** Entities to use;

#### Returns:

* **Dict\[str, Any]:** \
  Expected keys:
  * <mark style="color:red;">**"labels"**</mark>**&#x20;(List\[str]):** Labels model inputs;

***

***

***

## <mark style="color:green;">GLiNERRelationExtractionPostprocessor</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;&#x20;
  * <mark style="color:red;">**"relations"**</mark>**&#x20;(List\[**[**Relation**](/tasks/relation-extraction-tasks-utilities.md#relation)**]):** Relations parameters;
  * <mark style="color:red;">**"entities"**</mark>**&#x20;(List\[**[**ClassifiedEntity**](/tasks/objects.md#classifiedentity)**]):** Entities to use;
  * <mark style="color:red;">**"chunks\_starts"**</mark>**&#x20;(List\[int]):** Chunks starts;

#### Returns:

* **Dict\[str, Any]:** \
  Expected keys:
  * <mark style="color:red;">**"output"**</mark>**&#x20;(List\[**[**Triplets**](/tasks/relation-extraction-tasks-utilities.md#triplet)**]):** Extracted relations;

***

***
