CSS-LM
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
19import logging20
21from .configuration_bert import BertConfig22
23
24logger = logging.getLogger(__name__)25
26ROBERTA_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
36class RobertaConfig(BertConfig):37r"""38This is the configuration class to store the configuration of a :class:`~transformers.RobertaModel`.
39It is used to instantiate an RoBERTa model according to the specified arguments, defining the model
40architecture. Instantiating a configuration with the defaults will yield a similar configuration to that of
41the BERT `bert-base-uncased <https://huggingface.co/bert-base-uncased>`__ architecture.
42
43Configuration objects inherit from :class:`~transformers.PretrainedConfig` and can be used
44to control the model outputs. Read the documentation from :class:`~transformers.PretrainedConfig`
45for more information.
46
47The :class:`~transformers.RobertaConfig` class directly inherits :class:`~transformers.BertConfig`.
48It reuses the same defaults. Please check the parent class for more information.
49
50Example::
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"""
63model_type = "roberta"64
65def __init__(self, pad_token_id=1, bos_token_id=0, eos_token_id=2, **kwargs):66"""Constructs RobertaConfig.67"""
68super().__init__(pad_token_id=pad_token_id, bos_token_id=bos_token_id, eos_token_id=eos_token_id, **kwargs)69