Chinese spelling error correction method, device, equipment and storage medium for sampling, segmentation and reorganization

By obtaining the inference trajectory of the large language model to perform word segmentation alignment and merging optimization, and combining the pronunciation, shape and meaning scores, the problem of insufficient accuracy of the large language model in the Chinese spelling correction task is solved, and a more efficient correction effect is achieved.

CN120509400BActive Publication Date: 2025-09-30WUHAN DONGXIN TONGBANG INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511018314.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-07-23
Publication Date
2025-09-30
Estimated Expiration
2045-07-23

AI Technical Summary

Technical Problem

Existing large language models perform poorly in Chinese spelling correction tasks, especially when it is difficult to meet the requirements of pronunciation or glyph similarity while keeping the number of characters unchanged, resulting in inaccurate correction results.

Method used

By obtaining all the inference traces of the preset large language model, word segmentation alignment and merging optimization are performed, and the optimal error correction results are screened out by combining the pronunciation, shape and meaning scores.

Benefits of technology

The accuracy of large language models in Chinese spelling correction tasks has been significantly improved, fully utilizing their language capabilities to provide more accurate correction results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120509400B_ABST
    Figure CN120509400B_ABST
Patent Text Reader

Abstract

The present invention discloses a method, device, equipment and storage medium for Chinese spelling error correction by sampling segmentation and reorganization. The method obtains all reasoning trajectories of preset large language models (LLMs); performs word-meaning unit segmentation on target sample sentences and input sentences in all reasoning trajectories, aligns the sentences in all reasoning trajectories according to the word segmentation results of the input sentences, merges and optimizes the alignment results to obtain optimized alignment results; scores and screens the optimized alignment results to obtain Chinese spelling error correction results. The method can trace back all trajectories of LLMs in the reasoning process in a depth-first manner, mine all contents generated by LLMs, make full use of their rich language capabilities, fully mine the contents generated by LLMs in the reasoning process, and use these contents to reorganize more accurate error correction results, thereby significantly improving the performance of two types of LLMs, namely, those based on prompts and those based on supervised fine-tuning, on CSC tasks.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of natural language processing, and in particular to a method, device, equipment and storage medium for correcting Chinese spelling errors by sampling, segmenting and recombining words. Background Art

[0002] The Chinese Spelling Correction (CSC) task involves detecting and correcting errors in Chinese text caused by similar pronunciations or glyphs. These errors often occur in applications such as Chinese input methods, optical character recognition (OCR), and speech recognition. These errors can reduce communication efficiency and even cause misunderstandings, causing great distress to people.

[0003] In recent years, large language models (LLMs) have achieved remarkable success in the field of natural language processing and have been applied to various tasks, such as grammatical error correction. However, some studies have shown that in CSC tasks, although LLMs have demonstrated strong semantic understanding capabilities, their actual performance is unsatisfactory. This is mainly because the powerful language generation capabilities of LLMs can lead to excessive modification of sentences, thus deviating from the core requirement of CSC tasks, that is, the output sentence must have the same number of characters as the input sentence. In addition, CSC tasks usually require that the characters before and after the modification have a certain degree of phonetic or glyphic similarity, which LLMs often find difficult to meet. Although the correction results returned by LLMs are semantically correct, they do not meet the requirement of a certain degree of phonetic or glyphic similarity between the characters before and after the modification.

[0004] Currently, the research on LLMs in CSC tasks is still in its preliminary stage, and the main research methods are divided into two categories: prompt-based and supervised fine-tuning-based;

[0005] The prompt-based research method hopes to use carefully designed prompt words to guide LLMs to use their own abilities to complete the error correction task;

[0006] The research method based on supervised fine-tuning uses the training data of the CSC task to adjust the parameters of LLMs based on the prompt words, making LLMs more suitable for the CSC task.

[0007] The two methods each have their own advantages and disadvantages: the prompt-based method has high flexibility and scalability. By designing different prompt words, it can guide LLMs to adapt to various CSC task scenarios without requiring a large number of model parameter adjustments; however, this method has high requirements for the design of prompt words, and it may be difficult to find the optimal prompt word in complex tasks.

[0008] The supervised fine-tuning method optimizes the performance of LLMs in CSC tasks by directly adjusting their parameters, which can more accurately adapt the model to specific tasks; however, this method requires a large amount of labeled data to train the model and may lead to a decrease in the model's own generalization ability. Summary of the Invention

[0009] The main purpose of the present invention is to provide a method, device, equipment and storage medium for Chinese spelling correction by sampling word segmentation and reorganization, aiming to solve the technical problem in the prior art that the two types of LLMs, namely, prompting and supervised fine-tuning, have poor performance in CSC tasks.

[0010] In a first aspect, the present invention provides a method for correcting Chinese spelling errors by sampling word segmentation and reorganization, the method comprising the following steps:

[0011] Get all the inference traces of the preset large language model LLMs;

[0012] Performing word segmentation on the target sample sentences and input sentences in all the reasoning trajectories, aligning the sentences in all the reasoning trajectories according to the word segmentation results of the input sentences, and merging and optimizing the alignment results to obtain an optimized alignment result;

[0013] The optimized alignment results are scored and screened to obtain Chinese spelling correction results.

[0014] Optionally, obtaining all reasoning trajectories of a preset large language model LLMs includes:

[0015] A depth-first multi-trajectory sampling (DFMTS) method is used to perform depth-first backtracking on the preset large language models (LLMs) to obtain all reasoning trajectories of the preset large language models (LLMs).

[0016] Optionally, the depth-first multi-trajectory sampling (DFMTS) method is used to perform depth-first backtracking on the preset large language model (LLMs) to obtain all reasoning trajectories of the preset large language model (LLMs), including:

[0017] Get the list of token trajectories for unfinished reasoning in the preset large language model (LLMs);

[0018] Inferring the token trajectory list according to the preset sampling cardinality and sampling the next token, and recording the initial inference trajectory of each token;

[0019] The initial reasoning trajectory is depth-first backtracked using a depth-first multi-trajectory sampling (DFMTS) method until all trajectories in the initial reasoning trajectory end with an end marker, thereby obtaining all reasoning trajectories of the preset large language model (LLMs).

[0020] Optionally, the depth-first multi-trajectory sampling (DFMTS) method is used to perform depth-first backtracing on the initial reasoning trajectory until all trajectories in the initial reasoning trajectory end with an end marker, thereby obtaining all reasoning trajectories of the preset large language model (LLMs), including:

[0021] Perform depth-first backtracking on the initial reasoning trajectory using a depth-first multi-trajectory sampling (DFMTS) method;

[0022] When detecting that the token of the current trajectory in the initial reasoning trajectory is a reasoning end marker, updating the token on the current trajectory to the reasoning trajectory;

[0023] When it is detected that the token of the current trajectory in the initial reasoning trajectory is not an inference end marker, the token on the current trajectory is added to the token list of the current trajectory, and the reasoning is continued until all trajectories in the initial reasoning trajectory end with an end marker, thereby obtaining all the inference trajectories of the preset large language model LLMs.

[0024] Optionally, performing word segmentation on the target sample sentences and the input sentences in all the reasoning trajectories, aligning the sentences in all the reasoning trajectories according to the word segmentation results of the input sentences, merging and optimizing the alignment results to obtain an optimized alignment result, includes:

[0025] Perform word segmentation processing on the target sample sentences and input sentences in all the reasoning trajectories, align the word segmentation results of the target sample sentences by editing distance according to the word segmentation results of the input sentences to obtain an alignment result, and optimize the alignment result by a preset word segmentation merging optimization algorithm to obtain an optimized alignment result.

[0026] Optionally, performing word segmentation processing on the target sample sentences and the input sentences in all the reasoning trajectories, aligning the word segmentation results of the target sample sentences by using the edit distance according to the word segmentation results of the input sentences to obtain an alignment result, and optimizing the alignment result by using a preset word segmentation merging optimization algorithm to obtain an optimized alignment result, includes:

