
    Z j)                     p    S r SSKJr  SSKJr  SSKJr  SSKJr  \" SS9\ " S	 S
\5      5       5       r	S
/r
g)zPhi-3 model configuration    )strict   )PreTrainedConfig)RopeParameters)auto_docstringz microsoft/Phi-3-mini-4k-instruct)
checkpointc                   
  ^  \ rS rSr% SrSrS/rSSSSS.rS/S	/4S
S/S
/4S
/S
/4S.rSr	\
\S'   Sr\
\S'   Sr\
\S'   Sr\
\S'   Sr\
\S'   Sr\
S-  \S'   Sr\\
-  \S'   Sr\\
-  \S'   Sr\\
-  \S'   Sr\\S'   Sr\
\S'   Sr\
\S '   S!r\\S"'   S#r\\S$'   S%r\\S&'   S'r\\S('   Sr\\ -  S-  \S)'   S*r!\
S-  \S+'   S,r"\
\#\
   -  S-  \S-'   S,r$\
S-  \S.'   Sr%\
S-  \S/'   U 4S0 jr& S6S1\
\-  S2\'S-  4S3 jjr(U 4S4 jr)S5r*U =r+$ )7
Phi3Config   a[  
original_max_position_embeddings (`int`, *optional*, defaults to 4096):
    The maximum sequence length that this model was trained with. This is used to determine the size of the
    original RoPE embeddings when using long scaling.

Example:

```python
>>> from transformers import Phi3Model, Phi3Config

>>> # Initializing a Phi-3 style configuration
>>> configuration = Phi3Config.from_pretrained("microsoft/Phi-3-mini-4k-instruct")

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

>>> # Accessing the model configuration
>>> configuration = model.config
```phi3past_key_valuescolwise_gather_outputrowwise_split_input)zlayers.*.self_attn.qkv_projzlayers.*.self_attn.o_projzlayers.*.mlp.gate_up_projzlayers.*.mlp.down_proj	input_idsinputs_embedshidden_statesattention_mask)embed_tokenslayersnormi@}  
vocab_sizei   hidden_sizei    intermediate_size    num_hidden_layersnum_attention_headsNnum_key_value_headsg        resid_pdrop
embd_pdropattention_dropoutsilu
hidden_acti   max_position_embeddings original_max_position_embeddingsg{Gz?initializer_rangegh㈵>rms_norm_epsT	use_cacheFtie_word_embeddingsrope_parameters   bos_token_idi }  eos_token_idpad_token_idsliding_windowc                 b   > U R                   c  U R                  U l         [        TU ]  " S0 UD6  g )N )r   r   super__post_init__)selfkwargs	__class__s     |/root/GenerationalWealth/GenerationalWealth/venv/lib/python3.13/site-packages/transformers/models/phi3/configuration_phi3.pyr2   Phi3Config.__post_init__S   s-    ##+'+'?'?D$''    default_thetaignore_keysc                    UR                  SS 5      nU=(       d    U R                  U l        U R                  b  U R                  O0 U l        U R                  R                  SUR                  SU5      5        U R                  R                  SUR                  SS5      5        U R	                  5         U R                  R                  SS 5      nUb  US;   a  SU R                  S'   U$ )Nrope_scaling
rope_thetapartial_rotary_factorg      ?	rope_type)suyarnlongrope)popr)   
setdefaultgetstandardize_rope_params)r3   r9   r:   r4   r<   rope_parameters_types         r6   convert_rope_params_to_dict&Phi3Config.convert_rope_params_to_dictY   s     zz.$7+Ct/C/C7;7K7K7Wt33]_ 	''fjj}6]^''(?LcehAij$$&  $3377TJ+0D0V0:D  -r8   c                 v  > [         TU ]  5         [        U R                  [        5      (       d  [        SU R                   35      eU R                  R                  SS5      nU R                  R                  SS5      nU R                  R                  SS5      n[        U R                  U R                  -  U R                  S   -  5      nUS;  a  [        SU 35      eUbi  [        U[        5      (       a  [        S	 U 5       5      (       d  [        S
U 35      e[        U5      US-  :X  d  [        SUS-   S[        U5       35      eUbj  [        U[        5      (       a  [        S U 5       5      (       d  [        SU 35      e[        U5      US-  :X  d  [        SUS-   S[        U5       35      egg)z/
Validate the `rope_parameters` configuration.
z/`rope_parameters` must be a dictionary but got r?   Nshort_factorlong_factorr>   )defaultrB   z@`rope_parameters`'s type field must be one of ['longrope'], got c              3   N   #    U  H  n[        U[        [        45      v   M     g 7fN
isinstanceintfloat.0xs     r6   	<genexpr>+Phi3Config.validate_rope.<locals>.<genexpr>   s      Z=Y
1sEl33=Y   #%zF`rope_parameters`'s short_factor field must be a list of numbers, got    z8`rope_parameters`'s short_factor field must have length z, got c              3   N   #    U  H  n[        U[        [        45      v   M     g 7frO   rP   rT   s     r6   rW   rX      s      Y=X
1sEl33=XrY   zE`rope_parameters`'s long_factor field must be a list of numbers, got z7`rope_parameters`'s long_factor field must have length )r1   validate_roperQ   r)   dict
ValueErrorrE   rR   r   r   listalllen)r3   rG   rope_parameters_short_factorrope_parameters_long_factorrotary_ndimsr5   s        r6   r\   Phi3Config.validate_ropek   s    	 $..55NtOcOcNdeff#3377TJ'+';';'?'?PT'U$&*&:&:&>&>}d&S# 8 884;O;OPg;hh
  '>>_`t_uvww'37>>Z=YZZZ \]y\z{  348II N|_`O`Naaghk  mI  iJ  hK  L  '26==Y=XYYY [\w[xy  23|q7HH Ml^_N_M``fgj  lG  hH  gI  J  I 3r8   )r   r)   )g     @N),__name__
__module____qualname____firstlineno____doc__
model_typekeys_to_ignore_at_inferencebase_model_tp_planbase_model_pp_planr   rR   __annotations__r   r   r   r   r   r   rS   r   r    r"   strr#   r$   r%   r&   r'   boolr(   r)   r   r]   r+   r,   r_   r-   r.   r2   setrH   r\   __static_attributes____classcell__)r5   s   @r6   r
   r
      s   ( J#4"5'>%:%<"7	 &(9:#%568IJ!"_$56 JK!s!s!!&*t*"K"!J!%(us{(J#'S',0$c0#u#L%It %%48O^d*T18 L#* +0L#S	/D(0$L#*$!%NC$J%( PT 5[BE*$* *r8   r
   N)rj   huggingface_hub.dataclassesr   configuration_utilsr   modeling_rope_utilsr   utilsr   r
   __all__r0   r8   r6   <module>rz      sM      . 3 1 # =>{! {  ?{| .r8   