Text time sequence extraction method and device, electronic equipment and storage medium

By dividing the target instances in the electronic health medical record into multiple instance fragments and using the associated attention network to strengthen hidden representations, the problem that instances and entities in unstructured text are difficult to distinguish and identify context information, and the timing relationship extraction is improved ability.

CN119476456AActive Publication Date: 2025-02-18INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411505296.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-25
Publication Date
2025-02-18
Estimated Expiration
2044-10-25

AI Technical Summary

Technical Problem

Due to fragmentation and large number of entities, unstructured text in electronic health records is difficult for instances and entities to distinguish and identify contextual information, which increases the complexity of timing relationship extraction.

Method used

By dividing the target instance into multiple instance fragments, encode the word vectors separately and calculate the entity position weight, the associated attention network is used to strengthen the hidden representation, and combine the associated attention parameters to generate the hidden representation, and then perform timing extraction.

Benefits of technology

The ability to extract text classification recognition level and timing relationships is improved, and instance fragments at different locations can be better processed, more differentiated and related instance representations can be obtained, and the entity timing relationships that effectively capture text.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119476456A_ABST
    Figure CN119476456A_ABST
Patent Text Reader

Abstract

The invention provides a text time sequence extraction method and device, electronic equipment and a storage medium, and the method comprises the steps: obtaining a target instance of a to-be-extracted time sequence relationship in a text, dividing the target instance into a plurality of instance segments, coding a word vector into a first hidden representation of the instance segments, calculating the entity position information to obtain a position weight of the instance fragment, weighting the first hidden representation of the instance fragment by adopting the position weight to obtain a second hidden representation of the instance fragment, and calculating the second hidden representation of the instance fragment to obtain an associated attention parameter of the instance fragment, and combining the associated attention parameters of the instance fragments into a target hidden representation of the target instance, and performing time sequence extraction on the target instance in the text according to the target hidden representation to obtain a time sequence relationship of the target instance in the text. According to the method, the hidden representation of the instance is obtained by associating the attention network, so that more differentiated and associated instance representation is realized, and the entity sequential relationship of the text is effectively captured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of natural language processing, and in particular to a text time series extraction method, device, electronic device and storage medium. Background Art

[0002] Temporal relation extraction is a key task in natural language processing. It aims to automatically identify and extract the temporal order relationship between entities from text. It is essential for in-depth understanding of the event process in the text, building an accurate timeline, and reasoning about the causal relationship between entities. In recent years, electronic health records have become widely popular. Extracting secondary information from the text of electronic health records has attracted the attention of users. Since temporal relation extraction has the function of building a timeline and determining the relationship between medical events and time expressions, it is regarded as a necessary process for the secondary use of electronic health records.

[0003] Currently, electronic health records contain highly structured tables and lists, as well as a large amount of unstructured text such as doctors' narrations, medical history records, and chief complaints. Unstructured text is often fragmented, lacking continuity between paragraphs, and contains a large number of entities and entity pairs in the same text, making it difficult to distinguish instances and identify context-related information of specific entity pairs, increasing the complexity of temporal relationship extraction. Summary of the invention

[0004] In view of this, the present invention aims to propose a text temporal extraction method, device, electronic device and storage medium to solve the problem that it is difficult to distinguish and identify contextual information between text instances and entities, resulting in complex text temporal relationship extraction, and to improve the text classification and recognition level and temporal relationship extraction capabilities.

[0005] According to a first aspect of the present invention, a text time sequence extraction method is provided, the method comprising:

[0006] Obtaining a target instance of a temporal relationship to be extracted from a text; the target instance includes an entity and an entity pair;

[0007] Divide the target instance into multiple instance segments; the instance segments include word vectors and entity position information;

[0008] Encoding the word vector as a first hidden representation of the instance segment;

[0009] Calculating the entity position information to obtain the position weight of the instance segment;

[0010] weighting the first hidden representation of the instance segment by using the position weight to obtain a second hidden representation of the instance segment;

[0011] Calculating the second hidden representation of the instance segment to obtain an associated attention parameter of the instance segment;

[0012] combining the associated attention parameters of the instance fragments into a target hidden representation of the target instance;

[0013] The target instances in the text are temporally extracted according to the target hidden representation to obtain the temporal relationship of the target instances in the text.

[0014] Optionally, dividing the target instance into a plurality of instance segments; the instance segments include word vectors and entity position information, including:

[0015] Dividing the target instance into a plurality of instance fragments according to positions of entities and entity pairs in the target instance;

[0016] Determine the entity and the entity position in the instance segment to obtain the entity position information of the instance segment;

[0017] The instance segment is vectorized to obtain a word vector corresponding to the instance segment.

[0018] Optionally, encoding the word vector into a first hidden representation of the instance segment comprises:

[0019] Integrate the word vectors corresponding to the instance fragments into a multi-dimensional vector;

[0020] Encoding the multidimensional vector to obtain a forward hidden state and a reverse hidden state of the instance segment;

[0021] The forward hidden state and the reverse hidden state are serially processed to obtain a first hidden representation of the instance segment.

[0022] Optionally, calculating the position weight of the instance segment based on the entity position information includes:

[0023] Determining a segment length of the instance segment and entity position information in the instance segment;

[0024] A nonlinear calculation is performed on the entity position information and the segment length to obtain a position weight of the instance segment.

[0025] Optionally, the entity position information and the segment length are subjected to nonlinear calculation to obtain a position weight of the instance segment, and the position weight of the instance segment is obtained by the following formula:

[0026]

[0027]