[0027] Perform word segmentation processing on the target sample sentence and the input sentence in the reasoning track by using a preset word segmenter to obtain a word segmentation result;

[0028] Using an alignment algorithm based on edit distance, the word segmentation result of the target sample sentence is aligned with the word segmentation result of the input sentence to obtain an alignment result tuple;

[0029] Obtain the tuple index that caused the exception in the alignment result tuple;

[0030] Constructing alignment sub-rules for the sentence according to the tuple index, and merging all the alignment sub-rules into a rule list;

[0031] The alignment result of the target sample sentence and the alignment result of the input sentence are uniformly merged and optimized according to the rule list to obtain an optimized alignment result.

[0032] Optionally, scoring and screening the optimized alignment results to obtain Chinese spelling correction results includes:

[0033] Performing pronunciation scoring on the optimized alignment results from three dimensions: initial consonant, final consonant, and tone to obtain an initial consonant score, a final consonant score, and a tone score;

[0034] The pronunciation score is obtained by calculating the following formula based on the preset weight, the initial consonant score, the final consonant score and the tone score:

[0035]

[0036] in, Score for pronunciation. Score the initial consonants. Score the finals. Score the tone. Assign weights to initial consonants, Assign weights to finals. assign weights to tones;

[0037] The glyph similarity score of the optimized alignment result is scored based on seven feature dimensions: four-corner code, radical, word frequency, number of strokes, decomposition structure, construction structure and stroke order. The glyph similarity score is obtained by the following formula:

[0038]

[0039] in, is the glyph similarity score, Indicates the The similarity score of the features, , Indicates the The weight of the feature, , is the normalization factor;

[0040] The final score of the optimized alignment result is determined by the following formula:

[0041]

[0042] in, For the final score, Score for pronunciation. Score the glyph similarity;

[0043] Obtain the word sense cosine similarity between the input sentence segmentation and the sample sentence segmentation in the optimized alignment result, and use the word sense cosine similarity as the word sense score:

[0044]

[0045] in, Score word meanings. To segment the input sentence, Segment the sampled sentences. for word2vec word vector, for word2vec word vector;

[0046] Forming a candidate segmentation list based on the input sentence segmentation and the sampled sentence segmentation, and revising the final scores of the candidate segmentations in the candidate segmentation list based on the word meaning scores;

[0047] The candidate segmentation with the highest score in the candidate segmentation list is taken as the best candidate segmentation, a sentence composed of all the best candidate segmentations is taken as the final error-corrected sentence, and the final error-corrected sentence is used as the Chinese spelling correction result.

[0048] In a second aspect, to achieve the above-mentioned purpose, the present invention further proposes a Chinese spelling correction device for sampling, segmentation and reorganization, comprising:

[0049] The trajectory acquisition module is used to obtain all reasoning trajectories of the preset large language model LLMs;

[0050] a merging module, configured to perform word segmentation on the target sample sentences and the input sentences in all the reasoning trajectories, align the sentences in all the reasoning trajectories according to the word segmentation results of the input sentences, and merge and optimize the alignment results to obtain an optimized alignment result;

[0051] The scoring and screening module is used to score and screen the optimized alignment results to obtain Chinese spelling correction results.

[0052] In the third aspect, to achieve the above-mentioned purpose, the present invention also proposes a sampling word segmentation and reorganization Chinese spelling correction device, which includes: a memory, a processor, and a sampling word segmentation and reorganization Chinese spelling correction program stored on the memory and capable of running on the processor, and the sampling word segmentation and reorganization Chinese spelling correction program is configured to implement the steps of the sampling word segmentation and reorganization Chinese spelling correction method described above.

[0053] In a fourth aspect, in order to achieve the above-mentioned purpose, the present invention also proposes a storage medium, on which a sampling word segmentation and reorganization Chinese spelling correction program is stored. When the sampling word segmentation and reorganization Chinese spelling correction program is executed by a processor, the steps of the sampling word segmentation and reorganization Chinese spelling correction method described above are implemented.

[0054] The sampling segmentation and reorganization Chinese spelling correction method proposed in the present invention obtains all reasoning trajectories of preset large language models (LLMs); performs word-meaning unit segmentation on the target sample sentences and input sentences in all the reasoning trajectories, aligns the sentences in all the reasoning trajectories according to the segmentation results of the input sentences, merges and optimizes the alignment results to obtain optimized alignment results; scores and filters the optimized alignment results to obtain Chinese spelling correction results. It can trace back all trajectories of LLMs in the reasoning process in a depth-first manner, mine all contents generated by LLMs, and make full use of their rich language capabilities. It can fully mine the contents generated by LLMs in the reasoning process and use these contents to reorganize more accurate correction results, which significantly improves the performance of both prompt-based and supervised fine-tuning-based LLMs on CSC tasks. BRIEF DESCRIPTION OF THE DRAWINGS

[0055] Figure 1 A schematic diagram of the device structure of the hardware operating environment involved in the embodiment of the present invention;

[0056] Figure 2 This is a flow chart of the first embodiment of the Chinese spelling error correction method for sampling, segmentation, and reorganization of the present invention;

[0057] Figure 3 This is a flow chart of a second embodiment of the Chinese spelling error correction method for sampling, segmentation, and reorganization according to the present invention;

[0058] Figure 4 This is a flow chart of the third embodiment of the Chinese spelling error correction method for sampling, segmentation, and reorganization of the present invention;

[0059] Figure 5 This is a schematic diagram of the word segmentation, alignment and merging process in the Chinese spelling error correction method of sampling word segmentation and reorganization of the present invention;

[0060] Figure 6 This is a functional module diagram of the first embodiment of the Chinese spelling correction device for sampling, segmentation and reorganization of the present invention.

[0061] The purpose, features and advantages of the present invention will be further described with reference to the accompanying drawings and in conjunction with the embodiments. DETAILED DESCRIPTION

[0062] It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.

[0063] The solution of the embodiment of the present invention is mainly: by obtaining all reasoning trajectories of preset large language models (LLMs); performing word-meaning unit segmentation on the target sample sentences and input sentences in all the reasoning trajectories, aligning the sentences in all the reasoning trajectories according to the word segmentation results of the input sentences, merging and optimizing the alignment results, and obtaining optimized alignment results; scoring and screening the optimized alignment results to obtain Chinese spelling correction results, and being able to trace back all trajectories of LLMs in the reasoning process in a depth-first manner, mine all contents generated by LLMs, and make full use of their rich language capabilities. It can fully mine the contents generated by LLMs in the reasoning process and use these contents to reconstruct more accurate correction results, which significantly improves the performance of both the prompt-based and supervised fine-tuning-based LLMs on CSC tasks, and solves the technical problem of poor performance of both the prompt-based and supervised fine-tuning-based LLMs on CSC tasks in the prior art.

[0064] Reference Figure 1 , Figure 1 This is a schematic diagram of the device structure of the hardware operating environment involved in the embodiment of the present invention.

[0065] like Figure 1 As shown, the device may include: a processor 1001, such as a CPU, a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. The communication bus 1002 is used to implement communication between these components. The user interface 1003 may include a display and an input unit such as a keyboard. Optionally, the user interface 1003 may also include a standard wired interface or a wireless interface. The network interface 1004 may optionally include a standard wired interface or a wireless interface (such as a Wi-Fi interface). The memory 1005 may be a high-speed RAM memory or a non-volatile memory, such as a disk storage. The memory 1005 may also be a storage device independent of the processor 1001.

[0066] Those skilled in the art will understand that Figure 1 The device structure shown in the figure does not constitute a limitation of the device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.

[0067] like Figure 1 As shown, the memory 1005 as a storage medium may include an operating device, a network communication module, a user interface module, and a sample word segmentation and reorganization Chinese spelling correction program.

[0068] The device of the present invention calls the sampled word segmentation and reorganization Chinese spelling correction program stored in the memory 1005 through the processor 1001 and performs the following operations:

