Artificial intelligence-based document classification method and device, computer device and medium

By combining template matching, character recognition and error correction, and training models, the problem of low accuracy in existing document classification is solved, and more accurate and efficient document classification is achieved.

CN116361681BActive Publication Date: 2026-02-13CHINA PING AN LIFE INSURANCE CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202211618681.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-15
Publication Date
2026-02-13
Estimated Expiration
2042-12-15

AI Technical Summary

Technical Problem

Existing document classification methods have low accuracy, making it difficult to effectively archive and record documents based on the classification results.

Method used

The primary document category is determined by template matching. Combined with character recognition and error correction, the text extraction optimization results are obtained. Keyword matching is then performed, and the secondary document category is determined using a trained document classification model. Finally, the actual document category is output based on the preset delimiter.

Benefits of technology

It improves the accuracy and efficiency of document classification, ensuring the organization and accuracy of categories.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116361681B_ABST
    Figure CN116361681B_ABST
Patent Text Reader

Abstract

The application is suitable for the technical field of document classification, and particularly relates to a document classification method and device based on artificial intelligence, computer equipment and medium. The application determines a primary document category by matching a to-be-classified document with a plurality of primary category document templates, and performs rough classification on the to-be-classified document. The application performs error correction processing on a preliminary text extraction result of the to-be-classified document according to a preset dictionary to obtain an optimized text extraction result, thereby improving the accuracy of character recognition. The application performs keyword matching on the optimized text extraction result to obtain document keywords, thereby improving the extraction accuracy of category semantic information. The application inputs the document keywords into a trained document classification model corresponding to the primary document category, and more accurately determines a secondary document category on the basis of the primary document category, thereby improving the accuracy of document classification. The application separates the primary document category and the secondary document category through a preset separator, thereby improving the orderliness of actual document categories.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of document classification technology, and in particular to a document classification method, apparatus, computer equipment, and medium based on artificial intelligence. Background Technology

[0002] As living standards improve, people are increasingly willing to purchase insurance. The insurance industry has accumulated a large amount of documents. Classifying these documents can effectively improve the efficiency of insurance processes. With the development of artificial intelligence technology, intelligent classification of documents using AI processing methods has been gradually applied in insurance industry scenarios.

[0003] Currently, existing document classification methods generally match documents directly with preset document templates to determine the actual category of the document based on the matching results. However, due to the low accuracy of template matching, this method can only identify the basic categories of documents, such as insurance policies, expense lists, and individual income tax lists. For large amounts of document data, the number of documents in each category remains large after classification according to the basic categories, making it difficult to effectively archive and record documents based on the classification results, resulting in low accuracy in document classification.

[0004] Therefore, in document classification scenarios, improving the accuracy of document classification has become an urgent problem to be solved. Summary of the Invention

[0005] In view of this, embodiments of the present invention provide a document classification method, apparatus, computer device, and medium based on artificial intelligence to solve the problem of low accuracy in existing document classification.

[0006] In a first aspect, embodiments of the present invention provide an artificial intelligence-based document classification method, the document classification method comprising:

[0007] Obtain the document to be classified, match the document to be classified with several primary category document templates, and determine the primary document category of the document to be classified from several document categories based on the matching results;

[0008] The document to be classified is subjected to character recognition to obtain the preliminary text extraction result of the document to be classified. The preliminary text extraction result is then corrected according to a preset dictionary to obtain the optimized text extraction result of the document to be classified.

[0009] Keyword matching is performed on the optimized text extraction results to obtain document keywords;

[0010] obtain a second document category of the document to be classified by inputting the document keyword into the trained document classification model corresponding to the first document category;

[0011] output an actual document category of the document to be classified according to the first document category, the second document category and a preset separator.

[0012] In a second aspect, an embodiment of the present application provides a document classification device based on artificial intelligence, which comprises:

[0013] a first document category determination module configured to obtain a document to be classified, match the document to be classified with a plurality of first category document templates, and determine a first document category of the document to be classified from a plurality of document categories according to a matching result;

[0014] a character recognition and error correction module configured to perform character recognition on the document to be classified to obtain a preliminary text extraction result of the document to be classified, and perform error correction processing on the preliminary text extraction result according to a preset dictionary to obtain an optimized text extraction result of the document to be classified;

[0015] a keyword extraction module configured to perform keyword matching on the optimized text extraction result to obtain a document keyword;

[0016] a second document category determination module configured to obtain a trained document classification model corresponding to the first document category, input the document keyword into the trained document classification model, and obtain a second document category of the document to be classified;

[0017] an actual document category determination module configured to output an actual document category of the document to be classified according to the first document category, the second document category and a preset separator.

[0018] In a third aspect, an embodiment of the present application provides a computer device, which comprises a processor, a memory and a computer program stored in the memory and executable on the processor, and the processor implements the document classification method according to the first aspect when executing the computer program.

[0019] In a fourth aspect, an embodiment of the present application provides a computer readable storage medium, which stores a computer program, and the computer program is executable on a processor to implement the document classification method according to the first aspect.