[0028] in, and are the position weights of the instance fragment corresponding to the i-th position, tanh is a nonlinear function, To obtain the upper limit operation, Len L , Len C and Len R are the segment lengths of the left instance segment, the middle instance segment, and the right instance segment, respectively.

[0029] Optionally, the instance segment includes a left instance segment, a middle instance segment, and a right instance segment, and the second hidden representation of the instance segment is calculated to obtain the associated attention parameter of the instance segment, including:

[0030] Performing pooling calculation on the second hidden representation of the intermediate instance fragment to obtain the overall representation of the intermediate instance fragment and the importance weight of the intermediate instance fragment;

[0031] Calculating the overall representation of the middle instance segment to obtain importance weights of the left instance segment and the right instance segment;

[0032] The associated attention parameter of the instance segment is calculated using the second hidden representation and the importance weight; the associated attention parameter of the instance segment is obtained by the following formula:

[0033]

[0034] Among them, r C 、r L 、r R are the associated attention parameters of the middle instance fragment, the left instance fragment, and the right instance fragment, respectively. are the importance weights of the middle instance fragment, the left instance fragment, and the right instance fragment, respectively. are the second hidden representations of the i-th word in the middle instance segment, left instance segment, and right instance segment, respectively.

[0035] Optionally, the associated attention parameters of the instance segments are combined into a target hidden representation of the target instance, and the target hidden representation of the target instance is obtained by the following formula:

[0036]

[0037] y=softmax(W o ·r)

[0038] Among them, r is the associated attention combination of the instance fragment, sigmoid is the nonlinear activation function, are the weight matrices for the middle instance fragment, the left instance fragment, and the right instance fragment, respectively, r C 、r L 、r R are the associated attention parameters of the middle instance fragment, the left instance fragment, and the right instance fragment, respectively. Softmax is a nonlinear function, and W o is the output weight matrix and y is the target hidden representation of the target instance.

[0039] According to a second aspect of the present invention, a text time sequence extraction device is provided, the device comprising:

[0040] An instance acquisition module is used to acquire a target instance of a temporal relationship to be extracted in a text; the target instance includes an entity and an entity pair;

[0041] An instance segmentation module, used to divide the target instance into multiple instance segments; the instance segments include word vectors and entity position information;

[0042] A vector encoding module, configured to encode the word vector into a first hidden representation of the instance segment;

[0043] A weight determination module is used to calculate the position weight of the instance segment based on the entity position information;

[0044] A weighting processing module, configured to weight the first hidden representation of the instance segment by using the position weight to obtain a second hidden representation of the instance segment;

[0045] An associated attention parameter module, configured to calculate an associated attention parameter of the instance segment based on the second hidden representation of the instance segment;

[0046] a parameter processing module, configured to combine the associated attention parameters of the instance fragments into a target hidden representation of the target instance;

[0047] The temporal extraction module is used to perform temporal extraction on the target instance in the text according to the target hidden representation to obtain the temporal relationship of the target instance in the text.

[0048] According to another aspect of the present invention, there is also provided an electronic device, comprising:

[0049] processor;

[0050] a memory for storing instructions executable by the processor;

[0051] Wherein, the processor is configured to execute the instructions to implement the text time sequence extraction method as described above.

[0052] According to another aspect of the present invention, a readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the text time series extraction method as described above are implemented.

[0053] The text temporal extraction method provided by the embodiment of the present invention obtains the target instance of the temporal relationship to be extracted in the text, divides the target instance into multiple instance fragments, encodes the word vector into the first hidden representation of the instance fragment, calculates the position weight of the instance fragment for the entity position information, weights the first hidden representation of the instance fragment by the position weight, obtains the second hidden representation of the instance fragment, calculates the associated attention parameter of the instance fragment for the second hidden representation of the instance fragment, combines the associated attention parameter of the instance fragment into the target hidden representation of the target instance, and extracts the target instance in the text according to the target hidden representation to obtain the temporal relationship of the target instance in the text. The embodiment of the present invention divides the target instance into multiple instance fragments, encodes the word vector of the instance fragment, obtains the hidden representation for characterizing the dependency relationship of the instance fragment, uses the position weight weighted hidden representation to emphasize the important information around the entity, obtains the hidden representation that can reflect the association relationship between the instance fragments through the associated attention network, can better handle instance fragments at different positions, improve the ability to understand the instance fragments, obtain more differentiated and associated instance representations, further improve the text classification recognition level and the ability to extract the temporal relationship, and effectively capture the entity temporal relationship of the text.

[0054] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented according to the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0055] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present invention. Moreover, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:

[0056] Figure 1 It is a flowchart of the steps of a text time series extraction method provided by an embodiment of the present invention;

[0057] Figure 2 yes Figure 1 A flowchart of step 102 in the text time series extraction method provided by an embodiment of the present invention;

[0058] Figure 3 yes Figure 1The flowchart of step 103 in the text time series extraction method provided by the embodiment of the present invention;

[0059] Figure 4 yes Figure 1 A flowchart of step 104 in the text time series extraction method provided by an embodiment of the present invention;

[0060] Figure 5 yes Figure 1 A flowchart of step 106 in the text time series extraction method provided by an embodiment of the present invention;

[0061] Figure 6 Schematic diagram of a scenario of a text time series extraction method provided by an embodiment of the present invention;

[0062] Figure 7 Schematic diagram of example division of the text time series extraction method provided by an embodiment of the present invention;

[0063] Figure 8 It is a structural schematic diagram of a text time sequence extraction device provided by an embodiment of the present invention;