[0069] Get all the inference traces of the preset large language model LLMs;

[0070] Performing word segmentation on the target sample sentences and input sentences in all the reasoning trajectories, aligning the sentences in all the reasoning trajectories according to the word segmentation results of the input sentences, and merging and optimizing the alignment results to obtain an optimized alignment result;

[0071] The optimized alignment results are scored and screened to obtain Chinese spelling correction results.

[0072] The device of the present invention calls the sampled word segmentation and reorganization Chinese spelling correction program stored in the memory 1005 through the processor 1001, and further performs the following operations:

[0073] A depth-first multi-trajectory sampling (DFMTS) method is used to perform depth-first backtracking on the preset large language models (LLMs) to obtain all reasoning trajectories of the preset large language models (LLMs).

[0074] The device of the present invention calls the sampled word segmentation and reorganization Chinese spelling correction program stored in the memory 1005 through the processor 1001, and further performs the following operations:

[0075] Get the list of token trajectories for unfinished reasoning in the preset large language model (LLMs);

[0076] Inferring the token trajectory list according to the preset sampling cardinality and sampling the next token, and recording the initial inference trajectory of each token;

[0077] The initial reasoning trajectory is depth-first backtracked using a depth-first multi-trajectory sampling (DFMTS) method until all trajectories in the initial reasoning trajectory end with an end marker, thereby obtaining all reasoning trajectories of the preset large language model (LLMs).

[0078] The device of the present invention calls the sampled word segmentation and reorganization Chinese spelling correction program stored in the memory 1005 through the processor 1001, and further performs the following operations:

[0079] Perform depth-first backtracking on the initial reasoning trajectory using a depth-first multi-trajectory sampling (DFMTS) method;

[0080] When detecting that the token of the current trajectory in the initial reasoning trajectory is a reasoning end marker, updating the token on the current trajectory to the reasoning trajectory;

[0081] When it is detected that the token of the current trajectory in the initial reasoning trajectory is not an inference end marker, the token on the current trajectory is added to the token list of the current trajectory, and the reasoning is continued until all trajectories in the initial reasoning trajectory end with an end marker, thereby obtaining all the inference trajectories of the preset large language model LLMs.

[0082] The device of the present invention calls the sampled word segmentation and reorganization Chinese spelling correction program stored in the memory 1005 through the processor 1001, and further performs the following operations:

[0083] Perform word segmentation processing on the target sample sentences and input sentences in all the reasoning trajectories, align the word segmentation results of the target sample sentences by editing distance according to the word segmentation results of the input sentences to obtain an alignment result, and optimize the alignment result by a preset word segmentation merging optimization algorithm to obtain an optimized alignment result.

[0084] The device of the present invention calls the sampled word segmentation and reorganization Chinese spelling correction program stored in the memory 1005 through the processor 1001, and further performs the following operations:

[0085] Perform word segmentation processing on the target sample sentence and the input sentence in the reasoning track by using a preset word segmenter to obtain a word segmentation result;

[0086] Using an alignment algorithm based on edit distance, the word segmentation result of the target sample sentence is aligned with the word segmentation result of the input sentence to obtain an alignment result tuple;

[0087] Obtain the tuple index that caused the exception in the alignment result tuple;

[0088] Constructing alignment sub-rules for the sentence according to the tuple index, and merging all the alignment sub-rules into a rule list;

[0089] The alignment result of the target sample sentence and the alignment result of the input sentence are uniformly merged and optimized according to the rule list to obtain an optimized alignment result.

[0090] The device of the present invention calls the sampled word segmentation and reorganization Chinese spelling correction program stored in the memory 1005 through the processor 1001, and further performs the following operations:

[0091] Performing pronunciation scoring on the optimized alignment results from three dimensions: initial consonant, final consonant, and tone to obtain an initial consonant score, a final consonant score, and a tone score;

[0092] The pronunciation score is obtained by calculating the following formula based on the preset weight, the initial consonant score, the final consonant score and the tone score:

[0093]

[0094] in, Score for pronunciation. Score the initial consonants. Score the finals. Score the tone. Assign weights to initial consonants, Assign weights to finals. assign weights to tones;

[0095] The glyph similarity score of the optimized alignment result is scored based on seven feature dimensions: four-corner code, radical, word frequency, number of strokes, decomposition structure, construction structure and stroke order. The glyph similarity score is obtained by the following formula:

[0096]

[0097] in, is the glyph similarity score, Indicates the The similarity score of the features, , Indicates the The weight of the feature, , is the normalization factor;

[0098] The final score of the optimized alignment result is determined by the following formula:

[0099]

[0100] in, For the final score, Score for pronunciation. Score the glyph similarity;

[0101] Obtain the word sense cosine similarity between the input sentence segmentation and the sample sentence segmentation in the optimized alignment result, and use the word sense cosine similarity as the word sense score:

[0102]

[0103] in, Score word meanings. To segment the input sentence, Segment the sampled sentences. for word2vec word vector, for word2vec word vector;

[0104] Forming a candidate segmentation list based on the input sentence segmentation and the sampled sentence segmentation, and revising the final scores of the candidate segmentations in the candidate segmentation list based on the word meaning scores;

[0105] The candidate segmentation with the highest score in the candidate segmentation list is taken as the best candidate segmentation, a sentence composed of all the best candidate segmentations is taken as the final error-corrected sentence, and the final error-corrected sentence is used as the Chinese spelling correction result.

[0106] Through the above scheme, this embodiment obtains all reasoning trajectories of preset large language models (LLMs); performs word-meaning unit segmentation on the target sample sentences and input sentences in all the reasoning trajectories, aligns the sentences in all the reasoning trajectories according to the word segmentation results of the input sentences, merges and optimizes the alignment results to obtain optimized alignment results; scores and filters the optimized alignment results to obtain Chinese spelling correction results. It can trace back all trajectories of LLMs in the reasoning process in a depth-first manner, mine all contents generated by LLMs, and make full use of their rich language capabilities. It can fully mine the contents generated by LLMs in the reasoning process and use these contents to reconstruct more accurate correction results, which significantly improves the performance of both prompt-based and supervised fine-tuning-based LLMs on CSC tasks.

[0107] Based on the above hardware structure, an embodiment of the Chinese spelling correction method of sampling, segmentation and reorganization of the present invention is proposed.

[0108] Reference Figure 2 , Figure 2 This is a flow chart of the first embodiment of the Chinese spelling correction method for sampling, segmentation, and reorganization of words according to the present invention.

[0109] In a first embodiment, the Chinese spelling error correction method for sampling word segmentation and reorganization includes the following steps:

[0110] Step S10: Obtain all reasoning trajectories of the preset large language model (LLMs).

[0111] It should be noted that the reasoning trajectory refers to all reasoning trajectories generated by the preset large language model LLMs during the reasoning process.

[0112] Step S20: performing word segmentation on the target sample sentences and the input sentences in all the reasoning trajectories, aligning the sentences in all the reasoning trajectories according to the word segmentation results of the input sentences, merging and optimizing the alignment results, and obtaining an optimized alignment result.

[0113] It should be understood that the target sampled sentences are several branch sentences inferred by the reasoning trajectory, that is, all sentences composed of the reasoning trajectories obtained using the depth-first multi-trajectory sampling (DFMTS) method. The input sentence is the sentence input by the user, that is, the sentence that needs to be corrected. Different reasoning trajectories can form different sampled correction sentences. The target sampled sentences and the input sentences are segmented, aligned, and merged through all the reasoning trajectories to obtain the corresponding merged results.

[0114] Step S30: Score and screen the optimized alignment results to obtain Chinese spelling correction results.

[0115] It is understandable that after scoring and screening the optimized alignment results, Chinese spelling correction results can be obtained.

[0116] Furthermore, the step S30 specifically includes the following steps:

[0117] Performing pronunciation scoring on the optimized alignment results from three dimensions: initial consonant, final consonant, and tone to obtain an initial consonant score, a final consonant score, and a tone score;

