Document information extraction method, system and program product combining logic constraints with reinforcement learning

CN122313508APending Publication Date: 2026-06-30UNIV OF SCI & TECH OF CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
UNIV OF SCI & TECH OF CHINA
Filing Date
2026-04-01
Publication Date
2026-06-30

AI Technical Summary

Technical Problem

Existing document information extraction technologies suffer from error accumulation, numerical illusion, and structural drift when processing medical invoices and financial documents, making it difficult to meet the requirements of high-precision extraction and logical consistency.

Method used

Combining logical constraints and reinforcement learning methods for document information extraction, this paper designs an SCL-Reward mechanism, utilizes structural gating, content alignment, and logical verification reward functions to optimize the document information extraction model and generate JSON format output that conforms to the database schema.

Benefits of technology

It significantly improves logical consistency, reduces numerical illusions, accurately extracts wireless table structures, and directly outputs JSON format that conforms to the database schema without the need for complex subsequent processing, thus realizing the conversion from images to a queryable database.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122313508A_ABST
    Figure CN122313508A_ABST
Patent Text Reader

Abstract

This invention discloses a document information extraction method, system, and program product that combines logical constraints and reinforcement learning, relating to the fields of artificial intelligence and intelligent document processing technology. Firstly, by explicitly incorporating arithmetic rules into the reward function, this invention significantly reduces "numerical illusions" and substantially improves logical consistency. Secondly, it solves the problem of extracting borderless tables, deriving the table structure through semantic content and logical constraints instead of relying on visual dividing lines, making it particularly suitable for borderless complex tables such as medical invoices. Thirdly, this invention uses reinforcement learning to transform discrete business rules into dense supervisory signals to guide the optimization of the document information extraction model. Furthermore, the document information extraction model of this invention directly outputs JSON format conforming to the database schema, eliminating the need for complex post-processing steps and achieving direct conversion from images to a queryable database.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of artificial intelligence and intelligent document processing technology, specifically to a document information extraction method, system, and program product that combines logical constraints and reinforcement learning. Background Technology

[0002] In financial auditing, insurance reimbursement, and enterprise ERP processes, automated processing of medical invoices and financial documents is crucial. Current technologies mainly fall into two categories, but both have significant shortcomings:

[0003] 1. Pipeline Paradigm: Such as the LayoutLM series and PaddleOCR, this approach breaks down the task into text detection, OCR recognition, and information extraction. Its drawbacks include severe error accumulation; detection or recognition errors can irreversibly propagate to the extraction stage. Furthermore, when processing "wireless tables," traditional grid-based table structure recognition is highly prone to failure, leading to row and column misalignment.

[0004] 2. End-to-end generation paradigm: such as Qwen-VL and other multimodal large models. Although they have strong general perception capabilities, they suffer from the "illusion" problem in high-precision extraction tasks. Specifically, this manifests as:

[0005] Numerical illusion: The generated amount does not conform to mathematical logic (e.g., unit price × quantity ≠ amount).

[0006] Structure drift: In dense text or wireless tables, the model is prone to losing row and column alignment, and cannot generate structured JSON that meets the requirements of the business database.

[0007] Existing fine-tuning methods primarily focus on token-level prediction accuracy, making it difficult to capture long-distance dependencies and discrete logical constraints. This results in extraction results that, while appearing logically sound, are flawed in terms of business logic. Therefore, the aforementioned technical issues urgently need to be addressed. Summary of the Invention

[0008] To address the aforementioned problems, the present invention aims to provide a document information extraction method, system, and program product that combines logical constraints and reinforcement learning.

[0009] The first aspect discloses a document information extraction method that combines logical constraints and reinforcement learning, the method comprising:

[0010] The document information extraction model is fed with training samples to generate a candidate output sequence of length G, where G is an integer greater than 1. The training samples include document images and corresponding predefined schemas, which include key-value definitions, table structures, and constraint rules. A reward value is calculated for each output in the candidate output sequence, where the reward value is obtained based on a structure gating indicator function, content alignment reward, and logic verification reward. The calculated reward values ​​are used to calculate the dominance function for each output, and a loss function is constructed based on the dominance function. The document information extraction model is then optimized based on the loss function. Finally, the document image to be extracted and the corresponding predefined schema are input into the optimized document information extraction model to obtain the final output.

[0011] The second aspect discloses a document information extraction system that combines logical constraints and reinforcement learning, the system comprising:

[0012] The document information extraction model is configured with a candidate output sequence acquisition module, which generates a candidate output sequence of length G by inputting training samples into the document information extraction model, where G is an integer greater than 1. The training samples include document images and corresponding predefined schemas, which include key-value definitions, table structures, and constraint rules. A reward value calculation module is configured to calculate the corresponding reward value for each output in the candidate output sequence, wherein the reward value is obtained based on a structure gating indicator function, content alignment reward, and logic verification reward. A loss function construction module is configured to calculate the dominance function for each output using the calculated reward values ​​and construct a loss function based on the dominance function. A model optimization module is configured to optimize the document information extraction model based on the loss function. A document information extraction module is configured to input the document image to be extracted and the corresponding predefined schema into the optimized document information extraction model to obtain the final output.

[0013] The third aspect discloses a computer program product that, when run on a computer, causes the computer to perform the document information extraction method combining logical constraints and reinforcement learning disclosed in the first aspect or any possible implementation of the first aspect.

[0014] As can be seen from the above technical solutions, the present invention has the following beneficial effects:

[0015] This invention significantly reduces "numerical illusion" and greatly improves logical consistency by explicitly incorporating arithmetic rules into the reward function. Secondly, this invention solves the problem of extracting borderless tables, deriving the table structure through semantic content and logical constraints instead of relying on visual dividing lines. It is particularly suitable for borderless complex tables such as medical invoices. This invention designs a combined reward function consisting of structural gating, content alignment, and logical verification using the SCL-Reward (Schema-Configurable Logic-Guided Reward) mechanism. Through reinforcement learning, discrete business rules are transformed into dense supervisory signals to guide the optimization of the document information extraction model. Furthermore, the document information extraction model of this invention directly outputs JSON format conforming to the database schema, eliminating the need for complex post-processing steps and achieving direct conversion from images to a queryable database. Attached Figure Description

[0016] Figure 1 The flowchart of a document information extraction method combining logical constraints and reinforcement learning provided by the present invention is shown.

[0017] Figure 2 This is a schematic diagram of a document information extraction system framework that combines logical constraints and reinforcement learning, as provided by the present invention. Detailed Implementation

[0018] To make the objectives, features, and advantages of the present invention more apparent and understandable, specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings. Several embodiments of the present invention are shown in the drawings. However, the present invention can be implemented in many different forms and is not limited to the embodiments described herein. Rather, these embodiments are provided so that the disclosure of the present invention will be thorough and complete.

[0019] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a particular order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments described herein can be implemented in a sequence other than that illustrated or described herein. Furthermore, the terms “comprising” and “having,” and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0020] It should be noted that when an element is referred to as being "fixed to" another element, it can be directly on the other element or there may be an intervening element. When an element is considered to be "connected to" another element, it can be directly connected to the other element or there may be an intervening element. The terms "vertical," "horizontal," "left," "right," "up," "down," and similar expressions used herein are for illustrative purposes only and are not intended to indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be construed as limiting the invention.

[0021] In this invention, unless otherwise explicitly specified and limited, the terms "installation," "connection," "linking," "fixing," etc., should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal communication between two components. Those skilled in the art can understand the specific meaning of the above terms in this invention according to the specific circumstances. The term "and / or" as used herein includes any and all combinations of one or more of the related listed items.

[0022] In one embodiment, the present invention provides a document information extraction method that combines logical constraints and reinforcement learning, such as... Figure 1 As shown, the specific steps include:

[0023] S101. Input training samples into the document information extraction model to generate candidate output sequences of length G, where G is an integer greater than 1; the training samples include document images and corresponding predefined schemas, and the predefined schemas (represented by S) include key definitions, table structures and constraint rules;

[0024] Specifically, the input consists of a document image X and its corresponding predefined schema, including key-value definitions, table structure, and constraint rules. In this embodiment, there are six predefined schemas: "Discharge Summary_Schema," "Medication Invoice_Schema," "Outpatient Invoice_Schema," "Inpatient Invoice_Schema," "SIBR_Bill_Schema (Fee List Class)," and "SIBR_Note_Schema (Guidance / Notification Class)." Constraint rules include extraction rules and arithmetic rules. Extraction rules include, for example, "Discharge Date": "Priority: Discharge Date > Discharge Time"; "Number of Days in Hospital": "Priority: Number of Days in Hospital > Explicit Numbers in the Text," etc. Arithmetic rules include, for example, "Unit Price × Quantity = Amount," and "The sum of all item amounts equals the total amount." The training samples use the StructBill-CN dataset.

[0025] Furthermore, the document information extraction model can employ any large multimodal model, such as Qwen2.5-VL. First, supervised fine-tuning (SFT) is used to pre-train the document information extraction model, enabling it to possess basic instruction compliance and JSON generation capabilities, resulting in a reference model. .

[0026] Furthermore, during the reinforcement learning phase, for each input (X,S), the current document information extraction model is used. Generate a set of candidate output sequences , , ..., }

[0027] Where G represents a set of answers generated by the GRPO (Group Relative Policy Optimization) algorithm for a question in each round. There are a total of G answers in this set, and the value of G is set to 8, that is, 8 answers are generated for the same question in each round.

[0028] S102. Calculate the corresponding reward value for each output in the candidate output sequence, wherein the reward value is obtained based on the structure gating indicator function, content alignment reward and logic verification reward;

[0029] This invention designs a combined reward function consisting of structural gating, content alignment, and logical verification through the SCL-Reward (Schema-Configurable Logic-Guided Reward) mechanism. By using reinforcement learning, discrete business rules are transformed into dense supervision signals to guide the optimization of the document information extraction model.

[0030] Specifically, for each candidate output The reward value is calculated using the SCL-Reward mechanism. .

[0031] It consists of three parts, as shown in the formula:

[0032] (1)

[0033] in, Indicates the reward value. Indicates the model output, This represents a predefined schema. This indicates a content alignment reward. This indicates a reward for logical verification. This represents the structure gating indicator function. This represents the balance coefficient. The final scalar reward value under a given architecture S can be obtained using the above formula. This refers to the structure gating indicator function, also known as the "veto mechanism." Its value is either 0 or 1. This is a balancing factor used to adjust the weight between content accuracy and logical consistency; this parameter is typically set to 0.4. Content alignment reward refers to global matching using the Hungarian algorithm to measure the consistency between extracted content and the true value; The logical verification reward is based on the arithmetic rules defined in the schema (such as unit price × quantity = amount) to measure the logical consistency of the extracted data.

[0034] In one embodiment, the process of determining the structural gating indication function value includes the following steps:

[0035] Each output is checked for syntactic validity and architectural compliance using a structure-gated indicator function.

[0036] The structure gating indicator function takes the value 1 when both the grammatical validity and architectural compliance conditions are met; otherwise, it takes the value 0.

