Base64 invoice automatic read-write optimization method based on artificial intelligence
By optimizing the automatic reading and writing process of invoices through Base64 encoding and evidence deep learning models, the problems of recognition accuracy and format compatibility in existing technologies are solved, and efficient and reliable full-process automated processing of electronic invoices is achieved, improving recognition accuracy and compliance.
Patent Information
- Application Number
- CN202510917713.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-03
- Publication Date
- 2025-10-03
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The existing automatic invoice reading technology has the following problems: recognition accuracy depends on image quality, the processing process is not compatible with multi-format electronic invoices, and there is a lack of reliable result marking and systematic verification mechanism. It is difficult to meet the comprehensive requirements for invoice reading and writing efficiency, accuracy and compliance in electronic office scenarios.
Base64 encoding technology is used to transmit electronic invoice files, combined with cloud-based structured field extraction and tax interface verification, an evidence deep learning model is introduced to construct field consistency labels, uncertainty quantification is achieved through Dirichlet distribution parameter modeling, and a trusted labeling and manual review mechanism is designed.
It realizes the full process automation of electronic invoices from uploading to trusted marking, improves recognition accuracy, processing efficiency and data credibility, and enhances the system's ability to judge recognition credibility and respond to risk control. It is suitable for intelligent management and risk control application scenarios of large-scale electronic invoices.
Smart Images