[0020] The beneficial effects of this invention compared to existing technologies are as follows: By matching the document to be classified with several primary category document templates, the primary document category of the document to be classified is determined from several document categories based on the matching results. Taking advantage of the convenient but inability to perform fine-grained classification using template matching, the document to be classified is coarsely classified according to the template matching method. Furthermore, character recognition is performed on the document to be classified to obtain preliminary text extraction results. Error correction is then performed on the preliminary text extraction results according to a preset dictionary to obtain optimized text extraction results, improving the accuracy of character recognition. Finally, keyword matching is performed on the optimized text extraction results to obtain document keywords. This method eliminates the influence of interfering strings in the text extraction optimization results, effectively improving the accuracy of extracting category semantic information and the efficiency of document classification. Then, it obtains the trained document classification model corresponding to the primary document category, inputs document keywords into the trained model to obtain the secondary document category of the document to be classified, and more accurately determines the secondary document category based on the primary document category, improving the accuracy of document classification. Finally, based on the primary document category, secondary document category, and preset separator, it outputs the actual document category of the document to be classified, separating the primary and secondary document categories using the preset separator, thus improving the logical structure of the actual document categories. Attached Figure Description

[0021] To more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0022] Figure 1 This is a schematic diagram of an application environment for an artificial intelligence-based document classification method provided in Embodiment 1 of the present invention;

[0023] Figure 2 This is a flowchart illustrating an artificial intelligence-based document classification method provided in Embodiment 1 of the present invention.

[0024] Figure 3 This is a schematic diagram of the structure of an artificial intelligence-based document classification device provided in Embodiment 2 of the present invention;

[0025] Figure 4 This is a schematic diagram of the structure of a computer device provided in Embodiment 3 of the present invention. Detailed Implementation

[0026] In the following description, for purposes of explanation and not limitation, specific details are set forth such as particular architectures, techniques, etc. in order to provide a thorough understanding of the embodiments of the present application. However, it will be apparent to those skilled in the art that the present application can be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known methods, devices, circuits, and

[0027] It will be understood that the term "includes," "including," "has," "having," "comprises," "comprising," "contains" or "containing," when used in the specification and throughout the claims, specifies the presence of the stated features, integers, steps, operations, elements, and / or components but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof.

[0028] It will be understood that the term "and / or," when used in the specification and throughout the claims, means any one and / or any combination of the associated listed items can be present or added.

[0029] As used in the description of the application and the appended claims, the term "if' can be interpreted to mean "when" or "upon" or "in response to determining" or "in response to detecting," depending on the context. Similarly, the phrase "if it is determined" or "if [a described condition or event] is detected" can be interpreted to mean "upon determining" or "in response to determining" or "upon detecting [the described condition or event]" or "in response to detecting [the described condition or event]," depending on the context.

[0030] In addition, the terms "first," "second," "third," etc. are used herein only to distinguish one element from another, and do not imply a relative importance or a given order.

[0031] Reference throughout this specification to "one embodiment" or "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment is included in at least one embodiment of the present application. Thus, the appearances of the phrases "in one embodiment" or "in an embodiment" or "in other embodiments" or "in still other embodiments" in various places throughout this specification are not necessarily all referring to the same embodiment, unless otherwise specified. Furthermore, the terms "comprise," "comprising," "include," "including," "contain," "containing," "have," "having," and the like mean "including but not limited to," unless otherwise indicated.

[0032] The embodiment of the present application can acquire and process related data based on artificial intelligence technology. The artificial intelligence (AI) is the theory, method, technology and application system of using digital computer or digital computer controlled machine to simulate, extend and expand human intelligence, perceive environment, acquire knowledge and use knowledge to obtain the best results.

[0033] The artificial intelligence basic technology generally includes technologies such as sensors, special artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operation / interaction system, mechatronics, etc. The artificial intelligence software technology mainly includes computer vision technology, robot technology, biometric technology, speech processing technology, natural language processing technology and machine learning / deep learning, etc.

[0034] It should be understood that the size of the serial number of each step in the following embodiment does not mean the order of execution, and the execution order of each process should be determined according to its function and inherent logic, and should not constitute any limitation on the implementation process of the embodiment of the present application.

[0035] In order to illustrate the technical solutions of the present application, the following will be illustrated by specific embodiments.

[0036] The embodiment of the present application provides a document classification method based on artificial intelligence, which can be applied in the application environment such as Figure 1 , wherein the client and the server communicate. The client includes but is not limited to palmtop computer, desktop computer, notebook computer, ultra-mobile personal computer (UMPC), netbook, cloud computer device, personal digital assistant (PDA) and other computer devices. The server can be realized by an independent server or a server cluster composed of multiple servers.

[0037] Referring to Figure 2 , it is a flowchart of a document classification method based on artificial intelligence provided by the embodiment of the present application, and the above document classification method can be applied to the client in Figure 1 , the document classification method can include the following steps:

[0038] Step S201, acquiring a document to be classified, matching the document to be classified with a plurality of first-level category document templates, and determining a first-level document category of the document to be classified from a plurality of document categories according to the matching result.

[0039] The document classification of the document data can effectively improve the corresponding work efficiency and is of great significance in various scenarios. For example, in the insurance scenario, as the living standards improve, people's willingness to purchase insurance is increasingly strong, and the insurance industry has accumulated a large amount of document data. The insurance document data has various document categories, and the document classification can effectively improve the processing efficiency of the insurance process.

[0040] The template matching method is a technology for finding the most similar part in one image to another template image. The existing document classification method generally directly matches the document data with the preset document template, and determines the actual category of the document data according to the matching result. Therefore, template matching plays an important role in the document classification task. However, the accuracy of template matching is low, and only the template information is matched without involving semantic information matching. When using template matching to determine the document category, the recognition can only recognize the basic category of the document data, such as hospitalization documents, tax documents, and expense documents. However, the document categories in the insurance scenario are diverse, and each basic first-level document category includes several second-level document categories that are more detailed and similar in template. For example, the hospitalization documents in the first-level document category include hospitalization single, hospitalization medical record, ultrasonic examination report, and physical examination report. Therefore, only using the template matching method cannot accurately recognize the multiple document categories in the insurance scenario, resulting in poor accuracy of document classification and difficulty in effectively archiving and recording processing according to the classification result, which cannot achieve the purpose of improving the processing efficiency of the insurance process.

