gliner.config module

class gliner.config.BaseGLiNERConfig(model_name='microsoft/deberta-v3-small', name='gliner', max_width=12, hidden_size=512, dropout=0.4, fine_tune=True, subtoken_pooling='first', span_mode='markerV0', post_fusion_schema='', num_post_fusion_layers=1, vocab_size=-1, max_neg_type_ratio=1, max_types=25, max_len=384, words_splitter_type='whitespace', num_rnn_layers=1, fuse_layers=False, embed_ent_token=True, class_token_index=-1, encoder_config=None, ent_token='<<ENT>>', sep_token='<<SEP>>', _attn_implementation=None, **kwargs)[source]

Bases: PretrainedConfig

Base configuration class for all GLiNER models.

Initialize BaseGLiNERConfig.

Parameters:
  • model_name (str, optional) – Name of the pretrained encoder model. Defaults to “microsoft/deberta-v3-small”.

  • name (str, optional) – Name identifier for the GLiNER model. Defaults to “gliner”.

  • max_width (int, optional) – Maximum span width for entity detection. Defaults to 12.

  • hidden_size (int, optional) – Dimension of hidden representations. Defaults to 512.

  • dropout (float, optional) – Dropout probability. Defaults to 0.4.

  • fine_tune (bool, optional) – Whether to fine-tune the encoder. Defaults to True.

  • subtoken_pooling (str, optional) – Subtoken pooling strategy. Defaults to “first”.

  • span_mode (str, optional) – Span representation mode. Defaults to “markerV0”.

  • post_fusion_schema (str, optional) – Post-fusion processing schema. Defaults to ‘’.

  • num_post_fusion_layers (int, optional) – Number of post-fusion layers. Defaults to 1.

  • vocab_size (int, optional) – Vocabulary size. Defaults to -1.

  • max_neg_type_ratio (int, optional) – Max ratio of negative to positive types. Defaults to 1.

  • max_types (int, optional) – Maximum number of entity types. Defaults to 25.

  • max_len (int, optional) – Maximum sequence length. Defaults to 384.

  • words_splitter_type (str, optional) – Word splitter type. Defaults to “whitespace”.

  • num_rnn_layers (int, optional) – Number of LSTM layers, if less then 1, then LSTM is not used.

  • fuse_layers (bool, optional) – Whether to fuse layers. Defaults to False.

  • embed_ent_token (bool, optional) – Whether to embed entity tokens. Defaults to True.

  • class_token_index (int, optional) – Index of class token. Defaults to -1.

  • encoder_config (dict, optional) – Encoder configuration dict. Defaults to None.

  • ent_token (str, optional) – Entity marker token. Defaults to “<<ENT>>”.

  • sep_token (str, optional) – Separator token. Defaults to “<<SEP>>”.

  • _attn_implementation (str, optional) – Attention implementation. Defaults to None.

  • **kwargs – Additional keyword arguments passed to parent class.

is_composition = True
model_type: str = None
__init__(model_name='microsoft/deberta-v3-small', name='gliner', max_width=12, hidden_size=512, dropout=0.4, fine_tune=True, subtoken_pooling='first', span_mode='markerV0', post_fusion_schema='', num_post_fusion_layers=1, vocab_size=-1, max_neg_type_ratio=1, max_types=25, max_len=384, words_splitter_type='whitespace', num_rnn_layers=1, fuse_layers=False, embed_ent_token=True, class_token_index=-1, encoder_config=None, ent_token='<<ENT>>', sep_token='<<SEP>>', _attn_implementation=None, **kwargs)[source]

Initialize BaseGLiNERConfig.

