Commit f8823bad authored by Julien Chaumond's avatar Julien Chaumond
Browse files

Expose missing mappings (see #3415)

parent d0c36a7b
...@@ -38,7 +38,6 @@ from torch.utils.data.distributed import DistributedSampler ...@@ -38,7 +38,6 @@ from torch.utils.data.distributed import DistributedSampler
from tqdm import tqdm, trange from tqdm import tqdm, trange
from transformers import ( from transformers import (
CONFIG_MAPPING,
MODEL_WITH_LM_HEAD_MAPPING, MODEL_WITH_LM_HEAD_MAPPING,
WEIGHTS_NAME, WEIGHTS_NAME,
AdamW, AdamW,
...@@ -679,7 +678,12 @@ def main(): ...@@ -679,7 +678,12 @@ def main():
elif args.model_name_or_path: elif args.model_name_or_path:
config = AutoConfig.from_pretrained(args.model_name_or_path, cache_dir=args.cache_dir) config = AutoConfig.from_pretrained(args.model_name_or_path, cache_dir=args.cache_dir)
else: else:
config = CONFIG_MAPPING[args.model_type]() # When we release a pip version exposing CONFIG_MAPPING,
# we can do `config = CONFIG_MAPPING[args.model_type]()`.
raise ValueError(
"You are instantiating a new config instance from scratch. This is not supported, but you can do it from another script, save it,"
"and load it from here, using --config_name"
)
if args.tokenizer_name: if args.tokenizer_name:
tokenizer = AutoTokenizer.from_pretrained(args.tokenizer_name, cache_dir=args.cache_dir) tokenizer = AutoTokenizer.from_pretrained(args.tokenizer_name, cache_dir=args.cache_dir)
...@@ -687,8 +691,8 @@ def main(): ...@@ -687,8 +691,8 @@ def main():
tokenizer = AutoTokenizer.from_pretrained(args.model_name_or_path, cache_dir=args.cache_dir) tokenizer = AutoTokenizer.from_pretrained(args.model_name_or_path, cache_dir=args.cache_dir)
else: else:
raise ValueError( raise ValueError(
"You are instantiating a new {} tokenizer. This is not supported, but you can do it from another script, save it," "You are instantiating a new tokenizer from scratch. This is not supported, but you can do it from another script, save it,"
"and load it from here, using --tokenizer_name".format(AutoTokenizer.__name__) "and load it from here, using --tokenizer_name"
) )
if args.block_size <= 0: if args.block_size <= 0:
......
...@@ -32,7 +32,7 @@ from .benchmark_utils import ( ...@@ -32,7 +32,7 @@ from .benchmark_utils import (
stop_memory_tracing, stop_memory_tracing,
) )
from .configuration_albert import ALBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, AlbertConfig from .configuration_albert import ALBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, AlbertConfig
from .configuration_auto import ALL_PRETRAINED_CONFIG_ARCHIVE_MAP, AutoConfig from .configuration_auto import ALL_PRETRAINED_CONFIG_ARCHIVE_MAP, CONFIG_MAPPING, AutoConfig
from .configuration_bart import BartConfig from .configuration_bart import BartConfig
from .configuration_bert import BERT_PRETRAINED_CONFIG_ARCHIVE_MAP, BertConfig from .configuration_bert import BERT_PRETRAINED_CONFIG_ARCHIVE_MAP, BertConfig
from .configuration_camembert import CAMEMBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, CamembertConfig from .configuration_camembert import CAMEMBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, CamembertConfig
...@@ -119,7 +119,7 @@ from .pipelines import ( ...@@ -119,7 +119,7 @@ from .pipelines import (
pipeline, pipeline,
) )
from .tokenization_albert import AlbertTokenizer from .tokenization_albert import AlbertTokenizer
from .tokenization_auto import AutoTokenizer from .tokenization_auto import TOKENIZER_MAPPING, AutoTokenizer
from .tokenization_bart import BartTokenizer from .tokenization_bart import BartTokenizer
from .tokenization_bert import BasicTokenizer, BertTokenizer, BertTokenizerFast, WordpieceTokenizer from .tokenization_bert import BasicTokenizer, BertTokenizer, BertTokenizerFast, WordpieceTokenizer
from .tokenization_bert_japanese import BertJapaneseTokenizer, CharacterTokenizer, MecabTokenizer from .tokenization_bert_japanese import BertJapaneseTokenizer, CharacterTokenizer, MecabTokenizer
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment