Chapter relationship identification method, system, device and computer storage medium
By introducing the pre-trained language model BERT and Brown cluster vector into the existing technology, combining the argument vector, and using the CLS vector to predict the chapter relationship, the problem of low accuracy in chapter relationship recognition in the existing technology is solved, and a higher recognition accuracy is achieved.
Patent Information
- Application Number
- CN202111325913.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-10
- Publication Date
- 2025-09-19
- Estimated Expiration
- 2041-11-10
AI Technical Summary
The accuracy of the existing chapter relationship recognition method based on Brownian clustering is not high.
The pre-trained language model BERT is used to encode the two texts, and the Brown cluster vector and argument vector are combined to predict the chapter relationship through the CLS vector.
Improved the accuracy of text relationship recognition.
Smart Images

Figure CN115936000B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of natural language processing technology, and in particular to a method, system, device and computer storage medium for identifying paragraph relationships. Background Art
[0002] Discourse relationship recognition involves identifying the discourse relationship between two given text segments. Specifically, given two text segments, for example, "Today's weather is fine, but yesterday there were thunder and lightning," the discourse relationship between the two segments is predicted to be a transition.
[0003] In the existing technology, Brownian clustering features are usually used to realize chapter relationship recognition. However, the chapter relationship recognition methods based on Brownian clustering all add Brownian clustering as discrete features to the chapter relationship classifier, and the accuracy of chapter relationship recognition is not high. Summary of the Invention
[0004] In view of this, embodiments of the present invention provide a method, system, device, and computer storage medium for identifying chapter relationships, so as to achieve the purpose of improving the accuracy of chapter relationship identification.
[0005] To achieve the above objectives, the embodiments of the present invention provide the following technical solutions:
[0006] A first aspect of an embodiment of the present invention discloses a method for identifying chapter relationships, the method comprising:
[0007] Get two paragraphs of text describing the object;
[0008] Input the two texts into the pre-trained language model BERT for encoding and output text semantic representation;
[0009] Performing Brownian cluster mapping on the two texts to obtain Brownian cluster vectors;
[0010] Mark the two paragraphs of text as the first argument and the second argument respectively, and obtain the first argument vector and the second argument vector corresponding to the two paragraphs of text;
[0011] Combining the first argument vector and the second argument vector to obtain argument vectors of the two paragraphs of text;
[0012] Obtaining a classification CLS vector based on the text semantic representation, the Brownian cluster vector, and the argument vector;
[0013] The CLS vector is used to predict the chapter relationship between the two texts to obtain the chapter relationship between the two texts.
[0014] Optionally, performing Brownian cluster mapping on the two text segments to obtain a Brownian cluster vector includes:
[0015] For each piece of text, a category index pointing to the Brownian clustering of the text is established;
[0016] Based on the category index of each Brownian cluster, obtaining a vector corresponding to each category index;
[0017] The vectors corresponding to each of the category indices are combined to obtain a Brownian clustering vector.
[0018] Optionally, obtaining a vector corresponding to each category index based on each Brownian cluster includes:
[0019] Based on the category index of each Brownian cluster, obtaining a word vector with the same category index in the text;
[0020] Calculate the sum of the word vectors with the same category index in the text, and use the average of the sums as the vector corresponding to each category index.
[0021] Optionally, the using the CLS vector to predict the chapter relationship between the two texts to obtain the chapter relationship between the two texts includes:
[0022] The CLS vector is used as the input of the Softmax logistic regression model to predict the chapter relationship between the two texts, and the chapter relationship between the two texts is output.
[0023] Optionally, also include:
[0024] The chapter relationship between the two paragraphs of text and the standard category label are used as inputs of the loss function to calculate the loss value, thereby obtaining the loss value of the chapter relationship between the two paragraphs of text.
[0025] A second aspect of an embodiment of the present invention discloses a chapter relationship recognition system, the system comprising:
[0026] The acquisition module is used to obtain two paragraphs of text describing the object;
[0027] An encoding module, configured to input the two text segments into a pre-trained language model BERT for encoding and output a semantic representation of the text;
[0028] A mapping module, configured to perform Brownian cluster mapping on the two text segments to obtain a Brownian cluster vector;
[0029] a marking module, configured to mark the two paragraphs of text as first arguments and second arguments, respectively, and obtain first argument vectors and second argument vectors corresponding to the two paragraphs of text;
[0030] a combining module, configured to combine the first argument vector and the second argument vector to obtain argument vectors of the two paragraphs of text;
[0031] An obtaining module, configured to obtain a CLS vector based on the text semantic representation, the Brownian clustering vector, and the argument vector;
[0032] The prediction module is used to predict the chapter relationship between the two text segments using the CLS vector to obtain the chapter relationship between the two text segments.
[0033] Optionally, the mapping module is specifically configured to:
[0034] For each segment of the text, a category index of the Brownian cluster pointing to the text is established; based on the category index of each Brownian cluster, a vector corresponding to each category index is obtained; and by combining the vectors corresponding to each category index, a Brownian cluster vector is obtained.
[0035] Optionally, the prediction module is specifically used to:
[0036] The CLS vector is used as the input of the Softmax logistic regression model to predict the chapter relationship between the two texts, and the chapter relationship between the two texts is output.
[0037] A third aspect of an embodiment of the present invention discloses an electronic device, which is used to run a program, wherein the program, when running, executes the chapter relationship recognition method as described in any one of the first aspects of the embodiment of the present invention.
[0038] A fourth aspect of an embodiment of the present invention discloses a computer storage medium, which includes a stored program, wherein when the program is running, the device where the storage medium is located is controlled to execute the chapter relationship identification method as described in any one of the first aspects of the embodiment of the present invention.
[0039] Based on the above-mentioned embodiments of the present invention, a method, system, device, and computer storage medium for identifying chapter relationships are provided. The method includes: obtaining two texts describing an object; inputting the two texts into a pre-trained language model BERT for encoding and outputting a text semantic representation; performing Brownian cluster mapping on the two texts to obtain Brownian cluster vectors; marking the two texts as first arguments and second arguments, respectively, to obtain first argument vectors and second argument vectors corresponding to the two texts; combining the first argument vector and the second argument vector to obtain argument vectors for the two texts; obtaining a CLS vector based on the text semantic representation, the Brownian cluster vector, and the argument vector; and predicting the chapter relationship between the two texts using the CLS vector to obtain the chapter relationship between the two texts. In this solution, the two texts are encoded using the pre-trained language model BERT, and the chapter relationship between the two texts is predicted using the CLS vector obtained based on the text semantic representation, the Brownian cluster vector, and the argument vector, thereby improving the accuracy of chapter relationship identification. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are merely embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
[0041] Figure 1 A flow chart of a method for identifying chapter relationships provided by an embodiment of the present invention;
[0042] Figure 2 A schematic diagram of a process for obtaining a Brownian clustering vector provided by an embodiment of the present invention;
[0043] Figure 3 A schematic diagram of a process for obtaining a vector corresponding to each category index provided by an embodiment of the present invention;
[0044] Figure 4 A schematic flow chart of another method for identifying chapter relationships provided by an embodiment of the present invention;
[0045] Figure 5 A schematic diagram of the structure of a chapter relationship recognition system provided by an embodiment of the present invention;
[0046] Figure 6 A schematic diagram of the structure of another chapter relationship recognition system provided by an embodiment of the present invention;
[0047] Figure 7 A schematic structural diagram of an electronic device 70 provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0048] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.
[0049] In this application, the terms "comprises," "comprising," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or apparatus that includes a list of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not preclude the presence of additional identical elements in the process, method, article, or apparatus that includes the element.
[0050] As can be seen from the background art, when the existing Brownian clustering chapter relationship recognition method is used to identify chapter relationships, the accuracy of chapter relationship recognition is not high.
[0051] Therefore, an embodiment of the present invention provides a method, system, device and computer storage medium for identifying chapter relationships. In this solution, a pre-trained language model BERT is used to encode two paragraphs of text, and a CLS vector obtained based on text semantic representation, Brownian clustering vector and argument vector is used to predict the chapter relationship between the two paragraphs of text, thereby improving the accuracy of chapter relationship identification.
[0052] like Figure 1 FIG. 1 is a flow chart of a method for identifying chapter relationships according to an embodiment of the present invention. The method mainly includes the following steps:
[0053] Step S101: Obtain two paragraphs of text describing an object.
[0054] In step S101 , the objects may be the same object or different objects, which is not limited in the present invention.
[0055] For example, there are two paragraphs of text: the computer screen is large, and the mobile phone screen is small. In this case, the objects in these two paragraphs of text are the computer and the mobile phone, which are different objects.
[0056] For example, there are two texts: The computer has a large screen and a large memory. In this case, the objects in these two texts are both computers, which are the same object.
[0057] In the specific implementation of step S101 , when performing chapter relationship recognition, it is necessary to determine two paragraphs of text for chapter relationship recognition. Therefore, it is necessary to obtain two specific paragraphs of text describing the object.
[0058] Step S102: Input the two texts into the pre-trained language model BERT for encoding, and output the text semantic representation.
[0059] In step S102 , the pre-trained language model BERT is a bidirectional conversion decoding model that can simultaneously utilize information of the previous word and the following word.
[0060] The text semantic representation can be: h = (h0, h1, h2, ..., h N ), where N is the total length of the two texts, that is, the number of words contained in the two texts.
[0061] It should be noted that in the original pre-trained language model BERT, each word in the text consists of two parts: word vector and position vector, as shown in formula (1):
[0062] e(a)=w(a)+p(a) (1),
[0063] Among them, a is a word, e(a) is the vector of a, w(a) is the word vector of a, and p(a) is the position vector of a.
[0064] In the specific implementation of step S102, the two acquired texts are used as inputs of the pre-trained language model BERT, and are input into the pre-trained language model BERT for encoding to obtain text semantic representation, and the text semantic representation is output.
[0065] Step S103: Perform Brownian cluster mapping on the two text segments to obtain Brownian cluster vectors.
[0066] In step S103, if a is a word, b(a) can be used to represent the Brownian clustering vector of a.
[0067] In the specific implementation of step S103 , the two acquired text segments are mapped to obtain Brownian cluster vectors pointing to the two text segments, and the Brownian cluster vectors are obtained based on the category indexes of all Brownian clusters corresponding to the two text segments.
[0068] Optionally, step S103 is executed to perform Brownian cluster mapping on the two text segments to obtain the Brownian cluster vector, such as Figure 2 FIG. 1 is a flow chart of obtaining a Brownian clustering vector according to an embodiment of the present invention, which mainly includes the following steps:
[0069] Step S201: For each text segment, a category index pointing to the Brownian clustering of the text is established.
[0070] In the process of implementing step S201, when establishing the category index of the Brownian cluster pointing to the text for each paragraph of text, it is first necessary to introduce the category index of the Brownian cluster of the text, and then determine the category index of the Brownian cluster pointing to each paragraph of text, so as to establish the category index of the Brownian cluster pointing to the text.
[0071] Step S202: Based on the category index of each Brownian cluster, obtain a vector corresponding to each category index.
[0072] In the specific implementation of step S202, based on the category index of each Brownian cluster, it is necessary to obtain the word vectors with the same category index in the text, and based on the word vectors with the same category index in the text, obtain the vector corresponding to each category index.
[0073] Optionally, step S202 is performed to obtain the vector corresponding to each category index based on the category index of each Brownian cluster, such as Figure 3 FIG. 1 is a flow chart of obtaining a vector corresponding to each category index provided by an embodiment of the present invention, which mainly includes the following steps:
[0074] Step S301: Based on the category index of each Brownian cluster, word vectors with the same category index in the text are obtained.
[0075] In the specific implementation of step S301 , based on the category index of each Brownian cluster, word vectors with the same category index are searched in the text to obtain word vectors with the same category index in the text.
[0076] For example, there are three words in the text, namely you, me, she and he. The category index of the Brownian cluster corresponding to you, me and him is 1, and the category index of the Brownian cluster corresponding to her is 2. In this text, find the words with the same category index as you, me and he, and thus obtain the word vectors corresponding to you, me and him, which are w(you), w(me) and w(he) respectively.
[0077] Step S302: Calculate the sum of word vectors with the same category index in the text, and use the average of the sums as the vector corresponding to each category index.
[0078] In the specific implementation of step S302, all word vectors with the same category index in the text are added to obtain specific numerical values, and the average value of the numerical values is calculated, and the average value of the numerical values is used as the vector corresponding to each category index.
[0079] Taking the example in step S301 as an example, the word vectors of the words with the same category index (you, me, and him) in the text are obtained. These three word vectors are added together to obtain specific values, and the average value of the values is calculated. The average value of the values is used as the vector corresponding to each category index. Specifically, the vector corresponding to category index 1 is shown in formula (2):
[0080] b1=(w(you)+w(me)+w(him)) / 3 (2)
[0081] Among them, w(you) is the word vector corresponding to "you", w(I) is the word vector corresponding to "I", and w(he) is the word vector corresponding to "he".
[0082] Step S203: combining the vectors corresponding to each category index to obtain a Brownian clustering vector.
[0083] In the specific implementation of step S203 , a Brownian clustering operation is performed on the vector corresponding to each obtained category index to obtain a Brownian clustering vector.
[0084] Among them, Brownian clustering is a bottom-up hierarchical clustering algorithm. Based on this hierarchical clustering algorithm, Brownian clustering is performed on the vector corresponding to each category index to obtain a Brownian clustering vector.
[0085] Step S104: Mark the two text segments as first arguments and second arguments respectively, and obtain the first argument vector and the second argument vector corresponding to the two text segments.
[0086] In step S104 , if a is a word, r(a) can be used to represent the argument vector of a.
[0087] In the specific implementation process of step S104, the first paragraph of the two obtained texts is marked as the first argument, and the first argument vector corresponding to the first paragraph of the two texts is obtained, and the second paragraph of the two obtained texts is marked as the second argument, and the second argument vector corresponding to the second paragraph of the two texts is obtained.
[0088] For example, the first paragraph is: "The weather is very good today" and the second paragraph is: "There were thunder and lightning yesterday." Mark the first paragraph "The weather is very good today" as the first argument, use "a" to represent the words in the first argument, and use subscripts to distinguish the words in the first argument. The first argument vector r(a1, a2, a3, a4, a5, a6) corresponding to "The weather is very good today" is obtained. Mark "There were thunder and lightning yesterday" as the second argument, use "b" to represent the words in the second argument, and also use subscripts to distinguish the words in the first argument. The second argument vector r(b1, b2, b3, b4, b5, b6, b7) corresponding to "There were thunder and lightning yesterday" is obtained.
[0089] Step S105: Combine the first argument vector and the second argument vector to obtain the argument vectors of the two text segments.
[0090] In the specific implementation of step S105, the first argument vector corresponding to the first paragraph of the two texts and the second argument vector corresponding to the second paragraph of the two texts are merged to obtain the final argument vector, that is, the argument vectors of the two texts.
[0091] Taking step S104 as an example, the first argument vector obtained is r(a1, a2, a3, a4, a5, a6), and the second argument vector is r(b1, b2, b3, b4, b5, b6, b7). The first argument vector r(a1, a2, a2, a3, a4, a5) and the second argument vector r(b1, b2, b3, b4, b5, b6, b7) are merged to obtain the argument vectors of the two texts "The weather is very good today, but there were thunder and lightning yesterday".
[0092] It should be noted that the argument vectors of the two paragraphs of text finally obtained include the argument vectors of each word in the first paragraph of text and the argument vectors of each word in the second paragraph of text, and the "0" in the argument vector obtained above represents a placeholder, which is used to more intuitively describe the final argument vector.
[0093] Step S106: Obtain a CLS vector based on the text semantic representation, the Brownian clustering vector, and the argument vector.
[0094] In the specific implementation of step S106, based on the text semantic representation, Brown cluster vector and argument vector, the pre-trained language model BERT is used to encode the text semantic representation, Brown cluster vector and argument vector to obtain a CLS vector.
[0095] Step S107: using the CLS vector to predict the chapter relationship between the two texts, and obtaining the chapter relationship between the two texts.
[0096] Optionally, step S107 uses the CLS vector to predict the chapter relationship between the two texts to obtain the chapter relationship between the two texts, including:
[0097] The CLS vector is used as the input of the Softmax logistic regression model to predict the chapter relationship between the two texts and output the chapter relationship between the two texts.
[0098] Specifically, the obtained CLS vector is used as the input of the logistic regression model Softmax, and is input into the logistic regression model Softmax to predict the chapter relationship between the two texts, and output the chapter relationship between the two texts.
[0099] Based on the above-mentioned embodiment of the present invention, a method for identifying chapter relations is provided, which obtains two paragraphs of text describing an object; inputs the two paragraphs of text into a pre-trained language model BERT for encoding, and outputs a text semantic representation; performs Brownian cluster mapping on the two paragraphs of text to obtain a Brownian cluster vector; labels the two paragraphs of text as first arguments and second arguments respectively, and obtains the first argument vector and second argument vector corresponding to the two paragraphs of text; combines the first argument vector and the second argument vector to obtain the argument vector of the two paragraphs of text; obtains a CLS vector based on the text semantic representation, the Brownian cluster vector, and the argument vector; and uses the CLS vector to predict the chapter relation of the two paragraphs of text, thereby obtaining the chapter relation of the two paragraphs of text. In this solution, the two paragraphs of text are encoded using the pre-trained language model BERT, and the chapter relation of the two paragraphs of text is predicted using the CLS vector obtained based on the text semantic representation, the Brownian cluster vector, and the argument vector, thereby improving the accuracy of chapter relation identification.
[0100] Based on the above embodiments of the present invention Figure 1 The chapter relationship identification method shown in Figure 4 FIG. 1 is a flow chart of another method for identifying chapter relationships according to an embodiment of the present invention. The method mainly includes the following steps:
[0101] Step S401: Obtain two paragraphs of text describing the object.
[0102] Step S402: Input the two texts into the pre-trained language model BERT for encoding, and output the text semantic representation.
[0103] Step S403: Perform Brownian cluster mapping on the two text segments to obtain Brownian cluster vectors.
[0104] Step S404: Mark the two text segments as first arguments and second arguments respectively, and obtain the first argument vector and the second argument vector corresponding to the two text segments.
[0105] Step S405: Combine the first argument vector and the second argument vector to obtain the argument vectors of the two text segments.
[0106] Step S406: Obtain a CLS vector based on the text semantic representation, the Brownian clustering vector, and the argument vector.
[0107] Step S407: using the CLS vector to predict the chapter relationship between the two texts, and obtaining the chapter relationship between the two texts.
[0108] The execution principle and process of the above steps S401 to S407 are the same as Figure 1 The execution principles and processes of steps S101 to S107 disclosed in are the same as those disclosed in , and can be referred to, and will not be repeated here.
[0109] Step S408: The chapter relationship between the two texts and the standard category label are used as inputs of the loss function to calculate the loss value, thereby obtaining the loss value of the chapter relationship between the two texts.
[0110] In the specific implementation of step S408, the chapter relationship between the two paragraphs of text and the standard category label are used as inputs of the loss function, and are input into the loss function to calculate the loss value, thereby obtaining the loss value of the chapter relationship between the two paragraphs of text.
[0111] Based on the above-mentioned embodiment of the present invention, a method for identifying chapter relations is provided, which comprises obtaining two texts describing an object; inputting the two texts into a pre-trained language model BERT for encoding and outputting a text semantic representation; performing Brownian cluster mapping on the two texts to obtain a Brownian cluster vector; marking the two texts as first arguments and second arguments respectively to obtain first argument vectors and second argument vectors corresponding to the two texts; combining the first argument vector and the second argument vector to obtain an argument vector for the two texts; obtaining a CLS vector based on the text semantic representation, the Brownian cluster vector, and the argument vector; and predicting the chapter relation between the two texts using the CLS vector to obtain the chapter relation between the two texts. In this solution, the two texts are encoded using the pre-trained language model BERT, and the chapter relation between the two texts is predicted using the CLS vector obtained based on the text semantic representation, the Brownian cluster vector, and the argument vector. A loss value is further calculated for the chapter relation between the two texts, thereby measuring the error or loss of the chapter relation between the two texts, thereby improving the accuracy of chapter relation identification.
[0112] In order to better understand the chapter relationship identification method provided by the above embodiment of the present invention, an example is given below to illustrate.
[0113] For example, paragraph 1 is "He got up late today" and paragraph 2 is "So he was late."
[0114] First, obtain chapter 1 and chapter 2, input chapter 1 and chapter 2 into the pre-trained language model BERT for encoding, and obtain the semantic representation of chapter 1 and chapter 2 h = (h0, h1, h2, ..., h 11 ), output text semantic representation h=(h0,h1,h2,...,h 11 ).
[0115] Next, we create the category indexes of the Brownian cluster pointing to chapter 1 and chapter 2 respectively.
[0116] Assume that the category indexes of the Brownian clusters corresponding to the words in chapter 1 are 1, 2, 3, 4, 5, and 6 respectively, and the category indexes of the Brownian clusters corresponding to the words in chapter 2 are 1, 2, 3, 4, and 6 respectively.
[0117] According to the category index of each Brown cluster, search for the word vectors with the same category index in Passage 1 and Passage 2. The specific words found with the same category index are: 今 and 所, 天 and 以, 他 and 迟, 起 and 到, 了 and 了. Obtain the word vectors in Passage 1 and Passage 2 with the same category index, which are w(今) and w(所), w(天) and w(以), w(他) and w(迟), w(起) and w(到), w(了) and w(了).
[0118] Calculate the sum of the word vectors with the same category index in Passage 1 and Passage 2, and take the average of the sum as the vector corresponding to each category index, specifically:
[0119] The vector corresponding to category index 1 is b1 = (w(今) + w(所)) / 2;
[0120] The vector corresponding to category index 2 is b2 = (w(天) + w(以)) / 2;
[0121] The vector corresponding to category index 3 is b3 = (w(他) + e(迟)) / 2;
[0122] The vector corresponding to category index 4 is b4 = (w(起) + w(到)) / 2;
[0123] The vector corresponding to category index 5 is b5 = w(晚) / 1;
[0124] The vector corresponding to category index 6 is b6 = (w(了) + w(了)) / 2.
[0125] Combine the vectors corresponding to each category index to obtain the Brown cluster vector. Specifically: Perform the Brown clustering operation on the vectors corresponding to each category index to obtain the Brown cluster vector b = (b1, b2, b3, b4, b5, b6).
[0126] Next, mark Passage 1 as the first argument, use "a" to represent the words in the first argument, and use subscripts to distinguish each word in the first argument, obtaining the first argument vector r(a1, a2, a3, a4, a5, a6) corresponding to "今天他起晚了". Mark Passage 2 as the second argument, use "b" to represent the words in the second argument, and also use subscripts to distinguish each word in the first argument, obtaining the second argument vector r(b1, b2, b3, b4, b5) corresponding to "所以迟到了".
[0127] Merge the first argument vector and the second argument vector to obtain the argument vector of Passage 1 and Passage 2
[0128] It should be noted that the argument vectors of the two paragraphs of text finally obtained include the argument vectors of each word in the first paragraph of text and the argument vectors of each word in the second paragraph of text, and the "0" in the argument vector obtained above represents a placeholder, which is used to more intuitively describe the final argument vector.
[0129] Next, based on the text semantic representation, Brown cluster vector and argument vector, the pre-trained language model BERT is used to encode the text semantic representation, Brown cluster vector and argument vector to obtain the CLS vector.
[0130] Finally, the CLS vector is used as the input of the Softmax logistic regression model to predict the chapter relationship between the two texts. It is found that the chapter relationship between Chapter 1 and Chapter 2 is causal, and the chapter relationship between Chapter 1 and Chapter 2 is output.
[0131] Based on a chapter relationship identification method provided by an embodiment of the present invention, chapters 1 and 2 are encoded using the pre-trained language model BERT, and the chapter relationship between the two texts is predicted using a CLS vector obtained based on text semantic representation, Brownian clustering vector, and argument vector, thereby improving the accuracy of chapter relationship identification.
[0132] Corresponding to the chapter relationship identification method shown in the above embodiment of the present invention, the embodiment of the present invention also provides a chapter relationship identification system, such as Figure 5 As shown, the chapter relationship recognition system includes: an acquisition module 51, an encoding module 52, a mapping module 53, a marking module 54, a combination module 55, a obtaining module 56 and a prediction module 57.
[0133] The acquisition module 51 is used to acquire two paragraphs of text describing the object.
[0134] The encoding module 52 is used to input two text segments into the pre-trained language model BERT for encoding and output text semantic representation.
[0135] The mapping module 53 is used to perform Brownian cluster mapping on the two text segments to obtain Brownian cluster vectors.
[0136] The marking module 54 is used to mark the two sections of text as the first argument and the second argument respectively, and obtain the first argument vector and the second argument vector corresponding to the two sections of text.
[0137] The combining module 55 is used to combine the first argument vector and the second argument vector to obtain the argument vectors of the two text segments.
[0138] The obtaining module 56 is used to obtain a CLS vector based on the text semantic representation, the Brownian clustering vector and the argument vector.
[0139] The prediction module 57 is used to predict the chapter relationship between two text segments using the CLS vector to obtain the chapter relationship between the two text segments.
[0140] It should be noted that the specific principles and execution processes of each module in the chapter relationship identification system disclosed in the above embodiment of the present invention are the same as those of the chapter relationship identification method implemented in the above embodiment of the present invention. Please refer to the corresponding parts of the chapter relationship identification method disclosed in the above embodiment of the present invention, and no further details will be given here.
[0141] Based on the above-mentioned embodiment of the present invention, a chapter relationship recognition system is provided. The system obtains two texts describing an object; inputs the two texts into a pre-trained language model BERT for encoding, and outputs a text semantic representation; performs Brownian cluster mapping on the two texts to obtain Brownian cluster vectors; labels the two texts as first arguments and second arguments, respectively, to obtain first argument vectors and second argument vectors corresponding to the two texts; combines the first argument vectors and second argument vectors to obtain argument vectors for the two texts; obtains a CLS vector based on the text semantic representation, the Brownian cluster vector, and the argument vector; and uses the CLS vector to predict the chapter relationship between the two texts, thereby obtaining the chapter relationship between the two texts. In this solution, the two texts are encoded using the pre-trained language model BERT, and the chapter relationship between the two texts is predicted using the CLS vector obtained based on the text semantic representation, the Brownian cluster vector, and the argument vector, thereby improving the accuracy of chapter relationship recognition.
[0142] Optional, based on the above Figure 5 The mapping module 53 shown is specifically configured to:
[0143] For each piece of text, a category index pointing to the Brownian cluster of the text is established; based on the category index of each Brownian cluster, a vector corresponding to each category index is obtained; and combined with the vectors corresponding to each category index, a Brownian cluster vector is obtained.
[0144] A chapter relationship recognition system provided by an embodiment of the present invention performs Brownian cluster mapping on two text segments to obtain Brownian cluster vectors, thereby improving the accuracy of chapter relationship recognition.
[0145] Optional, based on the above Figure 5 The mapping module 53 shown, which is used to obtain the vector corresponding to each category index based on the category index of each Brownian cluster, is specifically used to:
[0146] Based on the category index of each Brownian cluster, the word vectors with the same category index in the text are obtained; the sum of the word vectors with the same category index in the text is calculated, and the average of the sums is used as the vector corresponding to each category index.
[0147] A chapter relationship recognition system provided by an embodiment of the present invention utilizes the category index of each Brownian cluster to obtain a vector corresponding to each category index, thereby improving the accuracy of chapter relationship recognition.
[0148] Optional, based on the above Figure 5 The prediction module 57 shown is specifically configured to:
[0149] The CLS vector is used as the input of the Softmax logistic regression model to predict the chapter relationship between the two texts and output the chapter relationship between the two texts.
[0150] A chapter relationship recognition system provided by an embodiment of the present invention uses the obtained CLS vector to predict the chapter relationship between two texts, thereby improving the accuracy of chapter relationship recognition.
[0151] Based on the above Figure 5 The chapter relationship recognition system shown, combined with Figure 5 ,like Figure 6 As shown, the chapter relationship recognition system is further provided with a loss value calculation module 58.
[0152] The loss value calculation module 58 is used to calculate the loss value by taking the chapter relationship between the two text segments and the standard category label as inputs of the loss function to obtain the loss value of the chapter relationship between the two text segments.
[0153] A chapter relationship recognition system provided by an embodiment of the present invention calculates a loss value of the chapter relationship between two text segments, thereby measuring the error or loss degree of the chapter relationship between the two text segments, thereby improving the accuracy of chapter relationship recognition.
[0154] Based on the chapter relationship recognition system disclosed in the above embodiment of the present invention, each of the above modules can be implemented by a hardware device composed of a processor and a memory. Specifically, each of the above modules is stored in the memory as a program unit, and the processor executes the program unit stored in the memory to realize chapter relationship recognition.
[0155] The processor includes a kernel, which retrieves the corresponding program unit from the memory. One or more kernels can be set, and the recognition of chapter relationships can be achieved by adjusting the kernel parameters.
[0156] An embodiment of the present invention provides a computer storage medium, which includes a program for storing chapter relationship recognition. When the program is executed by a processor, the above-mentioned chapter relationship recognition method is implemented.
[0157] An embodiment of the present invention provides a processor for running a program, wherein the program executes Figure 1Public method for identifying discourse relations.
[0158] An embodiment of the present invention provides an electronic device 70, such as Figure 7 , which is a structural diagram of an electronic device 70 provided by an embodiment of the present invention.
[0159] The electronic device in the embodiment of the present invention may be a server, a PC, a PAD, a mobile phone, etc.
[0160] The electronic device includes at least one processor 701 , at least one memory 702 connected to the processor, and a bus 703 .
[0161] The processor 701 and the memory 702 communicate with each other via the bus 703. The processor 701 is configured to execute the program stored in the memory 702.
[0162] Memory 702 is used to store a program, which is at least used to: obtain two paragraphs of text describing an object; input the two paragraphs of text into a pre-trained language model BERT for encoding, and output a text semantic representation; perform Brownian cluster mapping on the two paragraphs of text to obtain a Brownian cluster vector; mark the two paragraphs of text as the first argument and the second argument respectively, and obtain the first argument vector and the second argument vector corresponding to the two paragraphs of text; combine the first argument vector and the second argument vector to obtain the argument vector of the two paragraphs of text; obtain a CLS vector based on the text semantic representation, the Brownian cluster vector and the argument vector; use the CLS vector to predict the chapter relationship between the two paragraphs of text to obtain the chapter relationship between the two paragraphs of text.
[0163] The present application also provides a computer program product, which, when executed on an electronic device, is adapted to execute a program for initializing the following method steps:
[0164] Obtain two paragraphs of text describing an object; input the two paragraphs of text into the pre-trained language model BERT for encoding, and output the text semantic representation; perform Brownian clustering mapping on the two paragraphs of text to obtain Brownian clustering vectors; mark the two paragraphs of text as the first argument and the second argument respectively, and obtain the first argument vector and the second argument vector corresponding to the two paragraphs of text; combine the first argument vector and the second argument vector to obtain the argument vector of the two paragraphs of text; obtain the CLS vector based on the text semantic representation, Brownian clustering vector and argument vector; use the CLS vector to predict the chapter relationship of the two paragraphs of text to obtain the chapter relationship of the two paragraphs of text.
[0165] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the steps in the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0166] In a typical configuration, the device includes one or more processors (CPUs), memory, and a bus. The device may also include input / output interfaces, network interfaces, and the like.
[0167] Memory may include non-permanent memory in a computer-readable medium, random access memory (RAM), and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory includes at least one memory chip. Memory is an example of a computer-readable medium.
[0168] Computer-readable media includes permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. The information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory computer-readable media (transitory media), such as modulated data signals and carrier waves.
[0169] Each embodiment in this specification is described in a progressive manner. The same or similar parts between the embodiments can be referred to each other. Each embodiment focuses on the differences from other embodiments. In particular, for system or system embodiments, since they are basically similar to method embodiments, the description is relatively simple. For relevant parts, refer to the partial description of the method embodiment. The system and system embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment. A person of ordinary skill in the art can understand and implement it without expending creative work.
[0170] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the components and steps of each example according to their functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present invention.
[0171] The above description of the disclosed embodiments is intended to enable one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be readily apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention is not limited to the embodiments shown herein but is intended to conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for identifying chapter relationships, characterized in that: The method comprises: Get two paragraphs of text describing the object; Input the two texts into the pre-trained language model BERT for encoding and output text semantic representation; Performing Brownian cluster mapping on the two texts to obtain Brownian cluster vectors; Mark the two paragraphs of text as the first argument and the second argument respectively, and obtain the first argument vector and the second argument vector corresponding to the two paragraphs of text; Combining the first argument vector and the second argument vector to obtain argument vectors of the two paragraphs of text; Obtaining a classification CLS vector based on the text semantic representation, the Brownian cluster vector, and the argument vector; The CLS vector is used to predict the chapter relationship between the two texts to obtain the chapter relationship between the two texts.
2. The method according to claim 1, characterized in that The Brownian clustering mapping is performed on the two text segments to obtain a Brownian clustering vector, including: For each piece of text, a category index pointing to the Brownian clustering of the text is established; Based on the category index of each Brownian cluster, obtaining a vector corresponding to each category index; The vectors corresponding to each of the category indices are combined to obtain a Brownian clustering vector.
3. The method according to claim 2, characterized in that The process of obtaining a vector corresponding to each category index based on each Brownian cluster includes: Based on the category index of each Brownian cluster, obtaining a word vector with the same category index in the text; Calculate the sum of the word vectors with the same category index in the text, and use the average of the sums as the vector corresponding to each category index.
4. The method according to claim 1, wherein The method of using the CLS vector to predict the chapter relationship between the two texts to obtain the chapter relationship between the two texts includes: The CLS vector is used as the input of the Softmax logistic regression model to predict the chapter relationship between the two texts, and the chapter relationship between the two texts is output.
5. The method according to claim 1, wherein Also includes: The chapter relationship between the two paragraphs of text and the standard category label are used as inputs of the loss function to calculate the loss value, thereby obtaining the loss value of the chapter relationship between the two paragraphs of text.
6. A chapter relationship recognition system, characterized in that: The system comprises: The acquisition module is used to obtain two paragraphs of text describing the object; An encoding module, configured to input the two text segments into a pre-trained language model BERT for encoding and output a semantic representation of the text; A mapping module, configured to perform Brownian cluster mapping on the two text segments to obtain a Brownian cluster vector; a marking module, configured to mark the two paragraphs of text as first arguments and second arguments, respectively, and obtain first argument vectors and second argument vectors corresponding to the two paragraphs of text; a combining module, configured to combine the first argument vector and the second argument vector to obtain argument vectors of the two paragraphs of text; An obtaining module, configured to obtain a CLS vector based on the text semantic representation, the Brownian clustering vector, and the argument vector; The prediction module is used to predict the chapter relationship between the two text segments using the CLS vector to obtain the chapter relationship between the two text segments.
7. The system according to claim 6, characterized in that The mapping module is specifically used for: For each segment of the text, a category index of the Brownian cluster pointing to the text is established; based on the category index of each Brownian cluster, a vector corresponding to each category index is obtained; and by combining the vectors corresponding to each category index, a Brownian cluster vector is obtained.
8. The system according to claim 6, wherein: The prediction module is specifically used for: The CLS vector is used as the input of the Softmax logistic regression model to predict the chapter relationship between the two texts, and the chapter relationship between the two texts is output.
9. An electronic device, characterized in that: The electronic device is used to run a program, wherein the program executes the chapter relationship recognition method according to any one of claims 1 to 5 when running.
10. A computer storage medium, characterized in that The storage medium includes a stored program, wherein when the program is running, the device where the storage medium is located is controlled to execute the chapter relationship identification method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Chinese event co-reference resolution method and system
CN106021229A
Implicit discourse relation automatic recognition method and system
CN112528642A