Sentence component recognition method, device, computer equipment and storage medium

By treating sentence component identification as a question and answer task and using pre-trained models to automatically identify the positions of sentence components, we solve the complex operational problems in the existing technology, achieve simple and accurate identification of sentence components, and improve the efficiency of language analysis.

CN115114902BActive Publication Date: 2024-09-06GUANGZHOU SHIYUAN ELECTRONICS CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110303970.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-03-22
Publication Date
2024-09-06
Estimated Expiration
2041-03-22

AI Technical Summary

Technical Problem

Existing dependency syntax analysis methods require manual definition and maintenance of rules, which are complex operations and difficult to achieve simple sentence component identification.

Method used

Use sentence component recognition as a question and answer task, use the pre-trained sentence component recognition model, use query and sentence input features for attention interaction processing, automatically obtain the start and end positions of sentence components, construct training corpus, and adjust the model until the training is satisfied. end condition.

Benefits of technology

It realizes sentence component identification with simple operation and high convenience, improves the efficiency and accuracy of analysis, and especially helps to understand the components of sentences in language learning and semantic understanding.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115114902B
    Figure CN115114902B
Patent Text Reader

Abstract

The present application relates to a sentence component recognition method, device, computer equipment and storage medium. The method includes: obtaining a sentence and a sentence component to be recognized; obtaining a query corresponding to the sentence component; inputting the query and the sentence into a pre-trained sentence component recognition model to obtain the starting position and ending position of the sentence component in the sentence; the sentence component recognition model is trained based on the query and a sentence set that identifies the location of each sentence component; according to the starting position and ending position of the sentence component, the text content corresponding to the sentence component is obtained. The method treats the component analysis task as a question-answering task, constructs a query for each sentence component, and trains the sentence component recognition model in advance. The operation is simple and convenient.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of natural language processing, and in particular to a sentence component recognition method, apparatus, computer equipment and storage medium. Background Art

[0002] Syntactic analysis is one of the key technologies in natural language processing. Its basic task is to determine the syntactic structure of a sentence or the dependency relationship between words in a sentence. For example, by using the dependency syntactic analysis method, the dependency relationship between words is obtained, such as the subject-predicate relationship with the central word. Therefore, the dependency relationship can be used to analyze the components of a sentence. Specifically, it is based on dependency syntactic analysis and rule methods.

[0003] However, the dependency parsing and rule-based methods require manual definition and maintenance of rules, which is complex to operate. Summary of the invention

[0004] Based on this, it is necessary to provide a simple-to-operate sentence component recognition method, device, computer equipment and storage medium to address the above technical problems.

[0005] A sentence component recognition method, the method comprising:

[0006] Obtain the sentence and the sentence components to be identified;

[0007] Obtaining a query corresponding to the sentence component;

[0008] Inputting the query and the sentence into a pre-trained sentence component recognition model to obtain the start position and the end position of the sentence component in the sentence; the sentence component recognition model is trained based on the query and a sentence set that identifies the position of each sentence component;

[0009] According to the starting position and the ending position of the sentence component, the text content corresponding to the sentence component is obtained.

[0010] In one embodiment, the query and the sentence are input into a pre-trained sentence component recognition model to obtain the starting position and the ending position of the sentence component in the sentence, including:

[0011] Using the word vector, position vector and identification vector of each word in the query as input features of the query, and using the word vector, position vector and identification vector of each word in the sentence as input features of the sentence, input into a pre-trained sentence component recognition model;

[0012] Processing the input features of the query and the input features of the sentence through the sentence component recognition model to obtain word representations of each word in the sentence; wherein the processing includes attention interaction processing of the input features of the query and the input features of the sentence;

[0013] According to the word representation of each word in the sentence, the starting position and the ending position of the sentence component in the sentence are obtained.

[0014] In one embodiment, obtaining the word representations of the starting position and the ending position of the sentence component in the sentence according to the word representations of each word in the sentence includes:

[0015] According to the word representation of each position of the sentence, if the corresponding position is judged to be the starting position of the sentence component, the position is added to the starting position set; if the corresponding position is judged to be the ending position of the sentence component, the position is added to the ending position set;

[0016] If the position matching probability of the start position in the start position set and the end position in the end position set is greater than a threshold, the start position and the end position of the sentence component are obtained.

[0017] In one embodiment, the method further comprises:

[0018] If there is a predicate component between the start position and the end position of the sentence component, then the sentence component is determined to be a clause;

[0019] The sentence components whose starting positions and ending positions are within the scope of the clause are determined as subordinate sentence components of the clause.

[0020] In one embodiment, the method further comprises:

[0021] Acquire a sentence set for training, the sentence set including training corpus of each sentence, the training corpus including sentences, sentence components, queries corresponding to the sentence components, sentence component start positions, and sentence component end positions;

[0022] The step of training the sentence component recognition model to be trained by using the training sentence set comprises: inputting the training corpus of the sentences in the sentence set into the sentence component recognition model to be trained, the sentence component recognition model outputting the predicted start position and the predicted end position of the corresponding sentence component according to the sentence component and the query corresponding to the sentence component, and adjusting the sentence component recognition model according to the difference between the sentence component start position and the predicted start position, and the difference between the sentence component end position and the predicted end position;

