Bill batch recognition and data automatic pairing and verification method based on AI scanning

By using multi-template collaborative recognition and layout consistency verification, the problem of decreased accuracy in document recognition when the layout changes has been solved, achieving efficient and automated document recognition and data verification.

CN122490158APending Publication Date: 2026-07-31JIANXIANG CLOUD INFORMATION TECH (DONGGUAN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
JIANXIANG CLOUD INFORMATION TECH (DONGGUAN) CO LTD
Filing Date
2026-04-30
Publication Date
2026-07-31

AI Technical Summary

Technical Problem

Existing document recognition technology suffers from decreased accuracy when the layout changes, and cannot automatically determine the reliability of the recognition results, requiring manual verification one by one, which is inefficient.

Method used

The system uses multiple historical versions of the identification template, determines the final identification result through layout fingerprint matching and weighted voting, performs consistency checks, and automatically marks fields to be reviewed.

Benefits of technology

It improves the stability and accuracy of document recognition, reduces the workload of manual review, and realizes self-evaluation and automated review of recognition results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122490158A_ABST
    Figure CN122490158A_ABST
Patent Text Reader

Abstract

This invention discloses a method for batch recognition and automatic data pairing verification of documents based on AI scanning. It includes pre-constructing a template library containing multiple historical versions, field names, expected locations, and relative relationships. During recognition, the layout features of the document to be recognized are first extracted to generate a "layout fingerprint." The fingerprint is then compared with the template library to select the top K templates as candidate templates. For the target field, recognition is performed based on the expected location of each candidate template, resulting in K candidate results. These are then weighted by template similarity to determine the final recognition result. Simultaneously, a consistency check is performed on the field location areas given by each template; if the difference is too large, the field is marked for further verification. This invention solves the problem of decreased recognition accuracy caused by a single fixed template or optimal template matching method when the document layout undergoes minor or unexpected changes. Furthermore, the consistency check of the recognition results improves both the accuracy of the detection results and work efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data processing technology, and in particular to a method for batch identification of documents and automatic data matching and verification based on AI scanning. Background Technology

[0002] Existing document recognition and data verification methods typically employ fixed recognition templates or optical character recognition (OCR) technology based on a single template. Operators must manually pre-set a standard template for each document type, including fixed coordinate areas or relative positions for each field. During recognition, the system compares the document to be recognized with this standard template, extracts characters from the specified areas within the template, and outputs the recognition result. When the document layout changes, such as adjusting column widths, adding or deleting fields, or making minor layout adjustments, manual adjustments to the template or updating of the recognition rules are required. Some improved solutions use layout feature matching, selecting the best-matching template from a template library for recognition. However, this approach means that even minor, unexpected changes to the document layout can lead to field positioning offsets, significantly reducing recognition accuracy. Furthermore, existing technology cannot automatically determine the reliability of recognition results or identify errors caused by mismatches between the template and the actual document layout. Since the system cannot automatically flag suspicious recognition results, all recognition outputs often require manual verification, resulting in low efficiency. Summary of the Invention

[0003] To address at least one of the aforementioned technical problems, this invention provides a method for batch identification of documents and automatic data pairing and verification based on AI scanning.

[0004] In a first aspect, the present invention provides a method for batch identification of documents and automatic data pairing and verification based on AI scanning, the method comprising:

[0005] For documents of the same type, store multiple historical versions of recognition templates to generate a template library. Each recognition template includes at least the field name, the expected location area of ​​the field, and the relative positional relationship between the fields.

[0006] Extract the layout features of the document to be identified and generate the layout fingerprint of the document to be identified;

[0007] Calculate the similarity between the layout fingerprint of the document to be identified and the layout fingerprint of each historical template in the template library, and select the top K templates with the highest similarity as candidate templates;

[0008] The target field to be identified on the document to be identified is determined. The field is located and identified according to the expected location area of ​​the field corresponding to the target field in each candidate template, resulting in K candidate identification results. The fusion weight is assigned to each candidate identification result according to the similarity of each candidate template, and the final identification result of the target field is determined by weighted voting.

[0009] The consistency of the field location regions corresponding to the target field given by each candidate template is checked. If the difference between each location region exceeds a preset threshold, the target field is marked as pending review. If the difference between each location region does not exceed the preset threshold, the final recognition result determined by weighted voting is output as the recognition result of the target field.

[0010] Preferably, the fingerprint on the screen is generated in the following way:

[0011] Feature extraction is performed on the document to be identified, including extracting the text line density distribution, table line intersection distribution, blank area ratio, and relative coordinates of key identification fields. The key identification fields include document type identifier, document number field, and date field.

[0012] Each extracted feature is converted into a feature vector, and the feature vectors are concatenated to obtain a fused feature vector. Principal component analysis is used to reduce the dimensionality of the fused feature vector, and the dimensionality-reduced vector is used as the layout fingerprint.

[0013] Preferably, the method further includes:

[0014] Once the document to be identified has been manually confirmed to be correct, the fingerprint of the document and the actual location area of ​​each field are stored as a new template in the template library.

[0015] When the document to be identified is manually corrected, the template with the lowest similarity among the candidate templates is updated based on the corrected field location area.

[0016] Preferably, the method further includes:

[0017] Obtain the final recognition results for each of multiple documents to be recognized in the same batch;

[0018] The system invokes a preset batch-based constraint rule base, which includes at least one of the following constraint types:

[0019] The summation constraint means that the sum of the identification results of multiple sub-item fields should match the identification result of the total item field;

[0020] Consistency constraint, which means that the recognition results of a specified field in the same batch should be the same as each other;

[0021] Ordinal constraint, that is, document numbers should be consecutive and non-repeating;

[0022] Constraint validation is performed on multiple documents in the batch to identify abnormal fields that violate constraint rules; abnormal fields are corrected, and a batch validation report is generated.

[0023] Preferably, the correction of the abnormal field includes:

[0024] For abnormal fields that violate the summation constraint, calculate the difference between the sum of the sub-items and the total item. If the difference is less than the preset threshold, distribute the difference inversely proportionally to the recognition confidence of each sub-item field to one or more sub-item fields with the lowest confidence, and automatically correct the recognition results of the sub-item fields.

[0025] For abnormal fields that violate consistency constraints, the identification result with the highest frequency of abnormal fields in the same batch is taken as the standard value, and abnormal fields that deviate from the standard value are automatically corrected to the standard value.

[0026] When the same abnormal field violates multiple constraint rules at the same time, the conflict is resolved in a preset priority order; if the conflict still exists after the conflict is resolved, the abnormal field is marked as pending manual review and the information of each constraint rule that caused the conflict is output.

[0027] Among them, the priority of summation constraints, consistency constraints, and ordinal constraints decreases in that order.

[0028] Preferably, the method further includes a confidence level dynamic correction step:

[0029] Obtain the initial recognition confidence score of the OCR engine for the target field;

[0030] The business scenario context library is invoked. The context library stores statistical features of each field for different business scenarios. The statistical features include mean, standard deviation, and common value range.

[0031] Calculate the degree of deviation between the recognition result of the target field and the statistical features, determine the context correction coefficient based on the degree of deviation, and calculate the final confidence based on the initial recognition confidence and the context correction coefficient;

[0032] The appropriate processing is performed based on the threshold range of the final confidence level: if the final confidence level is higher than the first threshold, it will pass automatically; if the final confidence level is lower than the first threshold but higher than the second threshold, cross-validation of related documents will be automatically triggered; if the final confidence level is lower than the second threshold, it will be suspended and await manual review.

[0033] Preferably, the method further includes:

[0034] Once the recognition result of the target field is manually confirmed to be correct, the recognition result is used as new sample data to update the statistical features of the corresponding field in the business scenario context library.

[0035] Once the identification result of the target field is manually corrected, the corrected value is used as the correct sample to update the statistical feature.

[0036] Secondly, the present invention also provides a device for batch identification of documents and automatic data matching and verification based on AI scanning, the device comprising:

[0037] The template library generation unit is used to store multiple historical versions of identification templates for the same type of document to generate a template library. Each identification template contains at least the field name, the expected location area of ​​the field, and the relative positional relationship between the fields.

[0038] The layout fingerprint recognition unit is used to extract the layout features of the document to be recognized and generate the layout fingerprint of the document to be recognized.

[0039] The candidate template selection unit is used to calculate the similarity between the layout fingerprint of the document to be identified and the layout fingerprint of each historical template in the template library, and select the top K templates with the highest similarity as candidate templates.

[0040] The target field identification unit is used to determine the target field on the document to be identified. It locates and identifies the target field according to the expected location area of ​​the field corresponding to the target field in each candidate template, and obtains K candidate identification results. It assigns fusion weights to each candidate identification result according to the similarity of each candidate template, and determines the final identification result of the target field through weighted voting.

[0041] The consistency verification unit is used to verify the consistency of the positional regions of the fields corresponding to the target field given by each candidate template. If the difference between each positional region exceeds a preset threshold, the target field is marked as pending review. If the difference between each positional region does not exceed the preset threshold, the final recognition result determined by weighted voting is output as the recognition result of the target field.

[0042] Thirdly, the present invention also provides an electronic device including a processor and a memory, the memory being used to store computer program code, the computer program code including computer instructions, wherein when the processor executes the computer instructions, the electronic device performs the method as described in the first aspect above and any possible implementation thereof.

[0043] Fourthly, the present invention also provides a computer-readable storage medium storing a computer program, the computer program including program instructions that, when executed by a processor of an electronic device, cause the processor to perform a method as described in the first aspect above and any possible implementation thereof.

[0044] Compared with the prior art, the beneficial effects of the present invention are as follows:

[0045] The method provided by this invention selects the top K templates with the highest similarity as candidate templates and combines this with weighted voting to determine the final recognition result. Even if a single template experiences positioning deviation due to layout changes, other similar templates can still provide correct position information. The weighted voting mechanism uses the similarity of each template as a confidence level, allowing templates with high matching degrees to contribute more to the result, thereby significantly improving the stability and accuracy of recognition in scenarios with dynamic layout changes. By performing a "consistency check" on the field position areas given by each candidate template, if the difference between the position areas exceeds a preset threshold, the target field is automatically "marked as pending review." This mechanism enables the system to proactively identify unreliable recognition results caused by layout anomalies or template conflicts without relying on manual sampling, achieving self-assessment of recognition quality. Only fields marked as "pending review" require manual intervention, while fields that pass the consistency check directly output the weighted voting result. Compared to existing technologies that require full review or random sampling, this solution precisely narrows the review scope to suspicious fields with positional discrepancies, significantly reducing manual workload and avoiding unnecessary intervention in correct recognition results. By using "weighted voting" to fuse the recognition results of K candidate templates, occasional recognition errors of a single template, such as local noise interference or character incompleteness, will be suppressed by the voting mechanism because they are inconsistent with the results of other templates. The output result is the consensus of multiple templates, which has a stronger anti-interference ability.

[0046] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description

[0047] To more clearly illustrate the technical solutions in the embodiments of the present invention or the background art, the accompanying drawings used in the embodiments of the present invention or the background art will be described below.

[0048] Figure 1 A flowchart illustrating a method for batch identification of documents and automatic data pairing verification based on AI scanning, provided in an embodiment of the present invention;

[0049] Figure 2 This is a schematic diagram of a device for batch identification of documents and automatic data matching and verification based on AI scanning, provided in an embodiment of the present invention. Detailed Implementation

[0050] To enable those skilled in the art to better understand the present invention, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0051] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of the invention. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.

