o
    ¾e¦ih"  ã                   @   sL   d Z ddlmZ ddlmZ ddlmZ e e¡Z	G dd„ deƒZ
dgZdS )zFalcon configurationé   )ÚPreTrainedConfig)ÚRopeParameters)Úloggingc                2       sB  e Zd ZdZdZdgZ								
																	d/dedB dedB dedB dedB dedB dedB dedB dedB dedB dedB dedB dedB dedB dedB dedB d edB d!edB d"e	e
ee	f B dB d#edB d$edB d%edB d&edB d'edB d(edB f0‡ fd)d*„Zed+d,„ ƒZed-d.„ ƒZ‡  ZS )0ÚFalconConfiga´  
    This is the configuration class to store the configuration of a [`FalconModel`]. It is used to instantiate a Falcon
    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
    [tiiuae/falcon-7b](https://huggingface.co/tiiuae/falcon-7b) architecture.

    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 65024):
            Vocabulary size of the Falcon model. Defines the number of different tokens that can be represented by the
            `inputs_ids` passed when calling [`FalconModel`]
        hidden_size (`int`, *optional*, defaults to 4544):
            Dimension of the hidden representations.
        num_hidden_layers (`int`, *optional*, defaults to 32):
            Number of hidden layers in the Transformer decoder.
        num_attention_heads (`int`, *optional*, defaults to 71):
            Number of attention heads for each attention layer in the Transformer encoder.
        num_ln_in_parallel_attn (`int`, *optional*):
            Set to 2 if separate layer norms are to be used for the MLP and the attention output when using parallel
            attention, otherwise, 1.
        layer_norm_epsilon (`float`, *optional*, defaults to 1e-05):
            The epsilon used by the layer normalization layers.
        initializer_range (`float`, *optional*, defaults to 0.02):
            The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
        use_cache (`bool`, *optional*, defaults to `True`):
            Whether the model should return the last key/values attentions (not used by all models). Only relevant if
            `config.is_decoder=True`.
        hidden_dropout (`float`, *optional*, defaults to 0.0):
            The dropout probability for MLP layers.
        attention_dropout (`float`, *optional*, defaults to 0.0):
            The dropout probability for attention layers.
        num_kv_heads (`int`, *optional*):
            Number of key-value heads to use per attention layer. If unset, defaults to the same value as
            `num_attention_heads`.
        alibi (`bool`, *optional*, defaults to `False`):
            Whether to use ALiBi positional biases during self-attention.
        new_decoder_architecture (`bool`, *optional*, defaults to `False`):
            Whether to use the new (Falcon-40B) decoder architecture. If `True`, the `multi_query` and `parallel_attn`
            arguments are ignored, as the new decoder always uses parallel attention.
        multi_query (`bool`, *optional*, defaults to `True`):
            Whether to use multi-query attention in the decoder. Ignored when `new_decoder_architecture` is `True`.
        parallel_attn (`bool`, *optional*, defaults to `True`):
            Whether to compute attention in parallel with the feedforward layer. If False, they are consecutive
            instead, as in the original Transformer architecture. Ignored when `new_decoder_architecture` is `True`.
        bias (`bool`, *optional*, defaults to `False`):
            Whether to use bias on Linear layers.
        max_position_embeddings (`int`, *optional*, defaults to 2048):
            The maximum sequence length that this model might ever be used with, when `alibi` is `False`. Pretrained
            Falcon models with RoPE support up to 2048 tokens.
        rope_parameters (`RopeParameters`, *optional*):
            Dictionary containing the configuration parameters for the RoPE embeddings. The dictionary should contain
            a value for `rope_theta` and optionally parameters used for scaling in case you want to use RoPE
            with longer `max_position_embeddings`.
        bos_token_id (`int`, *optional*, defaults to 11):
            The id of the "beginning-of-sequence" token.
        eos_token_id (`int`, *optional*, defaults to 11):
            The id of the "end-of-sequence" token.
        pad_token_id (`int`, *optional*):
            Padding token id.
        ffn_hidden_size (`int`, *optional*):
            The hidden size of the feedforward layer in the Transformer decoder.
            defaults to 4x hidden dim
        activation (`str`, *optional*, defaults to `"gelu"`):
            The activation function used in the feedforward layer.
        tie_word_embeddings (`bool`, *optional*, defaults to `True`):
            Whether to tie weight embeddings

    Example:

    ```python
    >>> from transformers import FalconModel, FalconConfig

    >>> # Initializing a small (2-layer) Falcon configuration
    >>> configuration = FalconConfig(num_hidden_layers=2)

    >>> # Initializing a model from the small configuration
    >>> model = FalconModel(configuration)

    >>> # Accessing the model configuration
    >>> configuration = model.config
    ```ÚfalconÚpast_key_valuesé þ  éÀ  é    éG   Nçñhãˆµøä>ç{®Gáz”?Tç        Fé   é   ÚgeluÚ
vocab_sizeÚhidden_sizeÚnum_hidden_layersÚnum_attention_headsÚnum_ln_in_parallel_attnÚlayer_norm_epsilonÚinitializer_rangeÚ	use_cacheÚhidden_dropoutÚattention_dropoutÚnum_kv_headsÚalibiÚnew_decoder_architectureÚmulti_queryÚparallel_attnÚbiasÚmax_position_embeddingsÚrope_parametersÚbos_token_idÚeos_token_idÚpad_token_idÚffn_hidden_sizeÚ
activationÚtie_word_embeddingsc                    sÞ   || _ | dd ¡}|d u r|n|| _|| _|| _|| _|| _|| _|	| _|
| _	|| _
|| _|| _|d u r6|n|| _|| _|| _|| _|| _|| _|| _|| _|| _|| _|d u r^|d | _n|| _|| _tƒ jdi |¤Ž d S )NÚn_embedé   © )r   Úpopr   r   r   r   r   r   r   r   r$   r%   r&   r   r   r   r   r    r!   r   r"   r(   r)   r'   r#   ÚsuperÚ__init__)Úselfr   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   Úkwargsr*   ©Ú	__class__r,   úm/home/ubuntu/transcripts/venv/lib/python3.10/site-packages/transformers/models/falcon/configuration_falcon.pyr/   q   s8   zFalconConfig.__init__c                 C   s   | j | j S ©N)r   r   ©r0   r,   r,   r4   Úhead_dim®   s   zFalconConfig.head_dimc                 C   s   | j  S r5   )r   r6   r,   r,   r4   Úrotary²   s   zFalconConfig.rotary)r   r	   r
   r   Nr   r   Tr   r   NFFTTFr   Nr   r   NNr   T)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú
model_typeÚkeys_to_ignore_at_inferenceÚintÚfloatÚboolr   ÚdictÚstrr/   Úpropertyr7   r8   Ú__classcell__r,   r,   r2   r4   r      s¢    Uçþýüûúùø	÷
öõôóòñðïîíìëêéèç=
r   N)r<   Úconfiguration_utilsr   Úmodeling_rope_utilsr   Úutilsr   Ú
get_loggerr9   Úloggerr   Ú__all__r,   r,   r,   r4   Ú<module>   s   
 
 