U
    &c2                     @   sP   d Z ddlZddlmZ eeZddddd	d
ddddd
ZG dd deZdS )z XLM configuration     N   )PretrainedConfigzOhttps://s3.amazonaws.com/models.huggingface.co/bert/xlm-mlm-en-2048-config.jsonzQhttps://s3.amazonaws.com/models.huggingface.co/bert/xlm-mlm-ende-1024-config.jsonzQhttps://s3.amazonaws.com/models.huggingface.co/bert/xlm-mlm-enfr-1024-config.jsonzQhttps://s3.amazonaws.com/models.huggingface.co/bert/xlm-mlm-enro-1024-config.jsonzWhttps://s3.amazonaws.com/models.huggingface.co/bert/xlm-mlm-tlm-xnli15-1024-config.jsonzShttps://s3.amazonaws.com/models.huggingface.co/bert/xlm-mlm-xnli15-1024-config.jsonzQhttps://s3.amazonaws.com/models.huggingface.co/bert/xlm-clm-enfr-1024-config.jsonzQhttps://s3.amazonaws.com/models.huggingface.co/bert/xlm-clm-ende-1024-config.jsonzOhttps://s3.amazonaws.com/models.huggingface.co/bert/xlm-mlm-17-1280-config.jsonzPhttps://s3.amazonaws.com/models.huggingface.co/bert/xlm-mlm-100-1280-config.json)
zxlm-mlm-en-2048zxlm-mlm-ende-1024zxlm-mlm-enfr-1024zxlm-mlm-enro-1024zxlm-mlm-tlm-xnli15-1024zxlm-mlm-xnli15-1024zxlm-clm-enfr-1024zxlm-clm-ende-1024zxlm-mlm-17-1280zxlm-mlm-100-1280c                !       sh   e Zd ZdZeZdZd  fdd	Zedd Z	e	j
dd Z	edd Zedd Zedd Z  ZS )!	XLMConfigay  
        This is the configuration class to store the configuration of a :class:`~transformers.XLMModel`.
        It is used to instantiate an XLM 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 `xlm-mlm-en-2048 <https://huggingface.co/xlm-mlm-en-2048>`__ architecture.

        Configuration objects inherit from  :class:`~transformers.PretrainedConfig` and can be used
        to control the model outputs. Read the documentation from  :class:`~transformers.PretrainedConfig`
        for more information.

        Args:
            vocab_size (:obj:`int`, optional, defaults to 30145):
                Vocabulary size of the XLM model. Defines the different tokens that
                can be represented by the `inputs_ids` passed to the forward method of :class:`~transformers.XLMModel`.
            emb_dim (:obj:`int`, optional, defaults to 2048):
                Dimensionality of the encoder layers and the pooler layer.
            n_layer (:obj:`int`, optional, defaults to 12):
                Number of hidden layers in the Transformer encoder.
            n_head (:obj:`int`, optional, defaults to 16):
                Number of attention heads for each attention layer in the Transformer encoder.
            dropout (:obj:`float`, optional, defaults to 0.1):
                The dropout probability for all fully connected
                layers in the embeddings, encoder, and pooler.
            attention_dropout (:obj:`float`, optional, defaults to 0.1):
                The dropout probability for the attention mechanism
            gelu_activation (:obj:`boolean`, optional, defaults to :obj:`True`):
                The non-linear activation function (function or string) in the
                encoder and pooler. If set to `True`, "gelu" will be used instead of "relu".
            sinusoidal_embeddings (:obj:`boolean`, optional, defaults to :obj:`False`):
                Whether to use sinusoidal positional embeddings instead of absolute positional embeddings.
            causal (:obj:`boolean`, optional, defaults to :obj:`False`):
                Set this to `True` for the model to behave in a causal manner.
                Causal models use a triangular attention mask in order to only attend to the left-side context instead
                if a bidirectional context.
            asm (:obj:`boolean`, optional, defaults to :obj:`False`):
                Whether to use an adaptive log softmax projection layer instead of a linear layer for the prediction
                layer.
            n_langs (:obj:`int`, optional, defaults to 1):
                The number of languages the model handles. Set to 1 for monolingual models.
            use_lang_emb (:obj:`boolean`, optional, defaults to :obj:`True`)
                Whether to use language embeddings. Some models use additional language embeddings, see
                `the multilingual models page <http://huggingface.co/transformers/multilingual.html#xlm-language-embeddings>`__
                for information on how to use them.
            max_position_embeddings (:obj:`int`, optional, defaults to 512):
                The maximum sequence length that this model might
                ever be used with. Typically set this to something large just in case
                (e.g., 512 or 1024 or 2048).
            embed_init_std (:obj:`float`, optional, defaults to 2048^-0.5):
                The standard deviation of the truncated_normal_initializer for
                initializing the embedding matrices.
            init_std (:obj:`int`, optional, defaults to 50257):
                The standard deviation of the truncated_normal_initializer for
                initializing all weight matrices except the embedding matrices.
            layer_norm_eps (:obj:`float`, optional, defaults to 1e-12):
                The epsilon used by the layer normalization layers.
            bos_index (:obj:`int`, optional, defaults to 0):
                The index of the beginning of sentence token in the vocabulary.
            eos_index (:obj:`int`, optional, defaults to 1):
                The index of the end of sentence token in the vocabulary.
            pad_index (:obj:`int`, optional, defaults to 2):
                The index of the padding token in the vocabulary.
            unk_index (:obj:`int`, optional, defaults to 3):
                The index of the unknown token in the vocabulary.
            mask_index (:obj:`int`, optional, defaults to 5):
                The index of the masking token in the vocabulary.
            is_encoder(:obj:`boolean`, optional, defaults to :obj:`True`):
                Whether the initialized model should be a transformer encoder or decoder as seen in Vaswani et al.
            summary_type (:obj:`string`, optional, defaults to "first"):
                Argument used when doing sequence summary. Used in for the multiple choice head in
                :class:`~transformers.XLMForSequenceClassification`.
                Is one of the following options:

                - 'last' => take the last token hidden state (like XLNet)
                - 'first' => take the first token hidden state (like Bert)
                - 'mean' => take the mean of all tokens hidden states
                - 'cls_index' => supply a Tensor of classification token position (GPT/GPT-2)
                - 'attn' => Not implemented now, use multi-head attention
            summary_use_proj (:obj:`boolean`, optional, defaults to :obj:`True`):
                Argument used when doing sequence summary. Used in for the multiple choice head in
                :class:`~transformers.XLMForSequenceClassification`.
                Add a projection after the vector extraction
            summary_activation (:obj:`string` or :obj:`None`, optional, defaults to :obj:`None`):
                Argument used when doing sequence summary. Used in for the multiple choice head in
                :class:`~transformers.XLMForSequenceClassification`.
                'tanh' => add a tanh activation to the output, Other => no activation.
            summary_proj_to_labels (:obj:`boolean`, optional, defaults to :obj:`True`):
                Argument used when doing sequence summary. Used in for the multiple choice head in
                :class:`~transformers.XLMForSequenceClassification`.
                If True, the projection outputs to config.num_labels classes (otherwise to hidden_size). Default: False.
            summary_first_dropout (:obj:`float`, optional, defaults to 0.1):
                Argument used when doing sequence summary. Used in for the multiple choice head in
                :class:`~transformers.XLMForSequenceClassification`.
                Add a dropout before the projection and activation
            start_n_top (:obj:`int`, optional, defaults to 5):
                Used in the SQuAD evaluation script for XLM and XLNet.
            end_n_top (:obj:`int`, optional, defaults to 5):
                Used in the SQuAD evaluation script for XLM and XLNet.
            mask_token_id (:obj:`int`, optional, defaults to 0):
                Model agnostic parameter to identify masked tokens when generating text in an MLM context.
            lang_id (:obj:`int`, optional, defaults to 1):
                The ID of the language used by the model. This parameter is used when generating
                text in a given language.

        Example::

            from transformers import XLMConfig, XLMModel

            # Initializing a XLM configuration
            configuration = XLMConfig()

            # Initializing a model from the configuration
            model = XLMModel(configuration)

            # Accessing the model configuration
            configuration = model.config

        Attributes:
            pretrained_config_archive_map (Dict[str, str]):
                A dictionary containing all the available pre-trained checkpoints.
    Zxlmu           皙?TFr      ;f?-q={Gz?r            firstNc"           #         s   t  jf | |!d|" || _|| _|| _|| _|| _|| _|| _|| _	|	| _
|
| _|| _|| _|| _|| _|| _|| _|| _|| _|| _|| _|| _|| _|| _|| _|| _|| _|| _|| _|| _|| _|| _ d|"kr|"d | _!dS )zConstructs XLMConfig.
        )pad_token_idbos_token_idn_wordsN)"super__init__
