ShuyangCao / cliff_summ

Code for EMNLP 2021 paper "CLIFF: Contrastive Learning for Improving Faithfulness and Factuality in Abstractive Summarization"
Apache License 2.0
44 stars 8 forks source link

Attribute Error #10

Closed ashleylew closed 2 years ago

ashleylew commented 2 years ago

I keep running into this error and can't figure out what is going wrong. I'm attempting to run the train_cnndm_single_neg.sh script on the given data. I have not made any changes to the batch script except to add my directories, but I'll paste it here just in case:

TOTAL_NUM_UPDATES=20000
WARMUP_UPDATES=500
LR=3e-05
MAX_TOKENS=1024
UPDATE_FREQ=32
NEG_DIR=$DATA/cnndm_synthetic/negative_syslowcon
SAVE_PATH=$DATA/2
POS_DIR=$DATA/cnndm_synthetic/positive_bt_filter
DATA_DIR=$DATA/cnndm_binarized
USER_DIR=../../models/bart

fairseq-train $DATA_DIR --pos-data $POS_DIR --neg-data $NEG_DIR --max-neg-samples 4 \
    --restore-file $BART_PATH --save-dir $SAVE_PATH \
    --max-tokens $MAX_TOKENS \
    --task contrastive_translation --mlp 1024 \
    --source-lang source --target-lang target \
    --truncate-source \
    --layernorm-embedding \
    --share-all-embeddings \
    --share-decoder-input-output-embed \
    --reset-optimizer --reset-dataloader --reset-meters \
    --required-batch-size-multiple 1 \
    --arch contrastive_bart_large \
    --criterion contrastive_loss \
    --label-smoothing 0.1 \
    --fixed-validation-seed 7 \
    --spectral-norm-classification-head \
    --dropout 0.1 --attention-dropout 0.1 \
    --weight-decay 0.01 --optimizer adam --adam-betas "(0.9, 0.999)" --adam-eps 1e-08 \
    --clip-norm 0.1 \
    --lr-scheduler polynomial_decay --lr $LR --total-num-update $TOTAL_NUM_UPDATES --warmup-updates $WARMUP_UPDATES \
    --fp16 --update-freq $UPDATE_FREQ \
    --skip-invalid-size-inputs-valid-test --max-epoch 5 \
    --no-save-optimizer-state --no-epoch-checkpoints \
    --find-unused-parameters \
    --user-dir $USER_DIR;

Here is the error I keep getting:

  File "/home/lewis.2/fairseq/cliff_summ/models/bart/constrative_bart.py", line 49, in forward
    eos: int = self.eos
  File "/home/lewis.2799/miniconda3/envs/QP2/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1185, in __getattr__
    raise AttributeError("'{}' object has no attribute '{}'".format(
AttributeError: 'ContrastiveBARTModel' object has no attribute 'eos'

It appears that something is going wrong in the constrative_bart.py script with "eos" but I'm struggling to trace where that is coming from and what it's doing. Any information would be really appreciated!

ShuyangCao commented 2 years ago

Hi, I have never experienced such issue before. A quick fix would be removing the line containing eos: int = self.eos, as the forward function is not actually using it.

pkuzengqi commented 2 years ago

Hi, I have never experienced such issue before. A quick fix would be removing the line containing eos: int = self.eos, as the forward function is not actually using it.

Hi, can you reflect this issue to your latest code?