[0052] Please see Figure 1 , Figure 1 This is a flowchart illustrating a method for batch document recognition and automatic data pairing verification based on AI scanning, provided as an embodiment of the present invention. Figure 1 As shown, the method includes:

[0053] S10. For documents of the same type, store multiple historical versions of identification templates to generate a template library. Each identification template shall at least include field names, expected field location areas, and relative positional relationships between fields.

[0054] S20. Extract the layout features of the document to be identified and generate the layout fingerprint of the document to be identified.

[0055] S30. Calculate the similarity between the layout fingerprint of the document to be identified and the layout fingerprint of each historical template in the template library, and select the top K templates with the highest similarity as candidate templates.

[0056] S40. Determine the target field to be identified on the document to be identified, and locate and identify it according to the expected location area of ​​the field corresponding to the target field in each candidate template to obtain K candidate identification results; assign fusion weights to each candidate identification result according to the similarity of each candidate template, and determine the final identification result of the target field through weighted voting;

[0057] S50. Perform a consistency check on the field location regions corresponding to the target field given by each candidate template. If the difference between each location region exceeds a preset threshold, mark the target field as pending review. If the difference between each location region does not exceed the preset threshold, output the final recognition result determined by weighted voting as the recognition result of the target field.

[0058] During the batch recognition of documents, frequent minor adjustments to the document format, such as changes in table column width and field position offsets, lead to a decrease in the recognition accuracy of fixed templates or single optimal templates. At the same time, existing methods cannot automatically determine the credibility of the recognition results, making it difficult to distinguish between correct and suspicious recognitions, resulting in high manual review costs and low efficiency.

