Certificate key information extraction system and method based on large language model

Through the document key information extraction system based on the large language model, OCR technology and few-shot learning are used to solve the problem of strong dependence on rule design and template matching in document key information extraction, and achieve efficient and low-cost document information extraction, which is suitable for Suitable for multiple document types and expanded to other scenarios.

CN118692097AInactive Publication Date: 2024-09-24SHENZHEN WISE E-COMMERCE CO LTD

Patent Information

Application Number
CN202410898715.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-05
Publication Date
2024-09-24
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Existing document key information extraction technology has problems such as rule design that is difficult to generalize, template matching is highly dependent, and supervised learning requires a large amount of annotated data, resulting in low efficiency and high cost.

Method used

A document key information extraction system based on a large language model is used to obtain text information through OCR technology, build a document information table, and use a small number of sample input and output pairs of prompt words to perform few-sample learning of the large language model to extract document information.

Benefits of technology

It does not require a large amount of annotated data, has strong generalization capabilities, and can accurately extract key information from a variety of document types, reducing labor and time costs, and can be expanded to other key information extraction scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118692097A
    Figure CN118692097A
Patent Text Reader

Abstract

The invention discloses a certificate key information extraction system and method based on a large language model, and relates to the technical field of certificate data extraction, and the method comprises the following steps: S1, obtaining text information from a certificate image by using an OCR technology, including text detection and text recognition; s2, constructing a table of certificate information according to the acquired text information and the position of the text information in the image; s3, a cue word containing a small number of sample input and output pairs is constructed and used for guiding the large language model to conduct small-sample learning; and S4, inputting the constructed cue word into the large language model to extract certificate information. According to the method, a large-language-model-based feed-shot learning strategy is adopted, knowledge required by a new task can be excellently mastered only by providing a small number of samples, the generalization ability is excellent, the rich and powerful natural language understanding ability is achieved, the application range is wide, the method is based on a large-language-model-based feed-shot learning mode, and the large-language-model-based feed-shot learning method has the advantages that the large-language-model-based feed-shot learning strategy is provided; and the key information can be accurately extracted only depending on plain texts.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of certificate data extraction, and in particular to a system and method for extracting key certificate information based on a large language model. Background Art

[0002] The extraction of key information from ID cards plays a vital role in document understanding. Its goal is to digitize the text information in the ID card image and output it in a formatted manner to facilitate subsequent computer processing and application. Key information includes many elements such as ID number, name, gender, address, nationality, and date of issuance. However, different application scenarios and specific needs have different requirements for the key information required.

[0003] At present, there are three common methods for extracting key information from certificates: First, the rule-based extraction method, such as the patent (CN116665224A), extracts key information through regular matching and keyword identification. However, this method has obvious defects. On the one hand, it is difficult to design universal rules, that is, the rules designed for a specific type of certificate are difficult to apply to other types of certificates. On the other hand, for each type of certificate, completely new rules must be redesigned, which consumes a lot of time and effort.

[0004] Secondly, the template matching-based method first needs to build and maintain a template library. When a certificate is input, its category is first determined, and then the corresponding template is found, and the area aligned with the template is regarded as the key information area. However, the generalization ability of the template matching-based method is relatively weak and highly dependent on the type of certificate. In addition, if the certificate image is tilted or rotated in the natural scene, the template often cannot accurately correspond one-to-one, which affects the extraction of key information.

[0005] Third, methods based on supervised learning models, such as the patent (CN115578736A) uses labeled data sets to train information extraction models, and the paper (PICK: Processing Key Information Extraction from Documents using Improved Graph Learning-Convolutional Networks) uses graph convolution to train information extraction models. However, the disadvantage of this method is that a large amount of data needs to be labeled for model training, which not only requires huge manpower and time costs, but also may introduce human errors and deviations in the data labeling process. Summary of the invention

[0006] The purpose of the present invention is to provide a system and method for extracting key information of a certificate based on a large language model to solve at least any one of the problems raised in the above background technology.

[0007] To achieve the above object, the present invention provides the following technical solution: a system and method for extracting key information of a certificate based on a large language model, comprising the following steps: S1. Use OCR technology to obtain text information from document images, including text detection and text recognition; S2. constructing a table of certificate information based on the acquired text information and its position in the image; S3, constructing prompt words containing a small number of sample input-output pairs to guide the large language model to perform few-sample learning; S4. Input the constructed prompt words into the large language model to extract the certificate information.

[0008] Preferably, the text position information obtained by the text detection is represented by four corner point coordinates, which correspond to the upper left corner, upper right corner, lower right corner and lower left corner of the text boundary box respectively.

[0009] Preferably, the text content obtained by the text recognition is in a character string format.

[0010] Preferably, the representation of the certificate information further includes normalizing the text box coordinates, wherein the horizontal coordinate is divided by the image width, and the vertical coordinate is divided by the image height.

[0011] Preferably, the constructed prompt words include at least one sample input-output pair, and at least one sample with only input and no output, to guide the model to predict missing output information.

[0012] Preferably, text coordinate information is added to the prompt word to help the model distinguish information with the same text content but representing different meanings, such as date of birth and expiration date.