Figure CN120746495A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of invoice data processing, and in particular to an artificial intelligence-based Base64 invoice automatic reading and writing optimization method. Background Art
[0002] With the widespread application of electronic invoices in various financial management and tax processing scenarios, traditional invoice reading methods have gradually become unable to meet the actual needs of efficient, accurate and compliant processing. Current technologies mostly use methods based on optical character recognition (OCR), which extract key fields such as invoice code, invoice number, amount, tax rate, invoice date, seller information and buyer information by identifying the text content in the invoice image. However, the OCR method is highly sensitive to image quality, and the recognition accuracy will be significantly reduced when the image is blurred, deformed or occluded. In addition, due to the variety of invoice templates and different formats in different regions or versions, a large amount of sample training and template adaptation are often required, which increases the system maintenance cost and error risk.
[0003] Existing technologies typically require users to upload screenshots or printouts, and lack the ability to directly process original electronic files in PDF, OFD, or JPG formats, hindering the advancement of paperless processes. In terms of data processing, OCR methods primarily focus on information extraction and lack the legitimacy verification of structured results. This makes it impossible to automatically interface with the tax system, making it difficult to guarantee the accuracy and credibility of the recognition results. Furthermore, traditional systems have weak control capabilities in terms of security and data credibility, and lack mechanisms for reliable tagging, uncertainty analysis, or risk classification of recognition results, making it difficult to meet the risk control and auditability requirements of automated financial systems.
[0004] To sum up, the existing automatic invoice reading technology has problems such as recognition accuracy relying on image quality, processing flow not being compatible with multi-format electronic invoices, lack of trusted result marking and systematic verification mechanism, and it is difficult to meet the comprehensive requirements of invoice reading and writing efficiency, accuracy and compliance in electronic office scenarios.
[0005] Therefore, how to provide an artificial intelligence-based Base64 invoice automatic reading and writing optimization method is a problem that technicians in this field urgently need to solve. Summary of the Invention
[0006] One objective of the present invention is to propose an artificial intelligence-based method for optimizing the automatic reading and writing of Base64 invoices. The method uses Base64 encoding technology to transmit electronic invoice files, combined with cloud-based structured field extraction and tax interface verification, to achieve automated parsing and compliance verification of electronic invoices. The method introduces an evidence-based deep learning model to construct field consistency labels, quantifies the uncertainty of recognition results through Dirichlet distribution parameter modeling, and triggers a trusted tag or manual review mechanism based on data uncertainty and model uncertainty scores. This method offers the advantages of high transmission security, high recognition accuracy, evaluable credibility, and a high degree of process automation, making it suitable for intelligent management and risk control applications for large-scale electronic invoices.
[0007] According to an embodiment of the present invention, an artificial intelligence-based Base64 invoice automatic reading and writing optimization method includes the following steps:
[0008] S1. Receive the electronic invoice file uploaded by the user, perform integrity check on the electronic invoice file, and use the Base64 encoding algorithm to generate Base64 encoded invoice data;
[0009] S2. Transmit the Base64-encoded invoice data to the cloud service platform via the HTTPS protocol, generate the original electronic invoice file content, and perform field structured extraction processing to generate a structured invoice field set;
[0010] S3. Call the tax system invoice data interface to perform a legality and consistency check on the structured invoice field set and generate a tax verification result.
[0011] S4. Input the structured invoice field set into the evidence deep learning model, which includes an input vector encoding layer, an embedding expression generation layer, an evidence output layer, a Dirichlet parameter construction module, and an uncertainty calculation unit to generate uncertainty analysis results;
[0012] S5. Based on the uncertainty analysis results, calculate the data uncertainty score and the model uncertainty score respectively to generate the uncertainty decomposition results;
[0013] S6. Based on the uncertainty decomposition results, determine the relationship with the preset threshold, generate a risk flag status and trigger the manual review process;
[0014] S7. If the uncertainty decomposition results do not exceed the corresponding preset thresholds, the structured invoice field set and the tax inspection results are marked as credible, and the credible marking results and the structured invoice field set are sent back to the client together.
[0015] Optionally, the S1 specifically includes:
[0016] S11. Receive an electronic invoice file uploaded by a user through a client, where the electronic invoice file is in any one of PDF, OFD, or JPG formats, and generate the electronic invoice file to be processed;
[0017] S12. Parsing the file header information of the electronic invoice file to be processed, extracting the file format type, file byte length, and file creation time, and generating a set of invoice file metadata;
[0018] S13: Perform integrity check on the electronic invoice file to be processed and use the preset digest algorithm function H(x) to calculate the digest value D of the original file. f =H(F), where F represents the original electronic invoice file content;
[0019] S14, the original file digest value and the reference digest value D generated by the client at the time of uploading and uploaded with the request ref Compare and if D is satisfied f =D ref , then the integrity check is determined to be passed and a verification pass mark is generated;
[0020] S15. If the verification pass flag is established, perform Base64 encoding on the electronic invoice file to be processed, and use the standard Base64 encoding function to encode the file content F into an ASCII string B. f , output as Base64-encoded invoice data.
[0021] Optionally, the S2 specifically includes:
[0022] S21. Submit the Base64-encoded invoice data to a preset cloud service platform interface address via the secure transmission protocol HTTPS to form the HTTPS transmission request message;
[0023] S22. After receiving the HTTPS transmission request message, the cloud service platform parses the Base64 encoded invoice data field and extracts the Base64 format string B from it. f After verifying that the identification field is valid, perform the Base64 decoding operation;
[0024] S23. Perform a format recognition operation on the original electronic invoice file content F to determine whether the original electronic invoice file content is in PDF format, OFD format, or JPG format, and select a corresponding field parsing template based on the file format;
[0025] S24: Based on the field parsing template, perform structured field extraction processing on the original electronic invoice file content F, extracting invoice code, invoice number, invoice date, amount, tax rate, seller information and buyer information, and construct a structured invoice field set V. f .
[0026] Optionally, the S3 specifically includes:
[0027] S31. Set the structured invoice field V f The invoice code, invoice number, invoice date, amount, tax rate, seller information, and buyer information are sequentially filled into the data structure required by the tax system interface and organized according to the predefined order of the fields in the interface protocol to form a tax inspection request data packet;
[0028] S32. Send a tax inspection request data packet through the tax system open data interface, and receive the tax inspection return result based on the interface response protocol format;
[0029] S33. Parse the tax inspection return result, extract the invoice verification status identifier, interface response code, inspection timestamp, and related return fields from the tax inspection return result, and generate a tax inspection result set;
[0030] S34. Output the tax inspection result set as a result of the legality and consistency inspection of the structured invoice field set.
[0031] Optionally, the S4 specifically includes:
[0032] S41. Set the structured invoice field V f Inputting an evidence deep learning model, the evidence deep learning model includes an input vector encoding layer, an embedding expression generation layer, an evidence output layer, a Dirichlet parameter construction module, and an uncertainty calculation unit;
[0033] S42. Input vector encoding layer receives structured invoice field set V f , and set the structured invoice field set V f Convert to a standardized feature representation vector x;
[0034] S43, the embedding expression generation layer performs a multi-layer mapping operation on the standardized feature representation vector x to generate an embedding expression vector z for the interaction between fields;
[0035] S44, the evidence output layer outputs the evidence value set e={e1,e2,…,e k ,…,e K}, where each evidence value is e k ≥0, indicating the strength of evidence support for the category label;
[0036] S45, a Dirichlet parameter construction module constructs a Dirichlet distribution parameter set based on the evidence value set e;
[0037] S46, the uncertainty calculation unit calculates the consistency prediction probability and the total uncertainty score based on the Dirichlet parameter set α;
[0038] S47. The consistent prediction probability set and the total uncertainty score u are combined to form the uncertainty analysis result.
[0039] Optionally, the Dirichlet parameter construction module receives a set of evidence values generated by the evidence output layer, each evidence value corresponding to a field consistency category label; the Dirichlet parameter construction module generates the Dirichlet distribution parameters corresponding to each category label in turn by adding the evidence value corresponding to each category label to the constant 1; the Dirichlet distribution parameters of all categories together constitute the Dirichlet distribution parameter set.
[0040] Optionally, the uncertainty calculation unit calculates the consistency prediction probability and the total uncertainty score based on the Dirichlet parameter set α; based on the Dirichlet distribution parameter set, calculates the prediction probability of each type of field consistency label, the consistency prediction probability is the ratio of the Dirichlet parameter value of the current category to the sum of all category parameter values, and the prediction probabilities of all field consistency labels are combined into a consistency prediction probability set; based on the Dirichlet distribution parameter set, calculates the total uncertainty score, the total uncertainty score is the ratio between the total number of consistency categories and the sum of all category parameter values.
[0041] Optionally, the S5 specifically includes:
[0042] S51, receiving uncertainty analysis results, and extracting a total uncertainty score calculated based on a set of Dirichlet distribution parameters;
[0043] S52. Extract the field quality indicators of each field in the structured invoice field set, including the missing rate, character recognition confidence, and structure deviation score, and calculate the field data uncertainty score:
[0044] U data =ω1·r missing +ω2·(1-c conf )+ω3·s bias ;
[0045] Among them, U datarepresents the data uncertainty score, ω1 represents the weighted coefficient of the missing rate factor, r missing represents the field missing rate, ω2 represents the weighted coefficient of the character recognition confidence factor, c conf represents the confidence of character recognition, ω3 represents the weighting coefficient of the structural deviation scoring factor, s bias represents the structural deviation score;
[0046] S53, based on the total uncertainty score U total and data uncertainty score U data , calculate the model uncertainty score U madel , subtract the data uncertainty score from the total uncertainty score. If the result is positive, the difference is used as the model uncertainty score. If the result is negative or zero, the model uncertainty score is set to zero;
[0047] S54. Score the data uncertainty U data and model uncertainty score U madel Output as uncertainty decomposition result.
[0048] Optionally, the S6 specifically includes:
[0049] S61, receiving uncertainty decomposition results, the uncertainty decomposition results including data uncertainty score U data and model uncertainty score U madel ;
[0050] S62. Determine the data uncertainty score U data Is it higher than the first preset threshold θ data , or determine the model uncertainty score U madel Is it higher than the second preset threshold θ madel ;
[0051] S63, if the data uncertainty score U is satisfied data Higher than the first preset threshold θ data Or model uncertainty score U madel Higher than the second preset threshold θ madel , then a risk marking state is generated, marking the corresponding structured field as a high-risk field;
[0052] S64. After the risk marking status is generated, the manual review process is triggered, the marking field and uncertainty score information are submitted to the manual review interface, and the review request log is recorded.
[0053] Optionally, the S7 specifically includes:
[0054] S71. If the data uncertainty score U is satisfied data Not higher than the first preset threshold θ dataOr model uncertainty score U madel Not higher than the second preset threshold θ madel , then the corresponding structured invoice field set is marked as trusted;
[0055] S72. Associate the tax inspection result with the structured invoice field set to generate a trusted tag result. Write the trusted tag result as a trusted invoice record into the database system, thereby forming a joint storage of the structured trusted field entry and the trusted inspection record.
[0056] S73. Construct a return data structure, where the return data structure includes a structured invoice field set and a trusted tag result.
[0057] S74. Output the returned data structure to the user interface through the client interface, presenting the invoice fields marked as credible and the corresponding verification status information.
[0058] The beneficial effects of the present invention are:
[0059] This paper, by constructing an AI-based optimized method for automatically reading and writing Base64 invoices, automates the entire process of electronic invoice processing, from upload to trusted marking. Compared to traditional reading methods that rely on image recognition, this method significantly improves recognition accuracy, processing efficiency, and data credibility. By using Base64 encoding to process original electronic invoice files in PDF, OFD, and JPG formats, the system can directly perform binary encoding and secure transmission of electronic files, reducing reliance on paper printing and image scanning, and improving data processing integrity and efficiency.
[0060] During the cloud-based structured parsing phase, the system extracts the invoice code, invoice number, invoice date, amount, tax rate, seller information, and buyer information based on format recognition and field template matching mechanisms. It then uses the tax system's open interface to perform field-level legitimacy verification on the extracted results, ensuring semantic and source consistency of the structured results. Combined with an evidence-based deep learning model, the system generates evidence values for each field's consistency label and constructs a set of Dirichlet distribution parameters to quantitatively assess field credibility. By calculating the predicted probability of consistency and the total uncertainty score, the system identifies the uncertainty level of the recognition results.
[0061] In addition, the present invention has designed an uncertainty decomposition mechanism that can distinguish between defects in the data itself and cognitive biases in the model reasoning process. The system determines whether risk marking and manual review are required based on the data uncertainty score and the model uncertainty score. For structured results that do not exceed the threshold, the system automatically marks them as trustworthy, stores them together with the tax inspection results, and transmits them back to the client; for high-risk fields, the scoring information is recorded and submitted for manual review, forming a traceable review log. This processing method improves the intelligence level of the invoice data processing process, enhances the system's ability to judge recognition credibility and respond to risk control, and is suitable for compliance management and automatic identification scenarios of large-scale electronic invoices. BRIEF DESCRIPTION OF THE DRAWINGS
[0062] The accompanying drawings are used to provide a further understanding of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation of the present invention. In the accompanying drawings:
[0063] Figure 1 This is a flowchart of an artificial intelligence-based Base64 invoice automatic reading and writing optimization method proposed by the present invention;
[0064] Figure 2 This is a schematic diagram of the evidence deep learning model structure and Dirichlet distribution parameter generation process in the artificial intelligence-based Base64 invoice automatic reading and writing optimization method proposed in the present invention;
[0065] Figure 3 This is a logical structure diagram of the uncertainty score decomposition and trustworthy tag triggering mechanism in the artificial intelligence-based Base64 invoice automatic reading and writing optimization method proposed by the present invention. DETAILED DESCRIPTION
[0066] The present invention will now be described in further detail with reference to the accompanying drawings, which are simplified schematic diagrams that illustrate the basic structure of the present invention in a schematic manner.
[0067] refer to Figure 1-3 , an artificial intelligence-based Base64 invoice automatic reading and writing optimization method, comprising the following steps:
[0068] S1. Receive the electronic invoice file uploaded by the user, perform integrity check on the electronic invoice file, and use the Base64 encoding algorithm to generate Base64 encoded invoice data;
[0069] S2. Transmit the Base64-encoded invoice data to the cloud service platform via the HTTPS protocol, generate the original electronic invoice file content, and perform field structured extraction processing to generate a structured invoice field set;
[0070] S3. Call the tax system invoice data interface to perform a legality and consistency check on the structured invoice field set and generate a tax verification result.
[0071] S4. Input the structured invoice field set into the evidence deep learning model, which includes an input vector encoding layer, an embedding expression generation layer, an evidence output layer, a Dirichlet parameter construction module, and an uncertainty calculation unit to generate uncertainty analysis results;
[0072] S5. Based on the uncertainty analysis results, calculate the data uncertainty score and the model uncertainty score respectively to generate the uncertainty decomposition results;
[0073] S6. Based on the uncertainty decomposition results, determine the relationship with the preset threshold, generate a risk flag status and trigger the manual review process;
[0074] S7. If the uncertainty decomposition results do not exceed the corresponding preset thresholds, the structured invoice field set and the tax inspection results are marked as credible, and the credible marking results and the structured invoice field set are sent back to the client together.
[0075] The present invention realizes the intelligent processing of the entire process of electronic invoices from file reception, structured extraction, tax inspection to trust marking and return by constructing an artificial intelligence-based Base64 invoice automatic reading and writing optimization method. Through Base64 encoding and HTTPS secure transmission mechanism, the integrity and security of electronic invoice data interaction are improved; through the linkage of structured field extraction and tax system interface, the accuracy and compliance of invoice information are enhanced; by introducing evidence deep learning model and Dirichlet uncertainty modeling, the system can quantify the credibility of field recognition, and realize automatic risk judgment and review triggering based on this, effectively reducing the pressure of manual review. In practical applications, the present invention significantly improves the recognition accuracy, verification consistency rate and automatic processing efficiency, and has good stability and scalability.
[0076] In this embodiment, S1 specifically includes:
[0077] S11. Receive an electronic invoice file uploaded by a user through a client. The electronic invoice file is in any one of PDF, OFD, or JPG formats. The upload operation is completed by selecting a local file or scanning a QR code on a mobile device, and the electronic invoice file to be processed is generated.
[0078] S12. Parsing the file header information of the electronic invoice file to be processed, extracting the file format type, file byte length, and file creation time, and generating a set of invoice file metadata;
[0079] S13: Perform integrity check on the electronic invoice file to be processed and use the preset digest algorithm function H(x) to calculate the digest value D of the original file. f =H(F), where F represents the original electronic invoice file content;
[0080] S14, the original file digest value and the reference digest value D generated by the client at the time of uploading and uploaded with the request ref Compare and if D is satisfied f =D ref , then the integrity check is determined to be passed and a verification pass mark is generated;
[0081] S15. If the verification pass flag is established, perform Base64 encoding on the electronic invoice file to be processed, and use the standard Base64 encoding function to encode the file content F into an ASCII string B. f , output as Base64-encoded invoice data.
[0082] The present invention introduces file format identification, metadata extraction, integrity verification and Base64 encoding mechanisms in the electronic invoice reception and encoding processing stage to ensure the reliability of uploaded invoice files in terms of format compatibility, content integrity and transmission security. After receiving the electronic invoice file, the system first parses the file header information to extract the format type, byte length and creation time to form a file metadata set for subsequent processing optimization. A preset digest algorithm is used to generate a digest value for the original file, and it is compared with the reference digest value uploaded synchronously by the client to effectively prevent tampering and mistransmission of the file during transmission. After the verification is passed, the system uniformly converts the file content into Base64 encoding format and standardizes it into an ASCII string to facilitate subsequent transmission through an encrypted channel and structured processing in the cloud. This method improves the accuracy and stability of electronic invoice upload processing and lays a safe and reliable data foundation for subsequent parsing processes.
[0083] In this embodiment, S2 specifically includes:
[0084] S21. Submitting the Base64-encoded invoice data to a preset cloud service platform interface address via the secure transmission protocol HTTPS to form the HTTPS transmission request message, wherein the transmission request message includes a Base64-encoded invoice data field and a verification pass identification field;
[0085] S22. After receiving the HTTPS transmission request message, the cloud service platform parses the Base64-encoded invoice data field and extracts the Base64 format string B from it. f After verifying that the identification field is valid, perform the Base64 decoding operation;
[0086] S23. Perform a format recognition operation on the original electronic invoice file content F to determine whether the original electronic invoice file content is in PDF format, OFD format, or JPG format, and select a corresponding field parsing template based on the file format;
[0087] S24: Based on the field parsing template, perform structured field extraction processing on the original electronic invoice file content F, extracting invoice code, invoice number, invoice date, amount, tax rate, seller information and buyer information, and construct a structured invoice field set V. f .
[0088] During the transmission and structural processing of electronic invoice data, the present invention uses the HTTPS protocol to achieve secure transmission of Base64-encoded invoice data, effectively ensuring the integrity and confidentiality of the data in the network. After receiving the transmission message, the system verifies the legitimacy of the data by checking the identification field, and performs a Base64 decoding operation to restore the original content of the electronic invoice. Subsequently, based on the identified file format type, the corresponding field parsing template is automatically matched to accurately extract the invoice code, invoice number, amount, tax rate, invoice date, seller information, and buyer information to construct a structured invoice field set. This method improves the security of the invoice data transmission process and the automation and accuracy of the structured extraction stage, providing high-quality data support for subsequent inspection and analysis.
[0089] In this embodiment, S3 specifically includes:
[0090] S31. Set the structured invoice field V f The invoice code, invoice number, invoice date, amount, tax rate, seller information, and buyer information are sequentially filled into the data structure required by the tax system interface and organized according to the predefined order of the fields in the interface protocol to form a tax inspection request data packet;
[0091] S32. Send a tax inspection request data packet through the tax system open data interface, and receive the tax inspection return result based on the interface response protocol format;
[0092] S33. Parse the tax inspection return result, extract the invoice verification status identifier, interface response code, inspection timestamp, and related return fields from the tax inspection return result, and generate a tax inspection result set;
[0093] S34. Output the tax inspection result set as a result of the legality and consistency inspection of the structured invoice field set.
[0094] By constructing a data structure that matches the tax system interface protocol, this invention achieves standardized encapsulation of structured invoice fields and automated verification request construction. The system populates the invoice code, invoice number, invoice date, amount, tax rate, seller information, and buyer information in a preset order to generate a verification data packet, and completes legality and consistency verification through the tax open interface. Upon return of the verification results, the system automatically extracts the verification status, response code, verification timestamp, and other necessary fields to form a complete tax verification result set. This mechanism significantly improves the automation level of the verification process and the accuracy of data matching, enhancing the real-time and reliability of the system's judgment of the legality of electronic invoices.
[0095] In this embodiment, the S4 specifically includes:
[0096] S41. Set the structured invoice field V f Inputting an evidence deep learning model, the evidence deep learning model includes an input vector encoding layer, an embedding expression generation layer, an evidence output layer, a Dirichlet parameter construction module, and an uncertainty calculation unit;
[0097] S42. Input vector encoding layer receives structured invoice field set V f , and set the structured invoice field set V f Convert to a standardized feature representation vector x;
[0098] S43, the embedding expression generation layer performs a multi-layer mapping operation on the standardized feature representation vector x to generate an embedding expression vector z for the interaction between fields;
[0099] S44, the evidence output layer outputs the evidence value set e={e1,e2,…,e k ,…,e K}, where each evidence value is e k ≥0, indicating the strength of evidence support for the category label;
[0100] S45, a Dirichlet parameter construction module constructs a Dirichlet distribution parameter set based on the evidence value set e;
[0101] S46, the uncertainty calculation unit calculates the consistency prediction probability and the total uncertainty score based on the Dirichlet parameter set α;
[0102] S47. The consistent prediction probability set and the total uncertainty score u are combined to form the uncertainty analysis result.
[0103] By introducing an evidence deep learning model, the present invention achieves credibility modeling and uncertainty quantification of the recognition results of structured invoice fields. The model consists of an encoding layer, an embedding layer, an evidence output layer, a Dirichlet parameter construction module, and an uncertainty calculation unit. It can convert field information into a high-dimensional feature representation, capture the semantic relationship between fields, and output a set of evidence values corresponding to the consistency label. Based on these evidence values, the Dirichlet distribution parameters are constructed, and the consistency prediction probability and total uncertainty score are further calculated to form a complete uncertainty analysis result. This method effectively improves the system's ability to express the confidence of the recognition results and provides a quantitative basis for subsequent credibility judgment and risk management.
[0104] In this embodiment, the Dirichlet parameter construction module receives a set of evidence values generated by the evidence output layer, each evidence value corresponds to a field consistency category label; the Dirichlet parameter construction module generates the Dirichlet distribution parameters corresponding to each category label in turn by adding the evidence value corresponding to each category label to the constant 1; the Dirichlet distribution parameters of all categories together constitute a Dirichlet distribution parameter set, which serves as a priori input for subsequent field consistency prediction probability calculation and total uncertainty score calculation, and is passed to the uncertainty analysis module for use.
[0105] This method constructs a set of Dirichlet distribution parameters by adding the evidence value of each field's consistency label to a constant of 1. This parameter serves as the prior input for consistency prediction and uncertainty scoring, effectively enhancing the model's ability to express categorical uncertainty. This mechanism prevents probability estimates from deviating from the actual label distribution, improves the accuracy of credibility assessments of field recognition results, and provides a clearly structured and statistically interpretable foundation for subsequent uncertainty analysis, enhancing the trustworthy judgment capabilities of invoice recognition systems in risk control.
[0106] In this embodiment, the uncertainty calculation unit calculates the consistency prediction probability and the total uncertainty score based on the Dirichlet parameter set α; based on the Dirichlet distribution parameter set, the prediction probability of each type of field consistency label is calculated, and the consistency prediction probability is the ratio of the Dirichlet parameter value of the current category to the sum of all category parameter values, and the prediction probabilities of all field consistency labels are combined into a consistency prediction probability set; based on the Dirichlet distribution parameter set, the total uncertainty score is calculated, and the total uncertainty score is the ratio between the total number of consistency categories and the sum of all category parameter values.
[0107] This method quantitatively analyzes the credibility of recognition results by calculating the field consistency prediction probability and total uncertainty score based on a set of Dirichlet parameters. The consistency prediction probability reflects the relative confidence level of each category label, while the total uncertainty score measures the stability of the overall recognition distribution. This method effectively enhances the system's ability to interpret the credibility of model outputs, providing a reliable basis for subsequent risk assessment and treatment strategy selection.
[0108] In this embodiment, the S5 specifically includes:
[0109] S51, receiving uncertainty analysis results, and extracting a total uncertainty score calculated based on a set of Dirichlet distribution parameters;
[0110] S52. Extract the field quality indicators of each field in the structured invoice field set, including the missing rate, character recognition confidence, and structure deviation score, and calculate the field data uncertainty score:
[0111] U data =ω1·r missing +ω2·(1-c conf )+ω3·s bias ;
[0112] Among them, U data represents the data uncertainty score, ω1 represents the weighted coefficient of the missing rate factor, r missing represents the field missing rate, ω2 represents the weighted coefficient of the character recognition confidence factor, c conf represents the confidence of character recognition, ω3 represents the weighting coefficient of the structural deviation scoring factor, s bias represents the structural deviation score;
[0113] S53, based on the total uncertainty score U total and data uncertainty score U data , calculate the model uncertainty score U madel , subtract the data uncertainty score from the total uncertainty score. If the result is positive, the difference is used as the model uncertainty score. If the result is negative or zero, the model uncertainty score is set to zero;
[0114] S54. Score the data uncertainty U data and model uncertainty score U madel Output as uncertainty decomposition result.
[0115] The present invention introduces a data uncertainty scoring mechanism in the uncertainty decomposition process, and quantitatively evaluates the data quality of structured invoice fields by integrating multiple influencing factors. The system comprehensively considers the field missing rate, character recognition confidence, and the degree of structural deviation to establish a data uncertainty scoring model. Among them, the missing rate is used to measure whether the field value exists, the character recognition confidence reflects the model's confidence in recognizing the current field, and the structural deviation indicates the degree of deviation of the field's position or format in the document from the standard template. The system assigns a weighting coefficient to each factor, and weights and combines the factors to generate a single uncertainty score to express the credibility of the field at the data level. This score can not only identify potential risks caused by data defects, but also distinguish it from the uncertainty in the model reasoning process. Finally, the model uncertainty score is constructed by the difference between the two to achieve a clear judgment on the source of the risk.
[0116] In this embodiment, S6 specifically includes:
[0117] S61, receiving uncertainty decomposition results, the uncertainty decomposition results including data uncertainty score U data and model uncertainty score U madel ;
[0118] S62. Determine the data uncertainty score U data Is it higher than the first preset threshold θ data , or determine the model uncertainty score U madel Is it higher than the second preset threshold θ madel ;
[0119] S63, if the data uncertainty score U is satisfied data Higher than the first preset threshold θ data Or model uncertainty score U madel Higher than the second preset threshold θ madel , then a risk marking state is generated, marking the corresponding structured field as a high-risk field;
[0120] S64. After the risk marking status is generated, the manual review process is triggered, the marking field and uncertainty score information are submitted to the manual review interface, and the review request log is recorded.
[0121] This invention automatically identifies the risk level of structured fields by establishing a dual-threshold judgment mechanism for data uncertainty scoring and model uncertainty scoring. When the scoring result exceeds any preset threshold, the system automatically marks the field as high-risk and triggers a manual review process, ensuring timely verification and intervention of key fields when uncertainty exists. The system also logs review requests, ensuring full process traceability. This mechanism enhances the system's risk control capabilities, reduces the probability of untrusted fields being mistakenly entered into accounts, and improves the reliability of processing results.
[0122] In this embodiment, the S7 specifically includes:
[0123] S71. If the data uncertainty score U is satisfied data Not higher than the first preset threshold θ data Or model uncertainty score U madel Not higher than the second preset threshold θ madel , then the corresponding structured invoice field set is marked as trusted;
[0124] S72. Associate the tax inspection result with the structured invoice field set to generate a trusted tag result. Write the trusted tag result as a trusted invoice record into the database system, thereby forming a joint storage of the structured trusted field entry and the trusted inspection record.
[0125] S73. Construct a return data structure, where the return data structure includes a structured invoice field set and a trusted tag result.
[0126] S74. Output the returned data structure to the user interface through the client interface, presenting the invoice fields marked as credible and the corresponding verification status information.
[0127] When the credibility of the recognition results meets preset conditions, this method automatically marks the structured invoice field set as trusted. This trusted marking is then linked to the tax verification results, enabling the joint storage of structured fields and verification information. The system establishes a unified data feedback structure and outputs the trusted fields and verification status to the user interface via a client interface, enhancing the user's intuitive understanding and trust in the recognition results. This method enhances the automation and credibility management capabilities of the recognition process, helping to improve the overall system's operational efficiency and compliance.
[0128] Example 1:
[0129] In order to verify the feasibility of the present invention in implementation, the present invention was applied to a large-scale financial information management system, which is responsible for the daily reception, reading, verification and accounting processing of electronic invoices. The total amount of electronic invoices received by the unit is stable at around 2,000 per day. The invoice formats include three mainstream types: OFD, PDF and JPG. The source channels include various business departments within the enterprise, supplier systems and third-party platform push. The data sources are diverse and the formats are complex, which poses a great challenge to traditional OCR image recognition. The original system relied on image scanning combined with template matching to extract invoice fields. The image quality needed to be manually pre-processed. The field recognition accuracy was stable at around 85%. There were still problems such as field offset, missed content, and mismatched tax inspection results. The processing delay was long and manual intervention was frequent.
[0130] After deploying the artificial intelligence-based Base64 invoice automatic reading and writing optimization method proposed in this invention in this scenario, the overall workflow is reconstructed into electronic invoices directly uploading the original electronic file (OFD / PDF / JPG). The system first performs Base64 encoding and integrity verification, and sends it to the cloud service platform through the HTTPS channel. After decoding, the cloud platform identifies the invoice format, automatically matches the parsing template, completes the field structured extraction, and calls the tax interface to verify the legality and consistency of the invoice. After the field structuring is completed, the system inputs the extracted fields into the evidence deep learning model, and the model outputs the consistency label corresponding to the evidence value and constructs the Dirichlet parameter set, and further calculates the consistency prediction probability and the total uncertainty score.
[0131] During a seven-day test period, the system processed 13,926 electronic invoices, representing a 21% increase in the average daily processing capacity of the original system. 99.2% of invoices were correctly formatted with fully identifiable structural fields, and the average field extraction accuracy increased from 85.6% to 97.9%. Furthermore, uncertainty analysis generated by the model identified 234 invoices with medium- and high-risk fields, 197 of which were due to data defects and 37 of which fell within the range of model inference instability. All high-risk fields were manually reviewed, ultimately confirming that field marking errors were within 1.3%, effectively preventing incorrect invoice information from being entered into the accounts.
[0132] This example demonstrates that the method of the present invention achieves a synergistic improvement in structured field recognition accuracy, tax consistency verification capabilities, and identification credibility quantification while ensuring data processing efficiency. This significantly reduces the burden of manual review and enhances system stability and risk control capabilities. This method provides stable, efficient, and traceable invoice data processing capabilities, particularly for batch uploads of invoices with mixed formats and complex content, making it suitable for automated applications in the daily financial and tax management systems of large organizations.
[0133] The following table is a statistical table of comparative data between the implementation of the present invention and the traditional solution:
[0134] Table 1 Comparison of the AI-based Base64 invoice automatic reading and writing optimization method and the traditional OCR solution
[0135]
[0136]
[0137] As can be seen from the above table, the present invention has significant improvements over traditional OCR template recognition methods in multiple key performance indicators of automatic reading and writing of electronic invoices. First, in terms of the average daily invoice processing capacity, the method of the present invention reached 2,486 copies, an increase of 21% compared to the 2,052 copies of the traditional method, effectively enhancing the processing efficiency of the system in high-concurrency scenarios. In terms of field recognition accuracy, the average field recognition accuracy of the original system was 85.6%, while the present invention increased it to 97.9% through structured parsing and evidence modeling, significantly reducing field extraction errors, position offsets and content loss problems. The tax verification consistency rate increased from the original 87.4% to 98.5%, indicating that the matching of structured results with the tax system's back-check data has been greatly enhanced, significantly reducing the inspection failure rate due to field errors. In terms of processing delay, the processing time for a single invoice was reduced from 4.7 seconds to 2.8 seconds, reflecting the efficient execution capabilities of the present invention in the entire process of transmission, parsing and judgment.
[0138] In addition, the uncertainty scoring mechanism introduced by this invention enables the system to accurately identify 234 high-risk invoices and separately address model errors and data quality issues based on the scoring source, reducing the manual review trigger rate from 12.5% in the original system to 2.6%. In terms of the trusted marking function, this invention automatically completes 97.1% of the trusted field return operations, and combines the tax inspection results to write the trusted status to the database, further improving the system's automation and risk control capabilities in large-scale application scenarios. Overall, this method demonstrates significant advantages in recognition accuracy, response speed, risk control, and intelligent processing capabilities, and is suitable for practical application environments that require high-reliability invoice data management.
[0139] The above description is only a preferred specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any technician familiar with the technical field, within the technical scope disclosed by the present invention, who makes equivalent replacements or changes based on the technical solution and inventive concept of the present invention, should be covered by the scope of protection of the present invention.
Claims
1. An artificial intelligence-based Base64 invoice automatic reading and writing optimization method, characterized in that: The steps include: S1. Receive the electronic invoice file uploaded by the user, perform integrity check on the electronic invoice file, and use the Base64 encoding algorithm to generate Base64 encoded invoice data; S2. Transmit the Base64-encoded invoice data to the cloud service platform via the HTTPS protocol, generate the original electronic invoice file content, and perform field structured extraction processing to generate a structured invoice field set; S3. Call the tax system invoice data interface to perform a legality and consistency check on the structured invoice field set and generate a tax verification result. S4. Input the structured invoice field set into the evidence deep learning model, which includes an input vector encoding layer, an embedding expression generation layer, an evidence output layer, a Dirichlet parameter construction module, and an uncertainty calculation unit to generate uncertainty analysis results; S5. Based on the uncertainty analysis results, calculate the data uncertainty score and the model uncertainty score respectively to generate the uncertainty decomposition results; S6. Based on the uncertainty decomposition results, determine the relationship with the preset threshold, generate a risk flag status and trigger the manual review process; S7. If the uncertainty decomposition results do not exceed the corresponding preset thresholds, the structured invoice field set and the tax inspection results are marked as credible, and the credible marking results and the structured invoice field set are sent back to the client together.
2. The method for optimizing automatic reading and writing of Base64 invoices based on artificial intelligence according to claim 1 is characterized in that: Said S1 specifically includes: S11. Receive an electronic invoice file uploaded by a user through a client, where the electronic invoice file is in any one of PDF, OFD, or JPG formats, and generate the electronic invoice file to be processed; S12. Parsing the file header information of the electronic invoice file to be processed, extracting the file format type, file byte length, and file creation time, and generating a set of invoice file metadata; S13: Perform integrity check on the electronic invoice file to be processed and use the preset digest algorithm function H(x) to calculate the digest value D of the original file. f =H(F), where F represents the original electronic invoice file content; S14, the original file digest value and the reference digest value D generated by the client at the time of uploading and uploaded with the request ref Compare and if D is satisfied f =D ref , then the integrity check is determined to be passed and a verification pass mark is generated; S15. If the verification pass flag is established, perform Base64 encoding on the electronic invoice file to be processed, and use the standard Base64 encoding function to encode the file content F into an ASCII string B. f , output as Base64-encoded invoice data.
3. The method for optimizing automatic reading and writing of Base64 invoices based on artificial intelligence according to claim 1 is characterized in that: The S2 specifically includes: S21. Submit the Base64-encoded invoice data to a preset cloud service platform interface address via the secure transmission protocol HTTPS to form the HTTPS transmission request message; S22. After receiving the HTTPS transmission request message, the cloud service platform parses the Base64 encoded invoice data field and extracts the Base64 format string B from it. f After verifying that the identification field is valid, perform the Base64 decoding operation; S23. Perform a format recognition operation on the original electronic invoice file content F to determine whether the original electronic invoice file content is in PDF format, OFD format, or JPG format, and select a corresponding field parsing template based on the file format; S24: Based on the field parsing template, perform structured field extraction processing on the original electronic invoice file content F, extracting invoice code, invoice number, invoice date, amount, tax rate, seller information and buyer information, and construct a structured invoice field set V. f .
4. The method for optimizing automatic reading and writing of Base64 invoices based on artificial intelligence according to claim 1 is characterized in that: The S3 specifically includes: S31. Set the structured invoice field V f The invoice code, invoice number, invoice date, amount, tax rate, seller information, and buyer information are sequentially filled into the data structure required by the tax system interface and organized according to the predefined order of the fields in the interface protocol to form a tax inspection request data packet; S32. Send a tax inspection request data packet through the tax system open data interface, and receive the tax inspection return result based on the interface response protocol format; S33. Parse the tax inspection return result, extract the invoice verification status identifier, interface response code, inspection timestamp, and related return fields from the tax inspection return result, and generate a tax inspection result set; S34. Output the tax inspection result set as a result of the legality and consistency inspection of the structured invoice field set.
5. The method for optimizing automatic reading and writing of Base64 invoices based on artificial intelligence according to claim 1 is characterized in that: The S4 specifically includes: S41. Set the structured invoice field V f Inputting an evidence deep learning model, the evidence deep learning model includes an input vector encoding layer, an embedding expression generation layer, an evidence output layer, a Dirichlet parameter construction module, and an uncertainty calculation unit; S42. Input vector encoding layer receives structured invoice field set V f , and set the structured invoice field set V f Convert to a standardized feature representation vector x; S43, the embedding expression generation layer performs a multi-layer mapping operation on the standardized feature representation vector x to generate an embedding expression vector z for the interaction between fields; S44, the evidence output layer outputs the evidence value set e={e1,e2,…,e k ,…,e K }, where each evidence value is e k ≥0, indicating the strength of evidence support for the category label; S45, a Dirichlet parameter construction module constructs a Dirichlet distribution parameter set based on the evidence value set e; S46, the uncertainty calculation unit calculates the consistency prediction probability and the total uncertainty score based on the Dirichlet parameter set α; S47. The consistent prediction probability set and the total uncertainty score u are combined to form the uncertainty analysis result.
6. The method for optimizing automatic reading and writing of Base64 invoices based on artificial intelligence according to claim 5 is characterized in that: The Dirichlet parameter construction module receives a set of evidence values generated by the evidence output layer, each of which corresponds to a field consistency category label. The Dirichlet parameter construction module generates the Dirichlet distribution parameters corresponding to each category label in turn by adding the evidence value corresponding to each category label to a constant 1. The Dirichlet distribution parameters of all categories together constitute a Dirichlet distribution parameter set.
7. The method for optimizing automatic reading and writing of Base64 invoices based on artificial intelligence according to claim 5 is characterized in that: The uncertainty calculation unit calculates the consistency prediction probability and the total uncertainty score based on the Dirichlet parameter set α; based on the Dirichlet distribution parameter set, calculates the prediction probability of each category of field consistency labels, the consistency prediction probability is the ratio of the Dirichlet parameter value of the current category to the sum of all category parameter values, and the prediction probabilities of all field consistency labels are combined into a consistency prediction probability set; based on the Dirichlet distribution parameter set, calculates the total uncertainty score, the total uncertainty score is the ratio between the total number of consistency categories and the sum of all category parameter values.
8. The method for optimizing automatic reading and writing of Base64 invoices based on artificial intelligence according to claim 1 is characterized in that: The S5 specifically includes: S51, receiving uncertainty analysis results, and extracting a total uncertainty score calculated based on a set of Dirichlet distribution parameters; S52. Extract the field quality indicators of each field in the structured invoice field set, including the missing rate, character recognition confidence, and structure deviation score, and calculate the field data uncertainty score: U data =ω1·r missing +ω2·(1-c conf )+ω3·s bias ; Among them, U data represents the data uncertainty score, ω1 represents the weighted coefficient of the missing rate factor, r missing represents the field missing rate, ω2 represents the weighted coefficient of the character recognition confidence factor, c conf represents the confidence of character recognition, ω3 represents the weighting coefficient of the structural deviation scoring factor, s bias represents the structural deviation score; S53, based on the total uncertainty score U total and data uncertainty score U data , calculate the model uncertainty score U madel , subtract the data uncertainty score from the total uncertainty score. If the result is positive, the difference is used as the model uncertainty score. If the result is negative or zero, the model uncertainty score is set to zero; S54. Score the data uncertainty U data and model uncertainty score U madel Output as uncertainty decomposition result.
9. The method for optimizing automatic reading and writing of Base64 invoices based on artificial intelligence according to claim 1 is characterized in that: The S6 specifically includes: S61, receiving uncertainty decomposition results, the uncertainty decomposition results including data uncertainty score U data and model uncertainty score U madel ; S62. Determine the data uncertainty score U data Is it higher than the first preset threshold θ data , or determine the model uncertainty score U madel Is it higher than the second preset threshold θ madel ; S63, if the data uncertainty score U is satisfied data Higher than the first preset threshold θ data Or model uncertainty score U madel Higher than the second preset threshold θ madel , then a risk marking state is generated, marking the corresponding structured field as a high-risk field; S64. After the risk marking status is generated, the manual review process is triggered, the marking field and uncertainty score information are submitted to the manual review interface, and the review request log is recorded.
10. The method for optimizing automatic reading and writing of Base64 invoices based on artificial intelligence according to claim 1 is characterized in that: The S7 specifically includes: S71. If the data uncertainty score U is satisfied data Not higher than the first preset threshold θ data Or model uncertainty score U madel Not higher than the second preset threshold θ madel , then the corresponding structured invoice field set is marked as trusted; S72. Associate the tax inspection result with the structured invoice field set to generate a trusted tag result. Write the trusted tag result as a trusted invoice record into the database system, thereby forming a joint storage of the structured trusted field entry and the trusted inspection record. S73. Construct a return data structure, where the return data structure includes a structured invoice field set and a trusted tag result. S74. Output the returned data structure to the user interface through the client interface, presenting the invoice fields marked as credible and the corresponding verification status information.