[0023] The step of training the sentence component recognition model to be trained by using the training sentence set is repeated until the training end condition is met, thereby obtaining a trained sentence component recognition model.

[0024] In one embodiment, obtaining a sentence set for training includes:

[0025] Obtaining queries about sentences and sentence components and annotated start and end positions of sentence components;

[0026] According to the sentence, the query, and the start and end positions of the sentence components, constructing the sentence components of the sentence respectively for use as training corpus for model input;

[0027] According to the training corpus described in each sentence, a training sentence set is obtained.

[0028] In one embodiment, according to the starting position and the ending position of the sentence component, obtaining the text content corresponding to the sentence component includes: marking the text content corresponding to the sentence component on the sentence according to the starting position and the ending position of the sentence component.

[0029] A sentence component recognition device, the device comprising:

[0030] An input acquisition module is used to acquire sentences and sentence components to be recognized;

[0031] A query acquisition module, used to acquire the query corresponding to the sentence component;

[0032] A position acquisition module, used for inputting the query and the sentence into a pre-trained sentence component recognition model to obtain the starting position and the ending position of the sentence component in the sentence; the sentence component recognition model is trained based on the query and a sentence set that identifies the position of each sentence component;

[0033] The recognition module is used to obtain the text content corresponding to the sentence component according to the starting position and the ending position of the sentence component.

[0034] A computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:

[0035] Obtain the sentence and the sentence components to be identified;

[0036] Obtaining a query corresponding to the sentence component;

[0037] Inputting the query and the sentence into a pre-trained sentence component recognition model to obtain the start position and the end position of the sentence component in the sentence; the sentence component recognition model is trained based on the query and a sentence set that identifies the position of each sentence component;

[0038] According to the starting position and the ending position of the sentence component, the text content corresponding to the sentence component is obtained.

[0039] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the following steps:

[0040] Obtain the sentence and the sentence components to be identified;

[0041] Obtaining a query corresponding to the sentence component;

[0042] Inputting the query and the sentence into a pre-trained sentence component recognition model to obtain the start position and the end position of the sentence component in the sentence; the sentence component recognition model is trained based on the query and a sentence set that identifies the position of each sentence component;

[0043] According to the starting position and the ending position of the sentence component, the text content corresponding to the sentence component is obtained.

[0044] The above-mentioned sentence component recognition method, device, computer equipment and storage medium regard the recognition of sentence components as a question-answering task, and use the sentence component recognition model to output the starting position and ending position of the sentence component in the sentence according to the query corresponding to the sentence component, and obtain the text content corresponding to the sentence component according to the starting position and the ending position, and obtain the text content corresponding to each sentence component. This method regards the component analysis task as a question-answering task, constructs the query for each sentence component, and trains the sentence component recognition model in advance. It is simple to operate and highly convenient. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] Figure 1 A diagram showing an application environment of a sentence component recognition method in one embodiment;

[0046] Figure 2 A schematic diagram of a flow chart of a sentence component recognition method in one embodiment;

[0047] Figure 3 A flowchart of the steps of inputting a query and a sentence into a pre-trained sentence component recognition model to obtain the starting position and the ending position of the sentence component in the sentence in one embodiment;

[0048] Figure 4 A schematic diagram of the structure of a sentence component recognition model in another embodiment;

[0049] Figure 5 A flowchart of a sentence component recognition model training step in one embodiment;

[0050] Figure 6 is a structural block diagram of a sentence component recognition device in one embodiment;

[0051] Figure 7 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0052] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0053] The sentence component recognition method provided by this application can be applied to Figure 1 In the application environment shown. Among them, the terminal 102 communicates with the server 104 through the network. The terminal obtains the sentence to be analyzed input by the user, sends the recognition instruction and the sentence to the server, and the server obtains the sentence and the sentence components to be recognized; obtains the query corresponding to the sentence component; inputs the query and the sentence into a pre-trained sentence component recognition model to obtain the starting position and the ending position of the sentence component in the sentence; the sentence component recognition model is trained based on the query and the sentence set that identifies the location of each sentence component; according to the starting position and the ending position of the sentence component, the text content corresponding to the sentence component is obtained.

[0054] The terminal 102 may be, but is not limited to, various personal computers, laptop computers, smart phones, tablet computers, and portable wearable devices, and the server 104 may be implemented as an independent server or a server cluster consisting of multiple servers.

[0055] In one embodiment, Figure 2 As shown, a sentence component recognition method is provided, which is applied to Figure 1 The server in the example is used to illustrate the following steps:

[0056] Step 202, obtaining a sentence and sentence components to be recognized.

[0057] In language learning, identifying sentence components can help us better understand semantics. The components of a sentence are called sentence components, also called syntactic components. In a sentence, there is a certain combination relationship between words. According to different relationships, sentences can be divided into different components. Sentence components are played by words or phrases. For example, the sentence components of English include subject, predicate, object, predicate, attributive, adverbial, complement and appositive, etc.

