새로운 릴리스
우리는 LM 사전 훈련/양조 및 F- 디버 겐에 대한 적대적 훈련을 발표했습니다.
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 툴킷
ACL 2020
Hao Cheng과 Xiaodong Liu 및 Lis Pereira와 Yaoliang Yu 및 Jianfeng Gao
모델 견고성을 향상시키기위한 F 다산을 통한 후방 차등 정규화
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 run -it --rm --runtime nvidia allenlao/pytorch-mt-dnn:v1.3 bash
Docker를 처음 사용하는 경우 다음 링크를 참조하십시오 : https://docs.docker.com/
데이터 다운로드
> sh download.sh
Glue Dataset : https://gluebenchmark.com/ 다운로드를 참조하십시오.
전처리 데이터
> sh experiments/glue/prepro.sh
훈련
> python train.py
기본 MT-DNN 모델에 대한 4 V100 GPU에 대한 실험을 실행했습니다. 다른 GPU의 배치 크기를 줄여야 할 수도 있습니다.
MTL 정제 : 정제 MT-DNN (공유 계층)은 WNLI를 제외한 모든 접착제 작업을 사용하여 MTL을 통해 미리 훈련 된 BERT 모델로 초기화하여 새로운 공유 표현을 학습합니다.
배치 크기가 32 인 8 V100 GPU (32G) 에서이 실험을 실행했습니다.
>scriptsrun_mt_dnn.sh FINETUNING : FINETUNE MT-DNN 각 접착제 작업에 대한 작업 별 모델을 얻습니다.
여기서는 STS-B와 RTE의 두 가지 예를 제공합니다. 유사한 스크립트를 사용하여 모든 접착제 작업을 미선급 할 수 있습니다.
> scriptsrun_stsb.sh> scriptsrun_rte.sh Scitail의 도메인 적응
>scriptsscitail_domain_adaptation_bash.sh
SNLI에 대한 도메인 적응
>scriptssnli_domain_adaptation_bash.sh
전처리 데이터
a) {trave/valid/test} .txt를 포함하여 데이터/ner에 데이터를 다운로드하십시오
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) 다음을 포함하여 분대 데이터를 데이터/분대로 다운로드 한 다음 파일 이름을 다음과 같은 다음으로 변경합니다.
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 형식으로 변환하는 방법을 살펴 봅니다.
Google Bert 웹에서 Bert 모델을 다운로드하십시오 : 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을 통해 사전 배치 된 공유 임베드를 발표했으며 mt_dnn_base.pt 및 mt_dnn_large.pt .
유사한 모델을 얻으려면 :
>sh scriptsrun_mt_dnn.sh 실행 한 다음 mnli/rte의 평균 Dev Pre Formance를 기반으로 최고의 체크 포인트를 선택하십시오.scritpsstrip_model.py 를 통해 작업 별 레이어를 제거하십시오.Scitail/SNLI 작업의 경우, 학습 된 임베딩의 일반화와 Bert와 직접 비교할 수있는 복잡한 모델 구조 대신 새로운 도메인에 얼마나 쉽게 조정되는지 테스트하는 것이 목적입니다. 따라서 모든 도메인 적응 설정에 선형 투영을 사용합니다.
차이점은 QNLI 데이터 세트에 있습니다. 자세한 내용은 접착제 공식 홈페이지에 참조하십시오. QNLI를 우리의 논문으로 쌍별 순위 작업으로 공식화하려면 이전 QNLI 데이터를 사용해야합니다.
그런 다음 플래그로 Prepro 스크립트를 실행합니다. > sh experiments/glue/prepro.sh --old_glue
이전 버전의 데이터에 액세스하는 데 문제가있는 경우 접착제 팀에 문의하십시오.
멀티 태스킹 정제 모델을 사용하여 예측을 실행하고 합리적인 결과를 얻을 수 있습니다. 그러나 더 나은 결과를 얻으려면 각 작업마다 미세 조정이 필요합니다. Arxiv의 논문이 겨냥한 구식이며 오래된 접착제 데이터 세트에있는 것으로 나타났습니다. 아래에서 언급했듯이 논문을 업데이트하겠습니다.
Bert Pytorch는 다음과 같습니다
버트 : 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 he ( [email protected] ), weizhu chen (weizhu chen ( [email protected] ), jianshu ji (jianshuj@microsj@microsj@microsj@microsj@ [email protected] @microsoft)로 문의하십시오. [email protected] ) 또는 jianfeng gao ( [email protected] ).