Text recognition method and device, server and computer readable storage medium

By extracting nested vector features in the text and identifying user wishes, the problem of insufficient response accuracy of traditional named entity recognition models is solved, and higher response fit and accuracy are achieved.

CN119089903APending Publication Date: 2024-12-06TCL TECHNOLOGY GROUP CORPORATION
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310657854.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-06-05
Publication Date
2024-12-06

AI Technical Summary

Technical Problem

The traditional named entity recognition model has shortcomings in response accuracy, and it is difficult to accurately unearth the user's true intention to express himself.

Method used

By extracting nested vector features in the text, identifying the user's true intentions, thereby improving the accuracy of the model's response. The specific steps include obtaining the target text, performing feature extraction and nested feature extraction, using recurrent neural networks and self-attention mechanisms to generate nested text features, and then determining the response information.

Benefits of technology

This improves the fit of the model to user's wishes and enhances the accuracy and relevance of the response.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119089903A_ABST
    Figure CN119089903A_ABST
Patent Text Reader

Abstract

The invention provides a text recognition method and device, a server and a computer readable storage medium. The method comprises the steps of obtaining an input target text; performing feature extraction on the target text to obtain nested text features in the target text; and determining response information corresponding to the target text according to the nested text features in the target text. According to the text recognition method provided by the invention, after the text sent by the user is acquired, the nested features in the text of the user can be recognized, so that the real expression willingness of the user can be determined according to the nested features in the features, and the fit degree between the feedback made by the model and the willingness of the user is higher.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a text recognition method, device, server and computer-readable storage medium. Background Art

[0002] In recent years, with the rapid development of Internet information technology, the degree of informatization in various industries has been continuously improved. Among the numerous text data, how to mine the hidden effective information and give full play to the advantages of big data is a hot topic in natural language processing. Using named entity recognition, valuable structured information can be mined from massive unstructured texts. It is the basis for the architecture of intelligent question and answer, user intent recognition, chatbots and other systems. However, the accuracy of the responses of this type of traditional model needs to be improved. Summary of the invention

[0003] The present application provides a text recognition method, which obtains the user's true expression meaning by identifying the nested vectors in the text, and can then smoothly respond to the user's questions.

[0004] In a first aspect, the present application provides a text recognition method, the method comprising:

[0005] Get the input target text;

[0006] Extracting features from the target text to obtain nested text features in the target text;

[0007] According to the nested text features in the target text, response information corresponding to the target text is determined.

[0008] In a second aspect, the present application further provides a text recognition device, the device comprising:

[0009] The acquisition module is used to obtain the input target text;

[0010] An extraction module, used for performing feature extraction on the target text to obtain nested text features in the target text;

[0011] The determination module is used to determine the response information corresponding to the target text according to the nested text features in the target text.

[0012] In a third aspect, the present application further provides a server, comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps in any one of the text recognition methods.

[0013] In a fourth aspect, the present application further provides a computer-readable storage medium, on which a computer program is stored, and the computer program is executed by a processor to implement the steps in any one of the text recognition methods.

[0014] The text recognition method provided in the present application can identify the nested features in the user's text after obtaining the text sent by the user, so as to determine the user's true expression intention based on the features nested in the features, and further make the feedback made by the model more consistent with the user's intention. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0016] Figure 1 is a scenario diagram of a text recognition system provided in an embodiment of the present application;

[0017] Figure 2 This is a flowchart of an embodiment of a text recognition method in an embodiment of the present application;

[0018] Figure 3 This is a flowchart of an embodiment of a text recognition method in an embodiment of the present application;

[0019] Figure 4 is a functional module diagram of a text recognition device in an embodiment of the present application;

[0020] Figure 5 It is a schematic diagram of the structure of the server in the embodiment of the present application. DETAILED DESCRIPTION

[0021] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application.

[0022] In the description of the present application, it should be understood that the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the feature. In the description of the present application, "plurality" means two or more, unless otherwise clearly and specifically defined.

[0023] In this application, the word "exemplary" is used to mean "used as an example, illustration or description". Any embodiment described as "exemplary" in this application is not necessarily to be construed as being more preferred or advantageous than other embodiments. At the same time, it is to be understood that in the specific implementation of this application, when user information, user data and other related data are involved, when the above embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data shall comply with relevant laws, regulations and standards of relevant countries and regions.

[0024] In order to enable any person skilled in the art to implement and use the present application, the following description is provided. In the following description, details are listed for the purpose of explanation. It should be understood that those of ordinary skill in the art will recognize that the present application can be implemented without using these specific details. In other examples, known structures and processes will not be elaborated in detail to avoid unnecessary details that make the description of the present application obscure. Therefore, the present application is not intended to be limited to the embodiments shown, but is consistent with the widest range of principles and features disclosed in the present application.

[0025] The present application provides a text recognition method, apparatus, device and storage medium, which are described in detail below.