[0064] Fig. 9 It is a structural schematic diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0065] To make the purpose, technical scheme and advantages of the embodiments of the present invention clearer, the embodiments of the present invention will be described in detail below in conjunction with the accompanying drawings. However, it will be appreciated by those skilled in the art that in the embodiments of the present invention, many technical details are proposed in order to enable the reader to better understand the present application. However, even without these technical details and various changes and modifications based on the following embodiments, the technical scheme claimed in the present application can be implemented. The division of the following embodiments is for the convenience of description, and should not constitute any limitation on the specific implementation of the present invention. The various embodiments can be combined and referenced with each other without contradiction.

[0066] Reference Figure 1 , shows a flowchart of the steps of a text time series extraction method provided by an embodiment of the present invention, the method may include:

[0067] Step 101, obtain a target instance of a temporal relationship to be extracted in a text; the target instance includes an entity and an entity pair.

[0068] In an embodiment of the present invention, since the unstructured text in the electronic health record has the characteristics of strong paragraphing and a large number of entities, in order to solve the problem that the same text contains a large number of entities and entity pairs, which makes it difficult to distinguish instances and difficult to identify context-related information of specific entity pairs, resulting in complex text temporal relationship extraction, this embodiment divides each instance into a left segment, a middle segment and a right segment according to the position of the text entity, and uses a bidirectional long short-term memory network to encode these three segments separately. The proposed associative attention mechanism is used to strengthen the important information hidden in each segment, reconstruct the association between the segments, and obtain more differentiated and relevant segment representations, thereby improving the ability to extract temporal relationships from electronic medical record texts.

[0069] It should be noted that this embodiment constructs an associative attention network and uses the associative attention network to extract temporal relationships from text. Specifically, a target instance of the temporal relationship to be extracted in the text is obtained. The target instance includes entities and entity pairs. In the task of temporal relationship extraction of the text, the target instance can be a long sentence or a short paragraph in the text. The target instance includes entities (such as medical events, time expressions, etc.) and entity pairs (i.e., the relationship between two entities). The selection of the target instance is determined according to the actual text content and requirements, and this embodiment does not make any specific limitations on this.

[0070] Step 102, divide the target instance into multiple instance segments; the instance segments include word vectors and entity location information.

[0071] In the embodiment of the present invention, the target instance is divided into multiple instance segments according to the positions of entities and entity pairs, and the instance segments include left instance segments, middle instance segments and right instance segments. Specifically, the maximum length of the target instance is first set, and instances exceeding this length do not participate in the temporal relationship extraction task. The instance is divided into long instances and short instances according to half of the maximum length. For any given instance, it is pre-processed and divided into three parts: left, middle and right according to the position of the entity, and both entities are included in the middle segment.

[0072] Specifically, the target instance is divided into three parts: left, middle and right according to the position of the entity. According to the division result, the entity position information of the instance fragment is obtained. The entity position information includes the starting position and the ending position of the entity. The word vector maps the character vocabulary or words in the instance fragment to a numerical vector that can be recognized by the computer. It should be noted that in order to contain as much semantic and grammatical information as possible between vectors, this embodiment uses the BERT model to convert the instance fragment into a vector, and converts each word in the instance fragment into a continuous vector, which helps to combine the context information of the instance fragment with the temporal relationship, and facilitates the understanding of the temporal relationship between text events.

[0073] Step 103: Encode the word vector as a first hidden representation of the instance segment.

[0074] In an embodiment of the present invention, a long short-term memory network is used to encode a word vector as a first hidden representation of an instance fragment. The first hidden representation refers to an intermediate layer output obtained after a series of calculations in a neural network. The intermediate layer output is usually a high-dimensional numerical vector that can capture the complex features and semantic information of the input data. Long short-term memory is a recurrent neural network used to solve the gradient vanishing and gradient exploding problems of long sequences during training, and has better performance in longer sequences. In an embodiment of the present invention, Bi-LSTM is used to encode each instance fragment, and the word vectors obtained by preprocessing are sequentially sent to the Bi-LSTM. The word vector of each instance fragment is input twice, positively and negatively, to obtain two embedded codes, and then the two embedded codes are connected in series to represent the word to obtain a hidden representation of each fragment.

[0075] Step 104: Calculate the entity position information to obtain the position weight of the instance segment.

[0076] In an embodiment of the present invention, a target instance is divided into multiple instance fragments according to the position of the entity. The number and position of entities included in the instance fragments are different. Assuming that the context of the electronic health record has the same characteristics, the closer the word is to the entity, the more meaningful it is. Therefore, this embodiment calculates the position weight of the instance fragment based on the entity position information, and uses the position weight to emphasize the hidden representation in the instance fragment. Specifically, the position weight can be calculated by the ratio of the relative distance between the word and the entity in the instance fragment to the fragment length, which will not be elaborated here.

[0077] Step 105: weight the first hidden representation of the instance segment using the position weight to obtain a second hidden representation of the instance segment.

[0078] Step 106, calculating the associated attention parameter of the instance segment based on the second hidden representation of the instance segment.

[0079] The embodiment of the present invention uses an attention mechanism to emphasize relevant information to aggregate entities and similar instances, and makes the representation of instances easier to distinguish, emphasizing important information hidden in the instances. Specifically, on the basis of weighting the first hidden representation of the instance fragment to obtain the second hidden representation of the instance fragment, the associated attention parameters of the middle instance fragment and the left and right instance fragments are calculated respectively. The associated attention parameters are represented by importance weights and weighted sums, wherein the importance weights represent the importance of different parts of the input data, and can determine which parts should be paid attention to when processing the input data. By multiplying the input data by the corresponding importance weights and performing weighted sum calculations, a weighted representation can be obtained. This representation, namely the associated attention parameters, can better capture the important information in the input data.