[0041] Therefore, in this embodiment, the document data is only roughly classified according to the template matching method to obtain the first-level document category of the document data, which serves as the basis for further classification of the document data. The characteristics of convenient template matching but unable to perform fine classification ensure the accuracy of rough classification while improving the classification efficiency.

[0042] Specifically, in this embodiment, a plurality of first-level category document templates are preset according to the actual scene requirements as the basis for template matching. After obtaining the document to be classified, the document to be classified is matched with each first-level category document template, and the first-level document category of the document to be classified is determined from the plurality of document categories according to the matching result, thereby completing the rough classification of the document to be classified.

[0043] Optionally, matching the document to be classified with the plurality of first-level category document templates to determine the first-level document category of the document to be classified from the plurality of document categories includes:

[0044] calculating a first similarity between the document to be classified and each first-level category document template;

[0045] The document category corresponding to the first-level category document template with the highest first similarity is determined as the first-level document category of the document to be classified. The first-level document category includes at least one of the following categories: hospitalization documents, tax documents, expense documents, etc.

[0046] In the insurance scenario, the primary document category can include at least one of the following: hospitalization documents, tax documents, and expense documents. During template matching, the first similarity score between the document to be classified and each primary category document template is calculated. The higher the first similarity score, the better the match between the document to be classified and the corresponding primary category document template. Therefore, the document category corresponding to the primary category document template with the highest first similarity score is determined as the primary document category of the document to be classified, thus completing the coarse classification of the document.

[0047] In one embodiment, cosine similarity measures the similarity between two vectors by measuring the cosine of the angle between them. The value of cosine similarity is between -1 and 1, and the closer the value is to 1, the higher the similarity between the two vectors. It plays an important role in similarity matching.

[0048] Therefore, in this embodiment, the cosine similarity between the document to be classified and each first-level category document template can be calculated as the first similarity. For example, the document to be classified is denoted as vector X, the number of first-level category document templates is denoted as M, and the i-th (i = 1, 2, ..., M) first-level category document template is denoted as vector Y. i Then calculate the document to be classified X and the i-th first-level category document template Y. i The cosine similarity between the two documents yields the first similarity between the document to be classified and the template of the i-th primary category document:

[0049]

[0050] In the formula, S i Let X be the document to be classified and Y be the first similarity between the document to be classified and the template of the i-th first-level category. i This is the i-th first-level category document template.

[0051] Then calculate the first similarity S1, S2, ..., S between the document to be classified and the document template of each first-level category. M If the maximum similarity among the M first similarities is determined, then the document category corresponding to the first-level category document template corresponding to the maximum first similarity can be determined, which is the first-level document category of the document to be classified.

[0052] The step of obtaining the document to be classified, matching the document to be classified with the templates of the first-level categories, and determining the first-level document category of the document to be classified from the plurality of document categories according to the matching result, utilizes the convenience of template matching and the characteristic that template matching cannot be used for fine classification, and performs coarse classification on the document according to the template matching method to obtain the first-level document category of the document, which serves as a basis for further classification of the document, thereby improving the classification efficiency while ensuring the accuracy of the coarse classification.

[0053] In step S202, character recognition is performed on the document to be classified to obtain a preliminary text extraction result of the document to be classified, error correction processing is performed on the preliminary text extraction result according to a preset dictionary, and an optimized text extraction result of the document to be classified is obtained.

[0054] In order to obtain more accurate document classification results, the semantic information of the document to be classified needs to be extracted and analyzed on the basis of the first-level document category obtained by coarse classification of the document to be classified according to template matching. Therefore, the characters in the document to be classified need to be extracted.

[0055] However, the accuracy of character recognition is difficult to reach 100%, for example, the accuracy of optical character recognition in character recognition is basically maintained at about 75%. Therefore, in order to improve the accuracy of character recognition and further improve the accuracy of document classification, error correction processing needs to be performed on the character recognition result to correct the recognized errors, so as to obtain a character recognition result with higher accuracy.

[0056] Specifically, character recognition is performed on the document to be classified according to a character recognition technology to obtain a preliminary text extraction result of the document to be classified, a dictionary is preset according to the actual application scenario of document classification, and error correction processing is performed on the preliminary text extraction result according to the preset dictionary to obtain an optimized text extraction result with higher character recognition accuracy, so as to further improve the accuracy of document classification.

[0057] Optionally, the preliminary text extraction result includes N strings, and the preset dictionary includes M strings, where N and M are integers greater than 1.

[0058] The error correction processing performed on the preliminary text extraction result according to the preset dictionary to obtain the optimized text extraction result of the document to be classified includes:

[0059] Each string in the preliminary text extraction result is searched in the preset dictionary, and it is determined whether each string is in the preset dictionary according to the search result.

[0060] The strings in the preset dictionary are regarded as correct strings, and the strings not in the preset dictionary are regarded as strings to be corrected.

[0061] The error correction processing is performed on the to-be-corrected string to obtain a character extraction optimization result of the to-be-classified document.

[0062] In the character recognition of the to-be-recognized document, N strings are obtained as the character preliminary extraction result, and the preset dictionary includes M strings, where N and M are integers greater than 1.