[0026] See also Figure 1 , Figure 1 Schematic diagram of a text recognition system provided in an embodiment of the present application. The text recognition system may include a server 100 and a terminal device 200. The terminal device 200 may transmit data to the server 100. Figure 1 The server 100 in the embodiment can obtain the question and answer text data sent by the user in the terminal device 200 to execute the text recognition method in the present application.

[0027] In the embodiment of the present application, the server 100 includes but is not limited to an independent server, and may also be a server network or server cluster composed of servers, including but not limited to a computer, a network host, a single network server, a plurality of network server sets or a cloud server composed of multiple servers. The cloud server may be composed of a large number of computers or network servers based on cloud computing.

[0028] In the embodiment of the present application, the terminal device 200 includes but is not limited to a desktop computer, a portable computer, a network server, a PDA (Personal Digital Assistant), a tablet computer, a wireless terminal device, an embedded device, etc.

[0029] In the embodiments of the present application, communication between the server 100 and the terminal device 200 can be achieved through any communication method, including but not limited to mobile communications based on the 3rd Generation Partnership Project (3GPP), Long Term Evolution (LTE), and Worldwide Interoperability for Microwave Access (WiMAX), or computer network communications based on the TCP / IP Protocol Suite (TCP / IP), User Datagram Protocol (UDP), etc.

[0030] It should be noted that Figure 1 The scenario diagram of the text recognition system shown is merely an example. The text recognition system and scenario described in the embodiment of the present application are intended to more clearly illustrate the technical solution of the embodiment of the present application, and do not constitute a limitation on the technical solution provided in the embodiment of the present application. A person of ordinary skill in the art can appreciate that with the evolution of the text recognition system and the emergence of new business scenarios, the technical solution provided in the embodiment of the present application is equally applicable to similar technical problems.

[0031] like Figure 2 As shown, Figure 2 This is a flow chart of an embodiment of a text recognition method in an embodiment of the present application. The text recognition method may include the following steps 201 to 203:

[0032] 201. Get the input target text.

[0033] In the embodiments of the present application, the target text may be text data in any text form, including text data sent directly by a user, or voice data sent by a user and then text data generated based on the voice data, which is not limited in the embodiments of the present application.

[0034] 202. Perform feature extraction on the target text to determine the nested text features in the target text.

[0035] In the embodiment of the present application, the following methods can be used to determine the nested text features in the target text, specifically including:

[0036] Each time the text is fed into the nested text feature extraction model, the data is a batch-sized cross-modal data pair {V, Q, A}. Taking a single cross-modal data pair as an example, Q is the corresponding text language information, which can be expressed as a word sequence {word 1 ,word 2 ,…,word T}, where the maximum length of T is 14, and words exceeding this length will be discarded. The word sequence Q will first be sent to the lookup table module (Lookup Table), and the original one-hot word typical vector, such as {0,…,0,1,0,…,0}, will be converted into the corresponding word nested feature sequence {word_vector 1 ,word_vector 2 ,…,word_vector T}, where word_vector t is a vector of dimension 1×300. Then, the word nested feature sequence corresponding to the sentence is gradually sent to a specific recurrent neural network module in the order of time steps. In this embodiment, Gate Recurrent Unit (GRU) is used. Each step in this recurrent neural network contains two vectors: hidden state hidden_state and subsequent output output. In this embodiment, the hidden features of the last time step and the fusion features of the hidden features of all time steps are used as benchmarks to verify the effect. t is the hidden layer feature at time step t, which is a vector of dimension 1×1024. If the hidden layer feature of the last time step is used as the output feature, the final output ques_representation is hidden_state t , that is, the output is a 1×1024 vector. If the fusion features of the hidden features of all time steps are used as the output features, then the hidden features of all time steps, that is, {hidden_state 1 ,hidden_state 2 ,…,hidden_state T} will be simultaneously input into a self-attention module, which adopts a dual-headed self-attention mode, that is, the hidden layer features of all time steps are simultaneously passed through the same convolutional layer to become a vector of dimension T×512, and then simultaneously passed through the same convolutional layer to become a vector of dimension T×2. This vector is then split into two vectors of dimension T, which are used as two attention heads to perform dot multiplication and addition with the hidden layer features of all time steps to become a vector of dimension 1×1024. The output results of the two attention heads are then concatenated in the final dimension. The concatenated output ques_representation is usually expressed as Self-Attention 2 (hidden_state 1 ,hidden_state 2 ,…,hidden_state T ), that is, the output is a vector of 1×2048. The output feature ques_representation can be used as a nested text feature in subsequent steps.

[0037] 203. Determine response information corresponding to the target text according to the nested text features in the target text.

[0038] The purpose of obtaining the nested text feature in the embodiment of the present application is to determine the user's true expression intention. Therefore, after obtaining the nested text feature, the context information closest to the user's description can be determined based on the nested text feature, thereby determining the true meaning of the target text currently input by the user, and thus determining the specific response information.

