国产亚洲精品福利在线无卡一,国产精久久一区二区三区,亚洲精品无码国模,精品久久久久久无码专区不卡

當(dāng)前位置: 首頁 > news >正文

便宜網(wǎng)站建設(shè)價格微信引流推廣精準(zhǔn)粉

便宜網(wǎng)站建設(shè)價格,微信引流推廣精準(zhǔn)粉,網(wǎng)站托管怎么做等保,家裝公司建設(shè)網(wǎng)站模型介紹 本項目是使用Bert模型來進行文本的實體識別。 Bert模型介紹可以查看這篇文章:nlp系列(2)文本分類(Bert)pytorch_bert文本分類_牧子川的博客-CSDN博客 模型結(jié)構(gòu) Bert模型的模型結(jié)構(gòu): 數(shù)據(jù)介紹 …

模型介紹

本項目是使用Bert模型來進行文本的實體識別。

Bert模型介紹可以查看這篇文章:nlp系列(2)文本分類(Bert)pytorch_bert文本分類_牧子川的博客-CSDN博客

模型結(jié)構(gòu)

Bert模型的模型結(jié)構(gòu):

數(shù)據(jù)介紹

數(shù)據(jù)網(wǎng)址:??????https://github.com/buppt//raw/master/data/people-relation/train.txt

實體1? 實體2? 關(guān)系 文本

        input_ids_list, token_type_ids_list, attention_mask_list, e1_masks_list, e2_masks_list, labels_list = [], [], [], [], [], []for instance in batch_data:# 按照batch中的最大數(shù)據(jù)長度,對數(shù)據(jù)進行padding填充input_ids_temp = instance["input_ids"]token_type_ids_temp = instance["token_type_ids"]attention_mask_temp = instance["attention_mask"]e1_masks_temp = instance["e1_masks"]e2_masks_temp = instance["e2_masks"]labels_temp = instance["labels"]# 添加到對應(yīng)的list中input_ids_list.append(torch.tensor(input_ids_temp, dtype=torch.long))token_type_ids_list.append(torch.tensor(token_type_ids_temp, dtype=torch.long))attention_mask_list.append(torch.tensor(attention_mask_temp, dtype=torch.long))e1_masks_list.append(torch.tensor(e1_masks_temp, dtype=torch.long))e2_masks_list.append(torch.tensor(e2_masks_temp, dtype=torch.long))labels_list.append(labels_temp)# 使用pad_sequence函數(shù),會將list中所有的tensor進行長度補全,補全到一個batch數(shù)據(jù)中的最大長度,補全元素為padding_valuereturn {"input_ids": pad_sequence(input_ids_list, batch_first=True, padding_value=0),"token_type_ids": pad_sequence(token_type_ids_list, batch_first=True, padding_value=0),"attention_mask": pad_sequence(attention_mask_list, batch_first=True, padding_value=0),"e1_masks": pad_sequence(e1_masks_list, batch_first=True, padding_value=0),"e2_masks": pad_sequence(e2_masks_list, batch_first=True, padding_value=0),"labels": torch.tensor(labels_list, dtype=torch.long)}

模型準(zhǔn)備

    def forward(self, token_ids, token_type_ids, attention_mask, e1_mask, e2_mask):sequence_output, pooled_output = self.bert_model(input_ids=token_ids, token_type_ids=token_type_ids,attention_mask=attention_mask, return_dict=False)# 每個實體的所有token向量的平均值e1_h = self.entity_average(sequence_output, e1_mask)e2_h = self.entity_average(sequence_output, e2_mask)e1_h = self.activation(self.dense(e1_h))e2_h = self.activation(self.dense(e2_h))# [cls] + 實體1 + 實體2concat_h = torch.cat([pooled_output, e1_h, e2_h], dim=-1)concat_h = self.norm(concat_h)logits = self.hidden2tag(self.drop(concat_h))return logits

模型預(yù)測

輸入中文句子:丁一嵐與丈夫鄧拓
句子中的實體1:丁一嵐
句子中的實體2:鄧拓
在丁一嵐與丈夫鄧拓中丁一嵐與鄧拓的關(guān)系為:夫妻


輸入中文句子:丁一嵐與丈夫鄧拓
句子中的實體1:鄧拓
句子中的實體2:丁一嵐
在【丁一嵐與丈夫鄧拓】中【鄧拓】與【丁一嵐】的關(guān)系為:夫妻


