TextBrewer icon indicating copy to clipboard operation
TextBrewer copied to clipboard

无法复习结果

Open houpanpan opened this issue 5 years ago • 6 comments

前辈您好,NER任务的finetune过程,我将模型改为bert-base后,学习率改为2e-5/3e-5,衰减系数为1,反复试验多次,结果均很差很差,是我哪里设置出了问题嘛,按理说F1结果应该在90%才对啊,求指导,谢谢。

houpanpan avatar Apr 01 '21 06:04 houpanpan

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Apr 06 '21 07:04 stale[bot]

Closing the issue, since no updates observed. Feel free to re-open if you need any further assistance.

stale[bot] avatar Apr 13 '21 07:04 stale[bot]

实验了一下,基于msra_ner_exmaple修改,预训练模型使用谷歌的Chinese bert-base,训练半轮后F1可以达到0.92。 学习率 3e-5,不使用lr_decay (lr_decay is None),其他超参不变。

你注意下是否把mian.train.bert.dist.py中所有的electra模型都改成了bert模型 另外,如果你使用的是transformers中的BertForTokenClassification,其参数顺序与ElectraForTokenClassification不一致,可以通过batch_postprocessor修正:

def batch_postprocessor(batch):
    return {'input_ids':batch[0], 'attention_mask':batch[1], 'labels':batch[2]}
with distiller:
    distiller.train(optimizer, scheduler_class=scheduler_class, 
                      scheduler_args=scheduler_args,
                      max_grad_norm = 1.0,
                      dataloader=train_dataloader,
                      num_epochs=args.num_train_epochs, callback=callback_func,
                      batch_postprocessor=batch_postprocessor)

airaria avatar Apr 19 '21 02:04 airaria

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Apr 24 '21 05:04 stale[bot]

Closing the issue, since no updates observed. Feel free to re-open if you need any further assistance.

stale[bot] avatar May 01 '21 06:05 stale[bot]

实验了一下,基于msra_ner_exmaple修改,预训练模型使用谷歌的Chinese bert-base,训练半轮后F1可以达到0.92。 学习率 3e-5,不使用lr_decay (lr_decay is None),其他超参不变。

你注意下是否把mian.train.bert.dist.py中所有的electra模型都改成了bert模型 另外,如果你使用的是transformers中的BertForTokenClassification,其参数顺序与ElectraForTokenClassification不一致,可以通过batch_postprocessor修正:

def batch_postprocessor(batch):
    return {'input_ids':batch[0], 'attention_mask':batch[1], 'labels':batch[2]}
with distiller:
    distiller.train(optimizer, scheduler_class=scheduler_class, 
                      scheduler_args=scheduler_args,
                      max_grad_norm = 1.0,
                      dataloader=train_dataloader,
                      num_epochs=args.num_train_epochs, callback=callback_func,
                      batch_postprocessor=batch_postprocessor)

@airaria 能分享下完整的 mian.train.bert.dist.py 脚本? 按照上面改动后,报错:

  File "main.train.bert.dist.py", line 210, in main
    distiller.train(optimizer, scheduler_class=scheduler_class,
  File "/opt/conda/lib/python3.8/site-packages/textbrewer/distiller_train.py", line 180, in train
    callback(model=self.model, step=global_step)
  File "/share/Repository/model_compress/TextBrewer/examples/msra_ner_example/train_eval.py", line 78, in ddp_predict
    predict(model, eval_examples, eval_dataset, step, args)
  File "/share/Repository/model_compress/TextBrewer/examples/msra_ner_example/train_eval.py", line 109, in predict
    predictions = logits.argmax(dim=-1) #batch_size * length
AttributeError: 'str' object has no attribute 'argmax'
Killing subprocess 2354249


MrRace avatar May 25 '23 06:05 MrRace