[0063] Specifically, first, each string in the character preliminary extraction result is searched in the preset dictionary, and it is determined whether each string is in the preset dictionary according to the search result. If the string of the to-be-classified document is in the preset dictionary, it is considered that the string is correctly recognized and does not need to be corrected. Therefore, the string in the preset dictionary is regarded as a correct string. If the string of the to-be-classified document is not in the preset dictionary, it is considered that the string may be incorrectly recognized and needs to be corrected. Therefore, the string not in the preset dictionary is regarded as a to-be-corrected string for replacement error correction processing to obtain a character extraction optimization result of the to-be-classified document based on the character preliminary extraction result, thereby improving the accuracy of the character recognition result.

[0064] Optionally, the replacement error correction processing on the to-be-corrected string to obtain the character extraction optimization result of the to-be-classified document includes:

[0065] For any to-be-corrected string, the second similarity between the to-be-corrected string and each preset string in the preset dictionary is calculated, the maximum second similarity corresponding to the to-be-corrected string is determined, and the preset string corresponding to the maximum second similarity is determined.

[0066] If the maximum second similarity is greater than a preset replacement threshold, the to-be-corrected string is regarded as a correct string.

[0067] If the maximum second similarity is not greater than the preset replacement threshold, the to-be-corrected string is replaced by the preset string corresponding to the maximum second similarity to obtain an optimized string.

[0068] The character extraction optimization result of the to-be-classified document is obtained according to all the correct strings and all the optimized strings.

[0069] Since the forms of strings are various, the number of preset strings in the preset dictionary is limited and cannot include all strings, and the strings change over time based on the preset strings or new strings related to the preset strings appear, for the strings not in the preset dictionary, further judgment needs to be performed to determine whether the string not in the preset dictionary is an incorrectly recognized string.

[0070] Specifically, the second similarity of the to-be-corrected string and each preset string in the preset dictionary is calculated, the maximum second similarity corresponding to the to-be-corrected string is determined, and the preset string corresponding to the maximum second similarity is determined. The corresponding preset string can be regarded as the string closest to the to-be-corrected string.

[0071] When the maximum second similarity is greater than the preset replacement threshold, it indicates that the similarity between the to-be-corrected string and the corresponding preset string is high. The to-be-corrected string can be a string changed over time on the basis of the corresponding preset string, or a newly added string related to the corresponding preset string. Therefore, when the maximum second similarity is greater than the preset replacement threshold, the corresponding to-be-corrected string is regarded as a correct string.

[0072] When the maximum second similarity is not greater than the preset replacement threshold, it indicates that the similarity between the to-be-corrected string and the corresponding preset string is relatively low. It is considered that the to-be-corrected string is an incorrectly recognized string, and the to-be-corrected string needs to be replaced according to the preset string corresponding to the maximum second similarity to obtain an optimized string.

[0073] Then, after further judgment and replacement correction processing of all to-be-corrected characters, according to all correct strings and all optimized strings obtained, a character extraction optimization result of the to-be-classified document is obtained.

[0074] The above steps of performing character recognition on the to-be-classified document to obtain a character preliminary extraction result of the to-be-classified document, performing error correction processing on the character preliminary extraction result according to the preset dictionary to obtain a character extraction optimization result of the to-be-classified document, after obtaining the character preliminary extraction result of the to-be-classified document, performing error correction processing on the character preliminary extraction result according to the preset dictionary to obtain a character extraction optimization result with higher character recognition accuracy, as a basis for fine classification of the to-be-classified document, further improve the accuracy of document classification.

[0075] In step S203, the keyword matching is performed on the character extraction optimization result to obtain a document keyword.

[0076] The character extraction optimization result includes a plurality of strings, including a key string containing category semantic information and an interference string not containing category semantic information. If the character extraction optimization result is directly used as a target of document classification, due to the influence of the interference string, the model attention cannot be completely focused on the key string, which will seriously reduce the extraction accuracy of the category semantic information.

[0077] Therefore, in the embodiment, the keyword matching is performed on the text extraction optimization result according to the keyword extraction algorithm to obtain the document keywords, so as to eliminate the influence of the interference strings in the text extraction optimization result, improve the extraction accuracy of the category semantic information, and greatly reduce the number of strings, thereby effectively improving the efficiency of the document classification.

[0078] The step of performing keyword matching on the text extraction optimization result to obtain the document keywords eliminates the influence of the interference strings in the text extraction optimization result by extracting the keywords containing the category semantic information, effectively improves the extraction accuracy of the category semantic information, and improves the efficiency of the document classification.

[0079] In step S204, the trained document classification model corresponding to the primary document category is obtained, the document keywords are input into the trained document classification model, and the secondary document category of the document to be classified is obtained.

[0080] Each primary document category includes a plurality of secondary document categories. Based on the primary document category of the document to be classified, the category semantic information in the document to be classified can be analyzed by performing feature extraction and mapping on the document keywords, so that the document to be classified is classified in detail based on the primary document category, and the secondary document category of the document to be classified is obtained.

[0081] In the embodiment, in order to improve the accuracy of the document classification, each primary document category corresponds to a trained document classification model. After obtaining the trained document classification model corresponding to the primary document category, the document keywords are input into the trained document classification model, and the secondary document category of the document to be classified can be obtained.

[0082] Optionally, each primary document category corresponds to a trained document classification model, the document classification model includes a trained encoder and a trained fully connected layer, the pre-trained fully connected layer includes a pre-trained linear transformation layer and a normalization exponential function.