[0058] Step 204: Obtain the query corresponding to the sentence component.

[0059] In this application, the recognition of each sentence component is regarded as a question-answering task, and the sentence to be analyzed is regarded as a known context. For a query of a certain sentence component, the question-answering task is performed according to the context (i.e., the sentence to be analyzed), and the output of the question-answering task is the corresponding sentence component. Therefore, the query is the input of the sentence component recognition task.

[0060] It is understandable that the content of the query corresponding to each sentence component is already set. Taking English as an example, the queries corresponding to different sentence components are shown in Table 1.

[0061] Table 1. Queries corresponding to different sentence components

[0062]

[0063] It is understandable that the query of sentence components is not limited to the form of Table 1. The queries of different sentence components are different. It is only necessary to distinguish and make the query contents of different sentence components different.

[0064] In one implementation, queries corresponding to all preset sentence components are obtained to obtain analysis results of all sentence components. For example, queries for subject, predicate, object, predicate, attributive, adverbial, complement and appositive are obtained to obtain the subject, predicate, object, predicate, attributive, adverbial, complement and appositive of the sentence. In the application scenario of language learning, after the user inputs the sentence to be analyzed, the queries corresponding to all preset sentence components are automatically obtained.

[0065] In one implementation, a sentence component to be analyzed is obtained, and then a query corresponding to the specified sentence component is obtained to obtain an analysis result of the specified sentence component. For example, in a language learning interface, a sentence input box and optional sentence component options are provided. After the user enters a sentence, he selects a sentence component to be analyzed, such as a "subject", and then obtains a query corresponding to the preset "subject".

[0066] Step 206: Input the query and the sentence into a pre-trained sentence component recognition model to obtain the starting position and the ending position of the sentence component in the sentence.

[0067] Specifically, the sentence component recognition model is trained based on a query and a sentence set that identifies the position of each sentence component, wherein each sentence in the sentence set identifies the position of the sentence component in the sentence, including the start position and the end position.

[0068] The sentence component recognition model can adopt ELMO, BERT, ALBERT, RoBERTa, etc., and train the query and the sentence set with the location of each sentence component marked to obtain a trained component recognition model.

[0069] Using the trained component recognition model, the query and sentence are used as the input of the component recognition model, and the starting position and ending position of the sentence component in the sentence are output.

[0070] Step 208, obtaining the text content corresponding to the sentence component according to the start position and the end position of the sentence component.

[0071] The words between the start position and the end position are the text content of the sentence component. According to the start position and the end position, it can be determined which word the text content corresponding to the sentence component starts and which word it ends. For example, if the start position and the end position corresponding to the predicate component are (2, 4), then the text content corresponding to the predicate component starts from the word at the second position and ends at the word at the fourth position, that is, the words at the third position and the fourth position are the text content of the predicate component. Taking the sentence "He refused to talk about the sufferings he had during the disaster" as an example, the start position of the output subject is 0 and the end position is 1, then the subject of the sentence is He.

[0072] In one embodiment, according to the starting position and the ending position of the sentence component, the text content corresponding to the sentence component is obtained, including: according to the starting position and the ending position of the sentence component, the text content of the sentence component is identified. Among them, the text content of all sentence components can be identified according to the needs, and the text content of the specified sentence component can also be identified. The identification method can be to mark the text content of each sentence component on the sentence with a mark, and at the same time mark the sentence component to which it belongs under the corresponding mark. For example, the text content of the subject is circled with a red frame, and it is marked as the subject above the red frame. In this way, the text content of each sentence component can be intuitively seen. The identification method can also be to display each component identification and text content in the form of a list, and the text content is the attribute value of the component identification. For example, subject: He.

[0073] The above-mentioned sentence component recognition method regards the recognition of sentence components as a question-answering task. According to the query corresponding to the sentence component, the sentence component recognition model is used to output the starting position and ending position of the sentence component in the sentence. According to the starting position and ending position, the text content corresponding to the sentence component is obtained, and the text content corresponding to each sentence component is obtained. This method regards the component analysis task as a question-answering task, constructs the query for each sentence component, and trains the sentence component recognition model in advance. It is simple to operate and highly convenient.

[0074] In another embodiment, Figure 3 As shown, the query and the sentence are input into the pre-trained sentence component recognition model to obtain the starting position and the ending position of the sentence component in the sentence, including:

[0075] S302, the word vector, position vector and identification vector of each word in the query are used as input features of the query, and the word vector, position vector and identification vector of each word in the sentence are used as input features of the sentence, and are input into a pre-trained sentence component recognition model.

[0076] In one embodiment, the structure of the sentence component recognition model is as follows: Figure 4 As shown, it includes an input layer 402 , an intermediate layer 404 and an output layer 406 .

