ó
    >:j"  ã                  óZ   • S SK Jr  S SKrS SKJrJr  \(       a  S SKJr   " S S5      r\r	g)é    )ÚannotationsN)ÚTYPE_CHECKINGÚAny)Ú	BaseModelc                  óŠ   • \ rS rSrSrS r S         SS jjrSS jr S         SS jjr\	SS j5       r
SS	 jrS
rg)ÚBaseEvaluatoré
   a   
Base class for all evaluators. Notably, this class introduces the ``greater_is_better`` and ``primary_metric``
attributes. The former is a boolean indicating whether a higher evaluation score is better, which is used
for choosing the best checkpoint if ``load_best_model_at_end`` is set to ``True`` in the training arguments.

The latter is a string indicating the primary metric for the evaluator. This has to be defined whenever
the evaluator returns a dictionary of metrics, and the primary metric is the key pointing to the primary
metric, i.e. the one that is used for model selection and/or logging.

Extend this class and implement __call__ for custom evaluators.
c                ó    • SU l         S U l        g )NT©Úgreater_is_betterÚprimary_metric©Úselfs    Úl/home/mande/repo/quber/.venv/lib/python3.13/site-packages/sentence_transformers/base/evaluation/evaluator.pyÚ__init__ÚBaseEvaluator.__init__   s   € Ø!%ˆÔØ"ˆÕó    Nc                ó   • [         e)a  
This is called during training to evaluate the model.
It returns a score for the evaluation with a higher score indicating a better result.

Args:
    model: the model to evaluate
    output_path: path where predictions and metrics are written to
    epoch: the epoch where the evaluation takes place. This is used for the file prefixes. If this is -1,
        then we assume evaluation on test data.
    steps: the steps in the current epoch at time of the evaluation. This is used for the file prefixes.
        If this is -1, then we assume evaluation at the end of the epoch.

Returns:
    Either a score for the evaluation with a higher score indicating a better result, or a dictionary with
    scores. If the latter is chosen, then `evaluator.primary_metric` must be defined
)ÚNotImplementedError)r   ÚmodelÚoutput_pathÚepochÚstepss        r   Ú__call__ÚBaseEvaluator.__call__   s
   € ô& "Ð!r   c                óž  • SS jnU(       d+  UR                  5        VVs0 s H  u  pEXC" U5      _M     snn$ UR                  5        VVs0 s H  u  pEUS-   U-   U" U5      _M     nnn[        U S5      (       aG  U R                  b:  U R                  R                  US-   5      (       d  US-   U R                  -   U l        U$ s  snnf s  snnf )Nc                ó>   •  [        U 5      $ ! [         a    U s $ f = f©N)ÚfloatÚ
ValueError)Úvalues    r   Úmaybe_to_floatÚ<BaseEvaluator.prefix_name_to_metrics.<locals>.maybe_to_float1   s%   € ðÜ˜U“|Ð#øÜó Ø’ðús   ‚
 �›Ú_r   )r!   r   Úreturnr   )ÚitemsÚhasattrr   Ú
startswith)r   ÚmetricsÚnamer"   Úkeyr!   s         r   Úprefix_name_to_metricsÚ$BaseEvaluator.prefix_name_to_metrics0   s¼   € ô	ö ØAHÇÁÄÔQÂ±:°3�C˜¨Ó.Ò.ÁÒQÐQØMTÏ]É]Ì_Ô]Ê_¹z¸s�4˜#‘: Ñ#¡^°EÓ%:Ò:É_ˆÑ]ä�DÐ*×+Ñ+Ø×#Ñ#Ñ/Ø×'Ñ'×2Ñ2°4¸#±:×>Ñ>à"&¨¡*¨t×/BÑ/BÑ"BˆDÔØˆùó RùÛ]s    CÁC	c                ó<   • UR                   R                  XX45        g r   )Úmodel_card_dataÚset_evaluation_metrics)r   r   r)   r   Ústeps        r   Ú store_metrics_in_model_card_dataÚ.BaseEvaluator.store_metrics_in_model_card_dataB   s   € ð 	×Ñ×4Ñ4°TÀEÕPr   c                óè   • U R                   R                  nUR                  S5      (       a  SUSS -   n UR                  S5      nUSU n[
        R                  " SSU5      $ ! [         a     N$f = f)zð
Returns a human-readable description of the evaluator: BinaryClassificationEvaluator -> Binary Classification

1. Replace "CE" prefix with "CrossEncoder"
2. Remove "Evaluator" from the class name
3. Add a space before every capital letter
ÚCEÚCrossEncoderé   NÚ	Evaluatorz([a-z])([A-Z])z\g<1> \g<2>)Ú	__class__Ú__name__r(   Úindexr    ÚreÚsub)r   Ú
class_namer;   s      r   ÚdescriptionÚBaseEvaluator.descriptionG   s   € ð —^‘^×,Ñ,ˆ
à× Ñ  ×&Ñ&Ø'¨*°Q°R¨.Ñ8ˆJð	Ø×$Ñ$ [Ó1ˆEØ# F UÐ+ˆJô �vŠvÐ'¨¸ÓDÐDøô ó 	Ùð	ús   ¶A$ Á$
A1Á0A1c                ó   • 0 $ )zk
Return a dictionary with all meaningful configuration values of the evaluator to store in the model card.
© r   s    r   Úget_config_dictÚBaseEvaluator.get_config_dict]   s	   € ð ˆ	r   r   )NéÿÿÿÿrE   )
r   r   r   z
str | Noner   Úintr   rF   r%   zfloat | dict[str, float])r)   údict[str, float]r*   Ústrr%   rG   )r   r   )
r   r   r)   údict[str, Any]r   rF   r1   rF   r%   ÚNone)r%   rH   )r%   rI   )r:   Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r   r,   r2   Úpropertyr?   rC   Ú__static_attributes__rB   r   r   r   r   
   sš   † ñ
ò#ð
 _að"Øð"Ø-7ð"ØGJð"ØX[ð"à	!õ"ô*ð& VWðQØðQØ)7ðQØ@CðQØORðQà	õQð
 óEó ðE÷*r   r   )
Ú
__future__r   r<   Útypingr   r   Ú sentence_transformers.base.modelr   r   ÚSentenceEvaluatorrB   r   r   Ú<module>rU      s)   ðÝ "ã 	ß %æÝ:÷Wñ Wðv "Ñ r   