Ë
    T^(h­,  ã                   ó8   — d dl mZ ddlmZ  G d„ de«      ZdgZy)é    )ÚLiteralé   )ÚPretrainedConfigc                   óŠ   ‡ — e Zd ZdZdZdgZ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dded   fˆ fd„Zˆ fd„Zˆ xZ	S )	ÚModernBertConfiga÷  
    This is the configuration class to store the configuration of a [`ModernBertModel`]. It is used to instantiate an ModernBert
    model according to the specified arguments, defining the model architecture. Instantiating a configuration with the
    defaults will yield a similar configuration to that of the ModernBERT-base.
    e.g. [answerdotai/ModernBERT-base](https://huggingface.co/answerdotai/ModernBERT-base)

    Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
    documentation from [`PretrainedConfig`] for more information.

    Args:
        vocab_size (`int`, *optional*, defaults to 50368):
            Vocabulary size of the ModernBert model. Defines the number of different tokens that can be represented by the
            `inputs_ids` passed when calling [`ModernBertModel`]
        hidden_size (`int`, *optional*, defaults to 768):
            Dimension of the hidden representations.
        intermediate_size (`int`, *optional*, defaults to 1152):
            Dimension of the MLP representations.
        num_hidden_layers (`int`, *optional*, defaults to 22):
            Number of hidden layers in the Transformer decoder.
        num_attention_heads (`int`, *optional*, defaults to 12):
            Number of attention heads for each attention layer in the Transformer decoder.
        hidden_activation (`str` or `function`, *optional*, defaults to `"gelu"`):
            The non-linear activation function (function or string) in the decoder. Will default to `"gelu"`
            if not specified.
        max_position_embeddings (`int`, *optional*, defaults to 8192):
            The maximum sequence length that this model might ever be used with.
        initializer_range (`float`, *optional*, defaults to 0.02):
            The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
        initializer_cutoff_factor (`float`, *optional*, defaults to 2.0):
            The cutoff factor for the truncated_normal_initializer for initializing all weight matrices.
        norm_eps (`float`, *optional*, defaults to 1e-05):
            The epsilon used by the rms normalization layers.
        norm_bias (`bool`, *optional*, defaults to `False`):
            Whether to use bias in the normalization layers.
        pad_token_id (`int`, *optional*, defaults to 50283):
            Padding token id.
        eos_token_id (`int`, *optional*, defaults to 50282):
            End of stream token id.
        bos_token_id (`int`, *optional*, defaults to 50281):
            Beginning of stream token id.
        cls_token_id (`int`, *optional*, defaults to 50281):
            Classification token id.
        sep_token_id (`int`, *optional*, defaults to 50282):
            Separation token id.
        global_rope_theta (`float`, *optional*, defaults to 160000.0):
            The base period of the global RoPE embeddings.
        attention_bias (`bool`, *optional*, defaults to `False`):
            Whether to use a bias in the query, key, value and output projection layers during self-attention.
        attention_dropout (`float`, *optional*, defaults to 0.0):
            The dropout ratio for the attention probabilities.
        global_attn_every_n_layers (`int`, *optional*, defaults to 3):
            The number of layers between global attention layers.
        local_attention (`int`, *optional*, defaults to 128):
            The window size for local attention.
        local_rope_theta (`float`, *optional*, defaults to 10000.0):
            The base period of the local RoPE embeddings.
        embedding_dropout (`float`, *optional*, defaults to 0.0):
            The dropout ratio for the embeddings.
        mlp_bias (`bool`, *optional*, defaults to `False`):
            Whether to use bias in the MLP layers.
        mlp_dropout (`float`, *optional*, defaults to 0.0):
            The dropout ratio for the MLP layers.
        decoder_bias (`bool`, *optional*, defaults to `True`):
            Whether to use bias in the decoder layers.
        classifier_pooling (`str`, *optional*, defaults to `"cls"`):
            The pooling method for the classifier. Should be either `"cls"` or `"mean"`. In local attention layers, the
            CLS token doesn't attend to all tokens on long sequences.
        classifier_dropout (`float`, *optional*, defaults to 0.0):
            The dropout ratio for the classifier.
        classifier_bias (`bool`, *optional*, defaults to `False`):
            Whether to use bias in the classifier.
        classifier_activation (`str`, *optional*, defaults to `"gelu"`):
            The activation function for the classifier.
        deterministic_flash_attn (`bool`, *optional*, defaults to `False`):
            Whether to use deterministic flash attention. If `False`, inference will be faster but not deterministic.
        sparse_prediction (`bool`, *optional*, defaults to `False`):
            Whether to use sparse prediction for the masked language model instead of returning the full dense logits.
        sparse_pred_ignore_index (`int`, *optional*, defaults to -100):
            The index to ignore for the sparse prediction.
        reference_compile (`bool`, *optional*):
            Whether to compile the layers of the model which were compiled during pretraining. If `None`, then parts of
            the model will be compiled if 1) `triton` is installed, 2) the model is not on MPS, 3) the model is not
            shared between devices, and 4) the model is not resized after initialization. If `True`, then the model may
            be faster in some scenarios.
        repad_logits_with_grad (`bool`, *optional*, defaults to `False`):
            When True, ModernBertForMaskedLM keeps track of the logits' gradient when repadding for output. This only
            applies when using Flash Attention 2 with passed labels. Otherwise output logits always have a gradient.

    Examples:

    ```python
    >>> from transformers import ModernBertModel, ModernBertConfig

    >>> # Initializing a ModernBert style configuration
    >>> configuration = ModernBertConfig()

    >>> # Initializing a model from the modernbert-base style configuration
    >>> model = ModernBertModel(configuration)

    >>> # Accessing the model configuration
    >>> configuration = model.config
    ```Ú