Parameters:
  • model_name (str, optional) – Name of the pretrained encoder model. Defaults to “microsoft/deberta-v3-small”.

  • name (str, optional) – Name identifier for the GLiNER model. Defaults to “gliner”.

  • max_width (int, optional) – Maximum span width for entity detection. Defaults to 12.

  • hidden_size (int, optional) – Dimension of hidden representations. Defaults to 512.

  • dropout (float, optional) – Dropout probability. Defaults to 0.4.

  • fine_tune (bool, optional) – Whether to fine-tune the encoder. Defaults to True.

  • subtoken_pooling (str, optional) – Subtoken pooling strategy. Defaults to “first”.

  • span_mode (str, optional) – Span representation mode. Defaults to “markerV0”.

  • post_fusion_schema (str, optional) – Post-fusion processing schema. Defaults to ‘’.

  • num_post_fusion_layers (int, optional) – Number of post-fusion layers. Defaults to 1.

  • vocab_size (int, optional) – Vocabulary size. Defaults to -1.

  • max_neg_type_ratio (int, optional) – Max ratio of negative to positive types. Defaults to 1.

  • max_types (int, optional) – Maximum number of entity types. Defaults to 25.

  • max_len (int, optional) – Maximum sequence length. Defaults to 384.

  • words_splitter_type (str, optional) – Word splitter type. Defaults to “whitespace”.

  • num_rnn_layers (int, optional) – Number of LSTM layers, if less then 1, then LSTM is not used.

  • fuse_layers (bool, optional) – Whether to fuse layers. Defaults to False.

  • embed_ent_token (bool, optional) – Whether to embed entity tokens. Defaults to True.

  • class_token_index (int, optional) – Index of class token. Defaults to -1.

  • encoder_config (dict, optional) – Encoder configuration dict. Defaults to None.

  • ent_token (str, optional) – Entity marker token. Defaults to “<<ENT>>”.

  • sep_token (str, optional) – Separator token. Defaults to “<<SEP>>”.

  • _attn_implementation (str, optional) – Attention implementation. Defaults to None.

  • **kwargs – Additional keyword arguments passed to parent class.

class gliner.config.UniEncoderConfig(**kwargs)[source]

Bases: BaseGLiNERConfig

Base configuration for uni-encoder GLiNER models.

Initialize BaseGLiNERConfig.

Parameters:
  • model_name (str, optional) – Name of the pretrained encoder model. Defaults to “microsoft/deberta-v3-small”.

  • name (str, optional) – Name identifier for the GLiNER model. Defaults to “gliner”.

  • max_width (int, optional) – Maximum span width for entity detection. Defaults to 12.

  • hidden_size (int, optional) – Dimension of hidden representations. Defaults to 512.

  • dropout (float, optional) – Dropout probability. Defaults to 0.4.

  • fine_tune (bool, optional) – Whether to fine-tune the encoder. Defaults to True.

  • subtoken_pooling (str, optional) – Subtoken pooling strategy. Defaults to “first”.

  • span_mode (str, optional) – Span representation mode. Defaults to “markerV0”.

  • post_fusion_schema (str, optional) – Post-fusion processing schema. Defaults to ‘’.

  • num_post_fusion_layers (int, optional) – Number of post-fusion layers. Defaults to 1.

  • vocab_size (int, optional) – Vocabulary size. Defaults to -1.

  • max_neg_type_ratio (int, optional) – Max ratio of negative to positive types. Defaults to 1.

  • max_types (int, optional) – Maximum number of entity types. Defaults to 25.

  • max_len (int, optional) – Maximum sequence length. Defaults to 384.

  • words_splitter_type (str, optional) – Word splitter type. Defaults to “whitespace”.

  • num_rnn_layers (int, optional) – Number of LSTM layers, if less then 1, then LSTM is not used.

  • fuse_layers (bool, optional) – Whether to fuse layers. Defaults to False.

  • embed_ent_token (bool, optional) – Whether to embed entity tokens. Defaults to True.

  • class_token_index (int, optional) – Index of class token. Defaults to -1.

  • encoder_config (dict, optional) – Encoder configuration dict. Defaults to None.

  • ent_token (str, optional) – Entity marker token. Defaults to “<<ENT>>”.

  • sep_token (str, optional) – Separator token. Defaults to “<<SEP>>”.

  • _attn_implementation (str, optional) – Attention implementation. Defaults to None.

  • **kwargs – Additional keyword arguments passed to parent class.

__init__(**kwargs)[source]

Initialize BaseGLiNERConfig.

