Text error correction method and apparatus, speech recognition method and device, and storage medium
By building a dependent syntax tree and self-attention map for correct grammar and adjusting the text error correction model, the problem of insufficient syntax error recognition and correction capabilities in the existing technology is solved, and higher text error correction accuracy is achieved.
Patent Information
- Application Number
- CN202411197446.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-28
- Publication Date
- 2024-11-29
AI Technical Summary
Existing text error correction techniques cannot effectively identify and correct syntax errors in text, affecting the accuracy of error correction, and do not consider the syntax relationship between characters in text.
By constructing a dependent syntax tree of grammatical correctness and grammatical errors, self-attention processing is performed, self-attention maps are generated, and the original text error correction model is adjusted in combination with text error correction loss data, synthesise relationships and context information are integrated to form a target text error correction model.
It improves the accuracy of text error correction, can better understand text structure and grammatical rules, and improves error correction effect.
Smart Images

Figure CN119047461A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of financial technology, and in particular to a text error correction method and apparatus, a speech recognition method, device and storage medium. Background Art
[0002] With the integration of finance and computer technology, text error correction in computer technology has also been integrated into the financial field, providing assistance for text input in financial services. For example, in insurance business scenarios, the accuracy of text input affects whether insurance information can be accurately found, so text error correction will be performed during text input, allowing users to enter more accurate text and achieve accurate search of insurance information.
[0003] In the related art, text error correction technology directly corrects the input text character by character, without considering the grammatical relationship in the text, so it is unable to identify the incorrect grammatical relationship in the text, affecting the accuracy of text error correction. Therefore, how to improve the accuracy of text error correction has become a technical problem to be solved urgently. Summary of the invention
[0004] The main purpose of the embodiments of the present application is to propose a text error correction method and apparatus, a speech recognition method, equipment and storage medium, aiming to improve the accuracy of text error correction.
[0005] To achieve the above-mentioned purpose, a first aspect of an embodiment of the present application proposes a text error correction method, the method comprising:
[0006] Acquire a training text set; wherein the training text set includes: a grammatically correct first training text and a grammatically incorrect second training text;
[0007] Acquire loss data from a preset original text error correction model to obtain text error correction loss data;
[0008] Constructing a first dependency syntax tree according to the first training text;
[0009] Constructing a second dependency syntax tree according to the first dependency syntax tree, the first training text, and the second training text;
[0010] Performing self-attention processing on the first training text according to the first dependency syntax tree to obtain a first self-attention map;
[0011] Performing self-attention processing on the second training text according to the second dependency syntax tree to obtain a second self-attention map;
[0012] Adjusting parameters of the original text error correction model according to the first self-attention map, the second self-attention map and the text error correction loss data to obtain a target text error correction model;
[0013] The target text is corrected by the target text error correction model.
[0014] In some embodiments, constructing a second dependency syntax tree according to the first dependency syntax tree and the first training text and the second training text includes:
[0015] Extracting grammatical error information from the second training text according to the first training text; wherein the grammatical error information includes: grammatical error position information and grammatical error category;
[0016] The first dependency syntax tree is adjusted according to the syntax error position information and the syntax error category to obtain the second dependency syntax tree.
[0017] In some embodiments, adjusting the first dependency syntax tree according to the syntax error location information and the syntax error category to obtain the second dependency syntax tree includes:
[0018] Filtering a target grammatical error label from preset candidate grammatical error labels according to the grammatical error category;
[0019] The first dependency syntax tree is labeled according to the syntax error position information and the target syntax error label to obtain the second dependency syntax tree.
[0020] In some embodiments, performing self-attention processing on the second training text according to the second dependency syntax tree to obtain a second self-attention map includes:
[0021] Performing encoding processing on the second dependency syntax tree to obtain an adjacency matrix; wherein the adjacency matrix represents the grammatical relationship between characters in the second training text;
[0022] Encoding the second training text according to the adjacency matrix to obtain second encoded data;
[0023] Perform self-attention processing on the second encoded data to obtain the second self-attention map.
[0024] In some embodiments, encoding the second dependency syntax tree to obtain an adjacency matrix includes:
[0025] Inputting the second dependency syntax tree into a preset graph convolutional neural network; wherein the graph convolutional neural network includes: a graph convolutional layer and a feedforward sublayer;
[0026] Performing convolution processing on the second dependency syntax tree through the graph convolution layer to obtain syntax convolution data;
[0027] The grammatical convolution data is normalized by the feedforward sublayer to obtain the adjacency matrix.
[0028] In some embodiments, adjusting parameters of the original text error correction model according to the first self-attention map, the second self-attention map, and the text error correction loss data to obtain a target text error correction model includes:
[0029] Calculating the contrast difference between the first self-attention map and the second self-attention map to obtain contrast difference data;
[0030] Calculating structural differences between the first self-attention map and the second self-attention map to obtain structural difference data;
[0031] The contrast difference data, the structure difference data and the text error correction loss data are concatenated to obtain target loss data;
[0032] The parameters of the original text error correction model are adjusted according to the target loss data to obtain a target text error correction model.
[0033] To achieve the above object, a second aspect of an embodiment of the present application provides a speech recognition method, the method comprising:
[0034] Obtain target voice data;
[0035] Performing voice content recognition on the target voice data to obtain original voice content;
[0036] The original speech content is corrected by a target text error correction model to obtain target speech content; wherein the target text error correction model is the target text error correction model in the text error correction method described in the first aspect.
[0037] To achieve the above-mentioned purpose, a third aspect of an embodiment of the present application provides a text error correction device, the device comprising:
[0038] A text acquisition module, used to acquire a training text set; wherein the training text set includes: a grammatically correct first training text and a grammatically incorrect second training text;
[0039] A loss data acquisition module is used to acquire loss data from a preset original text error correction model to obtain text error correction loss data;
[0040] A first syntax tree construction module, used to construct a first dependency syntax tree according to the first training text;
[0041] A second syntax tree construction module, used to construct a second dependency syntax tree according to the first dependency syntax tree and the first training text and the second training text;
[0042] A first self-attention module, configured to perform self-attention processing on the first training text according to the first dependency syntax tree to obtain a first self-attention map;
[0043] A second self-attention module, configured to perform self-attention processing on the second training text according to the second dependency syntax tree to obtain a second self-attention map;
[0044] A parameter adjustment module, configured to adjust parameters of the original text error correction model according to the first self-attention map, the second self-attention map and the text error correction loss data to obtain a target text error correction model;
[0045] The error correction module is used to perform error correction processing on the target text through the target text error correction model.
[0046] To achieve the above-mentioned purpose, the fourth aspect of an embodiment of the present application proposes a computer device, which includes a memory and a processor, the memory stores a computer program, and the processor implements the text correction method described in the first aspect or the speech recognition method described in the second aspect when executing the computer program.
[0047] To achieve the above-mentioned purpose, the fifth aspect of an embodiment of the present application proposes a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the text correction method described in the first aspect or the speech recognition method described in the second aspect.
[0048] The text correction method and apparatus, speech recognition method, equipment and storage medium proposed in the present application respectively construct dependency syntax trees through grammatically correct and grammatically incorrect training texts, and perform self-attention processing on the training texts according to the dependency syntax trees, so as to obtain self-attention maps corresponding to grammatical correctness and grammatical errors, so as to characterize the influence of grammatical relations on the extraction of text context information through two self-attention maps. Finally, the original text correction model is trained based on the self-attention maps corresponding to grammatical errors and grammatical correctness and the text correction loss data, so that the grammatical relations and context information are effectively integrated into the training of the original text correction model, so as to obtain a target text correction model that can better understand the structure and grammatical rules of the text, rather than relying only on the surface information of the text. Therefore, the accuracy of text correction can be improved through the target text correction model. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] Figure 1 is a flowchart of a text error correction method provided by an embodiment of the present application;
[0050] Figure 2is a schematic diagram of a first dependency syntax tree in the text error correction method provided in an embodiment of the present application;
[0051] Figure 3 yes Figure 1 Flow chart of step S104 in FIG.
[0052] Figure 4 yes Figure 3 Flow chart of step S302 in FIG.
[0053] Figure 5 is a schematic diagram of a second dependency syntax tree in the text error correction method provided in an embodiment of the present application;
[0054] Figure 6 yes Figure 1 Flow chart of step S106 in FIG.
[0055] Figure 7 yes Figure 6 Flow chart of step S601 in FIG.
[0056] Figure 8 yes Figure 1 Flow chart of step S107 in FIG.
[0057] Fig. 9 is a flow chart of a speech recognition method provided by an embodiment of the present application;
[0058] Fig.10 is a structural schematic diagram of a text error correction device provided in an embodiment of the present application;
[0059] Fig.11 is a structural diagram of a speech recognition device provided in an embodiment of the present application;
[0060] Fig.12 It is a schematic diagram of the hardware structure of the computer device provided in the embodiment of the present application. DETAILED DESCRIPTION
[0061] 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.
[0062] It should be noted that, although the functional modules are divided in the device schematic diagram and the logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart. The terms "first", "second", etc. in the specification, claims and the above drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0063] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0064] First, some nouns involved in this application are analyzed:
[0065] Artificial intelligence (AI) is a new technical science that studies and develops theories, methods, technologies and application systems for simulating, extending and expanding human intelligence. AI is a branch of computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Research in this field includes robots, language recognition, image recognition, natural language processing and expert systems. AI can simulate the information process of human consciousness and thinking. AI is also a theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
[0066] Automatic Speech Recognition (ASR): Also known as automatic speech recognition, it is a technology that converts speech audio into text.
[0067] Dependency Syntax Tree: A tree structure used to represent the dependency relationship between words in a sentence. Unlike the syntax tree, the dependency syntax tree focuses on the direct dependency relationship between words rather than the hierarchy of phrase structures. The dependency syntax tree consists of nodes and directed edges. Each node represents a word in a sentence, while the directed edges represent the dependency relationship between words.
[0068] Graph Convolutional Network (GCN) is a neural network architecture used to process graph structured data. Graph convolutional networks can capture the complex relationships between nodes in a graph and are widely used in various graph-related tasks, such as node classification, graph classification, link prediction, etc.
[0069] Feed-Forward Layer: It is a common structure in neural networks and is usually used to process linear transformations of data. In deep learning, the feed-forward layer is one of the basic building blocks in the network and is used to linearly combine input data before nonlinear activation functions.
[0070] ReLU (Rectified Linear Unit) activation function: It is a nonlinear activation function widely used in deep learning. Its purpose is to introduce nonlinearity into the neural network so that the network can learn and simulate more complex function mappings.
[0071] As computer technology is integrated into the financial field, text correction technology has become a widely used artificial intelligence technology in the financial field to assist text input in the financial field. Text correction technology corrects text when users enter text, prompts users to enter the correct text, and accurately searches for financial service information based on the correct text. For example, in the insurance business scenario, text correction by automatic language recognition can correct voice input information and incorrect sentences in voice input information, allowing users to enter information more smoothly and facilitating the output of more accurate insurance business information by the background. Because in the voice input process, it is easy to enter incomplete sentences or sentences with some words omitted, which can easily lead to grammatical errors in the input sentences. If the voice data is directly converted into text, it is easy to obtain grammatically incorrect text. Executing insurance business services based on incorrect text will affect the service effect of the insurance business.
[0072] In the related art, text correction technology is mainly trained on a clean tree bank consisting of grammatical sentences. When parsing grammatically incorrect text, due to input mismatch, it is impossible to accurately identify grammatically incorrect text, which affects the effect of text correction. At the same time, in the text correction process, the correlation between characters in the text is not considered, but the correction is made according to the literal meaning of the text, which is prone to misjudgment and reduces the accuracy of text correction.
[0073] Based on this, the embodiments of the present application provide a text correction method and apparatus, a speech recognition method, a device and a storage medium, which are intended to construct dependency syntax trees through grammatically incorrect and grammatically normal training texts respectively, and perform self-attention processing in the training text according to the dependency syntax tree to obtain an attention graph, and train the original text correction model through the attention graph formed by the two syntax trees with normal and grammatically incorrect syntax to integrate the syntax analysis tree and the self-attention graph into the text correction process. Then, in the text correction process, not only the normal and incorrect grammar in the text is learned, but also the contextual information of the text can be better understood to construct a target text correction text model with better text correction accuracy. Therefore, text correction through the target text correction model can improve the accuracy of text correction.
[0074] The text error correction method and apparatus, speech recognition method, device and storage medium provided in the embodiments of the present application are specifically illustrated through the following embodiments. First, the text error correction method in the embodiments of the present application is described.
[0075] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Artificial Intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
[0076] AI basic technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc. AI software technologies mainly include computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0077] The text error correction method provided in the embodiment of the present application relates to the field of financial technology technology. The text error correction method provided in the embodiment of the present application can be applied to a terminal, can be applied to a server side, or can be software running in a terminal or a server side. In some embodiments, the terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, etc.; the server side can be configured as an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms; the software can be an application that implements the text error correction method, etc., but is not limited to the above forms.
[0078] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.
[0079] It should be noted that in each specific implementation of the present application, when it comes to the need to perform relevant processing based on data related to user identity or characteristics such as user information, user behavior data, user historical data, and user location information, the user's permission or consent will be obtained first, and the collection, use, and processing of these data will comply with relevant laws, regulations, and standards. In addition, when the embodiment of the present application needs to obtain the user's sensitive personal information, the user's separate permission or consent will be obtained through a pop-up window or by jumping to a confirmation page. After clearly obtaining the user's separate permission or consent, the necessary user-related data for the normal operation of the embodiment of the present application will be obtained.
[0080] Figure 1 is an optional flowchart of the text error correction method provided in the embodiment of the present application. Figure 1 The method may include but is not limited to steps S101 to S108.
[0081] Step S101, obtaining a training text set; wherein the training text set includes: a grammatically correct first training text and a grammatically incorrect second training text;
[0082] Step S102, acquiring loss data from a preset original text error correction model to obtain text error correction loss data;
[0083] Step S103, constructing a first dependency syntax tree according to the first training text;
[0084] Step S104, constructing a second dependency syntax tree according to the first dependency syntax tree, the first training text, and the second training text;
[0085] Step S105, performing self-attention processing on the first training text according to the first dependency syntax tree to obtain a first self-attention map;
[0086] Step S106, performing self-attention processing on the second training text according to the second dependency syntax tree to obtain a second self-attention map;
[0087] Step S107, adjusting parameters of the original text error correction model according to the first self-attention map, the second self-attention map and the text error correction loss data to obtain a target text error correction model;
[0088] Step S108, performing error correction processing on the target text through the target text error correction model.
[0089] Steps S101 to S108 shown in the embodiment of the present application are to construct a first dependency syntax tree according to a grammatically correct first training text, and to construct a second dependency syntax tree corresponding to a grammatically incorrect second training text according to the first dependency syntax, the first training text and the second training text. When performing text self-attention processing, the first dependency syntax tree is used to perform self-attention processing on the grammatically correct first training text to obtain a first self-attention graph, and the second dependency syntax tree is used to perform self-attention processing on the grammatically incorrect second training text to obtain a second self-attention graph, and the original text error correction model is trained according to the first self-attention graph, the second self-attention graph and the text error correction loss data. Therefore, the original text error correction model is trained in combination with the syntax tree and the self-attention graph, so that the original text error correction model not only learns correct and incorrect grammar, but also learns the contextual relationship in the text, so that the trained target text error correction model can more accurately judge grammatical errors in sentences and achieve more accurate text error correction. Then, by correcting the text through the target text error correction model, the accuracy of text error correction can be improved.
[0090] In step S101 of some embodiments, the training text set can be extracted from a preset text training database, or it can be formed by collecting multiple training texts in real time. This embodiment does not specifically limit the method for obtaining the training text set. It should be noted that the training text set includes a first training text and a second training text. The second training text can be generated on the basis of the first training text, and the second training text is obtained by modifying the grammatically correct first training text into a grammatically incorrect text, and the content of each first training text and the second training text corresponds to each other, but the grammatical structure is wrong. Specifically, the first training text is set with grammatical errors according to a preset grammatical error category to obtain a second training text. The grammatical error category is pre-set, and there can be multiple second training texts generated for each grammatical error category, and multiple grammatical error categories can also be set, so the first training text can generate multiple second training texts.
[0091] For example, if the grammatical error category can be any one of the replacement error category, the redundancy error category and the omission error category. If the first training text is "Insurance Company of City A and Insurance Company of City B strengthen cooperation", and the grammatical error category is the omission error category, the second training text generated according to the omission error category and the first training text can be "Insurance Company of City A and Insurance Company of City B strengthen cooperation", or "Insurance Company of City A and Insurance Company of City B strengthen cooperation", etc. If the grammatical error category is the redundancy error category, the second training text generated according to the redundancy error category and the first training text can be "Insurance Company of City A and Insurance Company of City B strengthen cooperation" or "Insurance Company of City A and Insurance Company of City B strengthen cooperation". It can be seen from this that the same grammatically correct first training text can generate multiple corresponding second training texts, which assists the text correction model in learning grammatically incorrect texts and improves the text correction effect.
[0092] In step S102 of some embodiments, the text error correction loss data is the loss data of the original text error correction model in the model training process, which is used to characterize the text error correction accuracy of the original text error correction model. The original text error correction model performs error correction processing on the second training text with grammatical errors to obtain the corrected text, and performs loss calculation based on the first training text and the corrected text to obtain the text error correction loss data. It should be noted that the text error correction loss data only characterizes the error correction effect of the original text error correction model on the text character surface, and does not integrate the relationship between correct and incorrect grammar in the text and the contextual relationship in the text, so it is necessary to add grammar and contextual information to the original text error correction model to improve the training effect of the original text error correction model.
[0093] In step S103 of some embodiments, the first dependency syntax tree represents the dependency relationship between words in the first training text, that is, the grammatical relationship between words in the first training text. In this embodiment, a syntax parser is used to parse the first training text to obtain the grammatical relationship between multiple first training words and first training words, and then the first dependency syntax tree is constructed according to the grammatical relationship between the first training words and first training words. Figure 2 As shown in the figure, the first training text is "Insurance Company of City A and Insurance Company of City B strengthen cooperation", generating Figure 2 The first dependency syntax tree is shown. Therefore, the grammatical relationship between different first training words can be determined through the first dependency syntax tree.
[0094] As disclosed above, the generation of the first dependency syntax tree needs to be parsed by a syntax parser and then gradually generate the first dependency syntax tree based on the grammatical relationship between the first training words and the second training words. It can be seen that the operation of generating the dependency syntax tree is complicated, and the first training text is a grammatically correct text, and the first dependency syntax tree can be constructed. If the syntax parser is used directly to construct the syntax tree for the second training text, on the one hand, it will consume more computing resources, and on the other hand, the second training text is a grammatically incorrect text, which will affect the syntax tree construction. Therefore, the embodiment of the present application constructs the second dependency syntax tree based on the first dependency syntax tree, which not only saves computing resources for the construction of the second dependency syntax tree, but also can accurately construct the second dependency syntax tree.
[0095] See also Figure 3 In some embodiments, step S104 may include but is not limited to steps S301 to S302:
[0096] Step S301, extracting grammatical error information from the second training text according to the first training text; wherein the grammatical error information includes: grammatical error position information and grammatical error category;
[0097] Step S302: adjusting the first dependency syntax tree according to the syntax error position information and the syntax error category to obtain a second dependency syntax tree.
[0098] In step S301 of some embodiments, the second training text is generated based on the grammatically correct first training text, so the grammatical error information in the second training text can be determined by comparing the second training text with the first training text. Specifically, all grammatical error information of the second training text is extracted according to the alignment relationship between the second training text and the first training text by using an annotation tool. Among them, the annotation tool is ERRANT, and the grammatical error information includes: grammatical error position information and grammatical error category, the grammatical error position information is the character position of the grammatical error in the second training text, the grammatical error category is the category of the grammatical error in the second training text, and there is at least one grammatical error category.
[0099] In step S302 of some embodiments, the first dependency syntax tree is adjusted according to the grammatical error position information and the grammatical error category, that is, an error corresponding to the grammatical error category is set at a position corresponding to the grammatical error position information of the first dependency syntax tree to form a second dependency syntax tree representing the syntactic relationship of the second training text.
[0100] In step S301 to step S302 shown in this embodiment, the second training text is compared with the first training text to extract the grammatical error position information and grammatical error category of the second training text, and then the second dependency syntax tree is adjusted based on the grammatical error position information and the grammatical error category to form a second dependency syntax tree. Therefore, the construction of the second dependency syntax tree is adjusted on the first dependency syntax tree, without re-parsing the second training text and re-constructing the syntax tree, which not only makes the second dependency syntax tree construction operation simple, but also saves computing resources.
[0101] See also Figure 4 In some embodiments, step S302 may include but is not limited to steps S401 to S402:
[0102] Step S401, selecting a target grammatical error tag from preset candidate grammatical error tags according to the grammatical error category;
[0103] Step S402: label the first dependency syntax tree according to the syntax error position information and the target syntax error label to obtain a second dependency syntax tree.
[0104] In steps S401 to S402 of some embodiments, because the dependency syntax tree represents the grammatical relationship between training words, and the second dependency syntax tree represents the syntax tree with grammatical errors, there are words in the second dependency syntax tree that cannot represent the grammatical relationship, and it is necessary to set a target grammatical error label between the words that cannot represent the grammatical relationship. It should be noted that the target grammatical error label corresponding to the grammatical error category is first screened out from the candidate grammatical error labels, and the target grammatical error label represents the category of grammatical errors in the second training text. Then, the grammatical problem position corresponding to the first dependency syntax tree is determined according to the grammatical error position information, and the target grammatical error label is added to the first dependency syntax tree to obtain the second dependency syntax tree. Specifically, this embodiment constructs the second dependency syntax tree by projecting the first dependency syntax tree to the side source. For example, if the second training text is "A City Insurance Company and B City Insurance Company strengthen cooperation", the second dependency syntax tree is constructed as follows. Figure 5 As shown, “M” represents “omission error label”, and it can be clearly seen from the “omission error label” that the grammatical error category in the second training text is the omission error category.
[0105] As disclosed above, the present embodiment sets an original grammatical tag set, and the original grammatical tag set includes three candidate grammatical error tags, which are respectively "replacement error tag", "redundant error tag" and "omission error tag", and the "replacement error tag" represents the replacement error category, the "redundant error tag" represents the redundant error category, and the "omission error tag" represents the omission error category. It should be noted that the replacement error category includes spelling errors, etc., and the "replacement error tag" uses a single "S" tag to indicate that the target word is replaced by other words. The redundant error category is specifically characterized as some characters that should be deleted and redundant characters appear, and the "redundant error tag" is represented by a single "R" tag. The omission error category represents that some characters should be inserted, and the "omission error tag" is represented by a single "M" tag. Specifically, the position where the "redundant error tag" is inserted into the first dependency syntax tree is one position to the left of the corresponding position of the grammatical error position information, and the position where the "omission error tag" is inserted into the first dependency syntax tree is one position to the right of the corresponding position of the grammatical error position information.
[0106] In steps S401 to S402 shown in this embodiment, the grammatical error category is characterized by adopting a target grammatical error label, and the target grammatical error label is inserted into the first dependency syntax tree according to the grammatical error position information to form a second dependency syntax tree, so that the construction operation of the second dependency syntax tree is simple, which not only saves the computing resources for the second training text parsing and syntax tree construction, but also can efficiently generate the second dependency syntax tree.
[0107] See also Figure 6 In some embodiments, step S106 may include but is not limited to steps S601 to S603:
[0108] Step S601, encoding the second dependency syntax tree to obtain an adjacency matrix; wherein the adjacency matrix represents the grammatical relationship between characters in the second training text;
[0109] Step S602, encoding the second training text according to the adjacency matrix to obtain second encoded data;
[0110] Step S603, perform self-attention processing on the second encoded data to obtain a second self-attention map.
[0111] In step S601 of some embodiments, the adjacency matrix represents the grammatical relationship between characters in the second training text. By encoding the second training text using the adjacency matrix, the grammatical information between the characters can be incorporated to obtain encoding data that more accurately represents the semantic information of the text. In this embodiment, the second dependency syntax tree is first encoded to obtain the adjacency matrix, and the adjacency matrix is represented in the form of a vector.
[0112] In step S602 of some embodiments, the encoding process of the second training text is implemented by an encoder, and the second training text is encoded by the encoder and the adjacency matrix, specifically, the encoder uses a multi-head self-attention mechanism to obtain each grammatical relationship in the second training text, and encodes the second training text into second encoded data based on the grammatical relationship. Therefore, the second encoded data can accurately represent the semantic relationship in the second training text.
[0113] In step S603 of some embodiments, in order to better understand the sentence structure and grammatical relationship in the second training text, convert the second training text into actionable information, and improve the computer's deep and efficient error correction capabilities, a multi-head attention mechanism is used to perform self-attention processing on the second encoded data, and the relationship between word information, sentence structure and logic in the second encoded data is improved to obtain a second self-attention map. It should be noted that in the process of constructing the second self-attention map, a multi-head attention mechanism is used, and the information between each attention head has a complementary effect, so the constructed second self-attention map represents the deeper semantic relationship of the second training text, the structure and logic between characters.
[0114] Specifically, the second self-attention map is actually a self-attention weight map. Each map node in the second self-attention map represents a character in the second training text, and the edges between the map nodes represent the attention weight, that is, the degree of attention of one character to another character. When the multi-head attention mechanism is used to perform self-attention processing on the second encoded data, each attention head will generate a self-attention weight map. These self-attention maps capture the structure and logic information of the second training text from different angles and have a complementary effect. Therefore, the second self-attention map obtained in the end can more accurately represent the structure and logic information of the second training text.
[0115] In steps S601 to S603 shown in this embodiment, the second dependency syntax tree is first encoded into an adjacency matrix, the second training text is encoded into second encoded data according to the adjacency matrix, and then the second encoded data is self-attention processed to generate a second self-attention map, so as to construct a second self-attention map that can more accurately represent the grammatical relationship between the second training texts and the structure and logic between characters. Training the original text error correction model through the second self-attention map can enable the original text error correction model to learn the semantic relationship and contextual information in the training text, thereby improving the training effect of the original text error correction model.
[0116] It should be noted that, in step S105 of some embodiments, the method for constructing the first self-attention map is the same as the method for constructing the second self-attention map, which will not be repeated here.
[0117] See also Figure 7In some embodiments, step S601 may include but is not limited to steps S701 to S703:
[0118] Step S701, inputting the second dependency syntax tree into a preset graph convolutional neural network; wherein the graph convolutional neural network includes: a graph convolutional layer and a feedforward sublayer;
[0119] Step S702, performing convolution processing on the second dependency syntax tree through a graph convolution layer to obtain syntax convolution data;
[0120] Step S703, normalizing the grammatical convolution data through the feedforward sublayer to obtain an adjacency matrix.
[0121] In step S701 of some embodiments, this embodiment uses a graph convolutional neural network to construct an adjacency matrix, and the graph convolutional neural network is a deep learning model for graph structures. The core of the graph convolutional neural network is to aggregate the feature vector of a node with its adjacent feature vectors, and then use a linear transformation and a nonlinear activation function to update the feature vector of the node. Specifically, the graph convolutional neural network includes: multiple convolutional neural blocks, and each convolutional neural block includes: a graph convolutional layer and a feedforward sublayer, the graph convolutional layer is used for linear transformation, and the feedforward sublayer is mainly used for normalization processing, and is implemented using a nonlinear activation function.
[0122] In step S702 of some embodiments, the second dependency syntax tree is convolved by a graph convolution layer. Specifically, in the graph convolution layer, the information of dependency arcs and dependency labels in the first dependency syntax tree is introduced to generate grammatical convolution data. The dependency arc represents the words that have a grammatical relationship in the second training text, and the dependency label represents the grammatical relationship between the words in the second training text. For example, as shown in 5, the arc between "City A" and "Company" is a dependency arc, and the "subjective relationship" on the arc is a dependency label, so the grammatical convolution data can represent the grammatical relationship between different words.
[0123] Specifically, the second dependency syntax tree is convolved by the graph convolution layer to obtain the grammatical convolution data, which mainly calculates the grammatical relationship between each word in the first dependency syntax tree, as shown in formula (1):
[0124]
[0125] In the formula, Output the grammatical convolution data of the i-th word for the l-th convolutional neural block, n is the total number of convolutional neural blocks, A ij ∈ represents the probability data of the i-th word and the j-th word, which is also the initial adjacency matrix, e∈R drepresents the embedding of words and dependency labels between words, W and b are the model parameters of the graph convolution layer, and ReLU is the activation function. Vector stitching.
[0126] In step S703 of some embodiments, an activation function is set in the feedforward sublayer, and the activation function is a ReLU activation function, and the ReLU activation function can process nonlinear feature vectors, so the grammatical convolution data is normalized by the ReLU activation function in the feedforward sublayer to obtain an adjacency matrix. It should be noted that the adjacency matrix is a probability matrix, and the adjacency matrix is A ij It represents the probability that there is a dependency relationship between the word in the i-th row and the word in the j-th row, and A ij It can be determined by grammatical convolution data.
[0127] Specifically, the grammatical convolution data is normalized to obtain the adjacency matrix as shown in formula (2):
[0128] FF(h)=ReLU (W1h+b1)W2+b2 (2)
[0129] Where FF(h) = A ij , W1 and b1 are the model parameters of the first graph convolution layer, W2 and b2 are the model parameters of the second graph convolution layer, and h is the grammatical convolution data output by all graph convolution blocks.
[0130] In steps S701 to S703 shown in this embodiment, the second dependency syntax is input into a graph convolutional neural network including a graph convolutional layer and a feedforward sublayer, the second dependency syntax is convolved by the graph convolutional layer, and the grammatical convolution data after the convolution is normalized by the feedforward sublayer to obtain an adjacency matrix representing the grammatical relationship between words in the second training text, so as to facilitate the integration of grammatical relationships into subsequent text encoding.
[0131] See also Figure 8 In some embodiments, step S107 includes but is not limited to steps S801 to S804:
[0132] Step S801, calculating the contrast difference between the first self-attention map and the second self-attention map to obtain contrast difference data;
[0133] Step S802, calculating the structural difference between the first self-attention map and the second self-attention map to obtain structural difference data;
[0134] Step S803, concatenating the contrast difference data, the structure difference data and the text error correction loss data to obtain target loss data;
[0135] Step S804, adjusting the parameters of the original text error correction model according to the target loss data to obtain a target text error correction model.
[0136] In steps S801 to S802 of some embodiments, the first self-attention map is a self-attention map in the first training text corresponding to grammatical correctness, and the second self-attention map is a second training text corresponding to grammatical errors. Therefore, it is necessary to compare the similarity between the first self-attention map and the second self-attention map to measure the degree of influence of grammatical errors and grammatical correctness on the text context. Then, the original text correction model is trained according to the similarity between the first self-attention map and the second self-attention map, so that the original text correction model can learn the difference between grammatical errors and grammatical correct texts, and has stronger accuracy when correcting grammatical errors or grammatically correct texts. It should be noted that in this embodiment, the similarity between the self-attention maps corresponding to grammatical errors and grammatical correctness is measured, and the image comparison difference and structural difference are mainly used to determine. Specifically, the contrast difference between the first self-attention map and the second self-attention map is first calculated to obtain contrast difference data, and then the structural difference between the first self-attention map and the second self-attention map is calculated to obtain structural difference data, and the contrast difference data and the structural difference data are spliced into attention loss data to characterize the degree of influence of the text between correct grammar and incorrect grammar on context information.
[0137] Specifically, the contrast difference data is calculated as shown in formula (3):
[0138]
[0139] In the formula, x is the second training text, y is the first training text, σ x is the second self-attention map, σ y is the first self-attention map, and C1 is a constant.
[0140] The calculation of structural difference data is shown in formula (4):
[0141]
[0142] In the formula, σ xy is the sum of the self-attention weights of the first self-attention map and the second self-attention map, and C2 is a constant.
[0143] In step S803 of some embodiments, in order to train the original text error correction model, it is necessary to combine the contrast difference data, the structural difference data and the text error correction loss data into a joint training frame. Specifically, the contrast difference data and the structural difference data are first concatenated into attention loss data, and the concatenation of the attention loss data is obtained by using formula (5) in this embodiment:
[0144]
[0145] Where N is the number of attention heads in the multi-head attention graph mechanism, L P For attention loss data.
[0146] The attention loss data and the text error correction loss data are then spliced into target loss data, and this embodiment uses a sum value splicing method to splice the attention loss data and the text error correction loss data into target loss data, and this embodiment does not make specific restrictions on the splicing method of the attention loss data and the text error correction loss data.
[0147] Specifically, the target loss data is shown in formula (6):
[0148] L=L P +L g (6)
[0149] Where, L g is the text error correction loss data, and L is the target loss data.
[0150] In step S804 of some embodiments, the model parameters of the original text error correction model are adjusted according to the target loss data until the target loss data converges to form a target text error correction model.
[0151] In steps S801 to S804 shown in this embodiment, by adding contrast difference data and structural difference data between the first self-attention map and the second self-attention map during the training of the original text error correction model, the training of the original text error correction model can learn the contextual differences between grammatically correct and grammatically incorrect texts, and learn the grammatical relations in the text, and train a target text error correction model that can better understand the context, logic and structure in the text, so that text error correction through the target text error correction model is more accurate.
[0152] See also Fig. 9 The present application also provides a speech recognition method, which may include but is not limited to steps S901 to S903:
[0153] Step S901, obtaining target voice data;
[0154] Step S902, performing voice content recognition on the target voice data to obtain original voice content;
[0155] Step S903, performing error correction processing on the original speech content through the target text error correction model to obtain the target speech content; wherein the target text error correction model is the target text error correction model in the above-mentioned text error correction method.
[0156] It should be noted that when inputting information through traditional voice, due to the problem of colloquialism, the information input through voice may contain grammatical errors, resulting in a gap between the content recognized by voice and the user's true intention. In order to improve the accuracy of voice recognition, correct grammatical errors during voice input, and output more accurate voice content, this embodiment integrates the target text error correction model obtained through the above training into voice recognition.
[0157] In step S901 of some embodiments, the target voice data is acquired in real time by a voice acquisition device, or can be acquired by remote uploading. This embodiment does not impose any specific limitation on the method for acquiring the target voice data.
[0158] For example, in an insurance business scenario, when conducting insurance business consultation, the user can input target voice data through the insurance business software.
[0159] In step S902 of some embodiments, this embodiment uses automatic speech recognition technology to perform speech content recognition on the target speech data to obtain the original speech content.
[0160] In step S903 of some embodiments, the original speech content is subjected to text error correction processing by the target text error correction model. It should be noted that if there are grammatical errors or text errors in the original speech content, the output target speech content is the content with correct grammar and text after error correction. If there are no errors in the original speech content, the output target speech content is the same as the original speech content.
[0161] It should be noted that the training process of the target text correction model is specifically determined by referring to the above-mentioned text correction method and will not be repeated here.
[0162] For example, if the original voice content is "I want information about accident insurance", the target voice content generated after the target text error correction model corrects the original voice content is "I want to know information about accident insurance". It can be seen that by using the target text error correction model constructed by the above text error correction method to correct the voice content, the accuracy of voice recognition can be improved, and the voice content that meets the user's intention can be output, so that subsequent business services are more accurate.
[0163] In steps S901 to S903 shown in this embodiment, the accuracy of speech recognition can be improved by adding the target text error correction model with higher error correction accuracy to speech recognition.
[0164] The embodiment of the present application first obtains a grammatically correct first training text, and performs grammatical error setting on the first training text according to the grammatical error category to obtain a second training text. The first training text is parsed by a grammatical parser to obtain a grammatical relationship between the first training words and the first training words, and a grammatical tree is constructed by the grammatical parser, the first training words and the first training words to obtain a first dependency grammatical tree. Then, the first training text and the second training text are aligned to determine the grammatical error position information and grammatical error category in the second training text, and the target grammatical error label is screened from the candidate grammatical error labels according to the grammatical error category, and the target grammatical error label is adjusted to the first dependency grammatical tree according to the grammatical error position information to obtain a second dependency grammatical tree. Therefore, a grammatically correct first dependency grammatical tree is first constructed, and then a second dependency grammatical tree is constructed based on the first dependency grammatical tree, without the need to re-parse the second training text and construct the grammatical tree, making the construction operation of the second dependency grammatical tree simpler and saving computing resources. Then, the first dependency syntax tree is encoded by the graph convolutional neural network to obtain the target matrix, and the first training text is encoded by the encoder and the target matrix to obtain the first encoded data; the first encoded data is self-attended according to the multi-head attention mechanism to obtain the first self-attention map. At the same time, the second dependency syntax tree is input into the graph convolutional neural network, and the graph convolutional neural network includes: a graph convolutional layer and a feedforward sublayer, the second dependency syntax tree is convoluted by the graph convolutional layer to obtain syntax convolution data, and then the syntax convolution tree is normalized by the feedforward sublayer to obtain the adjacency matrix. The second training text is encoded by the encoder and the adjacency matrix to obtain the second encoded data, and then the second encoded data is self-attended according to the multi-head attention mechanism to obtain the second self-attention map. By constructing the self-attention maps corresponding to grammatical correctness and grammatical errors respectively, the influence of grammatical errors and error correctness on context information extraction can be clearly understood. Therefore, the contrast difference between the first self-attention map and the second self-attention map is calculated to obtain contrast difference data, and then the structural difference between the first self-attention map and the second self-attention map is calculated to obtain structural difference data, and the contrast difference data and the structural difference data are spliced into attention loss data, and finally the attention loss data and the text correction loss data are spliced into target loss data, and the original text correction model is trained according to the target loss data to obtain the target text correction model. Therefore, the training of the original text correction model can learn the context extraction difference between grammatically correct and grammatically incorrect, and learn the grammatical relationship in the text, so as to train a target text correction model that can better understand the context, logic and structure in the text, so that text correction through the target text correction model is more accurate.
[0165] See also Fig.10The present application also provides a text error correction device, which can implement the above text error correction method, and the device includes:
[0166] The text acquisition module 1001 is used to acquire a training text set; wherein the training text set includes: a grammatically correct first training text and a grammatically incorrect second training text;
[0167] The loss data acquisition module 1002 is used to acquire the loss data from the preset original text error correction model to obtain the text error correction loss data;
[0168] A first syntax tree construction module 1003, configured to construct a first dependency syntax tree according to a first training text;
[0169] A second syntax tree construction module 1004, configured to construct a second dependency syntax tree according to the first dependency syntax tree and the first training text and the second training text;
[0170] A first self-attention module 1005 is used to perform self-attention processing on the first training text according to the first dependency syntax tree to obtain a first self-attention map;
[0171] A second self-attention module 1006, configured to perform self-attention processing on the second training text according to the second dependency syntax tree to obtain a second self-attention map;
[0172] A parameter adjustment module 1007 is used to adjust the parameters of the original text error correction model according to the first self-attention map, the second self-attention map and the text error correction loss data to obtain a target text error correction model;
[0173] The error correction module 1008 is used to perform error correction processing on the target text through the target text error correction model.
[0174] The specific implementation of the text correction device is basically the same as the specific implementation of the above-mentioned text correction method, and will not be repeated here.
[0175] See also Fig.11 The present application also provides a speech recognition device that can implement the above-mentioned speech recognition method. The device includes:
[0176] The voice acquisition module 1101 is used to acquire target voice data;
[0177] The speech content recognition module 1102 is used to perform speech content recognition on the target speech data to obtain the original speech content;
[0178] The speech error correction module 1103 is used to perform error correction processing on the original speech content through a target text error correction model to obtain target speech content; wherein the target text error correction model is the target text error correction model in the above-mentioned text error correction method.
[0179] The specific implementation of the speech recognition device is substantially the same as the specific implementation of the speech recognition method described above, and will not be described in detail herein.
[0180] The embodiment of the present application also provides a computer device, the computer device includes a memory and a processor, the memory stores a computer program, and the processor implements the above-mentioned text error correction method or the above-mentioned speech recognition method when executing the computer program. The computer device can be any intelligent terminal including a tablet computer, a car computer, etc.
[0181] See also Fig.12 , Fig.12 The hardware structure of a computer device according to another embodiment is shown, and the computer device includes:
[0182] The processor 1201 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application;
[0183] The memory 1202 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 1202 can store an operating system and other applications. When the technical solution provided in the embodiments of this specification is implemented by software or firmware, the relevant program code is stored in the memory 1202, and the processor 1201 calls and executes the aforementioned text error correction method or the aforementioned speech recognition method in the embodiments of this application;
[0184] Input / output interface 1203, used to implement information input and output;
[0185] The communication interface 1204 is used to realize the communication interaction between the device and other devices. The communication can be realized through a wired manner (such as USB, network cable, etc.) or a wireless manner (such as mobile network, WI FI, Bluetooth, etc.);
[0186] A bus 1205 that transmits information between various components of the device (e.g., the processor 1201, the memory 1202, the input / output interface 1203, and the communication interface 1204);
[0187] The processor 1201 , the memory 1202 , the input / output interface 1203 and the communication interface 1204 are connected to each other in communication within the device via the bus 1205 .
[0188] An embodiment of the present application also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the aforementioned text error correction method or the aforementioned speech recognition method.
[0189] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0190] The text error correction method and device, speech recognition method, equipment and storage medium provided in the embodiment of the present application are constructed by constructing a grammatically correct first training text into a first dependency syntax tree, and then constructing a second dependency syntax tree corresponding to a grammatically incorrect second training text according to the first dependency syntax tree, the first training text and the second training text. According to the first dependency syntax tree, the first training text is self-attention processed to obtain a first self-attention map, and then the second training text is self-attention processed according to the second dependency syntax tree to obtain a second self-attention map, and the first self-attention map and the second self-attention map are used to characterize the influence of incorrect grammar and correct grammar on the self-attention processing in the text. Then, the model parameters of the original text error correction model are adjusted according to the first self-attention map, the second self-attention map and the text error correction loss data to obtain a target text error correction model that better understands the structure and grammatical rules of the sentence, so that the text error correction is performed by the target text error correction model, and the accuracy of the text error correction can be improved.
[0191] The embodiments described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0192] Those skilled in the art will appreciate that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.
[0193] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0194] Those skilled in the art will appreciate that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices may be implemented as software, firmware, hardware, or a suitable combination thereof.
[0195] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0196] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0197] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the above units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0198] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0199] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0200] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including multiple instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store programs.
[0201] The preferred embodiments of the present application are described above with reference to the accompanying drawings, but the scope of the rights of the present application is not limited thereto. Any modification, equivalent substitution and improvement made by a person skilled in the art without departing from the scope and essence of the present application should be within the scope of the rights of the present application.
Claims
1. A text error correction method, characterized in that: The method comprises: Acquire a training text set; wherein the training text set includes: a grammatically correct first training text and a grammatically incorrect second training text; Acquire loss data from a preset original text error correction model to obtain text error correction loss data; Constructing a first dependency syntax tree according to the first training text; Constructing a second dependency syntax tree according to the first dependency syntax tree, the first training text, and the second training text; Performing self-attention processing on the first training text according to the first dependency syntax tree to obtain a first self-attention map; Performing self-attention processing on the second training text according to the second dependency syntax tree to obtain a second self-attention map; Adjusting parameters of the original text error correction model according to the first self-attention map, the second self-attention map and the text error correction loss data to obtain a target text error correction model; The target text is corrected by the target text error correction model.
2. The method according to claim 1, characterized in that The step of constructing a second dependency syntax tree according to the first dependency syntax tree, the first training text, and the second training text includes: Extracting grammatical error information from the second training text according to the first training text; wherein the grammatical error information includes: grammatical error position information and grammatical error category; The first dependency syntax tree is adjusted according to the syntax error position information and the syntax error category to obtain the second dependency syntax tree.
3. The method according to claim 2, characterized in that The adjusting the first dependency syntax tree according to the syntax error position information and the syntax error category to obtain the second dependency syntax tree includes: Filtering a target grammatical error label from preset candidate grammatical error labels according to the grammatical error category; The first dependency syntax tree is labeled according to the syntax error position information and the target syntax error label to obtain the second dependency syntax tree.
4. The method according to claim 1, characterized in that: The step of performing self-attention processing on the second training text according to the second dependency syntax tree to obtain a second self-attention graph includes: Performing encoding processing on the second dependency syntax tree to obtain an adjacency matrix; wherein the adjacency matrix represents the grammatical relationship between characters in the second training text; Encoding the second training text according to the adjacency matrix to obtain second encoded data; Perform self-attention processing on the second encoded data to obtain the second self-attention map.
5. The method according to claim 4, characterized in that The encoding process is performed on the second dependency syntax tree to obtain an adjacency matrix, including: Inputting the second dependency syntax tree into a preset graph convolutional neural network; wherein the graph convolutional neural network includes: a graph convolutional layer and a feedforward sublayer; Performing convolution processing on the second dependency syntax tree through the graph convolution layer to obtain syntax convolution data; The grammatical convolution data is normalized by the feedforward sublayer to obtain the adjacency matrix.
6. The method according to any one of claims 1 to 5, characterized in that: The step of adjusting parameters of the original text error correction model according to the first self-attention map, the second self-attention map and the text error correction loss data to obtain a target text error correction model includes: Calculating the contrast difference between the first self-attention map and the second self-attention map to obtain contrast difference data; Calculating structural differences between the first self-attention map and the second self-attention map to obtain structural difference data; The contrast difference data, the structure difference data and the text error correction loss data are spliced to obtain target loss data; The parameters of the original text error correction model are adjusted according to the target loss data to obtain a target text error correction model.
7. A speech recognition method, characterized in that: The method comprises: Obtain target voice data; Performing voice content recognition on the target voice data to obtain original voice content; The original speech content is corrected by a target text error correction model to obtain target speech content; wherein the target text error correction model is the target text error correction model in the text error correction method according to any one of claims 1 to 6.
8. A text error correction device, characterized in that: The device comprises: A text acquisition module, used to acquire a training text set; wherein the training text set includes: a grammatically correct first training text and a grammatically incorrect second training text; A loss data acquisition module is used to acquire loss data from a preset original text error correction model to obtain text error correction loss data; A first syntax tree construction module, used to construct a first dependency syntax tree according to the first training text; A second syntax tree construction module, used to construct a second dependency syntax tree according to the first dependency syntax tree and the first training text and the second training text; A first self-attention module, configured to perform self-attention processing on the first training text according to the first dependency syntax tree to obtain a first self-attention map; A second self-attention module, configured to perform self-attention processing on the second training text according to the second dependency syntax tree to obtain a second self-attention map; A parameter adjustment module, configured to adjust parameters of the original text error correction model according to the first self-attention map, the second self-attention map and the text error correction loss data to obtain a target text error correction model; The error correction module is used to perform error correction processing on the target text through the target text error correction model.
9. A computer device, characterized in that: The computer device includes a memory and a processor, the memory stores a computer program, and the processor implements the text error correction method according to any one of claims 1 to 6 or the speech recognition method according to claim 7 when executing the computer program.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the text error correction method according to any one of claims 1 to 6 or the speech recognition method according to claim 7 is implemented.
Citation Information
Cited By
Video content understanding method and device based on structured grammar information, electronic equipment and storage medium
CN120976832A
Methods, devices, electronic devices, and storage media for video content understanding based on structured grammar information.
CN120976832B
