o
    -i                     @   s   U d dl mZmZmZ d dlmZ d dlmZ d dlm	Z	 d dl
mZ e	eZed ZeeZeedf ed< ed	 ZeeZeedf ed
< eeG dd dZdefddZdS )    )AnyLiteralget_args)	dataclass)config)init_logger)	safe_hash)CLSLASTMEAN.SEQ_POOLING_TYPES)ALLSTEPTOK_POOLING_TYPESc                   @   s6  e Zd ZU dZdZeeB dB ed< 	 dZedB ed< 	 dZ	edB ed< 	 dZ
edB ed< 	 dZedB ed< 	 dZedB ed< 	 dZedB ed	< 	 dZedB ed
< 	 dZedB ed< 	 dZedB ed< 	 dZedB ed< 	 dZedB ed< 	 dZee dB ed< 	 dd ZdefddZdefddZdefddZdS )PoolerConfigz:Controls the behavior of output pooling in pooling models.Npooling_typeseq_pooling_typetok_pooling_type	normalize
dimensionsenable_chunked_processingmax_embed_lensoftmax
activationuse_activation
logit_biasstep_tag_idreturned_token_idsc                 C   s   t | | _| j }r@| jd urtd| jd urtd|tv r,td|| || _d S |t	v r<td|| || _d S t
|d S )Nz5Cannot set both `pooling_type` and `seq_pooling_type`z5Cannot set both `pooling_type` and `tok_pooling_type`z4Resolved `pooling_type=%r` to `seq_pooling_type=%r`.z4Resolved `pooling_type=%r` to `tok_pooling_type=%r`.)get_use_activationr   r   r   
ValueErrorr   r   loggerdebugr   NotImplementedError)selfr    r$   O/home/ubuntu/veenaModal/venv/lib/python3.10/site-packages/vllm/config/pooler.py__post_init__l   s4   





zPoolerConfig.__post_init__returnc                 C      | j d us	J d| j S Nz!Should be resolved by ModelConfig)r   r#   r$   r$   r%   get_seq_pooling_type      z!PoolerConfig.get_seq_pooling_typec                 C   r(   r)   )r   r*   r$   r$   r%   get_tok_pooling_type   r,   z!PoolerConfig.get_tok_pooling_typec                 C   s    g }t t| dd }|S )a  
        WARNING: Whenever a new field is added to this config,
        ensure that it is included in the factors list if
        it affects the computation graph.

        Provide a hash that uniquely identifies all the configs
        that affect the structure of the computation
        graph from input ids/embeddings to the final hidden states,
        excluding anything before input ids/embeddings and after
        the final hidden states.
        F)usedforsecurity)r   strencode	hexdigest)r#   factorshash_strr$   r$   r%   compute_hash   s   zPoolerConfig.compute_hash)__name__
__module____qualname____doc__r   SequencePoolingTypeTokenPoolingType__annotations__r   r   r   boolr   intr   r   r   floatr   r   r   r   r   listr&   r+   r-   r/   r4   r$   r$   r$   r%   r      s@   
 	r   oc                 C   sr   t | dd  }d urtd |S t | dd  }d ur"td |S t | dd  }d ur3td |S t | dd S )Nr   z\`normalize` is deprecated and will be removed in v0.15. Please use `use_activation` instead.r   zZ`softmax` is deprecated and will be removed in v0.15. Please use `use_activation` instead.r   z]`activation` is deprecated and will be removed in v0.15. Please use `use_activation` instead.r   )getattrr    warning_once)r@   r   r   r   r$   r$   r%   r      s    r   N)typingr   r   r   pydantic.dataclassesr   vllm.config.utilsr   vllm.loggerr   vllm.utils.hashingr   r5   r    r9   r   tupler;   r:   r   r   objectr   r$   r$   r$   r%   <module>   s    