Parameters:
  • model_name (str, optional) – Name of the pretrained encoder model. Defaults to “microsoft/deberta-v3-small”.

  • name (str, optional) – Name identifier for the GLiNER model. Defaults to “gliner”.

  • max_width (int, optional) – Maximum span width for entity detection. Defaults to 12.

  • hidden_size (int, optional) – Dimension of hidden representations. Defaults to 512.

  • dropout (float, optional) – Dropout probability. Defaults to 0.4.

  • fine_tune (bool, optional) – Whether to fine-tune the encoder. Defaults to True.

  • subtoken_pooling (str, optional) – Subtoken pooling strategy. Defaults to “first”.

  • span_mode (str, optional) – Span representation mode. Defaults to “markerV0”.

  • post_fusion_schema (str, optional) – Post-fusion processing schema. Defaults to ‘’.

  • num_post_fusion_layers (int, optional) – Number of post-fusion layers. Defaults to 1.

  • vocab_size (int, optional) – Vocabulary size. Defaults to -1.

  • max_neg_type_ratio (int, optional) – Max ratio of negative to positive types. Defaults to 1.

  • max_types (int, optional) – Maximum number of entity types. Defaults to 25.

  • max_len (int, optional) – Maximum sequence length. Defaults to 384.

  • words_splitter_type (str, optional) – Word splitter type. Defaults to “whitespace”.

  • num_rnn_layers (int, optional) – Number of LSTM layers, if less then 1, then LSTM is not used.

  • fuse_layers (bool, optional) – Whether to fuse layers. Defaults to False.

  • embed_ent_token (bool, optional) – Whether to embed entity tokens. Defaults to True.

  • class_token_index (int, optional) – Index of class token. Defaults to -1.

  • encoder_config (dict, optional) – Encoder configuration dict. Defaults to None.

  • ent_token (str, optional) – Entity marker token. Defaults to “<<ENT>>”.

  • sep_token (str, optional) – Separator token. Defaults to “<<SEP>>”.

  • _attn_implementation (str, optional) – Attention implementation. Defaults to None.

  • **kwargs – Additional keyword arguments passed to parent class.

class gliner.config.UniEncoderSpanConfig(**kwargs)[source]

Bases: UniEncoderConfig

Configuration for uni-encoder span-based GLiNER model.

Initialize BaseGLiNERConfig.

Parameters:
  • model_name (str, optional) – Name of the pretrained encoder model. Defaults to “microsoft/deberta-v3-small”.

  • name (str, optional) – Name identifier for the GLiNER model. Defaults to “gliner”.

  • max_width (int, optional) – Maximum span width for entity detection. Defaults to 12.

  • hidden_size (int, optional) – Dimension of hidden representations. Defaults to 512.

  • dropout (float, optional) – Dropout probability. Defaults to 0.4.

  • fine_tune (bool, optional) – Whether to fine-tune the encoder. Defaults to True.

  • subtoken_pooling (str, optional) – Subtoken pooling strategy. Defaults to “first”.

  • span_mode (str, optional) – Span representation mode. Defaults to “markerV0”.

  • post_fusion_schema (str, optional) – Post-fusion processing schema. Defaults to ‘’.

  • num_post_fusion_layers (int, optional) – Number of post-fusion layers. Defaults to 1.

  • vocab_size (int, optional) – Vocabulary size. Defaults to -1.

  • max_neg_type_ratio (int, optional) – Max ratio of negative to positive types. Defaults to 1.

  • max_types (int, optional) – Maximum number of entity types. Defaults to 25.

  • max_len (int, optional) – Maximum sequence length. Defaults to 384.

  • words_splitter_type (str, optional) – Word splitter type. Defaults to “whitespace”.

  • num_rnn_layers (int, optional) – Number of LSTM layers, if less then 1, then LSTM is not used.

  • fuse_layers (bool, optional) – Whether to fuse layers. Defaults to False.

  • embed_ent_token (bool, optional) – Whether to embed entity tokens. Defaults to True.

  • class_token_index (int, optional) – Index of class token. Defaults to -1.

  • encoder_config (dict, optional) – Encoder configuration dict. Defaults to None.

  • ent_token (str, optional) – Entity marker token. Defaults to “<<ENT>>”.

  • sep_token (str, optional) – Separator token. Defaults to “<<SEP>>”.

  • _attn_implementation (str, optional) – Attention implementation. Defaults to None.

  • **kwargs – Additional keyword arguments passed to parent class.