[0059] To address the aforementioned issues, this invention provides a method that utilizes multiple historical versions of identification templates for collaborative identification. By employing dual verification through layout matching and field position consistency between templates, it achieves highly robust and self-assessable document identification. Specifically, in step S10, multiple historical versions of identification templates are pre-stored for documents of the same type. Each template not only includes field names and expected location areas but also records the relative positional relationships between fields. This makes the templates independent of absolute coordinates, providing a certain degree of layout adaptability. In step S20, layout features, such as text block distribution, table line structure, and blank area ratio, are extracted from the document to be identified, generating a unique "layout fingerprint" that identifies its layout structure. This fingerprint can abstractly describe the overall arrangement style of the document. In step S30, the similarity between the layout fingerprint of the document to be identified and the layout fingerprints of each historical template in the template library is calculated, and the top K templates with the highest similarity are selected as candidate templates. This step expands the identification scope from "single best match" to "multiple similar matches," laying the foundation for subsequent fusion identification. In step S40, for the target field to be identified, the expected location area of ​​the field in each candidate template is located and identified, resulting in K candidate identification results. Then, the K results are weighted and voted on using the layout similarity of each candidate template as a weight to determine the final identification result. Templates with higher similarity contribute more to the voting, thus suppressing the influence of individual mismatched templates. In step S50, a consistency check is performed on the field location areas given by each candidate template. If the difference between the location areas exceeds a preset threshold, it indicates a significant discrepancy in the judgment of the field's location among different templates, and the layout may have undergone unreliable changes; therefore, the field is marked as "to be reviewed." If the difference is small, the weighted voting result is directly output. The multi-template voting mechanism reduces the risk of identification errors caused by changes in the layout of a single template; simultaneously, the position consistency check automatically identifies fields with abnormal layouts or template conflicts, achieving reliable quantification and automatic review and screening of the identification results.

[0060] Therefore, this embodiment suppresses positioning deviations caused by minor layout adjustments in a single template through weighted voting using multiple templates, maintaining high recognition accuracy even when the layout changes to some extent. By utilizing field position consistency checks among candidate templates, it automatically determines which field recognition results are reliable and which require review without manual intervention. Only fields with position differences exceeding a threshold are marked as requiring review, significantly reducing the workload of full review and improving the efficiency of batch document processing. Multiple historical versions are retained in the template library, allowing the system to naturally adapt to the gradual evolution of document layouts, eliminating the need for frequent manual template maintenance.

[0061] In one embodiment, in step S10, for documents of the same business type (such as VAT invoices, warehouse receipts, express delivery slips, etc.), the system pre-stores multiple identification templates of different historical versions, forming a template library. Each template is not a simple screenshot or coordinate set, but contains three types of key information:

[0062] Field name: The name of the data item to be identified, such as "invoice code", "invoice date", "amount", "buyer name", etc.

[0063] Field expected location area: The approximate rectangular area in the document layout where this field may appear (usually described by coordinates or relative position).

[0064] The relative positions of the fields: for example, "the amount field is located approximately 3cm below the invoice date field" or "the tax amount field is on the right side of the same line as the amount field". This relative relationship does not rely on absolute coordinates and provides a basis for adaptive positioning when the layout changes.

[0065] By retaining multiple historical versions of the template (not just the latest version), the system can adapt to the gradual evolution of document formats (such as tax bureaus adjusting invoice formats or companies modifying internal document templates), avoiding recognition failures due to a single outdated template.

[0066] Suppose a company needs to identify VAT electronic general invoices in bulk. These invoices have undergone three version changes in the past three years, as shown in Table 1:

[0067] Table 1

[0068]

[0069] Taking the V1 template as an example, here's a sample of the content stored in the template library:

[0070] Field names: Invoice code, Invoice date, Amount, Tax amount, Buyer's name;

[0071] Expected location area for the field (with the top left corner of the page as the origin, in pixels):

[0072] Invoice codes: range (50, 60) to (200, 90);

[0073] Invoice issuance date: Area (400, 60) to (550, 90);

[0074] Amount: Range (450, 400) to (600, 430);

