(pad_on_left and) ids_tensor error(s) in Dynamic Quantization on BERT tutorial
Open
@Srujana2505 is already working on this.
Since Jun 1, 2023.
medium
module: quantization
- Dominant language
- Python
- Stars
- 9.3k
- Forks
- 4.4k
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 4
Description
Tutorial link: https://github.com/pytorch/tutorials/blob/master/intermediate_source/dynamic_quantization_bert_tutorial.rst
Version 1.8.0
Using either the Colab version or following the tutorial text locally, it fails in section 3.2:
# Evaluate the original FP32 BERT model
time_model_evaluation(model, configs, tokenizer)
Output from colab version:
/usr/local/lib/python3.7/dist-packages/transformers/data/processors/glue.py:175: FutureWarning: This processor will be removed from the library soon, preprocessing should be handled with the 🤗 Datasets library. You can have a look at this example script for pointers: https://github.com/huggingface/transformers/blob/master/examples/text-classification/run_glue.py
warnings.warn(DEPRECATION_WARNING.format("processor"), FutureWarning)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-14-7f3f2ffdfbf3> in <module>()
8
9 # Evaluate the original FP32 BERT model
---> 10 time_model_evaluation(model, configs, tokenizer)
2 frames
<ipython-input-11-9c9008fc3551> in load_and_cache_examples(args, task, tokenizer, evaluate)
113 pad_on_left=bool(args.model_type in ['xlnet']), # pad on the left for xlnet
114 pad_token=tokenizer.convert_tokens_to_ids([tokenizer.pad_token])[0],
--> 115 pad_token_segment_id=4 if args.model_type in ['xlnet'] else 0,
116 )
117 if args.local_rank in [-1, 0]:
TypeError: glue_convert_examples_to_features() got an unexpected keyword argument 'pad_on_left'
I can workaround this by commenting out the pad arguments in 2.3:
features = convert_examples_to_features(examples,
tokenizer,
label_list=label_list,
max_length=args.max_seq_length,
output_mode=output_mode,
# pad_on_left=bool(args.model_type in ['xlnet']), # pad on the left for xlnet
# pad_token=tokenizer.convert_tokens_to_ids([tokenizer.pad_token])[0],
# pad_token_segment_id=4 if args.model_type in ['xlnet'] else 0,
)
There is another problem when running through the tutorial locally, when I got to section 3.3:
input_ids = ids_tensor([8, 128], 2)
I got this error:
Traceback (most recent call last):
File "bert-test.py", line 307, in <module>
input_ids = ids_tensor([8, 128], 2)
NameError: name 'ids_tensor' is not defined
The Colab version diverges at this point and doesn't use the ids_tensor function.
cc @jerryzh168 @jianyuh @z-a-f @vkuzo
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.