OCR text error correction and intelligent optimization method and device based on large language model
Patent Information
- Application Number
- CN202610624634.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-05-08
- Publication Date
- 2026-08-07
AI Technical Summary
[0010]本发明的目的在于克服传统OCR后处理技术因缺乏上下文语义理解、多语种处理能力不足及专业术语识别缺陷导致的文本错误,通过融合大语言模型的深度推理能力,实现多语种复杂文本的上下文关联修正、专业术语精准识别及全自动化优化处理,显著提升OCR输出在拼写、语法、语义层面的准确性与领域适应性
[0083] 1. Precise correction with context awareness
Smart Images

Figure CN122528882A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of artificial intelligence, providing a method and apparatus for OCR text error correction and intelligent optimization based on a large language model. Specifically, it combines Natural Language Processing (NLP) and Optical Character Recognition (OCR) technologies, focusing on solving the problem of intelligent error correction and optimization after OCR text recognition. This technology is particularly suitable for the automated processing and optimization of complex multilingual and multi-domain texts, and is widely used in industries such as medicine, law, and technology to improve the accuracy of document processing. Background Technology
[0002] With the widespread application of OCR (Optical Character Recognition) technology, more and more scenarios require converting image-based documents (such as scanned documents and PDF files) into editable text. While OCR technology performs well in general documents, it still has significant limitations when processing complex documents, especially when encountering difficult-to-recognize characters, handwritten fonts, different languages, technical terms, or blurry images, easily leading to misrecognition or inaccurate output. Furthermore, existing OCR technologies are particularly weak when handling multilingual documents and documents containing technical terms, resulting in translation and technical terminology recognition errors, affecting the accuracy and fluency of the text. Traditional OCR post-processing methods typically rely on rule bases or dictionaries for correction, but these methods have limited effectiveness and cannot adapt to constantly changing text environments and complex contexts.
[0003] Currently, most OCR post-processing technologies rely on rule bases, dictionary matching, or simple spell checks. While these can correct some basic errors, they cannot deeply understand the context of the text or effectively recognize specialized terminology. For example, in documents from medical or legal fields, OCR output often contains terminology recognition errors; for instance, "hypertension" in medical documents may be misrecognized as "hypotension" or "hypetension," and terms in legal documents may also be misidentified. Furthermore, in multilingual documents, OCR technology often fails to accurately identify language switching and translation errors, leading to overall inconsistencies in the document content. For example, OCR engines (such as Tesseract, ABBYY, and Google Vision OCR) often produce language switching errors when processing documents in multilingual environments, resulting in inaccurate text content and affecting their effectiveness in multilingual document processing.
[0004] Existing correction methods can only correct errors through rule bases, but in complex contexts, these methods suffer from poor accuracy and adaptability, failing to effectively address issues such as grammatical errors, inconsistencies in context, and multilingual processing. Therefore, a more intelligent and efficient technology is needed to address these shortcomings in OCR output text.
[0005] 3. Technical problems to be solved in this proposal
[0006] Existing technologies have significant drawbacks in the following aspects:
[0007] 1. Lack of contextual understanding: Traditional OCR post-processing methods cannot fully understand the contextual information of the text, resulting in inadequate correction of grammatical and semantic errors. For example, the OCR engine may misidentify "he" as "she" or "filed" as "flied," and existing technologies struggle to automatically correct these errors.
[0008] 2. Insufficient error correction in multilingual text: When processing multilingual documents, existing OCR technology often suffers from language switching errors, failing to accurately identify the conversion between different languages, leading to translation errors or language confusion. For example, the OCR output may misidentify English text as French, or it may fail to accurately separate paragraphs of different languages in a multilingual document.
[0009] 3. Insufficient Recognition of Technical Terms: In fields involving technical terms (such as medicine, law, and technology), OCR technology often fails to accurately recognize industry-specific terms, leading to misrecognition of professional documents and affecting their reliability and usability. For example, "hypertension" in the medical field may be misrecognized as "hypotension," while certain proper nouns or terms in the legal field may also be misrecognized. Summary of the Invention
[0010] The purpose of this invention is to overcome the text errors caused by the lack of contextual semantic understanding, insufficient multilingual processing capabilities, and defects in the recognition of professional terms in traditional OCR post-processing technologies. By integrating the deep reasoning capabilities of large language models, this invention achieves contextual correlation correction, accurate recognition of professional terms, and fully automated optimization processing of complex multilingual texts, significantly improving the accuracy and domain adaptability of OCR output in terms of spelling, grammar, and semantics.
[0011] To achieve the above objectives, the present invention employs the following technical solution:
[0012] This invention provides a method for OCR text error correction and intelligent optimization based on a large language model, comprising the following steps:
[0013] Step 1: Perform OCR text extraction on the image document to obtain preliminary OCR text output;
[0014] Step 2: Preprocess and perform structural analysis on the preliminary OCR text to obtain structured text;
[0015] Step 3: Perform error identification and correction on the structured text, including the following sub-steps:
[0016] Step 3.1: Use the Levenshtein distance algorithm to detect and correct spelling errors;
[0017] Step 3.2: Detect and correct grammatical errors through dependency parsing;
[0018] Step 3.3: Identify and correct multilingual errors using a language detection algorithm;
[0019] Step 3.4: Perform contextual semantic analysis and optimization on the corrected text based on the large language model;
[0020] Step 4: Adjust the punctuation and verify the context consistency of the optimized text to generate the final output text.
[0021] In the above technical solution, step 1 includes:
[0022] Step 1.1: Extract text from the image document using an OCR engine;
[0023] Step 1.2: Mark the noisy areas in the initial OCR text output and identify distorted or non-textual information in the text.
[0024] In the above technical solution, step 2 includes:
[0025] Step 2.1: Remove noise from the initial OCR text output, including removing non-text information and filtering special characters, to obtain standardized text;
[0026] Step 2.2: Divide the standardized text into paragraphs and sentences, mark the text structure, and obtain structured text;
[0027] Step 2.3: Perform structured analysis on special documents containing tables, mathematical formulas, or images, mark error areas and provide structural information to obtain supplementary structural information text.
[0028] In the above technical solution, step 3 includes:
[0029] The Levenshtein distance algorithm is used to detect spelling errors in structured text, resulting in spell-corrected text. The formula for the Levenshtein distance algorithm is as follows:
[0030]
[0031] in:
[0032] Represents a string The former Characters and strings The former Edit distance between characters;
[0033] It is an indicator function, when The value is 1 if it is true, and 0 otherwise.
[0034] Step 3.2: Use dependency parsing to detect grammatical errors in the spell-corrected text to obtain the grammatically corrected text. The core formula of dependency parsing is as follows:
[0035]
[0036] in:
[0037] A dependency tree is a set of dependency relationships between all words in a sentence.
[0038] To represent a sentence;
[0039] Indicates the initial word and modifiers in a dependency relationship;
[0040] In the sentence Middle head words and modifiers The probability that a dependency relationship exists between them;
[0041] Step 3.3: Use a language detection algorithm to detect multilingual errors in the grammar-corrected text to obtain the language-corrected text;
[0042] Step 3.4: Use a large language model to perform contextual analysis and semantic correction on the language-corrected text to obtain a semantically consistent and logically coherent text.
[0043] In the above technical solution, step 4 includes:
[0044] Step 4.1: Adjust the punctuation of the semantically corrected text to ensure that the punctuation marks are used correctly, and obtain text with standard punctuation;
[0045] Step 4.2: Use a large language model to perform contextual consistency verification on the text with standard punctuation to ensure that the text is logically coherent and semantically consistent, and obtain the final output text.
[0046] Step 4.3: Save and export the final output text to generate the official document format.
[0047] This invention provides an OCR text error correction and intelligent optimization device based on a large language model, comprising:
[0048] The OCR text extraction module is used to extract text from image documents using OCR, and to obtain preliminary OCR text output.
[0049] The preprocessing and structural analysis module is used to preprocess and analyze the structure of the initial OCR text to obtain structured text.
[0050] An error identification and correction module is used to identify and correct errors in the structured text, including:
[0051] The spelling error detection and correction submodule uses the Levenshtein distance algorithm to detect and correct spelling errors.
[0052] The syntax error detection and correction submodule detects and corrects syntax errors through dependency parsing.
[0053] The multilingual error detection and correction submodule identifies and corrects multilingual errors using language detection algorithms.
[0054] The context semantic analysis and optimization submodule performs context semantic analysis and optimization on the corrected text based on a large language model;
[0055] The punctuation adjustment and consistency verification module is used to adjust the punctuation and verify the contextual consistency of the optimized text, and generate the final output text.
[0056] In the above-mentioned device, the OCR text extraction module further includes:
[0057] The OCR engine submodule is used to extract text from image documents using the OCR engine;
[0058] The noise region marking submodule is used to mark noise regions in the initial OCR text output and identify distorted or non-textual information in the text.
[0059] In the above-mentioned device, the preprocessing and structural analysis module is implemented through the following steps:
[0060] The noise removal submodule is used to remove noise from the initial OCR text output, including removing non-text information and filtering special characters to obtain standardized text.
[0061] The text structure segmentation submodule is used to divide standardized text into paragraphs and sentences, mark the text structure, and obtain structured text.
[0062] The Special Document Structured Analysis submodule is used to perform structured analysis on special documents containing tables, mathematical formulas, or images, mark error areas, provide structural information, and obtain supplementary structural information in the text.
[0063] In the above device, the error identification and correction module is implemented through the following steps:
[0064] The Levenshtein distance algorithm is used to detect spelling errors in structured text, resulting in spell-corrected text. The formula for the Levenshtein distance algorithm is as follows:
[0065]
[0066] in:
[0067] Represents a string The former Characters and strings The former Edit distance between characters;
[0068] It is an indicator function, when The value is 1 if it is true, and 0 otherwise.
[0069] Step 3.2: Use dependency parsing to detect grammatical errors in the spell-corrected text to obtain the grammatically corrected text. The core formula of dependency parsing is as follows:
[0070]
[0071] in:
[0072] A dependency tree is a set of dependency relationships between all words in a sentence.
[0073] To represent a sentence;
[0074] Indicates the initial word and modifiers in a dependency relationship;
[0075] In the sentence Middle head words and modifiers The probability that a dependency relationship exists between them;
[0076] Step 3.3: Use a language detection algorithm to detect multilingual errors in the grammar-corrected text to obtain the language-corrected text;
[0077] Step 3.4: Use a large language model to perform contextual analysis and semantic correction on the language-corrected text to obtain a semantically consistent and logically coherent text.
[0078] In the above-mentioned device, the punctuation adjustment and consistency verification module further includes:
[0079] A punctuation adjustment sub-module, which is used to adjust the punctuation of the text after semantic correction to ensure the correct use of punctuation marks and obtain text with standardized punctuation;
[0080] A context consistency verification sub-module, which is used to use a large language model to verify the context consistency of the text with standardized punctuation, ensure that the text is logically smooth and semantically consistent, and obtain the final output text;
[0081] A text saving and exporting sub-module, which is used to save and export the final output text and generate a formal document format.
[0082] By integrating a large language model and OCR technology, the present invention realizes the automatic correction and optimization of complex documents and has the following remarkable advantages:
[0083] 1. Precise correction with context awareness
[0084] Based on the deep semantic reasoning ability of a large language model (such as DeepSeek), it can perform multi-dimensional correction on OCR text in combination with the context, including spelling, grammar, semantics, and punctuation errors, and solve the misjudgment problem caused by the lack of context understanding in traditional methods. For example, when "he plays guitar" is misrecognized as "he play gu1tar", it can be corrected to "he plays guitar", significantly improving the logical smoothness and semantic consistency of the text.
[0085] 2. Efficient processing of multi-lingual mixed text
[0086] Through the synergistic effect of a language detection algorithm (langdetect) and dependency syntax analysis (spaCy), it supports the automatic recognition of multi-lingual text, language switching correction, and grammar adaptation. For example, in a Chinese-English mixed document, it can automatically correct cross-language spelling errors such as "苹果apple" misrecognized as "苹果aple" and optimize the grammar structure.
[0087] 3. Intelligent recognition and correction of professional terms
[0088] For professional terms in fields such as medicine and law, the domain knowledge base of a large language model is used to achieve accurate error correction. For example, correcting the misrecognized "hypetension" in a medical document to "hypertension" to ensure the accuracy of professional terms, and the error correction rate is greatly improved compared with traditional methods.
[0089] 4. Fully automated processing flow
[0090] The modular design automates the entire process from OCR extraction and structured analysis to final optimization, reducing manual intervention. Experiments show that the processing efficiency is significantly improved compared to manual proofreading, making it particularly suitable for large-scale document batch processing scenarios.
[0091] 5. Adaptive optimization of complex document structures
[0092] For documents with special structures such as tables and mathematical formulas, the noise marking and structured analysis module effectively identifies and corrects regional errors. For example, it converts misidentified "|" symbols in tables into standard tab characters, ensuring format integrity.
[0093] 6. Strong robustness across cross-domain scenarios
[0094] Combining the Levenshtein distance algorithm with dependency parsing, it can adapt to the characteristics of text in different domains. Even in low-quality input scenarios such as blurry images and handwritten text, it maintains a high correction accuracy, representing a significant improvement over traditional OCR post-processing techniques.
[0095] 7. Standardized output and format compatibility
[0096] The final text can be exported in formats such as PDF and Word, and punctuation and paragraph alignment are automatically completed to meet the format requirements of formal documents, avoiding the cost of manual secondary typesetting.
[0097] Comparative Advantages Explanation
[0098] refer to Figure 3 and Figure 4 Compared to traditional OCR post-processing techniques that rely on rule bases, this invention achieves full-stack optimization from the character level to the semantic level through the dynamic learning capability of a large language model. The error correction coverage rate is increased from 65% to 92% in traditional methods, and it performs particularly well in complex scenarios such as multilingual mixed documents and professional domain documents. Attached Figure Description
[0099] Figure 1 This is a simplified flowchart of the present invention;
[0100] Figure 2 Original multilingual - blurry image PDF;
[0101] Figure 3 The result after OCR has issues such as missing fields and missing intervals in some English fields.
[0102] Figure 4 The effect after the large model was corrected. Detailed Implementation
[0103] The embodiments of the present invention will be described in detail below. Although the present invention will be described and illustrated in conjunction with some specific embodiments, it should be noted that the present invention is not limited to these embodiments. On the contrary, any modifications or equivalent substitutions made to the present invention should be covered within the scope of the claims of the present invention.
[0104] Furthermore, to better illustrate the present invention, numerous specific details are set forth in the following detailed embodiments. Those skilled in the art will understand that the present invention can be practiced without these specific details.
[0105] This invention provides a method for OCR output text correction and optimization based on a large language model, the process of which is as follows:
[0106] Specifically, the following steps are included:
[0107] Step 1: Perform OCR text extraction on the image document to obtain preliminary OCR text output;
[0108] Step 2: Preprocess and analyze the structure of the initial OCR text to obtain structured text;
[0109] Step 3: Perform error identification and correction on the structured text to obtain the corrected text;
[0110] Step 4: Optimize and validate the corrected text to obtain the final output text.
[0111] The following is a detailed explanation of the specific implementation of each step:
[0112] Step 1 above specifically includes the following steps:
[0113] Step 1.1: Extract text from the image document using an OCR engine (such as Tesseract, ABBYY, etc.) to obtain preliminary OCR text output;
[0114] Step 1.2: Perform a preliminary check on the initial OCR text output to identify text noise or distortion areas and obtain text with marked noise areas.
[0115] Step 2 above specifically includes the following steps:
[0116] Step 2.1: Remove noise from the initial OCR text output, including removing non-textual information (such as image noise) and filtering special characters to obtain standardized text;
[0117] Step 2.2: Divide the standardized text into paragraphs and sentences, and mark the text structure (such as paragraphs, headings, lists, etc.) to obtain structured text;
[0118] Step 2.3: Perform structured analysis on special documents containing tables, mathematical formulas, or images, mark error areas and provide structural information to obtain supplementary structural information text.
[0119] Step 3 above specifically includes the following steps:
[0120] Step 3.1: For the structured text output by OCR, spelling errors are detected using the Levenshtein distance algorithm. This algorithm calculates the minimum number of editing operations between two strings, defined by the formula:
[0121]
[0122] in:
[0123] Represents a string The former Characters and strings The former Edit distance between characters.
[0124] It is an indicator function, when It is 1 if it is true, otherwise it is 0.
[0125] The specific correction process is as follows:
[0126] Generate a candidate word set from a domain terminology database. .
[0127] Calculate the minimum edit distance between the OCR output word and each candidate word.
[0128] The candidate word with the smallest edit distance is selected as the correction result; if the distance exceeds the threshold... (default If the result is 0, it is marked as requiring manual review.
[0129] Step 3.2: Parse the spell-corrected text using a dependency parsing model (such as spaCy) to generate a dependency tree T, whose probabilistic model is defined as:
[0130]
[0131] in:
[0132] A dependency tree is a set of dependency relationships between all words in a sentence.
[0133] It represents a sentence.
[0134] Indicate the head and modifier in a dependency relationship.
[0135] In the sentence Middle head words and modifiers The probability that a dependency relationship exists between them.
[0136] The specific error detection and correction process is as follows:
[0137] a. Probability threshold determination: Marking The dependency relationship is suspected to be incorrect.
[0138] b. Error type identification: subject-verb disagreement (e.g., singular-plural conflict); incorrect part of speech of modifiers (e.g., adverb modifying noun); isolated words (no valid dependency relationship).
[0139] c. Correction strategy: Combine the large language model to generate context-compatible correction suggestions (e.g., “have” → “has”).
[0140] Step 3.3: Multilingual Error Detection and Correction
[0141] a. Dynamic Language Segmentation: Performs paragraph / sentence-level language detection on grammar-corrected text, combined with confidence thresholding. Matching with a terminology database to identify multilingual regions; the formula is as follows:
[0142]
[0143] in Identifiers representing a specific language. Indicates a multilingual mixed state. Given a text fragment S, this fragment belongs to the language. The probability (or confidence level) of;
[0144] b. Context-enhanced semantic verification: For low-confidence language regions, a large language model (such as DeepSeek) is invoked for secondary verification, and language misjudgments are corrected by combining a domain terminology database.
[0145] c. Cross-linguistic grammar correction: In multilingual regions, verify the grammatical compatibility of different language components and generate correction suggestions through a large language model.
[0146] Step 3.4: Use a large language model (such as DeepSeek) to perform context analysis and semantic correction on the language-corrected text to obtain a semantically consistent and logically coherent text.
[0147] Step 4 above specifically includes the following steps:
[0148] Step 4.1: Adjust the punctuation of the semantically corrected text to ensure that the punctuation marks are used correctly, and obtain text with standard punctuation;
[0149] Step 4.2: Use a large language model (such as DeepSeek) to perform context consistency verification on the text with standard punctuation to ensure that the text is logically coherent and semantically consistent, and obtain the final output text.
[0150] Step 5 above specifically includes the following steps:
[0151] Step 5.1: Save and export the final output text to generate a formal document format (such as PDF, Word document, etc.).
[0152] In summary, the present invention has the following characteristics:
[0153] 1. Combining the contextual understanding capabilities of large language models: By leveraging the deep reasoning and contextual understanding capabilities of large language models, the accuracy and text quality of OCR output are significantly improved, especially in error correction and semantic optimization in complex contexts.
[0154] 2. Multilingual support and optimization: Supports automatic translation and grammar optimization in multiple languages to ensure consistency and accuracy of text translation when switching between different languages, effectively avoiding contextual misunderstandings and translation errors.
[0155] 3. Fully automated processing, reducing manual intervention: It provides a fully automated text correction and optimization process, automatically identifying and correcting spelling, grammar and context errors in OCR text, reducing the need for manual intervention, thereby improving work efficiency and processing speed.
[0156] Key points of this invention:
[0157] 1. Innovative combination of large language model and OCR: This invention innovatively combines large language model with OCR technology. Through the deep contextual understanding and reasoning capabilities of large language model, it achieves automatic correction and optimization of OCR text, especially in terms of precise correction at the levels of grammar, semantics, and punctuation.
[0158] 2. Automatic text correction and optimization: Based on the contextual analysis of OCR output text using a large language model, this invention can automatically identify and correct spelling errors, grammatical inconsistencies, and contextual inconsistencies, thereby improving the accuracy and natural fluency of OCR output.
[0159] 3. Multilingual Processing and Terminology Optimization: This invention can effectively process multilingual documents, automatically identify language switching, and optimize translations. Especially in fields such as medicine and law, it can automatically correct misidentification and translation errors of professional terminology, ensuring the professionalism and accuracy of the text content.
[0160] 4. Fully Automated Text Correction Process: This invention provides a fully automated correction and optimization process, which greatly reduces manual intervention, significantly improves document processing efficiency, and reduces labor costs.
[0161] Compared with the prior art, the present invention has the following advantages:
[0162] 1. Deep Contextual Understanding and Precise Correction: Compared with traditional OCR post-processing methods (such as rule base and dictionary matching), this invention, through the contextual understanding capabilities of a large language model, can perform deep contextual analysis, accurately identify and correct spelling errors, grammatical problems and contextual inconsistencies in OCR output, thereby significantly improving the accuracy and quality of text.
[0163] 2. Advantages of Multilingual Text Processing: Traditional OCR technology often encounters language switching errors when processing multilingual documents, and cannot effectively handle complex situations involving mixed multilingual text. This invention, however, can automatically identify and optimize language switching in multilingual documents, solving the recognition problems of existing technologies in multilingual environments, and is particularly suitable for the accurate translation and integration of multilingual documents.
[0164] 3. Automatic correction of domain-specific terms: This invention is specifically designed for professional documents in fields such as medicine, law, and technology, and provides an automatic terminology correction function. It can identify and correct misidentification of industry-specific terms, ensuring the professionalism and accuracy of the text content. This advantage is not easily achieved by existing technologies.
[0165] 4. Automated Processing and High Efficiency: Compared with traditional OCR post-processing methods, this invention achieves a fully automated text optimization process, greatly reducing the workload of manual proofreading and significantly improving processing efficiency. At the same time, reducing manual intervention not only increases processing speed but also lowers labor costs.
Claims
1. A method for OCR text error correction and intelligent optimization based on a large language model, characterized in that, Includes the following steps: Step 1: Perform OCR text extraction on the image document to obtain preliminary OCR text output; Step 2: Preprocess and perform structural analysis on the preliminary OCR text to obtain structured text; Step 3: Perform error identification and correction on the structured text, including the following sub-steps: Step 3.1: Use the Levenshtein distance algorithm to detect and correct spelling errors; Step 3.2: Detect and correct grammatical errors through dependency parsing; Step 3.3: Identify and correct multilingual errors using a language detection algorithm; Step 3.4: Perform contextual semantic analysis and optimization on the corrected text based on the large language model; Step 4: Adjust the punctuation and verify the contextual consistency of the optimized text to generate the final output text.
2. The method according to claim 1, characterized in that, Step 1 includes: Step 1.1: Extract text from the image document using an OCR engine; Step 1.2: Mark the noisy areas in the initial OCR text output and identify distorted or non-textual information in the text.
3. The method according to claim 1, characterized in that, Step 2 includes: Step 2.1: Remove noise from the initial OCR text output, including removing non-text information and filtering special characters, to obtain standardized text; Step 2.2: Divide the standardized text into paragraphs and sentences, mark the text structure, and obtain structured text; Step 2.3: Perform structured analysis on special documents containing tables, mathematical formulas, or images, mark error areas and provide structural information to obtain supplementary structural information text.
4. The method according to claim 1, characterized in that, Step 3 includes: The Levenshtein distance algorithm is used to detect spelling errors in structured text, resulting in spell-corrected text. The formula for the Levenshtein distance algorithm is as follows: in: Represents a string The former Characters and strings The former Edit distance between characters; It is an indicator function, when The value is 1 if it is true, and 0 otherwise. Step 3.2: Use dependency parsing to detect grammatical errors in the spell-corrected text to obtain the grammatically corrected text. The core formula of dependency parsing is as follows: in: A dependency tree is a set of dependency relationships between all words in a sentence. To represent a sentence; Indicates the initial word and modifiers in a dependency relationship; In the sentence Middle head words and modifiers The probability that a dependency relationship exists between them; Step 3.3: Use a language detection algorithm to detect multilingual errors in the grammar-corrected text to obtain the language-corrected text; Step 3.4: Use a large language model to perform contextual analysis and semantic correction on the language-corrected text to obtain a semantically consistent and logically coherent text.
5. The method according to claim 1, characterized in that, Step 4 includes: Step 4.1: Adjust the punctuation of the semantically corrected text to ensure that the punctuation marks are used correctly, and obtain text with standard punctuation; Step 4.2: Perform context consistency verification on the punctuated text using a large language model to ensure logical coherence and semantic consistency, thus obtaining the final output text. Step 4.3: Save and export the final output text to generate the official document format.
6. A device for OCR text error correction and intelligent optimization based on a large language model, characterized in that, include: The OCR text extraction module is used to extract text from image documents using OCR, and to obtain preliminary OCR text output. The preprocessing and structural analysis module is used to preprocess and analyze the structure of the initial OCR text to obtain structured text. An error identification and correction module is used to identify and correct errors in the structured text, including: The spelling error detection and correction submodule uses the Levenshtein distance algorithm to detect and correct spelling errors. The syntax error detection and correction submodule detects and corrects syntax errors through dependency parsing. The multilingual error detection and correction submodule identifies and corrects multilingual errors using language detection algorithms. The context semantic analysis and optimization submodule performs context semantic analysis and optimization on the corrected text based on a large language model; The punctuation adjustment and consistency verification module is used to adjust the punctuation and verify the contextual consistency of the optimized text, and generate the final output text.
7. The apparatus according to claim 6, characterized in that, The OCR text extraction module further includes: The OCR engine submodule is used to extract text from image documents using the OCR engine; The noise region marking submodule is used to mark noise regions in the initial OCR text output and identify distorted or non-textual information in the text.
8. The apparatus according to claim 6, characterized in that, The preprocessing and structural analysis module is implemented through the following steps: The noise removal submodule is used to remove noise from the initial OCR text output, including removing non-text information and filtering special characters to obtain standardized text. The text structure segmentation submodule is used to divide standardized text into paragraphs and sentences, mark the text structure, and obtain structured text; The Special Document Structured Analysis submodule is used to perform structured analysis on special documents containing tables, mathematical formulas, or images, mark error areas, provide structural information, and obtain supplementary structural information in the text.
9. The apparatus according to claim 6, characterized in that, The error identification and correction module is implemented through the following steps: The Levenshtein distance algorithm is used to detect spelling errors in structured text, resulting in spell-corrected text. The formula for the Levenshtein distance algorithm is as follows: in: Represents a string The former Characters and strings The former Edit distance between characters; It is an indicator function, when The value is 1 if it is true, and 0 otherwise. Step 3.2: Use dependency parsing to detect grammatical errors in the spell-corrected text to obtain the grammatically corrected text. The core formula of dependency parsing is as follows: in: A dependency tree is a set of dependency relationships between all words in a sentence. To represent a sentence; Indicates the initial word and modifiers in a dependency relationship; In the sentence Middle head words and modifiers The probability that a dependency relationship exists between them; Step 3.3: Use a language detection algorithm to detect multilingual errors in the grammar-corrected text to obtain the language-corrected text; Step 3.4: Use a large language model to perform contextual analysis and semantic correction on the language-corrected text to obtain a semantically consistent and logically coherent text.
10. The apparatus according to claim 6, characterized in that, The punctuation adjustment and consistency verification module further includes: The punctuation adjustment submodule is used to adjust the punctuation of the semantically corrected text to ensure that punctuation marks are used correctly and to obtain text with standard punctuation. The context consistency verification submodule is used to perform context consistency verification on text with punctuation standardization using a large language model to ensure that the text is logically coherent and semantically consistent, and to obtain the final output text. The text saving and export submodule is used to save and export the final output text, generating a formal document format.