
    sg                     j    d Z ddlmZ ddlmZ ddlmZmZ  ej                  e	      Z
 G d de      Zy)	zLlava model configuration   )PretrainedConfig)logging   )CONFIG_MAPPING
AutoConfigc                   B     e Zd ZdZdZeedZ	 	 	 	 	 	 	 	 d fd	Z xZS )LlavaConfiga	  
    This is the configuration class to store the configuration of a [`LlavaForConditionalGeneration`]. It is used to instantiate an
    Llava model according to the specified arguments, defining the model architecture. Instantiating a configuration
    with the defaults will yield a similar configuration to that of the Llava-9B.

    e.g. [llava-hf/llava-9b](https://huggingface.co/llava-hf/llava-9b)

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

    Args:
        vision_config (`Union[AutoConfig, dict]`,  *optional*, defaults to `CLIPVisionConfig`):
            The config object or dictionary of the vision backbone.
        text_config (`Union[AutoConfig, dict]`, *optional*, defaults to `LlamaConfig`):
            The config object or dictionary of the text backbone.
        ignore_index (`int`, *optional*, defaults to -100):
            The ignore index for the loss function.
        image_token_index (`int`, *optional*, defaults to 32000):
            The image token index to encode the image prompt.
        projector_hidden_act (`str`, *optional*, defaults to `"gelu"`):
            The activation function used by the multimodal projector.
        vision_feature_select_strategy (`str`, *optional*, defaults to `"default"`):
            The feature selection strategy used to select the vision feature from the vision backbone.
            Can be one of `"default"` or `"full"`.
        vision_feature_layer (`int`, *optional*, defaults to -2):
            The index of the layer to select the vision feature.
        image_seq_length (`int`, *optional*, defaults to 576):
            Sequence length of one image embedding.

    Example:

    ```python
    >>> from transformers import LlavaForConditionalGeneration, LlavaConfig, CLIPVisionConfig, LlamaConfig

    >>> # Initializing a CLIP-vision config
    >>> vision_config = CLIPVisionConfig()

    >>> # Initializing a Llama config
    >>> text_config = LlamaConfig()

    >>> # Initializing a Llava llava-1.5-7b style configuration
    >>> configuration = LlavaConfig(vision_config, text_config)

    >>> # Initializing a model from the llava-1.5-7b style configuration
    >>> model = LlavaForConditionalGeneration(configuration)

    >>> # Accessing the model configuration
    >>> configuration = model.config
    ```llava)text_configvision_configc	           
         || _         || _        || _        || _        |dvrt	        d|       || _        || _        t        |t              r d|v r|d   nd|d<   t        |d      di |}n|t        d   ddddd	d
dd      }|| _
        t        |t              r d|v r|d   nd|d<   t        |d      di |}n|t        d          }|| _        t        
| 4  di |	 y )N)defaultfullzGvision_feature_select_strategy should be one of 'default', 'full'.Got: 
model_typeclip_vision_modeli   i      iP         }  i   )intermediate_sizehidden_size
patch_size
image_sizenum_hidden_layersnum_attention_heads
vocab_sizeprojection_dimllama )ignore_indeximage_token_indexprojector_hidden_actimage_seq_length
ValueErrorvision_feature_select_strategyvision_feature_layer
isinstancedictr   r   r   super__init__)selfr   r   r    r!   r"   r%   r&   r#   kwargs	__class__s             `/var/www/html/venv/lib/python3.12/site-packages/transformers/models/llava/configuration_llava.pyr*   zLlavaConfig.__init__N   s;    )!2$8! 0)1DD679 
 /M+$8!mT*/;}/Ll+Re ,' +=+FGX-XM"*+>?"& "$$& "	M +k4(EQU`E`L(AfmK%(\)BCRkRK (13K&"6"    )NNir   gelur   i@  )	__name__
__module____qualname____doc__r   r   sub_configsr*   __classcell__)r-   s   @r.   r	   r	      s>    0d J",zJK #'05# 5#r/   r	   N)r5   configuration_utilsr   utilsr   autor   r   
get_loggerr2   loggerr	   r   r/   r.   <module>r=      s6      3  - 
		H	%k#" k#r/   