ó
    >:jð4  ã                  óÔ   • S SK Jr  S SKrS SKrS SKJr  S SKJrJr  S SK	J
r
  S SKJr  S SKJr  S SKJr  S S	KJr  S S
KJrJrJrJr  \R4                  " \5      r\ " S S\5      5       rg)é    )ÚannotationsN)ÚCallable)Ú	dataclassÚfield)ÚUnion)Úparse)ÚTrainingArguments)Ú__version__)ÚParallelMode)ÚBatchSamplersÚDefaultBatchSamplerÚMultiDatasetBatchSamplersÚMultiDatasetDefaultBatchSamplerc                  ó  ^ • \ rS rSr% Sr/ SQr\" SSS0S9rS\S	'   \" \	R                  SS
0S9rS\S'   \" \R                  SS0S9rS\S'   \" \SS0S9rS\S'   \" \SS0S9rS\S'   \" S SS0S9rS\S'   U 4S jrU 4S jrSrU =r$ )ÚBaseTrainingArgumentsé   aj  
BaseTrainingArguments extends :class:`~transformers.TrainingArguments` with additional arguments
specific to Sentence Transformers. See :class:`~transformers.TrainingArguments` for the complete list of
available arguments.

Args:
    output_dir (`str`):
        The output directory where the model checkpoints will be written.
    prompts (`Union[Dict[str, Dict[str, str]], Dict[str, str], str]`, *optional*):
        The prompts to use for each column in the training, evaluation and test datasets. Four formats are accepted:

        1. `str`: A single prompt to use for all columns in the datasets, regardless of whether the training/evaluation/test
           datasets are :class:`datasets.Dataset` or a :class:`datasets.DatasetDict`.
        2. `Dict[str, str]`: A dictionary mapping column names to prompts, regardless of whether the training/evaluation/test
           datasets are :class:`datasets.Dataset` or a :class:`datasets.DatasetDict`.
        3. `Dict[str, str]`: A dictionary mapping dataset names to prompts. This should only be used if your training/evaluation/test
           datasets are a :class:`datasets.DatasetDict` or a dictionary of :class:`datasets.Dataset`.
        4. `Dict[str, Dict[str, str]]`: A dictionary mapping dataset names to dictionaries mapping column names to
           prompts. This should only be used if your training/evaluation/test datasets are a
           :class:`datasets.DatasetDict` or a dictionary of :class:`datasets.Dataset`.

    batch_sampler (Union[:class:`~sentence_transformers.sentence_transformer.training_args.BatchSamplers`, `str`, :class:`~sentence_transformers.base.sampler.DefaultBatchSampler`, Callable[[...], :class:`~sentence_transformers.base.sampler.DefaultBatchSampler`]], *optional*):
        The batch sampler to use. See :class:`~sentence_transformers.sentence_transformer.training_args.BatchSamplers` for valid options.
        Defaults to ``BatchSamplers.BATCH_SAMPLER``.
    multi_dataset_batch_sampler (Union[:class:`~sentence_transformers.sentence_transformer.training_args.MultiDatasetBatchSamplers`, `str`, :class:`~sentence_transformers.base.sampler.MultiDatasetDefaultBatchSampler`, Callable[[...], :class:`~sentence_transformers.base.sampler.MultiDatasetDefaultBatchSampler`]], *optional*):
        The multi-dataset batch sampler to use. See :class:`~sentence_transformers.sentence_transformer.training_args.MultiDatasetBatchSamplers`
        for valid options. Defaults to ``MultiDatasetBatchSamplers.PROPORTIONAL``.
    router_mapping (`Dict[str, str] | Dict[str, Dict[str, str]]`, *optional*):
        A mapping of dataset column names to Router routes, like "query" or "document". This is used to specify
        which Router submodule to use for each dataset. Two formats are accepted:

        1. `Dict[str, str]`: A mapping of column names to routes.
        2. `Dict[str, Dict[str, str]]`: A mapping of dataset names to a mapping of column names to routes for
           multi-dataset training/evaluation.
    learning_rate_mapping (`Dict[str, float] | None`, *optional*):
        A mapping of parameter name regular expressions to learning rates. This allows you to set different
        learning rates for different parts of the model, e.g., `{'SparseStaticEmbedding\.*': 1e-3}` for the
        SparseStaticEmbedding module. This is useful when you want to fine-tune specific parts of the model
        with different learning rates.
)Úaccelerator_configÚfsdp_configÚ	deepspeedÚgradient_checkpointing_kwargsÚlr_scheduler_kwargsÚlearning_rate_mappingÚpromptsÚrouter_mappingNÚhelpzòThe prompts to use for each column in the datasets. Either 1) a single string prompt, 2) a mapping of column names to prompts, 3) a mapping of dataset names to prompts, or 4) a mapping of dataset names to a mapping of column names to prompts.)ÚdefaultÚmetadataz;Union[str, None, dict[str, str], dict[str, dict[str, str]]]r   zThe batch sampler to use.zRUnion[BatchSamplers, str, DefaultBatchSampler, Callable[..., DefaultBatchSampler]]Úbatch_samplerz'The multi-dataset batch sampler to use.zvUnion[MultiDatasetBatchSamplers, str, MultiDatasetDefaultBatchSampler, Callable[..., MultiDatasetDefaultBatchSampler]]Úmulti_dataset_batch_samplerzíA mapping of dataset column names to Router routes, like "query" or "document". Either 1) a mapping of column names to routes or 2) a mapping of dataset names to a mapping of column names to routes for multi-dataset training/evaluation. )Údefault_factoryr   r   zãA mapping of parameter name regular expressions to learning rates. This allows you to set different learning rates for different parts of the model, e.g., {'SparseStaticEmbedding\.*': 1e-3} for the SparseStaticEmbedding module.z"Union[str, None, dict[str, float]]r   c                 óB   • [        [        5      [        S5      :¼  a  S $ S$ )Nú5.0.0ç        )Úparse_versionÚtransformers_version© ó    Úe/home/mande/repo/quber/.venv/lib/python3.13/site-packages/sentence_transformers/base/training_args.pyÚ<lambda>ÚBaseTrainingArguments.<lambda>u   s    € ¬Ô6JÓ(KÌ}Ð]dÓOeÓ(e Ð nÐknÐ nr'   z¬This argument is deprecated and will be removed in the future. If you're on Transformers v5+, then you should use `warmup_steps` instead as it also works with float values.zfloat | NoneÚwarmup_ratioc                ó  >• [        [        5      [        S5      :¼  aK  U R                  b=  U R                  S:X  a-  U R                  U l        S U l        [        R                  S5        Oa[        U R                  [        5      (       aB  SU R                  s=:  a  S:  a+  O  O(U R                  S:X  a  U R                  U l        SU l        [        TU ]%  5         [        U R                  [        5      (       a  [        U R                  5      OU R                  U l
        [        U R                  [        5      (       a  [        U R                  5      OU R                  U l        [        U R                  [        5      (       a&   [         R"                  " U R                  5      U l        U R&                  b  U R&                  O0 U l        [        U R&                  [        5      (       a&   [         R"                  " U R&                  5      U l        U R*                  b  U R*                  O0 U l        [        U R*                  [        5      (       a&   [         R"                  " U R*                  5      U l        SU l        S	U l        U R0                  [2        R4                  :X  a'  U R6                  S
:w  a  [        R                  S5        g g U R0                  [2        R8                  :X  a?  U R:                  (       d-  U R6                  S
:w  a  [        R                  S5        SU l        g g g ! [         R$                   a     GN’f = f! [         R$                   a    [)        S5      ef = f! [         R$                   a    [)        S5      ef = f)Nr"   r   a  The `warmup_ratio` argument is deprecated in Transformers v5+, and will also be removed from Sentence Transformers once support for Transformers v4 is dropped. Since you're using Transformers v5+, please use `warmup_steps` (as a float) to specify the warmup ratio instead.r#   g      ð?zœThe `learning_rate_mapping` argument must be a dictionary mapping parameter name regular expressions to learning rates. A stringified dictionary also works.z¢The `router_mapping` argument must be a dictionary mapping dataset column names to Router routes, like 'query' or 'document'. A stringified dictionary also works.TFÚunusedzáCurrently using DataParallel (DP) for multi-gpu training, while DistributedDataParallel (DDP) is recommended for faster training. See https://sbert.net/docs/sentence_transformer/training/distributed.html for more information.z¶When using DistributedDataParallel (DDP), it is recommended to set `dataloader_drop_last=True` to avoid hanging issues with an uneven last batch. Setting `dataloader_drop_last=True`.)r$   r%   r+   Úwarmup_stepsÚloggerÚwarningÚ
isinstanceÚfloatÚsuperÚ__post_init__r   Ústrr   r   r   r   ÚjsonÚloadsÚJSONDecodeErrorr   Ú
ValueErrorr   Úprediction_loss_onlyÚddp_broadcast_buffersÚparallel_moder   ÚNOT_DISTRIBUTEDÚ
output_dirÚDISTRIBUTEDÚdataloader_drop_last)ÚselfÚ	__class__s    €r(   r4   Ú#BaseTrainingArguments.__post_init__|   só  ø€ ô Ô-Ó.´-ÀÓ2HÓHð × Ñ Ñ,°×1BÑ1BÀaÓ1GØ$(×$5Ñ$5�Ô!Ø$(�Ô!ä—‘ðtôøô ˜$×+Ñ+¬U×3Ñ3¸¸d×>OÑ>OÕ8UÐRUÖ8UÐZ^×ZkÑZkÐorÓZrØ$(×$5Ñ$5�Ô!Ø$%�Ô!ä‰ÑÔô 2<¸D×<NÑ<NÔPS×1TÑ1TŒM˜$×,Ñ,Ô-ÐZ^×ZlÑZlð 	Ôô
 ˜$×:Ñ:¼C×@Ñ@ô & d×&FÑ&FÔGà×1Ñ1ð 	Ô(ô �d—l‘l¤C×(Ñ(ðÜ#Ÿzšz¨$¯,©,Ó7�”ð DH×C]ÑC]ÑCi T×%?Ò%?ÐoqˆÔ"Ü�d×0Ñ0´#×6Ñ6ðÜ-1¯ZªZ¸×8RÑ8RÓ-S�Ô*ð 6:×5HÑ5HÑ5T˜d×1Ò1ÐZ\ˆÔÜ�d×)Ñ)¬3×/Ñ/ðÜ&*§j¢j°×1DÑ1DÓ&E�Ô#ð %)ˆÔ!ð &+ˆÔ"à×Ñ¤×!=Ñ!=Ó=ð �‰ (Ó*Ü—‘ðvõð +ð ×Ñ¤<×#;Ñ#;Ó;ÀD×D]×D]ð �‰ (Ó*Ü—‘ð;ôð )-ˆDÕ%ð E^Ð;øôU ×'Ñ'ó ò ðûô ×'Ñ'ó Ü ðNóð ðûô ×'Ñ'ó Ü ðWóð ðús*   Æ%L" Ç'%L= É%M  Ì"L:Ì9L:Ì= MÍ  N c                ó|   >• [         TU ]  5       n[        US   5      (       a  US	 [        US   5      (       a  US	 U$ )Nr   r   )r3   Úto_dictÚcallable)rA   Útraining_args_dictrB   s     €r(   rE   ÚBaseTrainingArguments.to_dictÚ   sJ   ø€ Ü"™W™_Ó.ÐÜÐ& Ñ7×8Ñ8Ø" ?Ð3ÜÐ&Ð'DÑE×FÑFØ"Ð#@ÐAØ!Ð!r'   )
r   r@   r;   r   r   r:   r   r   r+   r.   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú_VALID_DICT_FIELDSr   r   Ú__annotations__r   ÚBATCH_SAMPLERr   r   ÚPROPORTIONALr   Údictr   r   r+   r4   rE   Ú__static_attributes__Ú__classcell__)rB   s   @r(   r   r      s  ø‡ ñ'òZ	Ðñ LQØàð dð
ñL€GÐHó ñ inØ×+Ñ+°vÐ?ZÐ6[ñi€MÐeó ñ
 	Ø)×6Ñ6À&ÐJsÐAtñ	ð  ð "ó ñ
 SXØàð Pð
ñS€NÐOó ñ AFØàð Xð
ñAÐÐ=ó ñ "'Ùnàð ]ð
ñ"€L�,ó õ\-÷|"ó "r'   r   )Ú
__future__r   r6   ÚloggingÚcollections.abcr   Údataclassesr   r   Útypingr   Úpackaging.versionr   r$   Útransformersr	   ÚTransformersTrainingArgumentsr
   r%   Útransformers.training_argsr   Ú"sentence_transformers.base.samplerr   r   r   r   Ú	getLoggerrI   r/   r   r&   r'   r(   Ú<module>r`      s^   ðÝ "ã Û Ý $ß (Ý å 4Ý KÝ <Ý 3÷ó ð 
×	Ò	˜8Ó	$€ð ôG"Ð9ó G"ó ñG"r'   