Text error correction method and device and electronic equipment
By constructing a text error correction model containing character representation extraction, pronunciation/glyph similarity capture and context correction modules, the inefficient error correction problem caused by ignoring pronunciation and shape relationships in the prior art is solved, and more accurate and context-appropriate error correction effect.
Patent Information
- Application Number
- CN202411109205.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-13
- Publication Date
- 2024-11-29
AI Technical Summary
When handling pronunciation errors and glyph similar errors, existing text error correction methods ignore the relationship between pronunciation and shape, resulting in low error correction efficiency and affect communication efficiency and business efficiency.
Build an initial text error correction model, including character representation extraction module, pronunciation/glyph similarity capture module and context correction module. Through the BERT model, graph convolution neural network and KNN algorithm, the pronunciation and glyph similarity of characters are captured and in the context Correction based on information.
Improve the accuracy of error correction, better understand user intentions, correct characters similar in pronunciation and glyphs, avoid the generation of inconsistent sentences, and choose correction results that are more inconsistent.
Smart Images

Figure CN119047460A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of fintech, and particularly to a text error correction method, device and electronic device. Background Art
[0002] In the prior art, when a customer consults an insurance service and types in a chat, speech errors and shape-similar errors may occur. For example: a homophonic error sentence: "It's very hot inside the classroom (shi1) today.", the correct character is "room (shi4)". A shape error sentence: "There is a person named Yu (yu2) on the playground.", the correct character is "thousand (qian1)". The incorrect characters reduce the communication efficiency. The insurance chatbot may not accurately understand the customer's thoughts, resulting in an inability to give the customer the desired response and affecting the business efficiency.
[0003] Ordinary language models can provide feasible corrections semantically, but face difficulties in meeting pronunciation constraints. For example, for the incorrect sentence "The replacement funds in the restaurant are suitable for dating", possible correction results of basic language models such as bert may be: "The monthly consumption in the restaurant is most suitable for dating", and the most correct correction result is: "The environment in the restaurant is very suitable for dating". Although correcting "monthly consumption most" is reasonable semantically, its pronunciation is quite different from that of "replacement funds" and "environment very".
[0004] Existing text error correction methods generally regard similar characters as potential candidates, ignoring their mutual relationships in terms of pronunciation and shape, thus resulting in low text error correction efficiency.
[0005] Therefore, the prior art still needs to be improved and developed. Summary of the Invention
[0006] In view of the above deficiencies of the prior art, the present invention provides a text error correction method, device and electronic device, aiming to solve the problem that existing text error correction methods generally regard similar characters as potential candidates, ignoring their mutual relationships in terms of pronunciation and shape, thus resulting in low text error correction efficiency.
[0007] The technical solution of the present invention is as follows:
[0008] The first embodiment of the present invention provides a text error correction method, the method comprising:
[0009] Constructing an initial text error correction model, the initial text error correction model including a character representation extraction module, a pronunciation / shape similarity capture module and a context correction module;
[0010] Obtaining an initial training sample of the initial text error correction model;
[0011] Training the initial text error correction model based on the initial training sample to obtain a target text error correction model;
[0012] Get the text to be corrected entered by the user;
[0013] The text to be corrected is input into a target text correction model, an output result of the target text correction model is obtained, and the output result is used as a target correction text.
[0014] Furthermore, the constructing of the initial text error correction model includes:
[0015] Build the character representation extraction module of the initial text error correction model based on the BERT model;
[0016] Building a pronunciation / grapheme similarity capture module for the initial text error correction model based on graph convolutional neural networks;
[0017] The context correction module of the initial text error correction model is constructed based on the KNN algorithm.
[0018] Furthermore, the obtaining of initial training samples of the initial text error correction model includes:
[0019] A sequence of samples to be corrected and a sequence of target samples after error correction are obtained from the initial training samples.
[0020] Furthermore, the initial text error correction model is trained based on the initial training sample to obtain a target text error correction model, including:
[0021] Deriving a character representation vector of each character in the to-be-corrected sample sequence based on a character representation extraction module;
[0022] Outputting the similarity of the representation vector of each character based on the pronunciation / grapheme similarity capture module;
[0023] Based on the context correction module, the output text of the graph convolutional neural network module is corrected to obtain an initial error correction sequence;
[0024] The error between the initial error correction sequence and the target sample sequence is obtained, and the parameters of the initial text error correction model are adjusted until the error between the initial error correction sequence and the target sample sequence meets a preset error condition, thereby obtaining a target text error correction model.
[0025] Furthermore, a pronunciation / grapheme similarity capture module of the initial text error correction model is constructed based on the graph convolutional neural network, including:
[0026] Constructing a graph convolution operation unit of the pronunciation / graph similarity capture module, wherein the graph convolution unit is used to absorb information of adjacent characters in the graph;
[0027] An attention graph combination operation unit of the pronunciation / grapheme similarity capture module is constructed, and the attention graph combination operation unit is used to process the similarity of a single graph.
[0028] Furthermore, the similarity of the representation vector of each character outputted based on the graph convolutional neural network module includes:
[0029] Constructing a character similarity graph corresponding to the character representation vector based on the pronunciation relationship between characters, and constructing a pronunciation similarity graph corresponding to the character representation vector based on the shape relationship between characters;
[0030] A graph convolution operation unit based on the graph convolution neural network module obtains a character similarity graph and adjacent character information in the character similarity graph;
[0031] Acquire the similarity of the character similarity graph and the single graph in the character similarity graph based on the attention graph combination operation unit of the graph convolutional neural network module;
[0032] The similarity of the representation vector of each character is output based on the adjacent character information and the similarity of the single graph.
[0033] Furthermore, the constructing of the initial text error correction model further includes:
[0034] The cross entropy loss function is pre-set as the loss function of the initial text error correction model.
[0035] Another embodiment of the present invention provides a text error correction device, the device comprising:
[0036] A model building module, used to build an initial text error correction model, wherein the initial text error correction model includes a character representation extraction module, a pronunciation / grapheme similarity capture module and a context correction module;
[0037] A sample data acquisition module is used to obtain initial training samples for an initial text error correction model;
[0038] A model training module, used for training the initial text error correction model based on the initial training sample to obtain a target text error correction model;
[0039] A user data acquisition module, used to acquire the text to be corrected input by the user;
[0040] The text output module is used to input the text to be corrected into the target text correction model, obtain the output result of the target text correction model, and use the output result as the target correction text.
[0041] Another embodiment of the present invention provides an electronic device, the electronic device comprising at least one processor; and,
[0042] a memory communicatively connected to the at least one processor; wherein,
[0043] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the above-mentioned text error correction method.
[0044] Another embodiment of the present invention further provides a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by one or more processors, the one or more processors can execute the above-mentioned text error correction method.
[0045] Beneficial effects: The text correction method of the embodiment of the present invention can accurately identify and correct characters that are similar in pronunciation and shape, thereby improving the accuracy of error correction; by capturing pronunciation and shape similarity, it can better understand the user's intention and correct these types of errors; it can correctly capture the contextual information in the text and understand the relationship between different words in a sentence, thereby correcting errors more accurately, avoiding incoherent sentences, and selecting text correction results that are more in line with the context. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] The present invention will be further described below with reference to the accompanying drawings and embodiments, in which:
[0047] Figure 1 A flowchart of a preferred embodiment of a text error correction method of the present invention;
[0048] Figure 2 A functional module diagram of a preferred embodiment of a text error correction device of the present invention;
[0049] Figure 3 The figure is a schematic diagram of the hardware structure of a preferred embodiment of an electronic device of the present invention. DETAILED DESCRIPTION
[0050] In order to make the purpose, technical solution and effect of the present invention clearer and more specific, the present invention is further described in detail below. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0051] The ordinary language model in the prior art can provide semantically feasible corrections, but faces difficulties in satisfying pronunciation constraints. The present invention proposes a text correction method that captures pronunciation / shape similarities and explores prior dependencies between characters. Specifically, two corresponding similarity graphs are constructed for pronunciation and shape relationships. The model in the present invention takes the graph as input and generates a vector representation for each character after the interaction between similar characters. These representations are then constructed into a character classifier for the semantic representation extracted from another backbone module. The character classifier uses BERT because it has powerful semantic capabilities. Combining the graph representation with BERT, the text correction model can utilize similarity knowledge and generate correct corrections accordingly, thereby better completing the text correction work.
[0052] The embodiments of the present invention are described below with reference to the accompanying drawings.
[0053] In view of the above problems, the present invention provides a text error correction method. Figure 1 , Figure 1 Flow chart of a preferred embodiment of a text error correction method of the present invention. Figure 1 As shown, it includes:
[0054] Step S100, constructing an initial text error correction model, wherein the initial text error correction model includes a character representation extraction module, a pronunciation / grapheme similarity capture module, and a context correction module;
[0055] Step S200, obtaining an initial training sample of an initial text error correction model;
[0056] Step S300: training the initial text error correction model based on the initial training sample to obtain a target text error correction model;
[0057] Step S400, obtaining the text to be corrected input by the user;
[0058] Step S500: input the text to be corrected into a target text correction model, obtain an output result of the target text correction model, and use the output result as a target correction text.
[0059] In specific implementation, the text error correction method of the embodiment of the present invention is mainly used for text error correction of the consulting service content of the customer.
[0060] The embodiment of the present invention pre-constructs an initial text error correction model, which mainly updates the representation by aggregating information between similar characters. The initial text error correction model is used to capture the pronunciation and glyph similarity of characters in the text, and obtain context similarity, thereby improving the text error correction model's understanding and processing capabilities of the context. The initial text error correction model includes a character representation extraction module for deriving a representation vector for each character, a pronunciation / glyph similarity capture module for capturing the pronunciation / similarity of characters, and a context correction module for obtaining character context similarity. Among them, the character representation extraction module generally refers to a tool or software that can recognize, analyze and extract characters (including letters, numbers, special symbols, etc.) in a text. Such tools are widely used in many fields, such as text processing, data analysis, natural language processing, etc.
[0061] The character representation extraction module mainly uses specific algorithms and techniques to analyze the input text, identify the character elements therein, and extract, convert or process them according to needs. Its functions may include but are not limited to: Character recognition: It can accurately identify characters in the text, including characters of various fonts, sizes and styles. Special symbol extraction: Identify and extract special symbols in the text. These special symbols may have specific meanings or uses. Encoding conversion: Support conversion between different character encodings to ensure the correct display of characters on different systems or platforms. Format processing: Format the extracted characters, such as removing redundant spaces, adjusting the order of characters, etc.
[0062] The extraction methods of the character representation extraction module include: Rule-based extraction: Identify character elements in the text by defining a series of rules. This method is simple and intuitive, but may not be able to handle complex text situations. Statistics-based extraction: Analyze the text using statistical principles to identify character elements with significant features. This method is more flexible and can adapt to different types of text. Machine learning-based extraction: Use machine learning algorithms to train and learn text to automatically identify and extract character elements. This method has high accuracy and generalization ability, but requires a large amount of training data and computing resources.
[0063] Based on the existing open source datasets, initial training samples for the initial text error correction model are obtained. The initial training samples include a dataset containing erroneous characters and a marked target dataset. The dataset containing erroneous characters includes but is not limited to a pronunciation similarity dataset, a glyph similarity dataset, and a context similarity dataset.
[0064] The initial text error correction model is trained based on the initial training samples, and the initial text error correction model is trained according to the preset model parameters. After the training is completed, the target text error correction model is obtained.
[0065] Detecting the user's consultation instruction, obtaining the consultation content input by the user, and converting the consultation content into a text to be corrected in character form;
[0066] The text to be corrected is input into the target text correction model, and the output of the target text correction model is obtained. The output content is the target correction text after the correction is completed.
[0067] The embodiments of the present invention can effectively combine the phonetic and glyph similarity information between characters, which brings advantages to the model in correcting easily confused characters. It can more accurately identify and correct characters that are similar in phonetics and glyphs, thereby improving the accuracy of error correction. By capturing pronunciation and shape similarity, the model can better understand the customer's intentions and correct these types of errors. It can correctly capture contextual information in the text and understand the relationship between different words in a sentence, so as to more accurately correct errors, avoid producing incoherent sentences, and select corrections that are more in line with the context.
[0068] In one embodiment, constructing an initial text error correction model includes:
[0069] Build the character representation extraction module of the initial text error correction model based on the BERT model;
[0070] Building a pronunciation / grapheme similarity capture module for the initial text error correction model based on graph convolutional neural networks;
[0071] The context correction module of the initial text error correction model is constructed based on the KNN algorithm.
[0072] In specific implementation, the character representation extraction module of the initial text error correction model is built based on the BERT model, and the character representation extraction module is used to derive the representation vector of each character. Among them, the BERT model BERT is a language representation model, and BERT stands for Bidirectional Encoder Representations from Transformers. BERT aims to pre-train deep bidirectional representations by jointly adjusting the left and right contexts in all layers. Therefore, only one additional output layer is needed to fine-tune the pre-trained BERT representation to create state-of-the-art models for a wide range of tasks (such as question answering and language inference tasks) without making a lot of task-specific modifications to the model structure. The model structure of ERT is a multi-layer bidirectional Transformer encoder.
[0073] On top of the character representation extraction module, the GCN graph convolutional network module is used to model the interdependencies between characters. It outputs a target vector containing information about similar characters after interaction. The Graph Convolutional Network (GCN) is a deep learning model based on a graph structure. It aggregates neighbor information of nodes in the graph through convolution operations, thereby learning the representation of nodes or the entire graph.
[0074] Graph convolutional network is a neural network specially designed for processing graph structured data. It can capture the complex relationships between nodes and the deep structural features of the graph, and aggregate and update node information through convolution operations. Processing non-Euclidean space data: Unlike traditional convolutional neural networks (CNNs), GCN processes graph data, where the connection relationships between nodes are irregular and the number of nodes may vary. Neighbor aggregation mechanism: GCN updates the representation of each node through neighbor aggregation or message passing mechanism, which allows the model to learn the dependencies between nodes.
[0075] The working principle of GCN mainly includes the following steps: Adjacency representation: The adjacency matrix of the graph is used to represent the connection relationship between the nodes in the graph. The adjacency matrix is a square matrix whose elements represent the connection status between nodes. Feature aggregation: For a given node, GCN aggregates the features of its neighboring nodes (including its own features), usually through weighted averaging. This step is the core of GCN, which allows the model to capture the local dependencies between nodes. Non-linear transformation: The aggregated features are then passed through a non-linear transformation (such as the ReLU function), and may be passed through multiple layers of such transformations to learn deeper node representations. The introduction of non-linear transformations enables GCN to learn and simulate complex function mappings.
[0076] GCN has achieved remarkable results in graph classification, graph embedding, social network analysis, knowledge graphs, and other fields. Specifically, it can be applied to: Node classification: predicting the label of a single node in a graph, such as user interest classification in a social network. Graph classification: predicting the category or attribute of the entire graph, such as the classification of chemical molecules. Link prediction: predicting whether there is a connection relationship between nodes in a graph, such as friend recommendation in a recommendation system.
[0077] With the deepening of research and the development of technology, GCN and its variants have been expanded and optimized in many aspects: Spatiotemporal Graph Convolutional Network (ST-GCN): Extend the graph convolutional network to the spatiotemporal domain to process graph structured data with a time dimension, such as skeleton-based behavior recognition. Computational efficiency optimization: Study how to optimize the computational efficiency of graph convolutional networks to adapt to large-scale graph data. Model fusion: Fusion of graph convolutional networks with other deep learning models (such as Transformer, Autoencoder, etc.) to improve the expressiveness of the model.
[0078] Two similarity graphs are required in the GCN module to represent pronunciation A p and shape A s The similarities are derived from the open source obfuscation set. For simplicity, superscripts will be omitted if not necessary, and A represents one of the two similarity graphs. Each similarity graph is of size R NxN The binary adjacency matrix is constructed from the N characters in the confusion set. The edge A between the i-th character and the j-th character i,j ∈{0,1} indicates whether the (i,j) pair exists in the similar pairs of the confusion set. The goal of the error correction module is to learn a mapping function that embeds the input node of the lth layer into H through the convolution operation defined by a. l ∈R NxD (where D is the dimension of the character embedding) is mapped to a new representation H l+1 .
[0079] There are many overlaps between each pair of input and output text in CSC, because only a few tokens are incorrect. CSC Chinese spelling correction is a technical field involving natural language processing and text analysis, which aims to automatically detect and correct spelling errors in Chinese text. Due to the complexity and diversity of Chinese, the spelling correction task faces many challenges, including homophones, polyphones, similar characters, and errors caused by input methods.
[0080] In order to effectively perform Chinese spelling correction, a variety of techniques and methods can be used. The following are some commonly used methods:
[0081] Rule-based approach: Utilizes a predefined rule base to identify and correct errors. For example, rules can be developed to handle common typos or homophone substitutions.
[0082] Statistical-based methods: Use a large corpus to train a statistical model, which learns the correct word combinations and contextual relationships to identify and correct errors.
[0083] Hybrid methods: Combine the advantages of rule-based and statistical methods to improve the accuracy and robustness of error correction systems.
[0084] Deep learning methods: Use neural network models, such as recurrent neural networks (RNNs), long short-term memory networks (LSTMs), or Transformers, to learn complex patterns and relationships in texts, thereby achieving high-precision spelling correction.
[0085] Ensemble learning method: Use multiple different models for error correction and combine the outputs of each model through voting or weighted averaging to improve the overall performance.
[0086] Context-aware error correction: Consider the overall context of the text to correct errors, not just based on individual words or local context.
[0087] User feedback and adaptive learning: Leverage user feedback to continuously optimize and update the error correction system so that it can adapt to new error patterns and language changes.
[0088] In practical applications, Chinese spelling correction technology can be widely used in text editing, search engines, input methods, social media, online education and other fields, providing users with a more accurate and convenient text processing experience. With the continuous development of natural language processing technology, the performance and effect of Chinese spelling correction will continue to improve.
[0089] Therefore, in the KNN algorithm, n-grams around the target token can be stored as values for building a data store for further filtering and reordering, instead of traditionally storing only the token itself. Combining the above two ideas, the n-grams of the target token are retrieved through the general information of the target token. The structure of the data store is a dictionary, in which each element consists of a pair of (key, value). The key is used to perform nearest neighbor retrieval and obtain the value containing the required information. Among them, KNN (K-Nearest Neighbors) retrieval is an instance-based learning, or lazy learning, which does not construct a generalized model from the training set, but directly uses the instance points in the database for prediction. In KNN retrieval, the output is a set of category memberships, and an object is classified into a category determined by the "votes" of its neighbors.
[0090] The core idea of the KNN algorithm is: if most of the k most similar samples (i.e. the closest ones in the feature space) of a sample belong to a certain category, then the sample also belongs to this category. The general process of the KNN retrieval algorithm is as follows: Calculate the distance between the test data and each training data. Sort them in increasing order of distance. Select the k points with the smallest distance. Determine the frequency of occurrence of the category of the first k points. Return the category with the highest frequency among the first k points as the predicted classification of the test data.
[0091] When choosing a distance metric, KNN usually uses the Euclidean distance, but other distance metrics can also be selected according to the characteristics of the data. In addition, the choice of K value will have a significant impact on the results of the KNN algorithm. If a smaller K value is selected, it is equivalent to using training instances in a smaller neighborhood for prediction. The approximate error of learning will be reduced, but the estimation error will increase, and the prediction result will be very sensitive to the instance points of the neighbors; if a larger K value is selected, the estimation error of learning can be reduced, but the approximate error will increase. In practical applications, the K value is generally selected as a relatively small value, and cross-validation is usually used to select the optimal K value. In general, KNN retrieval is a simple but powerful classification and regression method, especially suitable for problems where the distance or similarity between data points is easy to calculate.
[0092] N-Gram, also known as N-tuple or N-itemset, is an important concept in the field of natural language processing (NLP). It refers to a sequence of N items that appear consecutively in a text. These items can be letters, syllables, words, or other meaningful text units. The N-Gram model is widely used in a variety of NLP tasks, such as text analysis, speech recognition, spelling check, language modeling, and machine translation.
[0093] N-Gram consists of N consecutive text units. For example, in the word-level 2-Gram (i.e., Bigram) model, both "natural language" and "language processing" are valid Bigrams. Text units can be letters, words, syllables, or other text fragments, depending on the application scenario and the required analysis granularity.
[0094] The application scenarios are as follows: Language modeling: N-Gram models are often used to build language models to predict the next word or character that may appear in a text. Text analysis: By analyzing the N-Gram distribution in a text, the features of the text can be extracted and then used for tasks such as text classification and sentiment analysis. Spelling check: N-Gram models can be used to identify spelling errors in text and provide correction suggestions. Machine translation: In machine translation tasks, N-Gram models help analyze the correspondence between the source language and the target language.
[0095] The N-Gram model is simple to understand, easy to implement, and performs well in a variety of NLP tasks.
[0096] However, as N increases, the number of parameters that the N-Gram model needs to process grows exponentially, which may lead to inefficient computation and excessive memory usage. In addition, the N-Gram model cannot capture long-range dependencies in text.
[0097] In one embodiment, obtaining an initial training sample of an initial text error correction model includes:
[0098] A sequence of samples to be corrected and a sequence of target samples after error correction are obtained from the initial training samples.
[0099] In the specific implementation, the initial training samples in the open source data set are obtained. The initial training samples include a sequence of samples to be corrected and a sequence of labeled target samples. Training samples are an important concept in machine learning. They refer to data sets used to train machine learning models. These data sets contain input variables (also called features) and corresponding output variables (also called labels or target variables). Through training samples, machine learning models can learn the relationship between input variables and output variables, and then predict or classify new, unseen data.
[0100] The selection and quality of training samples have a crucial impact on the performance of machine learning models. A high-quality training sample set should be representative and cover various situations that the model may encounter in practical applications. At the same time, the number of training samples is also an important consideration. Generally speaking, more training samples can help the model learn more information, thereby improving the accuracy and generalization ability of the model.
[0101] In one embodiment, the initial text error correction model is trained based on the initial training sample to obtain a target text error correction model, including:
[0102] Deriving a character representation vector of each character in the to-be-corrected sample sequence based on a character representation extraction module;
[0103] Outputting the similarity of the representation vector of each character based on the pronunciation / grapheme similarity capture module;
[0104] Based on the context correction module, the output text of the graph convolutional neural network module is corrected to obtain an initial error correction sequence;
[0105] The error between the initial error correction sequence and the target sample sequence is obtained, and the parameters of the initial text error correction model are adjusted until the error between the initial error correction sequence and the target sample sequence meets a preset error condition, thereby obtaining a target text error correction model.
[0106] In the specific implementation, the sample sequence to be corrected is input into the BERT model, the output result of the BERT model is obtained, and the character representation vector of each character in the sample sequence to be corrected is obtained according to the output result;
[0107] Based on the character representation vector of each character, the corresponding pronunciation and glyph graphic data are constructed, and the pronunciation and glyph graphic data are input into the graph convolutional neural network to obtain the output result of the graph convolutional neural network. The graph convolutional neural network captures the pronunciation / glyph similarity between characters, outputs the capture result, and obtains the initial error correction sequence according to the capture result;
[0108] The similar context of the wrong word is more valuable than the similarity of the pronunciation, meaning, and shape of the character. Therefore, using context similarity to assist in spelling correction is expected to improve the error correction performance of the model and the guiding significance for future work. Solving this problem requires a better model that integrates context similarity to improve the model's understanding and processing capabilities of the context. Therefore, in an embodiment of the present invention, the character representation vector of each character in the initial error correction sequence is context-corrected based on the KNN nearest neighbor algorithm to obtain a corrected target sample sequence.
[0109] The training process of the initial text model is an iterative process, which aims to optimize the performance of the model by adjusting the parameters (mainly weights and biases) in the network so that it can better fit the training data and achieve specific tasks. In the embodiment of the present invention, the error between the initial error correction sequence and the target sample sequence is obtained, and the parameters of the initial text error correction model are adjusted until the error between the initial error correction sequence and the target sample sequence meets the preset error condition, thereby obtaining the target text error correction model.
[0110] In one embodiment, a pronunciation / grapheme similarity capture module of an initial text error correction model is constructed based on a graph convolutional neural network, including:
[0111] Constructing a graph convolution operation unit of the pronunciation / graph similarity capture module, wherein the graph convolution unit is used to absorb information of adjacent characters in the graph;
[0112] An attention graph combination operation unit of the pronunciation / grapheme similarity capture module is constructed, and the attention graph combination operation unit is used to process the similarity of a single graph.
[0113] In practice, the mapping function has two main subcomponents: graph convolution operation and attention map combination operation.
[0114] Graph convolution operation: Graph convolution operation absorbs the information of adjacent characters in the graph. In each layer, a lightweight convolution layer in GCN is used, as shown in Formula 1:
[0115]
[0116] In formula 1 is a trainable matrix, is the normalized version of the adjacency matrix A. Note that we use BERT’s character embedding as the initial node feature H0 and omit the nonlinear function after the convolution. Since BERT is used as the extractor, it has its own learned semantic space, and the activation function is removed from the equation to keep the derived representation the same as the original space, rather than a completely different space.
[0117] Attention Graph Combination Operation: Graph convolution operation processes the similarity of a single graph. In order to combine pronunciation and shape similarity graphs, an attention mechanism is used. For each character, the representation combination operation is calculated as:
[0118]
[0119] C in Formula 2 l ∈R NxD and f k (A k , H l ) i is the i-th row of the convolutional representation of graph k, α i,k is a scalar representing the weight of the i-th character of graph k. i,k The calculation formula is
[0120]
[0121] w in formula 3 a ∈R D is a learnable vector shared across layers, and β is a hyperparameter that controls the smoothness of the attention weight. It is found that β is crucial to the attention mechanism. After the combined operation of graph convolution and attention, the representation C of the lth layer is obtained. l To keep the original semantics of the extractor, all outputs of the previous layers are accumulated as the output:
[0122]
[0123] In this way, the error correction model can focus on capturing knowledge about character similarities, leaving the responsibility of semantic reasoning to the extractor.
[0124] In one embodiment, the similarity of the representation vector of each character outputted based on the graph convolutional neural network module includes:
[0125] Constructing a character similarity graph corresponding to the character representation vector based on the pronunciation relationship between characters, and constructing a pronunciation similarity graph corresponding to the character representation vector based on the shape relationship between characters;
[0126] A graph convolution operation unit based on the graph convolution neural network module obtains a character similarity graph and adjacent character information in the character similarity graph;
[0127] Acquire the similarity of the character similarity graph and the single graph in the character similarity graph based on the attention graph combination operation unit of the graph convolutional neural network module;
[0128] The similarity of the representation vector of each character is output based on the adjacent character information and the similarity of the single graph.
[0129] In a specific implementation, the text to be corrected input by the user is obtained, and a character representation extraction operation is performed on the text to be corrected to obtain a character representation vector corresponding to each character;
[0130] Constructing a character similarity graph corresponding to the character representation vector based on the pronunciation relationship between characters, and constructing a pronunciation similarity graph corresponding to the character representation vector based on the shape relationship between characters;
[0131] The character similarity graph and the pronunciation similarity graph are input into a graph convolutional neural network to obtain an initial error correction text output by the graph convolutional neural network; thereby obtaining the similarity of the representation vector of each character based on the similarity of the adjacent character information and the single graph.
[0132] In one embodiment, constructing an initial text error correction model further includes:
[0133] The cross entropy loss function is pre-set as the loss function of the initial text error correction model.
[0134] In specific implementation, the cross entropy loss function is used as the loss function L of the error correction model. c Given a training sample (X,Y), where X is a character sequence, Y is the correction sequence of X, and p is the output distribution. The correction loss of the i-th token is defined as:
[0135]
[0136] Compared with the prior art, the text error correction method of the embodiment of the present invention makes a preliminary attempt to better learn the phonetic and glyphic information of the wrong characters, and tries to merge the symbol space (speech and visual similarity knowledge) and the semantic space (language semantic knowledge) into one model. To achieve this, the power of the graph convolutional network (GCN) is used to directly inject similarity knowledge, and the KNN retrieval is used to utilize the context similarity information. The basic idea is to update the representation by aggregating the information between similar characters.
[0137] The embodiments of the present invention can effectively combine the phonetic and glyph similarity information between characters, which brings advantages to the model in correcting easily confused characters. It can more accurately identify and correct characters that are similar in phonetics and glyphs, thereby improving the accuracy of error correction. By capturing pronunciation and shape similarity, the model can better understand the customer's intention and correct these types of errors.
[0138] The embodiments of the present invention can correctly capture the contextual information in the text and understand the relationship between different words in a sentence, so as to more accurately correct errors, avoid producing incoherent sentences, and select corrections that are more in line with the context.
[0139] It should be noted that there is not necessarily a certain order between the above-mentioned steps. A person skilled in the art can understand, based on the description of the embodiments of the present invention, that in different embodiments, the above-mentioned steps may have different execution orders, that is, they may be executed in parallel, may be executed interchangeably, and so on.
[0140] Another embodiment of the present invention provides a text error correction device, such as Figure 2 As shown, the device 1 comprises:
[0141] A model building module 11, used to build an initial text error correction model, wherein the initial text error correction model includes a character representation extraction module, a pronunciation / grapheme similarity capture module and a context correction module;
[0142] A sample data acquisition module 12 is used to acquire initial training samples of an initial text error correction model;
[0143] A model training module 13 is used to train the initial text error correction model based on the initial training sample to obtain a target text error correction model;
[0144] The user data acquisition module 14 is used to acquire the text to be corrected input by the user;
[0145] The text output module 15 is used to input the text to be corrected into the target text correction model, obtain the output result of the target text correction model, and use the output result as the target correction text.
[0146] The specific implementation method is shown in the method embodiment, which will not be described here in detail.
[0147] In one embodiment, the model building module 11 is specifically used for:
[0148] Build the character representation extraction module of the initial text error correction model based on the BERT model;
[0149] Building a pronunciation / grapheme similarity capture module for the initial text error correction model based on graph convolutional neural networks;
[0150] The context correction module of the initial text error correction model is constructed based on the KNN algorithm.
[0151] The specific implementation method is shown in the method embodiment, which will not be described here in detail.
[0152] In one embodiment, the sample data acquisition module 12 is specifically used for:
[0153] A sequence of samples to be corrected and a sequence of target samples after error correction are obtained from the initial training samples.
[0154] The specific implementation method is shown in the method embodiment, which will not be described here in detail.
[0155] In one embodiment, the model training module 13 is specifically used for:
[0156] Deriving a character representation vector of each character in the to-be-corrected sample sequence based on a character representation extraction module;
[0157] Outputting the similarity of the representation vector of each character based on the pronunciation / grapheme similarity capture module;
[0158] Based on the context correction module, the output text of the graph convolutional neural network module is corrected to obtain an initial error correction sequence;
[0159] The error between the initial error correction sequence and the target sample sequence is obtained, and the parameters of the initial text error correction model are adjusted until the error between the initial error correction sequence and the target sample sequence meets a preset error condition, thereby obtaining a target text error correction model.
[0160] The specific implementation method is shown in the method embodiment, which will not be described here in detail.
[0161] In one embodiment, the model building module 11 is further used to:
[0162] Constructing a graph convolution operation unit of the pronunciation / graph similarity capture module, wherein the graph convolution unit is used to absorb information of adjacent characters in the graph;
[0163] An attention graph combination operation unit of the pronunciation / grapheme similarity capture module is constructed, and the attention graph combination operation unit is used to process the similarity of a single graph.
[0164] The specific implementation method is shown in the method embodiment, which will not be described here in detail.
[0165] In one embodiment, the model training module 13 is also used to:
[0166] Constructing a character similarity graph corresponding to the character representation vector based on the pronunciation relationship between characters, and constructing a pronunciation similarity graph corresponding to the character representation vector based on the shape relationship between characters;
[0167] A graph convolution operation unit based on the graph convolution neural network module obtains a character similarity graph and adjacent character information in the character similarity graph;
[0168] Acquire the similarity of the character similarity graph and the single graph in the character similarity graph based on the attention graph combination operation unit of the graph convolutional neural network module;
[0169] The similarity of the representation vector of each character is output based on the adjacent character information and the similarity of the single graph.
[0170] The specific implementation method is shown in the method embodiment, which will not be described here in detail.
[0171] In one embodiment, the model building module 11 is further used to:
[0172] The cross entropy loss function is pre-set as the loss function of the initial text error correction model.
[0173] The specific implementation method is shown in the method embodiment, which will not be described here in detail.
[0174] Another embodiment of the present invention provides an electronic device, such as Figure 3 As shown, the electronic device 10 includes:
[0175] One or more processors 110 and memory 120, Figure 3 A processor 110 is used as an example for description. The processor 110 and the memory 120 may be connected via a bus or other means. Figure 3 The example of connecting through bus is taken in the following.
[0176] The processor 110 is used to complete various control logics of the electronic device 10, and it can be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA), a single-chip microcomputer, an ARM (Acorn RISCMachine) or other programmable logic device, a discrete gate or transistor logic, a discrete hardware control, or any combination of these components. In addition, the processor 110 can also be any traditional processor, microprocessor or state machine. The processor 110 can also be implemented as a combination of computing devices, for example, a combination of a DSP and a microprocessor, a plurality of microprocessors, one or more microprocessors combined with a DSP core, or any other such configuration.
[0177] The memory 120 is a non-volatile computer-readable storage medium that can be used to store non-volatile software programs, non-volatile computer executable programs and modules, such as program instructions corresponding to the text error correction method in the embodiment of the present invention. The processor 110 executes various functional applications and data processing of the device 10 by running the non-volatile software programs, instructions and units stored in the memory 120, that is, implementing the text error correction method in the above method embodiment.
[0178] The memory 120 may include a program storage area and a data storage area, wherein the program storage area may store applications required for operating the device and at least one function; the data storage area may store data created according to the use of the device 10, etc. In addition, the memory 120 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 non-volatile solid-state storage device. In some embodiments, the memory 120 may optionally include a memory remotely arranged relative to the processor 110, and these remote memories may be connected to the device 10 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.
[0179] One or more units are stored in the memory 120, and when executed by one or more processors 110, the text error correction method in any of the above method embodiments is executed, for example, the above described text error correction method is executed. Figure 1 The method comprises steps S100 to S500.
[0180] An embodiment of the present invention provides a non-volatile computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are executed by one or more processors, for example, to execute the above-described Figure 1 The method comprises steps S100 to S500.
[0181] As an example, non-volatile storage media can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) as external cache memory. By way of illustration and not limitation, RAM can be obtained in many forms such as synchronous RAM (SRAM), dynamic RAM, (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), Synchlink DRAM (SLDRAM), and direct Rambus RAM (DRRAM). The disclosed memory controls or memories of the operating environment described herein are intended to include one or more of these and / or any other suitable types of memory.
[0182] Another embodiment of the present invention provides a computer program product, the computer program product includes a computer program stored on a non-volatile computer-readable storage medium, the computer program includes program instructions, when the program instructions are executed by a processor, the processor executes the text error correction method of the above method embodiment. For example, executing the above described Figure 1The method comprises steps S100 to S500.
[0183] The embodiments described above are merely illustrative, in which the units described 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 modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0184] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a general hardware platform, and of course can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product can exist in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods of each embodiment or some parts of the embodiment.
[0185] Conditional language such as "can," "can," "might," or "may," among other things, unless specifically stated otherwise or otherwise understood within the context as used, is generally intended to convey that particular embodiments can include (while other embodiments do not) particular features, elements, and / or operations. Thus, such conditional language is also generally intended to imply that features, elements, and / or operations are anyway required for one or more embodiments or that one or more embodiments must include logic for determining, with or without input or prompting, whether such features, elements, and / or operations are included or will be performed in any particular embodiment.
[0186] What has been described herein in this specification and the accompanying drawings includes examples that can provide text error correction methods and devices. Of course, it is not possible to describe every conceivable combination of elements and / or methods for the purpose of describing the various features of the present disclosure, but it can be recognized that many other combinations and permutations of the disclosed features are possible. Therefore, it is obvious that various modifications can be made to the present disclosure without departing from the scope or spirit of the present disclosure. In addition, or in an alternative, other embodiments of the present disclosure may be apparent from consideration of this specification and the accompanying drawings and from the practice of the present disclosure as presented herein. It is intended that the examples set forth in this specification and the accompanying drawings are considered to be illustrative and not restrictive in all respects. Although specific terms are employed herein, they are used in a general and descriptive sense and are not used for limiting purposes.
Claims
1. A text error correction method, characterized in that , the method comprises: Constructing an initial text error correction model, wherein the initial text error correction model includes a character representation extraction module, a pronunciation / grapheme similarity capture module, and a context correction module; Obtaining initial training samples for an initial text error correction model; Training the initial text error correction model based on the initial training sample to obtain a target text error correction model; Get the text to be corrected entered by the user; The text to be corrected is input into a target text correction model, an output result of the target text correction model is obtained, and the output result is used as a target correction text.
2. The method according to claim 1, characterized in that: The constructing of the initial text error correction model comprises: Build the character representation extraction module of the initial text error correction model based on the BERT model; A pronunciation / grapheme similarity capture module is built based on a graph convolutional neural network to construct the initial text error correction model; The context correction module of the initial text error correction model is constructed based on the KNN algorithm.
3. The method according to claim 2, characterized in that The step of obtaining an initial training sample of an initial text error correction model includes: A sequence of samples to be corrected and a sequence of target samples after error correction are obtained from the initial training samples.
4. The method according to claim 3, characterized in that The step of training the initial text error correction model based on the initial training sample to obtain a target text error correction model includes: Deriving a character representation vector of each character in the to-be-corrected sample sequence based on a character representation extraction module; Outputting the similarity of the representation vector of each character based on the pronunciation / grapheme similarity capture module; Based on the context correction module, the output text of the graph convolutional neural network module is corrected to obtain an initial error correction sequence; The error between the initial error correction sequence and the target sample sequence is obtained, and the parameters of the initial text error correction model are adjusted until the error between the initial error correction sequence and the target sample sequence meets a preset error condition, thereby obtaining a target text error correction model.
5. The method according to claim 4, characterized in that The pronunciation / grapheme similarity capture module for constructing an initial text error correction model based on a graph convolutional neural network includes: Constructing a graph convolution operation unit of the pronunciation / graph similarity capture module, wherein the graph convolution unit is used to absorb information of adjacent characters in the graph; An attention graph combination operation unit of the pronunciation / grapheme similarity capture module is constructed, and the attention graph combination operation unit is used to process the similarity of a single graph.
6. The method according to claim 5, characterized in that The similarity of the representation vector of each character outputted by the graph convolutional neural network module includes: Constructing a character similarity graph corresponding to the character representation vector based on the pronunciation relationship between characters, and constructing a pronunciation similarity graph corresponding to the character representation vector based on the shape relationship between characters; A graph convolution operation unit based on the graph convolution neural network module obtains a character similarity graph and adjacent character information in the character similarity graph; Acquire the similarity of the character similarity graph and the single graph in the character similarity graph based on the attention graph combination operation unit of the graph convolutional neural network module; The similarity of the representation vector of each character is output based on the adjacent character information and the similarity of the single graph.
7. The method according to claim 6, characterized in that The constructing of the initial text error correction model further includes: The cross entropy loss function is pre-set as the loss function of the initial text error correction model.
8. A text error correction device, characterized in that: The device comprises: A model building module, used to build an initial text error correction model, wherein the initial text error correction model includes a character representation extraction module, a pronunciation / grapheme similarity capture module and a context correction module; A sample data acquisition module is used to obtain initial training samples for an initial text error correction model; A model training module, used for training the initial text error correction model based on the initial training sample to obtain a target text error correction model; A user data acquisition module, used to acquire the text to be corrected input by the user; The text output module is used to input the text to be corrected into the target text correction model, obtain the output result of the target text correction model, and use the output result as the target correction text.
9. An electronic device, characterized in that: The electronic device comprises at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the text error correction method according to any one of claims 1 to 7.
10. A non-volatile computer-readable storage medium, characterized in that: The non-volatile computer-readable storage medium stores computer-executable instructions, which, when executed by one or more processors, enable the one or more processors to execute the text error correction method described in any one of claims 1-7.
Citation Information
Cited By
Text error correction method and device, electronic equipment and storage medium
CN120336535A