__init__(**kwargs)[source]

Initialize BaseGLiNERConfig.

Parameters:
  • model_name (str, optional) – Name of the pretrained encoder model. Defaults to “microsoft/deberta-v3-small”.

  • name (str, optional) – Name identifier for the GLiNER model. Defaults to “gliner”.

  • max_width (int, optional) – Maximum span width for entity detection. Defaults to 12.

  • hidden_size (int, optional) – Dimension of hidden representations. Defaults to 512.

  • dropout (float, optional) – Dropout probability. Defaults to 0.4.

  • fine_tune (bool, optional) – Whether to fine-tune the encoder. Defaults to True.

  • subtoken_pooling (str, optional) – Subtoken pooling strategy. Defaults to “first”.

  • span_mode (str, optional) – Span representation mode. Defaults to “markerV0”.

  • post_fusion_schema (str, optional) – Post-fusion processing schema. Defaults to ‘’.

  • num_post_fusion_layers (int, optional) – Number of post-fusion layers. Defaults to 1.

  • vocab_size (int, optional) – Vocabulary size. Defaults to -1.

  • max_neg_type_ratio (int, optional) – Max ratio of negative to positive types. Defaults to 1.

  • max_types (int, optional) – Maximum number of entity types. Defaults to 25.

  • max_len (int, optional) – Maximum sequence length. Defaults to 384.

  • words_splitter_type (str, optional) – Word splitter type. Defaults to “whitespace”.

  • num_rnn_layers (int, optional) – Number of LSTM layers, if less then 1, then LSTM is not used.

  • fuse_layers (bool, optional) – Whether to fuse layers. Defaults to False.

  • embed_ent_token (bool, optional) – Whether to embed entity tokens. Defaults to True.

  • class_token_index (int, optional) – Index of class token. Defaults to -1.

  • encoder_config (dict, optional) – Encoder configuration dict. Defaults to None.

  • ent_token (str, optional) – Entity marker token. Defaults to “<<ENT>>”.

  • sep_token (str, optional) – Separator token. Defaults to “<<SEP>>”.

  • _attn_implementation (str, optional) – Attention implementation. Defaults to None.

  • **kwargs – Additional keyword arguments passed to parent class.

class gliner.config.UniEncoderTokenConfig(**kwargs)[source]

Bases: UniEncoderConfig

Configuration for uni-encoder token-based GLiNER model.

Initialize BaseGLiNERConfig.

Parameters:
  • model_name (str, optional) – Name of the pretrained encoder model. Defaults to “microsoft/deberta-v3-small”.

  • name (str, optional) – Name identifier for the GLiNER model. Defaults to “gliner”.

  • max_width (int, optional) – Maximum span width for entity detection. Defaults to 12.

  • hidden_size (int, optional) – Dimension of hidden representations. Defaults to 512.

  • dropout (float, optional) – Dropout probability. Defaults to 0.4.

  • fine_tune (bool, optional) – Whether to fine-tune the encoder. Defaults to True.

  • subtoken_pooling (str, optional) – Subtoken pooling strategy. Defaults to “first”.

  • span_mode (str, optional) – Span representation mode. Defaults to “markerV0”.

  • post_fusion_schema (str, optional) – Post-fusion processing schema. Defaults to ‘’.

  • num_post_fusion_layers (int, optional) – Number of post-fusion layers. Defaults to 1.

  • vocab_size (int, optional) – Vocabulary size. Defaults to -1.

  • max_neg_type_ratio (int, optional) – Max ratio of negative to positive types. Defaults to 1.

  • max_types (int, optional) – Maximum number of entity types. Defaults to 25.

  • max_len (int, optional) – Maximum sequence length. Defaults to 384.

  • words_splitter_type (str, optional) – Word splitter type. Defaults to “whitespace”.

  • num_rnn_layers (int, optional) – Number of LSTM layers, if less then 1, then LSTM is not used.

  • fuse_layers (bool, optional) – Whether to fuse layers. Defaults to False.

  • embed_ent_token (bool, optional) – Whether to embed entity tokens. Defaults to True.

  • class_token_index (int, optional) – Index of class token. Defaults to -1.

  • encoder_config (dict, optional) – Encoder configuration dict. Defaults to None.

  • ent_token (str, optional) – Entity marker token. Defaults to “<<ENT>>”.

  • sep_token (str, optional) – Separator token. Defaults to “<<SEP>>”.

  • _attn_implementation (str, optional) – Attention implementation. Defaults to None.

  • **kwargs – Additional keyword arguments passed to parent class.