[0075] Suppose a company receives a 2023 version invoice (V3 format) in 2024. If the template library only contains the V1 template, the system will attempt to identify the amount based on the "amount" position in V1, potentially locating the "deduction amount" or a blank area, leading to recognition errors or failures. However, because the V3 template exists, the system can prioritize the V3 template for recognition in subsequent step S30 through layout fingerprint matching, thus correctly extracting the "amount" field. Even if an invoice is slightly tilted or shifted overall during scanning (e.g., 0.5cm to the left), the relative positional relationship remains valid. The system can first identify the "invoice code" as an anchor point, and then dynamically calculate the actual position of the amount based on the relationship, rather than relying on fixed absolute coordinates, thus improving tolerance for scanning deviations.

[0076] In one embodiment, the layout fingerprint is generated in the following manner:

[0077] Feature extraction is performed on the document to be identified, including extracting the text line density distribution, table line intersection distribution, blank area ratio, and relative coordinates of key identification fields. The key identification fields include document type identifier, document number field, and date field.

[0078] Each extracted feature is converted into a feature vector, and the feature vectors are concatenated to obtain a fused feature vector. Principal component analysis is used to reduce the dimensionality of the fused feature vector, and the dimensionality-reduced vector is used as the layout fingerprint.

[0079] Specifically, the implementation steps of this embodiment are as follows:

[0080] 1) Text line density distribution extraction: Divide the image of the document to be identified into M×N grid cells, count the number of text characters identified in each grid cell, and use the character density in each grid cell to form the first feature vector, where M and N are both integers greater than or equal to 4;

[0081] 2) Extraction of table line intersection points: Perform line detection on the document image, extract the coordinates of the intersection points of horizontal and vertical lines, count the number of intersection points in each grid cell, and form the second feature vector;

[0082] 3) Extraction of blank area proportion: Identify continuous blank areas in the document image, calculate the area of ​​each blank area and its proportion in the whole document, sort the blank areas from largest to smallest and take the proportion values ​​of the first L blank areas to form the third feature vector, where L is a preset integer greater than or equal to 3.

[0083] 4) Extraction of relative coordinates of key identifier fields: Identify the predefined key identifier fields in the document, including the document type identifier, document number field, and date field. Extract the center point coordinates of each key identifier field, and normalize them with the upper left corner of the document as the origin to form the fourth feature vector.

[0084] 5) Feature fusion and dimensionality reduction: The first feature vector, the second feature vector, the third feature vector, and the fourth feature vector are concatenated to obtain the fused feature vector. The fused feature vector is reduced to a preset dimension D by principal component analysis, where the value of D ranges from 64 to 256. The dimensionality-reduced vector is used as the layout fingerprint.

[0085] In the above embodiments, the role of layout fingerprinting is to abstract the overall layout of a document into a quantifiable and comparable mathematical vector, used to quickly measure the layout similarity between different documents or templates, thereby providing an objective basis for selecting candidate templates. This embodiment integrates multi-dimensional features such as text line density, table line intersections, blank space ratio, and key field coordinates, and uses principal component analysis for dimensionality reduction, resulting in a layout fingerprint that is both information-rich and computationally efficient. Compared to methods using single features or without dimensionality reduction, it can more accurately match the same layout, distinguish different layouts, and significantly reduce the overhead of subsequent similarity calculations.

[0086] In one embodiment, cosine similarity, Euclidean distance (the smaller the distance, the more similar), or Pearson correlation coefficient can be used to calculate similarity in step S30. However, cosine similarity is not sensitive to the absolute length of the vector and is more suitable for comparing layout fingerprints. Therefore, this embodiment preferably uses cosine similarity. Specifically, for each historical template in the template library, its pre-stored layout fingerprint vector is read. According to the cosine similarity formula, the similarity score between the fingerprint of the document to be identified and the fingerprint of the template is calculated. Then, all templates are sorted from high to low according to their similarity scores. The top K templates are selected as candidate templates (e.g., K=3 or K=5). If the total number of templates in the template library is less than K, all templates are selected. The similarity score of each candidate template is retained for weighted voting in the subsequent step S40.

[0087] Further, the input data for step S40 consists of K candidate templates (each template contains the expected location region of the field and similarity weight) and an image of the document to be identified. The implementation process is as follows:

[0088] 1) Determine the target field: for example, the "amount" field.

[0089] 2) Template-by-template location recognition: For the i-th candidate template, based on the expected location area of ​​the stored "amount" (such as the coordinates of a rectangle), perform OCR recognition in the corresponding area of ​​the document to be recognized to obtain the candidate recognition result.

[0090] 3) Assign fusion weights: Use the layout similarity of the i-th template as its weight. Normalize all weights, and the sum of all weights is 1.

[0091] 4) Weighted voting determines the final result:

[0092] Group the K candidate results according to the recognized text (e.g., if the three results are “1234.56”, “1234.56”, and “1234.55”, they are divided into two groups).

[0093] Calculate the total weight for each group (the sum of the weights of all results within the group).

[0094] The text corresponding to the group with the highest total weight is selected as the final recognition result. If there are multiple groups with the highest weight, the best result can be selected by character-level averaging or confidence level.

[0095] For example, with K=3, similarities of 0.9, 0.8, and 0.7, and normalized weights of 0.375, 0.333, and 0.292 respectively, the recognition results are: "1234.56" (template 1), "1234.56" (template 2), and "1234.55" (template 3). The total weight of the "1234.56" group is 0.375 + 0.333 = 0.708, which is higher than the other group's 0.292. Therefore, the final output is "1234.56".

[0096] Further, step S50 performs consistency checks and verification marking:

[0097] 1) Collect location regions: From the K candidate templates, extract the expected location regions corresponding to the target field (each region is a rectangle, represented by the coordinates of the upper left and lower right corners).

[0098] 2) Calculate the location difference index: any one or a combination of the following can be used:

[0099] Center point offset: Calculate the average Euclidean distance between the center points of K rectangles.