[0037] Specifically, through structural gating ( Make the following judgment:

[0038] judge Is it a valid JSON format?

[0039] Determine whether S contains all root node keys defined in S;

[0040] Essentially, it's a logical AND operation. Its value is 1 only when all the preset compliance conditions are met simultaneously; if any one of them is not met, its value will be forcibly set to 0.

[0041] The specific value retrieval logic is as follows: Syntax validity check: The generated output Y must be parsable by a standard JSON parser (there must be no format errors). Architecture compliance check: The generated JSON must contain all root node keys and table keys defined in S.

[0042] In another embodiment, the present invention further includes the following steps:

[0043] If the predefined schema defines an anti-illusion flag, then determine whether the output contains fictitious table rows;

[0044] If it exists, the structure gating indicator function takes a value of 0;

[0045] If it does not exist, and both the grammatical validity and architectural compliance checks are satisfied, the structure gating indicator function takes the value of 1.

[0046] Specifically, hallucination indicates that the model generates content that is not present in the image or contradicts the image's content. If the schema has the "anti-hallucination flag" enabled, and the model fabricates non-existent table rows in the image, it is considered a hallucination triggered. The anti-hallucination flag is a Boolean switch set in a predefined schema. It primarily targets the behavior of the model "fabricating" non-existent table rows from unstructured text. When the schema defines this flag as True, the system activates the hallucination filter. The system checks whether the non-empty table rows generated by the model have factual basis in the original image. If the model generates extra table rows by fabricating details, it is determined that a hallucination has been triggered.

[0047] =1: If and only if the syntax is valid, the architecture is compliant, and there is no serious illusion; =0: When any of the above is "No".

[0048] This invention employs structural integrity gating as a "one-vote veto" mechanism, forcing the output generated by the model to conform to JSON syntax and contain the necessary fields defined in the schema, and integrates an illusion filter.

[0049] In one embodiment, the content alignment reward determination process includes the following steps:

[0050] Construct a cost matrix, where each element in the matrix represents the i-th element in the table structure of the document information extraction model's output. The first row and the first annotation Dissimilarity values ​​between rows, where, and This represents any row in the output table structure;

[0051] The optimal matching is found in the cost matrix using the Hungarian algorithm, where each row can only match one column, minimizing the sum of the values ​​in the paired cells.

[0052] Field-level precision and recall are calculated based on the matching results as content alignment rewards.

[0053] Specifically, construct the cost matrix The formula is expressed as follows:

[0054] (2)

[0055] Among them, matrix Each element in The first generation generated by the model Rows (predicted rows) ) and the marked row (truth row) The "distance" or "dissimilarity" between them; This is the normalized Levenshtein similarity score; the closer the value is to 1, the more similar the two lines of content are.

[0056] Solving for the optimal matching using the Hungarian algorithm To minimize the total matching cost, table row matching is modeled as a bipartite graph maximum weight matching problem.

[0057] The goal of the Hungarian algorithm is to perform a matrix operation. The algorithm finds an optimal pairing relationship (i.e., each row can only match one column) such that the sum of the values ​​in these paired cells is minimized, as shown in the formula:

[0058] (3)

[0059] In other words, by minimizing the sum of costs, the algorithm can automatically find those rows that have been "scrambled" by the model. Even if the order of the predicted rows is completely different from the true value, as long as the content is similar, the algorithm can accurately pair them together.

[0060] Finally, field-level precision and recall are calculated based on the matching results as content alignment rewards.

[0061] Specifically, the optimal match is obtained through the Hungarian algorithm. Then, the system will calculate the final content alignment reward according to the following steps. :

[0062] Step 1, calculate the sum of matching similarities:

[0063] Calculate all paired row pairs The sum of similarities is shown in the formula:

[0064] (4)

[0065] Step 2: Calculate field-level precision to measure how many of the generated rows are valid, as shown in the formula:

[0066] (5)

[0067] Where M is the total number of rows generated by the model.

[0068] Step 3: Calculate the field-level recall rate, which measures how many truth rows were successfully extracted by the model, as shown in the formula:

[0069] (6)

[0070] Where N is the total number of rows labeled with truth values.

[0071] Step 4: Calculate the final content alignment bonus The weighted harmonic mean of precision and recall is calculated as shown in the formula:

[0072] (7)