[0077] In the input layer, the query and the sentence to be analyzed are taken as input together. The start symbol [CLS] is added before the first word of the query, and the separator [SEP] is added between the last word of the query and the first word of the sentence. The input is Input = {[CLS], q1, q2, ..., qm, [SEP], x1, x2, ..., xm}. Among them, q1...qm represent the words in the query, and x1...xn represent the words in the sentence to be analyzed. In addition to the word vector, the input layer also needs to add the position vector and the identification vector. Among them, the identification vector identifies whether the word is a query or a sentence.

[0078] S304, processing the query input features and the sentence input features through the sentence component recognition model to obtain word representations of each word in the sentence; wherein the processing includes attention interaction processing of the query input features and the sentence input features.

[0079] Among them, the attention mechanism of the sentence component recognition model is used, and the attention mechanism allows each element in the input sequence (such as a word sequence) to focus on other elements. Through attention interaction processing, the features of the query and the features of the sentence pay attention to each other, the features of the query words participate in the features of the sentence words, and the features of the sentence words participate in the features of the query words. The words of the two pay attention to each other, and finally the word representation of the sentence is integrated into the features of the query.

[0080] The middle layer can use a variety of pre-trained models to obtain the context-related word representations {Tc, T1', T2', ..., Tm', Ts, T1, T2, ..., Tn, Ts} for each word. The pre-trained models used in the middle layer include ELMO, BERT, ALBERT, RoBERTa, etc. Figure 4The figure shows BERT as an example. When the BERT model is used to process the input features, the attention interaction processing of the query input features and the sentence input features is performed. The query corresponding to the sentence component is input, and the attention interaction is performed with the sentence input by the user, thereby locating the position of the corresponding component in the user input sentence.

[0081] S306, obtaining the starting position and the ending position of the sentence component in the sentence according to the word representation of each word in the sentence.

[0082] The sentence component recognition model can output the word representation of each word in the query and the word representation of each word in the sentence. Because the word representation of the sentence has been integrated with the query features, the word representation of the query {Tc, T1', T2', ..., Tm', Ts} can be directly discarded and not used. Only the word representation of each word in the sentence is used to predict the sentence components. Prediction is performed on the word representation E = {T1, T2, ..., Tn, Ts} corresponding to each word in the sentence to be analyzed to determine whether it is the starting position or the ending position of the sentence component, thereby obtaining the starting position and the ending position of the sentence component in the sentence.

[0083] Specifically, according to the word representation of each word in the sentence, the starting position and the ending position of the sentence component in the sentence are obtained, including:

[0084] According to the word representation of each position of the sentence, if the corresponding position is judged to be the starting position of the sentence component, the position is added to the starting position set; if the corresponding position is judged to be the ending position of the sentence component, the position is added to the ending position set; if the position matching probability of the starting position in the starting position set and the ending position in the ending position set is greater than the threshold, the starting position and the ending position of the sentence component are obtained. Specifically, for each position, whether it is the starting position or the ending position is judged as a binary classification problem, and the formula is as follows:

[0085] P start =softmax row (E⊙T start )∈R nx2

[0086] P end =softmax row (E⊙T end )∈R nx2

[0087] in, is the probability that the i-th position is the starting position, is the probability of whether the i-th position is the end position, T start ∈R dx2 , T end∈R dx2 are the parameters of the sentence component recognition model, E is the word representation E = {T1, T2, ..., Tn, Ts}, and d is the dimension of the output word Ti.

[0088] like The probability of being the starting position is greater than the probability of not being the starting position, then i is considered to be the starting position, and the position number i is added to the starting position set pos start , such as adding position i to the starting position set. Similarly, Is the probability of whether the jth position is the end position. If the probability of the end position is greater than the probability of not being the end position, j is considered to be the end position, and the position number j is added to the end position set pos en d, if position j is added to the end position set, we can get:

[0089]

[0090]

[0091] Among them, pos start is the starting position set, pos en d is the end position set, is the probability that the i-th position is the starting position, is the probability that the jth position is the end position.

[0092] Set the obtained start and end positions pos start ,pos en d is used to perform position matching to obtain the start and end positions of the final component. The position matching consideration is that the number of the start position should be smaller than the number of the end position. Specifically, a classifier can be used for judgment. The classifier is pre-trained with the restriction that the number of the start position is smaller than the number of the end position. Specifically, the word representation of the position in the start position set and the end position set is used to judge the position of pos start The starting position i and pos in the collection en The starting position j in the set d is matched. The formula is as follows:

[0093] P i,j =sigmoid(m·conact(E i ,E j ))

[0094] Where m∈R 1x2d is the classifier parameter, P i,j is the position matching probability, E i is the word representation of the i-th position, E jis the word representation of the jth position, connect is the connection function, and E i and E j Connect.

[0095] If the position matching probability P i,j If it is greater than the threshold, the position<i,j> That is, the starting and ending positions of the corresponding components of the sentence to be identified, where i is the starting position and j is the ending position.

[0096] There may be multiple identical sentence components in a sentence, and the corresponding start position set and end position set have multiple elements. In this case, it is necessary to calculate the matching of each element of the start position set (i.e., the start position) and each element of the end position set (i.e., the end position). For example, if there are two main sentences in a sentence, there are two elements in the start position set and the end position set. If the start position is predicted to be (0,7) and the end position is predicted to be (1,8), then the position matching probabilities of the four combined positions need to be calculated. Specifically, the position matching probability of (0,1) is calculated, indicating that the start position is 0 and the end position is 1, the position matching probability of (0,8) is calculated, indicating that the start position is 0 and the end position is, the position matching probability of (7,1) is calculated, indicating that the start position is 7 and the end position is 1, and the position matching probability of (7,8) is calculated, indicating that the start position is 7 and the end position is 8. Finally, the matching probability of the positions (0,1) and (7,8) exceeds the matching threshold, and the start and end positions corresponding to the sentence component include (0,1) and (7,8), and the corresponding first and eighth words are the text content corresponding to the sentence component.

[0097] In this embodiment, the accuracy of component recognition can be improved by judging the start position, the end position, and the matching between the start position and the end position of the sentence.

[0098] In practical applications, especially in English learning, in addition to single words as components, there are also sentences that act as components, such as the attributive clause "he had during the disaster" in the sentence "He refused to talk about the sufferings he had during the disaster." It can be identified that the attributive clause is an attributive component, and there are also subordinate components in the attributive component, such as the subject he, the predicate had, etc. In this embodiment, it is further determined whether there is a predicate component between its starting position and the end position to determine whether it is a clause. If it is a clause, the sentence component with the starting position and the end position within the scope of the clause is determined to determine the subordinate sentence components of the clause, thereby obtaining a nested result.

[0099] For example, for the sentence "He refused to talk about the sufferings he had duringthe disaster.", the start and end positions of an attributive component are recognized as (7, 12), and the corresponding text content is "he had during the disaster", and within the position range of the clause, there is a subject component with the start and end positions (7, 8), and the corresponding text content is "he", and the start and end positions of a predicate component are recognized as (8, 9), and the corresponding text content is "had", and the start and end positions of a state component are recognized as (9, 12), and the corresponding text content is "during the disaster", that is, there is a predicate component before the start and end positions of the clause, then, the sentence components whose start and end positions are within the scope of the clause, "he", "had" and "during the disaster" are divided into subordinate sentence components of the clause.

[0100] By adopting this method, nested sentence components can be identified and the levels of sentence analysis can be prepared, and the recognition results of sentence components are more accurate.

[0101] In one embodiment, the training process of the sentence component recognition model is as follows: Figure 5 As shown, the following steps are included:

[0102] S502, obtaining a sentence set for training, the sentence set including training corpus of each sentence, the training corpus including sentences, sentence components, queries corresponding to sentence components, sentence component start positions and sentence component end positions.

[0103] Wherein, a training corpus is obtained, and a plurality of training corpora form a sentence set. The training corpus includes sentences, sentence components, queries corresponding to sentence components, sentence component start positions, and sentence component end positions.

[0104] Specifically, obtaining a training sentence set includes: obtaining sentences, queries of sentence components, and the start and end positions of annotated sentence components; constructing training corpora for each sentence component of the sentence as a model input based on the sentences, queries, and the start and end positions of the sentence components; and obtaining a training sentence set based on the training corpora for each sentence.

[0105] Specifically, the recognition of each component is regarded as a question-answering task, and the sentence to be analyzed is regarded as a known context. Therefore, for each component, it is necessary to design a query corresponding to the component. That is, each sentence component corresponds to a query, as shown in Table 1. The types of components here can be designed according to different tasks. For tasks that only require the recognition of subject, predicate, and object, it is only necessary to design queries corresponding to the three components of subject, predicate, and object. Experiments have found that the more detailed the query design of each component is, the higher the distinction from other components is, and the higher the recognition accuracy is.

[0106] Each sample in the set includes the sentence to be analyzed and its corresponding components. Common sentence components in English can be divided into: subject, predicate, object, predicate, attributive, adverbial, complement and appositive. The sample format is shown in Table 2.

[0107] Table 2 Sentence component recognition sample form

[0108]

[0109] Preprocessing of sentence component recognition corpus mainly includes filtering some special characters, such as non-ASCII characters, replacing URLs, telephone numbers, etc. with unified characters, and filtering some illegal samples, such as the starting position of the component annotation being greater than the ending position.

[0110] The sentence component recognition method of the present application regards the recognition of each component as a question-answering task. Therefore, when preparing the training corpus, it is necessary to process a sample in Table 1 into multiple samples, one sample for each component. For example, for the subject component in the sentence to be processed in Table 1, "He refused to talk about the sufferings he had during the disaster.", it can be processed into the form of the following Table 3.

[0111] Table 3 Model input examples

[0112]

[0113] Among them, context is the text to be analyzed, and the [SEP] terminator is added to ensure that the end position end_position of the component does not go out of bounds. element_type is the category of the component, and query is the artificially constructed question corresponding to the component. start_position is the start position of the component, and span_position is the start and end position of the component. For this example, there are two subject components, so there are two start_position, two end_position, and two span_position respectively. It can be understood that for each sentence component of the sentence, a training corpus for model input is constructed to convert the original data of the sentence component into the data format required by the model. For each component in the sentence to be analyzed, it includes the corresponding query and the start and end positions of the component.

[0114] S504, the step of training the sentence component recognition model to be trained using the training sentence set, including: inputting the training corpus of the sentences in the sentence set into the sentence component recognition model to be trained, the sentence component recognition model outputting the predicted starting position and the predicted ending position of the corresponding sentence component according to the sentence component and the query corresponding to the sentence component, and adjusting the sentence component recognition model according to the difference between the sentence component starting position and the predicted starting position, and the difference between the sentence component ending position and the predicted ending position.

[0115] Specifically, using Figure 4 The sentence component recognition model shown in the figure is trained. The sentence to be analyzed and the corresponding query are input to predict the start and end positions of all components.

[0116] The word vector, position vector and identification vector of each word in the query are used as the input features of the query, and the word vector, position vector and identification vector of each word in the sentence are used as the input features of the sentence, and are input into the sentence component recognition model. The input features of the query and the input features of the sentence are processed by the sentence component recognition model to obtain the word representation of each word in the sentence; wherein the processing includes attention interaction processing of the input features of the query and the input features of the sentence. According to the word representation of each word in the sentence, the predicted start position and predicted end position of the sentence component in the sentence are obtained.

[0117] Specifically, based on the word representation of each position of the sentence, if the corresponding position is judged to be the starting position of a sentence component, the position is added to the starting position set; if the corresponding position is judged to be the ending position of the sentence component, the position is added to the ending position set; if the position matching probability between the starting position in the starting position set and the ending position in the ending position set is greater than a threshold, the predicted starting position and predicted ending position of the sentence component are obtained.

[0118] Then, based on the difference between the starting position of the sentence component and the predicted starting position, and the difference between the ending position of the component and the predicted ending position, back propagation is performed to adjust the parameters of the error correction model.

[0119] It can be seen that the sentence component recognition model needs to handle three tasks: 1. Prediction of the starting position, judging whether each position is the starting position, which can be regarded as a binary classification problem. 2. Prediction of the ending position, judging whether each position is the ending position, which can be regarded as a binary classification problem. 3. Whether the starting and ending positions match, for each starting position and each ending position, judge whether they match, which can be regarded as a binary classification problem. For each task, cross entropy loss is used, and the overall loss function of the model is the sum of the three, which can be controlled by hyperparameters α, β, and γ:

[0120] L start =CE(P start ,Y start )

[0121] L end =CE(P end ,Y end )

[0122] L span =CE(P start,end ,Y start,end )

[0123] L all =αL start +βL end +γL span

[0124] Among them, L start The loss function for starting position prediction, L end is the loss function for the end position prediction, L span is the loss function for matching the start position and the end position, L all is the overall loss function of the model.

[0125] During the training process, minimize the loss function L all The value of is used to train the model, and the model with the best component recognition effect on the validation set is saved.

[0126] S506, satisfying the training end condition and obtaining a trained sentence component recognition model.

[0127] Specifically, if the training end condition is not met, the sentence component recognition model to be trained is trained using the training samples iteratively until the training end condition is met to obtain a trained sentence component recognition model. The end condition includes that the number of iterations reaches the maximum number of iterations, or the model output accuracy reaches the requirement.

[0128] The sentence component recognition method of the present application regards sentence component recognition as a query task and directly extracts the components of the sentence to be analyzed. For samples containing clause components, the nested structure of the sentence components can be obtained through post-processing. Compared with the original method, it is simpler and the F1 value can reach 93.02% on the test set compiled by the author, which shows the effectiveness of this method.

[0129] Taking the recognition of components of English sentences as an example, for the sentence "He refused to talk about the sufferings he had during the disaster.", different queries are combined and input into the sentence component recognition model based on question and answer, so as to obtain the start and end positions of each component. Ideally, it is as follows:

[0130] Table 4 Examples of practical applications

[0131]

[0132] Combining the sentence to be analyzed, the start and end positions of each component, and performing post-processing operations on the clause components, the final result can be obtained:

[0133]

[0134] It should be understood that although Figure 2 , 3 The steps in the flowcharts of and 5 are shown in sequence as indicated by arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 2 , 3 At least part of the steps in 5 may include multiple steps or multiple stages. These steps or stages do not necessarily have to be executed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily one by one, but can be executed in turn or alternately with other steps or at least part of the steps or stages in other steps.

[0135] In one embodiment, Figure 6 As shown, a sentence component recognition device is provided, comprising:

[0136] The input acquisition module 602 is used to acquire sentences and sentence components to be recognized.

[0137] The query acquisition module 604 is used to acquire the query corresponding to the sentence component.

[0138] The position acquisition module 606 is used to input the query and the sentence into a pre-trained sentence component recognition model to obtain the starting position and the ending position of the sentence component in the sentence; the sentence component recognition model is trained based on the query and a sentence set that identifies the position of each sentence component.

[0139] The identification module 608 is used to obtain the text content corresponding to the sentence component according to the starting position and the ending position of the sentence component.

[0140] The above-mentioned sentence component recognition device regards the recognition of sentence components as a question-answering task, and uses a sentence component recognition model to output the starting position and ending position of the sentence component in the sentence according to the query corresponding to the sentence component, and obtains the text content corresponding to the sentence component according to the starting position and the ending position, thereby obtaining the text content corresponding to each sentence component. This method regards the component analysis task as a question-answering task, constructs the query for each sentence component, and trains the sentence component recognition model in advance. It is simple to operate and highly convenient.

[0141] In one embodiment, the position acquisition module includes: an input module, which is used to input the word vector, position vector and identification vector of each word of the query as the input features of the query, and the word vector, position vector and identification vector of each word of the sentence as the input features of the sentence, into a pre-trained sentence component recognition model;

[0142] A word feature processing module, used to process the input features of the query and the input features of the sentence through a sentence component recognition model to obtain word representations of each word in the sentence; wherein the processing includes attention interaction processing of the input features of the query and the input features of the sentence;

[0143] The analysis module is used to obtain the starting position and the ending position of the sentence component in the sentence according to the word representation of each word in the sentence.

[0144] In one of the embodiments, a word feature processing module is used to represent the word at each position of the sentence. If the corresponding position is judged to be the starting position of a sentence component, the position is added to a starting position set; if the corresponding position is judged to be the ending position of the sentence component, the position is added to an ending position set; if the position matching probability between the starting position in the starting position set and the ending position in the ending position set is greater than a threshold, the starting position and the ending position of the sentence component are obtained.

[0145] In another embodiment, it also includes:

[0146] The nested identification module is used to determine that a sentence component is a clause if there is a predicate component between the start position and the end position of the sentence component; and determine that the sentence component whose start position and end position are within the scope of the clause is a subordinate sentence component of the clause.

[0147] In another embodiment, a training module is further included, comprising:

[0148] A sentence set acquisition module is used to acquire a sentence set for training, wherein the sentence set includes training corpus of each sentence, and the training corpus includes sentences, sentence components, queries corresponding to sentence components, sentence component start positions, and sentence component end positions;

[0149] The training module is used for the steps of training the sentence component recognition model to be trained by using the training sentence set, including: inputting the training corpus of the sentences in the sentence set into the sentence component recognition model to be trained, the sentence component recognition model outputting the predicted starting position and the predicted ending position of the corresponding sentence component according to the sentence component and the query corresponding to the sentence component, adjusting the sentence component recognition model according to the difference between the sentence component starting position and the predicted starting position, and the difference between the sentence component ending position and the predicted ending position; repeating the steps of training the sentence component recognition model to be trained by using the training sentence set until the training end condition is met to obtain the trained sentence component recognition model.

[0150] In another embodiment, a sentence set acquisition module is used to acquire sentences, queries of sentence components, and start and end positions of annotated sentence components; construct training corpora for each sentence component of the sentence as model input based on the sentences, queries, and start and end positions of sentence components; and obtain a training sentence set based on the training corpora for each sentence.

[0151] In another embodiment, the recognition module is used to identify the text content corresponding to the sentence component in the sentence according to the starting position and the ending position of the sentence component.

[0152] For the specific definition of the sentence component identification device, please refer to the definition of the sentence component identification method above, which will not be repeated here. The various modules in the above-mentioned sentence component identification device can be implemented in whole or in part by software, hardware and their combination. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

[0153] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 7As shown. The computer device includes a processor, a memory and a network interface connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store query data corresponding to a training sentence set and sentence components. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a sentence component recognition method is implemented.

[0154] Those skilled in the art will understand that Figure 7 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0155] In one embodiment, a computer device is provided, including a memory and a processor. The memory stores a computer program, and the processor implements the steps of the methods of the above embodiments when executing the computer program.

[0156] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the methods of the above embodiments are implemented.

[0157] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory or optical memory, etc. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).