[0039] Specifically, the nested text feature can be input into a trained classifier, which can identify the context information expressed in the nested text feature and generate a recognition result. Then, the classifier can determine a specific question classification based on the recognition result, and then search for some keywords in the target text based on the question classification to generate corresponding response information, which can then be fed back to the user. Alternatively, the actual context information of the text input by the user can be determined based on the nested text feature, and the real keywords in the text input by the user can be determined based on the actual context information of the user. Finally, based on the real keywords, the answers related to the real keywords are searched in the database or on the Internet, and the response information is formed and fed back to the user.

[0040] The text recognition method provided in the present application can identify the nested features in the user's text after obtaining the text sent by the user, so as to determine the user's true expression intention based on the features nested in the features, and further make the feedback made by the model more consistent with the user's intention.

[0041] In order to better implement the embodiment of the present application, in one embodiment of the present application, before performing nested feature extraction on the target text and determining the nested text features in the target text, the method further includes:

[0042] A sample text for training is obtained, and nested features are extracted for the sample text to obtain sample nested features, which include text features of each character in the sample text and the real label corresponding to each text feature; a label prediction is performed on the sample nested features through a preset label determination model to obtain a predicted label corresponding to each text feature; the predicted label of each text feature is compared with the real label to obtain a positive reward parameter and a negative reward parameter of the label determination model; the positive reward parameter represents the reward parameter generated when the predicted label is consistent with the real label, and the negative reward parameter represents the reward parameter generated when the predicted label is inconsistent with the real label; according to the positive reward parameter and the negative reward parameter, the label prediction parameter of the label determination model is adjusted to train the label determination model.

[0043] According to the above embodiment, after the nested text features are obtained, the nested text features need to be classified to determine the corresponding response information. However, when classifying, it is necessary to determine the labels of the nested text features in order to perform effective classification. Therefore, if the labels are determined more accurately, the results of the classification are also more accurate. Therefore, the embodiment of the present application also provides a training method for improving the scheme of label prediction of nested text features.

[0044] In the embodiment of the present application, a training scheme with increased properties is introduced, specifically including a training scheme through a reward mechanism. The basic principle of this scheme is that a label prediction is performed according to a certain strategy for the obtained sample nested features. If the predicted result is the true label corresponding to the sample nested feature, it is equivalent to the model prediction being correct, and a positive reward feedback can be obtained; if the predicted result is not the true label corresponding to the sample nested feature, the model prediction is wrong, and a negative reward feedback is obtained at this time. Since the sample nested feature is a nested feature of the entire text, the sample nested feature includes the feature information of each character in the text. At this time, label prediction is performed for each character based on the feature information of each character. In this way, after each character is label predicted, each character can determine a positive reward parameter or a negative reward parameter. If at this time, the number of negative reward parameters obtained is less than a certain threshold, the label determination model does not need to be adjusted. If the number of negative reward parameters is greater than a certain threshold, it is necessary to adjust the label prediction parameter of the label determination model, and the label prediction parameter can be a specific value, which is used to characterize a specific label prediction strategy.

[0045] In addition, in the embodiment of the present application, the positive reward parameter can be a positive integer, such as 1; the negative reward parameter can be a negative integer, such as -1, etc., which is not limited to the specific embodiment of the present application.

[0046] Moreover, in the embodiment of the present application, the label prediction parameter may be Θ={W, b}, and the predicted label determined according to the label prediction parameter may be expressed by the following formula ①:

[0047] π(a t |s t ; Θ) = σ(W*S t +b)……①

[0048] Among them, π is the policy function; S t =(P t * ,L t ), P t * is the feature corresponding to a word in the sample nested feature, L t is the real label storage set corresponding to the text. In the initial state, L t = {l t0}; a t Predict actions for labels, one action corresponds to one label, and the action set is A = {a 1 ,a 2 ,…,a k}, k represents the set of all labels, where the number of k is greater than the number of labels in the real label storage set corresponding to each word. It can be obtained that when a is determined t When we take the action from the above, we can determine the specific predicted label. Therefore, we also need to determine how to determine a t Specifically, a can be determined by the following formula ② t :

[0049]

[0050] Among them, α can be a fixed constant or the value of a linear function f(t). At this time, when the value in formula ① is substituted into formula ② and the result of the calculation belongs to 1-α, the action can be predicted with the corresponding label. If the calculation result belongs to α, an action in the action set is randomly determined for label prediction.

[0051] In summary, when the number of negative reward parameters is greater than the preset threshold, W and b in Θ = {W, b} can be adjusted to adjust the specific label prediction action. The method of adjusting W and b can be random or manual, and the specific method is not limited here.

[0052] Of course, in the embodiment of the present application, W and b in Θ={W,b} may also be adjusted based on whether the number of positive reward parameters is greater than a preset threshold. The specific solution is the same as described above and will not be repeated here.

[0053] In addition, the method of determining the positive reward parameters and the negative reward parameters through the reward mechanism can be obtained by the following formula ③, and the specific formula ③ is as follows:

[0054]

[0055] Where sgn is a sign function. If the predicted label to be added is consistent with the actual label to be added, the value is 1, otherwise it is -1; μ is a parameter that controls the reward, which is related to the number of labels corresponding to the word. The more labels there are, the larger μ is; Y t is the true label of the current text; r is the positive reward parameter or the negative reward parameter.

[0056] In order to better implement the embodiment of the present application, in one embodiment of the present application, the label prediction parameters of the label determination model are adjusted according to the positive reward parameters and the negative reward parameters, including:

[0057] According to the positive reward parameters and the negative reward parameters, the sum of the reward parameters is determined; based on the gradient descent algorithm, the label prediction parameters of the label determination model are adjusted according to the sum of the reward parameters.

[0058] In the above embodiment, a scheme for label prediction based on label prediction parameters is provided, and the above embodiment adjusts the label prediction parameters by random adjustment or manual adjustment. However, the schemes of random adjustment or manual adjustment are usually inefficient. Therefore, the embodiment of the present application provides a scheme for adjusting the label prediction parameters. Specifically, in the embodiment of the present application, the positive reward parameter or negative reward parameter corresponding to each word can be summed to obtain the sum of the reward parameters R n ,in r is the positive reward parameter or negative reward parameter obtained by the above formula ③, t is the current word, and n is the number of r, which is also the number of words in the target text. When the sum of the reward parameters R is determined n , the adjusted label prediction parameters can be determined according to the following formulas ④ and ⑤. The specific formulas ④ and ⑤ representing the gradient descent method can be shown as follows:

[0059]

[0060]

[0061] Among them, p(S 1 ) and p(S t+1 |St ,a t ) is equal to 1; ∏ is a continuous multiplication operation; E is the expected calculation; P is the sample nesting feature; the parameters in formula ④ and formula ⑤ are the same as those in the above embodiment and will not be repeated here.

[0062] In this way, new label prediction parameters can be obtained based on formula ④ and formula ⑤. At this time, the adjustment can be completed by replacing the original label prediction parameters with the new label prediction parameters.

[0063] In summary, by looping in this way, when the new label prediction parameters are the same as the original label prediction parameters, the adjustment can be stopped, which indicates that the label determination model has completed training.

[0064] In order to better implement the embodiment of the present application, in one embodiment of the present application, nested feature extraction is performed on the target text to determine the nested text features in the target text, including:

[0065] The first feature extraction is performed on the target text to obtain the flat text features in the target text; flat label prediction is performed on the flat text features to obtain label sequences under different probabilities; the label sequence with the highest probability in each label sequence is determined as the target label sequence; feature processing is performed on the target label sequence and the flat text features to obtain the nested text features of the target text.

[0066] The above embodiment provides a method for extracting nested text features. In order to achieve better classification results when classifying nested text features in subsequent steps, the richer the feature information in the nested text features, the better the classification results. Therefore, the embodiment of the present application provides a solution for extracting nested text features, which is used to enrich the feature information in the nested text features.

[0067] The specific solution process may include: first extracting the flat text features of the target text, and then further extracting the flat text features to obtain the nested text features. Through the two feature extractions, the feature information in the nested text features is enriched.

[0068] In the embodiment of the present application, the flat text feature can be extracted by any text feature extraction model, such as a BiLSTM model. For example, the target text can be input into the BiLSTM model to obtain the flat text feature.

[0069] After obtaining the flat text feature, it is also necessary to perform label prediction for the flat text feature, and then determine the label corresponding to the flat text feature. Among them, the scheme for determining the target label sequence of the flat text feature can include inputting the flat text feature into any model that completes label prediction training, such as a BiLSTM model. For example, after inputting the target text into the BiLSTM model, the flat text feature can be obtained after passing through the feature extraction layer in the BiLSTM model. At this time, the obtained flat text feature is sent to the label prediction layer in the BiLSTM model, that is, a target label sequence that matches the flat text feature and has the highest probability can be output.

[0070] After obtaining the flat text feature and the target label sequence corresponding to the flat text feature, the flat text feature and the preset hyperparameters can be input into the BiLSTM model again to obtain the nested text feature. The nested text feature extraction scheme provided by the embodiment of the present application can enrich the feature information in the nested text feature.

[0071] In order to better implement the embodiment of the present application, in one embodiment of the present application, determining the label sequence with the highest probability among the label sequences as the target label sequence includes:

[0072] According to the flat text features and the preset conversion score matrix, the probability score of each label sequence is determined; the label sequence with the highest score among the probability scores of each label sequence is regarded as the target label sequence.

[0073] However, according to the above embodiment, the target label sequence for obtaining flat text features is obtained through the BiLSTM model. However, because the BiLSTM model in the feature extraction layer usually only predicts labels based on the maximum probability output, the outputs are not affected, resulting in the possibility that the sequence labels are not in order logic. Therefore, this layer can also use the CRF model to process the output of the feature extraction layer, consider the local features of the sentence, add transfer scores between adjacent labels, constrain label dependencies, and make up for the shortcomings of the BiLSTM model.

