HuggingFace镜像/deberta_base
模型介绍文件和版本分析

DeBERTa:采用解耦注意力机制的解码增强型 BERT

DeBERTa 通过解耦注意力机制和增强的掩码解码器对 BERT 和 RoBERTa 模型进行了改进。在 80GB 训练数据的支持下,它在大多数自然语言理解(NLU)任务上的表现均优于 BERT 和 RoBERTa。

更多详细信息和更新,请查看 官方代码库。

修改说明

增加了在 openmind 中使用 DeBERTa 的示例。

在 NLU 任务上的微调

我们展示了在 SQuAD 1.1/2.0 和 MNLI 任务上的开发集结果。

模型SQuAD 1.1SQuAD 2.0MNLI-m
RoBERTa-base91.5/84.683.7/80.587.6
XLNet-Large-/--/80.286.8
DeBERTa-base93.1/87.286.2/83.188.8

如何在 openmind 中使用 DeBERTa

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))

引用

如果您发现DeBERTa对您的工作有所帮助,请引用以下论文:

@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}
}
下载使用量0