o
    Zh                     @   sX   d Z ddlZddlmZ ddlmZ ddlmZmZ e	e
ZG dd	 d	eZd	gZdS )
zColPali model configuration    N)deepcopy   )PretrainedConfig   )CONFIG_MAPPING
AutoConfigc                       s<   e Zd ZdZdZeedZ			d	def fddZ	  Z
S )
ColPaliConfiga  
    Configuration class to store the configuration of a [`ColPaliForRetrieval`]. It is used to instantiate an instance
    of `ColPaliForRetrieval` according to the specified arguments, defining the model architecture following the methodology
    from the "ColPali: Efficient Document Retrieval with Vision Language Models" paper.

    Creating a configuration with the default settings will result in a configuration where the VLM backbone is set to the
    default PaliGemma configuration, i.e the one from [vidore/colpali-v1.2](https://huggingface.co/vidore/colpali-v1.2).

    The ColPali config is very similar to [`PaligemmaConfig`], but with an extra attribute defining the embedding dimension.

    Note that contrarily to what the class name suggests (actually the name refers to the ColPali **methodology**), you can
    use a different VLM backbone model than PaliGemma by passing the corresponding VLM configuration to the class constructor.

    Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
    documentation from [`PretrainedConfig`] for more information.

    Args:
        vlm_config (`PretrainedConfig`, *optional*):
            Configuration of the VLM backbone model.
        text_config (`PretrainedConfig`, *optional*):
            Configuration of the text backbone model. Overrides the `text_config` attribute of the `vlm_config` if provided.
        embedding_dim (`int`, *optional*, defaults to 128):
            Dimension of the multi-vector embeddings produced by the model.

    Example:

    ```python
    from transformers.models.colpali import ColPaliConfig, ColPaliForRetrieval

    config = ColPaliConfig()
    model = ColPaliForRetrieval(config)
    ```
    Zcolpali)
vlm_configtext_configN   embedding_dimc                    s  |d u rt d  }td n?t|tr<t|}d|vr td|d t vr0td|d  dt |d  d
i |}nt|trD|}n
t	dt
| d|| _|d urW|n|j | _}t| jtr{d|v rk|d nd	|d< t |d  d
i || _|| _t jd
i | d S )NZ	paligemmaza`vlm_config` is `None`. Initializing `vlm_config` with the `PaliGemmaConfig` with default values.
model_typez^The `model_type` key is missing in the `vlm_config` dictionary. Please provide the model type.zThe model type `z6` is not supported. Please provide a valid model type.zWInvalid type for `vlm_config`. Expected `PretrainedConfig`, `dict`, or `None`, but got .Zgemma )r   loggerinfo
isinstancedictr   KeyError
ValueErrorr   	TypeErrortyper	   r
   r   super__init__)selfr	   r
   r   kwargs	__class__r   `/var/www/auris/lib/python3.10/site-packages/transformers/models/colpali/configuration_colpali.pyr   A   s8   


zColPaliConfig.__init__)NNr   )__name__
__module____qualname____doc__r   r   r   Zsub_configsintr   __classcell__r   r   r   r   r      s    "
r   )r"   loggingcopyr   Zconfiguration_utilsr   autor   r   	getLoggerr   r   r   __all__r   r   r   r   <module>   s   

O