[0073] in, The weighting coefficients representing the ratio of precision to recall, when... When =1, it indicates that precision and recall are considered equally important when calculating content alignment rewards. When the value is greater than 1, the formula assigns a higher weight to recall, meaning that in business scenarios, the consequences of "missing actual table rows" are considered more serious than "generating a few extra rows of invalid data." A value less than 1 indicates a greater emphasis on the absolute accuracy of the content extracted by the model. The calculation method of this invention is similar to F1-score, capable of penalizing both "missed selections" and "random generation."

[0074] This invention is based on content alignment using bipartite graph matching. To address the issues of disordered and missing rows in table extraction, it utilizes the Hungarian algorithm to calculate the maximum weighted bipartite matching between predicted rows and true rows, thus solving the evaluation problem of unordered correspondence among multiple rows.

[0075] In another embodiment, the logic verification reward determination process includes the following steps:

[0076] Verify that each output satisfies document-level consistency.

[0077] If satisfied, verify whether each row of each output satisfies row-level consistency; if not, the logical verification reward is 0.

[0078] If the condition is met, the proportion of rows that meet the condition is calculated as the logical verification reward; otherwise, the logical verification reward is 0.

[0079] Specifically, the process of calculating the logical verification reward includes:

[0080] Row-level consistency: Verify whether each row satisfies the condition that unit price × quantity = amount (allowable error ε).

[0081] Document-level consistency: Verify that the sum of all item amounts equals the total amount field.

[0082] Furthermore, we first verify whether each output satisfies document-level consistency. If it does, we then perform row-level consistency verification. Finally, we calculate the proportion of rows that meet the conditions as the logical verification reward. If any output does not satisfy document-level consistency, the logical verification reward is directly set to 0.

[0083] This invention uses multi-level logical consistency checks and introduces deterministic arithmetic rules (such as unit price × quantity ≈ amount and total of items ≈ total amount) into the reward function to ensure that the data stored in the database meets mathematical rigor.

[0084] S103. Calculate the advantage function for each output using the calculated reward value, and construct the loss function based on the advantage function;

[0085] S104. Optimize the document information extraction model according to the loss function;

[0086] Specifically, using the calculated reward value, the advantage function is calculated according to the GRPO (Schema-Reinforced Policy Optimization) algorithm. And optimize the document information extraction model.

