请教关于MLM预训练问题
- Dominant language
- Python
- Stars
- 3.1k
- Forks
- 520
- PR merge metrics
- No merged PRs in 30d
Description
**您好!请问以下几个问题,非常感谢:**
**(1)请问我以BERT为基础,进行MLM的预训练,同时采用静态Span masking,请问是正确的操作吗?不知道为何,我实际训练出的模型效果反倒不如原生BERT。**
预训练脚本如下:
python3 preprocess.py --corpus_path corpus/corpus.txt \
--vocab_path models/google_zh_vocab.txt \
--dataset_path mlm_base_dataset.pt \
--processes_num 1 --span_masking --span_geo_prob 0.3 --span_max_length 5 --target mlm
python3 pretrain.py --dataset_path mlm_base_dataset.pt --vocab_path models/google_zh_vocab.txt \
--pretrained_model_path models/google_zh_model.bin \
--output_model_path models/output_model.bin \
--config_path models/bert/base_config.json \
--world_size 1 --gpu_ranks 0 --learning_rate 2e-5 \
--total_steps 50000 --save_checkpoint_steps 10000 --report_steps 1000 --batch_size 8\
--embedding word_pos_seg --encoder transformer --mask fully_visible --target mlm
**(2)请问以上述方式训练出来的UER模型,convert转化为huggingface模型的过程中,我采用了script文件夹中提供的convert_bert_from_uer_to_huggingface.py,其中choice选择默认的BERT还是MLM呢? 我选择了默认的BERT,但是报错:**
Traceback (most recent call last):
File "convert_bert_from_uer_to_huggingface_cloze_long.py", line 66, in
main()
File "convert_bert_from_uer_to_huggingface_cloze_long.py", line 51, in main
output_model["bert.pooler.dense.weight"] = input_model["target.nsp_linear_1.weight"]
KeyError: 'target.nsp_linear_1.weight'
Traceback (most recent call last):
File "convert_bert_from_uer_to_huggingface_cloze_short.py", line 66, in
main()
File "convert_bert_from_uer_to_huggingface_cloze_short.py", line 51, in main
output_model["bert.pooler.dense.weight"] = input_model["target.nsp_linear_1.weight"]
KeyError: 'target.nsp_linear_1.weight'
**(3)然后我选择了MLM,就没报错了,那么,请问下,采用上述训练方式(在原生BERT模型上继续预训练MLM)后,训练出的模型还属不属于和原生BERT结构相同的模型呢?还是说只剩下了MLM的权重?NSP的权重被自动删除了?如果需要训练出的模型和原生BERT结构一样,是否target 只能采用bert呢?同时语料库corpus也需要准备NSP的那种语料库?**
**(4)最后,请问下,如果MLM训练后,结构和BERT不一样了,会影响模型的正常使用吗?目前我测试了一下,在一些数据集上仍然可以和BERT一样用。**
感谢!
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.