[0080] Specifically, since the middle instance segment usually contains the richest temporal information between the two entities, it is regarded as the key segment. The associated attention parameters of the middle instance segment are first calculated, and then the associated attention parameters of the left and right instance segments are calculated based on the associated attention parameters of the middle instance segment. I will not go into details here.

[0081] Step 107, combine the associated attention parameters of the instance fragments into a target hidden representation of the target instance.

[0082] Step 108, performing temporal extraction on the target instances in the text according to the target hidden representation, and obtaining the temporal relationship of the target instances in the text.

[0083] In an embodiment of the present invention, a target instance in a text is temporally extracted according to a target hidden representation to obtain a temporal relationship of the target instance in the text. Specifically, the target hidden representation is provided to an output layer to predict the temporal relationship between entity pairs. The target hidden representation contains semantic information of instance fragments and associated attention parameters. The target hidden representation is provided to the output layer, which is usually a fully connected layer. The temporal relationship between entity pairs is predicted according to the output of the output layer. There are usually multiple types of temporal relationships, for example: event A occurs before event B, event A occurs after event B, event A and event B occur at the same time, and event A and event B overlap. The temporal relationships of the target instances are integrated to obtain the temporal relationship of events in the text.

[0084] The text temporal extraction method provided by the embodiment of the present invention obtains the target instance of the temporal relationship to be extracted in the text, divides the target instance into multiple instance fragments, encodes the word vector into the first hidden representation of the instance fragment, calculates the position weight of the instance fragment for the entity position information, weights the first hidden representation of the instance fragment by the position weight, obtains the second hidden representation of the instance fragment, calculates the associated attention parameter of the instance fragment for the second hidden representation of the instance fragment, combines the associated attention parameter of the instance fragment into the target hidden representation of the target instance, and extracts the target instance in the text according to the target hidden representation to obtain the temporal relationship of the target instance in the text. The embodiment of the present invention divides the target instance into multiple instance fragments, encodes the word vector of the instance fragment, obtains the hidden representation for characterizing the dependency relationship of the instance fragment, uses the position weight weighted hidden representation to emphasize the important information around the entity, obtains the hidden representation that can reflect the association relationship between the instance fragments through the associated attention network, can better handle instance fragments at different positions, improve the ability to understand the instance fragments, obtain more differentiated and associated instance representations, further improve the text classification recognition level and the ability to extract the temporal relationship, and effectively capture the entity temporal relationship of the text.

[0085] Further, see Figure 2 , showing Figure 1 The flowchart of step 102 in the text time sequence extraction method provided is substantially the same as the text time sequence extraction method provided in the first embodiment of the present invention. Step 102 may include:

[0086] Step 201 : dividing the target instance into a plurality of instance segments according to the positions of entities and entity pairs in the target instance.

[0087] In an embodiment of the present invention, the entire target instance is divided into multiple instance fragments according to the positions of entities and entity pairs in the target instance, and each instance fragment contains one or more entities and their corresponding relationships. It should be noted that in this embodiment, the maximum length of the target instance to be processed can be set first, and instances exceeding this length do not participate in the processing process, and the instances are divided into long instances and short instances according to half of the maximum length to obtain target instances, ensuring that the instances participating in the training have a reasonable length to avoid negative effects on model training caused by overly long instances. Through preprocessing, the target instance is divided into three parts, left, middle and right, according to the position of the entity, and both entities are included in the middle instance fragment.

[0088] For example, refer to Figure 7 , shows a schematic diagram of instance division of the text temporal extraction method provided by an embodiment of the present invention, taking a given target instance "She does not have her walker here today and is using the wheelchair primarily." as an example for explanation, assuming that entity 1 is "walker" and entity 2 is "wheelchair", the instance after processing can be divided into, left part: She does not have her; middle part: walker here today and is using the; and last right part: wheelchair primarily. Assuming that entity 1 is "today" and entity 2 is "using", the instance after processing can be divided into, left part: She does not have her walker here; middle part: today and is using; right part: the wheelchair primarily.

[0089] Step 202: determine the entity and entity position in the instance segment, and obtain the entity position information of the instance segment.

[0090] In this embodiment, after the target instance is divided into multiple instance fragments, the entities and entity positions contained in the instance fragments are changed due to the instance fragments obtained by dividing according to the positions of entities and entity pairs in the target instance. The target instance is divided into three parts, left, middle and right, according to the positions of the entities, and both entities are included in the middle instance fragment. In order to capture the relationship between the entities, the entities and entity positions in the instance fragments are determined, and this information is recorded to obtain the entity position information of the instance fragment, and the entity position information includes the starting position and the ending position of the entity.

[0091] Step 203: perform vector conversion on the instance segment to obtain a word vector corresponding to the instance segment.

[0092] Specifically, the instance fragment is converted into a vector to obtain the word vector corresponding to the instance fragment. Each instance fragment can be input into a pre-trained vector model to obtain the word vector corresponding to the instance fragment. The word vector is usually a high-dimensional numerical vector that can capture the semantic information in the text.

[0093] It should be noted that the word vector corresponding to the instance fragment is obtained through processing of the pre-trained vector model. This embodiment adopts BERT (Bidirectional Encoder Representations from Transformers) as the pre-trained vector model, wherein the BERT model is a deep pre-trained model built using a bidirectional Transformer. The key in the Transformer module is the multi-head attention mechanism. The instance fragment is input into the pre-trained vector model, and the word vector corresponding to the instance fragment is output. Specifically, the BERT model is used to pre-train the instance fragment to obtain a word embedding lookup table, and each word in the instance fragment is converted into a continuous word vector.