[0087] The reward value here It is a comprehensive indicator that integrates constraints from different dimensions. According to the above formula (1), It also includes content alignment rewards ( ) and logic verification reward ( Because there was one before that. (Structure gating) If the generated JSON format is incorrect, even if the content and logic are correct, the final reward will be "vetoed" and reduced to zero.

[0088] Advantage function It is the core component guiding the optimization direction of the model in reinforcement learning. Specific calculation process:

[0089] The GRPO algorithm does not use an additional Critic network; instead, it estimates advantage through the relative performance of a set of outputs.

[0090] Group sampling: Sample G candidate outputs for the same input.

[0091] Scoring: Calculate the reward value for each output { , ,..., }

[0092] Advantage function The specific details are shown in the formula:

[0093] (8)

[0094] in, Indicates the first The reward value corresponding to each output. They represent the 1st, 2nd, and 3rd respectively. The reward value corresponding to each output. Represents the arithmetic mean. This indicates the calculation of the standard deviation. This represents a numerically stable term, its purpose being to prevent arithmetic errors caused by a denominator of zero. In the loss function... of In each item, the probability ratio All must be multiplied by the corresponding .if If the value is >0 (performing better than the group average), the model will increase the probability of generating that sequence. If If the value is less than 0 (below average), the model will suppress the generation path.

[0095] The loss function is shown in the formula below:

[0096] (9)

[0097] in, This refers to the parameters to be optimized in the document information extraction model, which are updated in real time during training. This indicates the length of the output sequence, which can be set to 8. That is, the advantage function. Probability ratio Used to measure the current strategy Compared to the old strategy before the update In comparison, generating the first The probability change of each sample. and The parameters for the shearing operation and step size limit are set to prevent the model from deviating too much in a single iteration, which could lead to training failure. The KL divergence between the current strategy and the reference model; The KL divergence penalty coefficient is used to balance the model update intensity and language fluency. The KL divergence constraint is introduced to prevent the model from deviating too far from the reference model, ensuring the fluency of language generation. The document information extraction model is optimized using the loss function as the training objective. With 10,000 training samples, this invention achieves optimized document information extraction model through three rounds of iterative optimization using the training sample set.

[0098] This invention uses the Group Relative Policy Optimization (GRPO) algorithm to replace the traditional PPO algorithm. It uses the statistical characteristics of within-group sampling to estimate the baseline, thereby reducing memory overhead and improving training stability.

[0099] S105. Input the document image to be extracted and the corresponding predefined schema into the optimized document information extraction model to obtain the final output.

[0100] Specifically, by optimizing the training, a trained document information extraction model is obtained. By combining the document image to be extracted with the corresponding predefined schema, a rigorous and accurate output in JSON format that conforms to the database schema can be obtained.

[0101] To better explain the present invention, the extraction of medical inpatient invoices will be described below through a specific embodiment.

[0102] 1. Input: An image of an inpatient invoice containing multiple lines of medical treatment details, and a predefined schema (which needs to extract the hospital name, invoice number, and list of cost details).

[0103] 2. Schema constraint rules: Define that each row in the details list must satisfy the condition that unit price × quantity = amount.

[0104] 3. Model Inference: The document information extraction model attempts to generate multiple JSON results. Suppose that in one of the results, a certain line is identified as unit price: 10, quantity: 2, amount: 200 (OCR recognition error caused an extra 0).

[0105] 4. Reward Calculation:

[0106] Structure gating: JSON format is correct, pass.

[0107] Logical check: 10×2≠200 was detected, the logical score for this line is 0, causing the overall... reduce.

[0108] Content alignment: Match the generated lines with the truth values ​​and calculate the text similarity score.

[0109] 5. Optimization: When the document information extraction model receives low scores, it tends to generate results that conform to arithmetic logic (such as amount: 20) in subsequent training, thereby correcting the errors in visual recognition.

[0110] Compared to traditional SFT methods, this invention significantly reduces numerical illusion and improves logical consistency by explicitly incorporating arithmetic rules into the reward function. Experimental data show that on the constructed StructBill-CN dataset, the logical consistency (ACR) is improved from 84.2% to 94.7% of the SFT baseline.

[0111] This invention solves the problem of extracting wireless tables, which are tables without explicit vertical or horizontal dividing lines. The layout relies on text alignment and does not depend on visual dividing lines. Instead, the table structure is derived through semantic content and logical constraints. It is particularly suitable for borderless complex tables such as medical invoices, and the Table Structure Accuracy (TEDS) reaches 95.1%.

[0112] Furthermore, the document information extraction model of this invention directly outputs JSON format conforming to the database schema, eliminating the need for complex post-processing steps and achieving direct conversion from images to a queryable database. Moreover, in tests on unseen private datasets (OOD), the extraction accuracy for logically sensitive fields (such as total amount) significantly outperforms existing commercial closed-source models (such as Gemini-3-Pro).

[0113] This application also provides an extraction system corresponding to the method embodiments described above. Since the system embodiments are basically similar to the method embodiments, the description is relatively simple. For details of the relevant technical features and their effects, please refer to the corresponding descriptions of the method embodiments provided above. This disclosure provides a document information extraction system combining logical constraints and reinforcement learning, such as... Figure 2 As shown, the system specifically includes:

[0114] The candidate output sequence acquisition module is used to input training samples into the document information extraction model to generate candidate output sequences of length G, where G is an integer greater than 1. The training samples include document images and corresponding predefined schemas. The predefined schemas include key-value definitions, table structures, and constraint rules.

[0115] The reward value calculation module is used to calculate the corresponding reward value for each output in the candidate output sequence, wherein the reward value is obtained based on the structure gating indicator function, the content alignment reward, and the logic verification reward;

[0116] The loss function construction module is used to calculate the advantage function for each output using the calculated reward value, and to construct the loss function based on the advantage function;

[0117] The model optimization module is used to optimize the document information extraction model according to the loss function;

[0118] The document information extraction module is used to input the document image to be extracted and the corresponding predefined schema into the optimized document information extraction model to obtain the final output.

[0119] This application also provides an electronic device, which includes a processor and a memory. The memory stores at least one instruction or at least one program, which is loaded and executed by the processor. The document information extraction method combining logical constraints and reinforcement learning provided in the above-described method embodiments is described in detail.

[0120] Furthermore, the electronic device may participate in or include the apparatus or system provided in the embodiments of this application. The electronic device may include one or more processors (processors may include, but are not limited to, processing devices such as microprocessors (MCUs) or programmable logic devices (FPGAs), memory for storing data, and transmission devices for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the I / O interface), a network interface, a power supply, and / or a camera.

[0121] It should be noted that the aforementioned one or more processors and / or other data processing circuits are generally referred to herein as "data processing circuits". These data processing circuits can be implemented wholly or partially as software, hardware, firmware, or any other combination. Furthermore, the data processing circuits can be a single, independent processing module, or wholly or partially integrated into any other element within a device (or mobile device). As involved in the embodiments of this application, the data processing circuit serves as a processor control mechanism (e.g., selection of a variable resistor termination path connected to an interface).

[0122] The memory can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the method described in the embodiments of this application. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory, thereby realizing the above-mentioned data processing method. The memory may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory may further include memory remotely located relative to the processor, and these remote memories can be connected to electronic devices via a network. Examples of the above-mentioned networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.

[0123] The transmission device is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by the device's communication provider. In one example, the transmission device includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device may be a Radio Frequency (RF) module, used for wireless communication with the Internet.

[0124] The display can be, for example, a touchscreen liquid crystal display (LCD), which allows users to interact with the user interface of an electronic device (or mobile device).

[0125] This application also provides a computer storage medium storing at least one instruction or at least one program, which is loaded and executed by a processor to implement the document information extraction method combining logical constraints and reinforcement learning provided in the above-described method embodiments.

[0126] Optionally, in this embodiment, the aforementioned computer storage medium may be located at at least one of the multiple network servers in a computer network. Optionally, in this embodiment, the aforementioned storage medium may include, but is not limited to, various media capable of storing program code, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.

[0127] This application also provides a computer program product or computer program, which includes computer instructions stored in a computer storage medium. The processor of an electronic device reads the computer instructions from the computer storage medium and executes the computer instructions, causing the electronic device to perform the document information extraction method combining logical constraints and reinforcement learning provided in the above-described method embodiments.

[0128] It should be noted that the order of the embodiments described above is merely for descriptive purposes and does not represent the superiority or inferiority of the embodiments. Furthermore, specific embodiments have been described above. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps described in the claims can be performed in a different order than that shown in the embodiments and still achieve the desired result. Additionally, the processes depicted in the drawings do not necessarily require a specific or sequential order to achieve the desired result. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0129] It should be understood that the above description of the preferred embodiments is quite detailed, but it should not be considered as a limitation on the scope of protection of this invention. Those skilled in the art, under the guidance of this invention, can make substitutions or modifications without departing from the scope of protection of the claims of this invention, and all such substitutions or modifications fall within the scope of protection of this invention. The scope of protection of this invention should be determined by the appended claims.