[0118] The pronunciation score is obtained by calculating the following formula based on the preset weight, the initial consonant score, the final consonant score and the tone score:

[0119]

[0120] in, Score for pronunciation. Score the initial consonants. Score the finals. Score the tone. Assign weights to initial consonants, Assign weights to finals. assign weights to tones;

[0121] The glyph similarity score of the optimized alignment result is scored based on seven feature dimensions: four-corner code, radical, word frequency, number of strokes, decomposition structure, construction structure and stroke order. The glyph similarity score is obtained by the following formula:

[0122]

[0123] in, is the glyph similarity score, Indicates the The similarity score of the features, , Indicates the The weight of the feature, , is the normalization factor;

[0124] The final score of the optimized alignment result is determined by the following formula:

[0125]

[0126] in, For the final score, Score for pronunciation. Score the glyph similarity;

[0127] Obtain the word sense cosine similarity between the input sentence segmentation and the sample sentence segmentation in the optimized alignment result, and use the word sense cosine similarity as the word sense score:

[0128]

[0129] in, Score word meanings. To segment the input sentence, Segment the sampled sentences. for word2vec word vector, for word2vec word vector;

[0130] Forming a candidate segmentation list based on the input sentence segmentation and the sampled sentence segmentation, and revising the final scores of the candidate segmentations in the candidate segmentation list based on the word meaning scores;

[0131] The candidate segmentation with the highest score in the candidate segmentation list is taken as the best candidate segmentation, a sentence composed of all the best candidate segmentations is taken as the final error-corrected sentence, and the final error-corrected sentence is used as the Chinese spelling correction result.

[0132] It should be noted that the Chinese pinyin of the input sentence segmentation and the sampled sentence segmentation are comprehensively scored from the three dimensions of initial consonants, finals and tones, and different weights are assigned to initial consonants, finals and tones. These weights are calculated by the number of pronunciation error types in the CSCD-NS dataset using the Softmax normalization method.

[0133] As shown in Table 1 below, Table 1 is a statistical table of pronunciation error types:

[0134]

[0135] The Softmax normalization method can better distribute the weights of the three error types, so that all types of errors can better affect the final score. The calculation process is shown in the following formula:

[0136]

[0137] in, is the number of errors, is the normalized value:

[0138]

[0139] The phonetic score of the word segmentation is , which is calculated as shown in the following formula:

[0140]

[0141] in S initial , , Respectively represent the scores of initial consonants, finals, and tones. When the initial consonants, finals, and tones of the sampled sentence segmentation are the same as those of the input sentence segmentation, the corresponding score is 1, otherwise it is 0. , , They represent the distribution weights of initials, finals, and tones respectively.

[0142] In terms of glyph similarity, by adjusting the weights, we use the seven feature dimensions of the four-corner encoding of Chinese characters, radicals, word frequency, number of strokes, decomposition structure, construction structure and stroke order to score the glyph similarity between the input sentence segmentation and the sampled sentence segmentation; due to the different numerical ranges of each feature, the average normalization method is used to calculate the final glyph similarity score. , the calculation method is shown in the following formula:

[0143]

[0144] in, Indicates the The similarity score of the features, , w i represents the weight of the feature, w i , is the normalization factor; the adjusted feature dimension weights are shown in Table 2 below, which is the glyph similarity feature weight table:

[0145]

[0146] A candidate segmentation list is formed based on the input sentence segmentation and the sampled sentence segmentation, and the final score of each segmentation in the candidate segmentation list is The candidate segmentation word with the highest score is the best candidate segmentation word, which can better meet the requirement of the CSC task that the characters before and after modification have a certain degree of phonetic or glyph similarity.

[0147] By training a word2vec model, the cosine similarity between the word segmentation of the input sentence and the candidate word segmentation is calculated as the word sense score , the calculation process of the model is shown in the following formula:

[0148]

[0149] in, , The words and word2vec word vector, The range is between [-1, 1]. A value close to 1 indicates similar semantics, a value close to 0 indicates irrelevance, and a negative value indicates opposite semantics.

[0150] Based on the observed phenomenon, a word meaning penalty mechanism can be designed. First, when the word meaning score of a segmentation is too high, the possibility of it becoming the best segmentation is reduced by lowering the final score of the segmentation. Specifically, as shown in the following formula, let the penalty coefficient be , , the penalty threshold is , .

[0151]

[0152] After obtaining the final scores of all candidate word segments, filter them according to the word meaning score. When the word meaning score exceeds its final score, the word segment is replaced with the input word segment, and its final score is set to a fixed value of 1, as shown in the following formula; The candidate word list for , the final score list is , the best candidate for this word is .

[0153]

[0154]

[0155]

[0156]

[0157] in, Indicates the candidate participles, Indicates the The scores of candidate segmentation words; finally, the candidate segmentation list after modification is and the final score list is , get the best candidate word segmentation, as shown in the following formula, The candidate segmentation word with the highest score is the best candidate segmentation word.

[0158]

[0159] In this embodiment , .

[0160] The sentence formed by combining all the best segmentation words in the candidate segmentation list is the final error-corrected sentence.

[0161] Through the above scheme, this embodiment obtains all reasoning trajectories of preset large language models (LLMs); performs word-meaning unit segmentation on the target sample sentences and input sentences in all the reasoning trajectories, aligns the sentences in all the reasoning trajectories according to the word segmentation results of the input sentences, merges and optimizes the alignment results to obtain optimized alignment results; scores and filters the optimized alignment results to obtain Chinese spelling correction results. It can trace back all trajectories of LLMs in the reasoning process in a depth-first manner, mine all contents generated by LLMs, and make full use of their rich language capabilities. It can fully mine the contents generated by LLMs in the reasoning process and use these contents to reconstruct more accurate correction results, which significantly improves the performance of both prompt-based and supervised fine-tuning-based LLMs on CSC tasks.

[0162] Furthermore, Figure 3 This is a flow chart of the second embodiment of the Chinese spelling error correction method for sampling, segmentation, and reorganization of the present invention. Figure 3 As shown, based on the first embodiment, a second embodiment of the Chinese spelling correction method for sampling, segmentation and reorganization of the present invention is proposed. In this embodiment, step S10 specifically includes the following steps:

[0163] Step S11: Use the depth-first multi-trajectory sampling (DFMTS) method to perform depth-first backtracking on the preset large language models (LLMs) to obtain all reasoning trajectories of the preset large language models (LLMs).

[0164] It should be noted that the depth-first multi-trace sampling (DFMTS) method can be used to perform depth-first backtracing on the preset large language models (LLMs), thereby obtaining all inference traces of the preset large language models (LLMs).

[0165] Furthermore, the step S11 specifically includes the following steps:

[0166] Get the list of token trajectories for unfinished reasoning in the preset large language model (LLMs);

[0167] Inferring the token trajectory list according to the preset sampling cardinality and sampling the next token, and recording the initial inference trajectory of each token;

[0168] The initial reasoning trajectory is depth-first backtracked using a depth-first multi-trajectory sampling (DFMTS) method until all trajectories in the initial reasoning trajectory end with an end marker, thereby obtaining all reasoning trajectories of the preset large language model (LLMs).

[0169] It can be understood that when multiple possible tokens appear in the probability distribution of the large language model LLMs during the token reasoning process, these uncertain tokens are recorded at the same time according to the sampling cardinality, and the reasoning trajectories of these tokens are also recorded, that is, the token trajectory list is inferred and the next token is sampled according to the preset sampling cardinality, and the initial reasoning trajectory of each token is recorded; the depth-first multi-trajectory sampling DFMTS method can be used to perform depth-first backtracing on the initial reasoning trajectory until all trajectories in the initial reasoning trajectory end with an end marker, thereby obtaining all the reasoning trajectories of the preset large language model LLMs.

[0170] Furthermore, the step uses a depth-first multi-trajectory sampling (DFMTS) method to perform depth-first backtracking on the initial reasoning trajectory until all trajectories in the initial reasoning trajectory end with an end marker, thereby obtaining all reasoning trajectories of the preset large language model (LLMs), specifically including the following steps:

