
    qi+                     8    d dl mZ d dlmZ  G d de      ZdgZy)   )PreTrainedConfig)RopeParametersc            2       n    e Zd ZdZdZdgZdddddZ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd
ed	z  ded	z  ded	z  ded	z  ded	z  ded	z  ded	z  ded	z  ded	z  ded	z  ded	z  ded	z  ded	z  de	d	z  ded	z  de
d	z  deeeef   z  d	z  de
d	z  de
d	z  de	d	z  ded	z  ded	z  ded	z  de
d	z  f0 fdZ xZS ) MoonshineConfiga7  
    This is the configuration class to store the configuration of a [`MoonshineModel`]. It is used to instantiate a Moonshine
    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 Moonshine
    [UsefulSensors/moonshine-tiny](https://huggingface.co/UsefulSensors/moonshine-tiny).

    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 32768):
            Vocabulary size of the Moonshine model. Defines the number of different tokens that can be represented by the
            `inputs_ids` passed when calling [`MoonshineModel`].
        hidden_size (`int`, *optional*, defaults to 288):
            Dimension of the hidden representations.
        intermediate_size (`int`, *optional*, defaults to 1152):
            Dimension of the MLP representations.
        encoder_num_hidden_layers (`int`, *optional*, defaults to 6):
            Number of hidden layers in the Transformer encoder.
        decoder_num_hidden_layers (`int`, *optional*, defaults to 6):
            Number of hidden layers in the Transformer decoder.
        encoder_num_attention_heads (`int`, *optional*, defaults to 8):
            Number of attention heads for each attention layer in the Transformer encoder.
        decoder_num_attention_heads (`int`, *optional*, defaults to 8):
            Number of attention heads for each attention layer in the Transformer decoder.
        encoder_num_key_value_heads (`int`, *optional*):
            This is the number of key_value heads that should be used to implement Grouped Query Attention. If
            `encoder_num_key_value_heads=encoder_num_attention_heads`, the model will use Multi Head Attention (MHA), if
            `encoder_num_key_value_heads=1` the model will use Multi Query Attention (MQA) otherwise GQA is used. When
            converting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructed
            by meanpooling all the original heads within that group. For more details, check out [this
            paper](https://huggingface.co/papers/2305.13245). If it is not specified, will default to
            `num_attention_heads`.
        decoder_num_key_value_heads (`int`, *optional*):
            This is the number of key_value heads that should be used to implement Grouped Query Attention. If
            `decoder_num_key_value_heads=decoder_num_attention_heads`, the model will use Multi Head Attention (MHA), if
            `decoder_num_key_value_heads=1` the model will use Multi Query Attention (MQA) otherwise GQA is used. When
            converting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructed
            by meanpooling all the original heads within that group. For more details, check out [this
            paper](https://huggingface.co/papers/2305.13245). If it is not specified, will default to
            `decoder_num_attention_heads`.
        pad_head_dim_to_multiple_of (`int`, *optional*):
            Pad head dimension in encoder and decoder to the next multiple of this value. Necessary for using certain
            optimized attention implementations.
        encoder_hidden_act (`str` or `function`, *optional*, defaults to `"gelu"`):
            The non-linear activation function (function or string) in the encoder.
        decoder_hidden_act (`str` or `function`, *optional*, defaults to `"silu"`):
            The non-linear activation function (function or string) in the decoder.
        max_position_embeddings (`int`, *optional*, defaults to 512):
            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.
        decoder_start_token_id (`int`, *optional*, defaults to 1):
            Corresponds to the "<|startoftranscript|>" token, which is automatically used when no `decoder_input_ids`
            are provided to the `generate` function. It is used to guide the model`s generation process depending on
            the task.
        use_cache (`bool`, *optional*, defaults to `True`):
            Whether or not the model should return the last key/values attentions (not used by all models).
        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`.
        is_encoder_decoder (`bool`, *optional*, defaults to `True`):
            Whether the model is used as an encoder/decoder or not.
        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.
        bos_token_id (`int`, *optional*, defaults to 1):
            Denotes beginning of sequences token id.
        eos_token_id (`int`, *optional*, defaults to 2):
            Denotes end of sequences token id.
        pad_token_id (`int`, *optional*):
            Padding token id.
        tie_word_embeddings (`bool`, *optional*, defaults to `True`):
            Whether to tie weight embeddings

    Example:

    ```python
    >>> from transformers import MoonshineModel, MoonshineConfig

    >>> # Initializing a Moonshine style configuration
    >>> configuration = MoonshineConfig().from_pretrained("UsefulSensors/moonshine-tiny")

    >>> # Initializing a model from the configuration
    >>> model = MoonshineModel(configuration)

    >>> # Accessing the model configuration
    >>> configuration = model.config
    ```	moonshinepast_key_valuesdecoder_num_key_value_headsdecoder_num_attention_headsdecoder_num_hidden_layersdecoder_hidden_act)num_key_value_headsnum_attention_headsnum_hidden_layers
hidden_actN
vocab_sizehidden_sizeintermediate_sizeencoder_num_hidden_layersencoder_num_attention_headsencoder_num_key_value_headspad_head_dim_to_multiple_ofencoder_hidden_actmax_position_embeddingsinitializer_rangedecoder_start_token_id	use_cacherope_parametersis_encoder_decoderattention_biasattention_dropoutbos_token_ideos_token_idpad_token_idtie_word_embeddingsc                    || _         || _        || _        || _        || _        || _        || _        ||}|| _        |	|}	|	| _        |
| _	        || _
        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        |j1                  dd       t3        | h  dd|i| y )Npartial_rotary_factorg?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   
setdefault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$   kwargs	__class__s                             g/opt/pipecat/venv/lib/python3.12/site-packages/transformers/models/moonshine/configuration_moonshine.pyr*   zMoonshineConfig.__init__   s
   8 %&!2)B&)B&+F(+F(&.*E'+F(&.*E'+F(+F("4"4'>$!2&<#""4,!2(((&<##6 .137I,>I&I    )i   i   i     r0      r1   NNNgelusilui   g{Gz?   TNTFg        r4      NT)__name__
__module____qualname____doc__
model_typekeys_to_ignore_at_inferenceattribute_mapintstrfloatboolr   dictr*   __classcell__)r-   s   @r.   r   r      s   Zx J#4"5<<8*	M "'"%(,01012323262626)/)/.1*.-.!%MQ*.&+*-#$#$#'+/3?J$J?J 4Z?J :	?J
 $':?J $':?J &)4Z?J &)4Z?J &)4Z?J &)4Z?J &)4Z?J  $J?J  $J?J "%t?J !4<?J  !$d
!?J" $;#?J$ ($sN/B*CCdJ%?J& !4K'?J( t)?J* !4<+?J, Dj-?J. Dj/?J0 Dj1?J2 "D[3?J ?Jr/   r   N)configuration_utilsr   modeling_rope_utilsr   r   __all__r'   r/   r.   <module>rF      s)   * 4 1eJ& eJP 
r/   