[0083] The document keywords are input into the trained document classification model to obtain the secondary document category of the document to be classified, including:

[0084] The document keywords are input into the trained encoder for feature extraction to obtain keyword encoding features.

[0085] The keyword encoding features are input into the trained fully connected layer, the keyword encoding features are transformed into document classification vectors according to the pre-trained linear transformation layer, the document classification vectors are normalized according to the normalization exponential function, and a document category probability vector is obtained.

[0086] The secondary document category of the document to be classified is determined according to the document category probability vector.

[0087] The document classification model comprises a trained encoder and a trained full connection layer, wherein the pre-trained full connection layer comprises a pre-trained linear transformation layer and a normalization exponential function.

[0088] Specifically, the document keyword is input into the trained encoder for feature extraction to obtain keyword encoding features, and then the keyword encoding features are input into the trained full connection layer, the keyword encoding features are transformed into a document classification vector according to the pre-trained linear transformation layer, and the document classification vector is normalized according to the normalization exponential function to obtain a document category probability vector. The document category probability vector can represent the probability of the document keyword belonging to each secondary document category under the corresponding primary document category, and thus the secondary document category of the document to be classified can be determined according to the document category probability vector, and the fine classification of the document to be classified is completed on the basis of the primary document category.

[0089] Optionally, the sample document keyword and the actual secondary document category of the sample document are obtained, the sample keyword is taken as a training sample, the actual secondary document category of the training sample is taken as a training label, and the document classification model is trained.

[0090] The training process of the document classification model is as follows:

[0091] The sample document keyword is input into the encoder for feature extraction to obtain sample keyword encoding features.

[0092] The sample keyword encoding features are input into the full connection layer, the sample keyword encoding features are transformed into a sample document classification vector according to the linear transformation layer, and the sample document classification vector is normalized according to the normalization exponential function to obtain a sample document category probability vector.

[0093] The secondary document category of the sample text is determined according to the sample document category probability vector.

[0094] The model loss is calculated according to the secondary document category of the sample text and the corresponding actual secondary document category, the parameters of the encoder and the parameters of the full connection layer are trained according to the gradient descent method, until the model loss converges, and the trained document classification model is obtained.

[0095] In order to improve the accuracy of the document classification model, the parameters of the document classification model need to be corrected to obtain the trained document classification model.

[0096] Specifically, in the embodiment, the obtained sample keywords are taken as training samples, and the actual secondary document categories of the training samples are taken as training labels. First, the sample document keywords are input into an encoder for feature extraction to obtain sample keyword encoding features. The sample keyword encoding features are input into a fully connected layer, and the sample keyword encoding features are transformed into sample document classification vectors according to a linear transformation layer. The sample document classification vectors are normalized according to a normalized exponential function to obtain a sample document category probability vector. The sample document category probability vector can represent the probability of the sample keywords belonging to each secondary document category under the corresponding primary document category. Therefore, the secondary document category of the sample text can be determined according to the sample document category probability vector.

[0097] Then, the model loss is calculated according to the secondary document category of the sample text and the corresponding actual secondary document category. The model loss can be used to represent the similarity between the secondary document category of the sample text and the corresponding actual secondary document category. The smaller the model loss is, the greater the corresponding similarity is represented, and the higher the accuracy of the document classification model is. Conversely, the greater the model loss is, the smaller the corresponding similarity is represented, and the lower the accuracy of the document classification model is. Therefore, the parameters of the encoder and the fully connected layer need to be trained according to the gradient descent method until the model loss converges, so as to obtain the trained document classification model.

[0098] The above step of obtaining the trained document classification model corresponding to the primary document category, inputting the document keywords into the trained document classification model, and obtaining the secondary document category of the document to be classified, each primary document category including a plurality of secondary document categories, improves the accuracy of the document classification model.

[0099] In step S205, the actual document category of the document to be classified is output according to the primary document category, the secondary document category, and the preset separator.

[0100] The preset separator is used to separate the primary document category and the secondary document category to obtain the actual document category of the document to be classified, so as to improve the orderliness of the actual document category.

[0101] 7Optionally, outputting the actual document category of the document to be classified according to the primary document category, the secondary document category, and the preset separator includes:

[0102] The preset separator is obtained, and the primary document category, the secondary document category, and the preset separator are spliced in a preset order to obtain the actual document category of the document to be classified.

[0103] The preset separator is used to separate the first document category and the second document category in the embodiment, and thus the preset sequence is the first document category, the preset separator and the second document category.

[0104] The preset separator can be set according to actual conditions. For example, the preset separator is “-” in the embodiment, and when the first document category of the document to be classified is “hospitalization document” and the second document category is “physical examination report”, the corresponding actual document category is “hospitalization document-physical examination report”.

[0105] The step of outputting the actual document category of the document to be classified according to the first document category, the second document category and the preset separator separates the first document category and the second document category through the preset separator on the basis of obtaining the accurate first document category and the second document category, and thus the orderliness of the actual document category is improved.

