รีลีสใหม่
เราเปิดตัวการฝึกอบรมที่เป็นปฏิปักษ์สำหรับทั้งการฝึกอบรมก่อนการฝึกอบรม/finetuning และ f-divergence
การฝึกอบรมด้านศัตรูขนาดใหญ่สำหรับ LMS: รหัสสารส้ม
โมเดลเครือข่ายประสาทไฮบริดเพื่อการให้เหตุผลแบบทั่วไป: รหัส HNN
หากคุณต้องการใช้เวอร์ชันเก่าโปรดใช้ CMD ต่อไปนี้เพื่อโคลนรหัส:
git clone -b v0.1 https://github.com/namisan/mt-dnn.git
อัปเดต
เราเสียใจที่ต้องแจ้งให้คุณทราบว่าการเปลี่ยนแปลงนโยบายนั้นไม่ได้จัดเก็บที่เก็บสาธารณะสำหรับการแชร์โมเดลอีกต่อไป เรากำลังทำงานอย่างหนักเพื่อหาทางออก
แพ็คเกจ Pytorch นี้ใช้เครือข่ายประสาทส่วนลึกหลายงาน (MT-DNN) สำหรับการทำความเข้าใจภาษาธรรมชาติตามที่อธิบายไว้ใน:
Xiaodong Liu*, Pengcheng HE*, Weizhu Chen และ Jianfeng Gao
เครือข่ายประสาทลึกหลายงานสำหรับการทำความเข้าใจภาษาธรรมชาติ
ACL 2019
*: การมีส่วนร่วมที่เท่าเทียมกัน
Xiaodong Liu, Pengcheng HE, Weizhu Chen และ Jianfeng Gao
การปรับปรุงเครือข่ายประสาทลึกหลายงานผ่านการกลั่นความรู้เพื่อความเข้าใจภาษาธรรมชาติ
เวอร์ชัน arxiv
Liyuan Liu, Haoming Jiang, Pengcheng HE, Weizhu Chen, Xiaodong Liu, Jianfeng Gao และ Jiawei Han
เกี่ยวกับความแปรปรวนของอัตราการเรียนรู้แบบปรับตัวและอื่น ๆ
ICLR 2020
Haoming Jiang, Pengcheng HE, Weizhu Chen, Xiaodong Liu, Jianfeng Gao และ Tuo Zhao
อัจฉริยะ: การปรับจูนที่แข็งแกร่งและมีประสิทธิภาพสำหรับแบบจำลองภาษาธรรมชาติที่ผ่านการฝึกอบรมมาก่อนผ่านการปรับให้เหมาะสมอย่างสม่ำเสมอ
ACL 2020
Xiaodong Liu, Yu Wang, Jianshu Ji, Hao Cheng, Xueyun Zhu, Emmanuel Awa, Pengcheng HE, Weizhu Chen, Hoifung Poon, Guihong Cao, Jianfeng Gao
Microsoft Toolkit ของเครือข่ายประสาทลึกหลายงานสำหรับการทำความเข้าใจภาษาธรรมชาติ
ACL 2020
Hao Cheng และ Xiaodong Liu และ Lis Pereira และ Yaoliang Yu และ Jianfeng Gao
การทำให้เป็นมาตรฐานด้านหลังด้วย F-Divergence สำหรับการปรับปรุงความทนทานของโมเดล
NAACL 2021
Python3.6
อ้างอิงถึงการดาวน์โหลดและติดตั้ง: https://www.python.org/downloads/release/python-360/
ติดตั้งข้อกำหนด
> pip install -r requirements.txt
ดึงนักเทียบท่า
> docker pull allenlao/pytorch-mt-dnn:v1.3
เรียกใช้ Docker
> docker run -it --rm --runtime nvidia allenlao/pytorch-mt-dnn:v1.3 bash
โปรดดูลิงค์ต่อไปนี้หากคุณใช้ Docker ครั้งแรก: https://docs.docker.com/
ดาวน์โหลดข้อมูล
> sh download.sh
โปรดดูที่ชุดข้อมูลกาวดาวน์โหลด: https://gluebenchmark.com/
ข้อมูลประมวลผลล่วงหน้า
> sh experiments/glue/prepro.sh
การฝึกอบรม
> python train.py
โปรดทราบว่าเราทำการทดลองใน 4 V100 GPU สำหรับรุ่น MT-DNN พื้นฐาน คุณอาจต้องลดขนาดแบทช์สำหรับ GPU อื่น ๆ
การปรับแต่ง MTL: ปรับแต่ง MT-DNN (เลเยอร์ที่ใช้ร่วมกัน) เริ่มต้นด้วยโมเดล BERT ที่ผ่านการฝึกอบรมมาก่อนผ่าน MTL โดยใช้งานกาวทั้งหมดที่ไม่รวม WNLI เพื่อเรียนรู้การเป็นตัวแทนที่ใช้ร่วมกันใหม่
โปรดทราบว่าเราทำการทดลองนี้ใน 8 V100 GPU (32G) ที่มีขนาดแบทช์ 32
>scriptsrun_mt_dnn.sh FINETUNING: FINETUNE MT-DNN ไปยังแต่ละงานกาวเพื่อรับโมเดลเฉพาะงาน
ที่นี่เรามีสองตัวอย่างคือ STS-B และ RTE คุณสามารถใช้สคริปต์ที่คล้ายกันเพื่อ finetune งานกาวทั้งหมด
> scriptsrun_stsb.sh> scriptsrun_rte.sh การปรับโดเมนบน scitail
>scriptsscitail_domain_adaptation_bash.sh
การปรับโดเมนบน SNLI
>scriptssnli_domain_adaptation_bash.sh
ข้อมูลประมวลผลล่วงหน้า
a) ดาวน์โหลดข้อมูล ner ไปยัง data/ner รวมถึง: {train/ถูกต้อง/ทดสอบ} .txt
b) แปลงข้อมูล ner เป็นรูปแบบที่เป็นที่ยอมรับ: > python experimentsnerprepro.py --data dataner --output_dir datacanonical_data
c) ประมวลผลข้อมูลที่เป็นที่ยอมรับไปยังรูปแบบ mt-dnn: > python prepro_std.py --root_dir datacanonical_data --task_def experimentsnerner_task_def.yml --model bert-base-uncased
การฝึกอบรม
> python train.py --data_dir <data-path> --init_checkpoint <bert-base-uncased> --train_dataset squad,squad-v2 --test_dataset squad,squad-v2 --task_def experimentssquadsquad_task_def.yml
ข้อมูลประมวลผลล่วงหน้า
a) ดาวน์โหลดข้อมูลทีมไปยังข้อมูล/ทีมรวมถึง: {train/ถูกต้อง} .txt จากนั้นเปลี่ยนชื่อไฟล์เป็น: {squad_train/squad_dev} .json
b) แปลงข้อมูลเป็นรูปแบบ mt-dnn: > python experimentssquadsquad_prepro.py --root_dir datacanonical_data --task_def experimentssquadsquad_task_def.yml --model bert-base-uncased
การฝึกอบรม
> python train.py --data_dir <data-path> --init_checkpoint <bert-model> --train_dataset ner --test_dataset ner --task_def experimentsnerner_task_def.yml
การฝึกอบรม ADV ที่ขั้นตอนการปรับแต่ง: > python train.py --data_dir <data-path> --init_checkpoint <bert/mt-dnn-model> --train_dataset mnli --test_dataset mnli_matched,mnli_mismatched --task_def experimentsglueglue_task_def.yml --adv_train --adv_opt 1
การสกัดตัวอย่างข้อความคู่
>python extractor.py --do_lower_case --finput input_examplespair-input.txt --foutput input_examplespair-output.json --bert_model bert-base-uncased --checkpoint mt_dnn_modelsmt_dnn_base.pt
โปรดทราบว่าคู่ของข้อความถูกแยกด้วยโทเค็นพิเศษ ||| - คุณสามารถอ้างอิง input_examplespair-output.json เป็นตัวอย่าง
การสกัดตัวอย่างประโยคเดียว
>python extractor.py --do_lower_case --finput input_examplessingle-input.txt --foutput input_examplessingle-output.json --bert_model bert-base-uncased --checkpoint mt_dnn_modelsmt_dnn_base.pt
การสะสมการไล่ระดับสี
หากคุณมี GPU ขนาดเล็กคุณอาจต้องใช้การสะสมการไล่ระดับสีเพื่อให้การฝึกอบรมมีเสถียรภาพ
ตัวอย่างเช่นหากคุณใช้ธง: --grad_accumulation_step 4 ในระหว่างการฝึกอบรมขนาดแบทช์จริงจะเป็น batch_size * 4
FP16 รุ่นปัจจุบันของ MT-DNN ยังรองรับการฝึกอบรม FP16 และโปรดติดตั้ง Apex
คุณเพียงแค่เปิดธงในระหว่างการฝึกอบรม: --fp16
โปรดอ้างอิงสคริปต์: scriptsrun_mt_dnn_gc_fp16.sh
ที่นี่เราผ่านวิธีการแปลงรุ่น Tensorflow Bert จีนเป็นรูปแบบ mt-DNN
ดาวน์โหลด Bert Model จาก Google Bert Web: https://github.com/google-research/bert
เรียกใช้สคริปต์ต่อไปนี้สำหรับรูปแบบ mt-DNN
python scriptsconvert_tf_to_pt.py --tf_checkpoint_root chinese_L-12_H-768_A-12 --pytorch_checkpoint_path chinese_L-12_H-768_A-12bert_base_chinese.pt
ใช่เราเปิดตัวการฝังที่ใช้ร่วมกันผ่าน MTL ซึ่งจัดเรียงกับ Bert Base/Models ขนาดใหญ่: mt_dnn_base.pt และ mt_dnn_large.pt
เพื่อให้ได้โมเดลที่คล้ายกัน:
>sh scriptsrun_mt_dnn.sh จากนั้นเลือกจุดตรวจที่ดีที่สุดตามค่าเฉลี่ย dev preforance ของ MNLI/RTEscritpsstrip_model.pyสำหรับงาน Scitail/SNLI วัตถุประสงค์คือการทดสอบการวางนัยทั่วไปของการฝังที่เรียนรู้และการปรับให้เข้ากับโดเมนใหม่ได้ง่ายเพียงใดแทนที่จะเป็นโครงสร้างโมเดลที่ซับซ้อนสำหรับการเปรียบเทียบโดยตรงกับ Bert ดังนั้นเราจึงใช้การฉายเชิงเส้นในการตั้งค่า การปรับตัวของโดเมน ทั้งหมด
ความแตกต่างอยู่ในชุดข้อมูล QNLI โปรดอ้างอิงถึงหน้าแรกอย่างเป็นทางการของกาวสำหรับรายละเอียดเพิ่มเติม หากคุณต้องการกำหนด QNLI เป็นงานจัดอันดับคู่ที่ฉลาดเป็นกระดาษของเราตรวจสอบให้แน่ใจว่าคุณใช้ข้อมูล QNLI เก่า
จากนั้นเรียกใช้สคริปต์ prepro ด้วยธง: > sh experiments/glue/prepro.sh --old_glue
หากคุณมีปัญหาในการเข้าถึงข้อมูลเวอร์ชันเก่าโปรดติดต่อทีมกาว
เราสามารถใช้แบบจำลองการปรับแต่งแบบหลายงานเพื่อเรียกใช้การทำนายและสร้างผลลัพธ์ที่สมเหตุสมผล แต่เพื่อให้ได้ผลลัพธ์ที่ดีกว่านั้นต้องมีการปรับแต่งในแต่ละงาน มันเป็นสิ่งที่น่าสังเกตว่ากระดาษในอาร์กซิฟเป็นชุดข้อมูลที่มีค่าออกมาและบนชุดข้อมูลกาวเก่า เราจะอัปเดตกระดาษตามที่เราได้กล่าวไว้ด้านล่าง
Bert Pytorch มาจาก: https://github.com/huggingface/pytorch-pretrained-bert
bert: https://github.com/google-research/bert
นอกจากนี้เรายังใช้รหัสบางส่วนจาก: https://github.com/kevinduh/san_mrc
@inproceedings{liu2019mt-dnn,
title = "Multi-Task Deep Neural Networks for Natural Language Understanding",
author = "Liu, Xiaodong and He, Pengcheng and Chen, Weizhu and Gao, Jianfeng",
booktitle = "Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics",
year = "2019",
publisher = "Association for Computational Linguistics",
url = "https://www.aclweb.org/anthology/P19-1441",
pages = "4487--4496"
}
@article{liu2019mt-dnn-kd,
title={Improving Multi-Task Deep Neural Networks via Knowledge Distillation for Natural Language Understanding},
author={Liu, Xiaodong and He, Pengcheng and Chen, Weizhu and Gao, Jianfeng},
journal={arXiv preprint arXiv:1904.09482},
year={2019}
}
@inproceedings{liu2019radam,
title={On the Variance of the Adaptive Learning Rate and Beyond},
author={Liu, Liyuan and Jiang, Haoming and He, Pengcheng and Chen, Weizhu and Liu, Xiaodong and Gao, Jianfeng and Han, Jiawei},
booktitle={International Conference on Learning Representations},
year={2020}
}
@inproceedings{jiang2019smart,
title={SMART: Robust and Efficient Fine-Tuning for Pre-trained Natural Language Models through Principled Regularized Optimization},
author={Jiang, Haoming and He, Pengcheng and Chen, Weizhu and Liu, Xiaodong and Gao, Jianfeng and Zhao, Tuo},
booktitle = "Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics",
year={2020}
}
@article{liu2020mtmtdnn,
title={The Microsoft Toolkit of Multi-Task Deep Neural Networks for Natural Language Understanding},
author={Liu, Xiaodong and Wang, Yu and Ji, Jianshu and Cheng, Hao and Zhu, Xueyun and Awa, Emmanuel and He, Pengcheng and Chen, Weizhu and Poon, Hoifung and Cao, Guihong and Jianfeng Gao},
journal={arXiv preprint arXiv:2002.07972},
year={2020}
}
@inproceedings{liu2020mtmtdnn,
title = "The {M}icrosoft Toolkit of Multi-Task Deep Neural Networks for Natural Language Understanding",
author={Liu, Xiaodong and Wang, Yu and Ji, Jianshu and Cheng, Hao and Zhu, Xueyun and Awa, Emmanuel and He, Pengcheng and Chen, Weizhu and Poon, Hoifung and Cao, Guihong and Jianfeng Gao},
publisher = "Association for Computational Linguistics",
url = "https://aclanthology.org/2020.acl-demos.16",
year = "2020"
}
@article{cheng2020posterior,
title={Posterior Differential Regularization with f-divergence for Improving Model Robustness},
author={Cheng, Hao and Liu, Xiaodong and Pereira, Lis and Yu, Yaoliang and Gao, Jianfeng},
booktitle = "Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies",
year = "2021",
publisher = "Association for Computational Linguistics",
url = "https://aclanthology.org/2021.naacl-main.85",
doi = "10.18653/v1/2021.naacl-main.85",
}
สำหรับความช่วยเหลือหรือปัญหาโดยใช้ MT-DNN โปรดส่งปัญหา GitHub
สำหรับการสื่อสารส่วนตัวที่เกี่ยวข้องกับแพ็คเกจนี้โปรดติดต่อ Xiaodong Liu ( [email protected] ), Yu Wang ( [email protected] ), Pengcheng เขา ( [email protected] ), Weizhu Chen [email protected] [email protected] [email protected] ) หรือ Jianfeng Gao ( [email protected] )