vocab_sizeemb_dimn_layersn_headsdropoutattention_dropoutgelu_activationsinusoidal_embeddingscausalasmn_langsuse_lang_emblayer_norm_eps	bos_index	eos_index	pad_index	unk_index
mask_index
is_encodermax_position_embeddingsembed_init_stdinit_stdsummary_typesummary_use_projsummary_activationsummary_proj_to_labelssummary_first_dropoutstart_n_top	end_n_topmask_token_idlang_idr   )#selfr   r   r   r   r   r   r   r   r   r    r!   r"   r*   r+   r#   r,   r$   r%   r&   r'   r(   r)   r-   r.   r/   r0   r1   r2   r3   r4   r5   r   r   kwargs	__class__ B/tmp/pip-unpacked-wheel-ymerj3tt/transformers/configuration_xlm.pyr      sD    'zXLMConfig.__init__c                 C   s   | j S Nr   r6   r:   r:   r;   r      s    zXLMConfig.n_wordsc                 C   s
   || _ d S r<   r=   )r6   valuer:   r:   r;   r      s    c                 C   s   | j S r<   )r   r>   r:   r:   r;   hidden_size   s    zXLMConfig.hidden_sizec                 C   s   | j S r<   )r   r>   r:   r:   r;   num_attention_heads   s    zXLMConfig.num_attention_headsc                 C   s   | j S r<   )r   r>   r:   r:   r;   num_hidden_layers   s    zXLMConfig.num_hidden_layers)!r   r   r   r   r	   r	   TFFFr   Tr
   r   r   r   r   r   r   r   r   Tr   TNTr	   r   r   r   r   r   r   )__name__
__module____qualname____doc__!XLM_PRETRAINED_CONFIG_ARCHIVE_MAPZpretrained_config_archive_mapZ
model_typer   propertyr   setterr@   rA   rB   __classcell__r:   r:   r8   r;   r   '   s^   y                                 K



r   )	rF   loggingZconfiguration_utilsr   	getLoggerrC   loggerrG   r   r:   r:   r:   r;   <module>   s   