__init__(**kwargs)[source]

Initialize BaseGLiNERConfig.

Parameters:
  • model_name (str, optional) – Name of the pretrained encoder model. Defaults to “microsoft/deberta-v3-small”.

  • name (str, optional) – Name identifier for the GLiNER model. Defaults to “gliner”.

  • max_width (int, optional) – Maximum span width for entity detection. Defaults to 12.

  • hidden_size (int, optional) – Dimension of hidden representations. Defaults to 512.

  • dropout (float, optional) – Dropout probability. Defaults to 0.4.

  • fine_tune (bool, optional) – Whether to fine-tune the encoder. Defaults to True.

  • subtoken_pooling (str, optional) – Subtoken pooling strategy. Defaults to “first”.

  • span_mode (str, optional) – Span representation mode. Defaults to “markerV0”.

  • post_fusion_schema (str, optional) – Post-fusion processing schema. Defaults to ‘’.

  • num_post_fusion_layers (int, optional) – Number of post-fusion layers. Defaults to 1.

  • vocab_size (int, optional) – Vocabulary size. Defaults to -1.

  • max_neg_type_ratio (int, optional) – Max ratio of negative to positive types. Defaults to 1.

  • max_types (int, optional) – Maximum number of entity types. Defaults to 25.

  • max_len (int, optional) – Maximum sequence length. Defaults to 384.

  • words_splitter_type (str, optional) – Word splitter type. Defaults to “whitespace”.

  • num_rnn_layers (int, optional) – Number of LSTM layers, if less then 1, then LSTM is not used.

  • fuse_layers (bool, optional) – Whether to fuse layers. Defaults to False.

  • embed_ent_token (bool, optional) – Whether to embed entity tokens. Defaults to True.

  • class_token_index (int, optional) – Index of class token. Defaults to -1.

  • encoder_config (dict, optional) – Encoder configuration dict. Defaults to None.

  • ent_token (str, optional) – Entity marker token. Defaults to “<<ENT>>”.

  • sep_token (str, optional) – Separator token. Defaults to “<<SEP>>”.

  • _attn_implementation (str, optional) – Attention implementation. Defaults to None.

  • **kwargs – Additional keyword arguments passed to parent class.

class gliner.config.UniEncoderSpanDecoderConfig(labels_decoder=None, decoder_mode=None, full_decoder_context=True, blank_entity_prob=0.1, labels_decoder_config=None, decoder_loss_coef=0.5, span_loss_coef=0.5, **kwargs)[source]

Bases: UniEncoderConfig

Configuration for uni-encoder span model with decoder for label generation.

Initialize UniEncoderSpanDecoderConfig.

Parameters:
  • labels_decoder (str, optional) – Name/path of the decoder model. Defaults to None.

  • decoder_mode (str, optional) – Mode for decoder (‘prompt’ or ‘span’). Defaults to None.

  • full_decoder_context (bool, optional) – Use full context in decoder. Defaults to True.

  • blank_entity_prob (float, optional) – Probability of blank entities. Defaults to 0.1.

  • labels_decoder_config (dict, optional) – Decoder config dict. Defaults to None.

  • decoder_loss_coef (float, optional) – Decoder loss coefficient. Defaults to 0.5.

  • span_loss_coef (float, optional) – Span loss coefficient. Defaults to 0.5.

  • **kwargs – Additional keyword arguments passed to UniEncoderConfig.