輸入中文句子:京德云社演出相聲,演員包括郭德綱、于謙、李菁、高峰、何云偉、曹云金、劉云天、欒云平、岳云鵬等,段子包括《兵器譜》、《大西廂》、《夢中婚
句子中的實體1:郭德綱
句子中的實體2:劉云天
在【京德云社演出相聲,演員包括郭德綱、于謙、李菁、高峰、何云偉、曹云金、劉云天、欒云平、岳云鵬等,段子包括《兵器譜》、《大西廂》、《夢中婚】中【郭德綱】與【劉云天】的關(guān)系為:師生


輸入中文句子:在榮國府里,雖然官爵是由賈政承繼,但真正主持家政的卻是賈赦這一派,而且賈赦在賈母面前似乎并不得寵。
句子中的實體1:賈母
句子中的實體2:賈赦
在【在榮國府里,雖然官爵是由賈政承繼,但真正主持家政的卻是賈赦這一派,而且賈赦在賈母面前似乎并不得寵?!恐小举Z母】與【賈赦】的關(guān)系為:父母

源碼獲取

???????Bert 關(guān)系識別icon-default.png?t=N7T8https://github.com/mzc421/Pytorch-NLP/tree/master/12-Bert%20%E5%85%B3%E7%B3%BB%E8%AF%86%E5%88%AB???????

硬性的標(biāo)準(zhǔn)其實限制不了無限可能的我們,所以啊!少年們加油吧!

http://aloenet.com.cn/news/34781.html

相關(guān)文章:

  • 百度資料怎么做網(wǎng)站網(wǎng)站建設(shè)對企業(yè)品牌價值提升的影響
  • 什么行業(yè)做網(wǎng)站深圳網(wǎng)絡(luò)推廣有幾種方法
  • 網(wǎng)站項目建設(shè)目標(biāo)免費下載b站視頻軟件
  • 網(wǎng)絡(luò)工作室是干嘛的seo系統(tǒng)源碼
  • 軟件開發(fā)公司網(wǎng)站設(shè)計許昌seo推廣
  • 做商城網(wǎng)站要哪些流程如何創(chuàng)建自己的域名
  • 連云港做鴨網(wǎng)站2022最新新聞
  • 屏蔽蜘蛛網(wǎng)站還會被收錄嗎南京網(wǎng)站設(shè)計公司大全
  • 濟南做html5網(wǎng)站建設(shè)發(fā)布信息的免費平臺有哪些
  • 專業(yè)做網(wǎng)站網(wǎng)站seo搜索引擎優(yōu)化教程
  • 百度廣告聯(lián)盟看廣告賺錢seo項目經(jīng)理
  • 什么是軟件定制開發(fā)免費seo搜索優(yōu)化
  • 投資做個app要多少錢長沙seo優(yōu)化排名
  • 福州網(wǎng)站建設(shè)電話天津谷歌優(yōu)化
  • 大連h5網(wǎng)站開發(fā)東莞seo優(yōu)化推廣
  • asp新聞網(wǎng)站模板seowhy培訓(xùn)
  • 網(wǎng)站代理備案信陽網(wǎng)站推廣公司
  • brophp框架做網(wǎng)站網(wǎng)站seo方案策劃書
  • 怎樣做代刷網(wǎng)站廣州百度推廣優(yōu)化
  • 南陽誰會做網(wǎng)站網(wǎng)絡(luò)廣告策劃書
  • b2b商務(wù)貿(mào)易平臺網(wǎng)站seo搜索引擎優(yōu)化案例
  • 合肥做公司網(wǎng)站公司百度搜索熱詞查詢
  • 網(wǎng)易嚴選的網(wǎng)站建設(shè)簡單的個人主頁網(wǎng)站制作
  • 汨羅網(wǎng)站建設(shè)交換鏈接營銷案例
  • 網(wǎng)站開發(fā)可以用gif嗎網(wǎng)站推廣方案有哪些
  • 網(wǎng)站設(shè)計書本地建站軟件有哪些
  • 沒有網(wǎng)站如何做落地頁南京seo網(wǎng)絡(luò)推廣
  • 咸陽做網(wǎng)站開發(fā)公司哪家好創(chuàng)建網(wǎng)站
  • 東莞家用臺燈東莞網(wǎng)站建設(shè)免費發(fā)帖的平臺有哪些
  • 做網(wǎng)站復(fù)制國家機關(guān)印章如何在百度上做免費推廣