[0171] Perform depth-first backtracking on the initial reasoning trajectory using a depth-first multi-trajectory sampling (DFMTS) method;

[0172] When detecting that the token of the current trajectory in the initial reasoning trajectory is a reasoning end marker, updating the token on the current trajectory to the reasoning trajectory;

[0173] When it is detected that the token of the current trajectory in the initial reasoning trajectory is not an inference end marker, the token on the current trajectory is added to the token list of the current trajectory, and the reasoning is continued until all trajectories in the initial reasoning trajectory end with an end marker, thereby obtaining all the inference trajectories of the preset large language model LLMs.

[0174] In the specific implementation, let the sampling base be , assuming Take 5, LLMs has inferred the previous Tokens are lists , assuming that in the reasoning token exists A list of possible tokens ; The sampling process is shown in the following formula, the list All tokens in are sampled and their reasoning traces are recorded :

[0175]

[0176]

[0177]

[0178] in In the reasoning process possible tokens, Indicates the probability distribution The token corresponding to the high probability value.

[0179] In a depth-first manner, along Continue reasoning with the unfinished token track list in the input. The input is the token track list of unfinished reasoning. , inference trajectory list , output the updated trajectory list ; First initialize the lists N and M used by the algorithm, as well as the variables ; From the trajectory list Inference obtains the next token sampling list N, calls MultSample to traverse the token sampling list N: If the token is the inference end mark, it means that the inference of this trajectory is completed, and the token on the trajectory is updated to If the token is not the end marker, add the token to the token list of the trajectory and continue to reason until all reasoning trajectories end with the end marker; finally, return the updated trajectory list L.

[0180] The reasoning process of L1 in the inference trajectory list L obtained by the above formula is used as an example to illustrate the reasoning process of the DFMTS method, as shown in the following formula; the model is based on As the token track list T of the unfinished reasoning, continue to reason backward, let is the token that marks the end of reasoning. Assuming that two possible tokens m1 and m2 appear at the mth token in the reasoning process, and the reasoning ends at m+1, the trajectory generated during the reasoning process of L1 is , then L The trajectory is updated to .

[0181]

[0182]

[0183]

[0184] After decoding the tokens in all the trajectories through the vocabulary, we can get a list of all the error-corrected sentences generated by LLMs.

[0185]

[0186]

[0187] It can be understood that the process of Algorithm 1 (DFMTS inference algorithm) is as follows: receiving the incomplete inference token trajectory list T and the inference trajectory list L, first initializing a new inference token list N, calling the inference function to infer T to obtain a new token and store it in N, then using the MultiSample function to process T and N, and finally returning the updated trajectory list L. This is the main process that drives trajectory inference.

[0188] It should be understood that the process of Algorithm 2 (MultiSample function) receives the list of token trajectories T of unfinished reasoning and the list of reasoning trajectories L, initializes the reasoning end marker tend and list M, traverses the newly inferred token, and if the token is tend, updates L; if not, adds the token to T, infers M again, recursively calls itself to process T and M, and finally removes the token. After the loop, it returns the updated L, which is responsible for refining the iterative logic of trajectory reasoning.

[0189] Through the above scheme, this embodiment uses the depth-first multi-trajectory sampling (DFMTS) method to perform depth-first backtracking on the preset large language model (LLMs) to obtain all reasoning trajectories of the preset large language model (LLMs), thereby improving the speed and efficiency of Chinese spelling correction in sampled word segmentation and reorganization.

[0190] Furthermore, Figure 4 This is a flow chart of the third embodiment of the Chinese spelling correction method for sampling, segmentation, and reorganization of the present invention. Figure 4 As shown, based on the first embodiment, a third embodiment of the Chinese spelling correction method for sampling, segmentation and reorganization of the present invention is proposed. In this embodiment, step S20 specifically includes the following steps:

[0191] Step S21: perform word segmentation processing on the target sample sentences and input sentences in all the reasoning trajectories, align the word segmentation results of the target sample sentences by the edit distance according to the word segmentation results of the input sentences to obtain an alignment result, and optimize the alignment result by a preset word segmentation merging optimization algorithm to obtain an optimized alignment result.

[0192] It should be noted that, by performing word segmentation processing on the target sample sentences and the input sentences in all the reasoning trajectories, the word segmentation results of the target sample sentences can be aligned by the edit distance according to the word segmentation results of the input sentences to obtain an alignment result, and the alignment result can be optimized by a preset word segmentation merging optimization algorithm to obtain an optimized alignment result.

[0193] In the specific implementation, the content output by LLMs is rich and diverse. The error-corrected sentences sampled by the DFMTS method may have incorrect collocation of sentence characters, as shown in Table 3 below. Table 3 is a schematic table of the results of the multi-sampled error-corrected sentence list:

[0194]

[0195] Furthermore, the step S21 specifically includes the following steps:

[0196] Perform word segmentation processing on the target sample sentence and the input sentence in the reasoning track by using a preset word segmenter to obtain a word segmentation result;

[0197] Using an alignment algorithm based on edit distance, the word segmentation result of the target sample sentence is aligned with the word segmentation result of the input sentence to obtain an alignment result tuple;

[0198] Obtain the tuple index that caused the exception in the alignment result tuple;

[0199] Constructing alignment sub-rules for the sentence according to the tuple index, and merging all the alignment sub-rules into a rule list;

[0200] The alignment result of the target sample sentence and the alignment result of the input sentence are uniformly merged and optimized according to the rule list to obtain an optimized alignment result.

[0201] It can be understood that the depth-first multi-trajectory sampling (DFMTS) method is used to obtain all sampled sentences to form a correction list. The input sentence and all sentences in the list are segmented, and then the segmentation results of each sentence in the correction list are aligned with the segmentation results of the input sentence using an alignment method based on edit distance. Finally, after optimization by the merging algorithm, the segmentations of all sentences in the correction list that are aligned with the input sentence segmentation form the candidate segmentations of the input sentence.

[0202] In the specific implementation, see Figure 5 , Figure 5 Schematic diagram of the word segmentation, alignment and merging process in the Chinese spelling error correction method of the present invention. Figure 5 As shown in the figure, LLMs uses tokens as units in the reasoning process. Tokens are used as word mappings in the vocabulary, and the output results already have the effect of word segmentation. However, most of the word segmenters of LLMs are trained by BPE-like word segmentation algorithms. The word segmentation results are more in line with the reasoning characteristics of LLMs but deviate from the meaning of the words themselves. In order to obtain word segmentation results with actual word meanings, the jieba word segmenter is chosen to segment the sentences. It combines dictionary-based rule segmentation and statistical-based word segmentation methods, and can efficiently segment Chinese text into meaningful vocabulary units. Assuming the sentence Depend on characters, the word segmenter will Divided into The word segmentation process is shown in the following formula:

[0203]

[0204] in, Expressing sentences No. characters, Indicates the word segmentation process, Expressing sentences After the participle participles with actual meaning, and .

[0205] After word segmentation, the input sentence is aligned with the sentences in the error correction list using an alignment algorithm based on edit distance. Edit distance is a measure of the difference between two strings. It is based on dynamic programming (DP) and calculates the minimum transformation cost between two strings. Suppose sentence S has two strings and , the lengths are 、 , the dynamic programming (DP) matrix is ,in express Convert to The minimum transformation cost is calculated as follows:

[0206]

[0207] in,

[0208] By backtracking For a matrix, the optimal alignment path can be obtained; taking , as an example, first perform word segmentation according to the following formula:

[0209]

[0210]

[0211] Then, the matrix obtained through the alignment algorithm based on the edit distance is shown in Table 4 below. Table 4 is a schematic table of the DP matrix based on the edit distance algorithm:

[0212]

[0213] By backtracking this matrix, the and optimal alignment path can be obtained, as shown in Table 5 below. Table 5 is a and schematic table of the optimal alignment path:

[0214]

[0215] However, as shown in the result after alignment in Figure 5 , the alignment methods of the sentences in the error correction list are not the same, and there is a situation where the alignment object of word segmentation is empty, so the word segmentation result needs to be further optimized. During the experiment, it was found that due to sentence errors, the word segmentation results of the error sentence and the corrected word segmentation results cannot be aligned. For example, the word segmentation result of "我门" in the error sentence is , and the word segmentation result of "我们" in the correct sentence is . The aligned tuples are "(我, 我们)" and "(门, _)", while the correct aligned tuple should be "(我门, 我们)".

[0216] Therefore, a word segmentation merging and optimization algorithm is designed to further merge and optimize. The input of the algorithm is a list composed of tuple pairs of word segmentation alignments of the error correction sentence and the input sentence , and a list composed of all generated by all error correction sentences in all error correction lists . The output is in the updated through algorithm optimization ; first initialize the rule list and the sub-rule list ; then start traversing in , find the tuple indices in that may cause exceptions, and construct the alignment sub-rules of the sentences where these indices are located , all are combined into a rule list , and all sampled sentences in the error correction list will be uniformly combined according to the rules in to ensure that the word segmentation results of the input sentence and all sentences in the error correction list are aligned in the same way.

[0217] Specifically, assume there is a list of alignment results in , which is composed of tuple pairs . Among them, is the th word segmentation in the input sentence, and is the rd word segmentation in the error correction sentence:

[0218]

[0219] will traverse the tuples in from front to back. When the lengths of the two elements in the tuple are not equal, start recording the traversal index until the lengths of the two elements traversed are equal; assume there is a tuple pair in where the element lengths are not equal. At this time, the alignment sub-rule obtained by the word segmentation merging optimization algorithm, that is, the merging rule obtained in this error correction sentence is to merge the word segmentations at indices 2 to 4 and indices 8 to 9 in the alignment list into one word segmentation respectively, and the word segmentation at index 6 remains unchanged; to ensure that the alignment methods of all error correction sentences are the same, all sub-rules are merged into the total merging rule , and according to , start the merging operation on all sentences including the input sentence; after the alignment is optimized, if there is still a situation where the alignment object is empty, edit it according to the alignment operation method in the edit distance algorithm. Taking the alignment result of sampling 2 in Figure 5 as an example, there is an alignment character pair "( _, back)", corresponding to the "delete" operation in the edit distance algorithm, and the word segmentation needs to be deleted in the error correction sentence; if there is a character pair of the word segmentation "( , _ )" then it corresponds to the "insert" operation, and a word segmentation needs to be inserted in the error correction sentence.

[0220] After the above word segmentation, alignment, and merging operations, each word in the input sentence can find a corresponding word in the word segmentation results of each sentence in the correction list. These word segmentations form a candidate word segmentation list for the input sentence segmentation. By finding the best candidate word from the candidate word segmentation list for each word and forming a sentence, the best correction sentence can be obtained. This can alleviate the situation of incorrect character collocation in the correction list and, by controlling the length relationship between the input sentence word segmentation and the candidate word segmentation, make the best correction sentence more consistent with the requirement of the CSC task that the output and input sentences have the same number of characters.

[0221]

[0222] It can be understood that the process of Algorithm 3 "Word segmentation merging optimization algorithm" is as follows: first initialize the rule list R and the sub-rule list r; then traverse each word segmentation alignment tuple list m in the input list M, and then traverse the tuples in m. If the lengths of the words before and after the tuple are different, add its index to r. If the lengths are the same and r is not empty, add r to R and clear r; after completing the traversal, traverse each m in M ​​again, use the merge function to merge m according to R, add the processed m to the new list M', and finally return the updated M'. The core is to first mine the tuple indexes with inconsistent word segmentation lengths to form rules, and then use the rules to optimize the word segmentation alignment results.

[0223] This embodiment uses the above scheme to perform word segmentation processing on the target sample sentences and input sentences in all the reasoning trajectories, align the word segmentation results of the target sample sentences by editing distance according to the word segmentation results of the input sentences, and obtain an alignment result. The alignment result is optimized by a preset word segmentation merging optimization algorithm to obtain an optimized alignment result. This embodiment can backtrack all trajectories of LLMs in the reasoning process in a depth-first manner, mine all content generated by LLMs, make full use of their rich language capabilities, fully mine the content generated by LLMs in the reasoning process, and improve the performance of Chinese spelling correction in sampled word segmentation and reorganization.

[0224] Accordingly, the present invention further provides a Chinese spelling correction device for sampling, segmentation and reorganization.

[0225] Reference Figure 6 , Figure 6 This is a functional module diagram of the first embodiment of the Chinese spelling correction device for sampling, segmentation and reorganization of the present invention.

[0226] In a first embodiment of the Chinese spelling error correction device for sampling, segmentation and reorganization of the present invention, the Chinese spelling error correction device for sampling, segmentation and reorganization of the present invention comprises:

[0227] The trajectory acquisition module 10 is used to obtain all reasoning trajectories of the preset large language models LLMs.

[0228] The merging module 20 is used to perform word segmentation on the target sample sentences and the input sentences in all the reasoning trajectories, align the sentences in all the reasoning trajectories according to the word segmentation results of the input sentences, merge and optimize the alignment results, and obtain an optimized alignment result.

[0229] The scoring and screening module 30 is used to score and screen the optimized alignment results to obtain Chinese spelling correction results.

[0230] The trajectory acquisition module 10 is further configured to perform depth-first backtracking on the preset large language models (LLMs) using a depth-first multi-trajectory sampling (DFMTS) method to obtain all inference trajectories of the preset large language models (LLMs).

[0231] The trajectory acquisition module 10 is further configured to obtain a list of token trajectories for unfinished reasoning in a preset large language model (LLMs); perform reasoning on the token trajectory list and sample the next token according to a preset sampling cardinality, and record the initial reasoning trajectory of each token; perform depth-first backtracing on the initial reasoning trajectory using a depth-first multi-trajectory sampling (DFMTS) method until all trajectories in the initial reasoning trajectory end with an end marker, thereby obtaining all reasoning trajectories of the preset large language model (LLMs).

[0232] The trajectory acquisition module 10 is further configured to perform depth-first backtracing on the initial reasoning trajectory using a depth-first multi-trajectory sampling (DFMTS) method; when detecting that the token of the current trajectory in the initial reasoning trajectory is an inference end marker, updating the token on the current trajectory to the inference trajectory; when detecting that the token of the current trajectory in the initial reasoning trajectory is not an inference end marker, adding the token on the current trajectory to the token list of the current trajectory, and continuing to reason backward until all trajectories in the initial reasoning trajectory end with an end marker, thereby obtaining all inference trajectories of the preset large language model (LLMs).

[0233] The merging module 20 is further configured to perform word segmentation processing on the target sample sentences and the input sentences in all the reasoning trajectories, align the word segmentation results of the target sample sentences by using the edit distance according to the word segmentation results of the input sentences to obtain an alignment result, and optimize the alignment result by using a preset word segmentation merging optimization algorithm to obtain an optimized alignment result.

[0234] The merging module 20 is further configured to perform word segmentation processing on the target sampling sentence and the input sentence in the reasoning track through a preset word segmenter to obtain a word segmentation result; align the word segmentation result of the target sampling sentence with the word segmentation result of the input sentence using an alignment algorithm based on edit distance to obtain an alignment result tuple; obtain the tuple index that causes the exception in the alignment result tuple; construct the alignment sub-rule of the sentence according to the tuple index, and merge all the alignment sub-rules into a rule list; and perform unified merging and optimization on the alignment result of the target sampling sentence and the alignment result of the input sentence according to the rule list to obtain an optimized alignment result.

[0235] The scoring and screening module 30 is further configured to perform pronunciation scoring on the optimized alignment results based on three dimensions: initial consonant, final consonant, and tone, to obtain an initial consonant score, a final consonant score, and a tone score;