[0074] Specifically, the CRF model can be used to output multiple label sequences of the target text. At this time, the probability score of each label sequence is obtained through the preset conversion score matrix, and then the target label sequence is determined based on the highest probability score, which can be shown in the following formula ⑥ and formula ⑦:

[0075]

[0076] y * =arg max s(X,y)……⑦

[0077] Among them, X is the target text, y is any label sequence, A is the conversion score matrix, P is the flat text feature, n is the number of characters in the target text, and i is the ordinal number of the label sequence. Specifically, the conversion score matrix A is as follows:

[0078]

[0079] Finally, the target label sequence with the highest probability score can be obtained through formula ⑦.

[0080] It should be noted that in the embodiment of the present application, the model that outputs multiple label sequences using the CRF model can be trained using the following loss function:

[0081]

[0082] Where i represents a single training example and Y' represents the set of all possible label sequences.

[0083] In order to better implement the embodiment of the present application, in one embodiment of the present application, the target label sequence includes the position information of each character in the target text and the initial predicted label corresponding to each character, and the nested text features in the target text are determined according to the target label sequence and the flat text features, including:

[0084] Determine the label type of the initial prediction label corresponding to each character in the target text; obtain the target initial prediction label according to the label type of the initial prediction label corresponding to each character in the target text; determine the text position feature of the target text according to the position information of the target text corresponding to the target initial prediction label; obtain the nested text feature in the target text according to the text position feature, the flat text feature and the probability score of the target label sequence.

[0085] The above embodiment provides a solution for obtaining nested text features through a BiLSTM model. In order to further make the feature information included in the nested text features more targeted, the embodiment of the present application can also determine the nested text features based on the position information in the target tag sequence.

[0086] Specifically, for the label of each character in the target text, determine the label type of the label corresponding to each character. After determining the label type of the label corresponding to each character, select the specific label type and the position information of the character of the feature label type in the text, and perform certain feature processing on the flat vector, so as to obtain the character position feature. Assume that the label types may include: Type B, representing the beginning of the entity; Type I, representing the middle of the entity; Type E, representing the end of the entity; Type S, representing a single-word entity, etc. At this time, Type B and Type E can be regarded as the required target label types. At this time, the specific position information of the character corresponding to the label type in the target text can be determined according to the target label type. At this time, the flat text feature can be adjusted according to the specific position information. For example: Assume that there are 5 characters in the target text (character 1, character 2, character 3, character 4, character 5), and at the same time assume that the labels corresponding to character 1 and character 4 are the target label types. If the flat text feature corresponding to the target text is (a, b, c, d, e), then vector a and vector d can be converted to 1; vector b, vector c and vector e can be converted to 0, and a new position vector (1, 0, 0, 1, 0) is obtained. This new position vector is the text position feature involved in the embodiment of the present application. Next, the specific nested text feature can be obtained as shown in formula ⑧:

[0087] v * =εv+(1-ε)(s+v BE )……⑧

[0088] Among them, v BE is the text position feature; v and are flat text features; s is the probability score of the target label sequence mentioned in the above embodiment; ε is a hyperparameter. It should be noted that according to formula ⑧, v * As an intermediate feature, v * By inputting the BiLSTM model again, we can get the nested text feature P * . And it should be noted that P * In the above embodiment, P t * A collection of nested features for each literal.

[0089] In order to better implement the embodiment of the present application, in one embodiment of the present application, a first feature extraction is performed on the target text to obtain a flat text feature in the target text, including:

[0090] The target text is subjected to word vector conversion, block vector conversion and position vector conversion to obtain a word vector, a block vector and a position vector; a target vector is determined according to the word vector, the block vector and the position vector; a first feature is extracted from the target vector to obtain a flat text feature in the target text.

[0091] In order to further obtain effective flat text features, the embodiment of the present application can input the target text into the BERT model to encode Chinese characters and obtain relevant text vectors. Afterwards, the flat text features are extracted based on the text vectors.

[0092] Specifically, the target text can be converted into a text vector using the following formula ⑨:

[0093]

[0094] Among them, v is the text vector of the target text; v t Represents the word vector, v s represents a block vector, v p Represents the position vector. t is the one-hot vector corresponding to the input sequence X, e s is a block code. When the input sequence is a single block, the block code of all words is 0. p is the positional one-hot encoding. W t , W s , W p They represent the word vector matrix, block vector matrix, and position vector matrix respectively, all of which are obtained during the training of the BERT model. At this point, the text vector v of the target text is input into the BiLSTM model to obtain the flat text feature.

[0095] In order to better implement the embodiment of the present application, in one embodiment of the present application, the response information corresponding to the target text is determined according to the nested text features in the target text, including:

[0096] Perform label prediction on the nested text feature to obtain the predicted label of the nested text feature; determine the response type matched by the nested text feature according to the predicted label of the nested text feature; and determine the response information corresponding to the target text according to the response type.

