Invoice data recognition comparison method and device
By using a large language model and a multi-level matching strategy, the problem of low efficiency in reconciling invoices and system bills was solved, realizing automated reconciliation of invoice data and improving accuracy, and generating efficient reconciliation discrepancy reports.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SHANGHAI RUZHI INFORMATION TECH CO LTD
- Filing Date
- 2026-03-18
- Publication Date
- 2026-06-05
AI Technical Summary
In the current technology, the verification of invoices and system bills is inefficient and inaccurate, and manual verification is difficult to meet the needs of speed and accuracy.
A large language model is used to recognize text primitives and obtain planar coordinate information of invoice images. By clustering vertical coordinate differences into logical row objects, and combining multi-level matching strategies, such as single-item exact matching, multi-item combination summation matching and name fuzzy matching, a reconciliation difference report is generated.
It has enabled automated verification of invoice data, improved the efficiency and accuracy of reconciliation, and generated efficient reconciliation discrepancy reports.
Smart Images

Figure CN122157292A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of document processing technology, and in particular to a method and apparatus for identifying and comparing invoice data. Background Technology
[0002] In the daily operations of industries such as logistics and trade, reconciling invoices with system bills is a critical task. The bills to be paid recorded in the enterprise's business system are usually standardized structured data, while the invoices provided by suppliers are unstructured documents such as PDFs and images. Traditionally, staff need to manually compare the invoices with the amounts, currencies, and expense names in the system, which is not only inefficient but also prone to errors due to human negligence. With the growth of business volume, manual verification can no longer meet the demands for speed and accuracy. Summary of the Invention
[0003] This invention provides a method and apparatus for identifying and comparing invoice data, which solves the problems of low efficiency and inaccuracy in manual invoice verification in the prior art, and achieves the effect of automated verification.
[0004] This invention provides a method for identifying and comparing invoice data, comprising:
[0005] Obtain the bill data to be reconciled from the business system, and extract the amount, currency and name of each expense to construct a set of anchor points to be reconciled.
[0006] The invoice image is input into the large language model to obtain text primitives and their corresponding planar coordinate information. Based on the differences in the vertical coordinates in the planar coordinate information, the text primitives are clustered into multiple logical row objects.
[0007] Traverse the logical row object, extract the numeric fields in the logical row object, and perform numeric index matching between the extracted numeric fields and the set of anchor points to be reconciled, and filter out candidate logical rows that contain the target amount or a combination of target amounts;
[0008] A multi-level matching strategy is executed on the candidate logical rows and the set of anchor points to be reconciled to establish a mapping relationship between bill data and invoice data; the multi-level matching strategy includes at least one of single-item exact matching, multi-item combination summation matching and name fuzzy matching;
[0009] Based on the alignment results of the mapping relationship, the difference of the unmatched items is calculated, and a reconciliation difference report is generated.
[0010] According to an invoice data recognition and comparison method provided by the present invention, the method of clustering text primitives into multiple logical row objects based on the differences in the vertical coordinates in the planar coordinate information includes:
[0011] Obtain the Y-coordinate of the center point of all text primitives in the vertical direction within the plane coordinate information;
[0012] Determine the difference in the Y coordinates of the center points of two adjacent text elements. If the difference is less than a preset line height threshold, then the two text elements are determined to belong to the same physical line.
[0013] Text primitives belonging to the same physical row are sorted and concatenated according to their horizontal coordinates from smallest to largest to generate a logical row object containing the complete row text and the position information of each column within the row.
[0014] According to the invoice data recognition and comparison method provided by the present invention, the step of generating a logical row object containing complete line text and column position information within the line includes:
[0015] Based on the horizontal coordinates of the numeric fields in all logical row objects, a clustering algorithm is used to determine the horizontal range of the corresponding amount in the column of the page.
[0016] Text elements falling within the specified amount level range are marked as amount attributes, and text elements located to the left of the specified amount level range are marked as name attributes.
[0017] According to an invoice data recognition and comparison method provided by the present invention, the step of extracting numeric fields from the logical row object includes:
[0018] Extracting numeric sequences from logical row objects using regular expressions;
[0019] The system detects whether there are easily confused characters in the number sequence and replaces the erroneous characters corresponding to the easily confused characters with the correct characters; based on the preset currency decimal point rules, it converts the cleaned string into a standard floating-point number.
[0020] According to the present invention, an invoice data identification and comparison method includes a multi-level matching strategy comprising name fuzzy matching, wherein the name fuzzy matching employs an edit distance-based algorithm, and the step of performing a multi-level matching strategy on the candidate logical rows and the set of anchor points to be reconciled to establish a mapping relationship between billing data and invoice data includes:
[0021] Construct a synonym mapping table containing industry-standard fee names and common abbreviations;
[0022] Search the name field of the candidate logical row in the synonym mapping table;
[0023] If no match is found, the edit distance between the name field of the candidate logical row and the bill fee name is calculated;
[0024] When the similarity score corresponding to the edit distance is greater than the preset distance threshold, and the corresponding amounts are completely consistent, it is determined that the logical row object matches the billing expenses in the set of anchor points to be reconciled.
[0025] According to an invoice data recognition and comparison method provided by the present invention, before traversing the logical row object, the method further includes:
[0026] Determine the invoice page number and invoice number in each invoice image;
[0027] If the same invoice number is detected to appear in multiple invoice images, detect and remove non-fee text that appears repeatedly at the beginning or end of each page to merge logical line objects in multiple invoice images.
[0028] According to the invoice data recognition and comparison method provided by the present invention, the method of clustering text primitives into multiple logical row objects based on the difference in the vertical coordinates in the planar coordinate information further includes:
[0029] Identify text primitives in invoice images that correspond to functional keywords used to indicate the calculation function.
[0030] Based on the Y-coordinate of the aforementioned functional keywords, the invoice image is divided into a details area and a total area;
[0031] The logical row objects within the detailed area are used for numerical index matching with the set of anchor points to be reconciled.
[0032] The present invention also provides an invoice data recognition and comparison device, comprising:
[0033] The first processing module is used to obtain the bill data to be reconciled from the business system, and extract the amount, currency and name of each expense to build a set of anchor points to be reconciled.
[0034] The second processing module is used to input the invoice image into the large language model to obtain text primitives and their corresponding planar coordinate information, and to cluster the text primitives into multiple logical row objects based on the differences in the vertical coordinates in the planar coordinate information.
[0035] The first matching module is used to traverse the logical row object, extract the numeric fields in the logical row object, and perform numeric index matching between the extracted numeric fields and the set of anchor points to be reconciled, so as to filter out candidate logical rows containing the target amount or a combination of target amounts.
[0036] The second matching module is used to perform a multi-level matching strategy on the candidate logical rows and the set of anchor points to be reconciled in order to establish a mapping relationship between bill data and invoice data; the multi-level matching strategy includes at least one of single-item exact matching, multi-item combination summation matching and name fuzzy matching;
[0037] The third processing module is used to calculate the difference of unmatched items based on the alignment results of the mapping relationship and generate a reconciliation difference report.
[0038] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the invoice data recognition and comparison method as described above.
[0039] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the invoice data recognition and comparison method as described above.
[0040] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the invoice data recognition and comparison method as described above.
[0041] The invoice data recognition and comparison method and apparatus provided by this invention, by combining the visual recognition and coordinate extraction capabilities of a large language model, accurately restores the row and column logic of the invoice using vertical coordinate differences without relying on table lines, solves the problem of data fragmentation in invoice images, improves the efficiency of automatic verification through a multi-level matching strategy, ensures the accuracy of verification data, and can thus efficiently obtain accurate verification difference reports. Attached Figure Description
[0042] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0043] Figure 1 This is one of the flowcharts illustrating the invoice data recognition and comparison method provided by the present invention;
[0044] Figure 2 This is the second flowchart of the invoice data recognition and comparison method provided by the present invention;
[0045] Figure 3 This is a schematic diagram of the structure of the invoice data recognition and comparison device provided by the present invention;
[0046] Figure 4 is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation
[0047] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0048] The following is combined with Figure 1 Figure 4 illustrates the invoice data recognition and comparison method and apparatus of the present invention.
[0049] like Figure 1 As shown in the figure, this embodiment provides an invoice data recognition and comparison method, which can be applied to a computer system or server system (hereinafter referred to as the system). The method mainly includes the following steps.
[0050] Step 110, Data Acquisition and Anchor Point Construction.
[0051] The system retrieves a list of bills to be reconciled from business systems such as SAP and TMS via API interfaces or database connections. For each bill, the system extracts key triplet information: amount, currency, and expense name. Additionally, it can extract auxiliary information such as order number and occurrence date.
[0052] The extracted data can be loaded into the system to construct a set of anchor points to be reconciled. The anchor points in this set refer to settlement data originating from the enterprise's internal business systems and considered to be standard truth values. In this embodiment, because amounts are relatively unique and highly sensitive, the amounts in the system data are used as the primary search index, hence the term "anchor point."
[0053] To improve subsequent retrieval efficiency, a hash table structure can preferably be used to store anchor points, with the amount value as the key and the list of bill objects corresponding to that amount as the value. For example, if there are two charges of 100 yuan in the system, the data structure can be {100.00:[Bill-A,Bill-B]}.
[0054] Step 120: Obtain coordinates and perform row clustering based on the large language model.
[0055] Invoice images can be input into a Large Language Model (LLM). In this embodiment, a Large Language Model specifically refers to a model with multimodal visual understanding capabilities, such as a combined model including optical character recognition capabilities. The Large Language Model not only returns the recognized text content but also the planar coordinate information of each text block. The coordinate information is typically represented as the coordinates of the top-left and bottom-right corners, or the center point coordinates.
[0056] In other words, an invoice image can be input into a large language model to obtain text primitives and their corresponding planar coordinate information, and based on the differences in the vertical coordinates in the planar coordinate information, the text primitives can be clustered into multiple logical row objects.
[0057] Text primitives refer to the smallest text units extracted from images using a large language model, typically containing text content and its bounding box coordinates. A physical row refers to a collection of text primitives that are visually located at the same horizontal level, while a logical row refers to a structured data object that has been cleaned, reorganized, and sorted to have complete semantics, such as containing column attributes like fee name, amount, and tax rate.
[0058] Because scanned images may be tilted or jittery, the Y-coordinates of text within the same line are often not completely consistent. This application employs a dynamic threshold clustering method for clustering.
[0059] First, center point calculation is performed by iterating through all text elements and calculating their vertical center point coordinates. Then, all elements are sorted according to their vertical center point coordinates, and the difference between adjacent elements is calculated. A line height threshold can be set, typically 0.5 times the average character height. If the difference is less than the preset line height threshold, the two text elements are considered to belong to the same physical line. If the difference is greater than the preset line height threshold, a line break has occurred, and a new physical line container can be created.
[0060] After confirming that all text elements belong to the same physical row, their reading order needs to be restored. Text elements within the same physical row are sorted in ascending order based on their top-left horizontal coordinates. Further, the sorted text content can be concatenated, with spaces or tabs inserted, to generate a logical row object. This logical row object not only contains the concatenated string but also retains the original coordinates of each individual term within the row for subsequent column positioning.
[0061] To prevent the areas corresponding to calculation functions such as "Total" and "Tax Amount" in the footer from being mistakenly identified as detailed expenses, it is necessary to divide the area into regions.
[0062] In some embodiments, based on the difference in vertical coordinates in the planar coordinate information, text primitives are clustered into multiple logical row objects, and the method further includes: identifying text primitives in the invoice image corresponding to functional keywords used to indicate the function of the calculation function; dividing the invoice image into a detail area and a total area based on the Y coordinate of the functional keywords; wherein, the logical row objects in the detail area are used for numerical index matching with the set of anchor points to be verified.
[0063] It can scan all text elements and search for functional keywords such as "Total", "Total", "Amount", "Remarks", etc.
[0064] Taking "Total" as an example, we can find the Y-coordinate of the row containing "Total". The region with a Y-coordinate less than that of the row containing "Total" is defined as the detail region. The region with a Y-coordinate greater than that of the row containing "Total" is defined as the total region. In this case, subsequent unit price matching is performed only in the detail region, while the total result of multiple summation matching can be further verified against the data in the total region.
[0065] Step 130: Numerical extraction and candidate logical row filtering.
[0066] Suppose that the amount extracted from a certain logical line in an invoice is Value1, a record with Key equal to Value1 can be directly searched in the set of anchor points to be reconciled constructed in the aforementioned embodiment. If it exists, the logical line is marked as a single-item matching candidate. If Value1 does not exist in the set of anchor points to be reconciled, but its value is less than some large-amount anchor points in the set, then the logical line can be marked as a combined matching candidate and placed in the candidate pool.
[0067] In other words, you can iterate through the logical row object, extract the numeric fields in the logical row object, and then perform numeric index matching between the extracted numeric fields and the set of anchor points to be reconciled, and filter out candidate logical rows that contain the target amount or a combination of target amounts.
[0068] The above process is a coarse screening process, designed to quickly narrow down the search scope. The system scans the reconstructed invoice data line by line, using regular expressions to identify all possible "amount" numeric strings. The system then uses these numbers to quickly search the set of anchor points to be verified. If a certain amount on the invoice directly matches the system's bill amount, or if several amounts on the invoice add up to a large bill in the system, the system will mark these corresponding logical rows as candidate rows and put them into the processing pool, while filtering out other irrelevant and distracting rows such as dates and long notes.
[0069] Step 140: Execute the multi-level matching strategy.
[0070] The strategy includes at least one of the following: exact match, summation match of multiple combinations, and fuzzy name match.
[0071] Strategy 1: Exact Match. The conditions are that the invoice amount equals the bill amount, and the invoice name equals the bill name. This method can directly lock in the match and generate a mapping relationship.
[0072] Strategy Two: Fuzzy Name Matching. For example, for terms with the same amount but slightly different names, such as "freight fee" and "transportation service fee," an industry synonym mapping table needs to be built. Matching is performed by checking if related terms are in the synonym list. If no match is found, a similarity score based on edit distance can be further calculated.
[0073] In some embodiments, the multi-level matching strategy includes name fuzzy matching, which employs an edit distance-based algorithm. The multi-level matching strategy is applied to candidate logical rows and the set of anchor points to be reconciled to establish a mapping relationship between billing data and invoice data. This includes: constructing a synonym mapping table containing industry-standard expense names and common abbreviations; searching the name field of candidate logical rows in the synonym mapping table; if no match is found, calculating the edit distance between the name field of the candidate logical row and the expense name in the billing statement; and determining that the logical row object matches the expense in the set of anchor points to be reconciled when the similarity score corresponding to the edit distance is greater than a preset distance threshold and the corresponding amounts are completely identical.
[0074] To address the issue of inconsistent naming of the same expense on different invoices, the system pre-configures or dynamically maintains an industry synonym mapping table. This industry synonym mapping table is a collection of key-value pairs that maps various non-standard, abbreviated, or aliased expense names to standard names within the system. It allows for rapid matching with minimal computational cost, prioritizing the handling of common industry-specific variations.
[0075] When the expense name on the invoice is not in the synonym mapping table, the system initiates an algorithm-based similarity calculation. An edit distance algorithm can be used to quantify the number of operations required to change the name on the invoice to the name on the bill, such as inserting, deleting, and replacing characters. This distance value objectively reflects the literal similarity between the two strings, and can calculate the difference even if there are individual typos caused by text recognition.
[0076] When the similarity score corresponding to the edit distance is greater than the preset distance threshold, and the corresponding amounts are exactly the same, the logical row object is determined to match the bill expense in the set of anchor points to be reconciled. The edit distance can be converted into a normalized similarity score, which is between 0 and 1. Only when this similarity is higher than the set safety threshold, such as 0.8, which means they are very similar, and the invoice amount and the bill amount are exactly the same, can the system determine that the match is successful.
[0077] It should be noted that making the exact same amount a necessary condition is to prevent two expenses with similar names but different actual business operations, such as the first phase freight and the second phase freight, from being mistakenly linked.
[0078] Strategy 3: Multi-item combination summation matching.
[0079] To solve the problem of merging multiple lines into one, the target value can be a large unmatched bill in the system, and the candidate set can be a group of small unmatched lines in the invoice.
[0080] Specifically, from the unmatched logical rows of the invoice, all candidate rows with amounts lower than the specified target sum can be filtered out; a subset summation algorithm is used to search in the candidate rows for whether there is a set of logical rows whose sums are equal to the target sum; if such a matching relationship exists, and the expense names of the set of logical rows and the expense names of the invoice data satisfy a preset mathematical inclusion relationship, then a one-to-many mapping is established.
[0081] It should be noted that multi-level matching strategies can be applied to candidate logical rows and the set of anchor points to be reconciled in order to establish a mapping relationship between billing data and invoice data; the strategies include at least one of single-item exact matching, multi-item combination summation matching and name fuzzy matching.
[0082] In some embodiments, the system may first attempt the strictest single-item exact match, where the amount and name are exactly the same; if no match is found, it will proceed to fuzzy name matching, tolerating character differences in the name such as abbreviations or typos; if still no match is found, it will initiate a highly complex multi-item combination summation match, attempting to find cases where the sum of multiple invoice amounts equals a single system invoice. Through this tiered strategy, the system can maximize the automated approval rate of reconciliation while ensuring accuracy, resolving complex one-to-many or many-to-one scenarios.
[0083] Step 150: Difference report generated.
[0084] After aligning all the data, traversing all the data yields the following state results.
[0085] Status A: Complete match, amount and name match.
[0086] Status B: Deviation match, amount matches, name fuzzy match.
[0087] Status C: Combination matching, multiple lines of amounts are consistent after merging.
[0088] Status D: Not matched. The system has the invoice but not the invoice (e.g., the invoice was missed), or the invoice exists but not in the system (e.g., multiple invoices / illegal charges).
[0089] It can generate difference reports in JSON or Excel format, highlight data under different states, and calculate the total difference.
[0090] In other words, based on the alignment results of the mapping relationship, the difference for unmatched items can be calculated, generating a reconciliation difference report. After completing all the above matching attempts, the system can label all data with status tags, such as "Match successful," "Invoice available in system but not available," and "Invoice available but not available in system." The system will summarize the unmatched items, calculate the difference in amount between the two parties, and generate a visual report containing detailed difference information, such as an Excel or JSON file. This report can help finance personnel quickly locate problems such as missing invoices, multiple invoices, or incorrect amounts, thereby completing the final financial closing procedures.
[0091] In some embodiments, extracting numeric fields from the logical row object includes: extracting a sequence of numbers from the logical row object using regular expressions; detecting whether there are easily confused characters in the sequence of numbers, replacing the erroneous characters corresponding to the easily confused characters with the corresponding accurate characters; and converting the cleaned string into a standard floating-point number based on preset currency decimal point rules.
[0092] For the text content in logical lines, a preset regular expression can be used for pattern matching. This expression is designed to capture string segments containing thousands separators, decimal points, and plus / minus signs. This step aims to accurately identify all potential numerical candidates from mixed text containing Chinese characters, English words, and special symbols.
[0093] To address common errors in text recognition, the extracted numeric string can be scanned to check for the presence of similar-looking letters, such as 'l' and 'I', or 'O' and '0'. By considering contextual logic (e.g., both sides are numbers), these misidentified letters can be forcibly replaced with their corresponding numbers. Subsequently, the system removes interfering thousands separators such as commas and parses the cleaned pure numeric string into a standard computer-calculateable floating-point number format according to currency rules, ensuring the correctness of subsequent mathematical operations.
[0094] In some embodiments, generating a logical row object that includes complete row text and column position information within the row includes: determining the horizontal range of the amount in the column corresponding to the amount item on the page using a clustering algorithm based on the horizontal coordinates of the numeric fields in all logical row objects; marking text elements that fall within the horizontal range of the amount as amount attributes, and marking text elements located to the left of the horizontal range of the amount as name attributes.
[0095] Because invoices are typically formatted with alignment, the amount column exhibits a noticeable clustering effect on the X-axis. The system collects the horizontal center coordinates of the numbers identified in all rows and analyzes the distribution density of these coordinates using one-dimensional clustering algorithms such as K-Means or histogram peak detection. The algorithm can automatically identify the coordinate interval with the highest density on the right side of the page and lock it as the valid horizontal interval for the amount column, thus locating the amount attribute even without table borders.
[0096] After establishing the range for the amount column, the system scans the data in each row again. Text whose X-coordinate falls within this range is labeled as an amount; text whose X-coordinate is to the left of the range is typically a fee description and is therefore labeled as a name. This spatially based attribute labeling method effectively prevents misidentification of quantities, tax rates, or dates within a row as amounts, greatly improving the accuracy of data extraction.
[0097] Specifically, it can iterate through all logical row objects. It identifies all numeric fields within a row, i.e., text conforming to a number format. It then collects the horizontal center coordinates of these numeric fields, forming a one-dimensional coordinate set.
[0098] One-dimensional K-Means clustering or histogram peak detection algorithms can be used. Due to the regularity of invoice layout, the amount columns are usually vertically aligned. Therefore, the data will exhibit a clear clustered distribution. By identifying the rightmost cluster or the one whose numerical characteristics best match the amount rather than quantity or tax rate, the boundary of this cluster is determined and defined as the amount horizontal interval. Each text element in the logical row is then traversed again. If the X-coordinate of the text element falls within the amount horizontal interval, it is marked as the attribute: amount. If the X-coordinate of the text element is to the left of the interval, it can be marked as the attribute: name or specification. Understandably, this operation can be performed completely without relying on table borders; even in a plain text list, it can accurately distinguish which column contains numerical amounts and which contains text.
[0099] In some embodiments, before traversing the logical row objects, the invoice data recognition and comparison method of the present invention further includes: determining the invoice page number information and invoice number in each invoice image; if the same invoice number is detected to appear in multiple invoice images, detecting and removing non-fee text that appears repeatedly at the beginning or end of each page to merge the logical row objects in multiple invoice images.
[0100] In some scenarios, an invoice list can be up to five pages long, with each page containing the same headers such as supplier name, date, and footers such as page number. If text recognition is used directly, these headers might be mistakenly identified as expense lines, leading to duplicate matching or errors.
[0101] In this scenario, for each input image, the invoice number and page number information in the upper right corner can be extracted first. If multiple images are detected to have the same invoice number, a multi-page merging mode can be triggered. The first N rows and the last M rows of the first page are also selected as fingerprints. For subsequent pages 2 to k, their header text is compared with the fingerprint of the first page. If a high degree of similarity is found, such as both containing "XX Logistics Co., Ltd.", then that area is determined to be a duplicate header. Similarly, duplicate footers can be removed. The middle segment after removing duplicates, i.e., the pure detail rows, is appended to the main logical row list, ensuring that the data entering the matching algorithm is pure and continuous expense details, avoiding interference from dirty data.
[0102] In some embodiments, the invoice data recognition and comparison method of the present invention mainly includes steps 210, 220, 230, 240 and 250.
[0103] Step 210: Obtain the bill data to be reconciled from the business system, and extract the amount, currency and name of each expense to construct a set of anchor points to be reconciled.
[0104] Step 220: Input the invoice image into the large language model to obtain text primitives and their corresponding planar coordinate information, and cluster the text primitives into multiple logical row objects based on the differences in the vertical coordinates in the planar coordinate information.
[0105] Step 230: Traverse the logical row objects, extract the numeric fields in the logical row objects, and perform numeric index matching between the extracted numeric fields and the set of anchor points to be reconciled to filter out candidate logical rows that contain the target amount or a combination of target amounts.
[0106] Step 240: Perform a multi-level matching strategy on the candidate logical rows and the set of anchor points to be reconciled to establish a mapping relationship between bill data and invoice data; the strategy includes at least one of single-item exact matching, multi-item combination summation matching and name fuzzy matching;
[0107] Step 250: Based on the alignment results of the mapping relationship, calculate the difference of the unmatched items and generate a reconciliation difference report.
[0108] It is understood that the descriptions of steps 210 to 250 above can refer to the descriptions of steps 110 to 150 in the foregoing embodiments, and will not be repeated here.
[0109] The invoice data recognition and comparison method provided by the present invention combines the visual recognition and coordinate extraction capabilities of a large language model, and accurately restores the row and column logic of the invoice by utilizing the vertical coordinate difference without relying on table lines. This solves the problem of data fragmentation in invoice images, improves the efficiency of automatic verification through a multi-level matching strategy, ensures the accuracy of verification data, and thus efficiently obtains accurate verification difference reports.
[0110] The invoice data recognition and comparison device provided by the present invention is described below. The invoice data recognition and comparison device described below can be referred to in correspondence with the invoice data recognition and comparison method described above.
[0111] like Figure 3 As shown, the invoice data recognition and comparison device of this invention mainly includes: a first processing module 310, a second processing module 320, a first matching module 330, a second matching module 340, and a third processing module 350.
[0112] The first processing module 310 is used to obtain bill data to be reconciled from the business system, and extract the amount, currency and name of each expense to construct a set of anchor points to be reconciled.
[0113] The second processing module 320 is used to input the invoice image into the large language model to obtain text primitives and their corresponding planar coordinate information, and to cluster the text primitives into multiple logical row objects based on the differences in the vertical coordinates in the planar coordinate information.
[0114] The first matching module 330 is used to traverse the logical row object, extract the numeric fields in the logical row object, and perform numeric index matching between the extracted numeric fields and the set of anchor points to be reconciled, and filter out candidate logical rows that contain the target amount or a combination of target amounts.
[0115] The second matching module 340 is used to perform a multi-level matching strategy on the candidate logical rows and the set of anchor points to be reconciled in order to establish a mapping relationship between bill data and invoice data; the strategy includes at least one of the following: single exact matching, multiple combination summation matching and name fuzzy matching.
[0116] The third processing module 350 is used to calculate the difference of unmatched items based on the alignment results of the mapping relationship and generate a reconciliation difference report.
[0117] The invoice data recognition and comparison device provided in this embodiment of the invention combines the visual recognition and coordinate extraction capabilities of a large language model, and accurately restores the row and column logic of the invoice by utilizing the vertical coordinate difference without relying on table lines. This solves the problem of data fragmentation in invoice images, improves the efficiency of automatic verification through a multi-level matching strategy, ensures the accuracy of verification data, and thus can efficiently obtain accurate verification difference reports.
[0118] Figure 4 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 4 As shown, the electronic device may include: a processor 410, a communication interface 420, a memory 430, and a communication bus 440, wherein the processor 410, the communication interface 420, and the memory 430 communicate with each other through the communication bus 440. The processor 410 can call logical instructions in the memory 430 to execute an invoice data recognition and comparison method. This method includes: obtaining bill data to be reconciled from the business system, extracting the amount, currency, and expense name of each expense, and constructing a set of anchor points to be reconciled; inputting the invoice image into a large language model to obtain text primitives and their corresponding planar coordinate information, and clustering the text primitives into multiple logical row objects based on the differences in the vertical coordinates in the planar coordinate information; traversing the logical row objects, extracting numeric fields from the logical row objects, and performing numeric index matching between the extracted numeric fields and the set of anchor points to be reconciled to filter out candidate logical rows containing the target amount or a combination of target amounts; executing a multi-level matching strategy on the candidate logical rows and the set of anchor points to be reconciled to establish a mapping relationship between the bill data and the invoice data; the strategy includes at least one of single-item exact matching, multi-item combination summation matching, and name fuzzy matching; and calculating the difference of unmatched items based on the alignment result of the mapping relationship to generate a reconciliation difference report.
[0119] Furthermore, the logical instructions in the aforementioned memory 430 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0120] On the other hand, the present invention also provides a computer program product, which includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the invoice data recognition and comparison method provided by the above methods. The method includes: obtaining bill data to be reconciled from a business system, and extracting the amount, currency, and expense name of each expense to construct a set of anchor points to be reconciled; inputting the invoice image into a large language model to obtain text primitives and their corresponding planar coordinate information, and clustering the text primitives into multiple logical row objects based on the differences in the vertical coordinates in the planar coordinate information; traversing the logical row objects, extracting the numerical fields in the logical row objects to perform numerical index matching between the extracted numerical fields and the set of anchor points to be reconciled, and filtering out candidate logical rows containing the target amount or a combination of target amounts; performing a multi-level matching strategy on the candidate logical rows and the set of anchor points to be reconciled to establish a mapping relationship between the bill data and the invoice data; the strategy includes at least one of single-item exact matching, multi-item combination summation matching, and name fuzzy matching; and calculating the difference of unmatched items based on the alignment result of the mapping relationship to generate a reconciliation difference report.
[0121] In another aspect, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon. When executed by a processor, the computer program implements the invoice data recognition and comparison method provided by the above methods. The method includes: obtaining bill data to be reconciled from a business system, and extracting the amount, currency, and expense name of each expense to construct a set of anchor points to be reconciled; inputting the invoice image into a large language model to obtain text primitives and their corresponding planar coordinate information, and clustering the text primitives into multiple logical row objects based on the differences in the vertical coordinates in the planar coordinate information; traversing the logical row objects, extracting the numeric fields in the logical row objects to perform numeric index matching between the extracted numeric fields and the set of anchor points to be reconciled, and filtering out candidate logical rows containing the target amount or a combination of target amounts; performing a multi-level matching strategy on the candidate logical rows and the set of anchor points to be reconciled to establish a mapping relationship between the bill data and the invoice data; the strategy includes at least one of single-item exact matching, multi-item combination summation matching, and name fuzzy matching; and calculating the difference of unmatched items based on the alignment result of the mapping relationship to generate a reconciliation difference report.
[0122] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0123] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0124] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for identifying and comparing invoice data, characterized in that, include: Obtain the bill data to be reconciled from the business system, and extract the amount, currency and name of each expense to construct a set of anchor points to be reconciled. The invoice image is input into the large language model to obtain text primitives and their corresponding planar coordinate information. Based on the differences in the vertical coordinates in the planar coordinate information, the text primitives are clustered into multiple logical row objects. Traverse the logical row object, extract the numeric fields in the logical row object, and perform numeric index matching between the extracted numeric fields and the set of anchor points to be reconciled, and filter out candidate logical rows that contain the target amount or a combination of target amounts; A multi-level matching strategy is executed on the candidate logical rows and the set of anchor points to be reconciled to establish a mapping relationship between bill data and invoice data; the multi-level matching strategy includes at least one of single-item exact matching, multi-item combination summation matching and name fuzzy matching; Based on the alignment results of the mapping relationship, the difference of the unmatched items is calculated, and a reconciliation difference report is generated.
2. The invoice data identification and comparison method according to claim 1, characterized in that, The method of clustering text primitives into multiple logical row objects based on the differences in the vertical coordinates in the planar coordinate information includes: Obtain the Y-coordinate of the center point of all text primitives in the vertical direction within the plane coordinate information; Determine the difference in the Y coordinates of the center points of two adjacent text elements. If the difference is less than a preset line height threshold, then the two text elements are determined to belong to the same physical line. Text primitives belonging to the same physical row are sorted and concatenated according to their horizontal coordinates from smallest to largest to generate a logical row object containing the complete row text and the position information of each column within the row.
3. The invoice data identification and comparison method according to claim 2, characterized in that, The generation of a logical row object containing complete line text and the position information of each column within the line includes: Based on the horizontal coordinates of the numeric fields in all logical row objects, a clustering algorithm is used to determine the horizontal range of the corresponding amount in the column of the page. Text elements falling within the specified amount level range are marked as amount attributes, and text elements located to the left of the specified amount level range are marked as name attributes.
4. The invoice data identification and comparison method according to claim 1, characterized in that, The extraction of numeric fields from the logical row object includes: Extracting numeric sequences from logical row objects using regular expressions; The system detects whether there are easily confused characters in the number sequence and replaces the erroneous characters corresponding to the easily confused characters with the correct characters; based on the preset currency decimal point rules, it converts the cleaned string into a standard floating-point number.
5. The invoice data identification and comparison method according to claim 1, characterized in that, The multi-level matching strategy includes name fuzzy matching, which employs an edit distance-based algorithm. The step of implementing the multi-level matching strategy on the candidate logical rows and the set of anchor points to be reconciled to establish a mapping relationship between billing data and invoice data includes: Construct a synonym mapping table containing industry-standard fee names and common abbreviations; Search the name field of the candidate logical row in the synonym mapping table; If no match is found, the edit distance between the name field of the candidate logical row and the bill fee name is calculated; When the similarity score corresponding to the edit distance is greater than the preset distance threshold, and the corresponding amounts are completely consistent, it is determined that the logical row object matches the billing expenses in the set of anchor points to be reconciled.
6. The invoice data identification and comparison method according to claim 1, characterized in that, Before traversing the logical row object, the method further includes: Determine the invoice page number and invoice number in each invoice image; If the same invoice number is detected to appear in multiple invoice images, detect and remove non-fee text that appears repeatedly at the beginning or end of each page to merge logical line objects in multiple invoice images.
7. The invoice data identification and comparison method according to claim 1, characterized in that, The method of clustering text primitives into multiple logical row objects based on the differences in the vertical coordinates in the planar coordinate information also includes: Identify text primitives in invoice images that correspond to functional keywords used to indicate the calculation function. Based on the Y-coordinate of the aforementioned functional keywords, the invoice image is divided into a details area and a total area; The logical row objects within the detailed area are used for numerical index matching with the set of anchor points to be reconciled.
8. An invoice data recognition and comparison device, characterized in that, include: The first processing module is used to obtain the bill data to be reconciled from the business system, and extract the amount, currency and name of each expense to build a set of anchor points to be reconciled. The second processing module is used to input the invoice image into the large language model to obtain text primitives and their corresponding planar coordinate information, and to cluster the text primitives into multiple logical row objects based on the differences in the vertical coordinates in the planar coordinate information. The first matching module is used to traverse the logical row object, extract the numeric fields in the logical row object, and perform numeric index matching between the extracted numeric fields and the set of anchor points to be reconciled, so as to filter out candidate logical rows containing the target amount or a combination of target amounts. The second matching module is used to perform a multi-level matching strategy on the candidate logical rows and the set of anchor points to be reconciled in order to establish a mapping relationship between bill data and invoice data; the multi-level matching strategy includes at least one of single-item exact matching, multi-item combination summation matching and name fuzzy matching; The third processing module is used to calculate the difference of unmatched items based on the alignment results of the mapping relationship and generate a reconciliation difference report.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and capable of running on the processor, characterized in that, When the processor executes the program, it implements the invoice data recognition and comparison method as described in any one of claims 1 to 7.
10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the invoice data recognition and comparison method as described in any one of claims 1 to 7.