yangheng95 / PyABSA

Sentiment Analysis, Text Classification, Text Augmentation, Text Adversarial defense, etc.;

Home Page:https://pyabsa.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Attention mask not specified

svenhakvoort opened this issue · comments

We strongly recommend passing in an attention_mask since your input_ids may be padded, how to pass this in?

PyABSA Version (Required)

Python Version: 3.10
PyABSA Version: 2.3.4
Torch Version: 2.1.1
Transformers Version: 4.35.2

See the console output for PyABSA, Torch, Transformers Version

Code To Reproduce (Required)

base_model = 'yangheng/deberta-v3-large-absa-v1.1'
lcf = 'cdw'
model = APC.APCModelList.FAST_LSA_T
config = APC.APCConfigManager.get_apc_config_english()
config.lcf = lcf
config.model = model
config.pretrained_bert = base_model
config.evaluate_begin = 0
config.max_seq_len = 128
config.num_epoch = 30
config.similarity_threshold = 1
config.log_step = -1
config.patience = 5
config.dropout = 0.5
config.batch_size = 16
config.cache_dataset = False
config.l2reg = 1e-8
config.shuffle = True
config.dynamic_truncate = True
config.srd_alignment = True
config.use_torch_compile = False
config.seed = [random.randint(0, 10000) for _ in range(3)]

trainer = APC.APCTrainer(
              config=config,
              dataset=dataset,
              # from_checkpoint='english',
              checkpoint_save_mode=ModelSaveOption.SAVE_MODEL_STATE_DICT,
              # checkpoint_save_mode=ModelSaveOption.DO_NOT_SAVE_MODEL,
              path_to_save=f"checkpoints/{base_model}",
              auto_device=DeviceTypeOption.AUTO
          )

Full Console Output (Required)

Epoch:0 | Loss:0:   0%|          | 0/854 [00:00<?, ?it/s]We strongly recommend passing in an `attention_mask` since your input_ids may be padded. See

Describe the bug

Getting a message about missing attention_mask, how can i pass this in?

If you want to modify the attention mask, you need to revise the data_utils.py. Please debug to find the data_utils.py, which are different files for different tasks.