[0106] The embodiment of the application determines the first document category of the document to be classified from the plurality of document categories according to the matching result by matching the document to be classified with the plurality of first category document templates, performs rough classification on the document data according to the template matching method by using the characteristics that the template matching is convenient but cannot be used for fine classification, performs character recognition on the document to be classified to obtain a preliminary extraction result of the document to be classified, performs error correction processing on the preliminary extraction result of the document according to a preset dictionary to obtain an optimized extraction result of the document, improves the accuracy of character recognition, performs keyword matching on the optimized extraction result of the document to obtain document keywords, eliminates the influence of interfering character strings in the optimized extraction result of the document, effectively improves the extraction accuracy of the category semantic information and the efficiency of document classification, obtains the trained document classification model corresponding to the first document category, inputs the document keywords into the trained document classification model to obtain the second document category of the document to be classified, more accurately determines the second document category of the document to be classified on the basis of the first document category, and improves the accuracy of document classification, and finally outputs the actual document category of the document to be classified according to the first document category, the second document category and the preset separator, and separates the first document category and the second document category through the preset separator, thereby improving the orderliness of the actual document category.

[0107] According to the document classification method of the above embodiment, Figure 3 The structural block diagram of the document classification device provided by the second embodiment of the application is given, and only the parts related to the embodiments of the application are shown for the convenience of description.

[0108] Referring to Figure 3 The document classification device comprises:

[0109] The first document category determination module 31 is configured to obtain a document to be classified, match the document to be classified with a plurality of first category document templates, and determine a first document category of the document to be classified from the plurality of document categories according to a matching result.

[0110] The character recognition and correction module 32 is configured to perform character recognition on the document to be classified to obtain a preliminary text extraction result of the document to be classified, perform error correction processing on the preliminary text extraction result according to a preset dictionary, and obtain an optimized text extraction result of the document to be classified.

[0111] The keyword extraction module 33 is configured to perform keyword matching on the optimized text extraction result to obtain a document keyword.

[0112] The second document category determination module 34 is configured to obtain a trained document classification model corresponding to the first document category, input the document keyword into the trained document classification model, and obtain a second document category of the document to be classified.

[0113] The actual document category determination module 35 is configured to output an actual document category of the document to be classified according to the first document category, the second document category, and a preset separator.

[0114] Optionally, the first document category determination module 31 includes:

[0115] The first similarity calculation submodule is configured to calculate a first similarity between the document to be classified and each first category document template.

[0116] The first document category determination submodule is configured to determine a document category corresponding to a first category document template corresponding to the maximum first similarity as the first document category of the document to be classified, and the first document category includes at least one of a hospitalization document, a tax document, and a fee document.

[0117] Optionally, the preliminary text extraction result includes N strings, and the preset dictionary includes M strings, where N and M are integers greater than 1, and the character recognition and correction module 32 includes:

[0118] The string retrieval submodule is configured to search each string in the preliminary text extraction result in the preset dictionary according to a search result to determine whether each string is in the preset dictionary.

[0119] The string classification submodule is configured to classify a string in the preset dictionary as a correct string and a string not in the preset dictionary as a string to be corrected.

[0120] The string correction submodule is configured to perform replacement error correction processing on the string to be corrected to obtain the optimized text extraction result of the document to be classified.

[0121] Optionally, the string error correction submodule includes:

[0122] a second similarity calculation unit, configured to calculate, for any to-be-corrected string, a second similarity between the to-be-corrected string and each preset string in the preset dictionary, determine a maximum second similarity corresponding to the to-be-corrected string, and a preset string corresponding to the maximum second similarity;

[0123] a string category updating unit, configured to, if the maximum second similarity is greater than a preset replacement threshold, take the to-be-corrected string as a correct string;

[0124] a string replacement unit, configured to, if the maximum second similarity is not greater than the preset replacement threshold, replace the to-be-corrected string with the preset string corresponding to the maximum second similarity to obtain an optimized string;

[0125] a character extraction optimization result determination unit, configured to obtain a character extraction optimization result of the to-be-classified document according to all the correct strings and all the optimized strings.

[0126] Optionally, each primary document category corresponds to a trained document classification model, the document classification model includes a trained encoder and a trained fully connected layer, the pre-trained fully connected layer includes a pre-trained linear transformation layer and a normalized exponential function, and the secondary document category determination module 34 includes:

[0127] a feature extraction submodule, configured to input the document keyword into the trained encoder for feature extraction to obtain keyword coding features;

[0128] a document category probability vector determination submodule, configured to input the keyword coding features into the trained fully connected layer, transform the keyword coding features into a document classification vector according to the pre-trained linear transformation layer, and perform normalization processing on the document classification vector according to the normalized exponential function to obtain a document category probability vector;

[0129] a secondary document category determination submodule, configured to determine a secondary document category of the to-be-classified document according to the document category probability vector.

[0130] Optionally, the sample document keyword and the actual secondary document category of the sample document are obtained, the sample keyword is taken as a training sample, the actual secondary document category of the training sample is taken as a training label, the document classification model is trained, and the secondary document category determination module 34 includes:

[0131] a sample feature extraction submodule, configured to input the sample document keyword into the encoder for feature extraction to obtain sample keyword coding features;

[0132] The sample document category probability vector determination submodule is configured to input the sample keyword coding features into a full connection layer, transform the sample keyword coding features into a sample document category vector according to a linear transformation layer, and normalize the sample document category vector according to a normalized exponential function to obtain a sample document category probability vector.

[0133] The sample secondary document category determination submodule is configured to determine a secondary document category of the sample text according to the sample document category probability vector.

[0134] The model parameter correction submodule is configured to calculate a model loss according to the secondary document category of the sample text and a corresponding actual secondary document category, train parameters of the encoder and the full connection layer according to a gradient descent method until the model loss converges, and obtain a trained document classification model.

[0135] Optionally, the actual document category determination module 35 includes:

[0136] The actual document category determination submodule is configured to obtain a preset separator, splice the primary document category, the secondary document category and the preset separator according to a preset order to obtain an actual document category of the document to be classified.