Raises:

ValueError – If span_mode is ‘token-level’, which is incompatible with this config.

__init__(labels_decoder=None, decoder_mode=None, full_decoder_context=True, blank_entity_prob=0.1, labels_decoder_config=None, decoder_loss_coef=0.5, span_loss_coef=0.5, **kwargs)[source]

Initialize UniEncoderSpanDecoderConfig.

Parameters:
  • labels_decoder (str, optional) – Name/path of the decoder model. Defaults to None.

  • decoder_mode (str, optional) – Mode for decoder (‘prompt’ or ‘span’). Defaults to None.

  • full_decoder_context (bool, optional) – Use full context in decoder. Defaults to True.

  • blank_entity_prob (float, optional) – Probability of blank entities. Defaults to 0.1.

  • labels_decoder_config (dict, optional) – Decoder config dict. Defaults to None.

  • decoder_loss_coef (float, optional) – Decoder loss coefficient. Defaults to 0.5.

  • span_loss_coef (float, optional) – Span loss coefficient. Defaults to 0.5.

  • **kwargs – Additional keyword arguments passed to UniEncoderConfig.

Raises:

ValueError – If span_mode is ‘token-level’, which is incompatible with this config.

class gliner.config.UniEncoderSpanRelexConfig(relations_layer=None, triples_layer=None, embed_rel_token=True, rel_token_index=-1, rel_token='<<REL>>', span_loss_coef=1.0, adjacency_loss_coef=1.0, relation_loss_coef=1.0, **kwargs)[source]

Bases: UniEncoderConfig

Configuration for uni-encoder span model with relation extraction.

Initialize UniEncoderSpanRelexConfig.

Parameters:
  • relations_layer (str, optional) – Name of relations layer, see gliner.modeling.multitask.relations_layers.py. Defaults to None.

  • triples_layer (str, optional) – Name of triples layer, see gliner.modeling.multitask.triples_layers.py. Defaults to None.

  • embed_rel_token (bool, optional) – Whether to embed relation tokens. Defaults to True.

  • rel_token_index (int, optional) – Index of relation token. Defaults to -1.

  • rel_token (str, optional) – Relation marker token. Defaults to “<<REL>>”.

  • span_loss_coef (float, optional) – Span representaton loss coefficient. Defaults to 1.0.

  • adjacency_loss_coef (float, optional) – Adjacency modeling loss coefficient. Defaults to 1.0.

  • relation_loss_coef (float, optional) – Relation representaton loss coefficient. Defaults to 1.0.

  • **kwargs – Additional keyword arguments passed to UniEncoderConfig.

Raises:

ValueError – If span_mode is ‘token_level’, which is incompatible with this config.

__init__(relations_layer=None, triples_layer=None, embed_rel_token=True, rel_token_index=-1, rel_token='<<REL>>', span_loss_coef=1.0, adjacency_loss_coef=1.0, relation_loss_coef=1.0, **kwargs)[source]

Initialize UniEncoderSpanRelexConfig.

Parameters:
  • relations_layer (str, optional) – Name of relations layer, see gliner.modeling.multitask.relations_layers.py. Defaults to None.

  • triples_layer (str, optional) – Name of triples layer, see gliner.modeling.multitask.triples_layers.py. Defaults to None.

  • embed_rel_token (bool, optional) – Whether to embed relation tokens. Defaults to True.

  • rel_token_index (int, optional) – Index of relation token. Defaults to -1.

  • rel_token (str, optional) – Relation marker token. Defaults to “<<REL>>”.

  • span_loss_coef (float, optional) – Span representaton loss coefficient. Defaults to 1.0.

  • adjacency_loss_coef (float, optional) – Adjacency modeling loss coefficient. Defaults to 1.0.

  • relation_loss_coef (float, optional) – Relation representaton loss coefficient. Defaults to 1.0.

  • **kwargs – Additional keyword arguments passed to UniEncoderConfig.

Raises:

ValueError – If span_mode is ‘token_level’, which is incompatible with this config.