[0100] Overlap area ratio: Calculates the minimum value of the intersection-union ratio (IoU) of two pairs of rectangles.

[0101] Coordinate variance: Calculate the variance of the x-coordinate and y-coordinate of the top left corner respectively.

[0102] 3) Comparison with preset threshold: If the difference index exceeds the preset threshold (e.g., minimum IoU < 0.6), it is determined to be inconsistent.

[0103] 4) Tagging and Output:

[0104] If the difference exceeds the threshold: mark the target field as "pending review status", do not output the automatic recognition result, and wait for manual confirmation.

[0105] If the difference does not exceed the threshold: the final identification result determined by weighted voting in S40 will be directly output and entered into subsequent business processing.

[0106] Therefore, this embodiment automatically identifies situations where different templates have serious disagreements on the positioning of the same field through position consistency checks, avoiding blindly outputting incorrect results; while for fields where the templates "agree", the weighted voting results are trusted, achieving a precise division of labor between automatic identification and manual review.

[0107] In one embodiment, the method further includes:

[0108] Once the document to be identified has been manually confirmed to be correct, the fingerprint of the document and the actual location area of ​​each field are stored as a new template in the template library.

[0109] When the document to be identified is manually corrected, the template with the lowest similarity among the candidate templates is updated based on the corrected field location area.

[0110] Specifically, the process may include the following steps:

[0111] 1) Obtaining manual confirmation results: Receive the manual review results for the document to be identified. The manual review results include the "confirmed as correct" status or the corrected field location area and field content.

[0112] 2) Determine the type of manual review:

[0113] If the manual review result is "confirmed as correct", then execute the T3 new template process;

[0114] If the manual review result indicates that the issue has been corrected, then proceed with the T4 template replacement process.

[0115] T3: New Template Process:

[0116] T31: Extract the layout fingerprint of the document to be identified and record it as a new fingerprint;

[0117] T32: Calculate the similarity between the newly added fingerprint and the layout fingerprint of each existing template in the template library;

[0118] T33: If the similarity between the newly added fingerprint and any existing template in the template library is lower than the preset addition threshold, then the layout fingerprint of the document to be identified and the actual location area of ​​each field are stored in the template library as a new historical template.

[0119] T34: If the similarity between the newly added fingerprint and an existing template is higher than the newly added threshold, it is determined to be a duplicate template, the newly added operation is not performed, and the usage frequency count of the existing template is accumulated.

[0120] T4: Template Replacement Process:

[0121] T41: Identify the template with the lowest similarity among the candidate templates and record it as the template to be replaced;

[0122] T42: Generate a revised template based on the manually corrected field location areas;

[0123] T43: Calculate the degree of difference between the layout fingerprint of the revised template and the layout fingerprint of the template to be replaced;

[0124] T44: If the difference exceeds the preset replacement threshold, the template to be replaced is deleted from the template library, and the revised template is stored in the template library;

[0125] T45: If the difference does not exceed the replacement threshold, the template to be replaced is retained, and the modified template is marked as a variant version of the template to be replaced and stored in the associated storage area for use as an additional candidate template in subsequent weighted fusion identification.

[0126] 3) Template library capacity management: When the number of templates in the template library exceeds the preset maximum capacity threshold, templates are eliminated in order of their usage frequency from low to high until the template library capacity drops below the maximum capacity threshold. Templates marked as variant versions are eliminated before the main version templates.

[0127] In one embodiment, the method further includes:

[0128] Obtain the final recognition results for each of multiple documents to be recognized in the same batch;

[0129] The system invokes a preset batch-based constraint rule base, which includes at least one of the following constraint types:

[0130] The summation constraint means that the sum of the identification results of multiple sub-item fields should match the identification result of the total item field;

[0131] Consistency constraint, which means that the recognition results of a specified field in the same batch should be the same as each other;

[0132] Ordinal constraint, that is, document numbers should be consecutive and non-repeating;

[0133] Constraint validation is performed on multiple documents in the batch to identify abnormal fields that violate constraint rules; abnormal fields are corrected, and a batch validation report is generated.

[0134] In this embodiment, the system collects the final recognition results of multiple documents from the same batch. Each document has already obtained the recognition values ​​for each field through the preceding steps, and some fields may have been manually verified. For example, a batch of ten purchase invoices, each containing an invoice code, amount excluding tax, tax amount, total price including tax, and document number. The system, based on a pre-set constraint rule library for the business scenario, includes at least the following three types: Summation constraints, such as requiring the sum of the amount excluding tax and the tax amount on each invoice to equal the total price including tax, allowing for minimal error; Consistency constraints, such as requiring all invoice codes in the same batch to be identical, as they come from the same invoice book; and Ordinal constraints, such as requiring document numbers to be consecutively increasing and non-repeating, such as INV-001, INV-002, etc. The system applies these rules one by one. For summation constraints, the system calculates the sum of the left-hand fields for each document and compares it with the right-hand fields. If the difference exceeds the tolerance, the total field is considered abnormal. For consistency constraints, the system extracts the values ​​of specified fields from all documents, identifies a few documents that do not match the mode, and marks their corresponding fields as abnormal. For ordinal constraints, all document numbers are sorted, and checks are performed for skipped, duplicate, or missing numbers. Documents with abnormal numbers are recorded as problem items. For fields violating summation constraints, the system calculates the correct value based on the constraint relationship, automatically corrects it, and marks it as "automatically corrected." For fields violating consistency constraints, the system adopts the mode value for replacement and records the original identified value for future reference. For skipped or duplicate numbers in ordinal constraints, the system cannot automatically fill in missing documents, but it will clearly list the missing number sequence in the report, prompting the user to manually verify it. The system summarizes all verification results and outputs a batch verification report. The report contains three parts: a list of normal documents that passed constraint verification; a list of automatically corrected fields, indicating the values ​​before and after correction and the constraint rules on which they were based; and abnormal items that cannot be automatically corrected, such as missing document numbers, which require manual intervention. This report allows users to quickly locate problems in batch identification, significantly reducing the workload of checking each document individually.

