พื้นที่เก็บข้อมูลนี้เป็นการใช้งานอย่างเป็นทางการของ DeBERTa : D การเข้ารหัส BERT ขั้น สูง ด้วย Disentangled A ttention และ DeBERTa V3: การปรับปรุง DeBERTa โดยใช้การฝึกอบรมล่วงหน้าสไตล์ ELECTRA พร้อมการแบ่งปันการฝังแบบไล่ระดับที่แยกออก
รหัส DeBERTa v2 และรุ่น 900M, 1.5B อยู่ที่นี่แล้ว ซึ่งรวมถึงรุ่น 1.5B ที่ใช้สำหรับการส่ง SuperGLUE รุ่นเดียวของเราและได้คะแนน 89.9 เทียบกับค่าพื้นฐานของมนุษย์ที่ 89.8 คุณสามารถดูรายละเอียดเพิ่มเติมเกี่ยวกับการส่งนี้ได้ในบล็อกของเรา
ด้วยรุ่น DeBERTa 1.5B เราเหนือกว่ารุ่น T5 11B และประสิทธิภาพของมนุษย์บนกระดานผู้นำ SuperGLUE รหัสและรุ่นจะออกเร็วๆ นี้ โปรดตรวจสอบเอกสารของเราสำหรับรายละเอียดเพิ่มเติม
เราเผยแพร่โมเดลที่ได้รับการฝึกอบรมล่วงหน้า ซอร์สโค้ด และสคริปต์การปรับแต่งเพื่อสร้างผลลัพธ์การทดลองบางส่วนในรายงานฉบับนี้ คุณสามารถทำตามสคริปต์ที่คล้ายกันเพื่อนำ DeBERTa ไปใช้กับการทดลองหรือแอปพลิเคชันของคุณเองได้ สคริปต์ก่อนการฝึกอบรมจะเผยแพร่ในขั้นตอนถัดไป
DeBERTa (BERT ที่ปรับปรุงการถอดรหัสพร้อมความสนใจที่ไม่พันกัน) ปรับปรุงโมเดล BERT และ RoBERTa โดยใช้เทคนิคใหม่สองประการ ประการแรกคือกลไกความสนใจที่ไม่พันกัน โดยแต่ละคำจะถูกแทนด้วยเวกเตอร์สองตัวที่เข้ารหัสเนื้อหาและตำแหน่ง ตามลำดับ และน้ำหนักความสนใจของคำต่างๆ จะถูกคำนวณโดยใช้เมทริกซ์ที่ไม่พันกันกับเนื้อหาและตำแหน่งสัมพัทธ์ ประการที่สอง ใช้ตัวถอดรหัสมาสก์ที่ได้รับการปรับปรุงเพื่อแทนที่เลเยอร์ softmax เอาท์พุตเพื่อทำนายโทเค็นที่มาสก์สำหรับการฝึกโมเดลล่วงหน้า เราแสดงให้เห็นว่าเทคนิคทั้งสองนี้ปรับปรุงประสิทธิภาพของการฝึกอบรมแบบจำลองล่วงหน้าและประสิทธิภาพของงานขั้นปลายได้อย่างมีนัยสำคัญ
โมเดลที่ผ่านการฝึกอบรมล่วงหน้าของเราจะบรรจุเป็นไฟล์ซิป คุณสามารถดาวน์โหลดได้จากรุ่นต่างๆ ของเรา หรือดาวน์โหลดแต่ละรุ่นผ่านลิงก์ด้านล่าง:
แบบอย่าง | คำศัพท์(K) | พารามิเตอร์แกนหลัก (M) | ขนาดที่ซ่อนอยู่ | เลเยอร์ | บันทึก |
---|---|---|---|---|---|
V2-XXLarge 1 | 128 | 1320 | 1536 | 48 | คำศัพท์ SPM ใหม่ 128,000 คำ |
V2-XLarge | 128 | 710 | 1536 | 24 | คำศัพท์ SPM ใหม่ 128,000 คำ |
XLarge | 50 | 700 | 1,024 | 48 | คำศัพท์เดียวกับ RoBERTa |
ใหญ่ | 50 | 350 | 1,024 | 24 | คำศัพท์เดียวกับ RoBERTa |
ฐาน | 50 | 100 | 768 | 12 | คำศัพท์เดียวกับ RoBERTa |
V2-XXarge-MNLI | 128 | 1320 | 1536 | 48 | พลิกโฉมด้วย MNLI |
V2-XLarge-MNLI | 128 | 710 | 1536 | 24 | พลิกโฉมด้วย MNLI |
XLarge-MNLI | 50 | 700 | 1,024 | 48 | พลิกโฉมด้วย MNLI |
ขนาดใหญ่-MNLI | 50 | 350 | 1,024 | 24 | พลิกโฉมด้วย MNLI |
ฐาน-MNLI | 50 | 86 | 768 | 12 | พลิกโฉมด้วย MNLI |
DeBERTa -V3-ใหญ่ 2 | 128 | 304 | 1,024 | 24 | คำศัพท์ SPM ใหม่ 128,000 คำ |
DeBERTa -V3-เบส 2 | 128 | 86 | 768 | 12 | คำศัพท์ SPM ใหม่ 128,000 คำ |
DeBERTa -V3-เล็ก 2 | 128 | 44 | 768 | 6 | คำศัพท์ SPM ใหม่ 128,000 คำ |
DeBERTa -V3-XSmall 2 | 128 | 22 | 384 | 12 | คำศัพท์ SPM ใหม่ 128,000 คำ |
ม. DeBERTa -V3-ฐาน 2 | 250 | 86 | 768 | 12 | คำศัพท์ SPM ใหม่ 250,000 รายการ โมเดลหลายภาษาพร้อม 102 ภาษา |
อ่านเอกสารของเรา
มีหลายวิธีในการลองใช้โค้ดของเรา
Docker เป็นวิธีที่แนะนำในการรันโค้ดเนื่องจากเราได้สร้างการพึ่งพาทุกครั้งลงใน docker bagai/ DeBERTa ของเราแล้ว และคุณสามารถติดตามเว็บไซต์อย่างเป็นทางการของ docker เพื่อติดตั้ง docker บนเครื่องของคุณ
หากต้องการรันด้วยนักเทียบท่า ตรวจสอบให้แน่ใจว่าระบบของคุณเป็นไปตามข้อกำหนดในรายการด้านบน ต่อไปนี้เป็นขั้นตอนในการลองใช้การทดลอง GLUE: ดึงโค้ด รัน ./run_docker.sh
จากนั้นคุณสามารถรันคำสั่ง bash ภายใต้ / DeBERTa /experiments/glue/
ดึงโค้ดและรัน pip3 install -r requirements.txt
ในไดเร็กทอรีรากของโค้ด จากนั้นป้อนโฟลเดอร์ experiments/glue/
ของโค้ดแล้วลองใช้คำสั่ง bash ใต้โฟลเดอร์นั้นเพื่อทำการทดลองกาว
pip install DeBERTa
# To apply DeBERTa to your existing code, you need to make two changes to your code,
# 1. change your model to consume DeBERTa as the encoder
from DeBERTa import DeBERTa
import torch
class MyModel ( torch . nn . Module ):
def __init__ ( self ):
super (). __init__ ()
# Your existing model code
self . DeBERTa = DeBERTa . DeBERTa ( pre_trained = 'base' ) # Or 'large' 'base-mnli' 'large-mnli' 'xlarge' 'xlarge-mnli' 'xlarge-v2' 'xxlarge-v2'
# Your existing model code
# do inilization as before
#
self . DeBERTa . apply_state () # Apply the pre-trained model of DeBERTa at the end of the constructor
#
def forward ( self , input_ids ):
# The inputs to DeBERTa forward are
# `input_ids`: a torch.LongTensor of shape [batch_size, sequence_length] with the word token indices in the vocabulary
# `token_type_ids`: an optional torch.LongTensor of shape [batch_size, sequence_length] with the token types indices selected in [0, 1].
# Type 0 corresponds to a `sentence A` and type 1 corresponds to a `sentence B` token (see BERT paper for more details).
# `attention_mask`: an optional parameter for input mask or attention mask.
# - If it's an input mask, then it will be torch.LongTensor of shape [batch_size, sequence_length] with indices selected in [0, 1].
# It's a mask to be used if the input sequence length is smaller than the max input sequence length in the current batch.
# It's the mask that we typically use for attention when a batch has varying length sentences.
# - If it's an attention mask then if will be torch.LongTensor of shape [batch_size, sequence_length, sequence_length].
# In this case, it's a mask indicating which tokens in the sequence should be attended by other tokens in the sequence.
# `output_all_encoded_layers`: whether to output results of all encoder layers, default, True
encoding = DeBERTa . bert ( input_ids )[ - 1 ]
# 2. Change your tokenizer with the tokenizer built-in DeBERTa
from DeBERTa import DeBERTa
vocab_path , vocab_type = DeBERTa . load_vocab ( pretrained_id = 'base' )
tokenizer = DeBERTa . tokenizers [ vocab_type ]( vocab_path )
# We apply the same schema of special tokens as BERT, e.g. [CLS], [SEP], [MASK]
max_seq_len = 512
tokens = tokenizer . tokenize ( 'Examples input text of DeBERTa ' )
# Truncate long sequence
tokens = tokens [: max_seq_len - 2 ]
# Add special tokens to the `tokens`
tokens = [ '[CLS]' ] + tokens + [ '[SEP]' ]
input_ids = tokenizer . convert_tokens_to_ids ( tokens )
input_mask = [ 1 ] * len ( input_ids )
# padding
paddings = max_seq_len - len ( input_ids )
input_ids = input_ids + [ 0 ] * paddings
input_mask = input_mask + [ 0 ] * paddings
features = {
'input_ids' : torch . tensor ( input_ids , dtype = torch . int ),
'input_mask' : torch . tensor ( input_mask , dtype = torch . int )
}
สำหรับงานติดกาว
cache_dir=/tmp/ DeBERTa /
cd experiments/glue
./download_data.sh $cache_dir /glue_tasks
task=STS-B
OUTPUT=/tmp/ DeBERTa /exps/ $task
export OMP_NUM_THREADS=1
python3 -m DeBERTa .apps.run --task_name $task --do_train
--data_dir $cache_dir /glue_tasks/ $task
--eval_batch_size 128
--predict_batch_size 128
--output_dir $OUTPUT
--scale_steps 250
--loss_scale 16384
--accumulative_update 1
--num_train_epochs 6
--warmup 100
--learning_rate 2e-5
--train_batch_size 32
--max_seq_len 128
$HOME/.~ DeBERTa
คุณอาจต้องล้างข้อมูลหากการดาวน์โหลดล้มเหลวโดยไม่คาดคิดการทดลองปรับแต่งอย่างละเอียดของเราดำเนินการบนโหนด DGX-2 ครึ่งหนึ่งที่มีการ์ด GPU 8x32 V100 ผลลัพธ์อาจแตกต่างกันไปตามรุ่น GPU ไดรเวอร์ เวอร์ชัน CUDA SDK ที่แตกต่างกัน โดยใช้ FP16 หรือ FP32 และเมล็ดแบบสุ่ม เรารายงานตัวเลขของเราจากการวิ่งหลายครั้งโดยมีเมล็ดพันธุ์สุ่มที่แตกต่างกันที่นี่ นี่คือผลลัพธ์จากโมเดลขนาดใหญ่:
งาน | สั่งการ | ผลลัพธ์ | เวลาทำงาน (8x32G V100 GPU) |
---|---|---|---|
MNLI xxlarge เวอร์ชัน 2 | experiments/glue/mnli.sh xxlarge-v2 | 91.7/91.9 +/-0.1 | 4ชม |
MNLI xlarge เวอร์ชัน 2.1 | experiments/glue/mnli.sh xlarge-v2 | 91.7/91.6 +/-0.1 | 2.5 ชม |
MNLI xlarge | experiments/glue/mnli.sh xlarge | 91.5/91.2 +/-0.1 | 2.5 ชม |
MNLI ขนาดใหญ่ | experiments/glue/mnli.sh large | 91.3/91.1 +/-0.1 | 2.5 ชม |
QQP ใหญ่ | experiments/glue/qqp.sh large | 92.3 +/-0.1 | 6ชม |
QNLI ขนาดใหญ่ | experiments/glue/qnli.sh large | 95.3 +/-0.2 | 2ชม |
MRPC ขนาดใหญ่ | experiments/glue/mrpc.sh large | 91.9 +/-0.5 | 0.5ชม |
RTE ใหญ่ | experiments/glue/rte.sh large | 86.6 +/-1.0 | 0.5ชม |
SST-2 ใหญ่ | experiments/glue/sst2.sh large | 96.7 +/-0.3 | 1ชม |
STS-b ใหญ่ | experiments/glue/Stsb.sh large | 92.5 +/-0.3 | 0.5 ชม |
โคล่าใหญ่ | experiments/glue/cola.sh | 70.5 +/-1.0 | 0.5 ชม |
และนี่คือผลลัพธ์จากโมเดลพื้นฐาน
งาน | สั่งการ | ผลลัพธ์ | เวลาทำงาน (8x32G V100 GPU) |
---|---|---|---|
ฐาน MNLI | experiments/glue/mnli.sh base | 88.8/88.5 +/-0.2 | 1.5 ชม |
เรานำเสนอผลลัพธ์การพัฒนาบน SQuAD 1.1/2.0 และงานการวัดประสิทธิภาพ GLUE หลายงาน
แบบอย่าง | หน่วย 1.1 | ทีม 2.0 | MNLI-ม./มม | SST-2 | คิวเอ็นแอลไอ | โคล่า | ร.ต.ท | มพร | คิวคิวพี | เอสทีเอส-บี |
---|---|---|---|---|---|---|---|---|---|---|
F1/อีเอ็ม | F1/อีเอ็ม | บัญชี | บัญชี | บัญชี | มช | บัญชี | บัญชี/F1 | บัญชี/F1 | พี/เอส | |
BERT-ใหญ่ | 90.9/84.1 | 81.8/79.0 | 86.6/- | 93.2 | 92.3 | 60.6 | 70.4 | 88.0/- | 91.3/- | 90.0/- |
RoBERTa-Large | 94.6/88.9 | 89.4/86.5 | 90.2/- | 96.4 | 93.9 | 68.0 | 86.6 | 90.9/- | 92.2/- | 92.4/- |
XLNet-ขนาดใหญ่ | 95.1/89.7 | 90.6/87.9 | 90.8/- | 97.0 | 94.9 | 69.0 | 85.9 | 90.8/- | 92.3/- | 92.5/- |
DeBERTa -ใหญ่ 1 | 95.5/90.1 | 90.7/88.0 | 91.3/91.1 | 96.5 | 95.3 | 69.5 | 91.0 | 92.6/94.6 | 92.3/- | 92.8/92.5 |
DeBERTa -เอ็กซ์ลาร์จ 1 | - | - | 91.5/91.2 | 97.0 | - | - | 93.1 | 92.1/94.3 | - | 92.9/92.7 |
DeBERTa -V2-XLarge 1 | 95.8/90.8 | 91.4/88.9 | 91.7/91.6 | 97.5 | 95.8 | 71.1 | 93.9 | 92.0/94.2 | 92.3/89.8 | 92.9/92.9 |
DeBERTa -V2-XXLarge 1,2 | 96.1/91.4 | 92.2/89.7 | 91.7/91.9 | 97.2 | 96.0 | 72.0 | 93.5 | 93.1/94.9 | 92.7/90.3 | 93.2/93.1 |
DeBERTa -V3-Large | - | 91.5/89.0 | 91.8/91.9 | 96.9 | 96.0 | 75.3 | 92.7 | 92.2/- | 93.0/- | 93.0/- |
DeBERTa -V3-ฐาน | - | 88.4/85.4 | 90.6/90.7 | - | - | - | - | - | - | - |
DeBERTa -V3-Small | - | 82.9/80.4 | 88.3/87.7 | - | - | - | - | - | - | - |
DeBERTa -V3-XSmall | - | 84.8/82.0 | 88.1/88.3 | - | - | - | - | - | - | - |
เรานำเสนอผลการพัฒนาบน XNLI ด้วยการตั้งค่าการถ่ายโอนข้ามภาษาแบบ Zero-shot เช่น การฝึกอบรมโดยใช้ข้อมูลภาษาอังกฤษเท่านั้น การทดสอบในภาษาอื่น
แบบอย่าง | เฉลี่ย | ห้องน้ำในตัว | ศ | เช่น | เดอ | เอล | บีจี | รุ | ตร | อาร์ | วิ | ไทย | จ | สวัสดี | สว | คุณ |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
XLM-R-ฐาน | 76.2 | 85.8 | 79.7 | 80.7 | 78.7 | 77.5 | 79.6 | 78.1 | 74.2 | 73.8 | 76.5 | 74.6 | 76.7 | 72.4 | 66.5 | 68.3 |
ม. DeBERTa -V3-ฐาน | 79.8 +/-0.2 | 88.2 | 82.6 | 84.4 | 82.7 | 82.3 | 82.4 | 80.8 | 79.5 | 78.5 | 78.1 | 76.4 | 79.5 | 75.9 | 73.9 | 72.4 |
หากต้องการฝึกอบรม DeBERTa ล่วงหน้าด้วยวัตถุประสงค์ MLM และ RTD โปรดตรวจสอบ experiments/language_models
Pengcheng He([email protected]), Xiaodong Liu([email protected]), Jianfeng Gao([email protected]), Weizhu Chen([email protected])
@misc{he2021 DeBERTa v3,
title={ DeBERTa V3: Improving DeBERTa using ELECTRA-Style Pre-Training with Gradient-Disentangled Embedding Sharing},
author={Pengcheng He and Jianfeng Gao and Weizhu Chen},
year={2021},
eprint={2111.09543},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
@inproceedings{
he2021 DeBERTa ,
title={ DeBERTa : DECODING-ENHANCED BERT WITH DISENTANGLED ATTENTION},
author={Pengcheng He and Xiaodong Liu and Jianfeng Gao and Weizhu Chen},
booktitle={International Conference on Learning Representations},
year={2021},
url={https://openreview.net/forum?id=XPZIaotutsD}
}