class gliner.config.BiEncoderConfig(labels_encoder=None, labels_encoder_config=None, **kwargs)[source]

Bases: BaseGLiNERConfig

Base configuration for bi-encoder GLiNER models.

Initialize BiEncoderConfig.

Parameters:
  • labels_encoder (str, optional) – Name/path of labels encoder model. Defaults to None.

  • labels_encoder_config (dict, optional) – Labels encoder config dict. Defaults to None.

  • **kwargs – Additional keyword arguments passed to BaseGLiNERConfig.

__init__(labels_encoder=None, labels_encoder_config=None, **kwargs)[source]

Initialize BiEncoderConfig.

Parameters:
  • labels_encoder (str, optional) – Name/path of labels encoder model. Defaults to None.

  • labels_encoder_config (dict, optional) – Labels encoder config dict. Defaults to None.

  • **kwargs – Additional keyword arguments passed to BaseGLiNERConfig.

class gliner.config.BiEncoderSpanConfig(**kwargs)[source]

Bases: BiEncoderConfig

Configuration for bi-encoder span-based GLiNER model.

Initialize BiEncoderConfig.

Parameters:
  • labels_encoder (str, optional) – Name/path of labels encoder model. Defaults to None.

  • labels_encoder_config (dict, optional) – Labels encoder config dict. Defaults to None.

  • **kwargs – Additional keyword arguments passed to BaseGLiNERConfig.

__init__(**kwargs)[source]

Initialize BiEncoderConfig.

Parameters:
  • labels_encoder (str, optional) – Name/path of labels encoder model. Defaults to None.

  • labels_encoder_config (dict, optional) – Labels encoder config dict. Defaults to None.

  • **kwargs – Additional keyword arguments passed to BaseGLiNERConfig.

class gliner.config.BiEncoderTokenConfig(**kwargs)[source]

Bases: BiEncoderConfig

Configuration for bi-encoder token-based GLiNER model.

Initialize BiEncoderConfig.

Parameters:
  • labels_encoder (str, optional) – Name/path of labels encoder model. Defaults to None.

  • labels_encoder_config (dict, optional) – Labels encoder config dict. Defaults to None.

  • **kwargs – Additional keyword arguments passed to BaseGLiNERConfig.

__init__(**kwargs)[source]

Initialize BiEncoderConfig.

Parameters:
  • labels_encoder (str, optional) – Name/path of labels encoder model. Defaults to None.

  • labels_encoder_config (dict, optional) – Labels encoder config dict. Defaults to None.

  • **kwargs – Additional keyword arguments passed to BaseGLiNERConfig.

class gliner.config.GLiNERConfig(labels_encoder=None, labels_decoder=None, relations_layer=None, **kwargs)[source]

Bases: BaseGLiNERConfig

Legacy configuration class that auto-detects model type.

This class provides backward compatibility by automatically determining the appropriate model type based on the provided configuration parameters.

labels_encoder

Name of the encoder for entity labels (bi-encoder).

Type:

str

labels_decoder

Name of the decoder for label generation.

Type:

str

relations_layer

Layer configuration for relation extraction.

Type:

str

Initialize GLiNERConfig.

Parameters:
  • labels_encoder (str, optional) – Labels encoder for bi-encoder models. Defaults to None.

  • labels_decoder (str, optional) – Decoder for label generation. Defaults to None.

  • relations_layer (str, optional) – Relations layer for relation extraction. Defaults to None.

  • **kwargs – Additional keyword arguments passed to BaseGLiNERConfig.

__init__(labels_encoder=None, labels_decoder=None, relations_layer=None, **kwargs)[source]

Initialize GLiNERConfig.

Parameters:
  • labels_encoder (str, optional) – Labels encoder for bi-encoder models. Defaults to None.

  • labels_decoder (str, optional) – Decoder for label generation. Defaults to None.

  • relations_layer (str, optional) – Relations layer for relation extraction. Defaults to None.

  • **kwargs – Additional keyword arguments passed to BaseGLiNERConfig.

property model_type

Auto-detect model type based on configuration.