[0097] After the nested text features are determined, the embodiment of the present application also provides a specific implementation method for replying to the user based on the nested text features. This method specifically includes the following steps: First, after the nested text features are obtained, it is necessary to predict the labels of the nested text features. For example: determine the purpose of annotation and the type of annotation. For example, what we need to annotate are entities, relationships, events, etc., and the types of annotation required are classification, sequence annotation, structure annotation, etc. In this way, after completing the label prediction of the nested text features, the real nested entities, the relationships between the entities, and specific events can be obtained. For example: "Why is the sky blue?" The results of the text being annotated can include "the sky corresponds to an entity label", "blue corresponds to an entity label", and the relationship label is a label of the question type. At this time, after the specific label is determined, the response type can be the type of answering the user's question. At this time, the reason why the sky is blue can be searched for and given to the user.

[0098] Alternatively, the input text is assumed to be "play song B of A", in which case the annotation result of the text may include "A corresponds to an entity tag", "B corresponds to an entity tag", the relationship tag is an execution type tag, and the response type may be a type of executing user instructions. In this case, the user is given an affirmative response message and song B is played at the same time. It should be noted that the mapping relationship between the response type and the tag can be set in advance.

[0099] In addition, the present application also provides an implementation method. Specifically, as shown in the above embodiment, after obtaining the flat text feature, when generating the nested vector, if the hyperparameter ε takes the value of 1, there is no need to extract the nested feature for the flat text feature, but a solution is specially optimized for the flat text feature. Figure 3 As shown, if the value of the hyperparameter ε is not 1, the nested feature extraction is performed. Moreover, in the embodiment of the present application, the feature optimization scheme for the extracted flat text features can be optimized in accordance with the method of the above embodiment, for example, a reward mechanism is introduced to correct the flat text features. For example: referring to the operations in the nested entity recognition module based on reinforcement learning, the state, action, strategy, reward and objective function can be defined in the same way to optimize the flat entity label. The main difference is that the action that can be executed is no longer to go to state S t L t Instead of adding elements to L, we directly replace t , that is, L t = {l t0} is replaced by The reward judgment criteria have been changed to whether the replaced label is the same as the actual label.

[0100] in, Figure 3Data cleaning in the target text can be a process of deleting repeated words or modifying text errors and missing words in the text information in the target text, including removing repeated words: there may be reduplicated words in a target text, but these reduplicated words may be repeated characters entered by the user unintentionally. Therefore, it may affect the accuracy of the analysis results. In this case, one of the reduplicated words can be deleted for repair.

[0101] Missing text processing: Missing text processing refers to the situation where there are missing characters in the target text. In some cases, missing characters may also affect the accuracy of the model. For example, for nouns, if the part of speech of a word is a noun and the noun is missing a character, then the noun can be completed based on the context.

[0102] Typos: Users may make typos when entering target text, which may also affect the accuracy of the model. In this case, the user's typos can be corrected based on the grammar and words recorded in the dictionary.

[0103] In summary, the specific process of this application can be as follows:

[0104] (1) First, the original input data is sent to the flat text feature initial extraction module after data cleaning and other operations, and the flat entity and the corresponding annotation sequence y are output. * .

[0105] (2) In the nested basis vector generation module, the initial annotation information is used to calculate the nested basis vector v * If ε is 1, it will directly proceed to the flat entity optimization module in step 4, otherwise it will proceed to the nested entity recognition module in step (3). However, in actual situations, the value of ε is a fixed value and will not change.

[0106] (3) The process of adding nested entity labels is solved as reinforcement learning. Through the designed state, action, strategy, reward and objective function, various actions are tried. The next step is judged based on the observed rewards. A strategy-based method is used to add nested entity labels and output nested entities.

[0107] (4) Similar to step 3, if ε is taken as 1, reinforcement learning is used to correct the flat entity label, thereby optimizing the flat entity label. If there are nested entities in the data set, the process can return to step 2 for a loop. In this way, the function of optimizing flat entities and extracting nested entities can be achieved.

[0108] In order to solve the problems that traditional network algorithms cannot solve the problem of nested entity recognition and pointer networks cannot directly classify the types of nested entities, through the trial-and-error search and action reward mechanism of reinforcement learning, we can achieve the function of both optimizing flat entities and identifying nested entities, thereby improving users' satisfaction with the product.

[0109] In order to better implement the text recognition method in the embodiment of the present application, in addition to the text recognition method, the embodiment of the present application also provides a text recognition device, such as Figure 4 As shown, the device 300 includes:

[0110] The acquisition module 301 is used to acquire the input target text;

[0111] An extraction module 302 is used to extract features from the target text to obtain nested text features in the target text;

[0112] The determination module 303 is used to determine the response information corresponding to the target text according to the nested text features in the target text.

