当前位置:网站首页>Relationship extraction --r-bert
Relationship extraction --r-bert
2022-06-26 08:27:00 【xuanningmeng】
Relationship extraction –R-BERT
Relation extraction is an important task in naturallanguageprocessing . The relationship extraction task is divided into pipline Type extraction and joint line The formula extraction . among pipline The extraction method generally divides the relationship extraction into two processes , First, extract entities , After classifying entities, we can get the relationship between entities , Transform relation extraction into a classification problem .joint line Formal extraction is to extract entities and relationships at the same time ,joint line Relational extraction will become an important direction of relational extraction . This blog introduces a good model of relationship extraction ideas ——R-BERT Model . The content is roughly divided into the following parts :
- R-BERT Model
- R-BERT Key code Introduction
- experimental result
R-BERT Model
R-BERT The model is based on pre training BERT The relational classification model of the model , The core of the model is as follows :
(1) Use pre training BERT To express the characteristics of words
(2) Extract pre training BERT Of special marking symbols in classification tasks "[CLS]" Characteristic information of ,subject Characteristic information of and object The characteristic information of .
R-BERT In the model, the entity information is used for classification , A new relational classification model is proposed .R-BERT The model structure is shown below :
R-BERT Key code Introduction
R-BERT The authors of the model open source the code , Is in torch and transformers Realized . Let's introduce subject and object Extraction of two entities and classification of relationships between entities .
(1)subject and object Entity extraction
def entity_average(hidden_output, e_mask):
""" Average the entity hidden state vectors (H_i ~ H_j) :param hidden_output: [batch_size, j-i+1, dim] :param e_mask: [batch_size, max_seq_len] e.g. e_mask[0] == [0, 0, 0, 1, 1, 1, 0, 0, ... 0] :return: [batch_size, dim] """
e_mask_unsqueeze = e_mask.unsqueeze(1) # [b, 1, j-i+1]
length_tensor = (e_mask != 0).sum(dim=1).unsqueeze(1) # [batch_size, 1]
# [b, 1, j-i+1] * [b, j-i+1, dim] = [b, 1, dim] -> [b, dim]
sum_vector = torch.bmm(e_mask_unsqueeze.float(), hidden_output).squeeze(1)
avg_vector = sum_vector.float() / length_tensor.float() # broadcasting
return avg_vector
Yes subject and object Conduct 0 and 1 Of mask, At entity location mask by 1, Other locations mask by 0, So as to obtain subject and object The representation of pre - training words .
(2) Relationship classification
self.cls_fc_layer = FCLayer(config.hidden_size,
config.hidden_size,
args.dropout_rate)
self.entity_fc_layer = FCLayer(config.hidden_size,
config.hidden_size,
args.dropout_rate)
self.label_classifier = FCLayer(
config.hidden_size * 3,
config.num_labels,
args.dropout_rate,
use_activation=False,
)
among FCLayer It's a full connection layer .
(3)R-BERT Yes subject and object Insert special symbols before and after to mark the entity .
experimental result
stay ccks2019 Relation extraction data set ,R-BERT See the figure below for the model effect 
The above is right R-BERT Introduction to the model , If there is any inaccuracy , Welcome to correct .
边栏推荐
- How to Use Instruments in Xcode
- STM32 project design: temperature, humidity and air quality alarm, sharing source code and PCB
- Installation of jupyter
- 73b2d wireless charging and receiving chip scheme
- Late 2021 plan
- Database learning notes II
- MySQL practice: 3 Table operation
- Area of Blue Bridge Cup 2 circle
- Use of jupyter notebook
- 监听iPad键盘显示和隐藏事件
猜你喜欢

"System error 5 occurred when win10 started mysql. Access denied"

static const与static constexpr的类内数据成员初始化

JMeter performance testing - Basic Concepts

How to debug plug-ins using vs Code

Ora-12514: tns: the listener currently does not recognize the service requested in the connection descriptor
![Comparison version number [leetcode]](/img/02/d1a1922c10e5360e511782b16690e1.jpg)
Comparison version number [leetcode]

Uni app installation and project directory (hbuilder configuration)

Quickly upload data sets and other files to Google colab ------ solve the problem of slow uploading colab files
![[postgraduate entrance examination: planning group] clarify the relationship among memory, main memory, CPU, etc](/img/c2/d1432ab6021ee9da310103cc42beb3.jpg)
[postgraduate entrance examination: planning group] clarify the relationship among memory, main memory, CPU, etc

Win11 open folder Caton solution summary
随机推荐
Discrete device ~ resistance capacitance
Introduction of laser drive circuit
[postgraduate entrance examination planning group] conversion between signed and unsigned numbers
Golang JSON unsupported value: Nan processing
JWT in go
RF filter
Uploading pictures with FileReader object
I Summary Preface
Software engineering - high cohesion and low coupling
Calculation of decoupling capacitance
StarWar armor combined with scanning target location
OpenCV Learning notes iii
51 MCU project design: Based on 51 MCU clock perpetual calendar
Design based on STM32 works: multi-functional atmosphere lamp, wireless control ws2812 of mobile app, MCU wireless upgrade program
Quickly upload data sets and other files to Google colab ------ solve the problem of slow uploading colab files
[postgraduate entrance examination] group planning exercises: memory
Method of measuring ripple of switching power supply
SOC wireless charging scheme
Undefined symbols for architecture i386 is related to third-party compiled static libraries
opencv学习笔记三