DeBERTa improves the BERT and RoBERTa models using disentangled attention and enhanced mask decoder. It outperforms BERT and RoBERTa on majority of NLU tasks with 80GB training data.
Please check the official repository for more details and updates.
Add example with how to use DeBERTa in openmind.
We present the dev results on SQuAD 1.1/2.0 and MNLI tasks.
| Model | SQuAD 1.1 | SQuAD 2.0 | MNLI-m |
|---|---|---|---|
| RoBERTa-base | 91.5/84.6 | 83.7/80.5 | 87.6 |
| XLNet-Large | -/- | -/80.2 | 86.8 |
| DeBERTa-base | 93.1/87.2 | 86.2/83.1 | 88.8 |
import torch
from openmind import AutoTokenizer, is_torch_npu_available
from transformers import DebertaForMaskedLM
if is_torch_npu_available():
device = "npu:0"
elif torch.cuda.is_available():
device = "cuda:0"
else:
device = "cpu"
model_path= "PyTorch-NPU/deberta_base"
#推理
tokenizer = AutoTokenizer.from_pretrained(model_path)
model = DebertaForMaskedLM.from_pretrained(model_path).to(device)
inputs = tokenizer("The capital of France is [MASK].", return_tensors="pt").to(device)
with torch.no_grad():
logits = model(**inputs).logits
mask_token_index = (inputs.input_ids == tokenizer.mask_token_id)[0].nonzero(as_tuple=True)[0]
predicted_token_id = logits[0, mask_token_index].argmax(axis=-1)
print(">>>", tokenizer.decode(predicted_token_id))If you find DeBERTa useful for your work, please cite the following paper:
@inproceedings{
he2021deberta,
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}
}