[0236] The pronunciation score is obtained by calculating the following formula based on the preset weight, the initial consonant score, the final consonant score and the tone score:

[0237]

[0238] in, Score for pronunciation. Score the initial consonants. Score the finals. Score the tone. Assign weights to initial consonants, Assign weights to finals. assign weights to tones;

[0239] The glyph similarity score of the optimized alignment result is scored based on seven feature dimensions: four-corner code, radical, word frequency, number of strokes, decomposition structure, construction structure and stroke order. The glyph similarity score is obtained by the following formula:

[0240]

[0241] in, is the glyph similarity score, Indicates the The similarity score of the features, , Indicates the The weight of the feature, , is the normalization factor;

[0242] The final score of the optimized alignment result is determined by the following formula:

[0243]

[0244] in, For the final score, Score for pronunciation. Score the glyph similarity;

[0245] Obtain the word sense cosine similarity between the input sentence segmentation and the sample sentence segmentation in the optimized alignment result, and use the word sense cosine similarity as the word sense score:

[0246]

[0247] in, Score word meanings. To segment the input sentence, Segment the sampled sentences. for word2vec word vector, for word2vec word vector;

[0248] Forming a candidate segmentation list based on the input sentence segmentation and the sampled sentence segmentation, and revising the final scores of the candidate segmentations in the candidate segmentation list based on the word meaning scores;

[0249] The candidate segmentation with the highest score in the candidate segmentation list is taken as the best candidate segmentation, a sentence composed of all the best candidate segmentations is taken as the final error-corrected sentence, and the final error-corrected sentence is used as the Chinese spelling correction result.

[0250] Among them, the steps implemented by each functional module of the sampling word segmentation and reorganization Chinese spelling correction device can refer to the various embodiments of the sampling word segmentation and reorganization Chinese spelling correction method of the present invention, and will not be repeated here.

[0251] In addition, an embodiment of the present invention further provides a storage medium, on which a sampled word segmentation and reorganization Chinese spelling correction program is stored. When the sampled word segmentation and reorganization Chinese spelling correction program is executed by a processor, the following operations are implemented:

[0252] Get all the inference traces of the preset large language model LLMs;

[0253] Performing word segmentation on the target sample sentences and input sentences in all the reasoning trajectories, aligning the sentences in all the reasoning trajectories according to the word segmentation results of the input sentences, and merging and optimizing the alignment results to obtain an optimized alignment result;

[0254] The optimized alignment results are scored and screened to obtain Chinese spelling correction results.

[0255] Furthermore, when the sampled word segmentation and reorganization Chinese spelling correction program is executed by the processor, the following operations are also implemented:

[0256] A depth-first multi-trajectory sampling (DFMTS) method is used to perform depth-first backtracking on the preset large language models (LLMs) to obtain all reasoning trajectories of the preset large language models (LLMs).

[0257] Furthermore, when the sampled word segmentation and reorganization Chinese spelling correction program is executed by the processor, the following operations are also implemented:

[0258] Get the list of token trajectories for unfinished reasoning in the preset large language model (LLMs);

[0259] Inferring the token trajectory list according to the preset sampling cardinality and sampling the next token, and recording the initial inference trajectory of each token;

[0260] The initial reasoning trajectory is depth-first backtracked using a depth-first multi-trajectory sampling (DFMTS) method until all trajectories in the initial reasoning trajectory end with an end marker, thereby obtaining all reasoning trajectories of the preset large language model (LLMs).

[0261] Furthermore, when the sampled word segmentation and reorganization Chinese spelling correction program is executed by the processor, the following operations are also implemented:

[0262] Perform depth-first backtracking on the initial reasoning trajectory using a depth-first multi-trajectory sampling (DFMTS) method;

[0263] When detecting that the token of the current trajectory in the initial reasoning trajectory is a reasoning end marker, updating the token on the current trajectory to the reasoning trajectory;

[0264] When it is detected that the token of the current trajectory in the initial reasoning trajectory is not an inference end marker, the token on the current trajectory is added to the token list of the current trajectory, and the reasoning is continued until all trajectories in the initial reasoning trajectory end with an end marker, thereby obtaining all the inference trajectories of the preset large language model LLMs.

[0265] Furthermore, when the sampled word segmentation and reorganization Chinese spelling correction program is executed by the processor, the following operations are also implemented:

[0266] Perform word segmentation processing on the target sample sentences and input sentences in all the reasoning trajectories, align the word segmentation results of the target sample sentences by editing distance according to the word segmentation results of the input sentences to obtain an alignment result, and optimize the alignment result by a preset word segmentation merging optimization algorithm to obtain an optimized alignment result.

[0267] Furthermore, when the sampled word segmentation and reorganization Chinese spelling correction program is executed by the processor, the following operations are also implemented:

[0268] Perform word segmentation processing on the target sample sentence and the input sentence in the reasoning track by using a preset word segmenter to obtain a word segmentation result;

[0269] Using an alignment algorithm based on edit distance, the word segmentation result of the target sample sentence is aligned with the word segmentation result of the input sentence to obtain an alignment result tuple;

[0270] Obtain the tuple index that caused the exception in the alignment result tuple;

[0271] Constructing alignment sub-rules for the sentence according to the tuple index, and merging all the alignment sub-rules into a rule list;

[0272] The alignment result of the target sample sentence and the alignment result of the input sentence are uniformly merged and optimized according to the rule list to obtain an optimized alignment result.

[0273] Furthermore, when the sampled word segmentation and reorganization Chinese spelling correction program is executed by the processor, the following operations are also implemented:

[0274] Performing pronunciation scoring on the optimized alignment results from three dimensions: initial consonant, final consonant, and tone to obtain an initial consonant score, a final consonant score, and a tone score;

[0275] The pronunciation score is obtained by calculating the following formula based on the preset weight, the initial consonant score, the final consonant score and the tone score:

[0276]

[0277] in, Score for pronunciation. Score the initial consonants. Score the finals. Score the tone. Assign weights to initial consonants, Assign weights to finals. assign weights to tones;

[0278] The glyph similarity score of the optimized alignment result is scored based on seven feature dimensions: four-corner code, radical, word frequency, number of strokes, decomposition structure, construction structure and stroke order. The glyph similarity score is obtained by the following formula:

[0279]

[0280] in, is the glyph similarity score, Indicates the The similarity score of the features, , Indicates the The weight of the feature, , is the normalization factor;

[0281] The final score of the optimized alignment result is determined by the following formula:

[0282]

[0283] in, For the final score, Score for pronunciation. Score the glyph similarity;

[0284] Obtain the word sense cosine similarity between the input sentence segmentation and the sample sentence segmentation in the optimized alignment result, and use the word sense cosine similarity as the word sense score:

[0285]

[0286] in, Score word meanings. To segment the input sentence, Segment the sampled sentences. for word2vec word vector, for word2vec word vector;

[0287] Forming a candidate segmentation list based on the input sentence segmentation and the sampled sentence segmentation, and revising the final scores of the candidate segmentations in the candidate segmentation list based on the word meaning scores;

[0288] The candidate segmentation with the highest score in the candidate segmentation list is taken as the best candidate segmentation, a sentence composed of all the best candidate segmentations is taken as the final error-corrected sentence, and the final error-corrected sentence is used as the Chinese spelling correction result.

[0289] Those skilled in the art will understand that all or part of the steps in the above-mentioned implementation methods can be implemented by instructing related hardware through a program. The program is stored in a storage medium and includes a number of instructions for enabling a device (which may be a single-chip microcomputer, chip, etc.) or a processor to execute all or part of the steps of the method described in each embodiment of the present application; and the aforementioned storage medium is a computer-readable storage medium, including: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, and other media that can store program codes.

[0290] It should be noted that, in this document, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or apparatus comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or apparatus comprising the element.

[0291] The serial numbers of the above embodiments of the present invention are for description only and do not represent the advantages or disadvantages of the embodiments.

