Language model Chinese spelling checking method and system based on retrieval enhancement generation
Through retrieval enhancement generation and few-sample prompting technology, combined with iterative discrimination strategies, the problem of performance degradation and output control of large language models in Chinese spelling check has been solved, and the accuracy and stability of error correction have been significantly improved.
Patent Information
- Application Number
- CN202410832719.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-26
- Publication Date
- 2024-09-03
AI Technical Summary
When large language models lack relevant task information and data, Chinese spelling check performance declines, and the output length is difficult to control, making it prone to excessive or incomplete error correction.
The retrieval-augmented generation (RAG) strategy is adopted to obtain external knowledge from the vector database as auxiliary examples for model execution tasks, and the model output length and the accuracy of error correction results are controlled through few-sample prompts and iterative discrimination strategies.
It improves the performance and effect of large-scale language models in Chinese spelling check tasks, enhances the accuracy and stability of error correction, reduces excessive error correction and incomplete error correction, and adapts to the performance of different data sets.
Smart Images

Figure CN118586384A
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of natural language processing, and in particular relates to a Chinese spelling check large language model error correction method and system based on retrieval-enhanced generation. Background Art
[0002] Chinese spelling check (CSC) is a key task in natural language processing (NLP). Its purpose is to detect and correct spelling errors in sentences. Spelling errors are divided into pronunciation similarity errors, glyph similarity errors, and other errors according to their sources. Chinese spelling check plays an important auxiliary role in downstream NLP tasks such as named entity recognition, optical character recognition, speech recognition, and machine translation. In recent years, with the development of machine learning, especially deep learning, the technology of CSC has also undergone iterations and progress. The current mainstream solution is mostly a large pre-trained model improved by combining sentence features. This method has the problem of weak generalization. The model performs well on specific data sets, but the error correction performance declines seriously when facing unfamiliar data sets. Some researchers believe that the model learns general grammatical knowledge during pre-training, and the model learns a large number of character mappings when fine-tuning on the Chinese spelling check dataset, and the latter will damage the learning results of the former. Therefore, based on the strong generalization characteristics of large language models (LLMs), after referring to previous technical achievements, this project designed a new set of Chinese spelling check implementation methods.
[0003] 1.Chinese Spelling Correction as Rephrasing Language Model
[0004] The main content of this article is: Chinese spelling check (CSC), which aims to detect and correct potential spelling errors in a given sentence. The current state-of-the-art method treats Chinese spelling check as a sequence labeling task, using a model with a BERT architecture to perform full-sample fine-tuning on the training set. However, the researchers noticed that there is a serious flaw in the process of labeling one character to another, that is, excessive focus on character errors and ignoring the overall semantics of the sentence, which is contrary to the way humans think. Generally speaking, humans will first understand the original sentence they see in their minds, organize it into a familiar form, and then restate it into a complete sentence, rather than simply matching the previously remembered error pattern in their minds. Deep learning models will remember a large number of character mappings from incorrect characters to correct characters. This counterintuitive learning process leads to bottlenecks in model generalization and transferability. To solve this problem, the researchers proposed a rewriting language model (ReLM), which is trained to fill in the complete pre-correction sentence based on partial characters of the pre-correction sentence, and fill in the output post-correction sentence at the same time. This novel training paradigm achieved new state-of-the-art results in fine-tuning and zero-shot Chinese spelling check tests, outperforming existing similar methods.
[0005] The author of the article proposed to use a rewriting model to replace the sequence annotation model to complete the Chinese spelling check task. The rewriting model includes two implementation methods, one is an autoregressive generation architecture based on a large language model, and the other is a preset slot architecture based on BERT. The researchers believe that the generation length of the error correction results of the large language model is uncontrollable and does not have higher potential, so they focus on the second solution. The focus of this project is on the first solution, which is quite different from previous studies. Based on the large language model, it combines retrieval-augmented generation (RAG) and I-iterative discrimination strategy (IDS) to avoid the shortcomings of large language models in text generation and improve the competitiveness of large language models.
[0006] 2.On the(In)Effectiveness of Large Language Models for Chinese TextCorrection
[0007] The main content of this article is: The development and progress of large language models (LLMs) have amazed the entire artificial intelligence community. Benefiting from their emerging capabilities, large language models have attracted more and more researchers to study their capabilities and performance on various downstream natural language processing tasks. While marveling at the incredible performance of large language models on various tasks, researchers have noticed that large language models also have excellent multilingual processing capabilities. Therefore, in order to have a more comprehensive understanding of the Chinese processing capabilities of large language models, the researchers explored the performance of large language models on basic tasks such as Chinese text correction, which is a basic and challenging Chinese NLP task. Specifically, text correction includes two main Chinese text correction scenarios: Chinese grammatical error correction (CGEC) and Chinese spelling check. The researchers analyzed the error correction capabilities of existing LLMs represented by ChatGPT and found that the text correction capabilities of large language models still have some gaps with the previous state-of-the-art fine-tuning models, but show greater advantages in solving text fluency problems. In addition, the researchers observed that as the difficulty of the correction task increases, the performance of large language models tends to decline more significantly than traditional deep learning models. Researchers believe that the Chinese proofreading capabilities of large language models are currently not yet able to adapt to actual production environments, and further research is needed to promote the further implementation of large language models in the NLP field.
[0008] The article points out that large language models have a lot of potential in the field of Chinese spelling checking, but there are also some problems that need to be solved urgently. The researchers used a few sample prompts to guide different large language models to complete the task. The error correction results show that using large language models to complete Chinese spelling checking is a new and feasible solution, which opens up a new track for subsequent research on Chinese spelling checking.
[0009] 3.CSCD-IME:Correcting Spelling Errors Generated by Pinyin IME
[0010] The main content of this article is: The task of Chinese spelling check is to detect and correct spelling errors in text. Since the Pinyin input method has a very wide audience, phonetically similar spelling errors account for a considerable proportion of all types of spelling errors. Studying the spelling errors that occur in the Pinyin input method has great practical significance. The researchers first proposed a Chinese spelling check dataset (CSCD-IME) collected in the Pinyin input scenario. The data comes from 40,000 sentences in the official media posts of Sina Weibo. In addition, the researchers announced a new method to automatically construct large-scale, high-quality pseudo data by simulating the typing process of the Pinyin input method. A series of experiments on the CSCD-IME dataset in the article show that the spelling errors in the CSCD-IME dataset have a unique distribution and are sufficiently challenging. Summary of the invention
[0011] In view of the problems existing in the prior art, the present invention provides a Chinese spelling check large language model error correction method based on retrieval enhanced generation.
[0012] The present invention provides a Chinese spelling check large language model error correction method based on retrieval enhancement generation to complete the Chinese spelling check task, the method comprising:
[0013] S1: Using large language models for Chinese spelling checking tasks;
[0014] S2: Large language models have a general knowledge system and understanding ability. When a large model completes a task in a specific field, if there is a lack of information and relevant data about the task, the performance of the model on the task may decline. This solution chooses to use the RAG strategy to obtain relevant external knowledge from the vector database as auxiliary examples for the model to perform tasks;
[0015] S3: According to the task objectives and principles of the Chinese spelling check task, this solution designs appropriate prompt words for the large language model, and adopts the method of using few-sample prompts to put the auxiliary cases obtained by RAG as few-sample prompt sentences into the historical dialogue of the large language model for prompt-based few-sample context learning. In this way, the large language model obtained by the few-sample prompts is the error correction large language model in this solution;
[0016] S4: In order to control the output length of the large language model and improve the over-correction and incomplete correction of the error correction large language model, this solution uses the prompt engineering and the designed prompt template to build a discriminative large language model. After the error correction large language model corrects the sentence, it needs to be handed over to the discriminative large language model for judgment. Only after the judgment is passed, the correction result of the error correction large language model can be returned to the user. Otherwise, the error correction-discrimination process will continue to iterate to the preset maximum number of times;
[0017] S5: Construct evaluation datasets for automatic speech recognition and optical character scenarios to evaluate error correction performance.
[0018] The S2 specifically includes:
[0019] Data is collected from existing public data sets in the CSC field. After processing, the data will be converted into vectors of specified dimensions. In the vector conversion, the high-dimensional sentence semantic information is mapped to the low-dimensional space and stored in the vector database together with the correct sentence after error correction, sentence sequence number and other information. During the error correction process, the retrieval enhancement generation module will use the content of the vector database as an external knowledge base for error correction. For each sentence that needs to be corrected, the retrieval enhancement generation module will also use the same vectorization method to process it into a vector of specified dimensions. In the external knowledge base, several cases with similar semantics or the same error type are searched. These cases will be used as guiding knowledge for the current error correction process and input into the error correction large language model together with the sentences to be corrected.
[0020] Prompt Engineering is a technology in the field of natural language processing (NLP) and generative AI that aims to guide the language model to generate the desired output by designing and optimizing input prompts. This technology is particularly important when using large-scale pre-trained models such as GPT-3.5 and GPT-4. High-quality prompts can guide AI to interact more meaningfully with users.
[0021] The few-shot learning is to train a model or prompt a model on a limited dataset so that it can make good predictions on new, similar but unseen samples.
[0022] The retrieval-enhanced generation is a method of introducing external data, which can refer to a knowledge base in a specific field before a large language model generates a response; large language models (LLMs) are pre-trained on massive data, and the model contains billions of parameters. A large number of parameters enable large language models to easily understand the meaning of input text and provide feedback; based on the already powerful functions of LLMs, RAG supplements it with knowledge bases, allowing the model to have the ability of specific fields, all without retraining the model. This is a cost-effective method to improve the output of LLMs. The purpose of the improvement is to enable the model to maintain the relevance, accuracy and practicality of the generation in various situations. In this solution, a vector database is used as a tool for storing data, and the nearest neighbor search method is used to retrieve vectors. The results of the retrieval are input into the error correction large language model as an external knowledge base.
[0023] The S5 specifically includes:
[0024] Handwritten Chinese data and Mandarin Chinese speech data are obtained from public datasets in the fields of optical character recognition (OCR) and automatic speech recognition (ASR). This solution adds noise to the image and speech data before recognition to make it as close to the real recognition environment as possible. The recognition error rate will be improved to a certain extent after adding noise, and the recognition APIs of OCR and ASR will generate more erroneous texts during the recognition process. The collected raw data will be processed by several experienced annotators, who will compare and annotate the data, remove sentences that do not meet the requirements, and obtain the final dataset.
[0025] The present invention aims to explore a solution for implementing the large language model CSC based on retrieval enhancement generation, and the solution or implementation system should include:
[0026] RAG strategy selection module, used to select the vectorization strategy for RAG, select the vector database for storing data and the data search method, and obtain relevant external knowledge from the vector database as auxiliary examples for the model to perform tasks;
[0027] The prompt engineering module designs a sophisticated prompt template through prompt engineering, so that the model can clarify its own tasks, learn the task content and call the stored knowledge to answer according to the prompt;
[0028] The error correction large language model building module is used to design appropriate prompt words for the large language model according to the task objectives and principles of the Chinese spelling check task, and adopts the method of using few-sample prompts to put the auxiliary cases obtained by RAG as few samples into the historical dialogue of the large language model. The large language model obtained by the few-sample prompts is the error correction large language model;
[0029] Discriminative large language model building module: In order to control the output length of the large language model and improve the situation of over-correction and incomplete error correction of the large language model, a discriminative large language model is designed using prompt engineering. After the error correction model corrects the sentence, it needs to be handed over to the discriminative large language model for judgment. It can only be returned if it passes. Otherwise, it will continue to iterate until the maximum number of iterations is reached.
[0030] The dataset construction module builds corresponding datasets to conduct corresponding performance evaluation, promotes the development of Chinese spelling check, and enriches the diversity of datasets in the field of Chinese spelling check.
[0031] Another object of the present invention is to provide a new type of online service based on a large language model, under which the Chinese spelling check large language model error correction system based on retrieval enhancement generation is implemented to assist other NLP tasks in the form of plug-ins or APIs.
[0032] In combination with the above technical solutions and the technical problems solved, the advantages and positive effects of the technical solutions to be protected by the present invention are as follows:
[0033] First, in view of the technical problems existing in the above-mentioned prior art, some creative technical effects are brought about after solving the problems. The specific description is as follows:
[0034] 1: The present invention uses a deep learning model to vectorize the Chinese error correction data set and stores it in a vector database. When error correction is required, the sentence to be corrected is vectorized using the same method, and similar sentences in the vector database are retrieved as a few samples based on the nearest neighbor search method.
[0035] 2: The present invention uses prompt engineering to design prompt words to guide the model to clarify the task objectives and become a large-scale language model for error correction, and uses a small number of samples and prompt words in historical conversations to standardize the model's error correction process and output format.
[0036] 3: The present invention uses prompt engineering design prompt words to guide the model to clarify the task objectives and become a large-scale language model for discrimination. It uses an iterative discrimination strategy to allow the large-scale language model to judge the rationality and correctness of the error correction results. It continuously iterates until the pre-set requirements are met, and then the error correction results of the error correction model can be returned.
[0037] Second, the present invention proposes that few-shot or zero-shot contextual learning should be performed on the data set to replace the existing full-shot fine-tuning test method used by most BERT-based architectures, and a new evaluation data set is constructed based on downstream speech recognition and optical character recognition. This new solution provides a clear case for large language models to perform such NLP tasks, and also provides a new evaluation idea for Chinese spelling check tasks.
[0038] Third, the expected benefits and commercial value of the technical solution of the present invention after transformation are:
[0039] Development benefits: Large language models require less manual feature engineering and rule formulation due to their strong learning ability and generalization performance, which can greatly save early R&D time and cost. Once the model is fully trained, it can be quickly deployed and applied to a variety of scenarios, reducing the time cost of continuous adjustment and optimization.
[0040] Continuous development benefits: Traditional spelling check models need to continuously update the rule base or conduct further training on new data to adapt to changes in the error correction environment, which involves continuous investment in manpower and computing resources. However, the error correction framework that relies on large language models can gradually show stronger error correction capabilities through self-learning and adaptation as the large language models are autonomously iterated, improving user experience. The framework with few sample prompts also reduces the cost of long-term maintenance and does not require further investment in computing resources and human resources.
[0041] Personalized benefits: The Chinese spelling check model in the current solution has its error correction capability sourced from pre-trained knowledge learned by a large language model, few-sample prompts, and examples in an external knowledge base. Users can customize prompt content and external knowledge bases to obtain the desired personalized error correction model for different fields or different groups of people.
[0042] Easy to integrate and use: The Chinese spelling check large language model error correction system based on retrieval enhancement generation implemented by this solution is generally based on a large language model that runs stably on the server. This means that the services of this solution are mostly provided in the form of plug-ins or APIs (application programming interfaces), which can be easily used on different devices and platforms, and basically does not consume the user's computing resources, making it highly convenient.
[0043] Huge scope of application: Chinese spelling check is a small task in natural language processing, usually used as an aid and gain for other NLP tasks. Natural language text is usually processed by CSC at the beginning and end of other NLP tasks, such as machine translation, named entity recognition, text recognition, and speech recognition. These NLP tasks are closely related to daily life. The Chinese spelling check implemented by this solution has a certain degree of generalization and can serve as a good supplement to various other NLP fields to improve the user experience.
[0044] Fourth, the technical solution of the present invention overcomes technical prejudice:
[0045] Many previous studies were not optimistic about the error correction capabilities of existing large language models represented by ChatGPT. The text correction capabilities of LLMs are still far behind the most advanced fine-tuning models, or they are not suitable for Chinese spelling checking tasks. The main reason for this view is that the language understanding and generation capabilities of previous large language models were not strong enough, and they lacked fluency and rationality. However, with the iteration of large language models, this problem has been greatly alleviated.
[0046] Under the existing evaluation standards, the fine-tuned capabilities of current large language models are not as good as those of deep learning models fine-tuned on all samples. Previous studies have shown that the existing evaluation standards are only applicable to traditional models, and more reasonable evaluation methods, such as human evaluation, should be used for large prediction models. Existing error correction models only perform well on certain data sets, and their performance drops significantly when generalized to other data sets. This is also the reason why existing error correction models cannot be used commercially on a large scale.
[0047] The large language models mentioned in this solution are all language models with strong text generation capabilities. They already have certain program comprehension and language generation capabilities, such as GPT3.5, GLM3, GLM4, etc., and combine with the few-sample prompt project to standardize and control the generation results of the model, which can improve the error correction ability of the large language model to a certain extent and achieve better results in few-sample fine-tuning.
[0048] Fifth, the technical problems of the prior art solved by the present invention and the significant technical progress achieved:
[0049] Technical issues:
[0050] 1) Performance degradation in large language model applications: Traditional large language models will suffer from performance degradation when there is a lack of relevant task information and data, especially on specific tasks such as Chinese spelling checking.
[0051] 2) Output control issues of large language models: The output length of large language models is difficult to control, and it is easy to have excessive error correction or incomplete error correction.
[0052] Significant technological advancements:
[0053] 1) Application of RAG strategy: The RAG strategy is introduced to obtain relevant external knowledge through a vector database as auxiliary examples for the model to perform tasks, so as to improve the performance of large language models in Chinese spelling checking tasks.
[0054] 2) Few-sample prompt method: The method of using few-sample prompts is adopted. The auxiliary cases obtained by RAG are put into the historical dialogue of the large language model as few samples, and the few-sample fine-tuning is performed based on Prompt, thereby improving the performance and effect of the large language model.
[0055] 3) Design of output control and discriminant large language model: An output control and discriminant large language model is designed to control the output length of the large language model and improve the situations of over-correction and incomplete error correction. The error correction results are judged and fed back by discriminating the large language model, thereby improving the accuracy and stability of the error correction model.
[0056] 4) Contextual learning and dataset construction: Through few-shot or zero-shot contextual learning, the performance of large language models is further optimized. At the same time, corresponding datasets are constructed for performance evaluation, enriching the diversity of datasets in the field of Chinese spelling checking and promoting the development of Chinese spelling checking technology.
[0057] In summary, the present invention solves the problems of performance degradation and output control of large language models existing in the prior art by combining RAG strategy, few-sample prompt method, output control and discrimination large language model design, context learning and data set construction, and significantly improves the performance and effect of Chinese spelling checking technology. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] Figure 1 It is a flow chart of a Chinese spelling check large language model error correction method based on retrieval enhancement generation provided by an embodiment of the present invention;
[0059] Figure 2 It is a detailed flow chart of a Chinese spelling check large language model error correction method based on retrieval enhancement generation provided by an embodiment of the present invention;
[0060] Figure 3 This is a data set creation process provided by an embodiment of the present invention;
[0061] Figure 4 It is a structural diagram of a Chinese spelling check large language model error correction system based on retrieval enhanced generation provided by an embodiment of the present invention.
[0062] Figure 5 It is a diagram of a few samples and query prompt templates of a large error correction language model provided by an embodiment of the present invention.
[0063] Figure 6 It is a few-sample prompt and query template diagram for discriminating a large language model provided by an embodiment of the present invention.
[0064] Figure 7 This is the performance effect of the present invention in the Chinese spelling error correction scenario. DETAILED DESCRIPTION
[0065] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the embodiments. 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.
[0066] The technical solution of the present invention uses LLMs to replace deep learning models for Chinese spelling check tasks. In order to solve the problems of unclear task objectives, unstable generation length, lack of data support, etc. when large language models perform specific tasks, this solution adopts retrieval enhanced generation (RAG), few-sample hint engineering (FSL), and iterative discrimination strategy (IDS) to deal with them.
[0067] The present invention proposes to add noise to the correct sentence to artificially control the pinyin input method to produce errors. Since the location and number of errors are artificially specified, and the data set is constructed based on the errors collected by researchers, it will be biased when used as an evaluation data set because it does not contain error types that researchers have not seen. When creating an evaluation data set in the automatic speech recognition and optical character recognition scenarios, the present invention abandons the unreasonable process of artificially replacing the correct characters and specifying the number of characters, and instead increases the complexity of the environment to increase the error rate. The evaluation data set obtained in this way is obviously closer to the real scene and is worthy of further research.
[0068] A Chinese spelling checking method based on a large language model generated by retrieval enhancement is described below in detail:
[0069] Example 1: Assume that there is a large Chinese text generation model that performs well in general tasks but is slightly insufficient in Chinese spelling checking. Follow the steps below to implement it:
[0070] 1) Selecting a large language model (S1): First, this large Chinese text generation model is selected as the base model for the Chinese spelling checking task.
[0071] 2) Introducing the RAG strategy (S2): In order to enhance the performance of the model on the spelling error correction task, it is decided to use the RAG strategy. External knowledge related to the current spelling error, such as correct spelling, similar vocabulary, or contextual information, is retrieved from a pre-built vector database as auxiliary examples for the model.
[0072] 3) Designing prompt words and few-sample prompts (S3): According to the task objectives and principles of Chinese spelling check, appropriate prompt words are designed for the large language model. At the same time, auxiliary cases obtained through RAG are used as few samples and embedded into the historical dialogue of the large language model to help the model better understand the context and rules of spelling correction.
[0073] 4) Discriminative large language model (S4): In order to control the output length and improve the problems of over-correction and incomplete correction, a discriminative large language model is designed. After the error correction model corrects the sentence, the output will be passed to the discriminative model for judgment. If the judgment passes, the correction result will be returned; otherwise, the error correction model will iteratively correct until the maximum number of iterations is reached.
[0074] 5) Construct and evaluate the dataset (S5): In order to evaluate the performance of the model and promote the development of the Chinese spelling check field, a dataset containing a variety of spelling errors and correct corrections was constructed. The performance of the model was evaluated using this dataset, and the model was optimized and iterated based on the evaluation results.
[0075] like Figure 1 , 2 As shown, an embodiment of the present invention provides a Chinese spelling checking method for a large language model based on retrieval enhancement generation, the method comprising:
[0076] S1: Using large language models for Chinese spelling checking tasks;
[0077] S2: Since large language models have common semantic information, their performance will decline when they lack relevant task information and data. We choose to use the RAG strategy to obtain relevant external knowledge from the vector database as auxiliary examples for the model to perform tasks.
[0078] S3: According to the task objectives and principles of the Chinese spelling check task, appropriate prompt words are designed for the large language model. The method of using few-sample prompts is adopted to put the auxiliary cases obtained by RAG as few samples into the historical dialogue of the large language model for prompt-based few-sample context learning. The large language model obtained by the few-sample prompts is the error correction large language model.
[0079] S4: In order to control the output length of the large language model and improve the situation of over-correction and incomplete error correction of the large language model, a discriminative large language model was designed using prompt engineering. After the error correction model corrects the sentence, it needs to be handed over to the discriminative large language model for judgment. It can only return after passing the judgment. Otherwise, it will continue to iterate until the maximum number of iterations is reached.
[0080] S5: Construct the corresponding data set to perform corresponding performance evaluation.
[0081] The working principle of the large language model Chinese spelling check method based on retrieval-augmented generation (RAG) can be summarized in detail as follows:
[0082] S1: Foundations of Large Language Models
[0083] Our approach first utilizes a Large Language Model (LLM) as the basis for the Chinese spelling checking task.
[0084] LLM has strong natural language processing capabilities and general semantic information, making it an ideal choice for such tasks.
[0085] S2: Retrieval Enhancement Generation (RAG) Strategy
[0086] Considering that the performance of LLM may deteriorate when lacking specific task information and data, this method introduces the RAG strategy.
[0087] Through RAG, our method retrieves external knowledge related to the current task from the vector database, which will serve as auxiliary examples to help LLM perform the task better.
[0088] S3: Design appropriate prompt words and few-shot prompts
[0089] According to the task objectives and principles of Chinese spelling checking, special prompt words are designed for LLM.
[0090] A few-shot prompting method is adopted to incorporate auxiliary cases obtained by RAG into the historical dialogue of LLM as few-shot samples.
[0091] In this way, LLM is able to perform prompt-based few-shot contextual learning, thereby transforming into a model specialized for error correction.
[0092] S4: Output control and discrimination model
[0093] To ensure the accuracy and appropriateness of error correction, this method designs a discriminative LLM through prompt engineering.
[0094] When the error correction model completes the error correction of the sentence, the result will be submitted to the discriminative LLM for further judgment.
[0095] Only when the LLM determines that the error correction result meets the requirements will the result be returned; otherwise, the error correction process will continue to iterate until the maximum number of iterations is reached.
[0096] This method effectively controls the output length and improves the situation of over-error correction or incomplete error correction.
[0097] S5: Dataset construction and performance evaluation
[0098] In order to verify the effectiveness of this method, it is necessary to construct a special dataset for performance evaluation.
[0099] The dataset will contain a variety of spelling errors and correct control samples to fully evaluate the accuracy and efficiency of the error correction model.
[0100] Through the above working principle, the method can more accurately detect and correct spelling errors in Chinese texts while ensuring the appropriateness and effectiveness of the error correction.
[0101] In the embodiment of the present invention, S2 specifically includes:
[0102] Collect information from public data sets in the CSC field, and use a vectorized model to vectorize it after processing. According to the semantic features of the sentences, the Chinese sentences in the data set are converted into vectors of specified dimensions, and stored in the vector database together with the relevant information of the sentences. When external knowledge is needed, the root uses the same vectorization method to process the current sentence to be corrected into a vector, performs a nearest neighbor search in the vector database, finds the most similar cases, and inputs them into the subsequent model together with the current sentence to be corrected.
[0103] The prompt engineering is the process of guiding generative AI to generate the desired output. Although generative AI attempts to imitate humans and has a certain ability to understand language, it requires detailed instructions to create high-quality and relevant output; the most appropriate format, phrases, words and symbols can be selected to guide AI to interact more meaningfully with users.
[0104] The few-shot tip is to train a model on a limited dataset so that it can make good predictions on new, similar but unseen samples.
[0105] The retrieval-enhanced generation is to optimize the output of large language models so that they can reference authoritative knowledge bases outside the training data source before generating a response; large language models (LLMs) are trained with massive data and use billions of parameters to generate original output for tasks such as answering questions, translating languages, and completing sentences; based on the already powerful capabilities of LLMs, RAG extends them to access internal knowledge bases of specific fields or organizations, all without retraining the model. This is a cost-effective way to improve the output of LLMs so that the model can remain relevant, accurate, and practical in a variety of situations; using a vector database as a source of stored data, using nearest neighbor search for vector retrieval, and the results of the retrieval as an external knowledge base input into the error-correcting large language model.
[0106] like Figure 3 As shown, the S6 specifically includes:
[0107] Handwritten Chinese image data and Chinese audio recordings are obtained from public data sets in the fields of optical character recognition (OCR) and speech and text recognition (ASR). After being processed by adding noise to simulate a more complex environment, they are put into the application programming interface (API) of speech recognition and image recognition to increase the difficulty of recognition and the error rate of recognition, thereby obtaining erroneous data caused by the defects of current speech recognition and image recognition. After obtaining the erroneous data, the data are screened and annotated by multiple experienced annotators to obtain the annotated error-corrected data, which are then processed subsequently to obtain the final data set.
[0108] like Figure 4 As shown, an embodiment of the present invention provides a Chinese spelling check large language model error correction system based on retrieval enhancement generation that implements the Chinese spelling check method of the large language model based on retrieval enhancement generation, and the system includes:
[0109] RAG strategy selection module, used to select the vectorization strategy for RAG, select the vector database for storing data and the data search method, and obtain relevant external knowledge from the vector database as auxiliary examples for the model to perform tasks;
[0110] The prompt engineering module designs a sophisticated prompt template through prompt engineering, so that the model can clarify its own tasks, learn the task content and call the stored knowledge to answer according to the prompt;
[0111] The error correction large language model building module is used to design appropriate prompt words for the large language model according to the task objectives and principles of the Chinese spelling check task, and adopts the method of using few-sample prompts to put the auxiliary cases obtained by RAG as few samples into the historical dialogue of the large language model. The large language model obtained by the few-sample prompts is the error correction large language model;
[0112] Discriminative large language model building module: In order to control the output length of the large language model and improve the situation of over-correction and incomplete error correction of the large language model, a discriminative large language model is designed using prompt engineering. After the error correction model corrects the sentence, it needs to be handed over to the discriminative large language model for judgment. It can only be returned if it passes. Otherwise, it will continue to iterate until the maximum number of iterations is reached.
[0113] The dataset construction module builds corresponding datasets to conduct corresponding performance evaluation, promotes the development of Chinese spelling check, and enriches the diversity of datasets in the field of Chinese spelling check.
[0114] The computer device, computer-readable storage medium and information data processing terminal provided in the embodiments of the present invention are all for implementing a Chinese spelling checking method based on a large language model generated based on retrieval enhancement.
[0115] Computer equipment:
[0116] 1) Hardware composition:
[0117] Memory: used to store computer programs and data. In this embodiment, the memory stores a computer program for implementing a Chinese spelling checking method for a large language model based on retrieval enhancement generation.
[0118] Processor: Responsible for executing the computer program in the memory. When executing a specific computer program, the processor will perform various steps of the Chinese spelling checking method based on the large language model generated by retrieval enhancement according to the program instructions.
[0119] 2) Function realization:
[0120] When the processor executes the computer program in the memory, the computer device will be able to perform various steps of Chinese spelling checking, including but not limited to using a large language model for spelling checking, retrieving relevant knowledge using the RAG strategy, enhancing model performance through few-sample prompts, controlling output and performing discrimination, etc.
[0121] Computer readable storage medium:
[0122] 1) Storage content:
[0123] Computer programs are stored on computer-readable storage media, and these programs contain all instructions and codes required to implement the Chinese spelling checking method of a large language model generated based on retrieval enhancement.
[0124] 2) Program execution:
[0125] When these computer programs are executed by the processor, they will guide the processor to perform Chinese spelling checking tasks according to preset steps, thereby achieving efficient spelling error detection and correction.
[0126] Information data processing terminal:
[0127] 1) Functional positioning:
[0128] The information data processing terminal is a device or platform specially designed for implementing a Chinese spelling check large language model error correction system based on retrieval enhancement generation.
[0129] 2) System implementation:
[0130] The terminal integrates the necessary hardware and software resources to ensure smooth operation of large language models and related spelling checking algorithms.
[0131] By optimizing hardware configuration and software architecture, the information data processing terminal can provide efficient spelling checking services to meet users' needs for spelling accuracy in practical applications.
[0132] In summary, the computer device, computer-readable storage medium and information data processing terminal provided by the embodiments of the present invention together constitute a complete solution, which aims to improve the accuracy and efficiency of Chinese spelling checking through large-scale language models and retrieval enhancement generation technology.
[0133] The present invention uses two prompt templates: the few samples of the error correction model and the query prompt template. Figure 5 As shown in Figure 1, the identity of the large language model is defined, and then the spelling assistance samples queried from the vector database are used to allow the large language model to learn the rules and effects of Chinese spelling check in the few-sample prompts. The few-sample prompts and query templates of the discriminative model are shown in Figure 1. Figure 6 As shown in the figure, the identity of the large prediction model is also defined, and corresponding judgment criteria are designed for possible error correction results, so that the language model can learn the judgment requirements and standards from the pre-set few samples. In the two figures, we marked the key information in italics and bold.
[0134] The embodiments of the present invention have achieved some positive effects during the development or use process, and indeed have great advantages over the prior art. The following content is described in conjunction with data, charts, etc. of the test process.
[0135] Test Data: We selected the SIGHAN15 dataset for evaluation. SIGHAN15 is a dataset of three specific domains handwritten by Chinese as a second language (CSL) learners, which is widely used in the performance testing of Chinese spelling check models.
[0136] Evaluation indicators: For the Chinese spelling check task, following previous work, sentence-level accuracy, precision, recall, and F1 scores are used as evaluation indicators. Sentence-level metrics are stricter than character-level metrics because a sentence is considered correct only if all errors in the sentence are successfully detected and corrected. The evaluation indicators mainly include accuracy, precision, recall, and F1 values for detection and correction.
[0137] Comparison method: In order to judge the performance of large language models after few-shot prompting, some commonly used CSC models are selected as baselines after few-shot training:
[0138] BERT: First encodes the input sentence, then uses a classifier (e.g., linear layer) to pick the correction character from the vocabulary of each character. REALIZE: is a multimodal CSC model that leverages semantic, phonetic, and graphical knowledge.
[0139] CRASpell: introduces additional error to the original example and uses KL divergence to enhance the local smoothness of the model. This model optimizes the performance of the model in noisy or mis-realized environments.
[0140] SCOPE: It builds two parallel decoders on top of a shared encoder, one for the main Chinese spelling checking task and the other for a fine-grained auxiliary speech prediction task, adopts a novel adaptive weighting scheme to balance the two tasks, and designs a subtle iterative discriminative strategy for further improvement during inference.
[0141] GPT3.5: GPT3.5 is a language model based on deep learning algorithms. Its core idea is to use neural networks to model a large amount of text corpus and generate coherent and understandable natural language text. GPT3.5 uses more data for training than GPT3, including security desensitized data from massive work order data, robot conversation data, unstructured documents, etc. The inclusion of this data enables GPT3.5 to better adapt to corporate language and business scenarios, and also gives GPT3.5 rich grammatical knowledge and multilingual capabilities.
[0142] BERT, ReaLiSe and the large language model GPT used in the experiment were not pre-trained on a large amount of Chinese spelling check data. CRASpell and SCOPE used were pre-trained on 270,000 Chinese spelling check data. Before testing, all models were further fine-tuned on a small number of Chinese spelling check samples.
[0143] Experimental design: For deep learning models, few-sample fine-tuning is performed on a small number of randomly selected error correction samples, with a learning rate of 5e-5 and 10 training rounds. For deep learning models, RAG and IDS strategies are added to them to perform few-sample fine-tuning using contextual learning. Performance comparison is performed on the SIGHAN15 dataset.
[0144]
[0145] Table 1: Accuracy, precision, recall, and F1 results of deep learning models and GPT3.5 on SIGHAN15 using few-shot fine-tuning and few-shot prompting. The number of samples used for few-shot fine-tuning and few-shot prompting is 4.
[0146]
[0147] Table 2: Ablation results of the RSF error correction system using GPT3.5 as the base model on the SIGHAN15 test set. We made the following changes to the RSF error correction system (RAG+IDS+Few_Shot): Delete the retrieval enhancement generation strategy (IDS+Few_Shot). Delete the iterative discrimination strategy (RAG+Few_Shot). Delete both the retrieval enhancement generation strategy and the iterative discrimination strategy. Only use a few sample prompts of fixed samples for error correction (Few_Shot).
[0148] Main Results: Table 1 shows the evaluation results of the large language model and various deep learning baseline models on the SIGHAN15 dataset. Table 2 shows the ablation experiment results of our large language model error correction method for Chinese spelling check based on retrieval-enhanced generation.
[0149] We observed that BERT and ReaLiSe, which were pre-trained for only one step and then fine-tuned with a few samples, performed poorly on all evaluation datasets. In contrast, CRASpell and SCOPE, which were further pre-trained on a large amount of Chinese spelling check data and then fine-tuned with a few samples, showed excellent performance. This shows that deep learning models are very dependent on Chinese spelling check data when completing Chinese spelling check tasks. Using a large language model GPT-3.5 on SIGHAN15, it surpassed BERT and ReaLiSe, which were pre-trained for only one step, and was very close to the performance of SCOPE and CRASpell. This shows that large language models have considerable advantages and potential in few-sample scenarios.
[0150] The ablation experiment results from the SIGHAN15 test set in Table 2 show that using IDS or RAG alone can improve the correction performance, confirming that both strategies can enhance the effect of large language models on Chinese spelling check tasks. In addition, when using both RAG and IDS strategies at the same time, the effect of Chinese spelling check is further improved, indicating that RAG and IDS provide help from different angles and they are synergistic in the Chinese spelling check task.
[0151] Figure 7This is the actual performance of our RAG and IDS strategies in assisting large language models in Chinese spelling check tasks. We have underlined and bolded both the characters that need to be modified and the modified characters. The auxiliary statements are italicized. We can see that in the first example, the Fixed_Few_Shot LLMs failed to find the incorrect character "受" and the error correction failed. The RAG+Fixed_Few_Shot LLMs successfully found the error based on the prompt of the example and corrected it to the character "收", and the prediction result is the same as the correct result, so the error correction is successful. In the second example, when there are some grammar errors in the statement, the Fixed_Few_Shot LLMs cannot determine whether there are character errors in the sentence, and the error correction fails. The IDS+Fixed_Few_Shot LLM using our IDS strategy can successfully find the most reasonable prediction and change the incorrect character "湾" to "玩", and the error correction is successful. These error correction examples prove the superiority of our method
[0152] As described above, it is only the specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any modification, equivalent replacement, and improvement made within the technical scope disclosed by the present invention and within the spirit and principle of the present invention shall be covered by the protection scope of the present invention
Claims
1. A Chinese spelling check large language model error correction method based on retrieval enhancement generation, characterized in that: The method includes: S1: Using large language models for Chinese spelling checking tasks; S2: Since large language models have common semantic information, their performance will decline when they lack relevant task information and data. We choose to use the RAG strategy to obtain relevant external knowledge from the vector database as auxiliary examples for the model to perform tasks. S3: According to the task objectives and principles of the Chinese spelling check task, suitable prompt words are designed for the large language model. The method of using few-sample prompts is adopted to put the auxiliary cases obtained by RAG as few-samples into the historical dialogue of the large language model for prompt-based few-sample context learning. The large language model obtained by the few-sample prompts is the error correction large language model. S4: In order to control the output length of the large language model and improve the situation of over-correction and incomplete error correction of the large language model, after the error correction large language model corrects the sentence, it needs to be handed over to the discriminative large language model for judgment. It can only return after passing the judgment. Otherwise, it will continue to iterate until the maximum number of iterations is reached. S5: Construct the corresponding data set to perform corresponding performance evaluation.
2. The Chinese spelling check large language model error correction method based on retrieval enhancement generation as claimed in claim 1 is characterized in that: The S2 specifically includes: Information is collected from public data sets in the field of Chinese spelling checking, and after processing, it is vectorized using a vectorized model. The Chinese sentences in the data set are converted into vectors of specified dimensions based on the semantic features of the sentences, and stored in the vector database together with the relevant information of the sentences. When external knowledge is needed, the current sentence to be corrected is processed into a vector using the same vectorization method, and a nearest neighbor search is performed in the vector database to find the most similar cases, which are then input into the subsequent model together with the current sentence to be corrected.
3. The Chinese spelling check large language model error correction method based on retrieval enhancement generation as claimed in claim 1 is characterized in that: Prompt engineering is the process of guiding a generative AI solution to produce the desired output. Although generative AI attempts to mimic humans, it requires detailed instructions to create high-quality and relevant output; the most appropriate formats, phrases, words, and symbols can be selected to guide the AI to interact more meaningfully with users.
4. The Chinese spelling check large language model error correction method based on retrieval enhancement generation as claimed in claim 1 is characterized in that: The few-shot tip is to train a model on a limited dataset so that it can make good predictions on new, similar but unseen samples.
5. The Chinese spelling check large language model error correction method based on retrieval enhancement generation as claimed in claim 1, characterized in that: Retrieval-enhanced generation refers to optimizing the output of large language models so that they can reference authoritative knowledge bases outside the training data source before generating a response; building on the already powerful capabilities of LLMs, RAG expands them to access internal knowledge bases of specific domains or organizations, all without retraining the model.
6. The Chinese spelling check large language model error correction method based on retrieval enhancement generation as claimed in claim 1, characterized in that: The S5 specifically includes: Handwritten Chinese data and Chinese recordings are obtained from public data sets in the fields of optical character recognition (OCR) and speech recognition (ASR). After being processed with noise to simulate a more complex environment, they are put into the APIs of speech recognition and image recognition to increase the difficulty of recognition and the error rate of recognition, thereby obtaining speech recognition and image recognition results that contain Chinese spelling errors. After obtaining the recognition results, several experienced annotators screen and annotate the recognition results, remove duplicate and unreasonable sentences, and obtain the final data set.
7. A Chinese spelling check large language model error correction system based on retrieval enhancement generation, which implements the Chinese spelling check large language model error correction method based on retrieval enhancement generation as claimed in any one of claims 1 to 5, characterized in that: The system includes: RAG strategy selection module, used to select the vectorization strategy for RAG, select the vector database for storing data and the data search method, and obtain relevant external knowledge from the vector database as auxiliary examples for the model to perform tasks; The prompt engineering module designs a sophisticated prompt template through prompt engineering, so that the model can clarify its own tasks, learn the task content and call the stored knowledge to answer according to the prompt; The error correction large language model building module is used to design appropriate prompt words for the large language model according to the task objectives and principles of the Chinese spelling check task, and adopts the method of using few-sample prompts to put the auxiliary cases obtained by RAG as few samples into the historical dialogue of the large language model. The large language model obtained by the few-sample prompts is the error correction large language model; Discriminative large language model building module: In order to control the output length of the large language model and improve the situation of over-correction and incomplete error correction of the large language model, a discriminative large language model is designed using prompt engineering. After the error correction model corrects the sentence, it needs to be handed over to the discriminative large language model for judgment. It can only be returned if it passes. Otherwise, it will continue to iterate until the maximum number of iterations is reached. The dataset construction module builds corresponding datasets to conduct corresponding performance evaluation, promotes the development of Chinese spelling check, and enriches the diversity of datasets in the field of Chinese spelling check.
8. A computer device, characterized in that: The computer device includes a memory and a processor, the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the Chinese spelling checking method of a large language model based on retrieval enhancement generation as described in any one of claims 1-6.
9. A computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, the processor executes the steps of the Chinese spelling checking method of a large language model based on retrieval enhancement generation as described in any one of claims 1 to 6.
10. An information data processing terminal, characterized in that: The information data processing terminal is used to implement the Chinese spelling check large language model error correction system based on retrieval enhancement generation as described in claim 7.
Citation Information
Patent Citations
Medical auxiliary question and answer method and system based on knowledge calibration and retrieval enhancement
CN117573843A
Error correction method and system for large language model fusing rich semantic information
CN117852528A
Counterpart artificial intelligence software program
US20060179022A1
Cited By
Retrieval sample selection and multi-round error correction method for solving mathematical problem of large language model
CN119537567A
English composition correcting system based on AI large model
CN119621936A
Story generation method and device, electronic equipment and storage medium
CN119761503A
Story generation method and device, electronic device and storage medium
CN119761503B
Retrieval enhancement generation method and system based on dynamic pipeline
CN119848202A
