Size mismatch error - LongBART
- Lingua principale
- Python
- Stelle
- 2.2k
- Fork
- 285
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
Hi everyone,
I would like to plug the attention mechanism of Longformer to Pegasus.
As a first step, I use the script "convert_bart_to_longformerencoderdecoder.py" from the Longformer project "https://github.com/allenai/longformer/blob/master/scripts/convert_bart_to_longformerencoderdecoder.py", which plugs the long attention mechanism to BART.
After saving the model to the folder "LongBART", I run the following script to test whether fine-tuning (on xsum) works:
```
python transformers/examples/seq2seq/run_summarization.py \
--model_name_or_path LongBART \
--do_train \
--do_eval \
--dataset_name xsum \
--output_dir /saved/LongBART_results \
--per_device_train_batch_size=4 \
--per_device_eval_batch_size=4 \
--overwrite_output_dir \
--predict_with_generate \
--num_train_epochs 2 \
--max_train_samples 10 \
--max_val_samples 10
```
However, I get the following error:
```
RuntimeError: Error(s) in loading state_dict for BartForConditionalGeneration:
size mismatch for model.encoder.embed_positions.weight: copying a param with shape torch.Size([4098, 1024]) from checkpoint, the shape in current model is torch.Size([1026, 1024]).
```
The error comes from the following code snippet in "run_summarization.py" (line 348) :
```
model = AutoModelForSeq2SeqLM.from_pretrained(
model_args.model_name_or_path,
from_tf=bool(".ckpt" in model_args.model_name_or_path),
config=config,
cache_dir=model_args.cache_dir,
revision=model_args.model_revision,
use_auth_token=True if model_args.use_auth_token else None,
)
```
Does anyone know what might be the issue ? @ibeltagy @krrishdholakia @LIUYANZHI88
Any help would be much appreciated!
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Valutazione
Questa issue non è ancora stata valutata.