[0158] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0159] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.

Claims

1. A method for identifying sentence components, the method include: Obtain the sentence and the sentence components to be identified; Obtaining a query corresponding to the sentence component; The word vector, position vector and identification vector of each word in the query are used as input features of the query, and the word vector, position vector and identification vector of each word in the sentence are used as input features of the sentence, and are input into a pre-trained sentence component recognition model; the sentence component recognition model is trained based on the query and a sentence set in which the positions of each sentence component are identified; The input features of the query and the input features of the sentence are processed by the sentence component recognition model to obtain word representations of each word in the sentence; wherein the processing includes attention interaction processing of the input features of the query and the input features of the sentence; according to the word representations of each word in the sentence, the starting position and the ending position of the sentence component in the sentence are obtained; According to the starting position and the ending position of the sentence component, the text content corresponding to the sentence component is obtained.

2. The method according to claim 1, It is characterized in that According to the word representation of each word in the sentence, the word representation of the starting position and the ending position of the sentence component in the sentence is obtained, including: According to the word representation of each position of the sentence, if the corresponding position is judged to be the starting position of the sentence component, the position is added to the starting position set; if the corresponding position is judged to be the ending position of the sentence component, the position is added to the ending position set; If the position matching probability of the start position in the start position set and the end position in the end position set is greater than a threshold, the start position and the end position of the sentence component are obtained.

