Reference resolution method and apparatus
By constructing and processing the sentence matrix and using a semantic segmentation model to identify pronouns, the problem of low efficiency in pronoun resolution in human-computer interaction is solved, and smoother human-computer dialogue is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-27
- Publication Date
- 2026-03-20
AI Technical Summary
The lack of effective referential resolution solutions in existing technologies leads to poor smoothness in human-computer interaction dialogue.
By constructing a matrix of the current statement and the preceding statement, a feature matrix is generated. Then, a semantic segmentation model is used to identify pronouns, transforming the problem into a semantic segmentation problem to simplify the pronoun resolution process.
It improves the smoothness of human-computer interaction dialogue, accurately identifies pronouns, and simplifies the process of pronoun resolution.
Smart Images

Figure CN115618880B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the natural language processing field, and particularly relates to a reference resolution method and device. BACKGROUND
[0002] In daily conversation, our brain records the history information of the conversation, and in order to reduce redundant content, there is usually a reference in the reply, that is, "he", "this", "there" and the like, which refers to the word appearing before. Therefore, in a human-computer conversation system, the system needs to perform reference resolution on the sentence containing pronouns. The process of dividing different references representing the same entity into an equivalent set is called reference resolution. Through reference resolution, the system can understand the real semantics of the user input, so as to effectively improve the fluency of human-computer interactive conversation. However, there is still a lack of a scheme capable of accurately performing reference resolution in the prior art. SUMMARY
[0003] Therefore, the embodiments of the present application provide a reference resolution method and device, which can accurately perform reference resolution and effectively improve the fluency of human-computer interactive conversation.
[0004] In a first aspect, the embodiments of the present application provide a reference resolution method, comprising:
[0005] obtaining a current sentence containing a target pronoun, and constructing a first matrix corresponding to the current sentence;
[0006] obtaining at least one preceding sentence of the current sentence, and constructing a second matrix corresponding to the at least one preceding sentence;
[0007] generating a feature matrix corresponding to the current sentence according to the first matrix and the second matrix, the feature matrix being used to represent the correlation degree between each first word in the current sentence and a second word in the preceding sentence;
[0008] inputting the feature matrix into a semantic segmentation model to obtain a semantic segmentation result corresponding to the feature matrix;
[0009] determining a reference word corresponding to the target pronoun according to the semantic segmentation result.
[0010] Optionally, the constructing the first matrix corresponding to the current sentence comprises:
[0011] determining a feature vector of each first word in the current sentence;
[0012] combining the feature vectors of each first word to construct the first matrix corresponding to the current sentence.
[0013] Optionally, the constructing the second matrix corresponding to the at least one preceding sentence comprises:
[0014] determining a feature vector of each of the second words in the at least one preposition sentence;
[0015] combining the feature vectors of each of the second words to construct the second matrix corresponding to the preposition sentence.
[0016] Optionally, the generating, according to the first matrix and the second matrix, of the feature matrix corresponding to the current sentence comprises:
[0017] processing the first matrix and the second matrix in a dot product manner to generate the feature matrix corresponding to the current sentence.
[0018] Optionally, the inputting of the feature matrix into a semantic segmentation model to obtain a semantic segmentation result corresponding to the feature matrix comprises:
[0019] inputting the feature matrix into the semantic segmentation model to obtain a semantic segmentation matrix corresponding to the feature matrix; wherein the semantic segmentation matrix is used to represent a semantic segmentation result of the feature matrix, and an element in the semantic segmentation matrix takes a value of 0 or 1.
[0020] the determining of the referring word corresponding to the target pronoun according to the semantic segmentation result comprises:
[0021] determining a referring area corresponding to the target pronoun from the semantic segmentation matrix; wherein the referring area comprises at least one continuous element, and each of the continuous elements takes a value of 1.
[0022] determining a second word corresponding to the referring area, and determining the second word corresponding to the referring area as the referring word of the target pronoun.
[0023] Optionally, the number of the referring areas is a plurality.
[0024] the determining of the second word corresponding to the referring area, and the determining of the second word corresponding to the referring area as the referring word of the target pronoun comprises:
[0025] determining a distance value between each of the referring areas and the target pronoun;
[0026] determining, according to the distance value, a proximal referring area corresponding to the target pronoun from the plurality of referring areas;
[0027] determining a second word corresponding to the proximal referring area, and determining the second word corresponding to the proximal referring area as the referring word of the target pronoun.
[0028] Optionally, the constructing the second matrix corresponding to the at least one front sentence comprises:
[0029] Determining whether the pronoun is contained in the front sentence;
[0030] In the case that the pronoun is contained in the front sentence, determining the referent corresponding to the pronoun, and replacing the pronoun in the front sentence with the referent corresponding to the pronoun;
[0031] Constructing a second matrix corresponding to the replaced front sentence.
[0032] Optionally, after the obtaining the current sentence containing the target pronoun, the method further comprises:
[0033] Preprocessing the current sentence;
[0034] And / or,
[0035] After the obtaining the at least one front sentence of the current sentence, the method further comprises:
[0036] Preprocessing the at least one front sentence.
[0037] In a second aspect, an embodiment of the present application provides a referent resolution device, comprising:
[0038] A first constructing module, configured to obtain a current sentence containing a target pronoun, and construct a first matrix corresponding to the current sentence;
[0039] A second constructing module, configured to obtain at least one front sentence of the current sentence, and construct a second matrix corresponding to the at least one front sentence;
[0040] A matrix generating module, configured to generate a feature matrix corresponding to the current sentence according to the first matrix and the second matrix, the feature matrix being used to represent the correlation degree between each first word in the current sentence and each second word in the front sentence;
[0041] A semantic segmentation module, configured to input the feature matrix into a semantic segmentation model to obtain a semantic segmentation result corresponding to the feature matrix;
[0042] A referent resolution module, configured to determine a referent corresponding to the target pronoun according to the semantic segmentation result.
[0043] Optionally, the first constructing module is specifically configured to:
[0044] Determine a feature vector of each first word in the current sentence;
[0045] Combine the feature vectors of each first word to construct the first matrix corresponding to the current sentence.
[0046] Optionally, the second constructing module is configured to:
[0047] determine a feature vector of each second word in the at least one antecedent sentence;
[0048] combine the feature vectors of each second word to construct the second matrix corresponding to the antecedent sentence.
[0049] Optionally, the matrix generating module is configured to:
[0050] process the first matrix and the second matrix in a dot product manner to generate a feature matrix corresponding to the current sentence.
[0051] In a third aspect, an electronic device is provided, including:
[0052] one or more processors;
[0053] a storage device configured to store one or more programs,
[0054] when the one or more programs are executed by the one or more processors, the one or more processors implement the method of any of the above embodiments.
[0055] In a fourth aspect, a computer readable medium is provided, which stores a computer program, and the program is executed by a processor to implement the method of any of the above embodiments.
[0056] In a seventh aspect, a computer program product is provided, which includes a computer program, and the program is executed by a processor to implement the method of any of the above embodiments.
[0057] An embodiment of the above invention has the following advantages or beneficial effects: a first matrix corresponding to a current sentence containing a target pronoun is constructed, and a second matrix corresponding to at least one antecedent sentence of the current sentence is constructed. According to the first matrix and the second matrix, a feature matrix corresponding to the current sentence is generated. The horizontal and vertical coordinates of the feature matrix correspond to the first words in the current sentence and the second words in the antecedent sentence, respectively, and the feature matrix is used to represent the correlation degree of each first word and second word. The feature matrix is input into a semantic segmentation model to obtain a semantic segmentation result. According to the semantic segmentation result, a referring word corresponding to the target pronoun is determined. Semantic segmentation is used to divide the feature matrix into a region block with certain semantic meaning, thereby converting the reference resolution problem into a semantic segmentation problem, simplifying the reference resolution process, improving the speed of reference resolution, accurately resolving the reference, and effectively improving the smoothness of human-computer interaction dialogue.
[0058] The further effects of the above-described non-conventional optional mode will be described in the following in conjunction with the specific embodiments. BRIEF DESCRIPTION OF DRAWINGS
[0059] The accompanying drawings are used to better understand the present application and do not constitute undue limitations on the present application. Among them:
[0060] Figure 1 is a flowchart of a reference resolution method provided by the first embodiment of the present application;
[0061] Figure 2 is a flowchart of a reference resolution method provided by the second embodiment of the present application;
[0062] Figure 3 is a flowchart of a reference resolution method provided by the third embodiment of the present application;
[0063] Figure 4 is a schematic diagram of a reference resolution model structure provided by the embodiments of the present application;
[0064] Figure 5 is a structural schematic diagram of a reference resolution device provided by the embodiments of the present application;
[0065] Figure 6 is a structural schematic diagram of a computer system of a terminal device or a server suitable for implementing the embodiments of the present application. DETAILED DESCRIPTION
[0066] The exemplary embodiments of the present application are described below in conjunction with the accompanying drawings, which include various details of the embodiments of the present application to help understanding, and should be considered as merely exemplary. Therefore, those of ordinary skill in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present application. Also, for the sake of clarity and conciseness, the description below omits the description of well-known functions and structures.
[0067] The acquisition, storage, use, processing, etc. of data in the technical solutions of the present application comply with the relevant provisions of national laws and regulations.
[0068] Figure 1 is a flowchart of a reference resolution method provided by the first embodiment of the present application, as Figure 1 shown, the method comprises:
[0069] Step 101: Acquire a current sentence containing a target pronoun, and construct a first matrix corresponding to the current sentence.
[0070] A pronoun library can be constructed, and the pronoun library includes multiple pronouns. The pronouns can be this, this way, here, this, he, she, it, and the like. It is determined whether the current sentence includes a pronoun in the pronoun library. If yes, the pronoun resolution method provided in the embodiment of the present application is executed to perform pronoun resolution on a target pronoun in the current sentence.
[0071] The first matrix is used to represent the features of the first words in the current sentence. The first matrix corresponding to the current sentence can be constructed in the following manner: determining the feature vectors of the first words in the current sentence; and combining the feature vectors of the first words to construct the first matrix corresponding to the current sentence.
[0072] The current sentence can be split into multiple first words, and the feature vectors of the first words can be obtained by inputting the first words into the natural language processing model one by one. The first words can be single characters or single words. The natural language processing model can be constructed based on the Bert model.
[0073] The feature vectors of the first words are combined to construct the first matrix corresponding to the current sentence. The dimension of the feature vector of the first word is dim, the number of the first words in the current sentence is N, and the dimension of the generated first matrix is N*dim.
[0074] Step 102: At least one preceding sentence of the current sentence is obtained, and a second matrix corresponding to the at least one preceding sentence is constructed.
[0075] The preceding sentence is a sentence located before the current sentence. A preset number of sentences located before the current sentence can be selected as the preceding sentence according to needs. The preset number can be 1, 2, 3, and the like.
[0076] The application scenario of the embodiment of the present application can include human-computer dialogue. For example: [user: What is the weather like in Hangzhou today? Bot: It is raining in Hangzhou today. User: Why is Hangzhou always like this?]. In the example, user represents user input, and bot represents machine reply. It can be seen that the pronoun “this” is included in the sentence input by the user in the last sentence.
[0077] The multiple rounds of dialogue need to be cut into sentences. Here, the preset number can be set to 2, “Hangzhou why is always like this” is taken as the current sentence, and “Hangzhou weather how is today” and “Hangzhou today it is raining” are determined as the preceding sentences. By processing the current sentence and the preceding sentences, it is determined that the pronoun corresponding to “this” in the current sentence is “raining”.
[0078] The second matrix is used to represent the features of the second words in the preceding sentences. The second matrix corresponding to the at least one preceding sentence can be constructed in the following manner: determining the feature vectors of the second words in the at least one preceding sentence; and combining the feature vectors of the second words to construct the second matrix corresponding to the preceding sentence.
[0079] The at least one preposition sentence can be split into a plurality of second words, and each second word can be input into the natural language processing model in sequence to obtain a feature vector of each second word. The second word can be a single character or a single word. The natural language processing model can be constructed based on the Bert model. The natural language processing model used for processing the second word needs to be the same as the natural language processing model used for processing the first word.
[0080] The feature vectors of the second words are combined to construct a second matrix corresponding to the preposition sentence. The dimension of the feature vector of the second word is dim, the number of second words in the at least one preposition sentence is M, and the dimension of the generated second matrix is M*dim.
[0081] Step 103: According to the first matrix and the second matrix, a feature matrix corresponding to the current sentence is generated, and the feature matrix is used to represent the correlation degree between each first word in the current sentence and the second word in the preposition sentence.
[0082] The first matrix and the second matrix can be processed in a dot product manner to generate a feature matrix corresponding to the current sentence. The formula is: R=C*X'. Wherein, R is the feature matrix, X is the first matrix, and C is the second matrix. The feature matrix is the product of the second matrix C and the transpose matrix of the first matrix X. The dimension of the first matrix is N*dim, the dimension of the second matrix is M*dim, and the dimension of the feature matrix R is M*N.
[0083] The horizontal coordinate of the feature matrix can correspond to the first word, and the vertical coordinate of the feature can correspond to the second word. The first word contains the target pronoun. The feature matrix represents the correlation degree between the first word and the second word, and the combination of different regions in the feature matrix can represent the reference relationship between the words, so that the reference resolution problem is converted into a graph semantic segmentation problem.
[0084] Step 104: The feature matrix is input into a semantic segmentation model to obtain a semantic segmentation result corresponding to the feature matrix.
[0085] The semantic segmentation model is used to classify each element in the feature matrix. The semantic segmentation model can be constructed by using a U-net model, an FCN model, a SegNet model, or a PSPNet model.
[0086] Step 105: According to the semantic segmentation result, a reference word corresponding to the target pronoun is determined.
[0087] The semantic segmentation result represents the correlation degree between the first word and the second word. According to the semantic analysis result, at least one second word with the highest correlation degree with the target pronoun is determined from the plurality of second words, and the reference word corresponding to the target pronoun is determined according to the second word with the highest correlation degree.
[0088] For example, the pre-sentence 1 is: "Beijing Finance Bureau is in Beijing".
[0089] The pre-sentence 2 is: "How is the condition of Beijing Finance Bureau?".
[0090] The current sentence is: "Oh, it is not bad, and the weather here is more comfortable, and the treatment here is also good."
[0091] According to the semantic analysis result, it is determined that the first "here" in the current sentence has the highest correlation degree with "Beijing", so that the referring word of the first "here" is determined as "Beijing". It is determined that the second "here" in the current sentence has the highest correlation degree with "Beijing Finance Bureau", so that the referring word of the second "here" is determined as "Beijing Finance Bureau". It can be seen that the embodiment of the present application can eliminate the reference of the same pronoun in different positions respectively, so as to effectively solve the entity nesting problem.
[0092] In the embodiment of the present application, a first matrix corresponding to the current sentence containing the target pronoun is constructed, and a second matrix corresponding to at least one pre-sentence of the current sentence is constructed. According to the first matrix and the second matrix, a feature matrix corresponding to the current sentence is generated. The horizontal and vertical coordinates of the feature matrix correspond to the first word in the current sentence and the second word in the pre-sentence respectively, and the feature matrix is used to represent the correlation degree of each first word and second word. The feature matrix is input into a semantic segmentation model to obtain a semantic segmentation result. According to the semantic segmentation result, the referring word corresponding to the target pronoun is determined.
[0093] The semantic segmentation is used to divide the feature matrix into a region block with certain semantic meaning, so as to convert the reference resolution problem into a semantic segmentation problem, simplify the reference resolution process, improve the speed of reference resolution, accurately perform reference resolution, and effectively improve the smoothness of human-computer interaction dialogue.
[0094] In an embodiment of the present application, after obtaining the current sentence containing the target pronoun, the current sentence is preprocessed. And / or, after obtaining at least one pre-sentence of the current sentence, the at least one pre-sentence is preprocessed. The preprocessing includes removing stop words and punctuation marks in the sentence, modifying obvious wrong words and syntax errors, etc. By preprocessing the current sentence or the pre-sentence, the final reference result can be more accurate.
[0095] Figure 2 is a flowchart of a reference resolution method provided by the second embodiment of the present application, as shown in the figure, the method comprises: Figure 2
[0096] Step 201: obtaining a current sentence containing a target pronoun, and constructing a first matrix corresponding to the current sentence.
[0097] Step 202: Obtain at least one preceding sentence of the current sentence, and construct a second matrix corresponding to the at least one preceding sentence.
[0098] Step 203: Generate a feature matrix corresponding to the current sentence according to the first matrix and the second matrix, the feature matrix being used to represent the correlation degree of each first word in the current sentence and the second word in the preceding sentence.
[0099] Step 204: Input the feature matrix into a semantic segmentation model to obtain a semantic segmentation matrix corresponding to the feature matrix.
[0100] The semantic segmentation model can be constructed based on a U-net model. The feature matrix is input into the semantic segmentation model constructed based on the U-net model to obtain a semantic segmentation matrix output by the semantic segmentation model. The semantic segmentation matrix is used to represent the semantic segmentation result of the feature matrix, and the elements in the semantic segmentation matrix take values of 0 or 1.
[0101] In the semantic segmentation matrix, the horizontal and vertical coordinates correspond to the first word and the second word respectively. The first word contains the target pronoun. The element in the semantic segmentation matrix takes a value of 1, representing that the correlation degree of the first word corresponding to the horizontal coordinate and the second word corresponding to the vertical coordinate is relatively high.
[0102] Step 205: Determine the reference area corresponding to the target pronoun from the semantic segmentation matrix; wherein the reference area includes at least one continuous element, and the value of each continuous element is 1.
[0103] Step 206: Determine the second word corresponding to the reference area, and determine the second word corresponding to the reference area as the reference word of the target pronoun.
[0104] The elements corresponding to the target pronoun and taking continuous values of 1 are combined as the reference area of the target pronoun, and the second word corresponding to the reference area is the reference word of the target pronoun. The elements in the feature matrix represent the correlation degree of the words in the first matrix and the words in the second matrix. Here, the feature matrix can be regarded as a picture, and the feature matrix is segmented by the semantic segmentation model to obtain the area corresponding to the target pronoun, i.e. the reference area.
[0105] For example, the preceding sentence is "How is Beijing Fragrant Hill?", and the current sentence is "It is very beautiful". It can be seen that the current sentence contains the pronoun "it". Assuming that the length of the feature vector is 756, since the current sentence contains 3 words, the dimension of the first matrix X corresponding to the current sentence is 3*756.
[0106] For the second matrix corresponding to the preposition sentence, since the preposition sentence contains 7 words, the dimension of the constructed second matrix C is 7*756. The feature matrix R=C*X' is calculated, and the dimension of the feature matrix is 7*3. The horizontal and vertical coordinates in the feature matrix correspond to the first word and the second word respectively.
[0107] The feature matrix can be constructed based on a single word or based on a single word. If it is constructed based on a single word, the vertical coordinates of the feature matrix correspond to "North", "Beijing", "Xiang", "Mountain", "How", "How", and "How". The horizontal coordinates of the features correspond to "that", "very", and "beautiful".
[0108] After the feature matrix is segmented using the semantic segmentation matrix, a semantic segmentation matrix is obtained. In the semantic segmentation matrix, the values of the elements corresponding to (North, that), (Beijing, that), (Xiang, that) and (Mountain, that) are all 1. (North, that), (Beijing, that), (Xiang, that) and (Mountain, that) form a 4*1 reference area. It can be seen that the target pronoun "that" has a high degree of relevance with "North", "Beijing", "Xiang" and "Mountain", so "Beijing Xiangshan" is determined as the reference word of "that".
[0109] Similarly, the preposition sentence "Beijing Xiangshan how" can be split into "Beijing", "Xiangshan", and "how", and a 3*756 second matrix can be constructed, thereby obtaining a 3*3 feature matrix. After the feature matrix is segmented using the semantic segmentation matrix, a semantic segmentation matrix is obtained. In the semantic segmentation matrix, the values of the elements corresponding to (Beijing, that) and (Xiangshan, that) are all 1, and a 2*1 reference area is obtained. It is determined that the target pronoun "that" has a high degree of relevance with "Beijing" and "Xiangshan", so "Beijing Xiangshan" is determined as the reference word of "that".
[0110] In the embodiment of the present application, the anaphora resolution problem is converted into a similarity semantic segmentation problem, and the U-net model is used to process the feature matrix corresponding to the current sentence to identify the reference area, which can reduce the cumulative error of the model. In addition, even if there are multiple identical pronouns in the target sentence, these target pronouns correspond to different positions in the feature matrix and the semantic segmentation matrix, and through the scheme of the embodiment of the present application, the anaphora resolution can be performed for the same pronouns in different positions, so as to effectively solve the entity nesting problem.
[0111] In an embodiment of the present application, the number of reference areas is a plurality; the second word corresponding to the reference area is determined, and the second word corresponding to the reference area is determined as the reference word of the target pronoun, comprising: determining the distance value between each reference area and the target pronoun; according to the distance value, the adjacent reference area corresponding to the target pronoun is determined from the plurality of reference areas; the second word corresponding to the adjacent reference area is determined, and the second word corresponding to the adjacent reference area is determined as the reference word of the target pronoun.
[0112] From the reference area, the second word closest to the target pronoun is determined, and the distance value between the second word and the target pronoun is determined as the distance between the reference area and the target pronoun.
[0113] For example, the preceding sentence is "Hangzhou rained today", and the current sentence is "Why is Hangzhou always like this?" The current sentence contains the target pronoun "like this". In the semantic segmentation matrix, there are two reference areas corresponding to "like this". The first reference area is composed of "Hang, like this" and "State, like this", and the second reference area is composed of "Down, like this" and "Rain, like this". The distance between "State" and "like this" in the first reference area is 12, and the distance between "Rain" and "like this" in the second reference area is 8. The distance between the second reference area and the target pronoun is closer, so the second reference area is determined as the adjacent reference area, and "Rain" is determined as the reference word of the target pronoun.
[0114] In the case of multiple reference areas, the reference area closest to the target pronoun is selected as the adjacent reference area. The second word corresponding to the adjacent reference area is determined as the reference word of the target pronoun, so that the semantic recognition result is more accurate.
[0115] Figure 3 is a flowchart of a reference resolution method provided by the third embodiment of the present application, as shown in the figure, the method comprises: Figure 3
[0116] Step 301: Acquire the current sentence containing the target pronoun, and construct the first matrix corresponding to the current sentence.
[0117] Step 302: Acquire at least one preceding sentence of the current sentence, and determine whether the pronoun is contained in the preceding sentence.
[0118] Step 303: In the case that the pronoun is contained in the preceding sentence, the reference word corresponding to the pronoun is determined, and the pronoun in the preceding sentence is replaced by the reference word corresponding to the pronoun.
[0119] Step 304: Construct the second matrix corresponding to the replaced preceding sentence.
[0120] Step 305: According to the first matrix and the second matrix, generate the feature matrix corresponding to the current sentence, and the feature matrix is used to represent the correlation degree between each first word in the current sentence and the second word in the preceding sentence.
[0121] Step 306: Input the feature matrix into the semantic segmentation model to obtain the semantic segmentation result corresponding to the feature matrix.
[0122] Step 307: According to the semantic segmentation result, determine the reference word corresponding to the target pronoun.
[0123] If the preposition sentence has a pronoun, such as "What's the weather like in Hangzhou today?" "It's raining in Hangzhou today" "Why is it always like this in Hangzhou?" "It's the rainy season in Hangzhou recently" "The weather is really not suitable for me", among which "The weather is really not suitable for me" is the current sentence. Since the preposition sentence "Why is it always like this in Hangzhou?" contains the pronoun "like this", the preposition sentence needs to be resolved, and "Why is it always like this in Hangzhou?" is replaced and processed into "Why is it always raining in Hangzhou?". The preposition sentence after replacement is used to build the second matrix, so that the target pronoun is prevented from being the same as the pronoun in the preposition sentence, but due to the limitation of the number of sentences, the target pronoun cannot be found.
[0124] Figure 4 is a schematic diagram of a coreference resolution model structure provided by an embodiment of the present application, as shown in the figure, the coreference resolution model comprises an encoding layer, a feature layer and a segmentation layer. Figure 4
[0125] The encoding layer: after the current sentence and the preposition sentence are segmented, they are input into the encoder to generate the second matrix (C matrix) corresponding to the preposition sentence and the first matrix (X matrix) corresponding to the current sentence. The encoder can be selected from a Bert type encoder, such as the Roformer-V2 model of the Bert variant.
[0126] The feature layer: the similarity between each word vector in the C matrix and the X matrix is calculated, and the dot product method is used here. R = C * X', that is, the feature matrix R is equal to the product of the C matrix and the X transpose matrix, and the dimension is M*N. Wherein, M is the number of words in the preposition sentence, and N is the number of words in the current sentence. The feature matrix represents the correlation between the words in the first matrix and the words in the second matrix. The combination of different regions in the feature matrix can represent the coreference relationship between the words, and then the coreference resolution problem is converted into a graph semantic segmentation problem.
[0127] The segmentation layer: the U-net model is used as the semantic segmentation model in the semantic segmentation layer, each element in the feature matrix is classified to obtain a semantic segmentation matrix. The element in the semantic segmentation matrix takes a value of 1, representing that the correlation degree of the first word corresponding to the element and the second word is relatively high. In the semantic segmentation matrix, the target pronoun corresponding to the coreference region is determined, and the coreference region is composed of a plurality of continuous elements, and the value of each continuous element is 1.
[0128] To resolve the coreference of the pronoun corresponding to the current sentence, the current sentence needs to be converted from the text model into a corresponding semantic segmentation matrix, and the converted semantic segmentation matrix is used as a prediction target to calculate the loss with the output matrix of the semantic segmentation model, so as to further train the semantic segmentation model.
[0129] The following steps are used to resolve pronoun references: First, determine whether the current statement contains a pronoun. If the statement contains a pronoun, take the previous two rounds of dialogue as the preceding statement, and then input the preceding statement and the current statement as follows: Figure 4 The model shown yields a semantically segmented matrix.
[0130] Because semantic segmentation methods are used, the segmented shapes may be irregular, such as... Figure 4 In the case shown in r3, r3 needs to be completed into a rectangle, and the completed rectangle will be used as the referential region. It's also possible for a pronoun to correspond to more than two referential regions, as shown in Figure 4, where x6 corresponds to regions r2 and r4. Since region r4 is closer to x6, r4 is selected as the neighboring referential region, and the second word corresponding to the neighboring referential region is determined as the referent of x6.
[0131] Figure 5 This is a schematic diagram of the structure of a digestion apparatus provided in one embodiment of the present invention, as shown below. Figure 5 As shown, the device includes:
[0132] The first construction module 501 is used to obtain the current statement containing the target pronoun and construct the first matrix corresponding to the current statement;
[0133] The second construction module 502 is used to obtain at least one preceding statement of the current statement and construct a second matrix corresponding to the at least one preceding statement;
[0134] The matrix generation module 503 is used to generate a feature matrix corresponding to the current statement based on the first matrix and the second matrix. The feature matrix is used to characterize the correlation between each first word in the current statement and the second word in the preceding statement.
[0135] The semantic segmentation module 504 is used to input the feature matrix into the semantic segmentation model to obtain the semantic segmentation result corresponding to the feature matrix;
[0136] The pronoun resolution module 505 is used to determine the pronoun corresponding to the target pronoun based on the semantic segmentation result.
[0137] Optionally, the first construction module 501 is specifically used for:
[0138] Determine the feature vector of each of the first words in the current statement;
[0139] Combine the feature vectors of each of the first words to construct the first matrix corresponding to the current statement.
[0140] Optionally, the second building module 502 is specifically used for:
[0141] determining a feature vector of each of the second words in the at least one preamble sentence;
[0142] combining the feature vectors of the second words to construct the second matrix corresponding to the preamble sentence.
[0143] Optionally, the matrix generating module 503 is specifically configured to:
[0144] processing the first matrix and the second matrix in a dot product manner to generate a feature matrix corresponding to the current sentence.
[0145] Optionally, the semantic segmentation module 504 is specifically configured to:
[0146] inputting the feature matrix into the semantic segmentation model to obtain a semantic segmentation matrix corresponding to the feature matrix; wherein the semantic segmentation matrix is used to represent a semantic segmentation result of the feature matrix, and elements in the semantic segmentation matrix take values of 0 or 1;
[0147] The anaphora resolution module 505 is specifically configured to:
[0148] determining a reference area corresponding to the target pronoun from the semantic segmentation matrix; wherein the reference area includes at least one continuous element, and each of the continuous elements takes a value of 1;
[0149] determining a second word corresponding to the reference area, and determining the second word corresponding to the reference area as a reference word of the target pronoun.
[0150] Optionally, the number of the reference areas is a plurality;
[0151] The anaphora resolution module 505 is specifically configured to:
[0152] determining a distance value between each of the reference areas and the target pronoun;
[0153] According to the distance value, determining a proximal reference area corresponding to the target pronoun from the plurality of reference areas;
[0154] determining a second word corresponding to the proximal reference area, and determining the second word corresponding to the proximal reference area as a reference word of the target pronoun.
[0155] Optionally, the second constructing module 502 is specifically configured to:
[0156] determining whether the preamble sentence contains a pronoun;
[0157] In a case where the preposition sentence contains a pronoun, a referent corresponding to the pronoun is determined, and the pronoun in the preposition sentence is replaced with the referent corresponding to the pronoun;
[0158] A second matrix corresponding to the replaced preposition sentence is constructed.
[0159] Optionally, the apparatus further includes:
[0160] a preprocessing module 506 configured to preprocess the current sentence;
[0161] and / or,
[0162] The at least one preposition sentence is preprocessed.
[0163] An electronic device is provided in an embodiment of the present application, and the electronic device includes:
[0164] one or more processors;
[0165] a storage configured to store one or more programs,
[0166] When the one or more programs are executed by the one or more processors, the one or more processors implement the method of any of the above embodiments.
[0167] A computer program product is provided in an embodiment of the present application, and the computer program product includes a computer program which, when executed by a processor, implements the enterprise risk assessment method in the embodiment of the present application.
[0168] Reference is made below to Figure 6 which shows a structural schematic diagram of a computer system 600 of a terminal device suitable for being used to implement the embodiments of the present application. Figure 6 The terminal device shown is merely an example, and should not bring any limitation to the functions and use range of the embodiments of the present application.
[0169] As Figure 6 shown, the computer system 600 includes a central processing unit (CPU) 601 which can perform various appropriate actions and processes according to programs stored in a read-only memory (ROM) 602 or programs loaded from a storage portion 608 to a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the system 600 are also stored. The CPU 601, the ROM 602, and the RAM 603 are connected to each other through a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0170] The following components are connected to the I / O interface 605: an input part 606 including a keyboard, a mouse, etc.; an output part 607 including a display such as a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage part 608 including a hard disk, etc.; and a communication part 609 including a network interface card such as a LAN card, a modem, etc. The communication part 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the I / O interface 605 as necessary. A removable medium 611 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc. is attached to the drive 610 as necessary, so that a computer program read out therefrom is installed in the storage part 608 as necessary.
[0171] In particular, the processes described above with reference to the flowcharts can be implemented as a computer software program according to embodiments of the present disclosure. For example, embodiments of the present disclosure include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for executing the methods illustrated by the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network by the communication part 609, and / or installed from the removable medium 611. When the computer program is executed by the central processing unit (CPU) 601, the above-described functions defined in the system of the present disclosure are executed.
[0172] It should be noted that the computer-readable medium shown in the present application can be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may, for example, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or component, or any combination of the above. More specific examples of computer-readable storage media can include, but are not limited to, an electrical connection having one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, the computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, device or component. In the present application, the computer-readable signal medium can include a data signal carried in a baseband or as a part of a carrier wave, which carries computer-readable program code. Such a propagated data signal can take various forms, including but not limited to an electromagnetic signal, an optical signal or any suitable combination of the above. The computer-readable signal medium can also be any computer-readable medium other than the computer-readable storage medium, which can send, propagate or transmit a program for use by or in conjunction with an instruction execution system, device or component. The program code contained on the computer-readable medium can be transmitted by any suitable medium, including but not limited to wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0173] The flowcharts and block diagrams in the drawings illustrate the possible implementation architectures, functions and operations of the systems, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowcharts or block diagrams can represent a module, a program segment, or a portion of code that contains one or more executable instructions for implementing the specified logical functions. It should also be noted that in some alternative implementations, the functions noted in the blocks can occur in different orders than that shown in the figures. For example, two blocks that are shown in succession can actually be executed substantially concurrently, or they can sometimes be executed in reverse order, depending on the functionality involved. It should also be noted that each block in the block diagrams or flowcharts, and combinations of blocks in the block diagrams or flowcharts, can be implemented by a dedicated hardware-based system that performs specified functions or operations, or can be implemented by a combination of special-purpose hardware and computer instructions.
[0174] The modules described in the embodiments of the present application can be implemented in the form of software or hardware. The described modules can also be arranged in a processor, for example, can be described as: a first construction module, a second construction module, a matrix generation module, a semantic segmentation module, and a reference resolution module. In some cases, the names of these modules do not constitute a limitation on the modules themselves, for example, the first construction module can also be described as "a module that acquires a current sentence containing a target pronoun and constructs a first matrix corresponding to the current sentence".
[0175] As another aspect, the present application also provides a computer readable medium, which can be included in the device described in the above embodiments, or can exist independently without being assembled into the device. The computer readable medium carries one or more programs, which, when executed by the device, cause the device to include:
[0176] acquire a current sentence containing a target pronoun, and construct a first matrix corresponding to the current sentence;
[0177] acquire at least one preceding sentence of the current sentence, and construct a second matrix corresponding to the at least one preceding sentence;
[0178] generate a feature matrix corresponding to the current sentence according to the first matrix and the second matrix, the feature matrix being used to represent the correlation degree between each first word in the current sentence and a second word in the preceding sentence;
[0179] input the feature matrix into a semantic segmentation model to obtain a semantic segmentation result corresponding to the feature matrix;
[0180] determine a reference word corresponding to the target pronoun according to the semantic segmentation result.
[0181] According to the technical solutions of the embodiments of the present application, a first matrix corresponding to a current sentence containing a target pronoun is constructed, and a second matrix corresponding to at least one preceding sentence of the current sentence is constructed. A feature matrix corresponding to the current sentence is generated according to the first matrix and the second matrix. The horizontal and vertical coordinates of the feature matrix correspond to a first word in the current sentence and a second word in the preceding sentence, respectively, and the feature matrix is used to represent the correlation degree between each first word and second word. The feature matrix is input into a semantic segmentation model to obtain a semantic segmentation result. According to the semantic segmentation result, a reference word corresponding to the target pronoun is determined.
[0182] The semantic segmentation is used for segmenting the feature matrix into region blocks with certain semantic meanings, so that the anaphora resolution problem is converted into a semantic segmentation problem, the anaphora resolution process is simplified, the speed of anaphora resolution is improved, the anaphora resolution can be accurately performed, and the smoothness of human-computer interaction dialogue is effectively improved.
[0183] The above detailed description does not constitute a limitation on the protection scope of the present application. Those skilled in the art should understand that various modifications, combinations, sub-combinations and substitutions can occur depending on design requirements and other factors. Any modification, equivalent replacement and improvement made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. A method for resolving referential structures, characterized in that, include: Obtain the current sentence containing the target pronoun, split the current sentence into multiple first words, and input each first word into the natural language processing model in sequence to obtain the feature vector of each first word, and construct the first matrix corresponding to the current sentence; Obtain at least one preceding statement of the current statement, split the at least one preceding statement into multiple second words, and input each second word into a natural language processing model in sequence to obtain the feature vector of each second word, and construct a second matrix corresponding to the at least one preceding statement; Based on the first matrix and the second matrix, a feature matrix corresponding to the current statement is generated. The feature matrix is used to characterize the degree of correlation between each first word in the current statement and the second word in the preceding statement. The horizontal axis of the feature matrix can correspond to the first word, the vertical axis of the feature matrix can correspond to the second word, and the combination of different regions in the feature matrix can represent the referential relationship between words. The process of inputting the feature matrix into a semantic segmentation model to obtain the semantic segmentation result corresponding to the feature matrix includes: inputting the feature matrix into the semantic segmentation model to obtain the semantic segmentation matrix corresponding to the feature matrix; wherein, the semantic segmentation matrix is used to characterize the semantic segmentation result of the feature matrix, and the elements in the semantic segmentation matrix take values of 0 or 1; Based on the semantic segmentation result, determining the referent corresponding to the target pronoun includes: determining the referential region corresponding to the target pronoun from the semantic segmentation matrix; wherein the referential region includes at least one continuous element, and the value of each continuous element is 1; determining the second word corresponding to the referential region, and determining the second word corresponding to the referential region as the referent of the target pronoun.
2. The method according to claim 1, characterized in that, The construction of the first matrix corresponding to the current statement includes: Determine the feature vector of each of the first words in the current statement; Combine the feature vectors of each of the first words to construct the first matrix corresponding to the current statement.
3. The method according to claim 1, characterized in that, The construction of the second matrix corresponding to the at least one preamble statement includes: Determine the feature vector of each second word in the at least one preceding statement; Combine the feature vectors of each of the second words to construct the second matrix corresponding to the preceding statement.
4. The method according to claim 1, characterized in that, The step of generating the feature matrix corresponding to the current statement based on the first matrix and the second matrix includes: The first matrix and the second matrix are processed by dot product to generate the feature matrix corresponding to the current statement.
5. The method according to claim 1, characterized in that, The number of referred regions is multiple; The step of determining the second word corresponding to the referential region and identifying the second word corresponding to the referential region as the referent of the target pronoun includes: Determine the distance value between each of the referred regions and the target pronoun; Based on the distance value, the neighboring referential regions corresponding to the target pronoun are determined from the plurality of referential regions; Determine the second word corresponding to the adjacent referential region, and determine the second word corresponding to the adjacent referential region as the referent of the target pronoun.
6. The method according to claim 1, characterized in that, The construction of the second matrix corresponding to the at least one preamble statement includes: Determine whether the preceding statement contains a pronoun; If the preceding statement contains a pronoun, determine the referent corresponding to the pronoun, and replace the pronoun in the preceding statement with the referent corresponding to the pronoun; Construct the second matrix corresponding to the replaced preceding statement.
7. The method according to claim 1, characterized in that, After obtaining the current statement containing the target pronoun, the process further includes: The current statement is preprocessed; And / or, After obtaining at least one preceding statement of the current statement, the method further includes: Preprocessing is performed on the at least one preceding statement.
8. A digestion apparatus, characterized in that, include: The first construction module is used to obtain the current statement containing the target pronoun, split the current statement into multiple first words, and input each first word into the natural language processing model in sequence to obtain the feature vector of each first word, and construct the first matrix corresponding to the current statement; The second construction module is used to obtain at least one preceding statement of the current statement, split the at least one preceding statement into multiple second words, and input each second word into the natural language processing model in sequence to obtain the feature vector of each second word, and construct the second matrix corresponding to the at least one preceding statement; The matrix generation module is used to generate a feature matrix corresponding to the current statement based on the first matrix and the second matrix. The feature matrix is used to characterize the degree of correlation between each first word in the current statement and the second word in the preceding statement. The horizontal axis of the feature matrix can correspond to the first word, the vertical axis of the feature matrix can correspond to the second word, and the combination of different regions in the feature matrix can represent the referential relationship between words. A semantic segmentation module is used to input the feature matrix into a semantic segmentation model to obtain a semantic segmentation result corresponding to the feature matrix, including: inputting the feature matrix into the semantic segmentation model to obtain a semantic segmentation matrix corresponding to the feature matrix; wherein, the semantic segmentation matrix is used to characterize the semantic segmentation result of the feature matrix, and the elements in the semantic segmentation matrix take values of 0 or 1; The pronoun resolution module is used to determine the pronoun corresponding to the target pronoun based on the semantic segmentation result, including: determining the pronoun region corresponding to the target pronoun from the semantic segmentation matrix; wherein the pronoun region includes at least one continuous element, and the value of each continuous element is 1; determining the second word corresponding to the pronoun region, and determining the second word corresponding to the pronoun region as the pronoun of the target pronoun.
9. The apparatus according to claim 8, characterized in that, The first building module is specifically used for: Determine the feature vector of each of the first words in the current statement; Combine the feature vectors of each of the first words to construct the first matrix corresponding to the current statement.
10. The apparatus according to claim 8, characterized in that, The second building module is specifically used for: Determine the feature vector of each second word in the at least one preceding statement; Combine the feature vectors of each of the second words to construct the second matrix corresponding to the preceding statement.
11. The apparatus according to claim 8, characterized in that, The matrix generation module is specifically used for: The first matrix and the second matrix are processed by dot product to generate the feature matrix corresponding to the current statement.
12. An electronic device, characterized in that, include: One or more processors; Storage device for storing one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors implement the method as described in any one of claims 1-7.
13. A computer-readable medium having a computer program stored thereon, characterized in that... When the program is executed by the processor, it implements the method as described in any one of claims 1-7.
14. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1-7.
Citation Information
Patent Citations
Anaphora resolution method and device and electronic equipment
CN113297843A