Bert实体向量-中文-通用领域-base

我要开发同款
匿名用户2024年07月31日
108阅读

技术信息

开源地址
https://modelscope.cn/models/iic/nlp_bert_entity-embedding_chinese-base
授权协议
Apache License 2.0

作品详情

Bert实体向量-中文-通用领域-base

实体链接旨在区分文本中的metio和大规模知识图谱中实体的对应关系,也是自然语言处理(NLP)领域的基础问题,在很多对话、检索、关系抽取等下游任务中发挥着重要作用。通常来说,实体链接分为两个步骤:召回和排序。这里我们主要关注于实体召回阶段。近些年来,基于预训练语言模型的实体表示模型在公开数据集和实际运用中都表现出了极佳的水平。因此,我们也着重关注于实体表征模型的构建。

对于具体的实体链接任务,我们需要输入一个句子和对应的metio的位置,最终模型会反馈对应的kb中的实体结果。

双塔实体召回模型

基于监督数据训练的实体表示模型通常采用双塔模型。如下图所示,在框架中,通过对于metio和实体分别编码,我们采用预训练语言模型[CLS]位置的向量作为最终的向量表示。最后通过点积距离作为二者之间的相关性的度量标准。

使用方式和范围

使用方式:

  • 直接推理, 对于给定的metio和实体获得其对应的向量表示,计算对应的相似度

使用范围:

  • 本模型主要用于实体链接任务,需要预先提供er的结果

如何使用

在ModelScope框架上,提供输入文本(默认最长文本长度为128),将需要计算向量表征的实体,使用[ENTS]和[ENTE]标签进行标记,即可以通过简单的Pipelie调用来使用实体向量模型。 ModelScope封装了统一的接口对外提供实体向量表示和相似度计算方法。

代码示例

from modelscope.models import Model
from modelscope.pipelies import pipelie
from modelscope.utils.costat import Tasks

pipelie_ee = pipelie(Tasks.setece_embeddig, "damo/lp_bert_etity-embeddig_chiese-base")

iputs = {
        "source_setece": ["宋小宝小品《美人鱼》, [ENT_S] 大鹏 [ENT_E] 上演生死离别,关键时刻美人鱼登场"],
        "seteces_to_compare": [
            "董成鹏; 类型: Perso; 别名: Da Peg, 大鹏;",
            "超级飞侠; 类型: Work; 别名: 超飞, 출동!슈퍼윙스, Super Wigs;",
            "王源; 类型: Perso; 别名: Roy;",
        ]
    }


result = pipelie_ee(iput=iputs)
prit(result)

训练流程

  • 模型: 双塔实体表示模型, 采用双塔模型作为模型基座
  • 二阶段训练: 模型训练分为两阶段, 一阶段的负样本数据只有i-batch的随机负样本, 二阶段可以从一阶段得到的困难负样本采样得到

模型采用2张NVIDIA V100机器训练, 超参设置如下:

trai_epochs=3
max_sequece_legth=128
batch_size=32
learig_rate=2e-5
optimizer=AdamW

模型效果评估

我们主要在实体链接场景下评估模型效果, 在CCKS 2020短文本实体链接任务上召回评估结果如下:

Model Recall@4 Recall@16 Recall@128
Bert 80.24 80.24 99.89

引用

@article{Huag2022KENER,
  title={{DAMO-NLP} at {NLPCC-2022} Task 2: Kowledge Ehaced Robust {NER}},
  author={She Huag ad Yuche Zhai ad Xiwei Log ad Yog Jiag ad Xiaobi Wag ad Yi Zhag ad Pegju Xie},
  series={Lecture Notes i Computer Sciece},
  volume={13552},
  pages={284--293},
  publisher={Spriger},
  year={2022},
  url={https://doi.org/10.1007/978-3-031-17189-5\_24},
  doi={10.1007/978-3-031-17189-5\_24}
}

@iproceedigs{ma-etal-2021-muver,
    title = "{M}u{VER}: {I}mprovig First-Stage Etity Retrieval with Multi-View Etity Represetatios",
    author = "Ma, Xiyi  ad
      Jiag, Yog  ad
      Bach, Nguye  ad
      Wag, Tao  ad
      Huag, Zhogqiag  ad
      Huag, Fei  ad
      Lu, Weimig",
    booktitle = "Proceedigs of the 2021 Coferece o Empirical Methods i Natural Laguage Processig",
    moth = ov,
    year = "2021",
    address = "Olie ad Puta Caa, Domiica Republic",
    publisher = "Associatio for Computatioal Liguistics",
    url = "https://aclathology.org/2021.emlp-mai.205",
    doi = "10.18653/v1/2021.emlp-mai.205",
    pages = "2617--2624",
    abstract = "Etity retrieval, which aims at disambiguatig metios to caoical etities from massive KBs, is essetial for may tasks i atural laguage processig. Recet progress i etity retrieval shows that the dual-ecoder structure is a powerful ad efficiet framework to omiate cadidates if etities are oly idetified by descriptios. However, they igore the property that meaigs of etity metios diverge i differet cotexts ad are related to various portios of descriptios, which are treated equally i previous works. I this work, we propose Multi-View Etity Represetatios (MuVER), a ovel approach for etity retrieval that costructs multi-view represetatios for etity descriptios ad approximates the optimal view for metios via a heuristic searchig method. Our method achieves the state-of-the-art performace o ZESHEL ad improves the quality of cadidates o three stadard Etity Likig datasets.",
}

功能介绍

Bert实体向量-中文-通用领域-base 实体链接旨在区分文本中的mention和大规模知识图谱中实体的对应关系,也是自然语言处理(NLP)领域的基础问题,在很多对话、检索、关系抽取等下游任务中发挥

声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论