[0013] Preferably, the method is applicable to various types of certificates, including but not limited to driver's licenses, identity cards, and passports, and can be applied to open source models such as the Llama series or commercial models such as ChatGPT, GPT-4 and other large language models.

[0014] Preferably, the extracted certificate information includes, but is not limited to, fields such as certificate number, gender, date of birth, nationality, name, address and expiration date, and is expressed in the form of key-value pairs.

[0015] Preferably, it includes an OCR module for obtaining text information from a document image; a data processing module for constructing a representation of the document information and constructing prompt words; a large language model for extracting key information of the document based on the prompt words, and a method for extracting key information of the document based on a large language model as described in any one of claims 1-8.

[0016] The beneficial effects of the present invention are as follows: 1. In the present invention, a large amount of labeled data is not required. This method adopts a few-shot learning strategy based on a large language model. Only a small number of samples, such as only three samples, are required to master the knowledge required for the new task, thereby effectively avoiding the tedious work of labeling a large amount of data and the high cost investment in supervised learning.

[0017] 2. In the present invention, the generalization ability is excellent. The large language model has been trained on massive data and has rich and powerful natural language understanding capabilities. When faced with the need to extract key information on new types of documents, combined with few-shot, it can show excellent generalization performance. This method has been experimented and applied in Indonesia's first-generation ID card, second-generation ID card, and the Philippines' social security card, passport, driver's license, universal ID card (UMID) and ID card, and has successfully achieved satisfactory results.

[0018] 3. The present invention has a wide range of applications. This method is based on a few-shot learning method of a large language model, and can accurately extract key information only by relying on plain text. For this reason, its application field is not limited to certificates, but can also be expanded to any other scenarios that require key information extraction, such as invoices, forms, tickets, etc. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Figure 1 It is a partial flow chart of the information extraction method of the present invention. DETAILED DESCRIPTION

[0020] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0021] The present invention provides Figure 1 The system and method for extracting key information of a certificate based on a large language model include the following steps: S1. Use OCR technology to obtain text information from document images, including text detection and text recognition; S2. constructing a table of certificate information based on the acquired text information and its position in the image; S3, constructing prompt words containing a small number of sample input-output pairs to guide the large language model to perform few-sample learning; S4. Input the constructed prompt words into the large language model to extract the certificate information.

[0022] The text position information obtained by text detection is represented by four corner point coordinates, which correspond to the upper left corner, upper right corner, lower right corner and lower left corner of the text bounding box respectively.

[0023] The text content obtained by text recognition is in string format.

[0024] The representation of the document information further includes normalizing the coordinates of the text box, wherein the horizontal coordinate is divided by the image width and the vertical coordinate is divided by the image height.

[0025] The constructed prompt words include at least one sample input-output pair and at least one sample with only input and no output, which are used to guide the model to predict the missing output information.

[0026] Text coordinate information is added to the prompt words to help the model distinguish between information with the same text content but different meanings, such as date of birth and expiration date.

[0027] This method is applicable to various types of certificates, including but not limited to driver's licenses, ID cards, and passports, and can be applied to open source models such as the Llama series or commercial models such as ChatGPT, GPT-4 and other large language models.

[0028] The extracted document information includes, but is not limited to, fields such as document number, gender, date of birth, nationality, name, address, and expiration date, and is represented in the form of key-value pairs.

[0029] The invention comprises an OCR module for acquiring text information from a document image; a data processing module for constructing a representation of the document information and constructing prompt words; a large language model for extracting key information of the document according to the prompt words, and a method for extracting key information of the document based on a large language model as claimed in any one of claims 1 to 8.

[0030] The specific implementation of the system and method for extracting key information of a certificate based on a large language model of the present invention is as follows: Large language model (LLM) has powerful language understanding ability. This invention is based on large language model and does not specify a certain model or a certain type of model. It can be an open source model, such as Llama2, Llama3. This article takes Llama 3 as an example; it can also be a commercial model, such as ChatGPT, GPT4, etc. The purpose of extracting key information of the certificate is achieved by using the few-shot learning method. The specific steps are as follows: Get the text information of the certificate image. Use OCR technology to get text information from the certificate image, including text detection and text recognition. Text detection obtains the location information of the text, and the text bounding box is represented by the coordinates of the four corner points: , which respectively represent the coordinates of the upper left corner, upper right corner, lower right corner and lower left corner of the text bounding box; text recognition obtains the text content in string format.

[0031] The document information is represented. Let the image height be H and width be W. The text box obtained above is Indicates that From 1 to n, n is the total number of text boxes on the document image, Represents the normalized value of the horizontal and vertical coordinates of a point. The normalization method is to divide the horizontal coordinate by W and the vertical coordinate by H. 1, 2, 3, 4 correspond to the upper left, upper right, lower left, and lower right coordinates of the text box. Represents text content. , then the input of the certificate is "|" is a connection operation, and the output is defined as the key information of the certificate that needs to be extracted. Taking the Philippine driver's license as an example, the key information fields required are such as certificate number, gender, date of birth, nationality, last name, first name, middle name, full name, address, expiration date, etc., which are constructed into a key-value pair and represented by a dictionary. Here is an example of certificate number and gender: , such as "S07-00-12345" and "Male".