[0135] The above embodiments, through multi-dimensional verification of summation constraints, consistency constraints, and ordinal constraints, enable the system to automatically detect logical contradictions and numerical errors between documents within a batch, ensuring the overall consistency of data within the same batch and avoiding situations where individual documents are correctly identified but become unreasonable after batch aggregation. For minor deviations in summation constraints, the system can intelligently correct them based on an inverse proportional distribution of confidence levels; for deviations in consistency constraints, the system automatically adopts the mode standard value for replacement. This allows most common identification errors to be automatically corrected without manual intervention, significantly reducing the cost of manual review. When the same field violates multiple constraints simultaneously, conflict resolution is performed according to the priority order of summation constraints, consistency constraints, and ordinal constraints, avoiding the problem of conflicting correction instructions causing the system to be at a loss. Unresolved conflicts are explicitly marked for manual review and conflict information is output, ensuring that anomalies are not masked.

[0136] Furthermore, in one embodiment, the correction of the abnormal field includes:

[0137] For abnormal fields that violate the summation constraint, calculate the difference between the sum of the sub-items and the total item. If the difference is less than the preset threshold, distribute the difference inversely proportionally to the recognition confidence of each sub-item field to one or more sub-item fields with the lowest confidence, and automatically correct the recognition results of the sub-item fields.

[0138] For abnormal fields that violate consistency constraints, the identification result with the highest frequency of abnormal fields in the same batch is taken as the standard value, and abnormal fields that deviate from the standard value are automatically corrected to the standard value.

[0139] When the same abnormal field violates multiple constraint rules at the same time, the conflict is resolved in a preset priority order; if the conflict still exists after the conflict is resolved, the abnormal field is marked as pending manual review and the information of each constraint rule that caused the conflict is output.

[0140] Among them, the priority of summation constraints, consistency constraints, and ordinal constraints decreases in that order.

[0141] In this embodiment, when the system detects a violation of the summation constraint on a document, it first calculates the difference between the sum of the sub-items and the total. If this difference is less than a preset error threshold, the system determines it as a minor deviation that can be automatically corrected. At this point, the system checks the recognition confidence level of each sub-item field and distributes the difference inversely proportionally to one or more sub-items with the lowest confidence level. In other words, the less reliable the recognition result of a sub-item, the more correction is required. After correction, the recognition results of these sub-item fields are updated to new values, thus making the summation equation true. For abnormal fields that violate consistency constraints, the system statistically analyzes the recognition results of that field across all documents in the same batch and identifies the most frequent result as the standard value. Any abnormal field that is not equal to this standard value is automatically corrected to the standard value. This method is applicable to information such as invoice codes and supplier names that should be consistent across the entire batch.

[0142] When the same anomalous field violates multiple constraints simultaneously, the system resolves conflicts according to a preset priority order. The priorities, from highest to lowest, are: summation constraints (highest), consistency constraints (second highest), and ordinal constraints (lowest). The system prioritizes the correction requirements of higher-priority constraints. If the correction result of a higher-priority constraint conflicts with the requirements of a lower-priority constraint, the higher-priority constraint takes precedence. For example, if a field violates both a summation constraint and a consistency constraint, the system will first correct it according to the summation constraint method, without considering the consistency constraint correction. If, after conflict resolution, the anomalous field still has irreconcilable conflicts—for example, the corrected value cannot simultaneously satisfy two high-priority constraints—the system will not force a correction. Instead, it will mark the field as awaiting manual review and output information about the constraints causing the conflict for manual judgment and handling.

[0143] The above embodiments address the summation constraint deviation by distributing the difference in inverse proportion to the confidence level, prioritizing the allocation of correction to the sub-item with the lowest identification confidence. This ensures the validity of the summation equation while preserving the original values ​​of high-confidence identification results to the greatest extent possible, making the correction logic reasonable and interpretable. For consistency constraints, the mode standard value is used to automatically correct minority deviations, fully leveraging the data redundancy among documents in the same batch, eliminating the need for additional manual annotation to complete error correction. Conflict resolution is achieved through a clear priority (summation > consistency > ordinal number), ensuring a deterministic decision-making basis for the correction process. Unresolved conflicts are promptly marked for manual review and conflict information is output, avoiding the risks associated with automatic error correction and balancing automation efficiency with result reliability.

[0144] In one embodiment, the method further includes a confidence dynamic correction step:

[0145] Obtain the initial recognition confidence score of the OCR engine for the target field;

[0146] The business scenario context library is invoked. The context library stores statistical features of each field for different business scenarios. The statistical features include mean, standard deviation, and common value range.

[0147] Calculate the degree of deviation between the recognition result of the target field and the statistical features, determine the context correction coefficient based on the degree of deviation, and calculate the final confidence based on the initial recognition confidence and the context correction coefficient;

[0148] The appropriate processing is performed based on the threshold range of the final confidence level: if the final confidence level is higher than the first threshold, it will pass automatically; if the final confidence level is lower than the first threshold but higher than the second threshold, cross-validation of related documents will be automatically triggered; if the final confidence level is lower than the second threshold, it will be suspended and await manual review.

[0149] The system first obtains the initial recognition confidence score of the target field from the OCR engine. This value reflects the reliability at the character recognition level. Then, the system calls the business scenario context library, which stores statistical characteristics of each field for different business scenarios, such as the common range of invoice amounts, mean and standard deviation, or reasonable intervals for dates.

