CSS-LM

Форк
0
/
configuration_roberta.py 
68 строк · 3.1 Кб
1
# coding=utf-8
2
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
3
# Copyright (c) 2018, NVIDIA CORPORATION.  All rights reserved.
4
#
5
# Licensed under the Apache License, Version 2.0 (the "License");
6
# you may not use this file except in compliance with the License.
7
# You may obtain a copy of the License at
8
#
9
#     http://www.apache.org/licenses/LICENSE-2.0
10
#
11
# Unless required by applicable law or agreed to in writing, software
12
# distributed under the License is distributed on an "AS IS" BASIS,
13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
# See the License for the specific language governing permissions and
15
# limitations under the License.
16
""" RoBERTa configuration """
17

18

19
import logging
20

21
from .configuration_bert import BertConfig
22

23

24
logger = logging.getLogger(__name__)
25

26
ROBERTA_PRETRAINED_CONFIG_ARCHIVE_MAP = {
27
    "roberta-base": "https://s3.amazonaws.com/models.huggingface.co/bert/roberta-base-config.json",
28
    "roberta-large": "https://s3.amazonaws.com/models.huggingface.co/bert/roberta-large-config.json",
29
    "roberta-large-mnli": "https://s3.amazonaws.com/models.huggingface.co/bert/roberta-large-mnli-config.json",
30
    "distilroberta-base": "https://s3.amazonaws.com/models.huggingface.co/bert/distilroberta-base-config.json",
31
    "roberta-base-openai-detector": "https://s3.amazonaws.com/models.huggingface.co/bert/roberta-base-openai-detector-config.json",
32
    "roberta-large-openai-detector": "https://s3.amazonaws.com/models.huggingface.co/bert/roberta-large-openai-detector-config.json",
33
}
34

35

36
class RobertaConfig(BertConfig):
37
    r"""
38
        This is the configuration class to store the configuration of a :class:`~transformers.RobertaModel`.
39
        It is used to instantiate an RoBERTa model according to the specified arguments, defining the model
40
        architecture. Instantiating a configuration with the defaults will yield a similar configuration to that of
41
        the BERT `bert-base-uncased <https://huggingface.co/bert-base-uncased>`__ architecture.
42

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

47
        The :class:`~transformers.RobertaConfig` class directly inherits :class:`~transformers.BertConfig`.
48
        It reuses the same defaults. Please check the parent class for more information.
49

50
        Example::
51

52
            >>> from transformers import RobertaConfig, RobertaModel
53

54
            >>> # Initializing a RoBERTa configuration
55
            >>> configuration = RobertaConfig()
56

57
            >>> # Initializing a model from the configuration
58
            >>> model = RobertaModel(configuration)
59

60
            >>> # Accessing the model configuration
61
            >>> configuration = model.config
62
    """
63
    model_type = "roberta"
64

65
    def __init__(self, pad_token_id=1, bos_token_id=0, eos_token_id=2, **kwargs):
66
        """Constructs RobertaConfig.
67
        """
68
        super().__init__(pad_token_id=pad_token_id, bos_token_id=bos_token_id, eos_token_id=eos_token_id, **kwargs)
69

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.