Ë
    ÜÓ^jH  ã                   óv   — d Z ddlmZ ddlmZ ddlmZ ddlmZ  ed¬	«      e G d
„ de«      «       «       Z	dgZ
y)zRAG model configurationé    )Ústricté   )ÚPreTrainedConfig)Úauto_docstringé   )Ú
AutoConfigÚ )Ú
checkpointc                   ó  ‡ — e Zd ZU dZdZdZdZedz  ed<   dZ	e
ed<   dZedz  ed<   dZedz  ed<   dZedz  ed	<   dZeee   z  dz  ed
<   dZedz  ed<   dZeed<   dZeed<   dZeed<   dZeed<   dZeed<   dZeed<   dZeed<   dZeed<   dZeed<   dZedz  ed<   dZedz  ed<   d Ze
ed!<   d Ze
ed"<   d#Ze ed$<   dZ!e
ed%<   d Z"e
ed&<   d Z#e
ed'<   d Z$e
ed(<   dZ%e
ed)<   dZ&edz  ed*<   ˆ fd+„Z'e(d,e)d-e)d.e)fd/„«       Z*ˆ xZ+S )0Ú	RagConfiga%  
    prefix (`str`, *optional*):
        A string prefix prepended to every input before passing to the generator model.
    title_sep (`str`, *optional*, defaults to  `" / "`):
        Separator inserted between the title and the text of the retrieved document when calling [`RagRetriever`].
    doc_sep (`str`, *optional*, defaults to  `" // "`):
        Separator inserted between the text of the retrieved document and the original input when calling
        [`RagRetriever`].
    n_docs (`int`, *optional*, defaults to 5):
        Number of documents to retrieve.
    max_combined_length (`int`, *optional*, defaults to 300):
        Max length of contextualized input returned by [`~RagRetriever.__call__`].
    retrieval_vector_size (`int`, *optional*, defaults to 768):
        Dimensionality of the document embeddings indexed by [`RagRetriever`].
    retrieval_batch_size (`int`, *optional*, defaults to 8):
        Retrieval batch size, defined as the number of queries issues concurrently to the faiss index encapsulated
        [`RagRetriever`].
    dataset (`str`, *optional*, defaults to `"wiki_dpr"`):
        A dataset identifier of the indexed dataset in HuggingFace Datasets (list all available datasets and ids
        using `datasets.list_datasets()`).
    dataset_split (`str`, *optional*, defaults to `"train"`):
        Which split of the `dataset` to load.
    index_name (`str`, *optional*, defaults to `"compressed"`):
        The index name of the index associated with the `dataset`. One can choose between `"legacy"`, `"exact"` and
        `"compressed"`.
    index_path (`str`, *optional*):
        The path to the serialized faiss index on disk.
    passages_path (`str`, *optional*):
        A path to text passages compatible with the faiss index. Required if using
        [`~models.rag.retrieval_rag.LegacyIndex`]
    use_dummy_dataset (`bool`, *optional*, defaults to `False`):
        Whether to load a "dummy" variant of the dataset specified by `dataset`.
    reduce_loss (`bool`, *optional*, defaults to `False`):
        Whether or not to reduce the NLL loss using the `torch.Tensor.sum` operation.
    label_smoothing (`float`, *optional*, defaults to 0.0):
        Only relevant if `return_loss` is set to `True`. Controls the `epsilon` parameter value for label smoothing
        in the loss calculation. If set to 0, no label smoothing is performed.
    do_deduplication (`bool`, *optional*, defaults to `True`):
        Whether or not to deduplicate the generations from different context documents for a given input. Has to be
        set to `False` if used while training with distributed backend.
    exclude_bos_score (`bool`, *optional*, defaults to `False`):
        Whether or not to disregard the BOS token when computing the loss.
    do_marginalize (`bool`, *optional*, defaults to `False`):
        If `True`, the logits are marginalized over all documents by making use of
        `torch.nn.functional.log_softmax`.
    output_retrieved (`bool`, *optional*, defaults to `False`):
        If set to `True`, `retrieved_doc_embeds`, `retrieved_doc_ids`, `context_input_ids` and
        `context_attention_mask` are returned. See returned tensors for more detail.
    dataset_revision (`str`, *optional*,):
        The revision (commit hash, tag, or branch) of the Hugging Face dataset used for retrieval.
    ÚragTNÚ