[0137] It should be noted that the information interaction between the above modules, the execution process and the like, since the same concept as the method embodiment of the present application, the specific functions and the technical effects brought about, specific can be seen from the method embodiment part, here will not be repeated.

[0138] Figure 4 A structural schematic diagram of a computer device for the third embodiment of the present application is provided. As shown in the figure, Figure 4 The computer device of this embodiment includes at least one processor (only one is shown in the figure), a memory, and a computer program stored in the memory and executable on the at least one processor, and the processor executes the computer program to implement the steps in any of the above document classification method embodiments. Figure 4

[0139] The computer device can include, but is not limited to, a processor and a memory. Those skilled in the art can understand that Figure 4 It is only an example of a computer device and does not constitute a limitation on the computer device. The computer device can include more or fewer components than shown, or combine certain components, or different components, for example, it can also include a network interface, a display screen and an input device, etc.

[0140] ​The processor can be a CPU, and can also be other general-purpose processors, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA) or other programmable logic device, discrete gate or transistor logic, discrete hardware components, etc. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor.

[0141] The memory includes a readable storage medium, an internal memory, etc., where the internal memory can be a memory of the computer device, and the internal memory provides an environment for running the operating system and the computer-readable instructions in the readable storage medium. The readable storage medium can be a hard disk of the computer device, and in other embodiments, can also be an external storage device of the computer device, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) card, a Flash Card, etc. Further, the memory can include both an internal storage unit of the computer device and an external storage device. The memory is used to store an operating system, an application program, a BootLoader, data, and other programs, such as program codes of computer programs, etc. The memory can also be used to temporarily store data that has been output or will be output.

[0142] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the above-mentioned division of each functional unit and module is exemplified, and in actual application, the above-mentioned functions can be completed by different functional units and modules according to needs, that is, the internal structure of the device is divided into different functional units or modules to complete all or part of the functions described above. Each functional unit and module in the embodiment 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 software functional unit. In addition, the specific names of each functional unit and module are only for easy distinction, and do not limit the protection scope of the present application. The specific working process of the unit and module in the above device can refer to the corresponding process in the foregoing method embodiment, which will not be repeated here. If the integrated unit is realized in the form of software functional unit and sold or used as an independent product, it can be stored in a computer readable storage medium. Based on this understanding, the present application realizes all or part of the processes in the above-mentioned embodiment methods, which can be completed by a computer program to instruct related hardware. The computer program can be stored in a computer readable storage medium, and when the processor executes the computer program, the steps of the above-mentioned method embodiment can be realized. The computer program includes computer program code, which can be in the form of source code, object code, executable file or some intermediate form, etc. The computer readable medium can at least include any entity or device capable of carrying computer program code, recording medium, computer memory, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), electrical carrier signal, telecommunication signal and software distribution medium. For example, U disk, mobile hard disk, magnetic disk or optical disk, etc. In some jurisdictions, according to legislation and patent practice, the computer readable medium cannot be an electrical carrier signal and a telecommunication signal.

[0143] The present application realizes all or part of the processes in the above-mentioned embodiment methods, which can also be completed by a computer program product. When the computer program product runs on the computer device, it makes the computer device execute the steps that can realize the above-mentioned method embodiments.

[0144] In the above embodiments, the description of each embodiment has its own emphasis, and the parts not described or recorded in detail in a certain embodiment can be referred to the related description of other embodiments.

[0145] Those skilled in the art can understand that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be realized in electronic hardware or a combination of computer software and electronic hardware. Whether the functions are realized in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.

[0146] In the embodiments provided by the present application, it should be understood that the disclosed apparatus / computer device and method can be implemented in other ways. For example, the embodiments of the apparatus / computer device described above are merely schematic, and the division of the modules or units is merely a logical function division, and there can be another division manner in actual implementation. For example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the displayed or discussed mutual couplings or direct couplings or communication connections between the units can be indirect couplings or communication connections through some interfaces, devices or units, and can be electrical, mechanical or in other forms.

[0147] The units described as separate components can or can not be physically separate, and the components shown as units can or can not be physical units, i.e. can be located in one place, or can be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the embodiments.

[0148] The above embodiments are only used to illustrate the technical solutions of the present application, but not limit it; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that the technical solutions recorded in the foregoing embodiments can be modified, or some technical features can be replaced by equivalents; and these modifications or replacements do not make the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application.

Claims

1. An artificial intelligence-based document classification method, characterized by, The document classification method comprises: obtaining a document to be classified, matching the document to be classified with a plurality of first-class category document templates, and determining a first-class document category of the document to be classified from a plurality of document categories according to a matching result; performing character recognition on the document to be classified to obtain a preliminary text extraction result of the document to be classified, performing error correction processing on the preliminary text extraction result according to a preset dictionary to obtain an optimized text extraction result of the document to be classified; performing keyword matching on the optimized text extraction result to obtain document keywords; obtaining a trained document classification model corresponding to the first-class document category, inputting the document keywords into the trained document classification model to obtain a second-class document category of the document to be classified; outputting an actual document category of the document to be classified according to the first-class document category, the second-class document category, and a preset separator; each first-class document category corresponds to a trained document classification model, the document classification model comprises a trained encoder and a trained full connection layer, and the pre-trained full connection layer comprises a pre-trained linear transformation layer and a normalization exponential function; the inputting of the document keywords into the trained document classification model to obtain the second-class document category of the document to be classified comprises: inputting the document keywords into the trained encoder for feature extraction to obtain keyword encoding features; inputting the keyword encoding features into the trained full connection layer, transforming the keyword encoding features into a document classification vector according to the pre-trained linear transformation layer, performing normalization processing on the document classification vector according to the normalization exponential function to obtain a document category probability vector; and determining the second-class document category of the document to be classified according to the document category probability vector.

