transformers
transformers copied to clipboard
bug: it is broken to use tokenizer path
run run_glue.py with the parameter of tokenizer_name:
--tokenizer_name=/path/bert-base-chinese-vocab.txt
but get the error:
Traceback (most recent call last):
File "run_glue.py", line 485, in <module>
main()
File "run_glue.py", line 418, in main
tokenizer = tokenizer_class.from_pretrained(args.tokenizer_name if args.tokenizer_name else args.model_name_or_path, do_lower_case=args.do_lower_case)
File "/opt/conda/lib/python3.6/site-packages/pytorch_transformers/tokenization_bert.py", line 200, in from_pretrained
return super(BertTokenizer, cls)._from_pretrained(pretrained_model_name_or_path, *inputs, **kwargs)
File "/opt/conda/lib/python3.6/site-packages/pytorch_transformers/tokenization_utils.py", line 234, in _from_pretrained
special_tokens_map = json.load(open(special_tokens_map_file, encoding="utf-8"))
File "/opt/conda/lib/python3.6/json/__init__.py", line 299, in load
parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
File "/opt/conda/lib/python3.6/json/__init__.py", line 354, in loads
return _default_decoder.decode(s)
File "/opt/conda/lib/python3.6/json/decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/opt/conda/lib/python3.6/json/decoder.py", line 357, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 2 (char 1)
i debug the variable of resolved_vocab_files, has the same value:
{'added_tokens_file': '/home/zhoushengkai/script/NLP/pytorch-transformers/pytorch_transformers/vocab_files/bert-base-chinese-vocab.txt', 'special_tokens_map_file': '/home/zhoushengkai/script/NLP/pytorch-transformers/pytorch_transformers/vocab_files/bert-base-chinese-vocab.txt', 'vocab_file': '/home/zhoushengkai/script/NLP/pytorch-transformers/pytorch_transformers/vocab_files/bert-base-chinese-vocab.txt'}
Had the same issue when passing the exact path of the vocabulary file. Fixed it by just passing the name of the directory that contains the vocabulary file (in my case it was vocab.txt).
Good catch.
For non-BPE models with a single vocabulary file (Bert, XLNet, Transformer-XL) we can fix this workflow so you can provide a direct path.
Updating this.