vocab_sizeÚis_encoder_decoderÚprefixÚbos_token_idÚpad_token_idÚeos_token_idÚdecoder_start_token_idz / Ú	title_sepz // Údoc_sepé   Ún_docsi,  Úmax_combined_lengthi   Úretrieval_vector_sizeé   Úretrieval_batch_sizeÚwiki_dprÚdatasetÚtrainÚdataset_splitÚ
compressedÚ
index_nameÚ
index_pathÚpassages_pathFÚuse_dummy_datasetÚreduce_lossg        Úlabel_smoothingÚdo_deduplicationÚexclude_bos_scoreÚdo_marginalizeÚoutput_retrievedÚ	use_cacheÚdataset_revisionc                 ó^  •— d|vsd|vrt        d| j                  › d|› �«      ‚|j                  d«      }|j                  d«      }|j                  d«      }|j                  d«      }t        j                  |fi |¤Ž| _        t        j                  |fi |¤Ž| _        t        ‰| �   di |¤Ž y )NÚquestion_encoderÚ	generatorzA configuration of type zt cannot be instantiated because not both `question_encoder` and `generator` sub-configurations are passed, but only Ú
model_type© )	Ú
ValueErrorr1   Úpopr   Ú	for_modelr/   r0   ÚsuperÚ__post_init__)ÚselfÚkwargsÚquestion_encoder_configÚquestion_encoder_model_typeÚdecoder_configÚdecoder_model_typeÚ	__class__s         €út/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/transformers/models/rag/configuration_rag.pyr7   zRagConfig.__post_init__m   sÀ   ø€ Ø VÑ+¨{À&Ñ/HÜØ*¨4¯?©?Ð*;ð <HØHNÀxðQóð ð
 #)§*¡*Ð-?Ó"@ÐØ&=×&AÑ&AÀ,Ó&OÐ#ØŸ™ KÓ0ˆØ+×/Ñ/°Ó=Ðä *× 4Ñ 4Ð5PÑ lÐTkÑ lˆÔÜ#×-Ñ-Ð.@ÑSÀNÑSˆŒä‰ÑÑ' Ó'ó    r:   Úgenerator_configÚreturnc                 óP   —  | d|j                  «       |j                  «       dœ|¤ŽS )a  
        Instantiate a [`EncoderDecoderConfig`] (or a derived class) from a pre-trained encoder model configuration and
        decoder model configuration.

        Returns:
            [`EncoderDecoderConfig`]: An instance of a configuration object
        )r/   r0   r2   )Úto_dict)Úclsr:   rA   r9   s       r?   Ú'from_question_encoder_generator_configsz1RagConfig.from_question_encoder_generator_configs~   s.   € ñ ÐvÐ$;×$CÑ$CÓ$EÐQa×QiÑQiÓQkÑvÐouÑvÐvr@   ),Ú__name__Ú
__module__Ú__qualname__Ú__doc__r1   Úhas_no_defaults_at_initr   ÚintÚ__annotations__r   Úboolr   Ústrr   r   r   Úlistr   r   r   r   r   r   r   r   r    r"   r#   r$   r%   r&   r'   Úfloatr(   r)   r*   r+   r,   r-   r7   Úclassmethodr   rF   Ú__classcell__)r>   s   @r?   r   r      s�  ø… ñ2ðh €JØ"Ðà!€J��d‘
Ó!Ø#Ð˜Ó#Ø€FˆC�$‰JÓØ#€L�#˜‘*Ó#Ø#€L�#˜‘*Ó#Ø+/€L�#˜˜S™	‘/ DÑ(Ó/Ø)-Ð˜C $™JÓ-Ø€IˆsÓØ€GˆSÓØ€FˆCƒOØ"Ð˜Ó"Ø!$Ð˜3Ó$Ø !Ð˜#Ó!Ø€GˆSÓØ €M�3Ó Ø"€J�Ó"Ø!€J��d‘
Ó!Ø $€M�3˜‘:Ó$Ø#Ð�tÓ#Ø€K�ÓØ €O�UÓ Ø!Ð�dÓ!Ø#Ð�tÓ#Ø €N�DÓ Ø"Ð�dÓ"Ø€IˆtÓØ#'Ð�c˜D‘jÓ'ô(ð" ð
wØ&6ð
wØJZð
wà	ò
wó ô
wr@   r   N)rJ   Úhuggingface_hub.dataclassesr   Úconfiguration_utilsr   Úutilsr   Úauto.configuration_autor   r   Ú__all__r2   r@   r?   ú<module>rY      sO   ðñ å .å 3Ý #Ý 0ñ ˜2ÔØôpwÐ ó pwó ó ðpwðf ˆ-�r@   