Claims

1. A method for document information extraction combining logical constraints with reinforcement learning, characterized in that, The method includes: Input training samples into the document information extraction model to generate candidate output sequences of length G, where G is an integer greater than 1. The training samples include document images and corresponding predefined schemas. The predefined schemas include key-value definitions, table structures, and constraint rules. Calculate the corresponding reward value for each output in the candidate output sequence, wherein the reward value is obtained based on the structure gating indicator function, content alignment reward and logic verification reward; Calculate the advantage function for each output using the calculated reward value, and construct the loss function based on the advantage function; The document information extraction model is optimized based on the loss function. The final output is obtained by inputting the document image to be extracted and the corresponding predefined schema into the optimized document information extraction model.

2. The method of claim 1, wherein, The step involves calculating a reward value for each output in the candidate output sequence, wherein the reward value is obtained based on the structure gating indicator function value, content alignment reward, and logic verification reward, as shown in the formula: (1); wherein, represents a reward value, represents a model output, represents a predefined schema, represents a content alignment reward, represents a logical check reward, represents a structure gating indicator function, represents a balancing coefficient.

3. The method of claim 2, wherein, The process for determining the structural gating indicator function value includes: Each output is checked for syntactic validity and architectural compliance using a structure-gated indicator function. The structure gating indicator function takes the value 1 when both the grammatical validity and architectural compliance conditions are met; otherwise, it takes the value 0.