[0150] The system calculates the degree of deviation between the recognition result of the target field and the aforementioned statistical features. For example, if the recognized amount is much higher than the historical average, the deviation is large. A context correction coefficient is determined based on the degree of deviation: the smaller the deviation, the closer the correction coefficient is to 1, which can even increase the confidence level; the larger the deviation, the smaller the correction coefficient, used to reduce the confidence level. The system multiplies the initial recognition confidence level by this correction coefficient to obtain the final confidence level.

[0151] Based on the threshold range of the final confidence level, the system performs tiered processing. If the final confidence level is higher than the first threshold, it indicates that the recognition result is reliable at the character level and conforms to business common sense, and the system automatically passes the field. If the final confidence level is lower than the first threshold but higher than the second threshold, the system automatically triggers cross-validation of related documents, such as comparing the amount of the invoice with the corresponding warehouse receipt. If the final confidence level is lower than the second threshold, it indicates that the result is unreliable, and the system suspends the field for manual review.

[0152] This implementation dynamically corrects the original OCR confidence level by introducing business context, effectively solving the problem that relying solely on character recognition confidence level cannot detect "correct recognition but business-inappropriate" cases. The tiered processing mechanism implements differentiated follow-up strategies: high confidence levels are automatically approved, medium confidence levels trigger cross-validation, and low confidence levels are transferred to manual review. This avoids unnecessary full-scale manual checks and prevents obviously abnormal results from directly entering the business system, achieving a good balance between automation efficiency and result reliability.

[0153] In one embodiment, the method further includes:

[0154] Once the recognition result of the target field is manually confirmed to be correct, the recognition result is used as new sample data to update the statistical features of the corresponding field in the business scenario context library.

[0155] When the recognition result of a target field is manually corrected, the corrected value is used as the correct sample to update the statistical features. In this embodiment, the system provides a manual review interface for each target field during the recognition process. When the recognition result of a field is manually confirmed as correct, the system uses the recognition result as a positive sample, stores it in the historical data set of the corresponding field in the business scenario context library, and recalculates the mean, standard deviation, and common value range of the field to achieve dynamic updates of the statistical features. When the recognition result of a target field is manually corrected, the system does not adopt the original recognition value, but uses the manually corrected value as the correct sample to update the statistical features. At the same time, the system can selectively record the original error value as a negative sample for subsequent analysis of the pattern of recognition errors. The update operation is executed in real time or in batches to ensure that the context library always reflects the true distribution of the most recently reviewed data. To avoid outliers contaminating the statistical features, the system performs outlier detection on new samples before updating, for example, determining whether the value exceeds three times the current mean standard deviation. If it does, it is temporarily not included in the update and prompts for manual confirmation. In addition, the system sets sample decay weights according to the time dimension, with newer samples having higher weights, so that statistical features can adapt to the gradual changes in business data.

[0156] This implementation achieves a closed-loop self-evolution of the business scenario context library. The results of each manual review are fed back to optimize the confidence level correction for subsequent identifications, making the system increasingly adaptable to the real data distribution of the current business. This dynamic update mechanism significantly reduces the need for repeated manual intervention on the same type of anomalies, lowering long-term maintenance costs. Simultaneously, outlier detection and sample decay prevent the continuous contamination of statistical features by occasional errors or outdated data, ensuring the reliability of the correction coefficients.

[0157] See Figure 2 In one embodiment, the present invention also provides a device for batch identification and automatic data matching and verification of documents based on AI scanning, the device comprising:

[0158] The template library generation unit 100 is used to store multiple historical versions of identification templates for the same type of document to generate a template library. Each identification template contains at least the field name, the expected location area of ​​the field, and the relative positional relationship between the fields.

[0159] The layout fingerprint recognition unit 200 is used to extract the layout features of the document to be recognized and generate the layout fingerprint of the document to be recognized.

[0160] The candidate template selection unit 300 is used to calculate the similarity between the layout fingerprint of the document to be identified and the layout fingerprint of each historical template in the template library, and select the top K templates with the highest similarity as candidate templates.

[0161] The target field identification unit 400 is used to determine the target field on the document to be identified. It performs location identification based on the expected location area of ​​the field corresponding to the target field in each candidate template to obtain K candidate identification results. It assigns fusion weights to each candidate identification result based on the similarity of each candidate template and determines the final identification result of the target field through weighted voting.

[0162] The consistency verification unit 500 is used to verify the consistency of the positional regions of the fields corresponding to the target field given by each candidate template. If the difference between each positional region exceeds a preset threshold, the target field is marked as pending verification. If the difference between each positional region does not exceed the preset threshold, the final recognition result determined by weighted voting is output as the recognition result of the target field.

[0163] It is understood that the functions or modules of the automatic pairing and verification device provided in this embodiment can be used to execute the methods described in the above method embodiments. The specific implementation can be referred to the description of the above method embodiments, and for the sake of brevity, it will not be repeated here.

[0164] The present invention also provides an electronic device including a processor and a memory, the memory being used to store computer program code, the computer program code including computer instructions, wherein when the processor executes the computer instructions, the electronic device performs a method as described in any of the above possible implementations.

[0165] The present invention also provides a computer-readable storage medium storing a computer program, the computer program including program instructions that, when executed by a processor of an electronic device, cause the processor to perform a method as described in any of the above possible implementations.

[0166] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.

Claims

1. A method for batch identification and automatic data matching verification of documents based on AI scanning, characterized in that, The method includes: For documents of the same type, store multiple historical versions of recognition templates to generate a template library. Each recognition template includes at least the field name, the expected location area of ​​the field, and the relative positional relationship between the fields. Extract the layout features of the document to be identified and generate the layout fingerprint of the document to be identified; Calculate the similarity between the layout fingerprint of the document to be identified and the layout fingerprint of each historical template in the template library, and select the top K templates with the highest similarity as candidate templates; The target field to be identified on the document to be identified is determined. The field is located and identified according to the expected location area of ​​the field corresponding to the target field in each candidate template, resulting in K candidate identification results. The fusion weight is assigned to each candidate identification result according to the similarity of each candidate template, and the final identification result of the target field is determined by weighted voting. The consistency of the field location regions corresponding to the target field given by each candidate template is checked. If the difference between each location region exceeds a preset threshold, the target field is marked as pending review. If the difference between each location region does not exceed the preset threshold, the final recognition result determined by weighted voting is output as the recognition result of the target field.

