thunlp / PTR

Prompt Tuning with Rules

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OOM错误

superwars opened this issue · comments

commented

为什么我使用7张24G的3090都会报OOM错误呀(一开始运行run_large_tacred.sh报错找不到PTR/datasets/tacred/temp_dd.txt文件,我将temp_dd.txt改成了temp.txt),是我哪里使用的不对吗?

你把--per_gpu_train_batch_size 设小一点看一下

commented

感谢您的回复!我可以成功运行了,如果在有限的显存情况下要保证batch_size与论文中的一致,是否仅需要保持num_gpu×per_gpu_train_batch_size×gradient_accumulation_steps=64即可?

另外还有一个小问题,论文中加在template前后的的"Learnable continuous tokens"在代码中体现在哪里?我似乎没有看到。

Learnable continuous tokens这个地方代码里写的比较trick,主要最近有点偷懒。

你到 https://github.com/thunlp/PTR/blob/main/code_script/data_prompt.py 里面看数据处理部分注释掉的几句话,你往template里面加入tokenizer.unk_token_id就行。

modeling里面的forward会自动处理这些learnable的tokens

就是这部分,你可以自己改一下

...
# prompt = [tokenizer.unk_token_id, tokenizer.unk_token_id] +
prompt = self.temp_ids[rel_name]['mask_ids'][0] + e1 +
self.temp_ids[rel_name]['mask_ids'][1] +
self.temp_ids[rel_name]['mask_ids'][2] + e2
# +
# [tokenizer.unk_token_id, tokenizer.unk_token_id]
...

commented

既然它被注释掉了,是否可以认为这个东西对结果几乎没什么影响呢?如果有,它的影响大吗,对结果能有几个点的提升?

这个东西我试验了,小模型影响不大,BERT-base,BERT-large这种规模的好像不太影响。这种soft prompt在模型参数量到百亿以上级别了会有用处。lstm和mlp都是对这个soft prompt进行变换的,更多细节你可以看gpt understands too,还有autoprompt这两篇文章

commented

感谢您的回复,我明白了。

对, 很奇怪就是按理roberta large用不到这么多显存吧

我觉得可能的原因是sequence length始终是max_sequence_length而不是去mini-batch中最长的, 导致数据的size太大

您好,我将--per_gpu_train_batch_size 设置成1了,还是显存不够,我用的是8张12G的,到底是需要多大显存呢?