3. The method according to claim 1, It is characterized in that The method further comprises: If there is a predicate component between the start position and the end position of the sentence component, then the sentence component is determined to be a clause; The sentence components whose starting positions and ending positions are within the scope of the clause are determined as subordinate sentence components of the clause.

4. The method according to claim 1, It is characterized in that The method further comprises: Acquire a sentence set for training, the sentence set including training corpus of each sentence, the training corpus including sentences, sentence components, queries corresponding to the sentence components, sentence component start positions, and sentence component end positions; The step of training the sentence component recognition model to be trained by using the training sentence set comprises: inputting the training corpus of the sentences in the sentence set into the sentence component recognition model to be trained, the sentence component recognition model outputting the predicted start position and the predicted end position of the corresponding sentence component according to the sentence component and the query corresponding to the sentence component, and adjusting the sentence component recognition model according to the difference between the sentence component start position and the predicted start position, and the difference between the sentence component end position and the predicted end position; The step of training the sentence component recognition model to be trained by using the training sentence set is repeated until the training end condition is met, thereby obtaining a trained sentence component recognition model.

5. The method according to claim 4, It is characterized in that The acquiring of a sentence set for training comprises: Obtaining queries about sentences and sentence components and annotated start and end positions of sentence components; According to the sentence, the query, and the start and end positions of the sentence components, constructing the sentence components of the sentence respectively for use as training corpus for model input; According to the training corpus described in each sentence, a training sentence set is obtained.

