WO2023226292A1 - 从文本中进行关系抽取的方法、关系抽取模型及介质 - Google Patents

从文本中进行关系抽取的方法、关系抽取模型及介质 Download PDF

Info

Publication number
WO2023226292A1
WO2023226292A1 PCT/CN2022/127696 CN2022127696W WO2023226292A1 WO 2023226292 A1 WO2023226292 A1 WO 2023226292A1 CN 2022127696 W CN2022127696 W CN 2022127696W WO 2023226292 A1 WO2023226292 A1 WO 2023226292A1
Authority
WO
WIPO (PCT)
Prior art keywords
word
vector
entity word
entity
knowledge
Prior art date
Application number
PCT/CN2022/127696
Other languages
English (en)
French (fr)
Other versions
WO2023226292A9 (zh
Inventor
宋彦
田元贺
Original Assignee
苏州思萃人工智能研究所有限公司
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by 苏州思萃人工智能研究所有限公司 filed Critical 苏州思萃人工智能研究所有限公司
Publication of WO2023226292A1 publication Critical patent/WO2023226292A1/zh
Publication of WO2023226292A9 publication Critical patent/WO2023226292A9/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/205Parsing
    • G06F40/211Syntactic parsing, e.g. based on context-free grammar [CFG] or unification grammars
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/279Recognition of textual entities

Definitions

  • This application relates to the field of language processing technology, for example, to methods of relation extraction from text, relation extraction models and media.
  • Deep learning methods are gradually applied in relationship extraction. It can automatically extract text features based on the characteristics of the task, eliminating the huge cost of manual design and feature extraction.
  • the recognition effect of the relationship extraction method based on deep learning far exceeds that of traditional methods.
  • the operation method of adding syntactic knowledge to the relationship extraction method based on deep learning is generally to input the syntactic knowledge obtained through automatic methods into the embedding layer, map it into a knowledge vector in a high-dimensional continuous space, and directly connect the knowledge vector with the word vector.
  • this method of directly concatenating knowledge vectors and word vectors does not take into account the differences in the contributions of different knowledge to relationship labels. This will cause knowledge that contributes little or inaccurate knowledge obtained through automatic methods to predict relationships in the model. Labels can be misleading to the model. In this way, this inaccurate knowledge will have a negative impact on the relationship extraction model and affect the prediction results.
  • This application provides a method, a relationship extraction model, and a medium for extracting relationships from text to solve the problem that the prediction results of the method for extracting relationships from text are not accurate enough.
  • This application provides a method for extracting relationships from text, including:
  • the result vectors corresponding to the words are concatenated, and the concatenated result vectors are decoded to obtain the extracted relationship.
  • the preset information is obtained from the preset text, and the preset information is preprocessed to obtain a word vector containing contextual information of each entity word, including:
  • the contextual features in the context feature sequence K i are marked as k i,j
  • the syntactic knowledge in the syntactic knowledge sequence Vi is marked as vi ,i
  • i is the number of the entity word
  • j is the number of the entity word.
  • the number of contextual features and/or syntactic knowledge corresponding to the entity word x i , i ⁇ [1, n], j ⁇ [1, m]; n and m are both positive integers
  • n is the word sequence X included in The number of entity words, the number of contextual features corresponding to the entity word x i and the number of syntactic knowledge are m;
  • the entity word x i is combined with the context feature sequence K i corresponding to the entity word x i to obtain a word vector h i containing the context information of the entity word x i .
  • combining the entity word xi with the context feature sequence K i corresponding to the entity word xi to obtain a word vector hi containing the context information of the entity word xi includes:
  • the word vector The context feature sequence K i corresponding to the entity word xi is combined to obtain a word vector hi containing the context information of the entity word xi .
  • the contextual features corresponding to each entity word are used to weight the syntactic knowledge corresponding to each entity word to obtain a weighted knowledge vector corresponding to each entity word; each entity word is The corresponding weighted knowledge vector is concatenated with the word vector containing the contextual information of each entity word to obtain the result vector corresponding to each entity word, including:
  • the context feature sequence K i is mapped into a context feature embedding vector through the key-value memory neural network module Map the syntactic knowledge sequence V i into a knowledge embedding vector
  • Keys are mapped to the contextual feature embedding vectors through the key-value memory neural network module Map values to said knowledge embedding vector
  • the knowledge vector a i containing the information of contextual features and syntactic knowledge corresponding to the entity word x i is concatenated with the word vector h i containing the contextual information of the entity word x i , and we obtain The new vector o i , where, is the concatenation symbol.
  • decoding the concatenated result vector includes:
  • the concatenated result vector is decoded through the Decoder function to obtain the extracted relationship.
  • the method for extracting relationships from text also includes:
  • optimizing the method of extracting relationships from text based on comparison results includes:
  • the process until the comparison result reaches the predetermined standard includes:
  • This application also provides a relationship extraction model, which is configured to implement the method of extracting relationships from text as described above.
  • the relationship extraction model includes an embedding layer, a context information encoding layer, a key-value memory neural network module, and an output layer;
  • the embedding layer is configured to map the preprocessed result code into a high-dimensional word vector
  • the context information encoding layer is configured to process the word vector and the context features corresponding to the word vector, and compile the word vector containing the context information;
  • the key-value memory neural network module is configured to obtain a weighted knowledge vector, and concatenate the weighted knowledge vector with the word vector containing contextual information to obtain a result vector;
  • the output layer is configured to decode and output the extracted relationship regarding the relationship extraction according to the result vector.
  • This application also provides a device for extracting relationships from text, which is applied to the relationship extraction model, including:
  • the first module is configured to obtain preset information from the preset text and preprocess the preset information to obtain a word vector containing contextual information of each entity word, where the preset information includes different entities Words, contextual features corresponding to each entity word, and syntactic knowledge corresponding to each entity word;
  • the second module is configured to use the contextual features corresponding to each entity word to weight the syntactic knowledge corresponding to each entity word to obtain the weighted knowledge vector corresponding to each entity word;
  • the weighted knowledge vector is concatenated with the word vector containing the contextual information of each entity word to obtain the result vector corresponding to each entity word;
  • the third module is configured to concatenate the result vectors corresponding to different entity words in the preset text, and decode the concatenated result vectors to obtain the extracted relationship.
  • This application also provides an electronic device, including a processor and a memory.
  • the computer program in the memory is executed by the processor, the above-mentioned method of extracting relationships from text is implemented.
  • the present application also provides a computer-readable storage medium.
  • a computer program is stored on the computer-readable storage medium.
  • the method for extracting relationships from text is implemented as described above.
  • Figure 1 is a flow chart of a method for extracting relationships from text provided by an embodiment of the present application
  • Figure 2 is a flow chart of another method for extracting relationships from text provided by an embodiment of the present application.
  • Figure 3 is a schematic diagram of a method for extracting relationships from text provided by an embodiment of the present application.
  • Figure 4 is a schematic diagram of a key-value memory neural network module in a relationship extraction model provided by an embodiment of the present application
  • Figure 5 is a schematic structural diagram of a device for extracting relationships from text provided by an embodiment of the present application.
  • FIG. 6 is a schematic structural diagram of an electronic device provided by an embodiment of the present application.
  • Step S1 Obtain the preset information from the preset text, and preprocess the preset information to obtain a word vector containing the context information of each entity word.
  • the preset information includes different entity words and the context corresponding to each entity word. Features and syntactic knowledge corresponding to each entity word.
  • Step S2 Use the contextual features corresponding to each entity word to weight the syntactic knowledge corresponding to the entity word to obtain the weighted knowledge vector corresponding to the entity word, and compare the weighted knowledge vector corresponding to the entity word with the weighted knowledge vector containing the entity The word vectors of the context information of the word are concatenated to obtain the result vector corresponding to the entity word.
  • Step S3 Concatenate the result vectors corresponding to different entity words in the preset text, and decode the concatenated result vectors to obtain the extracted relationship.
  • This method uses the contextual features corresponding to each entity word to weight the syntactic knowledge corresponding to the entity word, which can effectively avoid knowledge that contributes little or inaccurate knowledge obtained through automatic methods when the model predicts relationship labels. Misleading the model, thereby improving the accuracy of prediction results of relationship extraction methods from text, and helping to improve the performance of relationship extraction models.
  • the algorithm steps of the relationship extraction model for general relationship extraction tasks are as follows: input the preset text into the embedding layer, and each word in the text is converted into an input word vector representing the characteristics of the word, forming a word sequence. Input all word vectors in the converted word sequence into the context information encoding layer, and output a word vector containing context information for each word. Input the word vectors containing contextual information corresponding to the given two words (entities) output in the previous step into the decoding output layer. The word vectors of the two words are concatenated in the decoding output layer, and then the two predicted words are output through the softmax function. Labels for relationships between words. Compare the predicted relationship labels with the manual annotation results and calculate the objective function; by optimizing the objective function, update the network parameters of the relationship extraction model for the relationship extraction task.
  • this embodiment effectively uses contextual features to weight syntactic knowledge, thereby using syntactic knowledge to improve the performance of the model on the relationship extraction task.
  • Step S1 includes the following steps:
  • Step S11 Obtain the word sequence X from the preset text, and obtain the corresponding contextual features and corresponding syntactic knowledge from the preset text for each entity word xi in the word sequence
  • Step S12 Based on the acquired word sequence, contextual features and syntactic knowledge, for each entity word x i , construct a corresponding contextual feature sequence K i and a syntactic knowledge sequence V i , where the contextual feature in the context feature sequence K i Denoted as k i,j , the syntactic knowledge in the syntactic knowledge sequence V i is denoted as vi ,i , i is the number of the entity word, j is the number of the contextual feature and/or syntactic knowledge corresponding to the entity word x i , i ⁇ [1, n], j ⁇ [1, m]; n and m are positive integers; n is the number of entity words included in the word sequence X, the number of contextual features and syntactic knowledge corresponding to the entity word x i The quantity is m.
  • Step S13 Combine the entity word x i with the corresponding context feature sequence K i to obtain a word vector h i containing context information.
  • a corresponding context feature sequence K i and a syntactic knowledge sequence V i are constructed to facilitate quick call-up of the corresponding context features, denoted as k i,j , and syntactic knowledge, denoted as v i,j , in subsequent steps.
  • step S11 is implemented through an automatic acquisition tool.
  • the corresponding step of preprocessing is S13, including the following steps:
  • Step S131 Input all entity words x i into the embedding layer, and convert all entity words x i into word vectors in the embedding layer
  • Step S132 Convert all word vectors And the context information is input to the context information encoding layer Encoder, and then a word vector h i containing contextual information is output through the context information encoding layer Encoder.
  • the word vector is denoted as Among them, E x represents the preset entity word embedding function; the superscript x represents is the vector related to the entity word xi .
  • the contextual feature embedding vector is denoted as Among them, E k represents the preset contextual feature embedding function; the superscript k represents is a vector related to context features k i,j .
  • the syntactic knowledge embedding vector is denoted as Among them, E v represents the preset syntactic knowledge embedding function; the superscript v represents is a vector related to syntactic knowledge v i,j
  • the word vector containing contextual information is denoted as
  • Step S2 includes the following steps:
  • Step S21 Input the word vector h i containing contextual information corresponding to each entity word x i in the preset text, and all contextual feature sequences K i and syntactic knowledge sequence V i corresponding to the entity word x i into the key-value memory.
  • Neural network module Input the word vector h i containing contextual information corresponding to each entity word x i in the preset text, and all contextual feature sequences K i and syntactic knowledge sequence V i corresponding to the entity word x i into the key-value memory.
  • Step S22 Map the context feature sequence K i into a context feature embedding vector through the key-value memory neural network module Map syntactic knowledge sequence V i into knowledge embedding vector
  • Step S23 Map keys to contextual feature embedding vectors through the key-value memory neural network module Map values to knowledge embedding vectors
  • Step S24 Use the key-value conversion in the key-value memory neural network module to embed the vector with the contextual features after mapping the key
  • Weighting is performed to obtain a weighted knowledge vector a i .
  • the weighted knowledge vector a i contains information on both contextual features and syntactic knowledge.
  • Step S25 Through the key-value memory neural network module, for all entity words x i in the preset text, combine the knowledge vector a i containing the information of contextual features and syntactic knowledge with the words containing the contextual information of the entity word x i The vectors h i are concatenated to obtain a new vector in, is the concatenation symbol.
  • the keys are mapped to contextual features through the key-value memory neural network module, and the values are mapped to the syntactic knowledge corresponding to these features. Then, through the conversion between key and value, the contextual features corresponding to each entity word are used to assign the entity word to the entity word.
  • the corresponding syntactic knowledge is weighted to avoid knowledge that contributes little or inaccurate knowledge obtained through automatic methods from misleading the model when predicting relationship labels, thereby helping to improve the performance of the relationship extraction model.
  • the key-value conversion formula is:
  • the expression of the vector a i containing information about contextual features and syntactic knowledge is:
  • This embodiment uses the Decoder function to decode the concatenated result vectors to obtain the extracted relationship.
  • This method of extracting relationships from text also includes:
  • Step S4 Compare the extracted relationship with the real result, and optimize the method based on the comparison result until the comparison result reaches the predetermined standard.
  • the extracted relationship is represented by y′
  • the real result is represented by y
  • the predetermined standard is that the predicted relationship between the two entity words is consistent with the actual relationship between the two entity words.
  • step S4 including the following steps:
  • Step S41 Calculate the result of the objective function based on the comparison result; update the parameters of the relationship extraction model by comparing the result of the objective function with the preset range.
  • the objective function uses the cross-entropy loss function.
  • the parameters of the updated relationship extraction model include all parameters of the relationship extraction model used to perform the above method of relationship extraction from text.
  • the embodiment of the present application also provides a relationship extraction model, which is configured to implement the above method of relationship extraction from text.
  • This relationship extraction model includes an embedding layer 1, a context information encoding layer 2, a key -Value memory neural network module 3 and output layer 4; embedding layer 1 is set to encode and map the preprocessing result into a high-dimensional vector; context information encoding layer 2 is set to process word vectors and corresponding context features, and compile to obtain context information The word vector; the key-value memory neural network module 3 is set to obtain the weighted knowledge vector, and then concatenate it with the word vector containing contextual information to obtain the result vector; the output layer 4 is set to decode and output the extracted relationship about the relationship extraction.
  • entity words, contextual features and syntactic knowledge are all input into the relationship extraction model through embedding layer 1; the entity words x i are converted into word vectors This step is completed in embedded layer 1.
  • converting contextual features into contextual feature embedding vectors, converting syntactic knowledge into syntactic knowledge embedding vectors, and implementing weighting through key-value conversion are all implemented by the key-value memory neural network module 3 .
  • the embodiment of the present application also provides a device for extracting relationships from text, which is applied to a relationship extraction model and includes: a first module 10, configured to obtain preset information from preset text, and The preset information is preprocessed to obtain a word vector containing contextual information of each entity word, where the preset information includes different entity words, contextual features corresponding to each entity word, and syntax corresponding to each entity word.
  • a first module 10 configured to obtain preset information from preset text
  • the preset information is preprocessed to obtain a word vector containing contextual information of each entity word, where the preset information includes different entity words, contextual features corresponding to each entity word, and syntax corresponding to each entity word.
  • the second module 20 is configured to use the contextual features corresponding to each entity word to weight the syntactic knowledge corresponding to each entity word to obtain the weighted knowledge vector corresponding to each entity word;
  • the weighted knowledge vector corresponding to the entity word is concatenated with the word vector containing the contextual information of each entity word to obtain the result vector corresponding to each entity word;
  • the third module 30 is configured to convert the preset text into The result vectors corresponding to different entity words are concatenated, and the concatenated result vectors are decoded to obtain the extracted relationship.
  • the first module 10 is configured as:
  • n is the word sequence X including The number of entity words, the number of contextual features corresponding to the entity word x i and the number of syntactic knowledge are m; combine the entity word x i with the context feature sequence K i corresponding to the entity word x i to obtain the The word vector h i of the contextual information of the entity word x i .
  • the first module 10 is configured to combine the entity word xi with the context feature sequence K i corresponding to the entity word xi in the following manner to obtain a word vector containing the context information of the entity word xi h i :
  • the second module 20 is configured as:
  • the third module 30 is configured to decode the concatenated result vector in the following manner:
  • the concatenated result vector is decoded through the Decoder function.
  • the device further includes a fourth module configured to:
  • the fourth module is configured to optimize the method of extracting relationships from text according to the comparison results in the following manner:
  • until the comparison result reaches the predetermined standard includes: until the result of the cross-entropy loss function is within a preset range.
  • the embodiment of the present application also provides an electronic device, including a processor 110 and a memory 120.
  • a processor 110 executes the computer program in the memory 120.
  • the above-mentioned relationship extraction from text is implemented. Methods.
  • Embodiments of the present application also provide a computer-readable storage medium.
  • a computer program is stored on the computer-readable storage medium.
  • the computer program is executed by a processor, the above method of extracting relationships from text is implemented.
  • the storage medium may be a non-transitory storage medium.
  • the method of extracting relationships from text in this application includes: obtaining preset information from preset text, and preprocessing the preset information to obtain a word vector containing contextual information of each entity word, Wherein, the preset information includes different entity words, contextual features corresponding to each entity word, and syntactic knowledge corresponding to each entity word; using the contextual features corresponding to each entity word, the syntactic knowledge corresponding to each entity word is used Weighting is performed to obtain the weighted knowledge vector corresponding to each entity word; the weighted knowledge vector corresponding to each entity word is concatenated with the word vector containing the context information of each entity word to obtain the weighted knowledge vector corresponding to each entity word.
  • Result vectors corresponding to each entity word concatenate the result vectors corresponding to different entity words in the preset text, and decode the concatenated result vectors to obtain the extracted relationship.
  • This method uses the contextual features corresponding to each entity word to weight the syntactic knowledge corresponding to the entity word, which can effectively avoid knowledge that contributes little or inaccurate knowledge obtained through automatic methods from affecting the model when predicting relationship labels. Causes misleading, thereby improving the accuracy of prediction results of relationship extraction methods from text, and helping to improve the performance of relationship extraction models.
  • preset information is obtained from the preset text, and the preset information is preprocessed to obtain a word vector containing contextual information of each entity word, including: obtaining words from the preset text Sequence X, and for each entity word xi in the word sequence Word x i constructs its corresponding context feature sequence K i and syntactic knowledge sequence V i .
  • the context features in the context feature sequence K i are denoted k i,j
  • the syntactic knowledge in the syntactic knowledge sequence V i is denoted vi , j , where i is the number of the entity word, j is the number of the contextual features and/or syntactic knowledge corresponding to the entity word x i , i ⁇ [1, n], j ⁇ [1, m]; n and m are positive Integer; combine the entity word x i with the corresponding context feature sequence K i to obtain the word vector h i containing context information.
  • a corresponding context feature sequence K i and a syntactic knowledge sequence V i are constructed to facilitate quick call-up of the corresponding context features, denoted as k i,j , and syntactic knowledge, denoted as v i,j , in subsequent steps.
  • the combination of the entity word xi and the corresponding context feature sequence K i to obtain the word vector h i containing contextual information includes: converting the entity word xi into a word vector convert word vectors Combined with the corresponding context feature sequence K i , a word vector h i containing context information is obtained. Convert the entity words x i into vectors before combining, which can facilitate operations.
  • the keys are mapped to contextual features through the key-value memory neural network module, and the values are mapped to the syntactic knowledge corresponding to these features, and then through the conversion between keys and values, the contextual features are used to give them
  • the corresponding syntactic knowledge is weighted to avoid knowledge that contributes little or inaccurate knowledge obtained by automatic methods from misleading the model when predicting relationship labels, thereby helping to improve the performance of the relationship extraction model.
  • the concatenated result vectors are decoded through the Decoder function to obtain the extracted relationship. This design is conducive to improving the accuracy of the extraction results.
  • the method will also be optimized to improve the accuracy of the prediction results of the relationship extraction method from text and improve the performance of the relationship extraction model.
  • the method of extracting relationships from text is optimized through the cross-entropy loss function until the cross-entropy value is within the preset range.
  • the optimization effect is good and is conducive to improving the accuracy of the extraction results.
  • This application also provides a relationship extraction model, which has the same effect as the above-mentioned method of relationship extraction from text.
  • This application also provides a computer-readable storage medium, which has the same effect as the above method of extracting relationships from text.
  • This application also provides a device and electronic equipment for extracting relationships from text, which have the same effect as the above method of extracting relationships from text.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Machine Translation (AREA)

Abstract

本申请提供从文本中进行关系抽取的方法、关系抽取模型及介质。从文本中进行关系抽取的方法包括:从预设文本中获取预设信息,并对预设信息进行预处理,得到含有每个实体词语的上下文信息的词语向量,预设信息包括不同实体词语、每个实体词语对应的上下文特征及句法知识;利用每个实体词语对应的上下文特征对该实体词语对应的句法知识进行加权,得到加权后的知识向量;把每个实体词语对应的加权后的知识向量与含有该实体词语对应的上下文信息的词语向量串联得到结果向量;把预设文本中不同实体词语对应的结果向量串联,并对串联的结果向量进行解码,从而得到抽取的关系。

Description

从文本中进行关系抽取的方法、关系抽取模型及介质
本申请要求在2022年05月07日提交中国专利局、申请号为202210584720.1的中国专利申请的优先权,该申请的全部内容通过引用结合在本申请中。
技术领域
本申请涉及语言处理技术领域,例如涉及从文本中进行关系抽取的方法、关系抽取模型及介质。
背景技术
深度学习方法被逐渐应用在关系抽取中。其能够依据任务的特点,自动实现对文本特征的提取,免去了人工设计、提取特征的巨大成本。使得基于深度学习的关系抽取方法的识别效果远远超过了传统的方法。
但由于已标注文本的数量往往不足以支持充分地训练深度学习模型,而传统方法中引入外部句法知识提升关系抽取任务的做法的有效性已经被证明,所以,外部句法知识也被利用在基于深度学习的模型中。将句法知识加入至基于深度学习的关系抽取方法的操作方式一般是把通过自动方法获取的句法知识输入嵌入层,并映射为高维连续空间的知识向量,并把知识向量与词语向量直接串联。然而,这种把知识向量与词语向量直接串联的方法,没有考虑不同的知识对关系标签的贡献的差异,这会使得那些贡献小的知识或者通过自动方法获取的不准确的知识在模型预测关系标签时对模型造成误导。这样一来,这种不准确的知识将会对关系抽取模型产生负面的影响,影响预测结果。
发明内容
本申请提供了从文本中进行关系抽取的方法、关系抽取模型及介质,以解决从文本中进行关系抽取的方法的预测结果不够准确的问题。
本申请提供一种从文本中进行关系抽取的方法,包括:
从预设文本中获取预设信息,并对所述预设信息进行预处理,得到含有每个实体词语的上下文信息的词语向量,其中,所述预设信息包括不同实体词语、每个实体词语对应的上下文特征及每个实体词语对应的句法知识;利用每个实体词语对应的上下文特征对所述每个实体词语对应的句法知识进行加权,得到所述每个实体词语对应的加权后的知识向量;把每个实体词语对应的加权后的知识向量与含有所述每个实体词语的上下文信息的词语向量串联得到所述每个 实体词语对应的结果向量;把所述预设文本中不同实体词语对应的结果向量串联,并对串联的结果向量进行解码,得到抽取的关系。
一实施例中,所述从预设文本中获取预设信息,并对所述预设信息进行预处理,得到含有每个实体词语的上下文信息的词语向量,包括:
从所述预设文本中获取词语序列X,并针对所述词语序列X内的实体词语x i从所述预设文本中获取与所述实体词语x i对应的上下文特征和句法知识;
基于获取的所述词语序列X、实体词语x i对应的上下文特征及句法知识,针对实体词语x i构建与所述实体词语x i相对应的上下文特征序列K i以及句法知识序列V i,其中,所述上下文特征序列K i中的上下文特征记为k i,j,所述句法知识序列V i中的句法知识记为v i,i,i为所述实体词语的编号,j为与所述实体词语x i对应的上下文特征和/或句法知识的编号,i∈[1、n],j∈[1、m];n与m均为正整数;n为所述词语序列X包括的实体词语的数量,实体词语x i对应的上下文特征的数量和句法知识的数量为m;
将实体词语x i与所述实体词语x i相对应的上下文特征序列K i相结合得到含有所述实体词语x i的上下文信息的词语向量h i
一实施例中,所述将实体词语x i与所述实体词语x i相对应的上下文特征序列K i相结合得到含有所述实体词语x i的上下文信息的词语向量h i,包括:
将所述实体词语x i转换为词语向量
Figure PCTCN2022127696-appb-000001
将所述词语向量
Figure PCTCN2022127696-appb-000002
与所述实体词语x i相对应的上下文特征序列K i相结合得到含有所述实体词语x i的上下文信息的词语向量h i
一实施例中,所述利用每个实体词语对应的上下文特征对所述每个实体词语对应的句法知识进行加权,得到所述每个实体词语对应的加权后的知识向量;把每个实体词语对应的加权后的知识向量与含有所述每个实体词语的上下文信息的词语向量串联得到所述每个实体词语对应的结果向量,包括:
将含有实体词语x i的上下文信息的词语向量h i和与所述实体词语x i相对应的上下文特征序列K i以及句法知识序列V i输入键-值记忆神经网络模块;
通过所述键-值记忆神经网络模块将所述上下文特征序列K i映射为上下文特征嵌入向量
Figure PCTCN2022127696-appb-000003
将所述句法知识序列V i映射为知识嵌入向量
Figure PCTCN2022127696-appb-000004
通过所述键-值记忆神经网络模块将键映射到所述上下文特征嵌入向量
Figure PCTCN2022127696-appb-000005
将值映射到所述知识嵌入向量
Figure PCTCN2022127696-appb-000006
利用所述键-值记忆神经网络模块中的键-值之间的转换,用映射键后的所述上下文特征嵌入向量
Figure PCTCN2022127696-appb-000007
来给映射值后的所述知识嵌入向量
Figure PCTCN2022127696-appb-000008
进行加权,得到加权后的知识向量a i,其中,所述加权后的知识向量a i包含上下文特征和句法知识 的信息;
通过所述键-值记忆神经网络模块,把实体词语x i对应的包含上下文特征和句法知识的信息的知识向量a i与含有所述实体词语x i的上下文信息的词语向量h i串联,得到新的向量o i,其中,
Figure PCTCN2022127696-appb-000009
为串联符号。
一实施例中,所述对串联的结果向量进行解码,包括:
通过Decoder函数对串联的结果向量其进行解码,从而得到抽取的关系。
一实施例中,本从文本中进行关系抽取的方法还包括:
把所述抽取关系与真实结果做比对,根据对比结果对所述从文本中进行关系抽取的方法进行优化,直至对比结果达到预定标准。
一实施例中,所述根据对比结果对所述从文本中进行关系抽取的方法进行优化,包括:
根据所述对比结果计算交叉熵损失函数的结果;
在所述交叉熵损失函数的结果未在预设范围的情况下,更新所述从文本中进行关系抽取的方法中的多项参数;
所述直至对比结果达到所述预定标准,包括:
直到交叉熵损失函数的结果在所述预设范围内。
本申请还提供一种关系抽取模型,设置为实现如上所述的从文本中进行关系抽取的方法,本关系抽取模型包括嵌入层、上下文信息编码层、键-值记忆神经网络模块以及输出层;
所述嵌入层设置为将预处理的结果编码映射为高维的词语向量;
所述上下文信息编码层设置为处理所述词语向量与所述词语向量对应的上下文特征,编译得到含有上下文信息的词语向量;
所述键-值记忆神经网络模块设置为获取加权后的知识向量,并将所述加权后的知识向量与所述含有上下文信息的词语向量串联得到结果向量;
所述输出层设置为根据所述结果向量解码输出关于关系抽取的抽取关系。
本申请还提供一种从文本中进行关系抽取的装置,应用于关系抽取模型,包括:
第一模块,设置为从预设文本中获取预设信息,并对所述预设信息进行预处理,得到含有每个实体词语的上下文信息的词语向量,其中,所述预设信息包括不同实体词语、每个实体词语对应的上下文特征及每个实体词语对应的句法知识;
第二模块,设置为利用每个实体词语对应的上下文特征对所述每个实体词语对应的句法知识进行加权,得到所述每个实体词语对应的加权后的知识向量;把每个实体词语对应的加权后的知识向量与含有所述每个实体词语的上下文信息的词语向量串联得到所述每个实体词语对应的结果向量;
第三模块,设置为把所述预设文本中不同实体词语对应的结果向量串联,并对串联的结果向量进行解码,得到抽取的关系。
本申请还提供一种电子设备,包括处理器以及存储器,所述存储器中的计算机程序被所述处理器执行时实现上述的从文本中进行关系抽取的方法。
本申请还提供一种计算机可读储存介质,所述计算机可读存储介质上存储计算机程序,所述计算机程序被处理器执行时实现如上所述的从文本中进行关系抽取的方法。
附图说明
图1是本申请实施例提供的一种从文本中进行关系抽取的方法的流程图;
图2是本申请实施例提供的另一种从文本中进行关系抽取的方法的流程图;
图3是本申请实施例提供的一种从文本中进行关系抽取的方法的示意图;
图4是本申请实施例提供的一种关系抽取模型中键-值记忆神经网络模块的示意图;
图5是本申请实施例提供的一种从文本中进行关系抽取的装置的结构示意图;
图6是本申请实施例提供的一种电子设备的结构示意图。
具体实施方式
以下结合附图及实施实例,对本申请进行说明。此处所描述的具体实施例仅仅用以解释本申请。
请结合图1至图3,本申请实施例提供一种从文本中进行关系抽取的方法,包括以下步骤:
步骤S1:从预设文本中获取预设信息,并对预设信息进行预处理,得到含有每个实体词语的上下文信息的词语向量,预设信息包括不同实体词语、每个实体词语对应的上下文特征及每个实体词语对应的句法知识。
步骤S2:利用每个实体词语对应的上下文特征对该实体词语对应的句法知识进行加权,得到该实体词语对应的加权后的知识向量,把该实体词语对应的加权后的知识向量与含有该实体词语的上下文信息的词语向量串联得到该实体 词语对应的结果向量。
步骤S3:把预设文本中不同实体词语对应的结果向量串联,并对串联的结果向量进行解码,得到抽取的关系。
本方法通过利用每个实体词语对应的上下文特征给该实体词语对应的所对应的句法知识加权,能有效地避免那些贡献小的知识或者通过自动方法获取的不准确的知识在模型预测关系标签时对模型造成误导,从而提高从文本中进行关系抽取的方法的预测结果的准确性,帮助提升关系抽取模型的性能。
一般的关系抽取任务的关系抽取模型的算法步骤如下:把预设文本输入嵌入层,文本中的每个词被转化为一个代表这个词的特征的输入词向量,形成词序列。把转换后的词序列中的所有词向量输入上下文信息编码层,对每个词输出一个含有上下文信息的词向量。把上一步输出的给定的两个词(实体)对应的含有上下文信息的词向量输入解码输出层,两个词的词向量在解码输出层中被串联,而后通过softmax函数,输出预测的两个词之间关系的标签。把预测的关系标签与人工标注的结果做比对,计算目标函数;通过优化目标函数,更新关系抽取任务的关系抽取模型的网络参数。
本实施例在深度学习的框架下,有效地利用上下文特征对句法知识进行了加权,从而利用句法知识,提高模型在关系抽取任务上的性能。
步骤S1包括以下步骤:
步骤S11:从预设文本中获取词语序列X,并针对词语序列X内的每个实体词语x i从预设文本中获取与其对应的上下文特征和对应的句法知识。
步骤S12:基于获取的词语序列、上下文特征及句法知识,针对每个实体词语x i构建与其相对应的上下文特征序列K i以及句法知识序列V i,其中,上下文特征序列K i中的上下文特征记为k i,j,句法知识序列V i中的句法知识记为v i,i,i为实体词语的编号,j为与实体词语x i对应的上下文特征和/或句法知识的编号,i∈[1、n],j∈[1、m];n与m为正整数;n为所述词语序列X包括的实体词语的数量,实体词语x i对应的上下文特征的数量和句法知识的数量为m。
步骤S13:将实体词语x i与相对应的上下文特征序列K i相结合得到含有上下文信息的词语向量h i
针对每个实体词语x i构建对应的上下文特征序列K i以及句法知识序列V i,便于在后续步骤中快速调用相应的上下文特征记为k i,j和句法知识记为v i,j
本实施例中,步骤S11通过自动获取工具进行实施。
预处理对应的步骤为S13,包括以下步骤:
步骤S131:将所有实体词语x i输入嵌入层,在嵌入层中将所有实体词语x i分别转换为词语向量
Figure PCTCN2022127696-appb-000010
步骤S132:将所有词语向量
Figure PCTCN2022127696-appb-000011
以及上下文信息输入上下文信息编码层Encoder,然后通过上下文信息编码层Encoder输出一个含有上下文信息的词语向量h i
词语向量记为
Figure PCTCN2022127696-appb-000012
其中,E x表示预设的实体词语嵌入函数;上标x表示
Figure PCTCN2022127696-appb-000013
为与实体词语x i相关的向量。
上下文特征嵌入向量记为
Figure PCTCN2022127696-appb-000014
其中,E k表示预设的上下文特征嵌入函数;上标k表示
Figure PCTCN2022127696-appb-000015
为与上下文特征k i,j相关的向量。
句法知识嵌入向量记为
Figure PCTCN2022127696-appb-000016
其中,E v表示预设的句法知识嵌入函数;上标v表示
Figure PCTCN2022127696-appb-000017
为与句法知识v i,j相关的向量
含有上下文信息的词语向量记为
Figure PCTCN2022127696-appb-000018
多种将信息转换为向量的嵌入函数为相关技术,故在此不做赘述。
步骤S2包括以下步骤:
步骤S21:把预设文本中每个实体词语x i对应的含有上下文信息的词语向量h i和所有与实体词语x i相对应的上下文特征序列K i以及句法知识序列V i输入键-值记忆神经网络模块。
步骤S22:通过键-值记忆神经网络模块将上下文特征序列K i映射为上下文特征嵌入向量
Figure PCTCN2022127696-appb-000019
将句法知识序列V i映射为知识嵌入向量
Figure PCTCN2022127696-appb-000020
步骤S23:通过键-值记忆神经网络模块把键映射到上下文特征嵌入向量
Figure PCTCN2022127696-appb-000021
把值映射到知识嵌入向量
Figure PCTCN2022127696-appb-000022
步骤S24:利用键-值记忆神经网络模块中的键-值之间的转换,用映射键后的上下文特征嵌入向量
Figure PCTCN2022127696-appb-000023
来给映射值后的知识嵌入向量
Figure PCTCN2022127696-appb-000024
进行加权,得到加权后的知识向量a i,加权后的知识向量a i同时包含上下文特征和句法知识的信息。
步骤S25:通过键-值记忆神经网络模块,对预设文本中的所有实体词语x i,把包含上下文特征和句法知识的信息的知识向量a i与含有该实体词语x i的上下文信息的词语向量h i串联,得到新的向量
Figure PCTCN2022127696-appb-000025
其中,
Figure PCTCN2022127696-appb-000026
为串联符号。
通过键-值记忆神经网络模块把键映射到上下文特征,把值映射到这些特征所对应的句法知识,再通过键-值之间的转换,利用每个实体词语对应的上下文特征给该实体词语所对应的句法知识加权,从而避免那些贡献小的知识或者通过自动方法获取的不准确的知识在模型预测关系标签时对模型造成误导,进而帮助提升关系抽取模型的性能。
一实施例中,键-值之间的转换公式为:
Figure PCTCN2022127696-appb-000027
即:对于第i个实体词语x i,利用上下文特征(键)
Figure PCTCN2022127696-appb-000028
计算分配给其对应知识(值)
Figure PCTCN2022127696-appb-000029
的权重。
一实施例中,包含上下文特征和句法知识的信息的向量a i的表达式为
Figure PCTCN2022127696-appb-000030
即:依据权重p i,j计算句法知识的加权和。
步骤S3中,把对应不同实体词语的两个结果向量串联后得到的抽取关系表示为y′=Decoder(o 1+o 2)。
本实施例通过Decoder函数对串联的结果向量其进行解码,从而得到抽取的关系。
本从文本中进行关系抽取的方法还包括:
步骤S4:把抽取的关系与真实结果做比对,根据对比结果对本方法进行优化,直至对比结果达到预定标准。
本实施例中,抽取的关系表示为y′,真实结果表示为y,预定标准为预测两实体词语之间的关系与两实体词语的实际关系相符。
请继续参阅图1至图3,步骤S4,包括以下步骤:
步骤S41:根据对比结果计算目标函数的结果;通过比较目标函数的结果与预设范围,更新关系抽取模型的参数。
本实施例中,目标函数采用的是交叉熵损失函数。
一实施例中,如果交叉熵损失函数的结果未在预设范围,则更新从文本中进行关系抽取的方法中的多项参数。
更新的关系抽取模型的参数包括用于执行上述从文本中进行关系抽取的方法的关系抽取模型的所有参数。
请结合图3和图4,本申请实施例还提供一种关系抽取模型,设置为实现如上的从文本中进行关系抽取的方法,本关系抽取模型包括嵌入层1、上下文信息编码层2、键-值记忆神经网络模块3以及输出层4;嵌入层1设置为将预处理的结果编码映射为高维向量;上下文信息编码层2设置为处理词语向量与对应的上下文特征,编译得到含有上下文信息的词语向量;键-值记忆神经网络模块3设置为获取加权后的知识向量,再把与含有上下文信息的词语向量串联得到结果向量;输出层4设置为解码输出关于关系抽取的抽取关系。
一实施例中,实体词语、上下文特征及句法知识皆通过嵌入层1输入到本关系抽取模型内;将实体词语x i转换为词语向量
Figure PCTCN2022127696-appb-000031
这一步绉在嵌入层1内完成。
一实施例中,将上下文特征转换为上下文特征嵌入向量、将句法知识转换为句法知识嵌入向量以及通过键-值转换实现加权皆由键-值记忆神经网络模块3实现。
如图5所示,本申请实施例还提供一种从文本中进行关系抽取的装置,应用于关系抽取模型,包括:第一模块10,设置为从预设文本中获取预设信息,并对所述预设信息进行预处理,得到含有每个实体词语的上下文信息的词语向量,其中,所述预设信息包括不同实体词语、每个实体词语对应的上下文特征及每个实体词语对应的句法知识;第二模块20,设置为利用每个实体词语对应的上下文特征对所述每个实体词语对应的句法知识进行加权,得到所述每个实体词语对应的加权后的知识向量;把每个实体词语对应的加权后的知识向量与含有所述每个实体词语的上下文信息的词语向量串联得到所述每个实体词语对应的结果向量;第三模块30,设置为把所述预设文本中不同实体词语对应的结果向量串联,并对串联的结果向量进行解码,得到抽取的关系。
一实施例中,第一模块10设置为:
从所述预设文本中获取词语序列X,并针对所述词语序列X内的实体词语x i从所述预设文本中获取与所述实体词语x i对应的上下文特征和句法知识;基于获取的所述词语序列X、实体词语x i对应的上下文特征及句法知识,针对实体词语x i构建与所述实体词语x i相对应的上下文特征序列K i以及句法知识序列V i,其中,所述上下文特征序列K i中的上下文特征记为k i,j,所述句法知识序列V i中的句法知识记为v i,j,i为所述实体词语的编号,j为与所述实体词语x i对应的上下文特征和句法知识中的至少之一的编号,i∈[1、n],j∈[1、m];n与m均为正整数;n为所述词语序列X包括的实体词语的数量,实体词语x i对应的上下文特征的数量和句法知识的数量为m;将实体词语x i与所述实体词语x i相对应的上下文特征序列K i相结合得到含有所述实体词语x i的上下文信息的词语向量h i
一实施例中,第一模块10设置为通过如下方式将实体词语x i与所述实体词语x i相对应的上下文特征序列K i相结合得到含有所述实体词语x i的上下文信息的词语向量h i
将所述实体词语x i转换为词语向量
Figure PCTCN2022127696-appb-000032
将所述词语向量
Figure PCTCN2022127696-appb-000033
与所述实体词语x i相对应的上下文特征序列K i相结合得到含有所述实体词语x i的上下文信息的词语向量h i
一实施例中,第二模块20设置为:
将含有实体词语x i的上下文信息的词语向量h i和与所述实体词语x i相对应的 上下文特征序列K i以及句法知识序列V i输入键-值记忆神经网络模块;通过所述键-值记忆神经网络模块将所述上下文特征序列K i映射为上下文特征嵌入向量
Figure PCTCN2022127696-appb-000034
将所述句法知识序列V i映射为知识嵌入向量
Figure PCTCN2022127696-appb-000035
通过所述键-值记忆神经网络模块将键映射到所述上下文特征嵌入向量
Figure PCTCN2022127696-appb-000036
将值映射到所述知识嵌入向量
Figure PCTCN2022127696-appb-000037
利用所述键-值记忆神经网络模块中的键-值之间的转换,用映射键后的所述上下文特征嵌入向量
Figure PCTCN2022127696-appb-000038
来给映射值后的所述知识嵌入向量
Figure PCTCN2022127696-appb-000039
进行加权,得到加权后的知识向量a i,其中,所述加权后的知识向量a i包含上下文特征和句法知识的信息;通过所述键-值记忆神经网络模块,把实体词语x i对应的包含上下文特征和句法知识的信息的知识向量a i与含有所述实体词语x i的上下文信息的词语向量h i串联,得到新的向量o i,其中,
Figure PCTCN2022127696-appb-000040
为串联符号。
一实施例中,第三模块30设置为通过如下方式对串联的结果向量进行解码:
通过Decoder函数对所述串联的结果向量进行解码。
一实施例中,所述装置还包括第四模块,设置为:
把所述抽取的关系与真实结果做比对,根据对比结果对所述从文本中进行关系抽取的方法进行优化,直至对比结果达到所述预定标准。
一实施例中,第四模块设置为通过如下方式根据对比结果对所述从文本中进行关系抽取的方法进行优化:
根据所述对比结果计算交叉熵损失函数的结果;在所述交叉熵损失函数的结果未在预设范围的情况下,更新所述从文本中进行关系抽取的方法中的多项参数。
一实施例中,直至对比结果达到所述预定标准,包括:直到交叉熵损失函数的结果在预设范围。
如图6所示,本申请实施例还提供一种电子设备,包括处理器110以及存储器120,所述存储器120中的计算机程序被所述处理器110执行时实现上述的从文本中进行关系抽取的方法。
本申请实施例还提供一种计算机可读储存介质,计算机可读存储介质上存储计算机程序,计算机程序被处理器执行时实现如上的从文本中进行关系抽取的方法。该存储介质可以为非暂态存储介质。
与相关技术相比,本申请的从文本中进行关系抽取的方法、关系抽取模型及介质可以实现:
1、本申请的从文本中进行关系抽取的方法,包括:从预设文本中获取预设 信息,并对所述预设信息进行预处理,得到含有每个实体词语的上下文信息的词语向量,其中,所述预设信息包括不同实体词语、每个实体词语对应的上下文特征及每个实体词语对应的句法知识;利用每个实体词语对应的上下文特征对所述每个实体词语对应的句法知识进行加权,进而得到所述每个实体词语对应的加权后的知识向量;把每个实体词语对应的加权后的知识向量与含有所述每个实体词语的上下文信息的词语向量串联得到所述每个实体词语对应的结果向量;把所述预设文本中不同实体词语对应的结果向量串联,并对串联的结果向量进行解码,从而得到抽取的关系。本方法通过利用每个实体词语对应的上下文特征给该实体词语所对应的句法知识加权,能有效地避免那些贡献小的知识或者通过自动方法获取的不准确的知识在模型预测关系标签时对模型造成误导,从而提高从文本中进行关系抽取的方法预测结果的准确性,帮助提升关系抽取模型的性能。
2、本申请的方法中,从预设文本中获取预设信息,并所述预设信息进行预处理,得到含有每个实体词语的上下文信息的词语向量,包括:从预设文本中获取词语序列X,并针对词语序列X内的每个实体词语x i从预设文本中获取与其对应的上下文特征和对应的句法知识;基于获取的词语序列X、上下文特征及句法知识,针对每个实体词语x i构建与其相对应的上下文特征序列K i以及句法知识序列V i,上下文特征序列K i中的上下文特征记为k i,j,句法知识序列V i中的句法知识记为v i,j,其中i为实体词语的编号,j为与实体词语x i对应的上下文特征和/或句法知识的编号,i∈[1、n],j∈[1、m];n与m为正整数;将实体词语x i与相对应的上下文特征序列K i相结合得到含有上下文信息的词语向量h i。针对每个实体词语x i构建对应的上下文特征序列K i以及句法知识序列V i,便于在后续步骤中快速调用相应的上下文特征记为k i,j和句法知识记为v i,j
3、本申请的方法中,所述将实体词语x i与相对应的上下文特征序列K i相结合得到含有上下文信息的词语向量h i,包括:将实体词语x i转换为词语向量
Figure PCTCN2022127696-appb-000041
将词语向量
Figure PCTCN2022127696-appb-000042
与相对应的上下文特征序列K i相结合得到含有上下文信息的词语向量h i。在进行结合前先将实体词语x i转换为向量,可以便于运算。
4、本申请的方法中,通过键-值记忆神经网络模块把键映射到上下文特征,把值映射到这些特征所对应的句法知识,再通过键-值之间的转换,利用上下文特征给其所对应的句法知识加权,从而避免那些贡献小的知识或者自动方法获取的不准确的知识在模型预测关系标签时对其造成误导,进而帮助提升关系抽取模型的性能。
5、本申请的方法中,通过Decoder函数对串联的结果向量其进行解码,从而得到抽取的关系,此设计利于提高抽取结果的准确性。
6、本申请的方法中,还会对方法进行优化,提高从文本中进行关系抽取的 方法预测结果的准确性,提升关系抽取模型的性能。
7、本申请的方法中,通过交叉熵损失函数来对从文本中进行关系抽取的方法进行优化直到交叉熵的值在预设范围,优化效果好,利于提高抽取结果的准确性。
8、本申请还提供一种关系抽取模型,具有与上述从文本中进行关系抽取的方法一致的效果。
9、本申请还提供一种计算机可读储存介质,具有与上述从文本中进行关系抽取的方法一致的效果。
10、本申请还提供一种从文本中进行关系抽取的装置以及电子设备,具有与上述从文本中进行关系抽取的方法一致的效果。

Claims (11)

  1. 一种从文本中进行关系抽取的方法,应用于关系抽取模型,包括:
    从预设文本中获取预设信息,并对所述预设信息进行预处理,得到含有每个实体词语的上下文信息的词语向量,其中,所述预设信息包括不同实体词语、每个实体词语对应的上下文特征及每个实体词语对应的句法知识;
    利用每个实体词语对应的上下文特征对所述每个实体词语对应的句法知识进行加权,得到所述每个实体词语对应的加权后的知识向量;
    把每个实体词语对应的加权后的知识向量与含有所述每个实体词语的上下文信息的词语向量串联得到所述每个实体词语对应的结果向量;
    把所述预设文本中不同实体词语对应的结果向量串联,并对串联的结果向量进行解码,得到抽取的关系。
  2. 如权利要求1所述的从文本中进行关系抽取的方法,其中,所述从预设文本中获取预设信息,并对所述预设信息进行预处理,得到含有每个实体词语的上下文信息的词语向量,包括:
    从所述预设文本中获取词语序列X,并针对所述词语序列X内的实体词语x i从所述预设文本中获取与所述实体词语x i对应的上下文特征和句法知识;
    基于获取的所述词语序列X、实体词语x i对应的上下文特征及句法知识,针对实体词语x i构建与所述实体词语x i相对应的上下文特征序列K i以及句法知识序列V i,其中,所述上下文特征序列K i中的上下文特征记为k i,j,所述句法知识序列V i中的句法知识记为v i,j,i为所述实体词语的编号,j为与所述实体词语x i对应的上下文特征和句法知识中的至少之一的编号,i∈[1、n],j∈[1、m];n与m均为正整数;n为所述词语序列X包括的实体词语的数量,所述实体词语x i对应的上下文特征的数量和句法知识的数量为m;
    将实体词语x i与所述实体词语x i相对应的上下文特征序列K i相结合得到含有所述实体词语x i的上下文信息的词语向量h i
  3. 如权利要求2所述的从文本中进行关系抽取的方法,其中,所述将实体词语x i与所述实体词语x i相对应的上下文特征序列K i相结合得到含有所述实体词语x i的上下文信息的词语向量h i,包括:
    将所述实体词语x i转换为词语向量
    Figure PCTCN2022127696-appb-100001
    将所述词语向量
    Figure PCTCN2022127696-appb-100002
    与所述实体词语x i相对应的上下文特征序列K i相结合得到含有所述实体词语x i的上下文信息的词语向量h i
  4. 如权利要求2所述的从文本中进行关系抽取的方法,其中,所述利用每个实体词语对应的上下文特征对所述每个实体词语对应的句法知识进行加权,得 到所述每个实体词语对应的加权后的知识向量;把每个实体词语对应的加权后的知识向量与含有所述每个实体词语的上下文信息的词语向量串联得到所述每个实体词语对应的结果向量,包括:
    将含有实体词语x i的上下文信息的词语向量h i和与所述实体词语x i相对应的上下文特征序列K i以及句法知识序列V i输入键-值记忆神经网络模块;
    通过所述键-值记忆神经网络模块将所述上下文特征序列K i映射为上下文特征嵌入向量
    Figure PCTCN2022127696-appb-100003
    将所述句法知识序列V i映射为知识嵌入向量
    Figure PCTCN2022127696-appb-100004
    通过所述键-值记忆神经网络模块将键映射到所述上下文特征嵌入向量
    Figure PCTCN2022127696-appb-100005
    将值映射到所述知识嵌入向量
    Figure PCTCN2022127696-appb-100006
    利用所述键-值记忆神经网络模块中的键-值之间的转换,用映射键后的所述上下文特征嵌入向量
    Figure PCTCN2022127696-appb-100007
    来给映射值后的所述知识嵌入向量
    Figure PCTCN2022127696-appb-100008
    进行加权,得到加权后的知识向量a i,其中,所述加权后的知识向量a i包含上下文特征和句法知识的信息;
    通过所述键-值记忆神经网络模块,把实体词语x i对应的包含上下文特征和句法知识的信息的知识向量a i与含有所述实体词语x i的上下文信息的词语向量h i串联,得到新的向量o i,其中,
    Figure PCTCN2022127696-appb-100009
    Figure PCTCN2022127696-appb-100010
    为串联符号。
  5. 如权利要求1所述的从文本中进行关系抽取的方法,其中,所述对串联的结果向量进行解码,包括:
    通过Decoder函数对所述串联的结果向量进行解码。
  6. 如权利要求1所述的从文本中进行关系抽取的方法,还包括:
    把所述抽取的关系与真实结果做比对,根据对比结果对所述从文本中进行关系抽取的方法进行优化,直至对比结果达到预定标准。
  7. 如权利要求6所述的从文本中进行关系抽取的方法,其中,所述根据对比结果对所述从文本中进行关系抽取的方法进行优化,包括:
    根据所述对比结果计算交叉熵损失函数的结果;
    在所述交叉熵损失函数的结果未在预设范围的情况下,更新所述从文本中进行关系抽取的方法中的多项参数;
    所述直至对比结果达到所述预定标准,包括:
    直到交叉熵损失函数的结果在所述预设范围内。
  8. 一种关系抽取模型,设置为实现如权利要求1~7任一项所述的从文本中进行关系抽取的方法,包括嵌入层、上下文信息编码层、键-值记忆神经网络模块以及输出层;
    所述嵌入层设置为将预处理的结果编码映射为高维的词语向量;
    所述上下文信息编码层设置为处理所述词语向量与所述词语向量对应的上下文特征,编译得到含有上下文信息的词语向量;
    所述键-值记忆神经网络模块设置为获取加权后的知识向量,并将所述加权后的知识向量与所述含有上下文信息的词语向量串联得到结果向量;
    所述输出层设置为根据所述结果向量解码输出从文本中抽取的关系。
  9. 一种从文本中进行关系抽取的装置,应用于关系抽取模型,包括:
    第一模块,设置为从预设文本中获取预设信息,并对所述预设信息进行预处理,得到含有每个实体词语的上下文信息的词语向量,其中,所述预设信息包括不同实体词语、每个实体词语对应的上下文特征及每个实体词语对应的句法知识;
    第二模块,设置为利用每个实体词语对应的上下文特征对所述每个实体词语对应的句法知识进行加权,得到所述每个实体词语对应的加权后的知识向量;把每个实体词语对应的加权后的知识向量与含有所述每个实体词语的上下文信息的词语向量串联得到所述每个实体词语对应的结果向量;
    第三模块,设置为把所述预设文本中不同实体词语对应的结果向量串联,并对串联的结果向量进行解码,得到抽取的关系。
  10. 一种电子设备,包括处理器以及存储器,所述存储器中的计算机程序被所述处理器执行时实现如权利要求1至7中任一项所述的从文本中进行关系抽取的方法。
  11. 一种计算机可读储存介质,存储有计算机程序,所述计算机程序被处理器执行时实现如权利要求1至7中任一项所述的从文本中进行关系抽取的方法。
PCT/CN2022/127696 2022-05-27 2022-10-26 从文本中进行关系抽取的方法、关系抽取模型及介质 WO2023226292A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202210584720.1A CN114997141A (zh) 2022-05-27 2022-05-27 一种从文本中进行关系抽取的方法、关系抽取模型及介质
CN202210584720.1 2022-05-27

Publications (2)

Publication Number Publication Date
WO2023226292A1 true WO2023226292A1 (zh) 2023-11-30
WO2023226292A9 WO2023226292A9 (zh) 2024-01-04

Family

ID=83029388

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/127696 WO2023226292A1 (zh) 2022-05-27 2022-10-26 从文本中进行关系抽取的方法、关系抽取模型及介质

Country Status (2)

Country Link
CN (1) CN114997141A (zh)
WO (1) WO2023226292A1 (zh)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117518857A (zh) * 2023-12-31 2024-02-06 深圳酷宅科技有限公司 应用nlp的个性化智能家居控制策略生成方法及系统
CN117610562A (zh) * 2024-01-23 2024-02-27 中国科学技术大学 一种结合组合范畴语法和多任务学习的关系抽取方法
CN117933372A (zh) * 2024-03-22 2024-04-26 山东大学 一种面向数据增强的词汇组合知识建模方法及装置

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114997141A (zh) * 2022-05-27 2022-09-02 苏州思萃人工智能研究所有限公司 一种从文本中进行关系抽取的方法、关系抽取模型及介质

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111291565A (zh) * 2020-01-17 2020-06-16 创新工场(广州)人工智能研究有限公司 一种用于命名实体识别的方法与装置
CN114118081A (zh) * 2021-11-15 2022-03-01 上海交通大学 基于句法对齐的自然语言推理方法及系统
CN114168754A (zh) * 2021-12-16 2022-03-11 杭州电子科技大学 一种基于句法依赖和融合信息的关系抽取方法
CN114997141A (zh) * 2022-05-27 2022-09-02 苏州思萃人工智能研究所有限公司 一种从文本中进行关系抽取的方法、关系抽取模型及介质

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111291565A (zh) * 2020-01-17 2020-06-16 创新工场(广州)人工智能研究有限公司 一种用于命名实体识别的方法与装置
CN114118081A (zh) * 2021-11-15 2022-03-01 上海交通大学 基于句法对齐的自然语言推理方法及系统
CN114168754A (zh) * 2021-12-16 2022-03-11 杭州电子科技大学 一种基于句法依赖和融合信息的关系抽取方法
CN114997141A (zh) * 2022-05-27 2022-09-02 苏州思萃人工智能研究所有限公司 一种从文本中进行关系抽取的方法、关系抽取模型及介质

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117518857A (zh) * 2023-12-31 2024-02-06 深圳酷宅科技有限公司 应用nlp的个性化智能家居控制策略生成方法及系统
CN117518857B (zh) * 2023-12-31 2024-04-09 深圳酷宅科技有限公司 应用nlp的个性化智能家居控制策略生成方法及系统
CN117610562A (zh) * 2024-01-23 2024-02-27 中国科学技术大学 一种结合组合范畴语法和多任务学习的关系抽取方法
CN117933372A (zh) * 2024-03-22 2024-04-26 山东大学 一种面向数据增强的词汇组合知识建模方法及装置
CN117933372B (zh) * 2024-03-22 2024-06-07 山东大学 一种面向数据增强的词汇组合知识建模方法及装置

Also Published As

Publication number Publication date
CN114997141A (zh) 2022-09-02
WO2023226292A9 (zh) 2024-01-04

Similar Documents

Publication Publication Date Title
WO2023226292A1 (zh) 从文本中进行关系抽取的方法、关系抽取模型及介质
CN111310438B (zh) 基于多粒度融合模型的中文句子语义智能匹配方法及装置
CN111581229B (zh) Sql语句的生成方法、装置、计算机设备及存储介质
CN109508462B (zh) 一种基于编码器-解码器的神经网络蒙汉机器翻译方法
CN109190120B (zh) 神经网络训练方法和装置及命名实体识别方法和装置
CN112507065B (zh) 一种基于注释语义信息的代码搜索方法
CN111666427B (zh) 一种实体关系联合抽取方法、装置、设备及介质
CN113190656B (zh) 一种基于多标注框架与融合特征的中文命名实体抽取方法
CN112446211A (zh) 文本处理装置、方法、设备和计算机可读存储介质
CN115861995B (zh) 一种视觉问答方法、装置及电子设备和存储介质
CN114091450B (zh) 一种基于图卷积网络的司法领域关系抽取方法和系统
CN113204611A (zh) 建立阅读理解模型的方法、阅读理解方法及对应装置
CN113821616B (zh) 领域自适应的槽位填充方法、装置、设备及存储介质
CN112418291B (zh) 一种应用于bert模型的蒸馏方法、装置、设备及存储介质
CN117151223B (zh) 一种基于可学习提示的多模态实体识别和关系抽取方法
CN116129902A (zh) 一种基于跨模态对齐的语音翻译方法及系统
CN113723058B (zh) 文本摘要与关键词抽取方法、装置、设备及介质
CN115565177A (zh) 文字识别模型训练、文字识别方法、装置、设备及介质
CN112528003B (zh) 一种基于语义排序和知识修正的多项选择问答方法
CN111507103B (zh) 一种利用部分标注集的自训练神经网络分词模型
CN116028606A (zh) 基于Transformer指针抽取的人机多轮对话改写方法
CN113157866B (zh) 一种数据分析方法、装置、计算机设备及存储介质
CN113792121B (zh) 阅读理解模型的训练方法及装置、阅读理解方法及装置
CN112015939A (zh) 一种基于图像中英文描述的电脑照片检索方法与系统
CN118012992B (zh) 一种金融文本关系抽取方法、系统及存储介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22943479

Country of ref document: EP

Kind code of ref document: A1