[0113] The text recognition device provided in the present application obtains the text sent by the user through the acquisition module 301, and then extracts the nested features in the user text through the extraction module 302, so that the user's true expression intention can be determined based on the determination module 303 according to the features nested in the features, thereby making the feedback made by the model more consistent with the user's intention.

[0114] In some embodiments of the present application, the text recognition device may further include a training module 304, and the training module 304 is specifically used to:

[0115] Obtain sample text for training, perform nested feature extraction on the sample text, and obtain sample nested features, where the sample nested features include text features of each character in the sample text and true labels corresponding to each text feature;

[0116] The preset label determination model is used to predict the labels of the sample nested features, and the predicted labels corresponding to each text feature are obtained;

[0117] Compare the predicted label of each text feature with the actual label to obtain the positive reward parameter and negative reward parameter of the label determination model; the positive reward parameter represents the reward parameter generated when the predicted label is consistent with the actual label, and the negative reward parameter represents the reward parameter generated when the predicted label is inconsistent with the actual label;

[0118] According to the positive reward parameter and the negative reward parameter, the label prediction parameter of the label determination model is adjusted to train the label determination model.

[0119] In some embodiments of the present application, the training module 304 is further used to:

[0120] Determine the sum of the reward parameters according to the positive reward parameters and the negative reward parameters;

[0121] Based on the gradient descent algorithm, the label prediction parameters of the label determination model are adjusted according to the sum of the reward parameters.

[0122] In some embodiments of the present application, the extraction module 302 is specifically used to:

[0123] Performing a first feature extraction on the target text to obtain a flat text feature in the target text;

[0124] Perform flat label prediction on flat text features to obtain label sequences with different probabilities;

[0125] Determine the label sequence with the highest probability among all label sequences as the target label sequence;

[0126] Feature processing is performed on the target label sequence and the flat text features to obtain the nested text features of the target text.

[0127] In some embodiments of the present application, the extraction module 302 is specifically used to:

[0128] Determine the probability score of each tag sequence based on the flat text features and the preset conversion score matrix;

[0129] The label sequence with the highest probability score among all label sequences is regarded as the target label sequence.

[0130] In some embodiments of the present application, the extraction module 302 is specifically used to:

[0131] Determine the label type of the initial predicted label corresponding to each word in the target text;

[0132] According to the label type of the initial prediction label corresponding to each word in the target text, the target initial prediction label is obtained;

[0133] Determine the text position feature of the target text according to the position information of the target text corresponding to the target initial prediction label;

[0134] According to the text position features, flat text features and the probability scores of the target label sequence, the embedded text features in the target text are obtained.

[0135] In some embodiments of the present application, the extraction module 302 is specifically used to:

[0136] Perform word vector conversion, block vector conversion and position vector conversion on the target text to obtain word vector, block vector and position vector;

[0137] Determine the target vector based on the word vector, block vector and position vector;

[0138] Perform the first feature extraction on the target vector to obtain the flat text features in the target text.

[0139] In some embodiments of the present application, the determination module 303 is specifically used to:

[0140] Perform label prediction on the nested text features to obtain the predicted labels of the nested text features;

[0141] Determine the response type that matches the nested text feature based on the predicted label of the nested text feature;

[0142] According to the response type, the response information corresponding to the target text is determined.

[0143] The present application also provides a server that integrates any text recognition method provided in the present application. Figure 5 As shown, it shows a schematic diagram of the structure of the server involved in the embodiment of the present application, specifically:

[0144] The server may include one or more processing core processors 401, one or more computer-readable storage media memories 402, a power supply 403, an input unit 404 and other components. Those skilled in the art will appreciate that Figure 5 The server structure shown in the figure does not constitute a limitation on the server, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.

[0145] in:

[0146] The processor 401 is the control center of the server, and uses various interfaces and lines to connect various parts of the entire server. By running or executing software programs and / or modules stored in the memory 402, and calling data stored in the memory 402, the processor 401 executes various functions of the server and processes data, thereby monitoring the server as a whole. Optionally, the processor 401 may include one or more processing cores; the processor 401 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc. Preferably, the processor 401 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface and application programs, etc., and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 401.

[0147] The memory 402 can be used to store software programs and modules. The processor 401 executes various functional applications and data processing by running the software programs and modules stored in the memory 402. The memory 402 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system and an application required for at least one function; the data storage area may store data created according to the use of the server, etc. In addition, the memory 402 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Accordingly, the memory 402 may also include a memory controller to provide the processor 401 with access to the memory 402.

[0148] The server also includes a power supply 403 for supplying power to each component. Preferably, the power supply 403 can be logically connected to the processor 401 through a power management system, so that the power management system can manage charging, discharging, power consumption and other functions. The power supply 403 can also include one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, power status indicators and other arbitrary components.

[0149] The server may further include an input unit 404, which may be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.

[0150] Although not shown, the server may further include a display unit, etc., which will not be described in detail herein. Specifically in this embodiment, the processor 401 in the server will load the executable files corresponding to the processes of one or more application programs into the memory 402 according to the following instructions, and the processor 401 will run the application programs stored in the memory 402, thereby realizing various functions, such as:

[0151] Get the input target text;

[0152] Extract features from the target text to obtain the nested text features in the target text;

[0153] According to the nested text features in the target text, the response information corresponding to the target text is determined.

[0154] A person of ordinary skill in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.

[0155] To this end, the embodiment of the present application provides a computer-readable storage medium, which may include: a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, etc. A computer program is stored thereon, and the computer program is loaded by a processor to execute the steps in any text recognition method provided in the embodiment of the present application. For example, the computer program loaded by the processor can execute the following steps:

[0156] Get the input target text;

[0157] Extract features from the target text to obtain the nested text features in the target text;

[0158] According to the nested text features in the target text, the response information corresponding to the target text is determined.

[0159] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the detailed description of other embodiments above, and will not be repeated here.

[0160] In specific implementation, the above units or structures can be implemented as independent entities, or can be arbitrarily combined to be implemented as the same or several entities. The specific implementation of the above units or structures can refer to the previous method embodiments, which will not be repeated here.

[0161] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.

[0162] The above is a detailed introduction to a text recognition method and device provided in an embodiment of the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for technical personnel in this field, according to the idea of ​​the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. A text recognition method, characterized in that: The method comprises: Get the input target text; Extracting features from the target text to obtain nested text features in the target text; According to the nested text features in the target text, response information corresponding to the target text is determined.

2. The text recognition method according to claim 1, characterized in that: The step of extracting features from the target text and determining the nested text features in the target text includes: Performing a first feature extraction on the target text to obtain a flat text feature in the target text; Performing flat label prediction on the flat text features to obtain label sequences under different probabilities; Determine the tag sequence with the highest probability among the tag sequences as the target tag sequence; Feature processing is performed on the target tag sequence and the flat text feature to obtain a nested text feature of the target text.

3. The text recognition method according to claim 2, characterized in that: The determining the tag sequence with the highest probability among the tag sequences as the target tag sequence includes: Determining a probability score of each of the tag sequences according to the flat text features and a preset conversion score matrix; The tag sequence with the highest probability score among the tag sequences is regarded as the target tag sequence.

4. The text recognition method according to claim 3, characterized in that: The target label sequence includes position information of each character in the target text and an initial predicted label corresponding to each character. Determining the nested text feature in the target text according to the target label sequence and the flat text feature includes: Determine the label type of the initial predicted label corresponding to each word in the target text; Obtaining a target initial prediction label according to the label type of the initial prediction label corresponding to each character in the target text; Determining the text position feature of the target text according to the position information of the target text corresponding to the target initial prediction label; The nested text features in the target text are obtained according to the text position features, the flat text features and the probability scores of the target tag sequence.

5. The text recognition method according to claim 2, characterized in that: The first feature extraction is performed on the target text to obtain a flat text feature in the target text, including: Performing word vector conversion, block vector conversion and position vector conversion on the target text to obtain word vectors, block vectors and position vectors; Determine a target vector according to the word vector, the block vector and the position vector; A first feature extraction is performed on the target vector to obtain a flat text feature in the target text.

6. The text recognition method according to claim 1, characterized in that: The step of determining the response information corresponding to the target text according to the nested text features in the target text includes: Performing label prediction on the nested text feature to obtain a predicted label of the nested text feature; Determining a response type matched by the nested text feature according to the predicted label of the nested text feature; According to the response type, response information corresponding to the target text is determined.

7. The text recognition method according to claim 1, characterized in that: Before extracting the nested features of the target text and determining the nested text features in the target text, the method further includes: Acquire sample text for training, perform nested feature extraction on the sample text, and obtain sample nested features, wherein the sample nested features include text features of each character in the sample text and true labels corresponding to each text feature; Using a preset label determination model to perform label prediction on the sample nested features, and obtain a predicted label corresponding to each text feature; The predicted label of each of the text features is compared with the real label to obtain a positive reward parameter and a negative reward parameter of the label determination model; the positive reward parameter represents the reward parameter generated when the predicted label is consistent with the real label, and the negative reward parameter represents the reward parameter generated when the predicted label is inconsistent with the real label; Determining a sum of reward parameters according to the positive reward parameter and the negative reward parameter; Based on a gradient descent algorithm, a label prediction parameter of the label determination model is adjusted according to the sum of the reward parameters to train the label determination model.

8. A text recognition device, characterized in that: The device comprises: The acquisition module is used to obtain the input target text; An extraction module, used for performing feature extraction on the target text to obtain nested text features in the target text; The determination module is used to determine the response information corresponding to the target text according to the nested text features in the target text.

9. A server, characterized in that: The server includes a processor, a memory, and a computer program stored in the memory and executable on the processor, and the processor executes the computer program to implement the steps of the text recognition method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and the computer program is executed by a processor to implement the steps in the text recognition method according to any one of claims 1 to 7.