+
    ¢÷Îj"…  ã                   ó2  € R t ^ RIHtHtHt ^ RIt^ RIHtH	t	H
t
  ! R R]
P                  4      t ! R R]
P                  4      t ! R R	]
P                  4      t ! R
 R]
P                  4      t ! R R]
P                  4      t ! R R]
P                  4      t ! R R]
P$                  4      t ! R R]
P(                  4      t ! R R]
P,                  4      t ! R R]
P0                  4      t ! R R]
P,                  4      t ! R R]
P0                  4      tR# )z0Declares specification of the Transformer model.)ÚOptionalÚTupleÚUnionN)Úattention_specÚcommon_specÚ
model_specc                   ó°   a € ] tR t^
t o RR]P
                  P                  ^]P                  P                  RRRRRRRRRRR^RRRR3V 3R lR llt	Rt
V tR# )ÚTransformerEncoderSpecTFNé'  c          .      ó@  <€ V ^8„  d   QhRS[ RS[ RS[RS[RS[P                  RS[ RS[P                  RS[R	S[R
S[RS[RS[RS[RS[S[ ,          RS[S[ ,          RS[S[ ,          RS[RS[S[P                  ,          RS[RS[RS[S[ ,          RS[S[,          RS[/# )é   Ú
num_layersÚ	num_headsÚpre_normÚno_final_normÚ
activationÚnum_source_embeddingsÚembeddings_mergeÚlayernorm_embeddingÚrelative_positionÚrelative_attention_biasÚffn_gluÚrms_normÚmulti_query_attentionÚnum_heads_kvÚhead_dimÚ
rotary_dimÚrotary_interleaveÚrotary_scaling_typeÚrotary_scaling_factorÚrotary_baseÚsliding_windowÚqk_normÚpre_post_layer_norm)	ÚintÚboolr   Ú
ActivationÚEmbeddingsMerger   r   ÚRotaryScalingTypeÚfloat)ÚformatÚ__classdict__s   "€ÚX/opt/data/home/.local/lib/python3.14/site-packages/ctranslate2/specs/transformer_spec.pyÚ__annotate__Ú#TransformerEncoderSpec.__annotate__   s5  ø€ ÷ g
ñ g
áðg
ñ ðg
ñ ð	g
ñ
 ðg
ñ  ×*Ñ*ðg
ñ  #ðg
ñ &×5Ñ5ðg
ñ "ðg
ñ  ðg
ñ "&ðg
ñ ðg
ñ ðg
ñ  $ðg
ñ ™s•mðg
ñ  ™3•-ð!g
ñ" ™S•Mð#g
ñ$  ð%g
ñ& &¡n×&FÑ&FÕGð'g
ñ(  %ð)g
ñ* ð+g
ñ, !¡�ð-g
ñ. ™$•ð/g
ñ0 "ñ1g
ó    c                óŠ  € V'       d   Ve   V^8w  d   \        R4      h^pWÐn        \        P                  ! R4      P	                  V4      V n        W0n        \        P                  ! R4      P	                  V4      V n        \        P                  ! R4      P	                  V4      V n        \        V4       Uu. uF  p\        P                  ! 4       NK  	  upV n        RV n        V	'       g   V
'       g   \        4       V n        V'       d%   V'       g   \        P                   ! VR7      V n        V'       d   \        P                   ! VR7      V n        Ve+   \        P                  ! R4      P	                  V4      V n        \        V4       Uu. uF  p\)        V	V
VVVVVVVVVVVVR7      NK  	  upV n        R# u upi u upi )	a/  Initializes a Transformer encoder specification.

Args:
  num_layers: Number of layers.
  num_heads: Number of attention heads.
  pre_norm: Enable the pre-norm Transformer architecture.
  no_final_norm: Disable the final layer norm in the pre-norm architecture.
  activation: Activation to apply in the feed-forward network.
  num_source_embeddings: Number of source embeddings.
  embeddings_merge: When :obj:`num_source_embeddings` > 1, specify how the
    embeddings are merged.
  layernorm_embedding: Apply layer normalization after the embedding layer.
  relative_position: Use relative position representations in the self-attention
    layers as described in https://arxiv.org/abs/1803.02155.
  relative_attention_bias: Use relative attention bias in the self-attention
    layers as described in the T5 paper https://arxiv.org/abs/1910.10683.
  ffn_glu: Use gated linear units in the FFN layers as described in
    https://arxiv.org/abs/2002.05202.
  rms_norm: Use the root mean square layer normalization.
  multi_query_attention: Use multi-query attention (alias for num_heads_kv=1).
  num_heads_kv: Number of attention heads for the key and value.
  head_dim: Number of dimensions per attention head.
  rotary_dim: Apply rotary embeddings to these first N dimensions. If 0, rotary
    embeddings are applied to all dimensions.
  rotary_interleave: Interleave the head dimensions when rotary embeddings are applied.
    Otherwise the head dimensions are sliced in half.
  rotary_scaling_type: Type of RoPE scaling.
  rotary_scaling_factor: Factor used in the RoPE scaling.
  rotary_base: The base period of the rotary embeddings.
  sliding_window: Max sequence length to retain in KV Cache.
  qk_norm: Apply layer normalization to the query and key projections.
  pre_post_layer_norm: Add post layer norm for each pre norm layer.
Nú5Enabling multi_query_attention implies num_heads_kv=1Úint16Úint8T©r   Úint32)r   r   r   r   r   r   r!   r   r   r   r   r    r"   r#   )Ú
ValueErrorr   ÚnpÚdtypeÚtyper   r   r   r   Úranger   ÚEmbeddingsSpecÚ
embeddingsÚscale_embeddingsÚPositionEncoderSpecÚposition_encodingsÚLayerNormSpecÚ
layer_normr   r!   ÚTransformerEncoderLayerSpecÚlayer)Úselfr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   Ú_s   &&&&&&&&&&&&&&&&&&&&&&&& r,   Ú__init__ÚTransformerEncoderSpec.__init__   s‚  € ÷x !ØÒ'¨L¸AÔ,=Ü ØKóð ð ˆLà%:Ô"ÜŸš 'Ó*×/Ñ/°	Ó:ˆŒØ ŒÜŸ(š( 6Ó*×/Ñ/°
Ó;ˆŒÜ "§¢¨Ó 0× 5Ñ 5Ð6FÓ GˆÔä27Ð8MÔ2Nó
Ù2N¨QŒK×&Ò&Ö(Ñ2Nñ
ˆŒð !%ˆÔß ×)@Ü&9Ó&;ˆDÔ#ßŸMÜ)×7Ò7ÀÔJˆDŒOßÜ'2×'@Ò'@È(Ô'SˆDÔ$ØÒ%Ü"$§(¢(¨7Ó"3×"8Ñ"8¸Ó"HˆDÔô& ˜:Ô&ó#
ñ" '�ô! (Ø"3Ø(?ØØ!Ø)Ø!Ø-Ø%Ø"3Ø$7Ø&;Ø'ØØ$7÷ñ  'ñ#
ˆŽ
ùò
ùò
s   Â8F;Æ"G )r   r<   r   rC   rA   r   r   r   r?   r   r=   r!   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__r   r&   ÚRELUr'   ÚCONCATrF   Ú__static_attributes__Ú__classdictcell__©r+   s   @r,   r	   r	   
   sp   ø‡ € ð
 Ø#Ø-8×-CÑ-C×-HÑ-HØ%&Ø8C×8SÑ8S×8ZÑ8ZØ$)Ø"'Ø(-ØØØ&+Ø&*Ø"&Ø$(Ø"&ØJNØ'(Ø"Ø(,Ø"'Ø$)÷1g
÷ g
ð g
r/   r	   c            $       ó¶   a € ] tR t^ut o R]P
                  P                  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R3$V 3R lR llt]R 4       t	Rt
V tR# )
ÚTransformerDecoderSpecTFNr
   c          L      óÊ  <€ V ^8„  d   QhRS[ RS[ RS[RS[P                  RS[RS[RS[RS[R	S[R
S[RS[ RS[ RS[RS[RS[RS[RS[RS[S[ ,          RS[RS[S[P                  ,          RS[RS[RS[ RS[ RS[RS[RS[RS[RS[S[ ,          RS[S[ ,          RS[S[ ,          R S[S[P                  ,          R!S[S[ ,          R"S[S[ ,          R#S[R$S[R%S[S[,          R&S[/&# )'r   r   r   r   r   r   Úwith_encoder_attentionr   Úproject_in_outr   r   Úalignment_layerÚalignment_headsr   r   ÚalibiÚalibi_use_positive_positionsÚscale_alibir   r   r   r   r    Ú original_max_position_embeddingsÚmax_position_embeddingsÚparallel_residualÚshared_layer_normr#   r   r   r   r!   Ú
quant_typeÚquant_group_sizeÚ
quant_bitsr"   Úv_normÚ external_pre_post_encoder_layersÚmerged_encoder_attention©	r$   r%   r   r&   r   r   r(   r)   ÚQuantization)r*   r+   s   "€r,   r-   Ú#TransformerDecoderSpec.__annotate__v   s  ø€ ÷ jGñ jGáðjGñ ðjGñ ð	jGñ
  ×*Ñ*ðjGñ "ðjGñ !%ðjGñ ðjGñ ðjGñ  ðjGñ "&ðjGñ ðjGñ ðjGñ ðjGñ ðjGñ  ð!jGñ" '+ð#jGñ$ ð%jGñ& ™S•Mð'jGñ(  ð)jGñ* &¡n×&FÑ&FÕGð+jGñ,  %ð-jGñ. ð/jGñ0 +.ð1jGñ2 "%ð3jGñ4  ð5jGñ6  ð7jGñ8 "ð9jGñ:  $ð;jGñ< ™s•mð=jGñ> ™3•-ð?jGñ@ !¡�ðAjGñB ™[×5Ñ5Õ6ðCjGñD #¡3�-ðEjGñF ™S•MðGjGñH ðIjGñJ ðKjGñL +3±4­.ðMjGñN #'ñOjGr/   c'           	     óh  € \        4       V n        V'       d'   V'       g   \        R4      hV'       d   \        R4      hV'       d   Ve   V^8w  d   \        R4      h^p\        P                  ! R4      P                  V4      V n        W0n        \        P                  ! R4      P                  V4      V n        \        P                  ! R4      P                  V4      V n	        \        P                  ! R4      P                  V4      V n
        \        P                  ! 4       V n        RV n        \        P                   V n        Wðn        VV n        VV n        Ve+   \        P                  ! R4      P                  V4      V n        V	'       g$   V
'       g   V'       g   Vf   \-        4       V n        V'       d%   V'       g   \        P0                  ! VR	7      V n        V'       d   \        P0                  ! VR	7      V n        \        P6                  ! 4       V n        \;        V4       U'u. uFN  p'\=        R%/ R
VbRV	bRV
bRVbRVbRVbRVbRVbRVbRVbRVbRVbRVbRVbRVbRVbRVbRVbRV#bRV$bRV%bRV&b NKP  	  up'V n        R V n         \        P                   V n!        T;'       g    VV8g  V P                  R!&   V'       d5   \        P6                  ! 4       V n"        \        P6                  ! 4       V n#        V '       d0   V V P                  R"&   V"V P                  R#&   V!V P                  R$&   R# R# u up'i )&a¾
  Initializes a Transformer decoder specification.

Args:
  num_layers: Number of layers.
  num_heads: Number of attention heads.
  pre_norm: Enable the pre-norm Transformer architecture.
  activation: Activation to apply in the feed-forward network.
  layernorm_embedding: Apply layer normalization after the embedding layer.
  with_encoder_attention: Enable the encoder attention sublayers.
  no_final_norm: Disable the final layer norm in the pre-norm architecture.
  project_in_out: Add linear transformations after the embedding layer and before
    the final layer.
  relative_position: Use relative position representations in the self-attention
    layers as described in https://arxiv.org/abs/1803.02155.
  relative_attention_bias: Use relative attention bias in the self-attention
    layers as described in the T5 paper https://arxiv.org/abs/1910.10683.
  alignment_layer: Layer index selected for alignment.
  alignment_heads: Number of attention heads selected for alignment.
  ffn_glu: Use gated linear units in the FFN layers as described in
    https://arxiv.org/abs/2002.05202.
  rms_norm: Use the root mean square layer normalization.
  alibi: Use attention with linear biases.
  alibi_use_positive_positions: Use positive positions in the ALiBi definition.
  scale_alibi: Apply the dot product scale factor to ALiBi.
  rotary_dim: Apply rotary embeddings to these first N dimensions. If 0, rotary
    embeddings are applied to all dimensions.
  rotary_interleave: Interleave the head dimensions when rotary embeddings are applied.
    Otherwise the head dimensions are sliced in half.
  rotary_scaling_type: Type of RoPE scaling.
  rotary_scaling_factor: Factor used in the RoPE scaling.
  rotary_base: The base period of the rotary embeddings.
  original_max_position_embeddings: The original max position embeddings
    for Su rope embeddings
  max_position_embeddings: The max position embeddings for Su rope embeddings
  parallel_residual: Use parallel residual connections in each layer block, as used
    by the GPT-J and GPT-NeoX models.
  shared_layer_norm: When using parallel residual, share the input and post
    attention layer norms.
  pre_post_layer_norm: Add post layer norm for each pre norm layer
  multi_query_attention: Use multi-query attention (alias for num_heads_kv=1).
  num_heads_kv: Number of attention heads for the key and value.
  sliding_window: Max sequence length to retain in KV Cache.
  quant_type: quantization type used (like awq... for lower bit quantization)
  quant_group_size: group size of the lower bit quantization
  quant_bits: number of bit of the quantization (ex: 4bit)
  external_pre_post_encoder_layers: if the encoder attention pre and processing
    is done outside the attention.
z/The GPT-J block expects a pre-norm architecturez-The GPT-J block does not have cross attentionNr1   r2   r3   Tr5   r4   rT   r   r   r   r   r   r   r   r   r    r[   r\   r]   r^   r#   r   r   r!   r"   rb   rc   rd   Fr   Úquantization_typeÚquantization_bitsÚquantization_group_size© )$ÚdictÚ_configr6   r7   r8   r9   r   r   r   rV   rW   r   r;   r<   r=   r   ÚOPTIONALÚscale_outputsrX   rY   rZ   r!   r>   r?   r@   rA   r   Ú
LinearSpecÚ
projectionr:   ÚTransformerDecoderLayerSpecrC   Ústart_from_zero_embeddingÚfinal_logit_softcappingÚ
project_inÚproject_out)(rD   r   r   r   r   r   rT   r   rU   r   r   rV   rW   r   r   rX   rY   rZ   r   r   r   r   r    r[   r\   r]   r^   r#   r   r   r   r!   r_   r`   ra   r"   rb   rc   rd   rE   s(   &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& r,   rF   ÚTransformerDecoderSpec.__init__v   s&  € ôt “vˆŒßßÜ Ð!RÓSÐSß%Ü Ð!PÓQÐQç ØÒ'¨L¸AÔ,=Ü ØKóð ð ˆLäŸš 'Ó*×/Ñ/°	Ó:ˆŒØ ŒÜŸ(š( 6Ó*×/Ñ/°
Ó;ˆŒÜ!Ÿxšx¨Ó0×5Ñ5°oÓFˆÔÜ!Ÿxšx¨Ó0×5Ñ5°oÓFˆÔÜ%×4Ò4Ó6ˆŒØ $ˆÔÜ'×0Ñ0ˆÔØŒ
Ø,HˆÔ)Ø&ˆÔØÒ%Ü"$§(¢(¨7Ó"3×"8Ñ"8¸Ó"HˆDÔç!ß+ßØÒ"ä&9Ó&;ˆDÔ#ßŸMÜ)×7Ò7ÀÔJˆDŒOßÜ'2×'@Ò'@È(Ô'SˆDÔ$Ü%×0Ò0Ó2ˆŒô4 ˜:Ô&ó3
ñ2 '�ô1 (ò Ù'=ðá"3ðñ )@ðñ  ð	ñ
 "ðñ &ðñ #4ðñ %8ðñ '<ðñ (ðñ 2Rðñ )@ðñ #4ðñ #4ðñ %8ðñ  *ð!ñ" "ð#ñ$  .ð%ñ&  ð'ñ( ð)ñ* 2Rð+ñ, *Bó-ñ0 'ñ3
ˆŒ
ð8 */ˆÔ&Ü'1×':Ñ':ˆÔ$Ø0E÷ 1
ð 1
Ø˜IÑ%ð 	�‰Ð,Ñ-÷ Ü)×4Ò4Ó6ˆDŒOÜ*×5Ò5Ó7ˆDÔçØ0:ˆD�L‰LÐ,Ñ-Ø0:ˆD�L‰LÐ,Ñ-Ø6FˆD�L‰LÐ2Ó3ñ ùòM
s   È&AL/c                ó   € V P                   # ©N)rn   ©rD   s   &r,   ÚconfigÚTransformerDecoderSpec.config"  s   € à�|‰|Ðr/   )rn   r   rX   rY   rW   rV   r<   ru   rC   rA   r   r   r?   r   rv   rw   rr   rZ   r=   rp   r!   rt   éÿÿÿÿ)rH   rI   rJ   rK   r   r&   rL   rF   Úpropertyr|   rN   rO   rP   s   @r,   rR   rR   u   s£   ø‡ € ð
 Ø-8×-CÑ-C×-HÑ-HØ$)Ø'+Ø#Ø$Ø"'Ø(-Ø!Ø ØØØØ-2Ø!Ø$(Ø"&ØJNØ'(Ø"Ø01Ø'(Ø"'Ø"'Ø$)Ø&+Ø&*Ø"&Ø(,Ø9=Ø*.Ø$(ØØØ;@Ø).÷OjGò jGðX ñó ör/   rR   c                   ó6   a € ] tR tRt o RV 3R lR lltRtV tR# )rB   i'  Nc                ór   <€ V ^8„  d   QhRS[ S[,          RS[RS[ S[P                  ,          RS[RS[RS[/# )r   r   r   r   r   r    r#   )r   r$   r%   r   r(   r)   )r*   r+   s   "€r,   r-   Ú(TransformerEncoderLayerSpec.__annotate__(  sX   ø€ ÷ /,ñ /,ñ ™S•Mð/,ñ  ð/,ñ &¡n×&FÑ&FÕGð/,ñ  %ð/,ñ ð/,ñ "ñ/,r/   c                óÄ  € \         P                  ! R VVVVVVVV	V
VVVR7      V n        \        W4R7      V n        V'       dŸ   \
        P                  ! VR7      V n        \
        P                  ! VR7      V n        \
        P                  ! VR7      V n	        \
        P                  ! VR7      V n
        \        V P                  R4       \        V P                  R4       R# R# )T)Úself_attentionr   r   r   r   r   r!   r   r   r   r   r    r"   ©Úglur   r4   rA   N)r   ÚMultiHeadAttentionSpecr„   ÚFeedForwardSpecÚffnr   r@   Úinput_layer_normÚpost_attention_layer_normÚpre_feedforward_layer_normÚpost_feedforward_layer_normÚdelattr)rD   r   r   r   r   r   r   r!   r   r   r   r   r    r"   r#   s   &&&&&&&&&&&&&&&r,   rF   Ú$TransformerEncoderLayerSpec.__init__(  sÍ   € ô" -×CÒCØØ/Ø$;ØØ%ØØ)Ø!Ø/Ø 3Ø"7Ø#Øô
ˆÔô # wÔBˆŒçÜ$/×$=Ò$=ÀxÔ$PˆDÔ!Ü-8×-FÒ-FØ!ô.ˆDÔ*ô /:×.GÒ.GØ!ô/ˆDÔ+ô 0;×/HÒ/HØ!ô0ˆDÔ,ô �D×'Ñ'¨Ô6Ü�D—H‘H˜lÖ+ñ r/   )r‰   rŠ   r‹   r�   rŒ   r„   )FFFFNNNNTNé   r
   FF©rH   rI   rJ   rK   rF   rN   rO   rP   s   @r,   rB   rB   '  s   ø‡ € ÷/,÷ /,ð /,r/   rB   c                   ó*   a € ] tR tRt o RR ltRtV tR# )rs   iZ  Nc           	     ó>  € \         P                  ! R/ R RbRVbRVbRVbRVbRVbRVbRV	bR	V
bR
VbRVbRVbRVbRVbRVbRVbRVb V n        V'       d,   V'       g$   \         P                  ! VVVVVVRJ R7      V n        \	        WER7      V n        V'       d„   V'       d   \        P                  ! 4       V n        M4\        P                  ! 4       V n	        \        P                  ! 4       V n
        \        V P                  R4       \        V P
                  R4       V'       då   \        P                  ! VR7      V n	        \        P                  ! VR7      V n
        V'       dA   V'       d9   \        P                  ! VR7      V n        \        P                  ! VR7      V n        \        P                  ! VR7      V n        \        P                  ! VR7      V n        \        V P                  R4       \        V P
                  R4       \         P"                  V n        R# )r„   Tr   r   r   r   r   r   r   r    r[   r\   r   r   r!   r"   rb   rd   F)r   r   r   r!   r"   Úhas_normr…   rA   r4   Nrl   )r   r‡   r„   Ú	attentionrˆ   r‰   r   r@   r^   rŠ   r‹   rŽ   Ú*external_post_encoder_attention_layer_normÚ)external_pre_encoder_attention_layer_normrŒ   r�   r   ro   Úlayer_scalar)rD   rT   r   r   r   r   r   r   r   r   r    r[   r\   r]   r^   r#   r   r   r!   r"   rb   rc   rd   s   &&&&&&&&&&&&&&&&&&&&&&&r,   rF   Ú$TransformerDecoderLayerSpec.__init__[  s  € ô2 -×CÒCò 
Ùð
á/ð
ñ %<ð
ñ ð	
ñ
 "ð
ñ 0ð
ñ !4ð
ñ #8ð
ñ $ð
ñ .Nð
ñ %<ð
ñ &ð
ñ ð
ñ *ð
ñ ð
ñ  ð!
ñ" &>ð#
ˆÔ÷( "×*BÜ+×BÒBØ!Ø)Ø!Ø-ØØ9¸UÐBôˆDŒNô # wÔBˆŒçß Ü)4×)BÒ)BÓ)D�Õ&ä(3×(AÒ(AÓ(C�Ô%Ü1<×1JÒ1JÓ1L�Ô.ä�D×'Ñ'¨Ô6Ü�D—H‘H˜lÔ+çä$/×$=Ò$=ÀxÔ$PˆDÔ!Ü-8×-FÒ-FØ!ô.ˆDÔ*÷ &×*Jä×-Ò-°xÔ@ð Ô?ô  ×-Ò-°xÔ@ð Ô>ô
 /:×.GÒ.GØ!ô/ˆDÔ+ô 0;×/HÒ/HØ!ô0ˆDÔ,ô �D×'Ñ'¨Ô6Ü�D—H‘H˜lÔ+ä&×/Ñ/ˆÖr/   )r•   r–   r—   r‰   rŠ   r˜   r‹   r�   rŒ   r„   r^   )TFFFFNTNr�   r
   é    rš   FFFNNNFFFFr‘   rP   s   @r,   rs   rs   Z  s   ø‡ € ÷]0ò ]0r/   rs   c                   ó*   a € ] tR tRt o RR ltRtV tR# )rˆ   i»  c                óî   € \         P                  ! VR 7      V n        \         P                  ! 4       V n        \         P                  ! 4       V n        V'       d   \         P                  ! 4       V n        R# R# )r4   N)r   r@   rA   rq   Úlinear_0Úlinear_1Úlinear_0_noact)rD   r†   r   s   &&&r,   rF   ÚFeedForwardSpec.__init__¼  sM   € Ü%×3Ò3¸XÔFˆŒÜ#×.Ò.Ó0ˆŒÜ#×.Ò.Ó0ˆŒßÜ"-×"8Ò"8Ó":ˆDÖñ r/   )rA   r�   rŸ   rž   N)FFr‘   rP   s   @r,   rˆ   rˆ   »  s   ø‡ € ÷;ò ;r/   rˆ   c                   ó&   a € ] tR tRt o R tRtV tR# )r>   iÄ  c                ó0   € \         P                  V n        R # rz   )r   ro   Ú	encodingsr{   s   &r,   rF   ÚPositionEncoderSpec.__init__Å  s   € Ü#×,Ñ,ˆŽr/   )r£   Nr‘   rP   s   @r,   r>   r>   Ä  s   ø‡ € ÷-ð -r/   r>   c                   óF   a a€ ] tR tRt oRtRV3R lV 3R llltRtVtV ;t# )ÚTransformerConfigiÉ  z%Configuration for Transformer models.c                ó0   <€ V ^8„  d   QhRS[ S[,          /# ©r   Úlayer_norm_epsilon©r   r)   )r*   r+   s   "€r,   r-   ÚTransformerConfig.__annotate__Ì  ó   ø€ ÷ Jñ J©8±E­?ñ Jr/   c                ó,   <€ \         SV `  ! RRV/VB  R# )z—Initializes the configuration for Transformer models.

Args:
  layer_norm_epsilon: The layer norm epsilon value.
  **kwargs: Additional configuration.
r©   Nrl   ©ÚsuperrF   ©rD   r©   ÚkwargsÚ	__class__s   &&,€r,   rF   ÚTransformerConfig.__init__Ì  ó   ø€ ô 	‰ÒÑIÐ,>ÐIÀ&ÔIr/   rl   rz   ©	rH   rI   rJ   rK   Ú__doc__rF   rN   rO   Ú__classcell__©r²   r+   s   @@r,   r¦   r¦   É  s   ù‡ € Ù/÷J÷ Jõ Jr/   r¦   c                   óþ   a a€ ] tR tRt oRtV3R lV 3R llt]RRR]P                  P                  R^^]P                  P                  RRRRR3V3R lR ll4       t]R	 4       t]R
 4       tR tR tR tRtVtV ;t# )ÚTransformerSpeciÖ  z�Describes a Transformer model.

The specification is invariant to hidden dimensions but requires to
explicitly set the number of layers and attention heads.
c                ó&   <€ V ^8„  d   QhRS[ RS[/# )r   ÚencoderÚdecoder)r	   rR   )r*   r+   s   "€r,   r-   ÚTransformerSpec.__annotate__Ý  s   ø€ ÷ 
ñ 
Ù-ð
Ù8Nñ
r/   c                ó   <€ \        V\        4      '       g   \        R4      h\        V\        4      '       g   \        R4      h\        SV `  4        Wn        W n        V P                  P                  RV P                  P                  4       R# )z‚Initializes a Transformer model specification.

Args:
  encoder: The encoder specification.
  decoder: The decoder specification.
ú1encoder argument must be a TransformerEncoderSpecú1decoder argument must be a TransformerDecoderSpecr   N)Ú
isinstancer	   Ú	TypeErrorrR   r¯   rF   r¼   r½   rn   Úadd_attributer   )rD   r¼   r½   r²   s   &&&€r,   rF   ÚTransformerSpec.__init__Ý  so   ø€ ô ˜'Ô#9×:Ò:ÜÐOÓPÐPÜ˜'Ô#9×:Ò:ÜÐOÓPÐPä‰ÑÔØŒØŒØ�‰×"Ñ"Ø# T§\¡\×%GÑ%Gö	
r/   FTc                óÈ   <€ V ^8„  d   QhRS[ S[S[S[S[3,          3,          RS[RS[RS[RS[RS[P
                  RS[RS[R	S[R
S[P                  RS[RS[RS[RS[RS[/# )r   r   r   Úwith_relative_positionr   r   r   rV   rW   r   r   r   r   r   r   r   )r   r$   r   r%   r   r&   r'   )r*   r+   s   "€r,   r-   r¾   ó  sÐ   ø€ ÷ O%ñ O%á™#™u¡S©# X�Ð.Õ/ðO%ñ ðO%ñ !%ð	O%ñ
 ðO%ñ ðO%ñ  ×*Ñ*ðO%ñ ðO%ñ ðO%ñ  #ðO%ñ &×5Ñ5ðO%ñ "ðO%ñ "&ðO%ñ ðO%ñ ðO%ñ   $ñ!O%r/   c                ó¾   € \        V\        \        34      '       d   Vw  ppMYpp\        VVVVVV	V
VVVVVVR7      p\	        VVVVVVVVVVVVVR7      pV ! VV4      # )aå  Creates a Transformer model specification.

Args:
  num_layers: Number of encoder and decoder layers, or a 2-tuple if the
    number is different.
  num_heads: Number of attention heads.
  with_relative_position: Use relative position representations in the self-attention
    layers as described in https://arxiv.org/abs/1803.02155.
  pre_norm: Enable the pre-norm Transformer architecture.
  no_final_norm: Disable the final layer norm in the pre-norm architecture.
  activation: Activation to apply in the feed-forward network.
  alignment_layer: Layer index selected for alignment.
  alignment_heads: Number of attention heads selected for alignment.
  num_source_embeddings: Number of source embeddings.
  embeddings_merge: When :obj:`num_source_embeddings` > 1, specify how the
    embeddings are merged.
  layernorm_embedding: Apply layer normalization after the embedding layer.
  relative_attention_bias: Use relative attention bias in the self-attention
    layers as described in the T5 paper https://arxiv.org/abs/1910.10683.
  ffn_glu: Use gated linear units in the FFN layer as described in
    https://arxiv.org/abs/2002.05202.
  rms_norm: Use the root mean square layer normalization.
  multi_query_attention: Use multi-query attention.
)r   r   r   r   r   r   r   r   r   r   r   )r   r   r   r   r   r   rV   rW   r   r   r   )rÂ   ÚlistÚtupler	   rR   )Úclsr   r   rÇ   r   r   r   rV   rW   r   r   r   r   r   r   r   Únum_encoder_layersÚnum_decoder_layersr¼   r½   s   &&&&&&&&&&&&&&&&    r,   Úfrom_configÚTransformerSpec.from_configò  sž   € ôV �j¤4¬ -×0Ò0Ø5?Ñ2ÐÑ 2à5?Ð 2Ðä(ØØØØ'Ø!Ø"7Ø-Ø 3Ø4Ø$;ØØØ"7ô
ˆô  )ØØØØ'Ø!Ø 3Ø4Ø$;Ø+Ø+ØØØ"7ô
ˆñ  �7˜GÓ$Ð$r/   c                ó   € R # )rº   rl   r{   s   &r,   ÚnameÚTransformerSpec.nameD  s   € á r/   c                ó   € ^# )é   rl   r{   s   &r,   ÚrevisionÚTransformerSpec.revisionH  ó   € ár/   c                ó   € \        4       # rz   )r¦   r{   s   &r,   Úget_default_configÚ"TransformerSpec.get_default_configL  s   € Ü Ó"Ð"r/   c                óŒ   € V P                   P                   Uu. uF  qP                  P                  ^ ,          NK!  	  up# u upi ©rš   ©r¼   r<   ÚweightÚshape)rD   Úspecs   & r,   Úget_source_vocabulary_sizeÚ*TransformerSpec.get_source_vocabulary_sizeO  s6   € Ø15·±×1HÒ1HÓIÑ1H¨—‘×!Ñ! !×$Ð$Ñ1HÑIÐIùÒIs   ™%Ac                ód   € V P                   P                  P                  P                  ^ ,          # rÜ   ©r½   r<   rÞ   rß   r{   s   &r,   Úget_target_vocabulary_sizeÚ*TransformerSpec.get_target_vocabulary_sizeR  ó#   € Ø�|‰|×&Ñ&×-Ñ-×3Ñ3°AÕ6Ð6r/   )r½   r¼   r~   )rH   rI   rJ   rK   r¶   rF   Úclassmethodr   r&   rL   r'   rM   rÎ   r   rÑ   rÕ   rÙ   rá   rå   rN   rO   r·   r¸   s   @@r,   rº   rº   Ö  s¯   ù‡ € ñ÷
ó 
ð* ð
 (-ØØ#Ø-8×-CÑ-C×-HÑ-HØ!Ø Ø%&Ø8C×8SÑ8S×8ZÑ8ZØ$)Ø(-ØØØ&+÷!O%ñ O%ó ðO%ðb ñ!ó ð!ð ñó ðò#òJ÷7ò 7r/   rº   c                   óF   a a€ ] tR tRt oRtRV3R lV 3R llltRtVtV ;t# )ÚTransformerDecoderModelConfigiV  z-Configuration for Transformer decoder models.c                ó0   <€ V ^8„  d   QhRS[ S[,          /# r¨   rª   )r*   r+   s   "€r,   r-   Ú*TransformerDecoderModelConfig.__annotate__Y  r¬   r/   c                ó,   <€ \         SV `  ! RRV/VB  R# )zŸInitializes the configuration for Transformer decoder models.

Args:
  layer_norm_epsilon: The layer norm epsilon value.
  **kwargs: Additional configuration.
r©   Nrl   r®   r°   s   &&,€r,   rF   Ú&TransformerDecoderModelConfig.__init__Y  r´   r/   rl   rz   rµ   r¸   s   @@r,   rê   rê   V  ó   ù‡ € Ù7÷J÷ Jõ Jr/   rê   c                   óò   a a€ ] tR tRt oRtV3R lV 3R llt]R]P                  P                  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3V3R	 lR
 ll4       t
]R 4       t]R 4       tR tR tRtVtV ;t# )ÚTransformerDecoderModelSpecic  z3Describes a Transformer decoder model (e.g. GPT-2).c                ó    <€ V ^8„  d   QhRS[ /# )r   r½   ©rR   )r*   r+   s   "€r,   r-   Ú(TransformerDecoderModelSpec.__annotate__f  s   ø€ ÷ 3ñ 3Ñ 6ñ 3r/   c                ó  <€ \        V\        4      '       g   \        R4      h\        SV `  4        Wn        V P
                  P                  P                  4        F   w  r#V P                  P                  W#4       K"  	  R# )zdInitializes a Transformer decoder model specification.

Args:
  decoder: The decoder specification.
rÁ   N)
rÂ   rR   rÃ   r¯   rF   r½   r|   Úitemsrn   rÄ   )rD   r½   ÚkeyÚvaluer²   s   &&  €r,   rF   Ú$TransformerDecoderModelSpec.__init__f  s`   ø€ ô ˜'Ô#9×:Ò:ÜÐOÓPÐPä‰ÑÔØŒØŸ,™,×-Ñ-×3Ñ3Ö5‰JˆCØ�L‰L×&Ñ& sÖ2ó 6r/   TFNr
   c          @      ó–  <€ V ^8„  d   QhRS[ RS[ RS[RS[P                  RS[RS[RS[RS[R	S[R
S[RS[RS[RS[RS[S[ ,          RS[RS[S[P                  ,          RS[RS[RS[ RS[ RS[RS[RS[RS[RS[S[ ,          RS[S[ ,          RS[S[ ,          RS[S[P                  ,          RS[S[ ,          RS[S[ ,          RS[R S[/ # )!r   r   r   r   r   r   r   rU   rÇ   r   r   rX   rY   rZ   r   r   r   r   r    r[   r\   r]   r^   r#   r   r   r   r!   r_   r`   ra   r"   rb   re   )r*   r+   s   "€r,   r-   rô   u  s¥  ø€ ÷ pñ páðpñ ðpñ ð	pñ
  ×*Ñ*ðpñ "ðpñ ðpñ ðpñ !%ðpñ ðpñ ðpñ ðpñ '+ðpñ ðpñ ™S•Mðpñ   ð!pñ" &¡n×&FÑ&FÕGð#pñ$  %ð%pñ& ð'pñ( +.ð)pñ* "%ð+pñ,  ð-pñ.  ð/pñ0 "ð1pñ2  $ð3pñ4 ™s•mð5pñ6 ™3•-ð7pñ8 !¡�ð9pñ: ™[×5Ñ5Õ6ð;pñ< #¡3�-ð=pñ> ™S•Mð?pñ@ ðApñB ñCpr/   c!                óâ   € \        VV3/ RVbRVbRVbRRbRVbRVbRVbR	V	bR
V
bRVbRVbRVbRVbRVbRVbRVbRVbRVbRVbRVbRVbRVbRVbRVbRVbRVbRVbRVbRVbRVbR V b p!V ! V!4      # )!aé  Creates a Transformer decoder model specification.

Args:
  num_layers: Number of decoder layers.
  num_heads: Number of attention heads.
  pre_norm: Enable the pre-norm Transformer architecture.
  activation: Activation to apply in the feed-forward network.
  layernorm_embedding: Apply layer normalization after the embedding layer.
  no_final_norm: Do not apply layer normalization after the last decoder block.
  project_in_out: Add a linear layer after the embedding layer and another one
    before the final output projection.
  with_relative_position: Enable relative position representations modules.
  ffn_glu: Use gated linear units in the FFN layers as described in
    https://arxiv.org/abs/2002.05202.
  rms_norm: Use the root mean square layer normalization.
  alibi: Use attention with linear biases.
  alibi_use_positive_positions: Use positive positions in the ALiBi definition.
  scale_alibi: Apply the dot product scale factor to ALiBi.
  rotary_dim: Apply rotary embeddings to these first N dimensions. If 0, rotary
    embeddings are applied to all dimensions.
  rotary_interleave: Interleave the head dimensions when rotary embeddings are applied.
    Otherwise the head dimensions are sliced in half.
  rotary_scaling_type: Type of RoPE scaling.
  rotary_scaling_factor: Factor used in the RoPE scaling.
  rotary_base: The base period of the rotary embeddings.
  original_max_position_embeddings: The original max position embeddings
    for Su rope embeddings
  max_position_embeddings: The max position embeddings for Su rope embeddings
  parallel_residual: Use parallel residual connections in each layer block, as used
    by the GPT-J and GPT-NeoX models.
  shared_layer_norm: When using parallel residual, share the input and post
    attention layer norms.
  pre_post_layer_norm: add post layer norm for each pre norm layer
  multi_query_attention: Use multi-query attention (alias for num_heads_kv=1).
  num_heads_kv: Number of attention heads for the key and value.
  head_dim: Number of head
  sliding_window: max sequence length to retain KV cache
  quant_type: quantization type used (like awq... for lower bit quantization)
  quant_group_size: group size of the lower bit quantization
  quant_bits: number of bit of the quantization (ex: 4bit)
r   r   r   rT   Fr   rU   r   r   r   rX   rY   rZ   r   r   r   r   r    r[   r\   r]   r^   r#   r   r   r   r!   r_   r`   ra   r"   rb   ró   )"rË   r   r   r   r   r   r   rU   rÇ   r   r   rX   rY   rZ   r   r   r   r   r    r[   r\   r]   r^   r#   r   r   r   r!   r_   r`   ra   r"   rb   r½   s"   &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& r,   rÎ   Ú'TransformerDecoderModelSpec.from_configt  s^  € ôZ )ØØò"
ñ ð"
ñ "ð	"
ñ
 !4ð"
ñ $)ð"
ñ (ð"
ñ *ð"
ñ 5ð"
ñ ð"
ñ ð"
ñ ð"
ñ *Fð"
ñ $ð"
ñ "ð"
ñ  0ð!"
ñ" !4ð#"
ñ$ #8ð%"
ñ& $ð'"
ñ( .Nð)"
ñ* %<ð+"
ñ, 0ð-"
ñ. 0ð/"
ñ0 !4ð1"
ñ2 #8ð3"
ñ4 &ð5"
ñ6 ð7"
ñ8 *ð9"
ñ: "ð;"
ñ< .ð="
ñ> "ð?"
ñ@ ðA"
ñB ðC"
ˆñH �7‹|Ðr/   c                ó   € R # ró   rl   r{   s   &r,   rÑ   Ú TransformerDecoderModelSpec.nameç  ó   € á'r/   c                ó   € ^# )é   rl   r{   s   &r,   rÕ   Ú$TransformerDecoderModelSpec.revisionë  r×   r/   c                ó   € \        4       # rz   )rê   r{   s   &r,   rÙ   Ú.TransformerDecoderModelSpec.get_default_configï  ó   € Ü,Ó.Ð.r/   c                ód   € V P                   P                  P                  P                  ^ ,          # rÜ   rä   r{   s   &r,   Úget_vocabulary_sizeÚ/TransformerDecoderModelSpec.get_vocabulary_sizeò  rç   r/   )r½   )rH   rI   rJ   rK   r¶   rF   rè   r   r&   rL   rÎ   r   rÑ   rÕ   rÙ   r  rN   rO   r·   r¸   s   @@r,   rñ   rñ   c  sÏ   ù‡ € Ù=÷3ó 3ð ð
 Ø-8×-CÑ-C×-HÑ-HØ$)Ø#Ø$Ø',ØØØØ-2Ø!Ø$(Ø"&ØJNØ'(Ø"Ø01Ø'(Ø"'Ø"'Ø$)Ø&+Ø&*Ø"&Ø(,Ø9=Ø*.Ø$(ØØ÷Cpñ pó ðpðd ñ(ó ð(ð ñó ðò/÷7ò 7r/   rñ   c                   óF   a a€ ] tR tRt oRtRV3R lV 3R llltRtVtV ;t# )ÚTransformerEncoderModelConfigiö  z-Configuration for Transformer encoder models.c                ó0   <€ V ^8„  d   QhRS[ S[,          /# r¨   rª   )r*   r+   s   "€r,   r-   Ú*TransformerEncoderModelConfig.__annotate__ù  r¬   r/   c                ó,   <€ \         SV `  ! RRV/VB  R# )zŸInitializes the configuration for Transformer encoder models.

Args:
  layer_norm_epsilon: The layer norm epsilon value.
  **kwargs: Additional configuration.
r©   Nrl   r®   r°   s   &&,€r,   rF   Ú&TransformerEncoderModelConfig.__init__ù  r´   r/   rl   rz   rµ   r¸   s   @@r,   r
  r
  ö  rï   r/   r
  c                   óž   a a€ ] tR tRt oRtR]P                  P                  3V3R lV 3R lllt]	R 4       t
]	R 4       tR tR	 tR
tVtV ;t# )ÚTransformerEncoderModelSpeci  z2Describes a Transformer encoder model (e.g. BERT).Fc                ó@   <€ V ^8„  d   QhRS[ RS[RS[P                  /# )r   r¼   Úpooling_layerÚpooling_activation)r	   r%   r   r&   )r*   r+   s   "€r,   r-   Ú(TransformerEncoderModelSpec.__annotate__  s4   ø€ ÷ Oñ Oá'ðOñ ðOñ (×2Ñ2ñ	Or/   c                ón  <€ \        V\        4      '       g   \        R4      h\        SV `  4        Wn        V P                  P                  RV P
                  P                  4       V'       dG   \        P                  ! 4       V n        \        P                  ! R4      P                  V4      V n        R# R# )zÓInitializes a Transformer encoder model specification.

Args:
  encoder: The encoder specification.
  pooling_layer: Add the pooling layer.
  pooling_activation: The activation to apply after the pooling layer.
rÀ   r   r3   N)rÂ   r	   rÃ   r¯   rF   r¼   rn   rÄ   r   r   rq   Úpooler_denser7   r8   r9   Úpooler_activation)rD   r¼   r  r  r²   s   &&&&€r,   rF   Ú$TransformerEncoderModelSpec.__init__  sˆ   ø€ ô ˜'Ô#9×:Ò:ÜÐOÓPÐPä‰ÑÔØŒØ�‰×"Ñ"Ø# T§\¡\×%GÑ%Gô	
÷ Ü +× 6Ò 6Ó 8ˆDÔÜ%'§X¢X¨fÓ%5×%:Ñ%:Ð;MÓ%NˆDÖ"ñ r/   c                ó   € R # )r	   rl   r{   s   &r,   rÑ   Ú TransformerEncoderModelSpec.name   rÿ   r/   c                ó   € ^# )r�   rl   r{   s   &r,   rÕ   Ú$TransformerEncoderModelSpec.revision$  r×   r/   c                ó   € \        4       # rz   )r
  r{   s   &r,   rÙ   Ú.TransformerEncoderModelSpec.get_default_config(  r  r/   c                ór   € V P                   P                  ^ ,          P                  P                  ^ ,          # rÜ   rÝ   r{   s   &r,   r  Ú/TransformerEncoderModelSpec.get_vocabulary_size+  s(   € Ø�|‰|×&Ñ& qÕ)×0Ñ0×6Ñ6°qÕ9Ð9r/   )r¼   r  r  )rH   rI   rJ   rK   r¶   r   r&   ÚTanhrF   r   rÑ   rÕ   rÙ   r  rN   rO   r·   r¸   s   @@r,   r  r    s_   ù‡ € Ù<ð
 $Ø5@×5KÑ5K×5PÑ5P÷	Oõ Oð4 ñ(ó ð(ð ñó ðò/÷:ò :r/   r  )r¶   Útypingr   r   r   Únumpyr7   Úctranslate2.specsr   r   r   Ú	LayerSpecr	   rR   rB   rs   rˆ   r>   ÚSequenceToSequenceModelConfigr¦   ÚSequenceToSequenceModelSpecrº   ÚLanguageModelConfigrê   ÚLanguageModelSpecrñ   r
  r  rl   r/   r,   Ú<module>r*     s  ðÙ 6ç )Ñ )ã ç EÑ Eôh
˜Z×1Ñ1ô h
ôVo˜Z×1Ñ1ô oôd0, *×"6Ñ"6ô 0,ôf^0 *×"6Ñ"6ô ^0ôB;�j×*Ñ*ô ;ô-˜*×.Ñ.ô -ô

J˜
×@Ñ@ô 
Jô}7�j×<Ñ<ô }7ô@
J J×$BÑ$Bô 
JôP7 *×">Ñ">ô P7ôf
J J×$BÑ$Bô 
Jô): *×">Ñ">ö ):r/   