6. The method according to any one of claims 1 to 5, It is characterized in that According to the starting position and the ending position of the sentence component, the text content corresponding to the sentence component is obtained, including: according to the starting position and the ending position of the sentence component, marking the text content corresponding to the sentence component on the sentence.

7. A sentence component recognition device, It is characterized in that The device comprises: An input acquisition module is used to acquire sentences and sentence components to be recognized; A query acquisition module, used to acquire the query corresponding to the sentence component; A position acquisition module, used for inputting the query and the sentence into a pre-trained sentence component recognition model to obtain the starting position and the ending position of the sentence component in the sentence; the sentence component recognition model is trained based on the query and a sentence set that identifies the position of each sentence component; An identification module, used for obtaining text content corresponding to the sentence component according to the starting position and the ending position of the sentence component; The location acquisition module comprises: An input module, used to input the word vector, position vector and identification vector of each word in the query as the input features of the query, and the word vector, position vector and identification vector of each word in the sentence as the input features of the sentence, into a pre-trained sentence component recognition model; A word feature processing module, used to process the input features of the query and the input features of the sentence through a sentence component recognition model to obtain word representations of each word in the sentence; wherein the processing includes attention interaction processing of the input features of the query and the input features of the sentence; The analysis module is used to obtain the starting position and the ending position of the sentence component in the sentence according to the word representation of each word in the sentence.

