Add CamemBERT to auto files and docs
This commit is contained in:
committed by
Julien Chaumond
parent
694d4fcbb6
commit
035fea5315
@@ -155,5 +155,9 @@ Here is the full list of the currently provided pretrained models together with
|
|||||||
| CTRL | ``ctrl`` | | 48-layer, 1280-hidden, 16-heads, 1.6B parameters |
|
| CTRL | ``ctrl`` | | 48-layer, 1280-hidden, 16-heads, 1.6B parameters |
|
||||||
| | | | Salesforce's Large-sized CTRL English model |
|
| | | | Salesforce's Large-sized CTRL English model |
|
||||||
+-------------------+------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------+
|
+-------------------+------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------+
|
||||||
|
| CamemBERT | ``camembert-base`` | | 12-layer, 768-hidden, 12-heads, 110M parameters |
|
||||||
|
| | | | CamemBERT using the BERT-base architecture |
|
||||||
|
| | | (see `details <https://github.com/pytorch/fairseq/tree/master/examples/camembert>`__) |
|
||||||
|
+-------------------+------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------+
|
||||||
|
|
||||||
.. <https://huggingface.co/transformers/examples.html>`__
|
.. <https://huggingface.co/transformers/examples.html>`__
|
||||||
@@ -27,6 +27,7 @@ from .configuration_xlm import XLMConfig
|
|||||||
from .configuration_roberta import RobertaConfig
|
from .configuration_roberta import RobertaConfig
|
||||||
from .configuration_distilbert import DistilBertConfig
|
from .configuration_distilbert import DistilBertConfig
|
||||||
from .configuration_ctrl import CTRLConfig
|
from .configuration_ctrl import CTRLConfig
|
||||||
|
from .configuration_camembert import CamembertConfig
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -50,6 +51,7 @@ class AutoConfig(object):
|
|||||||
- contains `xlnet`: XLNetConfig (XLNet model)
|
- contains `xlnet`: XLNetConfig (XLNet model)
|
||||||
- contains `xlm`: XLMConfig (XLM model)
|
- contains `xlm`: XLMConfig (XLM model)
|
||||||
- contains `roberta`: RobertaConfig (RoBERTa model)
|
- contains `roberta`: RobertaConfig (RoBERTa model)
|
||||||
|
- contains `camembert`: CamembertConfig (CamemBERT model)
|
||||||
- contains `ctrl` : CTRLConfig (CTRL model)
|
- contains `ctrl` : CTRLConfig (CTRL model)
|
||||||
This class cannot be instantiated using `__init__()` (throw an error).
|
This class cannot be instantiated using `__init__()` (throw an error).
|
||||||
"""
|
"""
|
||||||
@@ -72,6 +74,7 @@ class AutoConfig(object):
|
|||||||
- contains `xlnet`: XLNetConfig (XLNet model)
|
- contains `xlnet`: XLNetConfig (XLNet model)
|
||||||
- contains `xlm`: XLMConfig (XLM model)
|
- contains `xlm`: XLMConfig (XLM model)
|
||||||
- contains `roberta`: RobertaConfig (RoBERTa model)
|
- contains `roberta`: RobertaConfig (RoBERTa model)
|
||||||
|
- contains `camembert`: CamembertConfig (CamemBERT model)
|
||||||
- contains `ctrl` : CTRLConfig (CTRL model)
|
- contains `ctrl` : CTRLConfig (CTRL model)
|
||||||
Params:
|
Params:
|
||||||
pretrained_model_name_or_path: either:
|
pretrained_model_name_or_path: either:
|
||||||
@@ -116,6 +119,8 @@ class AutoConfig(object):
|
|||||||
"""
|
"""
|
||||||
if 'distilbert' in pretrained_model_name_or_path:
|
if 'distilbert' in pretrained_model_name_or_path:
|
||||||
return DistilBertConfig.from_pretrained(pretrained_model_name_or_path, **kwargs)
|
return DistilBertConfig.from_pretrained(pretrained_model_name_or_path, **kwargs)
|
||||||
|
elif 'camembert' in pretrained_model_name_or_path:
|
||||||
|
return CamembertConfig.from_pretrained(pretrained_model_name_or_path, **kwargs)
|
||||||
elif 'roberta' in pretrained_model_name_or_path:
|
elif 'roberta' in pretrained_model_name_or_path:
|
||||||
return RobertaConfig.from_pretrained(pretrained_model_name_or_path, **kwargs)
|
return RobertaConfig.from_pretrained(pretrained_model_name_or_path, **kwargs)
|
||||||
elif 'bert' in pretrained_model_name_or_path:
|
elif 'bert' in pretrained_model_name_or_path:
|
||||||
@@ -134,4 +139,4 @@ class AutoConfig(object):
|
|||||||
return CTRLConfig.from_pretrained(pretrained_model_name_or_path, **kwargs)
|
return CTRLConfig.from_pretrained(pretrained_model_name_or_path, **kwargs)
|
||||||
raise ValueError("Unrecognized model identifier in {}. Should contains one of "
|
raise ValueError("Unrecognized model identifier in {}. Should contains one of "
|
||||||
"'bert', 'openai-gpt', 'gpt2', 'transfo-xl', 'xlnet', "
|
"'bert', 'openai-gpt', 'gpt2', 'transfo-xl', 'xlnet', "
|
||||||
"'xlm', 'roberta', 'ctrl'".format(pretrained_model_name_or_path))
|
"'xlm', 'roberta', 'camembert', 'ctrl'".format(pretrained_model_name_or_path))
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ from .tokenization_xlnet import XLNetTokenizer
|
|||||||
from .tokenization_xlm import XLMTokenizer
|
from .tokenization_xlm import XLMTokenizer
|
||||||
from .tokenization_roberta import RobertaTokenizer
|
from .tokenization_roberta import RobertaTokenizer
|
||||||
from .tokenization_distilbert import DistilBertTokenizer
|
from .tokenization_distilbert import DistilBertTokenizer
|
||||||
|
from .tokenization_camembert import CamembertTokenizer
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -41,6 +42,7 @@ class AutoTokenizer(object):
|
|||||||
|
|
||||||
The tokenizer class to instantiate is selected as the first pattern matching
|
The tokenizer class to instantiate is selected as the first pattern matching
|
||||||
in the `pretrained_model_name_or_path` string (in the following order):
|
in the `pretrained_model_name_or_path` string (in the following order):
|
||||||
|
- contains `camembert`: CamembertTokenizer (CamemBERT model)
|
||||||
- contains `distilbert`: DistilBertTokenizer (DistilBert model)
|
- contains `distilbert`: DistilBertTokenizer (DistilBert model)
|
||||||
- contains `roberta`: RobertaTokenizer (RoBERTa model)
|
- contains `roberta`: RobertaTokenizer (RoBERTa model)
|
||||||
- contains `bert`: BertTokenizer (Bert model)
|
- contains `bert`: BertTokenizer (Bert model)
|
||||||
@@ -64,8 +66,9 @@ class AutoTokenizer(object):
|
|||||||
|
|
||||||
The tokenizer class to instantiate is selected as the first pattern matching
|
The tokenizer class to instantiate is selected as the first pattern matching
|
||||||
in the `pretrained_model_name_or_path` string (in the following order):
|
in the `pretrained_model_name_or_path` string (in the following order):
|
||||||
|
- contains `camembert`: CamembertTokenizer (CamemBERT model)
|
||||||
- contains `distilbert`: DistilBertTokenizer (DistilBert model)
|
- contains `distilbert`: DistilBertTokenizer (DistilBert model)
|
||||||
- contains `roberta`: RobertaTokenizer (XLM model)
|
- contains `roberta`: RobertaTokenizer (RoBERTa model)
|
||||||
- contains `bert`: BertTokenizer (Bert model)
|
- contains `bert`: BertTokenizer (Bert model)
|
||||||
- contains `openai-gpt`: OpenAIGPTTokenizer (OpenAI GPT model)
|
- contains `openai-gpt`: OpenAIGPTTokenizer (OpenAI GPT model)
|
||||||
- contains `gpt2`: GPT2Tokenizer (OpenAI GPT-2 model)
|
- contains `gpt2`: GPT2Tokenizer (OpenAI GPT-2 model)
|
||||||
@@ -103,6 +106,8 @@ class AutoTokenizer(object):
|
|||||||
"""
|
"""
|
||||||
if 'distilbert' in pretrained_model_name_or_path:
|
if 'distilbert' in pretrained_model_name_or_path:
|
||||||
return DistilBertTokenizer.from_pretrained(pretrained_model_name_or_path, *inputs, **kwargs)
|
return DistilBertTokenizer.from_pretrained(pretrained_model_name_or_path, *inputs, **kwargs)
|
||||||
|
elif 'camembert' in pretrained_model_name_or_path:
|
||||||
|
return CamembertTokenizer.from_pretrained(pretrained_model_name_or_path, *inputs, **kwargs)
|
||||||
elif 'roberta' in pretrained_model_name_or_path:
|
elif 'roberta' in pretrained_model_name_or_path:
|
||||||
return RobertaTokenizer.from_pretrained(pretrained_model_name_or_path, *inputs, **kwargs)
|
return RobertaTokenizer.from_pretrained(pretrained_model_name_or_path, *inputs, **kwargs)
|
||||||
elif 'bert' in pretrained_model_name_or_path:
|
elif 'bert' in pretrained_model_name_or_path:
|
||||||
@@ -121,4 +126,4 @@ class AutoTokenizer(object):
|
|||||||
return CTRLTokenizer.from_pretrained(pretrained_model_name_or_path, *inputs, **kwargs)
|
return CTRLTokenizer.from_pretrained(pretrained_model_name_or_path, *inputs, **kwargs)
|
||||||
raise ValueError("Unrecognized model identifier in {}. Should contains one of "
|
raise ValueError("Unrecognized model identifier in {}. Should contains one of "
|
||||||
"'bert', 'openai-gpt', 'gpt2', 'transfo-xl', 'xlnet', "
|
"'bert', 'openai-gpt', 'gpt2', 'transfo-xl', 'xlnet', "
|
||||||
"'xlm', 'roberta', 'ctrl'".format(pretrained_model_name_or_path))
|
"'xlm', 'roberta', 'camembert', 'ctrl'".format(pretrained_model_name_or_path))
|
||||||
|
|||||||
Reference in New Issue
Block a user