modernbertÚpast_key_valuesÚclassifier_pooling©ÚclsÚmeanc$           	      ó"  •— t        ‰%| �  d|||||dœ|$¤Ž || _        || _        || _        || _        || _        || _        || _        |	| _	        |
| _
        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        | | _        |!| _        |"| _        |#| _        | j.                  dvrtA        d| j.                  › d�«      ‚y )N)Úpad_token_idÚbos_token_idÚeos_token_idÚcls_token_idÚsep_token_idr   zQInvalid value for `classifier_pooling`, should be either "cls" or "mean", but is ú.© )!ÚsuperÚ__init__Ú
vocab_sizeÚmax_position_embeddingsÚhidden_sizeÚintermediate_sizeÚnum_hidden_layersÚnum_attention_headsÚinitializer_rangeÚinitializer_cutoff_factorÚnorm_epsÚ	norm_biasÚglobal_rope_thetaÚattention_biasÚattention_dropoutÚhidden_activationÚglobal_attn_every_n_layersÚlocal_attentionÚlocal_rope_thetaÚembedding_dropoutÚmlp_biasÚmlp_dropoutÚdecoder_biasr
   Úclassifier_dropoutÚclassifier_biasÚclassifier_activationÚdeterministic_flash_attnÚsparse_predictionÚsparse_pred_ignore_indexÚreference_compileÚrepad_logits_with_gradÚ
ValueError)&Úselfr   r   r   r   r   r%   r   r   r   r    r!   r   r   r   r   r   r"   r#   r$   r&   r'   r(   r)   r*   r+   r,   r
   r-   r.   r/   r0   r1   r2   r3   r4   ÚkwargsÚ	__class__s&                                        €úu/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/transformers/models/modernbert/configuration_modernbert.pyr   zModernBertConfig.__init__†   sT  ø€ ôN 	‰Ñð 	
Ø%Ø%Ø%Ø%Ø%ñ	
ð ò	
ð %ˆŒØ'>ˆÔ$Ø&ˆÔØ!2ˆÔØ!2ˆÔØ#6ˆÔ Ø!2ˆÔØ)BˆÔ&Ø ˆŒØ"ˆŒØ!2ˆÔØ,ˆÔØ!2ˆÔØ!2ˆÔØ*DˆÔ'Ø.ˆÔØ 0ˆÔØ!2ˆÔØ ˆŒØ&ˆÔØ(ˆÔØ"4ˆÔØ"4ˆÔØ.ˆÔØ%:ˆÔ"Ø(@ˆÔ%Ø!2ˆÔØ(@ˆÔ%Ø!2ˆÔØ&<ˆÔ#à×"Ñ"¨/Ñ9ÜØcÐdh×d{Ñd{Ðc|Ð|}Ð~óð ð :ó    c                 óH   •— t         ‰| �  «       }|j                  dd «       |S )Nr3   )r   Úto_dictÚpop)r6   Úoutputr8   s     €r9   r<   zModernBertConfig.to_dictÙ   s#   ø€ Ü‘‘Ó"ˆØ�
‰
Ð&¨Ô-Øˆr:   )#iÀÄ  i   i€  é   é   Úgelui    g{®Gáz”?g       @gñhãˆµøä>FikÄ  éjÄ  éiÄ  rC   rB   g     ˆAFç        r   é€   g     ˆÃ@rD   FrD   Tr   rD   FrA   FFiœÿÿÿNF)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú
model_typeÚkeys_to_ignore_at_inferencer   r   r<   Ú__classcell__)r8   s   @r9   r   r      s§   ø„ ñeðN €JØ#4Ð"5Ðð ØØØØØ Ø $ØØ"%ØØØØØØØØ"ØØØ#$ØØ ØØØØØ5:ØØØ$Ø!&ØØ!%ØØ$ñIQð8 $ MÑ2õ9Q÷fð r:   r   N)Útypingr   Úconfiguration_utilsr   r   Ú__all__r   r:   r9   ú<module>rP      s'   ðõ, å 3ôAÐ'ô AðH Ð
�r:   