A bill labeling method, device, equipment and medium
By segmenting documents and identifying element labels, the problem of low accuracy in document labeling during letter of credit review was solved, thus improving the accuracy and efficiency of identification.
Patent Information
- Application Number
- CN202311219954.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-21
- Publication Date
- 2026-01-09
- Estimated Expiration
- 2043-09-21
AI Technical Summary
In letter of credit review, the existing document annotation methods have poor recognition performance, resulting in low accuracy of annotation results and failing to meet business needs.
By segmenting the document into multiple sub-regions, element labels are identified based on text content and location information, and the labeling accuracy is improved by combining target classification models and recognition models.
This reduces the need for training sample data, improves the accuracy of feature recognition, and reduces the impact of changes in feature location.
Smart Images

Figure CN117274993B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of data processing, in particular to a bill labeling method and device, equipment and medium. BACKGROUND
[0002] In the document auditing link of the letter of credit audit, the documents submitted by the applicant usually need to meet the provisions of the Uniform Customs and Practice for Documentary Credits (UCP) 600 and other regulations, and at the same time meet the individual requirements proposed by the issuing bank in the letter of credit message, such as presentation time, signature requirements (time, signer), language requirements, display content requirements, etc. Otherwise, in order to protect the rights and interests of the applicant, the subsequent process may not be able to proceed.
[0003] In the process of letter of credit audit, natural language processing technology is usually used to assist in sorting out the individual requirements on the letter of credit, extracting the elements of the documents, and judging whether the elements / element values meet the requirements (document auditing) and whether the elements of the documents are self-consistent (single document auditing) and the data of the documents are self-consistent (intra-document auditing) by using pre-defined auditing rules.
[0004] In specific implementation, before extracting the elements of the document, the document needs to be pre-labeled. The computer extracts the elements of the document based on the pre-labeled document. At the same time, the accuracy of the pre-labeling result has a great influence on the accuracy of the element extraction.
[0005] However, due to the characteristics of the documents in the letter of credit audit, such as multiple element categories, small differences between categories, and limited data volume, the recognition effect of the current document labeling method is poor. SUMMARY
[0006] Embodiments of the present application provide a bill labeling method, device, equipment and medium, which are used to solve the problem of low accuracy of labeling results when labeling the documents used in the letter of credit audit in related technologies.
[0007] In a first aspect, to solve the above technical problem, the present application provides a bill labeling method, which comprises:
[0008] obtaining a target document to be labeled;
[0009] segmenting the target document into a plurality of sub-regions based on the text content in the target document;
[0010] For each sub-region, based on the text content and position information corresponding to each text in the sub-region, identifying the element label corresponding to each text, and labeling the corresponding text in the sub-region based on the identified element label;
[0011] Based on the positional relationship among the plurality of sub-regions, the labeled sub-regions are synthesized to obtain a labeled target document.
[0012] In a possible embodiment, based on the text content in the target document, the target document is divided into a plurality of sub-regions, including:
[0013] Text recognition is performed on the target document to obtain a first text corresponding to the target document and position information corresponding to each text block in the first text, the first text being composed of a plurality of sequentially arranged text blocks;
[0014] The first text is input into a target classification model to classify the text blocks based on the text content corresponding to each text block; each class corresponds to a sub-region.
[0015] Based on the classification result and the position information corresponding to each text block, a segmentation position of the target document is determined, and the target document is segmented into a plurality of sub-regions based on the segmentation position.
[0016] In a possible embodiment, the target classification model is obtained by the following method:
[0017] A plurality of first samples in a first training sample set are sequentially input into a first base model for iteration, and the first base model obtained after iteration is taken as the target classification model, wherein the first training sample set includes a plurality of first samples and classification labels corresponding to each text block in each first sample.
[0018] Each iteration includes the following processes:
[0019] Using the first base model, each text block is classified based on the text content corresponding to each text block in the input first sample, and the classification result corresponding to each text block is output.
[0020] Based on the classification result and the classification label corresponding to each sample block, a first loss function value is determined, and the parameters of the first base model are adjusted according to the first loss function value.
[0021] In a possible embodiment, the position region includes a first text region, a main text region, and a last text region.
[0022] In a possible embodiment, based on the text content and the position information corresponding to each text in the sub-region, an element label corresponding to each text is identified, including:
[0023] text recognition is performed on the sub-region to obtain a second text corresponding to the sub-region and position information corresponding to each text block in the second text, the first text is composed of a plurality of text blocks arranged in sequence, and the position information corresponding to the text blocks is used to identify positions of the text blocks in the sub-region;
[0024] The second text and the position information corresponding to each text block are input into a target recognition model to recognize relative positions between the text blocks based on the position information corresponding to each text block, and to recognize element labels corresponding to the text blocks based on text contents of the text blocks and the relative positions between the text blocks.
[0025] In a possible embodiment, the target recognition model is obtained in the following manner:
[0026] The second samples in the second training sample set and the corresponding position information are input into the second base model in sequence for iteration, and the second base model obtained after the iteration is completed is used as the target recognition model, wherein the second training sample set includes a plurality of second samples, position information corresponding to each text block in each second sample, and element labels;
[0027] Each iteration includes the following processes:
[0028] The second base model is used to recognize relative positions between the text blocks based on the position information of the input text blocks, and to determine output results corresponding to the text blocks based on the text contents of the text blocks and the relative positions between the text blocks.
[0029] A second loss function value is determined according to the output results corresponding to each sample block and the element labels, and parameters of the second base model are adjusted according to the second loss function value.
[0030] In a possible embodiment, the element labels are determined based on the text contents of the text blocks and positions of the text blocks in the target document.
[0031] In a possible embodiment, after the second text corresponding to the sub-region and the position information corresponding to each text block in the second text are obtained, the method further includes:
[0032] The position information corresponding to each text block in the second text is normalized.
[0033] The second text and the position information corresponding to each text block are input into the target recognition model, including:
[0034] The second text and the normalized position information are input into the target recognition model.
[0035] In a possible implementation, the method further includes:
[0036] text recognition is performed on the target document to obtain third text corresponding to the target document;
[0037] The third text is matched with keywords in a database;
[0038] Based on the label corresponding to the matched keyword, a corresponding text block in the third text is labeled.
[0039] In a second aspect, the present application provides a document labeling device, which includes:
[0040] An acquisition unit configured to acquire a target document to be labeled;
[0041] A segmentation unit configured to segment the target document into a plurality of sub-regions based on text content in the target document;
[0042] A labeling unit configured to, for each sub-region, identify an element label corresponding to each text based on text content and position information of the text in the sub-region, and label the corresponding text in the sub-region based on the identified element label;
[0043] A synthesis unit configured to synthesize the labeled sub-regions based on a positional relationship between the plurality of sub-regions to obtain a labeled target document.
[0044] In a possible implementation, the segmentation unit is specifically configured to:
[0045] Text recognition is performed on the target document to obtain first text corresponding to the target document and position information of each text block in the first text, the first text being composed of a plurality of sequentially arranged text blocks;
[0046] The first text is input into a target classification model to classify the text blocks based on text content of each text block, wherein each class corresponds to a sub-region;
[0047] Based on the classification result and the position information of each text block, a segmentation position of the target document is determined, and the target document is segmented into a plurality of sub-regions based on the segmentation position.
[0048] In a possible implementation, the target classification model is obtained in the following manner:
[0049] The plurality of first samples in the first training sample set are sequentially input into the first base model for iteration, and the first base model obtained after the iteration is ended is taken as the target classification model, wherein the first training sample set includes a plurality of first samples and classification labels corresponding to each text block in each first sample;
[0050] Each sub-iteration includes the following processes:
[0051] The first base model is used to classify each text block based on the text content corresponding to each text block in the input first sample, and output the classification result corresponding to each text block;
[0052] The first loss function value is determined according to the classification result corresponding to each sample block and the classification label, and the parameters of the first base model are adjusted according to the first loss function value.
[0053] In a possible embodiment, the position region includes: a first text region, a main text region, and a last text region.
[0054] In a possible embodiment, the labeling unit is specifically configured to:
[0055] The text recognition is performed on the sub-region to obtain the second text corresponding to the sub-region and the position information corresponding to each text block in the second text, the first text is composed of a plurality of sequentially arranged text blocks, and the position information corresponding to the text block is used to identify the position of the text block in the sub-region;
[0056] The second text and the position information corresponding to each text block are input into the target recognition model to identify the relative positions between each text block based on the position information of each text block, and identify the element label corresponding to each text based on the text content of each text block and the relative positions between each text block.
[0057] In a possible embodiment, the target recognition model is obtained by the following method:
[0058] The second sample and the corresponding position information in the second training sample set are sequentially input into the second base model for iteration, and the second base model obtained after the iteration is ended is taken as the target recognition model, wherein the second training sample set includes a plurality of second samples, position information corresponding to each text block in each second sample, and element labels;
[0059] Each sub-iteration includes the following processes:
[0060] The second base model is used to identify the relative positions between the text blocks based on the input position information of each text block, and determine the output result corresponding to each text block based on the text content of each text block and the relative positions between the text blocks.
[0061] According to the output result corresponding to each sample block and the element label, a second loss function value is determined, and the parameters of the second base model are adjusted according to the second loss function value.
[0062] In a possible embodiment, the element label is determined based on the text content of the text block and the position of the text block in the target document.
[0063] In a possible embodiment, the labeling unit is further configured to:
[0064] The position information corresponding to each text block in the second text is normalized;
[0065] The second text and the normalized position information are input into the target recognition model.
[0066] In a possible embodiment, the document labeling apparatus further includes a matching unit, which is specifically configured to:
[0067] Text recognition is performed on the target document to obtain a third text corresponding to the target document;
[0068] The third text is matched with the keywords in the database;
[0069] The text block in the third text corresponding to the matched keyword is labeled based on the label corresponding to the matched keyword.
[0070] In a third aspect, the present application provides an electronic device, comprising:
[0071] A memory for storing program instructions;
[0072] A processor for calling the program instructions stored in the memory and executing the steps included in the method of any one of the first aspect according to the obtained program instructions.
[0073] In a fourth aspect, the present application provides a computer readable storage medium, which stores a computer program, the computer program includes program instructions, and the program instructions, when executed by a computer, cause the computer to execute the method of any one of the first aspect.
[0074] In a fifth aspect, the present application provides a computer program product, comprising computer program codes, which, when running on a computer, cause the computer to execute the method of any one of the first aspect.
[0075] Through the technical solutions in one or more of the above embodiments of the present application, the present application has at least the following technical effects:
[0076] In the embodiments provided by the present application, the target document is segmented based on the text corresponding to the target document, and the element label is identified based on the text content and position information corresponding to each text in each sub-region after segmentation, which reduces the influence of element position change on element identification, and further reduces the data amount requirement of training samples, and improves the accuracy of identification by combining element position with element identification. BRIEF DESCRIPTION OF DRAWINGS
[0077] Figure 1 A flowchart of a document labeling method provided by an embodiment of the present application;
[0078] Figure 2 A schematic diagram of a labeled document provided by an embodiment of the present application;
[0079] Figure 3 A schematic diagram of another labeled document provided by an embodiment of the present application;
[0080] Figure 4 A schematic diagram of the working principle of a layoutLM model provided by an embodiment of the present application;
[0081] Figure 5 A structural diagram of a document labeling device provided by an embodiment of the present application;
[0082] Figure 6 A structural diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0083] In order to make the purpose, technical scheme and advantages of the present application clearer, the technical scheme of the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor fall within the scope of protection of the present application. In the case of no conflict, the embodiments in the present application and the features in the embodiments can be combined with each other at will. And, although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that here.
[0084] The terms "first" and "second" in the specification and claims of this application and above drawings are used to distinguish different objects, not to describe a particular order. In addition, the term "comprising" and any variations thereof are intended to cover non-exclusive protection. For example, a process, method, system, product or device including a series of steps or units is not limited to the listed steps or units, but can optionally include steps or units not listed, or can optionally include other steps or units inherent to the process, method, product or device. "Multiple" in this application can mean at least two, for example, can be two, three or more, and the embodiments of this application are not limited.
[0085] In the technical solutions of this application, the collection, transmission and use of data comply with the requirements of relevant national laws and regulations.
[0086] For ease of understanding, the terms involved in the embodiments of this application are first explained.
[0087] 1. Natural Language Processing (NLP): Natural Language Processing is a discipline that studies language problems in human communication and human-computer communication. In simple terms, it is a computer that accepts user natural language input, and internally processes, calculates and other series of operations through human-defined algorithms to simulate human understanding of natural language and return the results expected by the user. The purpose of natural language processing is to replace human labor with computers to process large-scale natural language information, mainly including automatic word segmentation, part-of-speech tagging, syntax analysis, text classification, information extraction and other categories, and is an interdisciplinary field of artificial intelligence, computer science and information engineering, which designs knowledge of statistics, linguistics, etc.
[0088] 2. Sequence labeling: is a basic problem in NLP. In sequence labeling, each element of a sequence is labeled with a label. Generally, a sequence refers to a sentence, and an element refers to a word in the sentence. Sequence labeling can be divided into two categories: raw labeling, which requires each element to be labeled as a label; joint segmentation and labeling, which labels all segments as the same label.
[0089] 3. Named Entity Recognition (NER): refers to identifying entities with specific meanings in text, mainly including names, place names, proper nouns, organization names, etc. Named entity recognition is a basic and key task in natural language processing, and is an important basic tool for information extraction, question answering system, syntax analysis, machine translation, Semantic Web-oriented metadata annotation, and other application fields.
[0090] 4. Optical Character Recognition (OCR): mainly uses optical methods to convert the text in paper documents into black and white dot matrix image files, and converts the text in the image into text format through recognition software for further editing and processing by word processing software.
[0091] 5. Bill of Lading (B / L): a document used to prove the contract of sea transportation and the takeover or loading of goods by the carrier, and the document used by the carrier to guarantee delivery at the destination port.
[0092] Before introducing the document labeling method provided by the embodiments of the present application, in order to facilitate understanding, first, the technical background of the embodiments of the present application is introduced in detail.
[0093] In the document auditing link in the letter of credit audit, the essence requires that the documents submitted by the applicant be within the scope of the Uniform Customs and Practice for Documentary Credits (UCP), International Standard Banking Practice for the Examination of Documents under Documentary Credits (ISBP), etc. requirements, while meeting the individual requirements of the issuing bank in the letter of credit message, such as specific requirements for presentation, documents, etc. such as presentation time, signing requirements (time, signer), language requirements, display content, etc. Otherwise, in order to protect the interests of the applicant, the subsequent process may not be able to proceed when the documents do not meet the requirements.
[0094] In the traditional manual document auditing process, the auditing personnel needs to check each piece of information in the document against the regulations and the document auditing requirements proposed in the letter of credit message. In order to reduce the auditing pressure of the auditing personnel, currently, the letter of credit intelligent auditing is usually used, that is, through the natural language processing technology, the “personalized requirements” on the letter of credit are assisted to be quickly combed, the “elements” of the document are extracted, and the pre-defined auditing rules are used to judge whether the “elements / element values” meet the “requirements” (document auditing) and whether the “elements” of each document are self-consistent (single document auditing) and whether the data of the single document is self-consistent (in-document auditing).
[0095] The algorithm for extracting the data of the document “elements” used in the letter of credit intelligent auditing is a driven algorithm, that is, if the intelligent auditing is to be implemented, the ability of the human being to understand and judge things needs to be taught to the computer, so that the computer learns the recognition ability. Specifically, the computer learns a large number of features of the labeled data, trains a learning model, and the learning model can understand and judge the unknown content.
[0096] In the process of the letter of credit intelligent auditing, it is particularly important to reasonably set the element labels of the document for the extraction of the document elements. The element labels of the document need to meet the conditions of identifying the document category, identifying the requirements of the single document, and identifying the requirements of the single document on other documents.
[0097] When the data is labeled, the artificial labeling method is generally used to label the data that needs to be recognized and distinguished by the computer, but the artificial labeling method is low in efficiency, and whether the labeling result is accurate depends largely on the knowledge level of the labeling personnel. In the scene of auditing, which requires high knowledge and experience, the labeling personnel are required to be higher.
[0098] In the related art, in order to reduce the labeling pressure of the labeling personnel, when the data in the document is labeled, the following two methods are usually used for intelligent labeling:
[0099] The first is to formulate a traditional labeling label system. This method can only identify a single information in the picture, such as two invoice numbers in the picture. However, the traditional label system can only identify what the corresponding invoice number is, but cannot identify two same or different invoice numbers respectively, or can identify two invoice numbers, but cannot identify different auditing intentions according to the identification. If different labels are set for the two invoice numbers: invoice number 1 and invoice number 2, the training data required will increase by one order of magnitude. Moreover, when the same label position changes greatly, this method cannot accurately identify the information in the document. If the accuracy of identification is to be improved, a large amount of training data must be used as support.
[0100] Secondly, the pre-labeled method, which includes keyword or regular-based recognition and machine learning / deep learning-based classification model recognition. Keyword or regular-based recognition is used to locate the element category by keyword matching based on the text block recognized by OCR. For example, "INV NO:" is used to locate the "invoice number". Although this method is accurate, it is difficult to apply to scenes with variable recognition positions and expressions due to the variable number and position of text blocks. Machine learning / deep learning-based classification model is used for applications with multiple element categories and small differences between categories, but the recognition effect is not ideal and requires a large amount of training data. In addition, due to the differences in natural language expression, pre-trained models are difficult to apply to this field, further increasing the demand for training sample size.
[0101] In the embodiments of the present application, the documents used for credit audit have the characteristics of knowledge closure and complex concept relationship. Specifically:
[0102] 1. The document covers a lot of information, and different information may express the same, i.e., the difference between categories is small, and the same information may appear in different positions. For example, there may be multiple invoice numbers, and the positions and intentions are different, but the expression is the same. The credit audit requires multiple intentions in the clauses, and the sentence expressions between different intentions are similar, i.e., the difference between categories is small. For example, the display element requirements for invoice documents and the display element requirements for bill of lading documents.
[0103] 2. The elements in different documents for credit audit are different. For example, there are more than 80 types of display elements in invoice documents, and there are more than 50 types of unique elements in bill of lading documents.
[0104] 3. The elements of the document have obvious long-tail distribution characteristics, and the low-frequency elements account for a large proportion.
[0105] 4. The elements in different areas (such as the first text, the main text, and the concluding text) of the document are relatively concentrated, and the element information is dense, almost every word needs to be recognized, and the different areas do not have obvious context (relatively independent) and other characteristics.
[0106] The aforementioned preamble, body, and conclusion constitute the three parts of a document. The preamble typically includes the bill of lading name (DOCTITTLE), bill of lading number (B / L NO), shipper, consignee, notifying party, and / or header information, means of transport, and route. The body typically includes a description of the goods, unit price and total amount, seal number, and counts of container or package figures. The conclusion typically includes the bill of lading issue date (bl issue date), place of issue (bl issue place), number of original bills of lading (bl original count), number of copies of the bill of lading issued (Number of origin), other information required by the letter of credit to be proven or declared on the invoice, and the signature of the invoice preparer.
[0107] 5. Considering the overall development cost and development cycle, the amount of training sample data is limited.
[0108] Based on this, the labeling methods in the relevant technologies for the labeling of "document elements" before extraction in the document review process have poor recognition effect and low accuracy, which cannot meet business needs.
[0109] Based on the above-mentioned problems, this application proposes a targeted personalized document labeling system and provides a document labeling method with high accuracy.
[0110] Based on the analysis of the requirements of business review elements and the characteristics of corresponding document content, this application's embodiments summarize the following document presentation forms and corresponding solutions:
[0111] 1. The overall description is relatively fixed. The middle part is generally a description of product information, while the upper and lower parts describe information such as shipping or transaction.
[0112] 2. For common elements, the same elements are relatively fixed in their position in the overall document. For example, "Shipper" and "Consignee" usually appear in the upper half of the document, while "Number of origin" usually appears in the lower half. Such elements can be identified separately for different areas.
[0113] 3. For rare elements (i.e., elements that do not appear often), their positions are relatively random, but generally these elements are special requirements for documents. When they appear, they are usually accompanied by corresponding element tags, such as "HS CODE (customs code): XXXXX". Such elements can be identified through keyword matching.
[0114] Based on this, the application provides a document labeling method, please refer to Figure 1 The processing procedure of the method is as follows.
[0115] In step S101, a target document to be labeled is obtained.
[0116] In some embodiments, the application does not limit the document type of the above-mentioned target document to be labeled. For example, the target document can be a bill of lading document or an invoice document.
[0117] In step S102, the target document is segmented into multiple sub-regions based on the text content in the target document.
[0118] In some embodiments, the application does not limit the number of sub-regions segmented from the above-mentioned target document. In one possible implementation, the application segments the target document into three sub-regions, i.e., a first text region, a main text region, and a last text region.
[0119] In some embodiments, the target document is first subjected to text recognition to obtain a first text corresponding to the target document and position information corresponding to each text block in the first text. In some embodiments, the above-mentioned text recognition can be OCR recognition.
[0120] The position information corresponding to each text block is used to identify the position of each text block in the target document. In some embodiments, the position information corresponding to each text block can be obtained by combining the position coordinates of the top-left corner of the text block with the position coordinates of the bottom-right corner of the text block. The above-mentioned first text is composed of multiple text blocks arranged in sequence. In addition to the multiple text blocks, the first text also includes the positional relationship between the text blocks, i.e., the arrangement order (sequence) of the multiple text blocks in the first text.
[0121] After the above-mentioned text recognition is completed, the first text is input into a target classification model to classify the text blocks based on the text content corresponding to each text block. In some possible implementations, the target classification model can classify the text blocks based on the text content corresponding to each text block and the arrangement order of each text block in the first text. Each class corresponds to a sub-region.
[0122] In some embodiments, the above-mentioned target classification model can be obtained by training a BERT model in an initial state based on training samples.
[0123] After the classification is completed, the segmentation positions of the target document are determined based on the classification results and the position information corresponding to each text block, and the target document is segmented into multiple sub-regions based on the segmentation positions.
[0124] In specific implementation, based on the classification result corresponding to each text block, the first text can be segmented into multiple parts, and the text blocks in each part belong to the same category. Then, it can be determined from which text block to start the segmentation, i.e., the text block corresponding to the segmentation. Since the position information corresponding to each text block can be obtained in the embodiments of the present application, after the text block corresponding to the segmentation is determined, the segmentation position (i.e., the segmentation position on the target document) can be determined according to the position information of the text block, and the target document can be segmented based on the segmentation position.
[0125] In step S103, for each sub-region, based on the text content and position information corresponding to each text in the sub-region, the element label corresponding to each text is recognized, and the corresponding text in the sub-region is labeled based on the recognized element label.
[0126] In some embodiments, the above step S103 (recognizing the element label corresponding to each text based on the text content and position information corresponding to each text in the sub-region) specifically includes:
[0127] Text recognition is performed on the sub-region to obtain the second text corresponding to the sub-region and the position information corresponding to each text block in the second text.
[0128] The second text is composed of multiple text blocks arranged in sequence, and the position information corresponding to the text block is used to identify the position of the text block in the sub-region. In some embodiments, the position information corresponding to each text block can be obtained by combining the position coordinates of the upper left corner of the text block with the position coordinates of the lower right corner of the text block.
[0129] In some embodiments, the above text recognition can be OCR recognition.
[0130] In some embodiments, after obtaining the position information corresponding to each text block in the second text, the position information corresponding to each text block in the second text is normalized. Subsequently, the second text and the normalized position information are input into the target recognition model for subsequent element label recognition.
[0131] The second text and the position information corresponding to each text block are input into the target recognition model to recognize the relative positions between the text blocks based on the position information corresponding to each text block, and to recognize the element label corresponding to each text based on the text content of each text block and the relative positions between the text blocks.
[0132] In some embodiments, the above target recognition model can be obtained by training a LayoutLM model in an initial state based on training samples, and the trained LayoutLM model.
[0133] In a specific implementation, when identifying the element label corresponding to each text block based on the text content of each text block and the relative positions between the text blocks, for each text block, the position label corresponding to the text block is identified based on the text content of the text block and the text content of the text blocks near the text block, that is, the text blocks farther from the current text block have less effect on the identification of the current text block.
[0134] In step S104, the labeled sub-regions are synthesized based on the positional relationship between the sub-regions to obtain a labeled target document.
[0135] After the target document is divided into multiple sub-regions based on step S102 described above, the positional relationship between the multiple sub-regions can be obtained. After labeling each sub-region, the multiple labeled sub-regions can be synthesized into a target document based on the positional relationship between the multiple sub-regions.
[0136] The above method divides the target document based on the text corresponding to the target document, and identifies the element label based on the text content and position information of each text in each sub-region after the division, thereby reducing the influence of the change of the element position on the element identification, and further reducing the demand for the data amount of the training sample. Meanwhile, the element identification is combined with the element position, thereby improving the accuracy of the identification.
[0137] In some embodiments, since the common elements in the document are usually distributed in relatively fixed positions, but the distribution positions of some rare elements are relatively random, the element identification process described in step S103 above cannot accurately identify the rare elements. Based on this, the embodiments of the present application also propose an identification method for identifying rare elements. The method can be based on the initial target document (before splitting) or the labeled target document.
[0138] In some embodiments, the method comprises: performing text recognition on the target document to obtain a third text corresponding to the target document; matching the third text with keywords in a database; and labeling the text block corresponding to the third text based on the label corresponding to the matched keyword. The correspondence between the keywords and the labels can be stored in the database or outside the database, and can be called from the outside in the future.
[0139] In a specific implementation, the rare element is generally the requirement for the document specified in the letter of credit, so for the uncommon content, the element is generally matched with the corresponding category (i.e., the above-mentioned keyword), and the keyword matching mode (i.e., the rule matching mode) can be used to identify such elements. For example, the label "HS code" in the document can be located by the keyword "H.S code:". According to the rule matching mode, the regular expression (i.e., the rule expression) is used to sort out the keyword corresponding to each element (stored in the database) and accurately match the scene. In the implementation, the text block in the target document is matched with the keyword, and based on the label corresponding to the matched keyword, the text block (optionally, and its related text block) matched with the keyword is labeled. It should be noted that the related text block of each text block is not limited by the present application. For example, for "H.S code: XXX", the text block matched with the keyword is "H.S code:", and the related text block is "XXX".
[0140] In the implementation, to solve the problem of uneven distribution of document elements, business personnel can sort specific elements according to the distribution of elements from high frequency to low frequency. The high-frequency element is the common element, which can be identified based on the method described in step S103. The low-frequency element with long-tail distribution is the rare element, and it is not necessary to increase the training data. Only the specific expression needs to be sorted, and the corresponding keyword is added to the above-mentioned database. The rare element is identified according to the rule expression.
[0141] The training process of the above-mentioned target classification model is described below.
[0142] In some embodiments, the above-mentioned target classification model is obtained by the following method:
[0143] The plurality of first samples in the first training sample set are input into the first base model for iteration in turn, and the first base model obtained after iteration is taken as the above-mentioned target classification model, wherein the above-mentioned first training sample set includes a plurality of first samples and the classification label corresponding to each text block in each first sample;
[0144] Each iteration includes the following process:
[0145] Using the first base model, classifying each text block based on the text content of each text block in the input first sample, and outputting the classification result corresponding to each text block;
[0146] According to the classification result and the classification label corresponding to each sample block, the first loss function value is determined, and the parameters of the above-mentioned first base model are adjusted according to the above-mentioned first loss function value.
[0147] The following BERT model is taken as an example to specifically describe the above pre-training and training process.
[0148] First, a small number of bill samples are manually annotated as a first training set.
[0149] Second, the BERT model is trained for classification:
[0150] 1. Image preprocessing, text recognition is performed on the target bill, and preprocessing is performed based on the recognized information (such as adjusting the size of each text block to be consistent, etc.), so that the picture is more suitable for the input of the BERT model.
[0151] 2. Text preprocessing, preprocessing is performed on the text recognized by OCR, special start marks are added before the part of the text corresponding to different sub-regions, and end marks are added at the end of the part of the text. In order to facilitate the training of the BERT model, the corresponding word segmentation, part of speech, etc. of each text block can also be labeled.
[0152] 3. BERT model training, the text with special start and end marks is used as the input of the model, and the BERT model is trained; during the training process, the cross-entropy loss function is used to calculate the difference between the predicted result and the true result, and then the parameters of the model are updated through back propagation, so that the prediction result of the model is more accurate.
[0153] 4. Result analysis, analyze the output of the BERT model, and divide the picture into different sub-regions according to the classification result. For example, Figure 2 、 3 As shown by the dashed box in the above figure, the bill is recognized as three sub-regions of the first text, the main text, and the last text according to the position.
[0154] The following describes the training process of the above target recognition model.
[0155] In some embodiments, the above target recognition model is obtained by the following method:
[0156] The second sample in the second training sample set and the corresponding position information are input into the second base model for iteration in turn, and the second base model obtained after iteration is taken as the above target recognition model, wherein the above second training sample set includes multiple second samples, position information corresponding to each text block in each second sample, and element labels.
[0157] Each iteration includes the following processes:
[0158] Using the second base model, the relative positions between the text blocks are recognized based on the position information of the input text blocks, and the output results corresponding to each text block are determined based on the text content of each text block and the relative positions between the text blocks.
[0159] According to the output results corresponding to each sample block and the element label, a second loss function value is determined, and the parameters of the second base model are adjusted according to the second loss function value.
[0160] In some embodiments, the element label is determined based on the text content of the text block and the position of the text block in the target document
[0161] Since the document review is a rigorous task that almost requires checking all the information on the document, when formulating the document label, the business information needs to be considered, in addition, a large number of element labels will inevitably increase the difficulty of information identification, therefore, when formulating the label, the difficulty of information identification is also considered in advance, and the misjudgment that affects the model analysis is avoided as much as possible when formulating the label.
[0162] Therefore, in the embodiments of the present application, the useful information in the document is formulated into labels according to business information (i.e. the business meaning corresponding to the entity) and text position (i.e. the entity text position), mainly including the following two aspects:
[0163] 1. The business meaning corresponding to the entity, such as the label of Figure 2 , Figure 3 , wherein the words around the rectangular box are the labels corresponding to the text in the rectangular box, such as Figure 1 , which includes labels such as Shipper, Consignee, BL_NO, etc. In addition, different business meanings correspond to different labels, as shown in Figure 2 and 3 , Figure 1 , the label (74) and the label (37) are both the names of the company, but considering that the label (74) of Figure 2 corresponds to the company name below the word “As Carrier”, that is, the company name, in addition to being the name of the shipping company, it also serves as the shipping company, so the business meanings of the two companies are different, and the corresponding labels should also be different; such as Figure 2 , Figure 1 , 2 , the label “CARGO_TYPE_SHIPPED_RECEIVED” only determines the type of shipment through the first English word group “RECEIVED” or “BOARD ON” of a whole paragraph of text, so the label “CARGO_TYPE_SHIPPED_RECEIVED” is only marked for the word group.
[0164] 2. The entity position, such as the label (74) and the label (11) of Figure 1 correspond to the names of the shipping company, but considering the large difference in position, the two companies are formulated into different labels.
[0165] By manually abstracting different element labels according to different positions of different documents, and combing and establishing the labeled training data in turn according to the frequency from high to low, a label system with position information and business information is formulated. Based on the labeled label system covering the position relationship, the document information can be more accurately obtained, and information omission can be avoided.
[0166] In a closed scene, for the problem of knowledge-intensive, independent element unit but multiple categories, and serious uneven distribution, the label system with position information is used to pre-label respectively, which has the advantages of fast start and convenient iteration; and through careful design of the labeled label, such as determining the shipment type only by "RECEIVED" or "BOARD ON", and designing the corresponding commodity quantity label according to whether the English expression or Arabic numerals of the commodity quantity, the labeling is more accurate and accurate.
[0167] The following takes the LayoutLM model as an example to specifically describe the above training before and during training:
[0168] I. Image preprocessing, the information after text recognition is preprocessed, segmented according to sub-regions, and the text recognition results of multiple pictures are separated, and the data is normalized (such as the position information of the text block is normalized) and the like.
[0169] II. Text preprocessing, respectively determine the element label corresponding to each sub-region.
[0170] III. Position information, in the LayoutLM model, in addition to the text features, the position information of the element (i.e. the text block) also needs to be considered, which can be realized by the position encoding of the text recognition (the position coordinates of the upper left corner and the lower right corner of the text block). Position encoding can map each element in the document to a unique vector, so that the model can understand the relative position relationship between elements. As shown in the following formula, the input of the LayoutLM model not only has the text content (i.e. the text block) but also the position information (i.e. the position encoding, in turn, the horizontal coordinate x0 of the upper left corner of the text block, the vertical coordinate y0 of the upper left corner, the horizontal coordinate x1 of the upper right corner, and the vertical coordinate y1 of the upper right corner) of the text block. Figure 4
[0171] IV. Model training, for each sub-region, input the training sample labeled by the above three parts (image preprocessing, text preprocessing and position information) into the initial LayoutLM model, select the Adam optimization algorithm and the cross-entropy loss function to train the LayoutLM model, and in the training process, the model will learn the association between text and position by learning the target document data, and gradually improve the accuracy and efficiency of element extraction.
[0172] Specifically, the input of the LayoutLM model is a text content vector and a set of position vectors, as shown in Figure 4 Taking the text "word1+word2+word3" as an example, the actual input of the model is "Token embeddings+Position embeddings(x0)+Position embeddings(y0)+Position embeddings(x1)+Position embeddings(y1)" corresponding to each word, where Token embeddings is the text vector corresponding to the word, Position embeddings(x0) is the position vector corresponding to x0, Position embeddings(y0) is the position vector corresponding to y0, Position embeddings(x1) is the position vector corresponding to x1, and Position embeddings(y1) is the position vector corresponding to y1.
[0173] Five, model inference, after training, the LayoutLM model corresponding to different sub-regions is obtained, the text and image information of the target document are input into the model, and the model will infer the value of the label corresponding to different sub-regions according to the trained parameters and algorithms.
[0174] The document elements are pre-labeled for different sub-regions, which reduces the influence of element position changes on the trained model, avoids problems such as difficulty in checking the amount of training data and conflicts caused by position changes, and based on the LayoutLM model for pre-labeling, which is consistent with the principle, avoids the huge workload of preparing a large amount of training data and defining rule priorities.
[0175] Based on the same inventive concept, an embodiment of the present application provides a document labeling device, please refer to Figure 5 The device comprises:
[0176] The acquisition unit 501 is configured to acquire a target document to be labeled;
[0177] The segmentation unit 502 is configured to segment the target document into a plurality of sub-regions based on the text content in the target document;
[0178] The labeling unit 503 is configured to, for each sub-region, identify the element label corresponding to each text based on the text content and position information corresponding to each text in the sub-region, and label the corresponding text in the sub-region based on the identified element label;
[0179] The synthesis unit 504 is configured to synthesize the labeled sub-regions based on the positional relationship between the plurality of sub-regions to obtain a labeled target document.
[0180] In a possible implementation, the segmentation unit 502 is specifically configured to:
[0181] perform text recognition on the target document to obtain first text corresponding to the target document and position information corresponding to each text block in the first text, the first text being composed of a plurality of sequentially arranged text blocks;
[0182] input the first text into a target classification model to classify the text blocks based on text content corresponding to each text block; each class corresponds to a sub-region;
[0183] determine a segmentation position corresponding to the target document based on the classification result and the position information corresponding to each text block, and segment the target document into a plurality of sub-regions based on the segmentation position.
[0184] In a possible implementation, the target classification model is obtained in the following manner:
[0185] input a plurality of first samples in a first training sample set into a first base model for iteration, and use the first base model obtained after the iteration as the target classification model, wherein the first training sample set includes a plurality of first samples and a classification label corresponding to each text block in each first sample;
[0186] Each iteration includes the following processes:
[0187] use the first base model to classify each text block based on text content corresponding to the text block in the input first sample, and output a classification result corresponding to each text block;
[0188] determine a first loss function value according to the classification result corresponding to each sample block and the classification label, and adjust parameters of the first base model according to the first loss function value.
[0189] In a possible implementation, the position region includes a first text region, a main text region, and a last text region.
[0190] In a possible implementation, the labeling unit 503 is specifically configured to:
[0191] perform text recognition on the sub-region to obtain second text corresponding to the sub-region and position information corresponding to each text block in the second text, the first text being composed of a plurality of sequentially arranged text blocks, and the position information corresponding to the text block being used to identify the position of the text block in the sub-region;
[0192] input the second text and the position information corresponding to each text block in the second text into the target recognition model, to recognize the relative positions between the text blocks based on the position information of each text block, and to recognize the element label corresponding to each text block based on the text content of each text block and the relative positions between the text blocks.
[0193] In a possible embodiment, the target recognition model is obtained by the following method:
[0194] input the second samples in the second training sample set and the corresponding position information into the second base model for iteration, and use the second base model obtained after the iteration as the target recognition model, wherein the second training sample set includes a plurality of second samples, position information corresponding to each text block in each second sample, and an element label;
[0195] Each iteration includes the following processes:
[0196] use the second base model to recognize the relative positions between the text blocks based on the position information of each text block input, and determine the output result corresponding to each text block based on the text content of each text block and the relative positions between the text blocks;
[0197] determine the second loss function value according to the output result corresponding to each sample block and the element label, and adjust the parameters of the second base model according to the second loss function value.
[0198] In a possible embodiment, the element label is determined based on the text content of the text block and the position of the text block in the target document.
[0199] In a possible embodiment, the labeling unit 503 is further configured to:
[0200] normalize the position information corresponding to each text block in the second text;
[0201] input the second text and the normalized position information into the target recognition model.
[0202] In a possible embodiment, the document labeling apparatus further includes a matching unit, which is specifically configured to:
[0203] perform text recognition on the target document to obtain a third text corresponding to the target document;
[0204] match the third text with the keywords in the database;
[0205] label the text block in the third text based on the label corresponding to the matched keyword.
[0206] It should be noted that the division of units in the embodiments of the present application is illustrative, and is only a logical functional division. In actual implementation, another division manner can be used. In addition, each functional unit in each embodiment of the present application can be integrated in one processing unit, or each unit can be physically present separately, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of a software functional unit.
[0207] When the integrated unit is realized in the form of a software functional unit and sold or used as an independent product, it can be stored in a processor-readable storage medium. Based on this understanding, the technical solutions of the present application can be embodied in the form of a software product, essentially or in the part that contributes to the prior art, or the whole or part of the technical solutions.
[0208] It should be noted that the above device provided by the embodiments of the present application can realize all method steps realized by the above method embodiments, and can achieve the same technical effects. Here, the same parts and beneficial effects of the method embodiments in the embodiments will not be described in detail.
[0209] Based on the same inventive concept, the embodiments of the present application provide an electronic device, which can realize the functions of the bill labeling discussed above, please refer to Figure 6 The device includes at least one processor 601 and a memory 602 connected with the at least one processor. In the embodiments of the present application, the specific connection medium between the processor 601 and the memory 602 is not limited, Figure 6 In the processor 601 and the memory 602, the connection between them can be through a bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For convenience of representation, Figure 6 In the processor 601 and the memory 602, the connection between them can be through a bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For convenience of representation,
[0210] The processor 601 is the control center of the electronic device, and can connect various parts of the electronic device through various interfaces and lines, and realize data processing by running or executing instructions stored in the memory 602 and calling data stored in the memory 602. Optionally, the processor 601 can include one or more processing units. The processor 601 can integrate an application processor and a modem processor, wherein the application processor mainly processes an operating system, a user interface and an application program, etc., and the modem processor mainly processes the issued instructions. It can be understood that the above-mentioned modem processor can also not be integrated into the processor 601. In some embodiments, the processor 601 and the memory 602 can be realized on the same chip, and in some embodiments, they can also be realized on independent chips respectively.
[0211] The processor 601 can be a general processor, such as a central processing unit (CPU), a digital signal processor, an application specific integrated circuit (ASIC), a field programmable gate array or other programmable logic device, a discrete gate or transistor logic component, a discrete hardware component, and can implement or execute the methods, steps and logic block diagrams disclosed in the embodiments of the present application. The general processor can be a microprocessor or any conventional processor. The steps of the method disclosed in combination with the test data generation method embodiment can be directly embodied as execution completed by a hardware processor, or executed by a combination of hardware and software modules in the processor.
[0212] The memory 602 is a non-volatile computer readable storage medium, which can be used to store non-volatile software programs, non-volatile computer executable programs and modules. The memory 602 can include at least one type of storage medium, such as flash memory, hard disk, multimedia card, card type memory, random access memory (RAM), static random access memory (SRAM), programmable read only memory (PROM), read only memory (ROM), electrically erasable programmable read only memory (EEPROM), magnetic storage, magnetic disk, optical disk, etc. The memory 602 is any other medium capable of carrying or storing desired program code in the form of instructions or data structures and capable of being accessed by a computer, but is not limited to this. The memory 602 in the embodiments of the present application can also be a circuit or any other device capable of realizing the storage function, used for storing program instructions and / or data.
[0213] In the embodiments of the present application, the memory 602 stores a computer program, which, when executed by the processor 601, causes the processor 601 to perform the following steps:
[0214] Obtaining a target document to be labeled;
[0215] Based on the text content in the target document, the target document is divided into a plurality of sub-regions;
[0216] For each sub-region, based on the text content and position information corresponding to each text in the sub-region, the element label corresponding to each text is identified, and the corresponding text in the sub-region is labeled based on the identified element label.
[0217] Based on the positional relationship among the plurality of sub-regions, the labeled sub-regions are synthesized to obtain a labeled target document.
[0218] In some optional embodiments, the processor 601 is specifically configured to perform the following:
[0219] Text recognition is performed on the target document to obtain a first text corresponding to the target document and position information corresponding to each text block in the first text, the first text being composed of a plurality of sequentially arranged text blocks;
[0220] The first text is input into a target classification model to classify the text blocks based on the text content corresponding to each text block; each class corresponds to a sub-region.
[0221] Based on the classification result and the position information corresponding to each text block, a segmentation position of the target document is determined, and the target document is segmented into a plurality of sub-regions based on the segmentation position.
[0222] In some optional embodiments, the target classification model is obtained in the following manner:
[0223] A plurality of first samples in a first training sample set are sequentially input into a first base model for iteration, and the first base model obtained after iteration is taken as the target classification model, wherein the first training sample set includes a plurality of first samples and classification labels corresponding to each text block in each first sample;
[0224] Each iteration includes the following processes:
[0225] Using the first base model, each text block is classified based on the text content corresponding to each text block in the input first sample, and a classification result corresponding to each text block is output;
[0226] A first loss function value is determined according to the classification result and the classification label corresponding to each sample block, and the parameters of the first base model are adjusted according to the first loss function value.
[0227] In some optional embodiments, the position region includes a first text region, a main text region, and a last text region.
[0228] In some optional embodiments, the processor 601 is specifically configured to perform the following:
[0229] perform text recognition on the sub-region to obtain second text corresponding to the sub-region and position information corresponding to each text block in the second text, the second text being composed of a plurality of text blocks arranged in sequence, and the position information corresponding to each text block being used to identify a position of the text block in the sub-region;
[0230] input the second text and the position information corresponding to each text block into a target recognition model to recognize relative positions between the text blocks based on the position information corresponding to each text block, and recognize an element label corresponding to each text block based on text content of each text block and the relative positions between the text blocks.
[0231] In some optional embodiments, the target recognition model is obtained in the following manner:
[0232] input the second samples in the second training sample set and the corresponding position information into the second base model for iteration in sequence, and use the second base model obtained after the iteration is completed as the target recognition model, wherein the second training sample set includes a plurality of second samples, position information corresponding to each text block in each second sample, and an element label;
[0233] wherein each iteration includes the following processes:
[0234] use the second base model to recognize relative positions between the text blocks based on the position information of the input text blocks, and determine an output result corresponding to each text block based on text content of each text block and the relative positions between the text blocks;
[0235] determine a second loss function value based on the output result corresponding to each sample block and the element label, and adjust parameters of the second base model based on the second loss function value.
[0236] In some optional embodiments, the element label is determined based on text content of the text blocks and positions of the text blocks in the target document.
[0237] In some optional embodiments, the processor 601 is specifically configured to perform:
[0238] perform normalization processing on the position information corresponding to each text block in the second text;
[0239] input the second text and the normalized position information into the target recognition model.
[0240] In some optional embodiments, the processor 601 is further configured to perform:
[0241] perform text recognition on the target document to obtain third text corresponding to the target document;
[0242] Matching the third text with the keywords in the database;
[0243] Based on the label corresponding to the matched keyword, the corresponding text block in the third text is labeled.
[0244] Based on the same inventive concept, the embodiments of the present application provide a computer readable storage medium, and a computer program product includes computer program code, when the computer program code runs on the computer, the computer executes the invoice labeling method as any of the foregoing. Since the computer readable storage medium solves the problem in the same way as the invoice labeling method, the implementation of the computer readable storage medium can be referred to the implementation of the method, and the repeated parts will not be repeated.
[0245] Based on the same inventive concept, the embodiments of the present application also provide a computer program product, which includes computer program code, when the computer program code runs on the computer, the computer executes the invoice labeling method as any of the foregoing. Since the computer program product solves the problem in the same way as the invoice labeling method, the implementation of the computer program product can be referred to the implementation of the method, and the repeated parts will not be repeated.
[0246] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can be in the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can be in the form of a computer program product implemented on one or more computer usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer usable program code.
[0247] The present application is described with reference to flowcharts and / or block diagrams according to the method, device (system), and computer program product of the present application. It should be understood that each flow and / or block in the flowchart and / or block diagram, and the combination of the flows and / or blocks in the flowchart and / or block diagram can be realized by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device produce a device that implements the functions specified in the flowchart and / or block diagram. Figure 1 The device that implements the functions specified in one flow or multiple flows and / or blocks Figure 1 The device that implements the functions specified in one flow or multiple flows and / or blocks
[0248] These computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture including instructions which implement the Figure 1 function specified in the flow or flows and / or blocks Figure 1 of the block or blocks.
[0249] The computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions that are executed on the computer or other programmable apparatus provide steps for implementing the Figure 1 function specified in the flow or flows and / or blocks Figure 1 of the block or blocks.
[0250] Obviously, numerous modifications and variations of the present application are possible in light of the above teachings. It is therefore to be understood that within the scope of the apparent to those skilled in the art that the application can be practiced otherwise than as specifically described herein. Any feature described herein as part of one aspect of the application can be combined with any other aspect of the application to provide an embodiment of the application. Conversely, any feature described herein as part of one aspect of the application can be excluded from that aspect of the application to provide an embodiment of the application. Thus, the breadth and scope of the present application should not be limited by any of the above described embodiments, but should be defined in accordance with the following claims and any equivalents thereof.
Claims
1. A method of labeling a document, characterized by, The method comprises: obtaining a target document to be labeled; performing text recognition on the target document to obtain first text corresponding to the target document and position information corresponding to each first text block in the first text, the first text comprising a plurality of first text blocks arranged in sequence; inputting the first text into a target classification model to classify each first text block based on the text content corresponding to the first text block; wherein each category corresponds to a sub-region; based on the classification result and the position information corresponding to each first text block, determining a segmentation position corresponding to the target document, and segmenting the target document into a plurality of sub-regions based on the segmentation position; for each sub-region, performing text recognition on the sub-region to obtain second text corresponding to the sub-region and position information corresponding to each second text block in the second text, the second text comprising a plurality of second text blocks arranged in sequence, the position information corresponding to the second text block identifying the position of the second text block in the sub-region; inputting the second text and the position information corresponding to each second text block into a target recognition model to recognize the relative positions between each second text block based on the position information of each second text block, recognize the element label corresponding to each second text block based on the text content of each second text block and the relative positions between each second text block, and label the corresponding second text block in the sub-region based on the recognized element label; based on the positional relationship between the plurality of sub-regions, synthesizing the labeled sub-regions to obtain a labeled target document.
2. The method of claim 1, wherein, The target classification model is obtained by: inputting a plurality of first samples in a first training sample set into a first base model for iteration in sequence, and taking the first base model obtained after iteration as the target classification model, wherein the first training sample set comprises a plurality of first samples and a classification label corresponding to each text block in each first sample; wherein each iteration comprises the following processes: using the first base model, classifying each text block based on the text content of each text block in the input first sample, and outputting the classification result corresponding to each text block; determining a first loss function value according to the classification result and the classification label corresponding to each sample block, and adjusting the parameters of the first base model according to the first loss function value.
3. The method of claim 1 or 2, wherein, The sub-region comprises a first text region, a main text region, and a last text region.
4. The method of claim 1, wherein, The target recognition model is obtained by: inputting a second sample and corresponding position information in a second training sample set into a second base model for iteration in sequence, and taking the second base model obtained after iteration as the target recognition model, wherein the second training sample set comprises a plurality of second samples, position information corresponding to each text block in each second sample, and an element label; wherein each iteration comprises the following processes: The second base model is used to identify the relative positions between the text blocks based on the input position information of each text block, and determine the output result corresponding to each text block based on the text content of each text block and the relative positions between the text blocks; According to the output result corresponding to each sample block and the element label, a second loss function value is determined, and the parameters of the second base model are adjusted according to the second loss function value.
5. The method of claim 4, wherein, The element label is determined based on the text content of the second text block and the position of the second text block in the target document.
6. The method of claim 1, wherein, After obtaining the second text corresponding to the sub-region and the position information corresponding to each second text block in the second text, the method further comprises: The position information corresponding to each second text block in the second text is normalized; The second text and the normalized position information are input into the target recognition model. The method further comprises:
7. The method of claim 1, wherein, Text recognition is performed on the target document to obtain a third text corresponding to the target document; The third text is matched with the keywords in the database; The corresponding text block in the third text is labeled based on the label corresponding to the matched keyword. The device comprises:
8. A slip labeling apparatus characterized by comprising: An acquisition unit is configured to acquire a target document to be labeled; A segmentation unit is configured to perform text recognition on the target document to obtain a first text corresponding to the target document and position information corresponding to each first text block in the first text, the first text comprising a plurality of first text blocks arranged in sequence; the first text is input into a target classification model to classify the first text blocks based on the text content corresponding to each first text block; each category corresponds to a sub-region; a segmentation position of the target document is determined based on the classification result and the position information corresponding to each first text block, and the target document is segmented into a plurality of sub-regions based on the segmentation position; A labeling unit is configured to, for each sub-region, perform text recognition on the sub-region to obtain a second text corresponding to the sub-region and position information corresponding to each second text block in the second text, the second text comprising a plurality of second text blocks arranged in sequence, the position information corresponding to each second text block identifying the position of the second text block in the sub-region; the second text and the position information corresponding to each second text block are input into a target recognition model to identify the relative positions between the second text blocks based on the position information corresponding to each second text block, and identify the element label corresponding to each second text block based on the text content of each second text block and the relative positions between the second text blocks, and label the corresponding second text block in the sub-region based on the identified element label. A synthesis unit is configured to synthesize the labeled sub-regions based on the positional relationship between the plurality of sub-regions to obtain a labeled target document. It comprises:
9. An electronic device, comprising: A memory is configured to store program instructions; A processor configured to invoke program instructions stored in the memory to perform the steps of the method of any of claims 1-7 in accordance with the obtained program instructions.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, the computer program comprising program instructions that, when executed by a computer, cause the computer to perform the method of any of claims 1-7.
11. A computer program product, characterised in that, The computer program product comprises computer program code which, when the computer program code is run on a computer, causes the computer to perform the method of any of claims 1-7.
Citation Information
Patent Citations
A self-adaptive intelligent document recognition and input device and a use method thereof
CN109840519A
Bidding document review analysis method based on regional processing
CN112613285A