【最新试验】用预训练模型Roberta做序列标注_自然语言处理_使用RobertaForTokenClassification做命名实体识别pytorch版

本文介绍了如何利用预训练模型RoBERTaForTokenClassification在PyTorch中实现命名实体识别,探讨了将CRF作为后置网络进行序列标注的方法,并提供了相应的代码示例。
摘要由CSDN通过智能技术生成

有了bert,roberta还会远吗,目前pytorch transformer上已经放出了bertForTokenClassification

然而,在工业界前进的我们,不能忍受如此慢速的更新

于是我们自己写好了robertaForTokenClassicification类,准备使用了!

以下是代码

 


class RobertaForTokenClassification(BertPreTrainedModel):
    r"""
        **labels**: (`optional`) ``torch.LongTensor`` of shape ``(batch_size, sequence_length)``:
            Labels for computing the token classification loss.
            Indices should be in ``[0, ..., config.num_labels - 1]``.

    Outputs: `Tuple` comprising various elements depending on the configuration (config) and inputs:
        **loss**: (`optional`, returned when ``labels`` is provided) ``torch.FloatTensor`` of shape ``(1,)``:
            Classification loss.
        **scores**: ``torch.FloatTensor`` of shape ``(bat
  • 0
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值