CN112633483B - Four-tuple gate diagram neural network event prediction method, device, equipment and medium - Google Patents
Four-tuple gate diagram neural network event prediction method, device, equipment and medium Download PDFInfo
- Publication number
- CN112633483B CN112633483B CN202110026128.5A CN202110026128A CN112633483B CN 112633483 B CN112633483 B CN 112633483B CN 202110026128 A CN202110026128 A CN 202110026128A CN 112633483 B CN112633483 B CN 112633483B
- Authority
- CN
- China
- Prior art keywords
- event
- vector
- events
- background
- vectors
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000013528 artificial neural network Methods 0.000 title claims abstract description 103
- 238000000034 method Methods 0.000 title claims abstract description 53
- 238000010586 diagram Methods 0.000 title description 47
- 239000013598 vector Substances 0.000 claims abstract description 308
- 238000004364 calculation method Methods 0.000 claims abstract description 28
- 230000007246 mechanism Effects 0.000 claims description 22
- 238000004590 computer program Methods 0.000 claims description 17
- 238000012549 training Methods 0.000 claims description 16
- 239000011159 matrix material Substances 0.000 claims description 15
- 238000003860 storage Methods 0.000 claims description 6
- 230000004927 fusion Effects 0.000 claims description 5
- 238000010276 construction Methods 0.000 claims description 2
- 230000006870 function Effects 0.000 description 8
- 230000008569 process Effects 0.000 description 8
- 238000012545 processing Methods 0.000 description 7
- 230000003993 interaction Effects 0.000 description 5
- 230000004913 activation Effects 0.000 description 3
- 238000013473 artificial intelligence Methods 0.000 description 2
- 125000004122 cyclic group Chemical group 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 238000005457 optimization Methods 0.000 description 2
- 235000021152 breakfast Nutrition 0.000 description 1
- 239000003086 colorant Substances 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 239000013604 expression vector Substances 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
- 238000003062 neural network model Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 230000000750 progressive effect Effects 0.000 description 1
- 230000000306 recurrent effect Effects 0.000 description 1
- 238000011160 research Methods 0.000 description 1
- 238000012546 transfer Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/04—Architecture, e.g. interconnection topology
- G06N3/045—Combinations of networks
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/04—Architecture, e.g. interconnection topology
- G06N3/048—Activation functions
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/06—Physical realisation, i.e. hardware implementation of neural networks, neurons or parts of neurons
- G06N3/063—Physical realisation, i.e. hardware implementation of neural networks, neurons or parts of neurons using electronic means
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/08—Learning methods
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06Q—INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
- G06Q10/00—Administration; Management
- G06Q10/04—Forecasting or optimisation specially adapted for administrative or management purposes, e.g. linear programming or "cutting stock problem"
Landscapes
- Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Health & Medical Sciences (AREA)
- Life Sciences & Earth Sciences (AREA)
- Biomedical Technology (AREA)
- Biophysics (AREA)
- Mathematical Physics (AREA)
- Evolutionary Computation (AREA)
- General Health & Medical Sciences (AREA)
- Molecular Biology (AREA)
- Computing Systems (AREA)
- General Engineering & Computer Science (AREA)
- Computational Linguistics (AREA)
- Artificial Intelligence (AREA)
- Software Systems (AREA)
- Data Mining & Analysis (AREA)
- Business, Economics & Management (AREA)
- Economics (AREA)
- Human Resources & Organizations (AREA)
- Strategic Management (AREA)
- Marketing (AREA)
- Game Theory and Decision Science (AREA)
- Neurology (AREA)
- Entrepreneurship & Innovation (AREA)
- Development Economics (AREA)
- Operations Research (AREA)
- Quality & Reliability (AREA)
- Tourism & Hospitality (AREA)
- General Business, Economics & Management (AREA)
- Management, Administration, Business Operations System, And Electronic Commerce (AREA)
- Traffic Control Systems (AREA)
Abstract
Description
技术领域technical field
本申请实施例涉及数据处理技术领域,具体而言,涉及一种四元组门图神经网络事件预测方法、装置、设备及介质。The embodiments of the present application relate to the technical field of data processing, and in particular, to a method, device, device and medium for predicting events in a quaternary gate diagram neural network.
背景技术Background technique
脚本事件预测是人工智能领域一个重要的研究方向,理解脚本事件是实现真正的人工智能的重要一步,具体来说,脚本时间预测任务是根据已经出现的上下文,从多个可能的答案中选择一个标准答案,脚本事件预测可以应用在阅读理解、意图识别和对话管理等方面。现有的脚本事件预测方法中,主要是对上下文进行建模,利用模型实现事件预测。Scripted event prediction is an important research direction in the field of artificial intelligence. Understanding scripted events is an important step in realizing real artificial intelligence. Specifically, the scripted event prediction task is to choose one from multiple possible answers based on the context that has emerged. Standard answer, script event prediction can be applied in reading comprehension, intent recognition, and dialogue management. In the existing script event prediction methods, the context is mainly modeled, and the event prediction is realized by using the model.
现有技术中,一个问题是将事件的不同组成部分直接进行拼接,无法很好地捕捉到事件内部不同组成部分之间相互影响的关系,另一个问题是基于事件或事件链进行建模,无法很好捕捉到不同事件之间相互影响的关系。In the existing technology, one problem is that the different components of the event are directly spliced, and the relationship between the different components within the event cannot be well captured. Another problem is that modeling based on events or event chains cannot It captures the interplay between different events very well.
发明内容Contents of the invention
本申请实施例提供一种四元组门图神经网络事件预测方法、装置、设备及介质。,旨在提高传统事件预测精度。Embodiments of the present application provide a quadruple gate diagram neural network event prediction method, device, equipment and medium. , which aims to improve the accuracy of traditional event prediction.
本申请实施例第一方面提供一种四元组门图神经网络事件预测方法,所述方法包括:The first aspect of the embodiment of the present application provides a quadruple gate diagram neural network event prediction method, the method comprising:
将多个初始背景事件与多个待选事件构成事理图谱;Constitute multiple initial background events and multiple candidate events to form an event map;
将所述事理图谱中的所述多个初始背景事件与多个初始待选事件的向量以四元组的形式进行表示,得到初始背景事件向量与初始待选事件向量;Representing the vectors of the plurality of initial background events and the plurality of initial candidate events in the event map in the form of quadruples to obtain an initial background event vector and an initial candidate event vector;
使用四元组门图神经网络对所述事理图谱进行图网络计算,得到多个新的背景事件向量与多个新的待选事件向量;Using the quaternion gate graph neural network to perform graph network calculation on the event map to obtain a plurality of new background event vectors and a plurality of new candidate event vectors;
利用注意力神经网络对所述多个新的背景事件向量与所述多个新的待选事件向量进行计算,得到背景事件的整体向量;Using the attention neural network to calculate the multiple new background event vectors and the multiple new candidate event vectors to obtain the overall vector of the background event;
将所述整体向量与每个所述新的待选事件向量进行打分,将得分最高的一个待选事件作为预测结果。Score the overall vector and each of the new candidate event vectors, and use the candidate event with the highest score as the prediction result.
可选地,将多个初始背景事件与多个待选事件构成事理图谱,包括:Optionally, multiple initial background events and multiple candidate events constitute an event map, including:
设置多个初始背景事件与多个待选事件之间的关系;Set the relationship between multiple initial background events and multiple events to be selected;
以多个初始背景事件与多个待选事件为节点,以多个初始背景事件与多个待选事件之间的关系为边,构成事理图谱。Taking multiple initial background events and multiple candidate events as nodes, and taking the relationship between multiple initial background events and multiple candidate events as edges, an event map is formed.
可选地,将所述事理图谱中的所述多个初始背景事件与多个初始待选事件的向量以四元组的形式进行表示,得到初始背景事件向量与初始待选事件向量,包括:Optionally, the vectors of the plurality of initial background events and the plurality of initial candidate events in the event map are represented in the form of quadruples to obtain the initial background event vector and the initial candidate event vector, including:
将包括所述多个初始背景事件与多个初始待选事件在内的所有事件的向量以v(es,eo,ep)的形式进行表示,其中v代表谓语动词,es代表主语,eo代表宾语,ep代表一个和谓语动词有介词关系的实体。Express the vectors of all events including the multiple initial background events and multiple initial candidate events in the form of v( es , e o , e p ), where v represents a predicate verb, and e s represents a subject , e o represents the object, and e p represents an entity that has a prepositional relationship with the predicate verb.
可选地,在使用四元组门图神经网络对所述事理图谱进行图网络计算,得到多个新的背景事件向量与多个新的待选事件向量之前,所述方法还包括:Optionally, before using the quaternion gate graph neural network to perform graph network calculation on the event map to obtain multiple new background event vectors and multiple new candidate event vectors, the method further includes:
收集多个相关事件,将所述多个相关事件中的一部分标注为背景事件,另一部分标注为待选事件,作为训练集;Collecting a plurality of related events, marking a part of the plurality of related events as a background event, and marking the other part as a candidate event as a training set;
将所述训练集输入所述四元组门图神经网络之中对所述四元组门图神经网络进行训练,得到训练好的四元组门图神经网络。The training set is input into the quadruple gate diagram neural network to train the quadruple gate diagram neural network to obtain a trained quadruple gate diagram neural network.
可选地,使用四元组门图神经网络对所述事理图谱进行图网络计算,得到多个新的背景事件向量与多个新的待选事件向量,包括:Optionally, use the quaternion gate graph neural network to perform graph network calculation on the event map to obtain multiple new background event vectors and multiple new candidate event vectors, including:
将所述事理图谱中的事件的表示向量和代表事件之间的关系的邻接矩阵输入所述四元组门图神经网络中;Inputting the representation vector of the event in the event map and the adjacency matrix representing the relationship between events into the quadruple gate graph neural network;
所述四元组门图神经网络对所述事件的表示向量和所述邻接矩阵进行计算,得到所述多个新的背景事件向量与所述多个新的待选事件向量。The quaternion gating neural network calculates the representation vector of the event and the adjacency matrix to obtain the multiple new background event vectors and the multiple new candidate event vectors.
可选地,利用注意力神经网络对所述多个新的背景事件向量与所述多个新的待选事件向量进行计算,得到背景事件的整体向量,包括:Optionally, the attention neural network is used to calculate the multiple new background event vectors and the multiple new candidate event vectors to obtain the overall vector of the background event, including:
将所述多个新的背景事件向量与所述多个新的待选事件向量输入到所述注意力神经网络中;Inputting the plurality of new background event vectors and the plurality of new candidate event vectors into the attention neural network;
针对所述多个新的待选事件向量中的每一个新的待选事件向量,将所述多个新的背景事件向量中的每一个新的背景事件向量与其进行注意力机制的运算,得到所述多个新的背景事件向量中的每一个新的背景事向量相对于所述每一个新的待选事件向量的权重系数;For each new event vector to be selected in the plurality of new event vectors to be selected, perform an attention mechanism operation on each new background event vector in the plurality of new background event vectors, and obtain The weight coefficient of each new background event vector in the plurality of new background event vectors relative to each new candidate event vector;
根据所述权重系数,计算得到所述背景事件的整体向量。According to the weight coefficient, the overall vector of the background event is obtained through calculation.
可选地,将所述整体向量与每个所述新的待选事件向量进行打分,将得分最高的待选事件向量对应的待选事件作为预测结果,包括:Optionally, scoring the overall vector and each of the new candidate event vectors, and using the candidate event corresponding to the highest-scoring candidate event vector as the prediction result includes:
根据所述背景事件的整体向量,计算每个新的待选事件向量与所述背景事件的整体向量之间的欧氏距离,得到多个欧氏距离的值;According to the overall vector of the background event, calculate the Euclidean distance between each new event vector to be selected and the overall vector of the background event to obtain a plurality of Euclidean distance values;
选择多个欧氏距离的值中的最小值所对应的新的待选事件向量作为所述得分最高的待选事件向量,将所述得分最高的待选事件向量对应的待选事件作为预测结果。Selecting the new candidate event vector corresponding to the minimum value among the values of multiple Euclidean distances as the candidate event vector with the highest score, and taking the candidate event corresponding to the candidate event vector with the highest score as the prediction result .
本申请实施例第二方面提供一种四元组门图神经网络事件预测装置,所述装置包括:The second aspect of the embodiment of the present application provides a quadruple gate graph neural network event prediction device, the device comprising:
事理图谱构成模块,用于将多个初始背景事件与多个待选事件构成事理图谱;An event map constituting module, which is used to form an event map with multiple initial background events and multiple events to be selected;
四元组事件表示模块,用于将所述事理图谱中的所述多个初始背景事件与多个初始待选事件的向量以四元组的形式进行表示,得到初始背景事件向量与初始待选事件向量;The quadruple event representation module is used to represent the vectors of the plurality of initial background events and the plurality of initial candidate events in the event map in the form of quadruples, and obtain the initial background event vector and the initial candidate events event vector;
四元组门图神经网络模块,用于使用四元组门图神经网络对所述事理图谱进行图网络计算,得到多个新的背景事件向量与多个新的待选事件向量;The quadruple gate diagram neural network module is used to use the quadruple gate diagram neural network to perform graph network calculations on the event map to obtain a plurality of new background event vectors and a plurality of new candidate event vectors;
基于注意力机制的背景融合模块,用于利用注意力神经网络对所述多个新的背景事件向量与所述多个新的待选事件向量进行计算,得到背景事件的整体向量;The background fusion module based on the attention mechanism is used to calculate the multiple new background event vectors and the multiple new candidate event vectors by using the attention neural network to obtain the overall vector of the background event;
背景事件与待选事件打分模块,用于将所述整体向量与每个所述新的待选事件向量进行打分,将得分最高的待选事件向量对应的待选事件作为预测结果。The background event and candidate event scoring module is configured to score the overall vector and each of the new candidate event vectors, and use the candidate event corresponding to the candidate event vector with the highest score as the prediction result.
可选地,所述事理图谱构成模块包括:Optionally, the constituting module of the event map includes:
关系设置子模块,用于设置多个初始背景事件与多个待选事件之间的关系;A relationship setting submodule, used to set the relationship between multiple initial background events and multiple events to be selected;
事理图谱构成子模块,用于以多个初始背景事件与多个待选事件为节点,以多个初始背景事件与多个待选事件之间的关系为边,构成事理图谱。The event map constitutes a sub-module, which is used to form an event map with multiple initial background events and multiple candidate events as nodes, and with relationships between multiple initial background events and multiple candidate events as edges.
可选地,所述四元组事件表示模块包括:Optionally, the quadruple event representation module includes:
四元组事件表示子模块,用于将包括所述多个初始背景事件与多个初始待选事件在内的所有事件的向量以v(es,eo,ep)的形式进行表示,其中v代表谓语动词,es代表主语,eo代表宾语,ep代表一个和谓语动词有介词关系的实体。The four-tuple event representation submodule is used to represent the vectors of all events including the multiple initial background events and multiple initial candidate events in the form of v( es , e o , e p ), Among them, v represents the predicate verb, es represents the subject, e o represents the object, and e p represents an entity that has a prepositional relationship with the predicate verb.
可选地,所述装置还包括:Optionally, the device also includes:
事件收集模块,用于收集多个相关事件,将所述多个相关事件中的一部分标注为背景事件,另一部分标注为待选事件,作为训练集;An event collection module, configured to collect a plurality of related events, mark a part of the plurality of related events as background events, and mark the other part as candidate events, as a training set;
四元组门图神经网络训练模块,用于将所述训练集输入所述四元组门图神经网络之中对所述四元组门图神经网络进行训练,得到训练好的四元组门图神经网络。The quadruple gate diagram neural network training module is used to input the training set into the quadruple gate diagram neural network to train the quadruple gate diagram neural network to obtain the trained quadruple gate Graph neural network.
可选地,所述四元组门图神经网络模块包括:Optionally, the quadruple gate graph neural network module includes:
第一向量输入子模块,用于将所述事理图谱中的事件的表示向量和代表事件之间的关系的邻接矩阵输入所述四元组门图神经网络中;The first vector input submodule is used to input the representation vector of the event in the event map and the adjacency matrix representing the relationship between the events into the quadruple gate graph neural network;
四原子门图神经网络计算子模块,用于所述四元组门图神经网络对所述事件的表示向量和所述邻接矩阵进行计算,得到所述多个新的背景事件向量与所述多个新的待选事件向量。The four-atom gate graph neural network calculation submodule is used for the quadruple gate graph neural network to calculate the representation vector and the adjacency matrix of the event, and obtain the multiple new background event vectors and the multiple a new event vector to be selected.
可选地,所述基于注意力机制的背景融合模块包括:Optionally, the background fusion module based on the attention mechanism includes:
第二向量输入子模块,用于将所述多个新的背景事件向量与所述多个新的待选事件向量输入到所述注意力神经网络中;The second vector input submodule is used to input the multiple new background event vectors and the multiple new candidate event vectors into the attention neural network;
权重系数计算子模块,用于针对所述多个新的待选事件向量中的每一个新的待选事件向量,将所述多个新的背景事件向量中的每一个新的背景事件向量与其进行注意力机制的运算,得到所述多个新的背景事件向量中的每一个新的背景事向量相对于所述每一个新的待选事件向量的权重系数;The weight coefficient calculation sub-module is used for combining each new background event vector among the multiple new background event vectors with each new candidate event vector among the multiple new candidate event vectors Perform an attention mechanism operation to obtain the weight coefficient of each new background event vector in the plurality of new background event vectors relative to each of the new candidate event vectors;
整体向量获得子模块,用于根据所述权重系数,计算得到所述背景事件的整体向量。The overall vector obtaining sub-module is used to calculate and obtain the overall vector of the background event according to the weight coefficient.
可选地,所述背景事件与待选事件打分模块包括:Optionally, the background event and candidate event scoring module includes:
欧氏距离计算子模块,用于根据所述背景事件的整体向量,计算每个新的待选事件向量与所述背景事件的整体向量之间的欧氏距离,得到多个欧氏距离的值;The Euclidean distance calculation submodule is used to calculate the Euclidean distance between each new event vector to be selected and the overall vector of the background event according to the overall vector of the background event, and obtain a plurality of Euclidean distance values ;
预测结果获得子模块,选择多个欧氏距离的值中的最小值所对应的新的待选事件向量作为所述得分最高的待选事件向量,将所述得分最高的待选事件向量对应的待选事件作为预测结果。The prediction result obtaining submodule selects the new candidate event vector corresponding to the minimum value among the values of multiple Euclidean distances as the candidate event vector with the highest score, and assigns the event vector corresponding to the highest score candidate event vector The event to be selected is used as the prediction result.
本申请实施例第三方面提供一种可读存储介质,其上存储有计算机程序,该计算机程序被处理器执行时,实现如本申请第一方面所述的方法中的步骤。The third aspect of the embodiment of the present application provides a readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the steps in the method described in the first aspect of the present application are implemented.
本申请实施例第四方面提供一种电子设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,所述处理器执行所述计算机程序时,实现本申请第一方面所述的方法的步骤。The fourth aspect of the embodiment of the present application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and operable on the processor. When the processor executes the computer program, the first aspect of the present application is realized. The steps of the method described in the aspect.
采用本申请提供的四元组门图神经网络事件预测方法,首先将收集到的事件构成一个事理图谱,收集到的事件中包含了背景事件和待选事件,将事理图谱中的每个事件的向量中的四个组成部分和四元组数据的四个组成部分相对应,将每个时间的向量以四元组的形式进行表示,利用训练好的门图神经网络模型对事理图谱中的事件的向量进行计算,得到新的事件的向量,其中包含了新的背景事件向量和新的待选事件向量,采用注意力机制计算每一个背景事件向量对每一个待选事件向量的重要程度,根据每一个背景事件向量对每一个待选事件向量的重要程度得到背景事件的整体向量,计算每一个待选事件向量与整体背景事件向量的欧式距离,选择与整体背景事件向量距离最近的一个待选事件向量作为预测结果。本发明采用四元组对事件进行表示,恰好与事件的组成分相对应,更好的捕捉了事件内部不同组成成分之间的互相影响,使用门图神经网络对事件之间的相互作用进行建模,可以更好地捕捉到事件之间的互相影响,采用注意力机制将背景事件融合,与待选事件进行计算,可以考虑到每个背景事件对待选事件的影响,预测更加准确。Using the quaternion gate graph neural network event prediction method provided by this application, firstly, the collected events constitute an event map, the collected events include background events and candidate events, and the event map of each event in the event map The four components in the vector correspond to the four components of the quadruple data, and the vector at each time is represented in the form of quadruples, and the events in the event map are analyzed by using the trained gate graph neural network model The vector is calculated to obtain a new event vector, which contains a new background event vector and a new candidate event vector. The attention mechanism is used to calculate the importance of each background event vector to each candidate event vector, according to The importance of each background event vector to each candidate event vector is obtained to obtain the overall vector of the background event, calculate the Euclidean distance between each candidate event vector and the overall background event vector, and select the candidate with the closest distance to the overall background event vector Event vectors as predictions. The present invention uses quadruples to represent events, which just correspond to the components of the event, and better capture the mutual influence between different components inside the event, and use the gate graph neural network to build the interaction between events The model can better capture the mutual influence between events, and use the attention mechanism to fuse the background events and calculate with the candidate events. The influence of each background event on the candidate events can be considered, and the prediction is more accurate.
附图说明Description of drawings
为了更清楚地说明本申请实施例的技术方案,下面将对本申请实施例的描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the accompanying drawings that need to be used in the description of the embodiments of the present application. Obviously, the accompanying drawings in the following description are only some embodiments of the present application , for those skilled in the art, other drawings can also be obtained according to these drawings without paying creative labor.
图1是本申请一实施例提出的四元组门图神经网络事件预测方法的流程图;Fig. 1 is the flow chart of the quadruple gate graph neural network event prediction method that an embodiment of the present application proposes;
图2是本发明一实施例提出的基于四元组表示模型进行哈密顿算子运算的不同组成部分计算流程;Fig. 2 is the calculation process of different components of the Hamiltonian operator operation based on the quaternion representation model proposed by an embodiment of the present invention;
图3是本发明一实施例提出的基于四元组表示模型的事件表示示意图;FIG. 3 is a schematic diagram of an event representation based on a quadruple representation model proposed by an embodiment of the present invention;
图4是本发明一实施例提出的基于注意力机制的背景事件与待选事件进行注意力机制运算的示意图;Fig. 4 is a schematic diagram of an attention mechanism operation based on an attention mechanism background event and an event to be selected according to an embodiment of the present invention;
图5是本发明一实施例提出的基于注意力机制的背景事件与待选事件进行注意力机制运算的示意图;Fig. 5 is a schematic diagram of an attention mechanism operation based on an attention mechanism background event and a candidate event proposed by an embodiment of the present invention;
图6是本申请一实施例提出的基于加权求和后的背景事件与待选事件进行欧氏距离计算的打分模型示意图;FIG. 6 is a schematic diagram of a scoring model for calculating the Euclidean distance based on weighted and summed background events and candidate events proposed by an embodiment of the present application;
图7是本申请一实施例提出的四元组门图神经网络的训练流程图;Fig. 7 is the training flow diagram of the quadruple gate graph neural network that an embodiment of the present application proposes;
图8是本申请一实施例提出的四元组门图神经网络事件预测装置的示意图。FIG. 8 is a schematic diagram of a quadruple gate graph neural network event prediction device proposed by an embodiment of the present application.
具体实施方式Detailed ways
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。The following will clearly and completely describe the technical solutions in the embodiments of the present application with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of them. Based on the embodiments in this application, all other embodiments obtained by persons of ordinary skill in the art without creative efforts fall within the protection scope of this application.
参考图1,图1是本申请一实施例提出的四元组门图神经网络事件预测方法的流程图。如图1所示,该方法包括以下步骤:Referring to FIG. 1 , FIG. 1 is a flow chart of a quadruple gate diagram neural network event prediction method proposed by an embodiment of the present application. As shown in Figure 1, the method includes the following steps:
S11:将多个初始背景事件与多个待选事件构成事理图谱。S11: Construct a plurality of initial background events and a plurality of candidate events into an event map.
本实施例中,初始背景事件可以理解为已经发生的事件,初始待选事件是与初始背景事件相对应的接下来可能发生的事件,事理图谱是由多个事件和事件之间的关系构成的图谱。In this embodiment, the initial background event can be understood as an event that has already occurred, the initial candidate event is an event that may occur next corresponding to the initial background event, and the event map is composed of multiple events and the relationship between events Atlas.
本实施例中,将多个初始背景事件与多个待选事件构成事理图谱的具体步骤包括:In this embodiment, the specific steps of forming an event graph from multiple initial background events and multiple candidate events include:
S11-1:设置多个初始背景事件与多个待选事件之间的关系。S11-1: Setting the relationship between multiple initial background events and multiple events to be selected.
本实施例中,包括初始背景事件与初始待选事件在内的多个事件之间都是相互联系的,具有一定的关系,需要将事件之间的关系预先设置好。In this embodiment, multiple events including the initial background event and the initial candidate event are all related to each other and have a certain relationship, and the relationship between the events needs to be set in advance.
示例地,一个事件是“进入商店”,另一个事件是“购物”,则“进入商店”的目的是“购物”,而“目的”可以记为“进入商店”与“购物”之间的关系。For example, one event is "entering a store" and the other event is "shopping", then the purpose of "entering a store" is "shopping", and "purpose" can be recorded as the relationship between "entering a store" and "shopping" .
S11-2:以多个初始背景事件与多个待选事件为节点,以多个初始背景事件与多个待选事件之间的关系为边,构成事理图谱。S11-2: Taking multiple initial background events and multiple candidate events as nodes, and taking relationships between multiple initial background events and multiple candidate events as edges to form an event map.
本实施例中,事理图谱是一个包含了事理逻辑的知识库,描述了事件之间的演化规律和演化模式。事理图谱的结构是一个有向有环图,其中节点代表关系,有向边代表事件之间顺承、因果、条件和上下位等事理逻辑关系。In this embodiment, the event map is a knowledge base containing event logic, which describes the evolution rule and evolution mode between events. The structure of the event map is a directed and cyclic graph, in which nodes represent relationships, and directed edges represent logical relations between events, such as sequence, causality, conditions, and upper and lower levels.
本实施例中,将包括多个初始背景事件与多个待选事件在内的所有事件作为事理图谱的节点,将各个事件之间的关系作为事理图谱的边,构成事理图谱,可以清晰的表达各个事件之间的逻辑关系,更加有利于对事件进行建模和计算。In this embodiment, all events including multiple initial background events and multiple candidate events are used as the nodes of the event map, and the relationship between each event is used as the edge of the event map to form the event map, which can be clearly expressed The logical relationship between various events is more conducive to modeling and calculation of events.
S12:将所述事理图谱中的所述多个初始背景事件与多个初始待选事件的向量以四元组的形式进行表示,得到初始背景事件向量与初始待选事件向量。S12: Represent the vectors of the plurality of initial background events and the plurality of initial candidate events in the event map in the form of quadruples to obtain an initial background event vector and an initial candidate event vector.
本实施例中,将包括所述多个初始背景事件与多个初始待选事件在内的所有事件的向量以v(es,eo,ep)的形式进行表示,其中v代表谓语动词,es代表主语,eo代表宾语,ep代表一个和谓语动词有介词关系的实体。In this embodiment, the vectors of all events including the multiple initial background events and multiple initial candidate events are expressed in the form of v( es , e o , e p ), where v represents a predicate verb , es represents the subject, e o represents the object, and e p represents an entity that has a prepositional relationship with the predicate verb.
本实施例中,四元组数据结构是复数数据的扩展,复数数据包括一个实部、一个虚部,四元组数据结构具有一个实部,三个虚部,即Q1=a1+b1i+c1j+d1k,其中a1为实部,b1、c1、d1为虚部,i、j、k代表虚数,而事件表示的一般模型一般也是具有四个组成部分,即v(es,eo,ep),,其中v代表谓语动词,es代表主语,eo代表宾语,ep代表一个和谓语动词有介词关系的实体。让a1与v对应,b1、c1、d1分别与es、eo、ep相对应,通过利用四元组数据结构与事件表示模型在结构上的类似,用四元组数据结构建模事件可以捕捉到事件内部的关系。In this embodiment, the quadruple data structure is an extension of complex data, complex data includes a real part and an imaginary part, and the quadruple data structure has a real part and three imaginary parts, that is, Q1=a1+b1i+c1j +d1k, where a1 is the real part, b1, c1, and d1 are the imaginary parts, i, j, and k represent imaginary numbers, and the general model of event representation generally has four components, namely v( es , e o , e p ), where v represents the predicate verb, es represents the subject, e o represents the object, and e p represents an entity that has a prepositional relationship with the predicate verb. Let a1 correspond to v, b1, c1, d1 correspond to e s , e o , e p respectively, by utilizing the similarity between the quadruple data structure and the event representation model in structure, use the quadruple data structure to model the event Relationships within events can be captured.
本实施例中,如图2所示,图2是本发明一实施例提出的基于四元组表示模型进行哈密顿算子运算的不同组成部分计算流程,四元组数据采用哈密顿算子进行运算,通过权重共享可以很好地捕捉到事件内部之间的相互作用的影响。图2中,Qin表示输入,Qout表示输出,W表示总权重,Ws、Wo、Wp是es、eo、ep对应的权重,v’、e’s、e’o、e’p分别是v、es、eo、ep结合各部分影响之后的向量表示。具体的计算流程可以通过如下公式描述:In this embodiment, as shown in Figure 2, Figure 2 is the calculation process of different components of the Hamiltonian operator operation based on the quadruple representation model proposed by an embodiment of the present invention, and the quadruple data is performed using the Hamiltonian operator Operation, the influence of the interaction between events can be well captured through weight sharing. In Figure 2, Qin represents the input, Q out represents the output, W represents the total weight, W s , W o , W p are the weights corresponding to e s , e o , e p , v', e' s , e' o , e' p are the vector representations of v, e s , e o , e p combined with the influence of each part respectively. The specific calculation process can be described by the following formula:
其中Q1=a1+b1i+c1j+d1k,Q2=a2+b2i+c2j+d2k。Where Q 1 =a 1 +b 1 i+c 1 j+d 1 k, Q 2 =a 2 +b 2 i+c 2 j+d 2 k.
本实施例中,如图3所示,图3是本发明一实施例提出的基于四元组表示模型的事件表示示意图,其中颜色的深浅代表每个向量不同的组成部分。In this embodiment, as shown in FIG. 3 , FIG. 3 is a schematic diagram of an event representation based on a quadruple representation model proposed by an embodiment of the present invention, where the shades of colors represent different components of each vector.
示例地,事理图谱中有一个事件为“我去商场购买衣服”其中,“我”是主语es,“衣服”是宾语eo,“商场”是和谓语动词有介词关系的实体ep,“去购买”是谓语动词v。For example, there is an event in the event map as "I go to the mall to buy clothes" where "I" is the subject e s , "clothes" is the object e o , "shop" is the entity e p that has a prepositional relationship with the predicate verb, "To buy" is the predicate verb v.
S13:使用四元组门图神经网络对所述事理图谱进行图网络计算,得到多个新的背景事件向量与多个新的待选事件向量。S13: Using the quaternion gate graph neural network to perform graph network calculation on the event map to obtain a plurality of new background event vectors and a plurality of new candidate event vectors.
本实施例中,四元组门图神经网络,是将循环神经网络中的门结构与图神经网络相结合的一种新型神经网络,其中门结构与GRU的门结构类似,图神经网络是一种用于处理具有图结构的数据的通用神经网络结构。不同的脚本事件具有多重交互作用,为了结合不同事件的交互作用和事件的内部依赖关系,本实施例中将四元数和门控神经网络与图神经网络相结合,得到四元组门图神经网络,可以更好的学习事件的特征表示。In this embodiment, the quaternion gate graph neural network is a new type of neural network that combines the gate structure in the recurrent neural network with the graph neural network, wherein the gate structure is similar to that of the GRU, and the graph neural network is a A general neural network architecture for processing data with a graph structure. Different script events have multiple interactions. In order to combine the interaction of different events and the internal dependencies of events, in this embodiment, the quaternion and the gated neural network are combined with the graph neural network to obtain the quaternion gate graph neural network. The network can better learn the feature representation of events.
本实施例中,使用四元组门图神经网络对所述事理图谱进行图网络计算,得到多个新的背景事件向量与多个新的待选事件向量的具体步骤是:In this embodiment, the specific steps for obtaining multiple new background event vectors and multiple new candidate event vectors are:
S13-1:将所述事理图谱中的事件的表示向量和代表事件之间的关系的邻接矩阵输入所述门图神经网络中。S13-1: Input the representation vectors of the events in the event graph and the adjacency matrix representing the relationship between events into the gate graph neural network.
本实施例中,使用四元组门图神经网络对所述事理图谱进行图网络计算,首先需要将初始背景事件与初始待选事件的向量h(0)和邻接矩阵A输入到神经网络之中。In this embodiment, using the quaternion gate graph neural network to perform graph network calculation on the event map, first, the vector h (0) and the adjacency matrix A of the initial background event and the initial candidate event need to be input into the neural network .
示例地,设共有8个背景事件与5个待选事件,则h(0)表示这8个背景事件和5个待选事件的初始向量,邻接矩阵A∈R13×13,表示这13个事件之间的互相关系。For example, suppose there are 8 background events and 5 candidate events, then h (0) represents the initial vectors of these 8 background events and 5 candidate events, and the adjacency matrix A∈R 13×13 represents the 13 Interrelationships between events.
S13-2:所述门图神经网络对所述事件的表示向量和所述邻接矩阵进行计算,得到所述多个新的背景事件向量与所述多个新的待选事件向量。S13-2: The gate graph neural network calculates the event representation vector and the adjacency matrix to obtain the multiple new background event vectors and the multiple new candidate event vectors.
本实施例中,如图4所示,图4是本发明一实施例提出的基于注意力机制的背景事件与待选事件进行注意力机制运算的示意图,其中节点e1、e1……、en代表不同的事件向量,每条边都代表了事件之间的关系。In this embodiment, as shown in FIG. 4 , FIG. 4 is a schematic diagram of an attention mechanism-based background event and a candidate event for an attention mechanism operation proposed by an embodiment of the present invention, in which nodes e 1 , e 1 . . . , en represents different event vectors, and each edge represents the relationship between events.
初始背景事件向量与初始待选事件向量只是将事件以向量的形式表示出来,并未对相互之间的关系进行建模,将背景事件向量与待选事件向量输入四元组门图神经网络进行计算,得到的新的背景事件向量和待选事件向量是融合了不同节点之间的信息,是融合了各个事件之间的影响的新的向量。The initial background event vector and the initial candidate event vector only express the events in the form of vectors, and do not model the relationship between them. The background event vector and the candidate event vector are input into the quadruple gate diagram neural network for Calculated, the new background event vector and the candidate event vector are obtained by fusing information between different nodes, and are new vectors fusing the influence between various events.
本实施例中,使用四元组门图神经网络对事件的表示向量和邻接矩阵进行计算得到多个新的背景事件向量与多个新的待选事件向量,具体计算方法是:In this embodiment, the expression vector and adjacency matrix of the event are calculated by using the quaternion gate diagram neural network to obtain multiple new background event vectors and multiple new candidate event vectors. The specific calculation method is:
a(t)=ATh(t-1)+b (2)a (t) = A T h (t-1) + b (2)
ht=(1-zt)⊙h(t-1)+zt⊙ct (6)h t =(1-z t )⊙h (t-1) +z t ⊙c t (6)
其中,表示哈密顿算子,⊙表示元素级别的乘法,a(t)是一个中间量,AT代表邻接矩阵的转置,h(t-1)代表第t个向量的上一个向量,b代表偏置量,/>Q1、Q2都表示四元组数值,σ()代表四元组划分的sigmoid激活函数,tanh()代表四元组划分的tanh激活函数,zt代表更新门,rt代表重置门,ct代表中间量,ht代表新的背景事件向量或新的待选事件向量。in, Indicates the Hamiltonian operator, ⊙ indicates element-level multiplication, a (t) is an intermediate quantity, A T represents the transpose of the adjacency matrix, h (t-1) represents the previous vector of the t-th vector, and b represents the bias set amount, /> Both Q 1 and Q 2 represent the quadruple value, σ() represents the sigmoid activation function of the quadruple division, tanh() represents the tanh activation function of the quadruple division, z t represents the update gate, and r t represents the reset gate , c t represents the intermediate quantity, h t represents the new background event vector or the new candidate event vector.
本实施例中,公式(2)表示的是信息在四元组门图神经网络的不同节点之间的传递过程,公式(3)-(6)表示的是从其余的节点和当前节点的之前的向量一起更新得到新的向量。上述公式中的循环传播过程中有一定的步数K步,步数由向量的数量决定。经过上述公式计算之后,四元组门图神经网络输出新的背景事件向量与新的待选事件向量,可以将新的背景事件向量以hi进行表示,将新的待选事件向量以hcj进行表示。In the present embodiment, what formula (2) represented is the transfer process of information between the different nodes of the quadruple gate graph neural network, and what formula (3)-(6) represented is from remaining node and current node before The vectors are updated together to get a new vector. There is a certain number of steps K in the cyclic propagation process in the above formula, and the number of steps is determined by the number of vectors. After the calculation of the above formula, the quadruple gate graph neural network outputs a new background event vector and a new candidate event vector. The new background event vector can be represented by h i , and the new candidate event vector can be represented by h cj to express.
示例地,将8个初始背景事件和5个初始背景事件的向量与表示这13个事件之间相互关系的邻接矩阵输入四元组门图神经网络之中后,可得到这8背景事件的新的背景事件向量h1,h2,……,h8,和5个待选事件的新的待选事件向量hc1,hc2,……,hc5。As an example, after inputting the vectors of 8 initial background events and 5 initial background events and the adjacency matrix representing the relationship between these 13 events into the quadruple gate graph neural network, the new vectors of these 8 background events can be obtained background event vectors h 1 , h 2 , ..., h 8 , and new candidate event vectors h c1 , h c2 , ..., h c5 of the five candidate events.
S14:利用注意力神经网络对所述多个新的背景事件向量与所述多个新的待选事件向量进行计算,得到背景事件的整体向量。S14: Using the attention neural network to calculate the multiple new background event vectors and the multiple new candidate event vectors to obtain an overall vector of background events.
本实施例中,在得到多个新的背景事件向量与多个新的待选事件向量之后,使用注意力机制对背景事件向量和待选事件向量进行运算,可以考虑到每个背景事件对待选事件的影响。将多个背景事件融合为背景事件的整体向量,便于下一步计算。In this embodiment, after obtaining a plurality of new background event vectors and a plurality of new candidate event vectors, the attention mechanism is used to calculate the background event vectors and candidate event vectors, and it can be considered that each background event to be selected impact of the event. Merge multiple background events into an overall vector of background events, which is convenient for the next calculation.
本实施例中,利用注意力神经网络对所述多个新的背景事件向量与所述多个新的待选事件向量进行计算,得到背景事件的整体向量的具体步骤包括:In this embodiment, using the attention neural network to calculate the multiple new background event vectors and the multiple new candidate event vectors, the specific steps of obtaining the overall vector of the background event include:
S14-1:将所述多个新的背景事件向量与所述多个新的待选事件向量输入到所述注意力神经网络中。S14-1: Input the multiple new background event vectors and the multiple new candidate event vectors into the attention neural network.
本实施例中,注意力神经网络用于对输入的新的背景事件向量和新的待选事件向量进行注意力机制的计算。In this embodiment, the attention neural network is used to calculate the attention mechanism for the input new background event vector and the new candidate event vector.
S14-2:针对所述多个新的待选事件向量中的每一个新的待选事件向量,将所述多个新的背景事件向量中的每一个新的背景事件向量与其进行注意力机制的运算,得到所述多个新的背景事件向量中的每一个新的背景事向量相对于所述每一个新的待选事件向量的权重系数。S14-2: For each of the plurality of new event vectors to be selected, perform an attention mechanism on each of the plurality of new background event vectors with it operation to obtain the weight coefficient of each new background event vector in the plurality of new background event vectors relative to each new event vector to be selected.
本实施例中,每个背景事件对每个待选事件的有着不同程度的影响,为了将这种影响可以在向量计算中体现出来,本实施例使用了注意力神经网络对新的背景事件向量和新的待选事件向量进行计算。In this embodiment, each background event has a different degree of influence on each candidate event. In order to reflect this influence in the vector calculation, this embodiment uses the attention neural network to the new background event vector Calculate with the new event vector to be selected.
本实施例中,针对所述多个新的待选事件向量中的每一个新的待选事件向量,将所述多个新的背景事件向量中的每一个新的背景事件向量与其进行注意力机制的运算,得到所述多个新的背景事件向量中的每一个新的背景事向量相对于所述每一个新的待选事件向量的权重的具体方法是:In this embodiment, for each new event vector among the multiple new event vectors to be selected, attention is paid to each new background event vector among the multiple new background event vectors The operation of the mechanism, the specific method of obtaining the weight of each new background event vector in the plurality of new background event vectors relative to the weight of each new candidate event vector is:
uij=tanh(Whhi+Wchcj+bu) (7)u ij =tanh(W h h i +W c h cj +b u ) (7)
其中,uij表示第i个新的背景事件与第j个新的待选事件之间的分数,分数越高表示关联程度越大,tanh()表示四元组划分的tanh激活函数,Wh和Wc表示权重,bu表示偏置参数,αij表示第i个背景事件对于第j个待选事件的权重系数,exp(uij)表示e的uij次方,∑kexp(ukj)表示e的u1j次方到ukj次方之和。Among them, u ij represents the score between the i-th new background event and the j-th new candidate event, the higher the score, the greater the degree of association, tanh() represents the tanh activation function of the quadruple division, W h and W c represent the weight, b u represents the bias parameter, α ij represents the weight coefficient of the i-th background event for the j-th candidate event, exp(u ij ) represents the u ij power of e, ∑ k exp(u kj ) represents the sum of e from u 1j power to u kj power.
示例地,如图5所示,图5是本发明一实施例基于注意力机制的背景事件与待选事件进行注意力机制运算的示意图,当输入了8个背景事件与5个待选事件,则计算这8个背景事件对每一个待选事件的权重系数。For example, as shown in FIG. 5, FIG. 5 is a schematic diagram of an attention mechanism operation based on background events and candidate events of the attention mechanism in an embodiment of the present invention. When 8 background events and 5 candidate events are input, Then calculate the weight coefficient of these 8 background events for each event to be selected.
S14-3:根据所述权重系数,计算得到所述背景事件的整体向量。S14-3: Calculate and obtain an overall vector of the background event according to the weight coefficient.
本实施例中,根据所述权重系数,计算得到所述背景事件的整体向量的具体方法是:In this embodiment, according to the weight coefficient, the specific method for calculating the overall vector of the background event is:
其中,h表示背景事件的整体向量,αij表示第i个背景事件对于第j个待选事件的权重系数,hi表示第i个背景向量。Among them, h represents the overall vector of the background event, α ij represents the weight coefficient of the i-th background event for the j-th candidate event, and h i represents the i-th background vector.
示例地,当输入8个背景事件时,整体向量h就是这8个背景事件向量的加权求和。For example, when 8 background events are input, the overall vector h is the weighted sum of the 8 background event vectors.
S15:将所述整体向量与每个所述新的待选事件向量进行打分,将得分最高的待选事件向量对应的待选事件作为预测结果。S15: Score the overall vector and each of the new candidate event vectors, and use the candidate event corresponding to the candidate event vector with the highest score as a prediction result.
本实施例中,在得到背景事件的整体向量之后,可以通过将每个新的待选事件向量与背景事件向量进行打分来确定预测结果,即最有可能发生的事情。In this embodiment, after the overall vector of the background event is obtained, the prediction result, that is, the most likely event can be determined by scoring each new candidate event vector and the background event vector.
本实施例中,将所述整体向量与每个所述新的待选事件向量进行打分,将得分最高的待选事件向量对应的待选事件作为预测结果的步骤为:In this embodiment, the steps of scoring the overall vector and each of the new candidate event vectors, and taking the candidate event corresponding to the candidate event vector with the highest score as the prediction result are as follows:
S15-1:根据所述背景事件的整体向量,计算每个新的待选事件向量与所述背景事件的整体向量之间的欧氏距离,得到多个欧氏距离的值。S15-1: According to the overall vector of the background event, calculate the Euclidean distance between each new event vector to be selected and the overall vector of the background event to obtain a plurality of Euclidean distance values.
本实施例中,根据所述背景事件的整体向量,计算每个新的待选事件向量与所述背景事件的整体向量之间的欧氏距离,得到多个欧氏距离的值,计算的方法可以表示为:In this embodiment, according to the overall vector of the background event, the Euclidean distance between each new event vector to be selected and the overall vector of the background event is calculated to obtain the values of multiple Euclidean distances. The calculation method It can be expressed as:
其中,g()表示两个事件的欧几里得距离,sj表示两个事件的欧几里得距离,即欧氏距离。Among them, g() represents the Euclidean distance between two events, and s j represents the Euclidean distance between two events, that is, the Euclidean distance.
示例地,两个事件a,b的欧几里得距离可以表示为:As an example, the Euclidean distance between two events a and b can be expressed as:
g(a,b)=‖a-b‖ (11)g(a,b)=‖a-b‖ (11)
S15-2:选择多个欧氏距离的值中的最小值所对应的新的待选事件向量作为所述得分最高的待选事件向量,将所述得分最高的待选事件向量对应的待选事件作为预测结果。S15-2: Select the new candidate event vector corresponding to the minimum value among multiple Euclidean distance values as the candidate event vector with the highest score, and select the candidate event vector corresponding to the highest score candidate event vector events as predicted outcomes.
本实施例中,欧氏距离的值代表了两个向量之间的距离,欧氏距离的值越小,两个向量之间的距离越近,得分就越高,欧氏距离的值越大,得分就越低,可以见得,与背景事件整体向量距离最近的待选事件向量对应的待选事件就是预测得到的接下来最有可能发生的事件,也是得分最高的待选事件,即预测结果。In this embodiment, the value of the Euclidean distance represents the distance between two vectors, the smaller the value of the Euclidean distance, the closer the distance between the two vectors, the higher the score, and the larger the value of the Euclidean distance , the lower the score, it can be seen that the candidate event corresponding to the candidate event vector closest to the overall background event vector is the predicted next most likely event, and also the candidate event with the highest score, that is, the prediction result .
示例地,如图6所示,图6是本申请一实施例提出的基于加权求和后的背景事件与待选事件进行欧氏距离计算的打分模型示意图,其中分别求出了背景事件整体向量和5个待选事件之间的欧氏距离,得出了5个值,对这5个待选事件向量给出了5个分数。For example, as shown in Figure 6, Figure 6 is a schematic diagram of a scoring model for calculating the Euclidean distance based on the weighted and summed background events and candidate events proposed by an embodiment of the present application, in which the overall vector of the background event is obtained respectively and the Euclidean distance between the 5 candidate events, 5 values are obtained, and 5 scores are given for the 5 candidate event vectors.
示例地,向四元组门图神经网络中输入的背景事件为“我早晨起床”、“我洗脸刷牙”、“我吃了早饭”、“我背上书包”。待选事件为“我去上学”、“我去上班”、“我去看电影”。则四元组门图神经网络将这几个背景事件的向量融合为整体向量后,经过计算发现“我去上学”对应的向量与背景事件向量的欧氏距离最近,故预测的结果为“我去上学”。Exemplarily, the background events input into the quadruple gate diagram neural network are "I get up in the morning", "I wash my face and brush my teeth", "I have breakfast", "I carry my schoolbag". The events to be selected are "I go to school", "I go to work", "I go to the movies". After the quaternion gate diagram neural network fuses the vectors of these background events into an overall vector, it finds that the Euclidean distance between the vector corresponding to "I go to school" and the background event vector is the closest, so the predicted result is "I go to school".
如图7所示,图7是本申请一实施例提出的四元组门图神经网络的训练流程图。如图7所示,该方法包括以下步骤:As shown in FIG. 7 , FIG. 7 is a training flow chart of a quadruple gate graph neural network proposed by an embodiment of the present application. As shown in Figure 7, the method includes the following steps:
S21:收集多个相关事件,将所述多个相关事件中的一部分标注为背景事件,另一部分标注为待选事件,作为训练集。S21: Collect a plurality of related events, mark a part of the plurality of related events as background events, and mark the other part as candidate events, as a training set.
本实施例中,需要收集多个事件作为训练集来训练四元组门图神经网络,其中包括了背景事件和待选事件,将收集到的事件分为若干组,每一组中有多个背景事件与待选事件,将背景事件进行标注,将这些背景事件对应的正确的待选事件标注为正确待选事件,将剩余的待选事件不进行标注。In this embodiment, it is necessary to collect multiple events as a training set to train the quadruple gate graph neural network, which includes background events and candidate events, and the collected events are divided into several groups, each group has multiple Background events and candidate events, the background events are marked, the correct candidate events corresponding to these background events are marked as correct candidate events, and the remaining candidate events are not marked.
示例地,收集到的事件有若干个事件为“小李下课了”、“小李背上书包”、“小李走回宿舍”、“小李拿了篮球”,将这几个事件分为一组,标注为背景事件,这一组中再加入候选事件“小李去食堂吃饭”、“小李去球场打篮球”、“小李去上课”,将“小李去球场打篮球”标注为正确待选事件。For example, the collected events include several events such as "Xiao Li is out of class", "Xiao Li carries his schoolbag", "Xiao Li walks back to the dormitory", "Xiao Li took a basketball", and these events are divided into One group, marked as the background event, add candidate events "Xiao Li went to the cafeteria to eat", "Xiao Li went to the court to play basketball", "Xiao Li went to class", and marked "Xiao Li went to the court to play basketball" is the correct event to be selected.
S22:将所述训练集输入所述四元组门图神经网络之中对所述四元组门图神经网络进行训练,得到训练好的四元组门图神经网络。S22: Input the training set into the quadruple gate diagram neural network to train the quadruple gate diagram neural network to obtain a trained quadruple gate diagram neural network.
本实施例中,将训练集中的多组事件分组输入到四元组门图神经网络之中,对神经网络进行训练,其中目标优化函数为:In this embodiment, multiple groups of events in the training set are grouped and input into the quadruple gate graph neural network to train the neural network, wherein the objective optimization function is:
其中N代表背景事件的数量,k代表待选事件的数量,sIj表示第I个背景事件和第j个相对应的待选事件的相关度分数,y表示正确的待选事件的索引,margin是margin损失函数的参数,λ是L2正则化的参数,Θ代表模型的参数,该模型参数的优化基于RMSprop优化器。Among them, N represents the number of background events, k represents the number of candidate events, s Ij represents the correlation score between the i-th background event and the j-th corresponding candidate event, y represents the index of the correct candidate event, margin Is the parameter of the margin loss function, λ is the parameter of L2 regularization, Θ represents the parameter of the model, and the optimization of the model parameter is based on the RMSprop optimizer.
基于同一发明构思,本申请一实施例提供一种四元组门图神经网络事件预测装置300。参考图8,图8是本申请一实施例提出的四元组门图神经网络事件预测装置的示意图。如图8所示,该装置包括:Based on the same inventive concept, an embodiment of the present application provides a quadruple gate diagram neural network
事理图谱构成模块301,用于将多个初始背景事件与多个待选事件构成事理图谱;An event
四元组事件表示模块302,用于将所述事理图谱中的所述多个初始背景事件与多个初始待选事件的向量以四元组的形式进行表示,得到初始背景事件向量与初始待选事件向量;The quadruple
四元组门图神经网络模块303,用于使用四元组门图神经网络对所述事理图谱进行图网络计算,得到多个新的背景事件向量与多个新的待选事件向量;The quaternion gate diagram
基于注意力机制的背景融合模块304,用于利用注意力神经网络对所述多个新的背景事件向量与所述多个新的待选事件向量进行计算,得到背景事件的整体向量;The background fusion module 304 based on the attention mechanism is used to calculate the multiple new background event vectors and the multiple new candidate event vectors by using the attention neural network to obtain the overall vector of the background event;
背景事件与待选事件打分模块305,用于将所述整体向量与每个所述新的待选事件向量进行打分,将得分最高的待选事件向量对应的待选事件作为预测结果。The background event and candidate
可选地,所述事理图谱构成模块包括:Optionally, the constituting module of the event map includes:
关系设置子模块,用于设置多个初始背景事件与多个待选事件之间的关系;A relationship setting submodule, used to set the relationship between multiple initial background events and multiple events to be selected;
事理图谱构成子模块,用于以多个初始背景事件与多个待选事件为节点,以多个初始背景事件与多个待选事件之间的关系为边,构成事理图谱。The event map constitutes a sub-module, which is used to form an event map with multiple initial background events and multiple candidate events as nodes, and with relationships between multiple initial background events and multiple candidate events as edges.
可选地,所述四元组事件表示模块包括:Optionally, the quadruple event representation module includes:
四元组事件表示子模块,用于将包括所述多个初始背景事件与多个初始待选事件在内的所有事件的向量以v(es,eo,ep)的形式进行表示,其中v代表谓语动词,es代表主语,eo代表宾语,ep代表一个和谓语动词有介词关系的实体。The four-tuple event representation submodule is used to represent the vectors of all events including the multiple initial background events and multiple initial candidate events in the form of v( es , e o , e p ), Among them, v represents the predicate verb, es represents the subject, e o represents the object, and e p represents an entity that has a prepositional relationship with the predicate verb.
可选地,所述装置还包括:Optionally, the device also includes:
事件收集模块,用于收集多个相关事件,将所述多个相关事件中的一部分标注为背景事件,另一部分标注为待选事件,作为训练集;An event collection module, configured to collect a plurality of related events, mark a part of the plurality of related events as background events, and mark the other part as candidate events, as a training set;
四元组门图神经网络训练模块,用于将所述训练集输入所述四元组门图神经网络之中对所述四元组门图神经网络进行训练,得到训练好的四元组门图神经网络。The quadruple gate diagram neural network training module is used to input the training set into the quadruple gate diagram neural network to train the quadruple gate diagram neural network to obtain the trained quadruple gate Graph neural network.
可选地,所述四元组门图神经网络模块包括:Optionally, the quadruple gate graph neural network module includes:
第一向量输入子模块,用于将所述事理图谱中的事件的表示向量和代表事件之间的关系的邻接矩阵输入所述四元组门图神经网络中;The first vector input submodule is used to input the representation vector of the event in the event map and the adjacency matrix representing the relationship between the events into the quadruple gate graph neural network;
四原子门图神经网络计算子模块,用于所述四元组门图神经网络对所述事件的表示向量和所述邻接矩阵进行计算,得到所述多个新的背景事件向量与所述多个新的待选事件向量。The four-atom gate graph neural network calculation submodule is used for the quadruple gate graph neural network to calculate the representation vector and the adjacency matrix of the event, and obtain the multiple new background event vectors and the multiple a new event vector to be selected.
可选地,所述基于注意力机制的背景融合模块包括:Optionally, the background fusion module based on the attention mechanism includes:
第二向量输入子模块,用于将所述多个新的背景事件向量与所述多个新的待选事件向量输入到所述注意力神经网络中;The second vector input submodule is used to input the multiple new background event vectors and the multiple new candidate event vectors into the attention neural network;
权重系数计算子模块,用于针对所述多个新的待选事件向量中的每一个新的待选事件向量,将所述多个新的背景事件向量中的每一个新的背景事件向量与其进行注意力机制的运算,得到所述多个新的背景事件向量中的每一个新的背景事向量相对于所述每一个新的待选事件向量的权重系数;The weight coefficient calculation sub-module is used for combining each new background event vector among the multiple new background event vectors with each new candidate event vector among the multiple new candidate event vectors Perform an attention mechanism operation to obtain the weight coefficient of each new background event vector in the plurality of new background event vectors relative to each of the new candidate event vectors;
整体向量获得子模块,用于根据所述权重系数,计算得到所述背景事件的整体向量。The overall vector obtaining sub-module is used to calculate and obtain the overall vector of the background event according to the weight coefficient.
可选地,所述背景事件与待选事件打分模块包括:Optionally, the background event and candidate event scoring module includes:
欧氏距离计算子模块,用于根据所述背景事件的整体向量,计算每个新的待选事件向量与所述背景事件的整体向量之间的欧氏距离,得到多个欧氏距离的值;The Euclidean distance calculation submodule is used to calculate the Euclidean distance between each new event vector to be selected and the overall vector of the background event according to the overall vector of the background event, and obtain a plurality of Euclidean distance values ;
预测结果获得子模块,选择多个欧氏距离的值中的最小值所对应的新的待选事件向量作为所述得分最高的待选事件向量,将所述得分最高的待选事件向量对应的待选事件作为预测结果。The prediction result obtaining submodule selects the new candidate event vector corresponding to the minimum value among the values of multiple Euclidean distances as the candidate event vector with the highest score, and assigns the event vector corresponding to the highest score candidate event vector The event to be selected is used as the prediction result.
基于同一发明构思,本申请另一实施例提供一种可读存储介质,其上存储有计算机程序,该程序被处理器执行时实现如本申请上述任一实施例所述的四元组门图神经网络事件预测方法中的步骤。Based on the same inventive concept, another embodiment of the present application provides a readable storage medium, on which a computer program is stored, and when the program is executed by a processor, the quadruple gate diagram as described in any of the above-mentioned embodiments of the present application is realized. Steps in a neural network event prediction method.
基于同一发明构思,本申请另一实施例提供一种电子设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,所述处理器执行时实现本申请上述任一实施例所述的四元组门图神经网络事件预测方法中的步骤。Based on the same inventive concept, another embodiment of the present application provides an electronic device, including a memory, a processor, and a computer program stored on the memory and operable on the processor. The steps in the quadruple group gate diagram neural network event prediction method described in the embodiment.
对于装置实施例而言,由于其与方法实施例基本相似,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and for related parts, please refer to the part of the description of the method embodiment.
本说明书中的各个实施例均采用递进的方式描述,每个实施例重点说明的都是与其他实施例的不同之处,各个实施例之间相同相似的部分互相参见即可。Each embodiment in this specification is described in a progressive manner, each embodiment focuses on the difference from other embodiments, and the same and similar parts of each embodiment can be referred to each other.
本领域内的技术人员应明白,本申请实施例的实施例可提供为方法、装置、或计算机程序产品。因此,本申请实施例可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本申请实施例可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。Those skilled in the art should understand that the embodiments of the embodiments of the present application may be provided as methods, devices, or computer program products. Therefore, the embodiment of the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, embodiments of the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
本申请实施例是参照根据本申请实施例的方法、终端设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理终端设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理终端设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。Embodiments of the present application are described with reference to flowcharts and/or block diagrams of methods, terminal devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each procedure and/or block in the flowchart and/or block diagram, and a combination of procedures and/or blocks in the flowchart and/or block diagram can be realized by computer program instructions. These computer program instructions may be provided to a general purpose computer, special purpose computer, embedded processor or processor of other programmable data processing terminal equipment to produce a machine such that instructions executed by the computer or processor of other programmable data processing terminal equipment Produce means for realizing the functions specified in one or more procedures of the flowchart and/or one or more blocks of the block diagram.
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理终端设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing terminal to operate in a specific manner, such that the instructions stored in the computer-readable memory produce an article of manufacture comprising instruction means, the The instruction means implements the functions specified in one or more procedures of the flowchart and/or one or more blocks of the block diagram.
这些计算机程序指令也可装载到计算机或其他可编程数据处理终端设备上,使得在计算机或其他可编程终端设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程终端设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded into a computer or other programmable data processing terminal equipment, so that a series of operational steps are performed on the computer or other programmable terminal equipment to produce computer-implemented processing, thereby The instructions executed above provide steps for implementing the functions specified in one or more procedures of the flowchart and/or one or more blocks of the block diagram.
尽管已描述了本申请实施例的优选实施例,但本领域内的技术人员一旦得知了基本创造性概念,则可对这些实施例做出另外的变更和修改。所以,所附权利要求意欲解释为包括优选实施例以及落入本申请实施例范围的所有变更和修改。While the preferred embodiments of the embodiments of the present application have been described, additional changes and modifications can be made to these embodiments by those skilled in the art once the basic inventive concept is understood. Therefore, the appended claims are intended to be interpreted to cover the preferred embodiment and all changes and modifications that fall within the scope of the embodiments of the application.
最后,还需要说明的是,在本文中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者终端设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者终端设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、物品或者终端设备中还存在另外的相同要素。Finally, it should also be noted that in this text, relational terms such as first and second etc. are only used to distinguish one entity or operation from another, and do not necessarily require or imply that these entities or operations, any such actual relationship or order exists. Furthermore, the term "comprises", "comprises" or any other variation thereof is intended to cover a non-exclusive inclusion such that a process, method, article, or terminal equipment comprising a set of elements includes not only those elements, but also includes elements not expressly listed. other elements identified, or also include elements inherent in such a process, method, article, or terminal equipment. Without further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article or terminal device comprising said element.
以上对本申请所提供的一种四元组门图神经网络事件预测方法、装置、设备及介质,进行了详细介绍,本文中应用了具体个例对本申请的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本申请的方法及其核心思想;同时,对于本领域的一般技术人员,依据本申请的思想,在具体实施方式及应用范围上均会有改变之处,综上所述,本说明书内容不应理解为对本申请的限制。Above, a kind of quaternion gate diagram neural network event prediction method, device, equipment and medium provided by the application have been introduced in detail. In this paper, specific examples have been used to illustrate the principle and implementation of the application. The above implementation The description of the example is only used to help understand the method of the present application and its core idea; at the same time, for those of ordinary skill in the art, according to the idea of the application, there will be changes in the specific implementation and scope of application. In summary As stated above, the content of this specification should not be construed as limiting the application.
Claims (9)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110026128.5A CN112633483B (en) | 2021-01-08 | 2021-01-08 | Four-tuple gate diagram neural network event prediction method, device, equipment and medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110026128.5A CN112633483B (en) | 2021-01-08 | 2021-01-08 | Four-tuple gate diagram neural network event prediction method, device, equipment and medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112633483A CN112633483A (en) | 2021-04-09 |
CN112633483B true CN112633483B (en) | 2023-05-30 |
Family
ID=75293864
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110026128.5A Active CN112633483B (en) | 2021-01-08 | 2021-01-08 | Four-tuple gate diagram neural network event prediction method, device, equipment and medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112633483B (en) |
Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2020232943A1 (en) * | 2019-05-23 | 2020-11-26 | 广州市香港科大霍英东研究院 | Knowledge graph construction method for event prediction and event prediction method |
Family Cites Families (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20080126399A1 (en) * | 2006-06-29 | 2008-05-29 | Macgregor Robert M | Method and apparatus for optimizing data while preserving provenance information for the data |
CN101937430B (en) * | 2010-09-03 | 2015-04-15 | 清华大学 | Method for extracting event sentence pattern from Chinese sentence |
US10303999B2 (en) * | 2011-02-22 | 2019-05-28 | Refinitiv Us Organization Llc | Machine learning-based relationship association and related discovery and search engines |
-
2021
- 2021-01-08 CN CN202110026128.5A patent/CN112633483B/en active Active
Patent Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2020232943A1 (en) * | 2019-05-23 | 2020-11-26 | 广州市香港科大霍英东研究院 | Knowledge graph construction method for event prediction and event prediction method |
Also Published As
Publication number | Publication date |
---|---|
CN112633483A (en) | 2021-04-09 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN111078836B (en) | Machine reading comprehension method, system and device based on external knowledge enhancement | |
CN111079601A (en) | Video content description method, system and device based on multi-mode attention mechanism | |
CN110852419B (en) | An action model based on deep learning and its training method | |
CN109766557B (en) | A sentiment analysis method, device, storage medium and terminal equipment | |
CN115757804A (en) | A knowledge map extrapolation method and system based on multi-layer path perception | |
CN113988464B (en) | Network link attribute relation prediction method and device based on graph neural network | |
US11675951B2 (en) | Methods and systems for congestion prediction in logic synthesis using graph neural networks | |
CN112905801A (en) | Event map-based travel prediction method, system, device and storage medium | |
CN112560823B (en) | A face age estimation method with adaptive variance and weight based on distribution learning | |
CN113468291B (en) | Automatic patent classification method based on patent network representation learning | |
CN114331122A (en) | Key person risk level assessment method and related equipment | |
CN116541507A (en) | A visual question answering method and system based on dynamic semantic graph neural network | |
CN115238169A (en) | A MOOC interpretable recommendation method, terminal equipment and storage medium | |
CN112559640B (en) | Training method and device of atlas characterization system | |
CN112633483B (en) | Four-tuple gate diagram neural network event prediction method, device, equipment and medium | |
WO2025030812A1 (en) | Chip layout and training method, electronic device, storage medium, and chip system | |
CN118940840A (en) | A large language model joint reasoning method based on knowledge graph enhanced thought chain prompts | |
US20250036989A1 (en) | Efficient hamiltonian exponentiation in a quantum circuit | |
CN115952438B (en) | Social platform user attribute prediction method, system, mobile device and storage medium | |
CN115146180B (en) | Friend and interest point recommendation method and terminal | |
CN112750042B (en) | Data processing method, device and electronic equipment | |
CN115393661A (en) | Adaptive context modeling method and device for scene graph generation | |
CN110580261B (en) | An in-depth technology tracking method for high-tech companies | |
Nagy et al. | Improving the sample-efficiency of neural architecture search with reinforcement learning | |
Benmeziane | Efficient hardware-aware neural architecture search for edge computing |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |