System Info
- `transformers` version: 4.18.0
- Platform: macOS-10.16-x86_64-i386-64bit
- Python version: 3.8.3
- Huggingface_hub version: 0.5.1
- PyTorch version (GPU?): 1.5.1 (False)
- Tensorflow version (GPU?): 2.4.0 (False)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using GPU in script?: N/A
- Using distributed or parallel set-up in script?: N/A
Who can help?
@LysandreJik @SaulLu
Information
Tasks
Reproduction
I'm interested in finding out the max sequence length that a model can be run with. After some code browsing, my current understanding that this is a property stored in the tokenizer model_max_length.
I wrote a simple script to load a tokenzier for a pretrained model and print the model max length. This is the important part:
# initialize the tokenizer to be able to print model_max_length
tokenizer = AutoTokenizer.from_pretrained(
model_args.tokenizer_name if model_args.tokenizer_name else model_args.model_name_or_path,
cache_dir=model_args.cache_dir,
use_fast=model_args.use_fast_tokenizer,
revision=model_args.model_revision,
use_auth_token=True if model_args.use_auth_token else None,
)
logger.info(f"Model max length {tokenizer.model_max_length}")
I used this to print max seq length for models such as BERT, RoBERTa, etc. All with expected results. For DeBERTa, I get confusing results.
If I run my script with DeBERTA-v3 as follows:
python check_model_max_len.py --model_name microsoft/deberta-v3-large --output_dir ./tmp --cache_dir ./tmp/cache
I get Model max length 1000000000000000019884624838656
If I understand correctly, this is a large integer used for models that can support "infinite" size lengths.
If I run my script with --model_name microsoft/deberta-v2-xlarge, I get Model max length 512
I don't understand if this is a bug or a feature :) My understanding is that the main difference between DeBERTa V2 and V3 is the use of ELECTRA style discriminator during MLM pretraining in V3. I don't understand why this difference would lead to a difference in supported max sequence lengths between the two models.
I also don't understand why some properties are hardcoded in the python files, e.g.,
PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES = {
"microsoft/deberta-v2-xlarge": 512,
"microsoft/deberta-v2-xxlarge": 512,
"microsoft/deberta-v2-xlarge-mnli": 512,
"microsoft/deberta-v2-xxlarge-mnli": 512,
}
I would expect these to be in the config files for the corresponding models.
Expected behavior
I would expect the max supported lengths for DeBERTa-V2 and DeBERTa-V3 models to be the same. Unless, I'm missing something. Thanks for your help!
System Info
Who can help?
@LysandreJik @SaulLu
Information
Tasks
examplesfolder (such as GLUE/SQuAD, ...)Reproduction
I'm interested in finding out the max sequence length that a model can be run with. After some code browsing, my current understanding that this is a property stored in the tokenizer
model_max_length.I wrote a simple script to load a tokenzier for a pretrained model and print the model max length. This is the important part:
I used this to print max seq length for models such as BERT, RoBERTa, etc. All with expected results. For DeBERTa, I get confusing results.
If I run my script with DeBERTA-v3 as follows:
I get
Model max length 1000000000000000019884624838656If I understand correctly, this is a large integer used for models that can support "infinite" size lengths.
If I run my script with
--model_name microsoft/deberta-v2-xlarge, I getModel max length 512I don't understand if this is a bug or a feature :) My understanding is that the main difference between DeBERTa V2 and V3 is the use of ELECTRA style discriminator during MLM pretraining in V3. I don't understand why this difference would lead to a difference in supported max sequence lengths between the two models.
I also don't understand why some properties are hardcoded in the python files, e.g.,
I would expect these to be in the config files for the corresponding models.
Expected behavior