2. The method for batch identification and automatic data pairing verification of documents based on AI scanning according to claim 1, characterized in that, The fingerprint on the screen is generated in the following way: Feature extraction is performed on the document to be identified, including extracting the text line density distribution, table line intersection distribution, blank area ratio, and relative coordinates of key identification fields. The key identification fields include document type identifier, document number field, and date field. Each extracted feature is converted into a feature vector, and the feature vectors are concatenated to obtain a fused feature vector. Principal component analysis is used to reduce the dimensionality of the fused feature vector, and the dimensionality-reduced vector is used as the layout fingerprint.

3. The method for batch identification and automatic data matching verification of documents based on AI scanning according to claim 1, characterized in that, The method further includes: Once the document to be identified has been manually confirmed to be correct, the fingerprint of the document and the actual location area of ​​each field are stored as a new template in the template library. When the document to be identified is manually corrected, the template with the lowest similarity among the candidate templates is updated based on the corrected field location area.

4. The method for batch identification and automatic data pairing verification of documents based on AI scanning according to claim 1, characterized in that, The method further includes: Obtain the final recognition results for each of multiple documents to be recognized in the same batch; The system invokes a preset batch-based constraint rule base, which includes at least one of the following constraint types: The summation constraint means that the sum of the identification results of multiple sub-item fields should match the identification result of the total item field; Consistency constraint, which means that the recognition results of a specified field in the same batch should be the same as each other; Ordinal constraint, that is, document numbers should be consecutive and non-repeating; Constraint validation is performed on multiple documents in the batch to identify abnormal fields that violate constraint rules; abnormal fields are corrected, and a batch validation report is generated.

5. The method for batch identification and automatic data pairing verification of documents based on AI scanning according to claim 4, characterized in that, The correction of abnormal fields includes: For abnormal fields that violate the summation constraint, calculate the difference between the sum of the sub-items and the total item. If the difference is less than the preset threshold, distribute the difference inversely proportionally to the recognition confidence of each sub-item field to one or more sub-item fields with the lowest confidence, and automatically correct the recognition results of the sub-item fields. For abnormal fields that violate consistency constraints, the identification result with the highest frequency of abnormal fields in the same batch is taken as the standard value, and abnormal fields that deviate from the standard value are automatically corrected to the standard value. When the same abnormal field violates multiple constraint rules at the same time, the conflict is resolved in a preset priority order; if the conflict still exists after the conflict is resolved, the abnormal field is marked as pending manual review and the information of each constraint rule that caused the conflict is output. Among them, the priority of summation constraints, consistency constraints, and ordinal constraints decreases in that order.

6. The method for batch identification and automatic data pairing verification of documents based on AI scanning according to claim 1, characterized in that, The method further includes a confidence level dynamic correction step: Obtain the initial recognition confidence score of the OCR engine for the target field; The business scenario context library is invoked. The context library stores statistical features of each field for different business scenarios. The statistical features include mean, standard deviation, and common value range. Calculate the degree of deviation between the recognition result of the target field and the statistical features, determine the context correction coefficient based on the degree of deviation, and calculate the final confidence based on the initial recognition confidence and the context correction coefficient; The appropriate processing is performed based on the threshold range of the final confidence level: if the final confidence level is higher than the first threshold, it will pass automatically; if the final confidence level is lower than the first threshold but higher than the second threshold, cross-validation of related documents will be automatically triggered; if the final confidence level is lower than the second threshold, it will be suspended and await manual review.

7. The method for batch identification and automatic data pairing verification of documents based on AI scanning according to claim 6, characterized in that, The method further includes: Once the recognition result of the target field is manually confirmed to be correct, the recognition result is used as new sample data to update the statistical features of the corresponding field in the business scenario context library. Once the identification result of the target field is manually corrected, the corrected value is used as the correct sample to update the statistical feature.

8. A device for batch recognition and automatic data matching and verification of documents based on AI scanning, characterized in that, The device includes: The template library generation unit is used to store multiple historical versions of identification templates for the same type of document to generate a template library. Each identification template contains at least the field name, the expected location area of ​​the field, and the relative positional relationship between the fields. The layout fingerprint recognition unit is used to extract the layout features of the document to be recognized and generate the layout fingerprint of the document to be recognized. The candidate template selection unit is used to calculate the similarity between the layout fingerprint of the document to be identified and the layout fingerprint of each historical template in the template library, and select the top K templates with the highest similarity as candidate templates. The target field identification unit is used to determine the target field on the document to be identified. It locates and identifies the target field according to the expected location area of ​​the field corresponding to the target field in each candidate template, and obtains K candidate identification results. It assigns fusion weights to each candidate identification result according to the similarity of each candidate template, and determines the final identification result of the target field through weighted voting. The consistency verification unit is used to verify the consistency of the positional regions of the fields corresponding to the target field given by each candidate template. If the difference between each positional region exceeds a preset threshold, the target field is marked as pending review. If the difference between each positional region does not exceed the preset threshold, the final recognition result determined by weighted voting is output as the recognition result of the target field.

9. An electronic device, characterized in that, include: The electronic device includes a processor and a memory, the memory being used to store computer program code, the computer program code including computer instructions, wherein when the processor executes the computer instructions, the electronic device performs the AI-based document batch recognition and automatic data pairing verification method as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, which includes program instructions that, when executed by a processor of an electronic device, cause the processor to perform the AI-based document batch recognition and automatic data matching verification method according to any one of claims 1 to 7.