[0094] The embodiment of the present invention divides the target instance into multiple instance segments, converts the instance segments into vectors, and obtains word vectors corresponding to the instance segments, so as to better process instance segments in different positions and improve the ability to understand the instance segments.

[0095] Further, see Figure 3 , showing Figure 1 The flowchart of step 103 in the text time sequence extraction method provided is substantially the same as the text time sequence extraction method provided in the first embodiment of the present invention. Step 103 may include:

[0096] Step 301: Integrate the word vectors corresponding to the instance segments into a multi-dimensional vector.

[0097] Step 302: Encode the multi-dimensional vector to obtain a forward hidden state and a reverse hidden state of the instance segment.

[0098] Step 303: The forward hidden state and the reverse hidden state are serially processed to obtain a first hidden representation of the instance segment.

[0099] In an embodiment of the present invention, the word vector corresponding to the instance fragment is input into a long short-term memory network (Bi-LSTM), and the word vector corresponding to the instance fragment is integrated into a multidimensional vector, wherein Bi-LSTM is a commonly used sequence model that can capture long-term dependencies in sequence data. The multidimensional vector is encoded by Bi-LSTM to obtain a forward hidden state and a reverse hidden state of the word vector, and the forward hidden state and the reverse hidden state are processed in series to obtain a first hidden representation of the instance fragment. The series processing is usually to connect the forward hidden state and the reverse hidden state element by element. The hidden representation refers to the intermediate layer output obtained after a series of calculations in the neural network. The intermediate layer output is usually a high-dimensional numerical vector that can capture the complex features and semantic information of the input data.

[0100] The embodiment of the present invention obtains a hidden representation for characterizing the dependency relationship of instance fragments by encoding the word vectors of instance fragments, thereby obtaining a more differentiated and correlated instance representation, which helps to capture the entity temporal relationship of the text.

[0101] Further, see Figure 4 , showing Figure 1 The flowchart of step 104 in the text time sequence extraction method provided is substantially the same as the text time sequence extraction method provided in the first embodiment of the present invention. Step 104 may include:

[0102] Step 401 : Determine the segment length of the instance segment and the entity position information in the instance segment.

[0103] Step 402 : Perform nonlinear calculation on the entity position information and the segment length to obtain the position weight of the instance segment.

[0104] In an embodiment of the present invention, the length of an instance segment and the entity position information in the instance segment are determined, the entity position information includes the starting position and the ending position of the entity, and a nonlinear calculation is performed on the entity position information and the segment length to obtain a position weight of the instance segment. The position weight is specifically calculated based on the relative distance between the instance segment context and the entity. The position weight is usually a numerical value that indicates the influence of the distance between the word at a specified position in the instance segment and the entity on the importance of the word. It should be noted that this embodiment uses a nonlinear function to calculate the entity position information and the segment length to generate the position weight of the instance segment, and specifically uses a nonlinear function tanh to smooth the ratio of the relative distance between the word and the entity to the segment length.

[0105] The embodiment of the present invention adopts position weight weighted hidden representation to emphasize important information around the entity, which can better process instance fragments at different positions, improve the ability to understand instance fragments, and obtain more differentiated and related instance representations.

[0106] Specifically, the entity position information and the segment length are nonlinearly calculated to obtain the position weight of the instance segment, and the position weight of the instance segment is obtained by the following formula:

[0107]

[0108] in, and are the position weights of the instance fragment corresponding to the i-th position, tanh is a nonlinear function, To obtain the upper limit operation, Len L , Len C and Len R are the segment lengths of the left instance segment, the middle instance segment, and the right instance segment, respectively.

[0109] It should be noted that, in the present embodiment, the position weight of the left instance fragment (right fragment) is calculated by the ratio of the relative distance between the word and the first entity and the length of the fragment. Therefore, the farther the word is from the entity, the lower the weight. In order to avoid assigning zero weight to the first word of the left instance fragment and the last word of the right fragment, the present embodiment increases the length of the fragment by one. Since the intermediate instance fragment hides important information and may be very short, the word positions of the intermediate instance fragment are treated equally, and the position weights of all words in the intermediate instance fragment are smoothed.

[0110] Further, see Figure 5 , showing Figure 1 A flowchart of step 106 in a text time sequence extraction method is provided. The method is basically the same as the text time sequence extraction method provided in the first embodiment of the present invention. Step 106 may include:

[0111] Step 501 : pooling the second hidden representation of the intermediate instance segment to obtain the overall representation of the intermediate instance segment and the importance weight of the intermediate instance segment.

[0112] In this embodiment, since the intermediate instance segment usually contains the richest temporal information between two entities, it is regarded as a key segment, and the second hidden representation of the intermediate instance segment is pooled to obtain the overall representation of the intermediate instance segment and the importance weight of the intermediate instance segment. Specifically, the maximum pooling operation maxpooling(·) is first used to obtain the overall representation of the intermediate instance segment. The overall expression of the intermediate instance fragment Calculated by the following formula:

[0113]

[0114] in, are the hidden representations of the starting and ending positions in the intermediate instance fragment, respectively.

[0115] It should be noted that the importance weight of the intermediate instance fragment is calculated by the following formula:

[0116]

[0117] in, is the importance weight of the intermediate instance fragment, W C The weight matrix pre-trained for the intermediate instance fragment, represents the hidden representation of the i-th word in the middle instance segment.

