gliner.modeling.context_encoders module¶
Context encoders for already embedded token or word sequences.
- class gliner.modeling.context_encoders.BaseContextEncoder(input_size, encoder_size, output_size)[source]¶
Bases:
ABC,ModuleCommon interface for contextualizing dense sequence representations.
- abstract property requires_full_recompute: bool¶
Whether appended positions can change all earlier representations.
- forward(hidden_states, attention_mask)[source]¶
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class gliner.modeling.context_encoders.DebertaV2ContextEncoder(config, input_size, output_size)[source]¶
Bases:
BaseContextEncoderDeBERTa-v2 encoder stack operating directly on dense representations.
- property requires_full_recompute: bool¶
Whether appended positions can change all earlier representations.
- class gliner.modeling.context_encoders.IdentityContextEncoder(hidden_size)[source]¶
Bases:
BaseContextEncoderNo-op encoder used when contextualization is disabled.
- property requires_full_recompute: bool¶
Whether appended positions can change all earlier representations.
- class gliner.modeling.context_encoders.ModernBertContextEncoder(config, input_size, output_size)[source]¶
Bases:
BaseContextEncoderModernBERT model using its public dense
inputs_embedspath.- property requires_full_recompute: bool¶
Whether appended positions can change all earlier representations.
- class gliner.modeling.context_encoders.RNNContextEncoder(config, input_size, output_size)[source]¶
Bases:
BaseContextEncoderPacked LSTM context encoder with optional bidirectionality.
- property requires_full_recompute: bool¶
Whether appended positions can change all earlier representations.