4. The method of claim 3, wherein, The method further includes: If the predefined schema defines an anti-illusion flag, then determine whether the output contains fictitious table rows; If it exists, the structure gating indicator function takes a value of 0; If it does not exist, and both the grammatical validity and architectural compliance checks are satisfied, the structure gating indicator function takes the value of 1.

5. The method of claim 2, wherein, The process for determining the content alignment reward includes: Construct a cost matrix, where each element in the matrix represents the dissimilarity value between the m-th row of the output table structure of the document information extraction model and the n-th row of the annotation, where m and n represent any row in the output table structure; The optimal matching is found in the cost matrix using the Hungarian algorithm, where each row can only match one column, minimizing the sum of the values ​​in the paired cells. Field-level precision and recall are calculated based on the matching results as content alignment rewards.

6. The method of claim 2, wherein, The logical verification reward determination process includes: Verify that each output satisfies document-level consistency. If satisfied, verify whether each row of each output satisfies row-level consistency; if not, the logical verification reward is 0. If the condition is met, the proportion of rows that meet the condition is calculated as the logical verification reward; if the condition is not met, the logical verification reward is 0.

7. The method of claim 1, wherein, The advantage function for each output is calculated using the computed reward values as shown in the equation below: (8); wherein, represents the reward value corresponding to the 1th output, represents the reward value corresponding to the 1th output, represents the reward value corresponding to the 1th output, represents the reward value corresponding to the 1th output, represents the arithmetic mean, represents the standard deviation, represents the numerical stabilizer.

8. The method of claim 7, wherein, The loss function is constructed based on the advantage function, as shown in the formula: (9); wherein, a parameter to be optimized of the document information extraction model, denotes the output sequence length, i.e. the advantage function, is a probability ratio, is a clipping operation function, is a step limit parameter, is the current policy the KL divergence between the reference model and the current policy, is a KL divergence penalty coefficient.

9. A document information extraction system combining logical constraints with reinforcement learning, characterized in that, The system includes: The candidate output sequence acquisition module is used to input training samples into the document information extraction model to generate candidate output sequences of length G, where G is an integer greater than 1. The training samples include document images and corresponding predefined schemas. The predefined schemas include key-value definitions, table structures, and constraint rules. The reward value calculation module is used to calculate the corresponding reward value for each output in the candidate output sequence, wherein the reward value is obtained based on the structure gating indicator function, the content alignment reward, and the logic verification reward; The loss function construction module is used to calculate the advantage function for each output using the calculated reward value, and to construct the loss function based on the advantage function; The model optimization module is used to optimize the document information extraction model according to the loss function; The document information extraction module is used to input the document image to be extracted and the corresponding predefined schema into the optimized document information extraction model to obtain the final output.

10. A computer program product, characterised in that, The computer program product includes a computer program stored in a computer-readable storage medium, which a processor reads from and executes to implement the method as described in any one of claims 1 to 8.