[0118] Step 502 : Calculate the overall representation of the middle instance segment to obtain the importance weights of the left instance segment and the right instance segment.

[0119] In an embodiment of the present invention, the left and right instance segments are respectively associated with the middle instance segment, a score function formula is defined, and the hidden representation of each word in the left part and the overall representation of the center part are used as inputs of the function to calculate the importance weight of the i-th word in the left and right instance segments. In this embodiment, the softmax(·) function can be used to calculate the importance weight of the instance segment after regularization.

[0120] Specifically, the hidden representation of each word in the left part and the overall representation of the center part are used as the input of the function to calculate the importance weight of the i-th word in the left instance segment:

[0121]

[0122] in, The weight matrix pre-trained for the left instance segment, is the hidden representation of the i-th word in the left instance segment, is the overall representation of the intermediate instance fragment, and tanh is a nonlinear function.

[0123] Specifically, in this embodiment, the softmax(·) function is used to calculate the importance weight of the regularized fragment:

[0124]

[0125] in, is the importance weight of the i-th word in the left instance segment.

[0126] It should be noted that the calculation process of calculating the importance weight of the i-th word in the right instance segment is the same as the calculation process of the importance weight of the left instance segment. Specifically:

[0127]

[0128] in, The weight matrix pre-trained for the right instance segment, is the hidden representation of the i-th word in the right instance segment, is the overall representation of the intermediate instance fragment, tanh is a nonlinear function, is the importance weight of the i-th word in the right instance segment.

[0129] Step 503, using the second hidden representation and the importance weight, calculate the associated attention parameter of the instance segment.

[0130] The associated attention parameter of the instance segment is obtained by the following formula:

[0131]

[0132] Among them, r C 、r L 、r R are the associated attention parameters of the middle instance fragment, the left instance fragment, and the right instance fragment, respectively. are the importance weights of the middle instance fragment, the left instance fragment, and the right instance fragment, respectively. are the second hidden representations of the i-th word in the middle instance segment, left instance segment, and right instance segment, respectively.

[0133] The embodiment of the present invention performs association calculation on the hidden representations of instance fragments through an association attention network to obtain a hidden representation that can reflect the association relationship between instance fragments, and further obtains more differentiated and associated instance representations, thereby improving the text classification recognition level and the temporal relationship extraction capability.

[0134] Specifically, in order to avoid information redundancy and control information fusion, the information control gate r is used in the output layer L 、r C and r R Combined as the final hidden representation r of the current entire target instance, the associated attention parameters of the instance fragments are combined into the target hidden representation of the target instance. The target hidden representation of the target instance is obtained by the following formula:

[0135]

[0136] y=softmax(W o ·r)

[0137] Among them, r is the associated attention combination of the instance fragment, sigmoid is the nonlinear activation function, are the importance weight matrices of the middle instance fragment, the left instance fragment, and the right instance fragment, respectively, r C 、r L 、r R are the associated attention parameters of the middle instance fragment, the left instance fragment, and the right instance fragment, respectively. Softmax is a nonlinear function, and W o is the output weight matrix and y is the target hidden representation of the target instance.

[0138] In order to facilitate those skilled in the art to fully understand the above-mentioned text time series extraction method, refer to Figure 6 , Figure 6 It is a scene schematic diagram of a text temporal extraction method provided by an embodiment of the present invention, showing the overall process of text temporal extraction provided by an embodiment of the present invention, specifically including: constructing an associative attention network, subdividing the target instance of the temporal relationship to be extracted in the text into short and long parts, the two parts of the network structure are exactly the same, and they are not repeated here one by one, each target instance is divided into a left instance fragment, a middle instance fragment and a right instance fragment according to the position of the entity pair, and the three fragments are encoded respectively by a bidirectional long short-term memory network, and the associative attention mechanism of the associative attention network is used to strengthen the important information hidden in each instance fragment, and reconstruct the association between the fragments. Through the associative attention mechanism, more different and relevant instance fragment representations can be obtained. Finally, the associative attention parameters of the three instance fragments are combined and connected as a hidden representation of the entire target instance, and provided to the output layer to extract the temporal relationship between the entity pairs in the text instance.

[0139] Reference Figure 8 , shows a schematic diagram of the structure of a text time sequence extraction device provided by an embodiment of the present invention, the device comprising:

[0140] The instance acquisition module 601 is used to acquire a target instance of a temporal relationship to be extracted from a text; the target instance includes an entity and an entity pair;

[0141] An instance segmentation module 602 is used to segment the target instance into multiple instance segments; the instance segments include word vectors and entity position information;

[0142] A vector encoding module 603, configured to encode the word vector into a first hidden representation of the instance segment;

[0143] A weight determination module 604 is used to calculate the position weight of the instance segment based on the entity position information;

[0144] A weighting processing module 605, configured to weight the first hidden representation of the instance segment by using the position weight to obtain a second hidden representation of the instance segment;

[0145] An associated attention parameter module 606, configured to calculate an associated attention parameter of the instance segment based on the second hidden representation of the instance segment;

[0146] A parameter processing module 607, configured to combine the associated attention parameters of the instance segments into a target hidden representation of the target instance;

[0147] The time sequence extraction module 608 is used to perform time sequence extraction on the target instance in the text according to the target hidden representation to obtain the time sequence relationship of the target instance in the text.

[0148] Furthermore, the instance partitioning module 602 includes:

[0149] A division submodule, used for dividing the target instance into a plurality of instance segments according to the positions of entities and entity pairs in the target instance;