[0032] Construct prompt words. Few-shot learning achieves understanding and generalization capabilities on new tasks by giving the model a small number of samples. The given samples include input and output. The samples that need model prediction only provide input and hope that the model predicts output. Assuming the number of samples is N, the prompt words can be obtained from the above and Specifically, let N = 3, then the prompt word Prompt = ''' Input:Input1, Output:Output1 Input:Input2, Output:Output2 Input:Input3, Output: Output3 Input: Input4 Output: ? Give the Output of the last one in json format. ''', where Input4 is the input that you want the model to predict. Adding text coordinates to the prompt word can effectively avoid ambiguity. For example, for the same date, it is impossible to determine which is the date of birth and which is the expiration date based solely on the text content. The model can identify them through the provided text box coordinates.

[0033] Extract key information. By inputting the above-constructed prompt words into the large language model, we can get the same key-value pair results as the output, which are the key information of the certificate. For different certificates, we only need to construct a small number of prompt words.

[0034] This method is based on the Python programming language: S1. First, deploy a large language model, provide an API (application programming interface), accept text prompt word input, and return text format or key-value pair JSON format content; S2. Use text detection and text recognition models to detect and recognize the documents to be used for extracting key information, and construct them into the above-mentioned input format; S3. The prompt word text in the above format can be provided in advance for each certificate, and only the input to be predicted is retained as a variable, and the user can provide it through the API; it is also possible not to provide the prompt word in advance. In order to be compatible with new types of certificates, the entire prompt word can also be provided through the API; S4, the model accepts the constructed prompt word input and returns the result; S5. The parsing result is in JSON format, which is the key information of the certificate.

[0035] Finally, it should be noted that the above are only preferred embodiments of the present invention and are not intended to limit the present invention. Although the present invention has been described in detail with reference to the aforementioned embodiments, it is still possible for those skilled in the art to modify the technical solutions described in the aforementioned embodiments, or to make equivalent substitutions for some of the technical features therein. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the protection scope of the present invention.

Claims

1. Method for extracting key information from certificates based on large language model, Features: The following steps are involved: S1. Use OCR technology to obtain text information from document images, including text detection and text recognition; S2. constructing a table of certificate information based on the acquired text information and its position in the image; S3, constructing prompt words containing a small number of sample input-output pairs to guide the large language model to perform few-sample learning; S4. Input the constructed prompt words into the large language model to extract the certificate information.

2. According to the method for extracting key information of a certificate based on a large language model according to claim 1, Features: The text position information obtained by the text detection is represented by four corner point coordinates, which correspond to the upper left corner, upper right corner, lower right corner and lower left corner of the text boundary box respectively.

3. According to the method for extracting key information of a certificate based on a large language model as described in claim 1, Features: The text content obtained by the text recognition is in a character string format.

4. The method for extracting key information of a certificate based on a large language model according to claim 1, Features: The representation of the document information further includes normalizing the text box coordinates, wherein the horizontal coordinate is divided by the image width and the vertical coordinate is divided by the image height.

5. According to the method for extracting key information of a certificate based on a large language model as claimed in claim 1, Features: The constructed prompt words include at least one sample input-output pair and at least one sample with only input and no output, which are used to guide the model to predict the missing output information.

6. The method for extracting key information of a certificate based on a large language model according to claim 1, Features: The text coordinate information is added to the prompt word to help the model distinguish information with the same text content but representing different meanings, such as date of birth and expiration date.

7. The method for extracting key information of a certificate based on a large language model according to claim 1, Features: This method is applicable to various types of certificates, including but not limited to driver's licenses, ID cards, and passports, and can be applied to open source models such as the Llama series or commercial models such as ChatGPT, GPT-4 and other large language models.

8. The method for extracting key information of a certificate based on a large language model according to claim 1, Features: The extracted certificate information includes, but is not limited to, fields such as certificate number, gender, date of birth, nationality, name, address and expiration date, and is expressed in the form of key-value pairs.

9. Certificate key information extraction system based on large language model, Features: The invention comprises an OCR module for obtaining text information from a document image; a data processing module for constructing a representation of the document information and constructing prompt words; a large language model for extracting key information of the document according to the prompt words, and a method for extracting key information of the document based on a large language model as described in any one of claims 1 to 8.

Citation Information

Patent Citations

  • Document visual language reasoning method based on layout perception prompt

    CN116822634A

  • Information extraction method, training method of information extraction system, and information extraction system

    CN117079298A

  • Risk prediction method and device, equipment and storage medium

    CN117764373A

  • OCR key information extraction method and model for medical bills

    CN117831043A

  • Image information extraction method and system based on cross-modal large model, and storage medium

    CN117854082A

Cited By

  • Receipt identification method, apparatus and device, and medium

    CN119418350A

  • A Method for Constructing a Jewelry Valuation Knowledge Base Based on a Large Language Model

    CN120562536B