[0292] The above are only preferred embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention description and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. A Chinese spelling error correction method for sampling, segmentation and reorganization, characterized in that: The Chinese spelling error correction method for sampling word segmentation and reorganization comprises: Get all the inference traces of the preset large language model LLMs; Performing word segmentation on the target sample sentences and input sentences in all the reasoning trajectories, aligning the sentences in all the reasoning trajectories according to the word segmentation results of the input sentences, and merging and optimizing the alignment results to obtain an optimized alignment result; Scoring and screening the optimized alignment results to obtain Chinese spelling correction results; The step of obtaining all inference trajectories of the preset large language model LLMs includes: Use the depth-first multi-trajectory sampling (DFMTS) method to perform depth-first backtracking on the preset large language model (LLMs) to obtain all reasoning trajectories of the preset large language model (LLMs); The method of performing depth-first backtracking on the preset large language model LLMs using the depth-first multi-trajectory sampling (DFMTS) method to obtain all reasoning trajectories of the preset large language model LLMs includes: Get the list of token trajectories for unfinished reasoning in the preset large language model (LLMs); Inferring the token trajectory list according to the preset sampling cardinality and sampling the next token, and recording the initial inference trajectory of each token; The initial reasoning trajectory is depth-first backtracked using a depth-first multi-trajectory sampling (DFMTS) method until all trajectories in the initial reasoning trajectory end with an end marker, thereby obtaining all reasoning trajectories of the preset large language model (LLMs).

2. The Chinese spelling error correction method of sampling word segmentation and reorganization as claimed in claim 1, characterized in that: The depth-first multi-trajectory sampling (DFMTS) method is used to perform depth-first backtracking on the initial reasoning trajectory until all trajectories in the initial reasoning trajectory end with an end marker, thereby obtaining all reasoning trajectories of the preset large language model (LLMs), including: Perform depth-first backtracking on the initial reasoning trajectory using a depth-first multi-trajectory sampling (DFMTS) method; When detecting that the token of the current trajectory in the initial reasoning trajectory is a reasoning end marker, updating the token on the current trajectory to the reasoning trajectory; When it is detected that the token of the current trajectory in the initial reasoning trajectory is not an inference end marker, the token on the current trajectory is added to the token list of the current trajectory, and the reasoning is continued until all trajectories in the initial reasoning trajectory end with an end marker, thereby obtaining all the inference trajectories of the preset large language model LLMs.

3. The Chinese spelling error correction method of sampling word segmentation and reorganization as claimed in claim 1 is characterized in that: The step of performing word segmentation on the target sample sentences and the input sentences in all the reasoning trajectories, aligning the sentences in all the reasoning trajectories according to the word segmentation results of the input sentences, and merging and optimizing the alignment results to obtain an optimized alignment result includes: Perform word segmentation processing on the target sample sentences and input sentences in all the reasoning trajectories, align the word segmentation results of the target sample sentences by editing distance according to the word segmentation results of the input sentences to obtain an alignment result, and optimize the alignment result by a preset word segmentation merging optimization algorithm to obtain an optimized alignment result.

4. The Chinese spelling error correction method of sampling word segmentation and reorganization as claimed in claim 3 is characterized in that: The step of performing word segmentation processing on the target sample sentences and the input sentences in all the reasoning trajectories, aligning the word segmentation results of the target sample sentences by using the edit distance according to the word segmentation results of the input sentences to obtain an alignment result, and optimizing the alignment result by using a preset word segmentation merging optimization algorithm to obtain an optimized alignment result includes: Performing word segmentation processing on the target sample sentence and the input sentence in the reasoning trajectory by using a preset word segmenter to obtain a word segmentation result; Using an alignment algorithm based on edit distance, the word segmentation result of the target sample sentence is aligned with the word segmentation result of the input sentence to obtain an alignment result tuple; Obtain the tuple index that caused the exception in the alignment result tuple; Constructing alignment sub-rules for the sentence according to the tuple index, and merging all the alignment sub-rules into a rule list; The alignment result of the target sample sentence and the alignment result of the input sentence are uniformly merged and optimized according to the rule list to obtain an optimized alignment result.

5. The Chinese spelling error correction method of sampling word segmentation and reorganization as claimed in claim 1, characterized in that: Scoring and screening the optimized alignment results to obtain Chinese spelling correction results includes: Performing pronunciation scoring on the optimized alignment results from three dimensions: initial consonant, final consonant, and tone to obtain an initial consonant score, a final consonant score, and a tone score; The pronunciation score is obtained by calculating the following formula based on the preset weight, the initial consonant score, the final consonant score and the tone score: in, Score for pronunciation. Score the initial consonants. Score the finals. Score the tone. Assign weights to initial consonants, Assign weights to finals. assign weights to tones; The glyph similarity score of the optimized alignment result is scored based on seven feature dimensions: four-corner code, radical, word frequency, number of strokes, decomposition structure, construction structure and stroke order. The glyph similarity score is obtained by the following formula: in, is the glyph similarity score, Indicates the The similarity score of the features, , Indicates the The weight of the feature, , is the normalization factor; The final score of the optimized alignment result is determined by the following formula: in, For the final score, Score for pronunciation. Score the glyph similarity; Obtain the word sense cosine similarity between the input sentence segmentation and the sample sentence segmentation in the optimized alignment result, and use the word sense cosine similarity as the word sense score: in, Score word meanings. To segment the input sentence, Segment the sampled sentences. for word2vec word vector, for word2vec word vector; Forming a candidate segmentation list based on the input sentence segmentation and the sampled sentence segmentation, and revising the final scores of the candidate segmentations in the candidate segmentation list based on the word meaning scores; The candidate segmentation with the highest score in the candidate segmentation list is taken as the best candidate segmentation, a sentence composed of all the best candidate segmentations is taken as the final error-corrected sentence, and the final error-corrected sentence is used as the Chinese spelling correction result.

6. A Chinese spelling correction device for sampling, segmentation and reorganization, characterized in that: The Chinese spelling error correction device for sampling, segmentation and reorganization comprises: The trajectory acquisition module is used to obtain all reasoning trajectories of the preset large language model LLMs; a merging module, configured to perform word segmentation on the target sample sentences and the input sentences in all the reasoning trajectories, align the sentences in all the reasoning trajectories according to the word segmentation results of the input sentences, and merge and optimize the alignment results to obtain an optimized alignment result; A scoring and screening module, used to score and screen the optimized alignment results to obtain Chinese spelling correction results; The trajectory acquisition module is further configured to perform depth-first backtracking on the preset large language models (LLMs) using a depth-first multi-trajectory sampling (DFMTS) method to obtain all inference trajectories of the preset large language models (LLMs); The trajectory acquisition module is further configured to obtain a list of token trajectories for unfinished reasoning in a preset large language model (LLMs); perform reasoning on the token trajectory list and sample the next token according to a preset sampling cardinality, and record the initial reasoning trajectory of each token; perform depth-first backtracing on the initial reasoning trajectory using a depth-first multi-trajectory sampling (DFMTS) method until all trajectories in the initial reasoning trajectory end with an end marker, thereby obtaining all reasoning trajectories of the preset large language model (LLMs).

7. A Chinese spelling correction device for sampling, segmentation and reorganization, characterized in that: The sampling word segmentation and reorganization Chinese spelling correction device includes: a memory, a processor, and a sampling word segmentation and reorganization Chinese spelling correction program stored in the memory and executable on the processor, wherein the sampling word segmentation and reorganization Chinese spelling correction program is configured to implement the steps of the sampling word segmentation and reorganization Chinese spelling correction method according to any one of claims 1 to 5.

8. A storage medium, characterized in that: The storage medium stores a sampled word segmentation and reorganization Chinese spelling correction program, which, when executed by a processor, implements the steps of the sampled word segmentation and reorganization Chinese spelling correction method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Text error correction method, device and equipment based on large model and storage medium

    CN118520869A

  • Modular Large Language Model (LLM) Guided Tree-of-Thought System

    US20250232187A1