8. The device according to claim 7, Features: The word feature processing module is used to represent the words at each position of the sentence. If the corresponding position is judged to be the starting position of the sentence component, the position is added to the starting position set; if the corresponding position is judged to be the ending position of the sentence component, the position is added to the ending position set; if the position matching probability between the starting position in the starting position set and the ending position in the ending position set is greater than a threshold, the starting position and the ending position of the sentence component are obtained.

9. The device according to claim 7, It is characterized in that The device also includes: The nested identification module is used to determine that a sentence component is a clause if there is a predicate component between the start position and the end position of the sentence component; and determine that the sentence component whose start position and end position are within the scope of the clause is a subordinate sentence component of the clause.

10. The device according to claim 7, It is characterized in that The device also includes: A sentence set acquisition module is used to acquire a sentence set for training, wherein the sentence set includes training corpus of each sentence, and the training corpus includes sentences, sentence components, queries corresponding to sentence components, sentence component start positions, and sentence component end positions; The training module is used to input the training corpus of the sentences in the sentence set into the sentence component recognition model to be trained. The sentence component recognition model outputs the predicted starting position and the predicted ending position of the corresponding sentence component according to the sentence component and the query corresponding to the sentence component. The sentence component recognition model is adjusted according to the difference between the sentence component starting position and the predicted starting position, and the difference between the sentence component ending position and the predicted ending position. The step of training the sentence component recognition model to be trained using the training sentence set is repeated until the training end condition is met to obtain the trained sentence component recognition model.

11. The device according to claim 10, It is characterized in that The sentence set acquisition module is used to acquire sentences, inquiries of sentence components, and the start and end positions of the annotated sentence components; and construct the training corpus of each sentence component of the sentence as a model input according to the sentences, inquiries, and the start and end positions of the sentence components; According to the training corpus of each sentence, a training sentence set is obtained.

12. The device according to any one of claims 7 to 11, It is characterized in that The recognition module is used to identify the text content corresponding to the sentence component on the sentence according to the starting position and the ending position of the sentence component.

13. A computer device comprising a memory and a processor, wherein the memory stores a computer program. It is characterized in that When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.

14. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.