[0150] A first determination submodule is used to determine the entity and the entity position in the instance segment to obtain the entity position information of the instance segment;

[0151] The first processing submodule is used to perform vector conversion on the instance segment to obtain a word vector corresponding to the instance segment.

[0152] Furthermore, the vector encoding module 603 includes:

[0153] The second processing submodule is used to integrate the word vectors corresponding to the instance segment into a multi-dimensional vector; encode the multi-dimensional vector to obtain a forward hidden state and a reverse hidden state of the instance segment;

[0154] The third processing submodule is used to perform serial processing on the forward hidden state and the reverse hidden state to obtain a first hidden representation of the instance segment.

[0155] Furthermore, the weight determination module 604 includes:

[0156] A second determination submodule, used to determine the segment length of the instance segment and entity position information in the instance segment;

[0157] The first calculation submodule is used to perform nonlinear calculation on the entity position information and the segment length to obtain the position weight of the instance segment.

[0158] Furthermore, the first calculation submodule is specifically configured such that the position weight of the instance segment is obtained by the following formula:

[0159]

[0160] in, and are the position weights of the instance fragment corresponding to the i-th position, tanh is a nonlinear function, To obtain the upper limit operation, Len L , Len C and Len R are the segment lengths of the left instance segment, the middle instance segment, and the right instance segment, respectively.

[0161] Further, the instance segment includes a left instance segment, a middle instance segment and a right instance segment, and the associated attention parameter module 606 includes:

[0162] A pooling submodule, used for performing pooling calculation on the second hidden representation of the intermediate instance fragment to obtain the overall representation of the intermediate instance fragment and the importance weight of the intermediate instance fragment;

[0163] A weight submodule, configured to calculate the overall representation of the middle instance segment to obtain the importance weights of the left instance segment and the right instance segment;

[0164] The second calculation submodule is used to calculate the associated attention parameter of the instance segment by using the second hidden representation and the importance weight; the associated attention parameter of the instance segment is obtained by the following formula:

[0165]

[0166] Among them, r C 、r L 、r R are the associated attention parameters of the middle instance fragment, the left instance fragment, and the right instance fragment, respectively. are the importance weights of the middle instance fragment, the left instance fragment, and the right instance fragment, respectively. are the second hidden representations of the i-th word in the middle instance segment, left instance segment, and right instance segment, respectively.

[0167] Furthermore, the parameter processing module 607 is specifically configured such that the target hidden representation of the target instance is obtained by the following formula:

[0168]

[0169] y=softmax(W o ·r)

[0170] Among them, r is the associated attention combination of the instance fragment, sigmoid is the nonlinear activation function, are the weight matrices for the middle instance fragment, the left instance fragment, and the right instance fragment, respectively, r C 、r L 、r R are the associated attention parameters of the middle instance fragment, the left instance fragment, and the right instance fragment, respectively. Softmax is a nonlinear function, and W o is the output weight matrix and y is the target hidden representation of the target instance.

[0171] The text temporal extraction device provided by the embodiment of the present invention obtains the target instance of the temporal relationship to be extracted in the text, divides the target instance into multiple instance segments, encodes the word vector into the first hidden representation of the instance segment, calculates the position weight of the instance segment by the entity position information, weights the first hidden representation of the instance segment by the position weight, obtains the second hidden representation of the instance segment, calculates the associated attention parameter of the instance segment by the second hidden representation of the instance segment, combines the associated attention parameter of the instance segment into the target hidden representation of the target instance, and extracts the target instance in the text according to the target hidden representation to obtain the temporal relationship of the target instance in the text. The embodiment of the present invention divides the target instance into multiple instance segments, encodes the word vector of the instance segment, obtains the hidden representation for characterizing the dependency relationship of the instance segment, uses the position weight weighted hidden representation to emphasize the important information around the entity, obtains the hidden representation that can reflect the association relationship between the instance segments through the associated attention network, can better handle the instance segments in different positions, improve the ability to understand the instance segments, obtain more differentiated and associated instance representations, further improve the text classification recognition level and the ability to extract the temporal relationship, and effectively capture the entity temporal relationship of the text.

[0172] Reference Fig. 9 , an embodiment of the present invention further provides an electronic device, such as Fig. 9 As shown, it includes a processor 701, a communication interface 702, a memory 703 and a communication bus 704, wherein the processor 701, the communication interface 702, and the memory 703 communicate with each other through the communication bus 704.

[0173] Memory 703, used for storing computer programs;

[0174] The processor 701 is used to execute the program stored in the memory 703 to implement the following steps:

[0175] Obtaining a target instance of a temporal relationship to be extracted from a text; the target instance includes an entity and an entity pair;

[0176] Divide the target instance into multiple instance segments; the instance segments include word vectors and entity position information;

[0177] Encoding the word vector as a first hidden representation of the instance segment;

[0178] Calculating the entity position information to obtain the position weight of the instance segment;

[0179] weighting the first hidden representation of the instance segment by using the position weight to obtain a second hidden representation of the instance segment;

[0180] Calculating the second hidden representation of the instance segment to obtain an associated attention parameter of the instance segment;

[0181] combining the associated attention parameters of the instance fragments into a target hidden representation of the target instance;

[0182] The target instances in the text are temporally extracted according to the target hidden representation to obtain the temporal relationship of the target instances in the text.

[0183] The communication bus mentioned in the above terminal can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.

[0184] The communication interface is used for communication between the above terminal and other devices.

[0185] The memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.