2. The document classification method of claim 1, wherein, the matching of the document to be classified with the plurality of first-class category document templates and the determination of the first-class document category of the document to be classified from the plurality of document categories according to a matching result comprises: calculating a first similarity between the document to be classified and each first-class category document template; determining the document category corresponding to the first-class category document template corresponding to the maximum first similarity as the first-class document category of the document to be classified, wherein the first-class document category comprises at least one of a hospitalization document, a tax document, a fee document, and the like.

3. The document classification method of claim 1, wherein, the preliminary text extraction result comprises N strings, and the preset dictionary comprises M strings, wherein N and M are integers greater than 1; the error correction processing of the preliminary text extraction result according to the preset dictionary to obtain the optimized text extraction result of the document to be classified comprises: searching each string in the preliminary text extraction result in the preset dictionary, and determining whether each string is in the preset dictionary according to a search result; regarding the string in the preset dictionary as a correct string, and regarding the string not in the preset dictionary as a to-be-corrected string; performing replacement error correction processing on the to-be-corrected string to obtain the optimized text extraction result of the document to be classified.

4. The document classification method of claim 3, wherein, The replacement error correction processing on the to-be-corrected string is performed to obtain a character extraction optimization result of the to-be-classified document, and the character extraction optimization result of the to-be-classified document includes: For any to-be-corrected string, a second similarity between the to-be-corrected string and each preset string in a preset dictionary is calculated, a maximum second similarity corresponding to the to-be-corrected string is determined, and a preset string corresponding to the maximum second similarity is determined; If the maximum second similarity is greater than a preset replacement threshold, the to-be-corrected string is regarded as a correct string; If the maximum second similarity is not greater than the preset replacement threshold, the to-be-corrected string is replaced by the preset string corresponding to the maximum second similarity to obtain an optimized string; Based on all the correct strings and all the optimized strings, a character extraction optimization result of the to-be-classified document is obtained.

5. The document classification method of claim 1, wherein, A sample document keyword and an actual secondary document category of a sample document are obtained, the sample document keyword is used as a training sample, the actual secondary document category of the training sample is used as a training label, and the document classification model is trained; The training process of the document classification model includes: The sample document keyword is input into an encoder for feature extraction to obtain a sample keyword coding feature; The sample keyword coding feature is input into a full connection layer, the sample keyword coding feature is transformed into a sample document classification vector by the linear transformation layer, and the sample document classification vector is normalized by the normalization exponential function to obtain a sample document category probability vector; The secondary document category of the sample document is determined based on the sample document category probability vector; The model loss is calculated based on the secondary document category of the sample document and the corresponding actual secondary document category, the parameters of the encoder and the parameters of the full connection layer are trained by the gradient descent method until the model loss converges, and a trained document classification model is obtained.

6. The document classification method of claim 1, wherein, The actual document category of the to-be-classified document is output based on the primary document category, the secondary document category, and a preset separator, and the actual document category of the to-be-classified document includes: A preset separator is obtained, the primary document category, the secondary document category, and the preset separator are spliced in a preset order to obtain the actual document category of the to-be-classified document.

7. An artificial intelligence-based document classification apparatus, characterized by comprising: The document classification device includes: A primary document category determination module is configured to obtain a to-be-classified document, match the to-be-classified document with a plurality of primary category document templates, and determine a primary document category of the to-be-classified document from a plurality of document categories based on a matching result; A character recognition and error correction module is configured to perform character recognition on the to-be-classified document to obtain a character preliminary extraction result of the to-be-classified document, and perform error correction processing on the character preliminary extraction result based on a preset dictionary to obtain a character extraction optimization result of the to-be-classified document; A keyword extraction module is configured to perform keyword matching on the character extraction optimization result to obtain a document keyword. The secondary document category determination module is configured to obtain a trained document classification model corresponding to the primary document category, input the document keywords into the trained document classification model, and obtain a secondary document category of the document to be classified. The actual document category determination module is configured to output an actual document category of the document to be classified according to the primary document category, the secondary document category, and a preset separator. Each of the primary document categories corresponds to a trained document classification model, and the document classification model comprises a trained encoder and a trained full connection layer. The feature extraction submodule is configured to input the document keywords into the trained encoder for feature extraction, and obtain keyword encoding features. The document category probability vector determination submodule is configured to input the keyword encoding features into the trained full connection layer, transform the keyword encoding features into a document classification vector according to the pre-trained linear transformation layer, and normalize the document classification vector according to the normalization exponential function, and obtain a document category probability vector. The secondary document category determination submodule is configured to determine the secondary document category of the document to be classified according to the document category probability vector.

8. A computer device, comprising: The computer device comprises a processor, a memory, and a computer program stored in the memory and executable on the processor, and the processor implements the document classification method of any one of claims 1 to 6 when executing the computer program.

9. A computer-readable storage medium storing a computer program, the computer program comprising instructions that, when executed by a computer, cause the computer to perform the method of any one of claims 1 to 8. The computer program is executed by the processor to implement the document classification method of any one of claims 1 to 6.

Citation Information

Patent Citations

  • Method and device for constructing document structure information retrieval library

    CN113449063A