[0186] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0187] In another embodiment provided by the present invention, a computer-readable storage medium is also provided, in which instructions are stored. When the computer-readable storage medium is run on a computer, the computer executes the text time series extraction method described in any of the above embodiments.

[0188] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk Solid State Disk (SSD)), etc.

[0189] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0190] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0191] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.

Claims

1. A text temporal extraction method, characterized in that: The method comprises: Obtaining a target instance of a temporal relationship to be extracted from a text; the target instance includes an entity and an entity pair; Divide the target instance into multiple instance segments; the instance segments include word vectors and entity position information; Encoding the word vector as a first hidden representation of the instance segment; Calculating the entity position information to obtain the position weight of the instance segment; weighting the first hidden representation of the instance segment by using the position weight to obtain a second hidden representation of the instance segment; Calculating the second hidden representation of the instance segment to obtain an associated attention parameter of the instance segment; combining the associated attention parameters of the instance fragments into a target hidden representation of the target instance; The target instances in the text are temporally extracted according to the target hidden representation to obtain the temporal relationship of the target instances in the text.

2. The method according to claim 1, characterized in that The target instance is divided into a plurality of instance segments; the instance segments include word vectors and entity position information, including: Dividing the target instance into a plurality of instance fragments according to positions of entities and entity pairs in the target instance; Determine the entity and the entity position in the instance segment to obtain the entity position information of the instance segment; The instance segment is vectorized to obtain a word vector corresponding to the instance segment.

3. The method according to claim 1, characterized in that: The encoding of the word vector into a first hidden representation of the instance segment comprises: Integrate the word vectors corresponding to the instance fragments into a multi-dimensional vector; Encoding the multidimensional vector to obtain a forward hidden state and a reverse hidden state of the instance segment; The forward hidden state and the reverse hidden state are serially processed to obtain a first hidden representation of the instance segment.

4. The method according to claim 1, characterized in that: The calculating the position weight of the instance segment based on the entity position information includes: Determining a segment length of the instance segment and entity position information in the instance segment; A nonlinear calculation is performed on the entity position information and the segment length to obtain a position weight of the instance segment.

5. The method according to claim 4, characterized in that The entity position information and the segment length are nonlinearly calculated to obtain the position weight of the instance segment, and the position weight of the instance segment is obtained by the following formula: in, and are the position weights of the instance fragment corresponding to the i-th position, tanh is a nonlinear function, To obtain the upper limit operation, Len L , Len C and Len R are the segment lengths of the left instance segment, the middle instance segment, and the right instance segment, respectively.

6. The method according to claim 1, characterized in that The instance fragments include a left instance fragment, a middle instance fragment, and a right instance fragment, and the second hidden representation of the instance fragments is calculated to obtain associated attention parameters of the instance fragments, including: Performing pooling calculation on the second hidden representation of the intermediate instance fragment to obtain the overall representation of the intermediate instance fragment and the importance weight of the intermediate instance fragment; Calculating the overall representation of the middle instance segment to obtain importance weights of the left instance segment and the right instance segment; The associated attention parameter of the instance segment is calculated using the second hidden representation and the importance weight; the associated attention parameter of the instance segment is obtained by the following formula: Among them, r C 、r L 、r R are the associated attention parameters of the middle instance fragment, the left instance fragment, and the right instance fragment, respectively. are the importance weights of the middle instance fragment, the left instance fragment, and the right instance fragment, respectively. are the second hidden representations of the i-th word in the middle instance segment, left instance segment, and right instance segment, respectively.

7. The method according to claim 1, characterized in that The associated attention parameters of the instance fragments are combined into a target hidden representation of the target instance, and the target hidden representation of the target instance is obtained by the following formula: y =softmax(W o ·r) Among them, r is the associated attention combination of the instance fragment, sigmoid is the nonlinear activation function, are the weight matrices for the middle instance fragment, the left instance fragment, and the right instance fragment, respectively, r C 、r L 、r R are the associated attention parameters of the middle instance segment, the left instance segment, and the right instance segment, respectively. Softmax is a nonlinear function, and W o is the output weight matrix and y is the target hidden representation of the target instance.

8. A text time sequence extraction device, characterized in that: The device comprises: An instance acquisition module is used to acquire a target instance of a temporal relationship to be extracted in a text; the target instance includes an entity and an entity pair; An instance segmentation module, used to divide the target instance into multiple instance segments; the instance segments include word vectors and entity position information; A vector encoding module, configured to encode the word vector into a first hidden representation of the instance segment; A weight determination module is used to calculate the position weight of the instance segment based on the entity position information; A weighting processing module, configured to weight the first hidden representation of the instance segment by using the position weight to obtain a second hidden representation of the instance segment; An associated attention parameter module, configured to calculate an associated attention parameter of the instance segment based on the second hidden representation of the instance segment; a parameter processing module, configured to combine the associated attention parameters of the instance fragments into a target hidden representation of the target instance; The temporal extraction module is used to perform temporal extraction on the target instance in the text according to the target hidden representation to obtain the temporal relationship of the target instance in the text.

9. An electronic device, characterized in that: include: processor; a memory for storing processor-executable instructions; The processor is configured to execute the instructions to implement the text temporal extraction method as described in any one of claims 1 to 7.

10. A readable storage medium, characterized in that: The readable storage medium stores a computer program, and when the computer program is executed by a processor, the text time series extraction method according to any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Image processing method and device

    CN107025457A

  • Word recognition method and device, electronic equipment and storage medium

    CN117131878A

  • Video summary generation method and apparatus, electronic device, and storage medium

    WO2023134088A1