Method, device and electronic device for automatically extracting structured image content

The structured information extraction model guided by OCR processing and prompt words solves the problem of traditional methods relying on annotated data, improves the efficiency and generalization ability of structured processing of image content, and achieves applicability and flexibility for cross-domain tasks.

CN118397645BActive Publication Date: 2024-10-18SHANGHAI AISHA MEDICAL TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202410832584.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-26
Publication Date
2024-10-18
Estimated Expiration
2044-06-26

AI Technical Summary

Technical Problem

Traditional image content structured processing methods rely on a large amount of annotated data, are inefficient, and have poor generalization capabilities and scalability in cross-domain tasks.

Method used

By obtaining the target image for OCR processing, the text information is standardized, and the prompt words are used to guide the structured information extraction model to extract structured information from the standardized text information, reducing the dependence on annotated data and improving the generalization ability and applicability of the model.

Benefits of technology

It reduces the cost and time of manual annotation, improves the applicability and flexibility of the model, so that it not only performs well in specific fields, but also adapts to new or cross-domain tasks, reducing model development and deployment time.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118397645B_ABST
    Figure CN118397645B_ABST
Patent Text Reader

Abstract

The present application discloses a method, device and electronic device for automatic structured extraction of image content, which belongs to the field of image data processing, wherein the method for automatic structured extraction of image content includes: obtaining a target image; performing OCR processing on the target image to obtain text information in the target image; performing standardization processing on the text information to obtain standardized text information; identifying the information field of the standardized text information; determining prompt words according to the information field, and using the prompt words to guide the information structured extraction model to extract structured information from the standardized text information. Prompt words can reduce the dependence on a large amount of annotated data, which means that the cost and time of manual annotation can be reduced, thereby reducing the overall project cost and speeding up the development and deployment of the model. In addition, prompt words can enhance the generalization ability of the model, so that it not only performs well in a specific field, but also can adapt to new or cross-domain tasks, thereby improving the applicability and flexibility of the model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the technical field of image data processing, and specifically relates to a method, device and electronic device for automatic structured extraction of image content. Background Art

[0002] In the wave of digital transformation, the explosive growth of image data has put forward higher requirements for automated image processing technology.

[0003] Traditional image content structured processing methods, such as OCR+BERT models, usually rely on a large amount of labeled data, which is not only inefficient but also increases labor costs. In addition, these methods often have poor generalization and scalability when dealing with cross-domain tasks. Summary of the invention

[0004] The purpose of this application is to provide a method, device and electronic device for automatic structured extraction of image content to improve the efficiency of image content structured processing and enhance generalization ability and scalability.

[0005] According to a first aspect of an embodiment of the present application, a method for automatically extracting structured content from an image is provided. The method may include:

[0006] Get the target image;

[0007] Perform OCR processing on the target image to obtain the text information in the target image;

[0008] Performing standardization processing on the text information to obtain standardized text information;

[0009] Identify information fields for standardized text messages;

[0010] The prompt words are determined according to the information domain, and the prompt words are used to guide the information structured extraction model to extract structured information from the standardized text information.

[0011] In some optional embodiments of the present application, obtaining a target image includes:

[0012] Detect the network bandwidth of the transmission network;

[0013] Adjust the image quality of the target image according to the network bandwidth;

[0014] Get the target image through the transmission network.

[0015] In some optional embodiments of the present application, performing OCR processing on the target image to obtain text information in the target image includes:

[0016] Perform denoising, contrast adjustment and binarization on the target image to obtain the image to be identified;

[0017] Use the trained text recognition model to identify the image to be identified and obtain the text information in the target image. The text recognition model is obtained through transfer learning training.

[0018] In some optional embodiments of the present application, the text information is standardized to obtain standardized text information, including:

[0019] Remove useless symbols from text messages;

[0020] Correcting incorrect information in text messages;

[0021] Standardize punctuation format in text messages.

[0022] In some optional embodiments of the present application, the prompt word is extracted by the following method:

[0023] Determine the information domain of the text message;

[0024] According to the information domain, key information is extracted from the text information using a keyword extraction model to obtain prompt words.

[0025] In some optional embodiments of the present application, after extracting key information from text information according to the information field and using a keyword extraction model to obtain prompt words, the method further includes:

[0026] Using prompt words to guide the information structured extraction model to extract structured information from standardized text information;

[0027] Use structured feedback to adjust key messages.

[0028] In some optional embodiments of the present application, the structured extraction model is obtained by training the ChatGLM-6B model and fine-tuning the LoRA.

[0029] According to a second aspect of an embodiment of the present application, a device for automatically extracting structured content from an image is provided, and the device may include:

[0030] Acquisition module, used to acquire the target image;

[0031] The OCR processing module is used to perform OCR processing on the target image to obtain the text information in the target image;

[0032] A text processing module is used to perform standardization processing on text information to obtain standardized text information;

[0033] A prompt word design module is used to identify the information field of standardized text information;

[0034] The large model extraction module is used to determine prompt words according to the information field, and use the prompt words to guide the information structured extraction model to extract structured information from standardized text information.

[0035] According to a third aspect of an embodiment of the present application, an electronic device is provided, which may include:

[0036] processor;

[0037] a memory for storing processor-executable instructions;

[0038] The processor is configured to execute instructions to implement the method for automatic structured extraction of image content as shown in any one of the embodiments of the first aspect.

[0039] According to the fourth aspect of the embodiments of the present application, a storage medium is provided. When the instructions in the storage medium are executed by a processor of an information processing device or a server, the information processing device or the server implements the method for automatic structured extraction of image content as shown in any one of the embodiments of the first aspect.

[0040] The above technical solution of the present application has the following beneficial technical effects:

[0041] The method of the embodiment of the present application extracts structured information from standardized text information by using prompt words to guide the information structured extraction model. It can reduce the dependence on a large amount of annotated data, which means that the cost and time of manual annotation can be reduced, thereby reducing the overall project cost and speeding up the development and deployment of the model. In addition, the prompt words can enhance the generalization ability of the model, so that it not only performs well in a specific field, but also can adapt to new or cross-domain tasks, thereby improving the applicability and flexibility of the model. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] FIG1 is a schematic diagram of a process of an automatic structured extraction method for image content in an exemplary embodiment of the present application;

[0043] FIG2 is a schematic diagram of the structure of a device for automatically extracting structured image content in an exemplary embodiment of the present application;

[0044] FIG3 is a schematic diagram of the structure of a device for automatically extracting structured image content in a specific embodiment of the present application;

[0045] FIG4 is a schematic diagram of the structure of an electronic device in an exemplary embodiment of the present application;

[0046] FIG. 5 is a schematic diagram of the hardware structure of an electronic device in an exemplary embodiment of the present application. DETAILED DESCRIPTION

[0047] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application is further described in detail below in conjunction with specific implementations and with reference to the accompanying drawings. It should be understood that these descriptions are only exemplary and are not intended to limit the scope of the present application. In addition, in the following description, the description of known structures and technologies is omitted to avoid unnecessary confusion of the concepts of the present application.

[0048] The accompanying drawings show schematic diagrams of layer structures according to embodiments of the present application. These figures are not drawn to scale, and some details are magnified and some details may be omitted for the purpose of clarity. The shapes of various regions and layers shown in the figures and the relative sizes and positional relationships therebetween are only exemplary, and may deviate in practice due to manufacturing tolerances or technical limitations, and those skilled in the art may additionally design regions / layers with different shapes, sizes, and relative positions according to actual needs.

[0049] Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present application.

[0050] In the description of the present application, it should be noted that the terms "first", "second" and "third" are only used for descriptive purposes and cannot be understood as indicating or implying relative importance.

[0051] In addition, the technical features involved in the different embodiments of the present application described below can be combined with each other as long as they do not conflict with each other.

[0052] The following, in conjunction with the accompanying drawings, describes in detail the method, device and electronic device for automatic structured extraction of image content provided by the embodiments of the present application through specific embodiments and their application scenarios.

[0053] like Figure 1 As shown, in a first aspect of an embodiment of the present application, a method for automatically extracting structured content from an image is provided, and the method may include:

[0054] S110: Acquire a target image;

[0055] S120: Perform OCR processing on the target image to obtain text information in the target image;

[0056] S130: Standardizing the text information to obtain standardized text information;

[0057] S140: Identify the information field of the standardized text information;

[0058] S150: Determine prompt words according to the information domain, and use the prompt words to guide the information structured extraction model to extract structured information from the standardized text information.

[0059] The method of this embodiment extracts structured information from standardized text information by using prompt words to guide the information structured extraction model. It can reduce the dependence on a large amount of labeled data, which means that the cost and time of manual annotation can be reduced, thereby reducing the overall project cost and speeding up the development and deployment of the model. In addition, prompt words can enhance the generalization ability of the model, so that it not only performs well in a specific field, but also can adapt to new or cross-domain tasks, thereby improving the applicability and flexibility of the model.

[0060] In some embodiments, obtaining a target image includes:

[0061] Detect the network bandwidth of the transmission network;

[0062] Adjust the image quality of the target image according to the network bandwidth;

[0063] Get the target image through the transmission network.

[0064] In this embodiment, the target image is the image data uploaded by the user through a friendly web interface or desktop application. The interface provides intuitive drag-and-drop functions, image previews, and basic image editing tools such as cropping and rotation. In the process of acquiring the target image, adaptive compression technology is used to dynamically adjust the image quality according to the user's network bandwidth to ensure fast upload while maintaining sufficient image details for subsequent processing. After the image acquisition is completed, clear confirmation information and image preview can be provided.

[0065] The network bandwidth of the transmission network can be detected by the following methods:

[0066] Perform periodic network bandwidth detection, send a small data packet (for example, 1 KB) to the server at a fixed interval (for example, 5 seconds), and measure the round-trip time.

[0067] Calculation formula:

[0068]

[0069] in, B is the bandwidth (bits / second); S is the packet size (bytes); T is the round trip time in seconds.

[0070] Averaging: Multiple measurements of bandwidth are smoothed using an exponential moving average (EMA) to obtain a more stable bandwidth estimate.

[0071]

[0072] in, a is the smoothing factor; usually the value is 0.2; B ema is the smoothed bandwidth value, that is, a more stable bandwidth estimate calculated by the EMA formula; B current The currently measured bandwidth value is the instantaneous bandwidth value calculated based on the currently measured data packet size and round-trip time; B previous is the previous smoothed bandwidth value, that is, the bandwidth value calculated by the EMA formula last time, which is used to perform weighted averaging with the currently measured bandwidth value. Specifically, a small data packet (for example, 1 KB) can be sent to the server at regular intervals (for example, 5 seconds), and the time from sending to receiving the data packet (round-trip time) can be recorded. According to the formula , calculate the current instant bandwidth value B current ; Use the above formula to smooth multiple instantaneous bandwidth values ​​to obtain a more stable bandwidth estimate B ema .

[0073] The specific implementation process of adjusting the image quality of the target image according to the network bandwidth can calculate the quality factor (compression ratio) of JPEG compression based on the real-time bandwidth data.

[0074] The calculation formula of compression quality factor is:

[0075]

[0076] in, Q Compression quality factor, which indicates the compression quality of the JPEG image. The value range is usually between 0 and 100. The higher the value, the higher the image quality and the larger the file size. B is the real-time bandwidth (Mbps), that is, the bandwidth value of the current network; Q max High quality compression factor, the JPEG compression quality factor used in high bandwidth situations, for example, set to 90; Q min is a low quality compression factor, which is the JPEG compression quality factor used in low bandwidth situations, for example, set to 30; B max is the high bandwidth threshold, for example, set to 10 Mbps; B min is the low bandwidth threshold, for example, set it to 1 Mbps.

[0077] Through the above formula, the compression quality factor of the JPEG image can be dynamically adjusted according to the real-time bandwidth. When the bandwidth is high, a higher compression quality factor is used to ensure image quality; when the bandwidth is low, a lower compression quality factor is used to reduce file size and transmission time. This dynamic adjustment helps to optimize image transmission efficiency and image quality under different network conditions.

[0078] Specifically, the parameter definition: Q max =90 (high quality); Q max =30 (low quality); B max =10 Mbps (high bandwidth threshold); B min =1 Mbps (low bandwidth threshold).

[0079] Apply JPEG compression to compress the image according to the calculated compression ratio. Specifically, an image processing library (such as Pillow in Python) can be used to apply JPEG compression to the acquired image.

[0080] In some embodiments, performing OCR processing on the target image to obtain text information in the target image includes:

[0081] Perform denoising, contrast adjustment and binarization on the target image to obtain the image to be identified;

[0082] Use the trained text recognition model to identify the image to be identified and obtain the text information in the target image. The text recognition model is obtained through transfer learning training.

[0083] In this embodiment, image denoising, contrast adjustment, and binarization are performed to improve the accuracy of text recognition. In addition, the text recognition model can be a model that applies a deep learning algorithm and combines CNN+RNN. Specifically, a large number of labeled image data sets can be used for supervised learning to train CNN and RNN models to recognize different types of text. Transfer learning is applied, and a CNN model pre-trained on a large data set (such as ImageNet) is used as a feature extractor to accelerate model training and improve accuracy. During fine-tuning, techniques such as learning rate decay and early stopping are used to prevent overfitting and ensure the generalization ability of the model.

[0084] Steps to apply transfer learning can include:

[0085] 1. Choose a pre-trained model

[0086] CNN models pre-trained on large datasets (such as ImageNet) are often used for transfer learning. Selecting a pre-trained model suitable for a new task is the first step.

[0087] 2. Load the pre-trained model

[0088] Load the pre-trained model and freeze its convolutional layers. These convolutional layers have learned low-level image features such as edges, textures, etc., which are common in many vision tasks.

[0089] 3. Remove and add layers

[0090] Remove the last few layers of the pre-trained model and add layers appropriate for the new task, such as new fully connected layers or classification layers.

[0091] 4. Training new layers

[0092] Only the newly added layers are trained while keeping the convolutional layer weights of the pre-trained model unchanged. This step is usually called the feature extraction phase.

[0093] 5. Fine-tune the model

[0094] After completing the training of the new layer, you can unfreeze some of the convolutional layers of the pre-trained model and fine-tune the entire model using a lower learning rate. The purpose of the fine-tuning phase is to further adjust the features of the pre-trained model to better suit the new task.

[0095] Using a pre-trained CNN model as a feature extractor can speed up model training because the pre-trained model has learned rich features on a large-scale dataset and can directly use these features in new tasks, reducing the need for large-scale new data. In the feature extraction stage, only a small number of new layers need to be trained, rather than training the entire model from scratch, which greatly shortens the training time. Pre-trained models usually have higher initial performance on new tasks, which speeds up the convergence of the model and improves initial performance.

[0096] Learning rate decay refers to gradually reducing the learning rate during training to ensure training stability and prevent overfitting. Learning rate decay during fine-tuning, specific measures: multiply the learning rate by a constant factor every certain number of training steps and rounds. In practice: multiply the learning rate by 0.1 every 10 epochs.

[0097] Early Stopping is a technique to prevent overfitting. It monitors the performance of the validation set and stops training early when the validation set performance stops improving. The specific process of early stopping in fine-tuning is: define a tolerance, which is the maximum number of times the validation set performance does not improve within a certain number of rounds. Practical operation: If the validation set loss does not improve within 5 consecutive epochs, stop training.

[0098] Although traditional image preprocessing methods such as denoising, contrast adjustment and binarization are effective, they are limited in effect when faced with complex backgrounds, different lighting conditions and various noise interferences. To this end, in another specific embodiment, some innovative improvement methods can be used to combine deep learning and adaptive algorithms to improve the effect of image preprocessing, thereby improving the accuracy of text recognition. Use U-Net model for denoising.

[0099] Combined with the U-Net model, the image is divided into text area and background area, and different denoising strategies are applied to different areas.

[0100] Region recognition: Use the pre-trained U-Net model to segment the image and identify the text area and background area.

[0101] The Net model inputs the original image and outputs a binary mask where white represents the text area and black represents the background area.

[0102] Text area: Apply a Gaussian bilateral filter to remove noise while keeping the text edges clear.

[0103] Background area: Apply median filter to effectively remove background noise. Median filter: For each pixel, take the median value of its neighboring pixel values ​​to replace the current pixel value.

[0104] Deep learning enhanced binarization processing uses a small convolutional neural network (CNN) to predict the optimal binarization threshold for different areas of the image, and performs image binarization according to the threshold predicted by CNN to adapt to uneven lighting and complex backgrounds.

[0105] The image is divided into small blocks (32x32 pixels) and input into the pre-trained CNN model to predict the optimal binarization threshold for each small block.

[0106] CNN model structure:

[0107] Input layer: 32x32 pixel image patches.

[0108] Convolutional layer: extract local features.

[0109] Fully connected layer: outputs the optimal threshold of the block.

[0110] Each small block is binarized according to the predicted threshold.

[0111] Local binarization formula:

[0112]

[0113] in,I ( x,y ) is the pixel value of the original image block, at coordinate ( x,y ) The original grayscale value at. This value represents the brightness of each pixel in the original image, usually between 0 and 255, 0 represents black and 255 represents white; I binary ( x,y ) is the pixel value of the image block after binarization, at coordinate ( x,y ) is the pixel value after binarization. This value can only be 0 or 1 after binarization. 0 usually represents black and 1 represents white. Binarization is to convert the original grayscale image into an image containing only black and white. is the local threshold predicted by CNN, for the first ( x,y ) image patches (32x32 pixel patches), the optimal binarization threshold predicted by the CNN model, which determines whether each pixel in the image patch is classified as 0 (black) or 1 (white).

[0114] The above formula is used to predict the threshold value according to the CNN model T ( x,y ), perform binary processing on the image block. If the gray value of a pixel I ( x,y ) is less than or equal to the predicted threshold , then the pixel is set to 0 (black). I ( x,y ) is greater than the predicted threshold , then the pixel is set to 1 (white).

[0115] Merge image: Merge the binarization results of all small blocks to generate a complete binary image.

[0116] Through the above embodiments, the OCR processing process can more effectively process images under complex backgrounds and different lighting conditions, and significantly improve the accuracy and robustness of text recognition.

[0117] In some embodiments, the text information is standardized to obtain standardized text information, including:

[0118] Remove useless symbols from text messages;

[0119] Correcting incorrect information in text messages;

[0120] Standardize punctuation format in text messages.

[0121] Specifically, remove meaningless symbols, correct OCR errors, unify punctuation formats, etc. Apply regular expressions to match and delete non-printing characters, extra spaces, vertically misaligned punctuation marks, etc. in the text, and use character set filtering rules to remove or replace errors or unusual characters that may be generated during the OCR process. Correct common OCR errors (such as mistaking "0" (zero) for "O" (letter O)).

[0122] For example, a sequence-to-sequence (Seq2Seq) model is trained to correct OCR errors and combined with a rule-based replacement method. The entire process can be divided into the following main steps:

[0123] Step 1: Data collection and preprocessing

[0124] Objective: Collect OCR-scanned Chinese documents and their correct text versions to build a dataset.

[0125] Input: OCR scanned Chinese document text.

[0126] Output: Cleaned and annotated text dataset.

[0127] Example: OCR error text: "Hippo is very happy", correct text: "Hippo is very happy".

[0128] Step 2: Feature Engineering

[0129] Objective: Extract text features and prepare data for model training.

[0130] Input: Cleaned and annotated text dataset.

[0131] Output: featurized text data sentence vector.

[0132] Algorithm: BERT.

[0133] Step 4: Build a Seq2Seq model

[0134] Objective: Design a Seq2Seq model for learning text correction.

[0135] Algorithm: Transformer.

[0136] Example: Using the Transformer model, the input sequence is: "But the horse can be very happy", and the target sequence is: "The hippo is very happy".

[0137] Step 5: Model training

[0138] Objective: Train a Seq2Seq model to correct OCR errors.

[0139] Input: featurized text data and target sequence.

[0140] Output: The trained model.

[0141] algorithm:

[0142] Model architecture: Encoder-Decoder architecture.

[0143] Optimizer: Adam.

[0144] Loss function: cross entropy loss.

[0145] Evaluation metric: BLEU score.

[0146] Detailed steps:

[0147] Data preprocessing: Convert text into a format acceptable to the model, token IDs.

[0148] Data Splitting: Split the dataset into training, validation, and test sets.

[0149] Model initialization: Initialize model parameters using random weights.

[0150] Training loop:

[0151] Iterate for each epoch.

[0152] Perform multiple batches of forward propagation and loss calculation on the training set.

[0153] Perform backpropagation and calculate gradients.

[0154] Use the optimizer to update the model parameters.

[0155] Validation and testing: Evaluate model performance on the validation set and select the best model.

[0156] Hyperparameter adjustment: Adjust the learning rate and batch size based on the validation set results.

[0157] Step 6: Integrate rules and models

[0158] Objective: Integrate the rule engine with the Seq2Seq model to improve correction accuracy.

[0159] Input: OCR output text.

[0160] Output: The text corrected by the rules and the model.

[0161] Example: Apply rules first to correct common errors, then refine the model to correct the results.

[0162] In some embodiments, the prompt words are extracted by the following method:

[0163] Determine the information domain of the text message;

[0164] According to the information domain, key information is extracted from the text information using a keyword extraction model to obtain prompt words.

[0165] The design of prompt words can gather the wisdom of experts in multiple fields such as medicine, government affairs, finance, and e-commerce. The prompt word library is carefully selected and manually organized, covering professional terms and common expressions in each field. These prompt words are not selected randomly, but are summarized by field experts based on rich industry knowledge and experience based on the analysis of actual cases and a large amount of text data.

[0166] In some embodiments, a prompt word optimization method is also designed for prompt words, the main purpose of which is to guide the large language model (chatgltm-6b) to complete specific tasks efficiently and accurately by designing and adjusting prompt words. In the task of extracting text entities, it helps to extract key information of concern from complex texts.

[0167] The prompt word optimization process includes:

[0168] Clarify the task objectives: determine the entity types or key information that need to be extracted.

[0169] Design initial prompt words: Design initial prompt words based on task objectives.

[0170] Debug and optimize prompt words: Improve the quality of the model's answers by continuously adjusting and optimizing prompt words.

[0171] Feedback adjustment: Feedback adjustment is performed based on the output of the model to gradually improve the prompt words.

[0172] Application of domain knowledge: Combine knowledge from specific fields to design prompts that better meet actual needs.

[0173] 1. Clarify the mission objectives

[0174] First, it is necessary to clarify what key information needs to be extracted from the text. For example, in a government text, the following information may need to be extracted:

[0175] date

[0176] Place

[0177] File name

[0178] Main content

[0179] Person in charge (name)

[0180] Relevant departments

[0181] 2. Design the initial prompt words

[0182] Please extract key information from the following government documents, including date, location, document name, main content, person in charge and relevant departments:

[0183] One day, a certain place issued "XXXX", proposing a number of new measures. The person in charge emphasized that all departments should work closely together.

[0184] 3. Debugging and optimization tips

[0185] Through preliminary testing, observe the model's response and make refinements as needed. For example, the initial cue words may not fully extract all the key information.

[0186] Please extract key information from the following government texts in detail and list the results separately:

[0187] 1) Date

[0188] 2) Location

[0189] 3) File name

[0190] 4) Main content

[0191] 5) Person in charge (name)

[0192] 6) Relevant departments

[0193] Text: On a certain day, a certain place issued "XXXX", proposing a number of new measures. The person in charge emphasized that all departments should work closely together.

[0194] 4. Feedback Adjustment

[0195] Based on the optimized model response, the prompt words can be further adjusted. For example, if the model has errors or omissions when extracting certain information, the prompt words can be improved by adding specific examples or adjusting the expression.

[0196] 5. Application of Domain Knowledge

[0197] Combining professional knowledge in the government affairs field, we can design prompt words that better meet actual needs. For example, understanding common government document formats and terminology can help extract key information more accurately.

[0198] Through continuous testing and feedback adjustment, the prompt words are dynamically optimized to improve the accuracy and efficiency of the model. According to different task requirements, the prompt words are customized to enable the model to adapt to various complex scenarios and specific fields. Users do not need to have a deep technical background, and can guide the model to complete complex information extraction tasks through simple prompt word design and adjustment. Compared with traditional methods, the prompt word optimization module can significantly improve the efficiency and accuracy of information extraction and reduce manual intervention and complex preprocessing steps.

[0199] The prompt words in each field have undergone a rigorous screening and optimization process, and have been verified and adjusted through actual text extraction tests. The extracted prompt words in the medical field include disease names, drug names, treatment methods, etc.; the government affairs field may cover keywords such as laws and regulations, policy clauses, and administrative procedures; the financial field will focus on terms such as stock codes, financial products, and market trends; the e-commerce field may include product names, prices, promotions, and other related information.

[0200] The prompt word library is not only static, it can also be dynamically updated. Regular maintenance and expansion of the prompt word library ensures the accuracy and efficiency of the system when processing texts in different fields, providing users with highly professional and customized services.

[0201] In some embodiments, after extracting key information from text information according to the information domain and using a keyword extraction model to obtain prompt words, the method further includes:

[0202] Using prompt words to guide the information structured extraction model to extract structured information from standardized text information;

[0203] Use structured feedback to adjust key messages.

[0204] Specifically, we rely on the pre-trained ChatGLM-6B language model and carefully designed prompt words to handle text information extraction tasks in most scenarios. When faced with complex scenarios or scenarios with special requirements for accuracy, we can adopt a customized fine-tuning method to adjust the model parameters in detail to meet specific needs. This approach ensures the applicability of the model in a wide range of scenarios while providing sufficient flexibility and accuracy for special needs. Through this strategy, we can achieve more accurate information extraction for complex scenarios while maintaining high efficiency.

[0205] In some embodiments, the structured extraction model is obtained by training the ChatGLM-6B model and fine-tuning with LoRA.

[0206] Specifically, the information structured extraction model training process may include:

[0207] 1. Data preparation

[0208] First, you need to prepare a dataset for training and testing. Each piece of data consists of two parts: the user's input text (context) and the expected output result (target). This data will be used for model training in the fine-tuning phase. For example, for a medical information extraction task, the data may contain annotations of symptoms, diseases, and other information in medical articles.

[0209] 2. Set parameters

[0210] A number of parameters are set for the training process, including:

[0211] Use LoRA technology: Choose to use LoRA (Low-Rank Adaptation) technology, which is an efficient fine-tuning method.

[0212] LoRA rank: Set the LoRA rank to 8. This parameter determines the degree of low-rank approximation.

[0213] Batch size: Setting the batch size to 1 means processing only one piece of training data at a time.

[0214] Training rounds: Set the training process to run for 50 rounds (epochs).

[0215] Learning rate: Set the learning rate to 3e-5 to control the pace of model parameter updates.

[0216] Logging frequency: Training logs are recorded every 100 steps, including information such as training loss and accuracy.

[0217] 3. Model training

[0218] Using the prepared dataset and set parameters, start the training process:

[0219] Load data: Load training set and test set data from the specified path.

[0220] Initialize model: Initialize the pre-trained ChatGLM-6B model and apply LoRA technology.

[0221] Start training: During the training process, the model will continuously adjust its internal parameters to better adapt to the information extraction tasks in a specific field.

[0222] Save checkpoints: Periodically save the current state of the model (checkpoints) so that after training is complete, the best performing model can be selected for deployment.

[0223] Record logs: Record detailed log information during training to help monitor training progress and results.

[0224] 4. Log Analysis

[0225] During the training process, the training loss, accuracy and other indicators are recorded in detail every 100 steps. These log information helps to analyze the training progress of the model, identify possible problems, and make adjustments as needed.

[0226] 5. End of training

[0227] After training is completed, the model's performance on the test set will be evaluated, and the best model version will be selected for deployment. This version of the model has been fine-tuned and performs well on information extraction tasks in a specific field.

[0228] In addition, users can evaluate the extraction results and provide feedback. This feedback is collected to analyze common error types and changes in user requirements. This information is used to adjust and optimize the prompt word design, model parameters, and preprocessing strategies to continuously improve the overall performance of the system.

[0229] It should be noted that the execution subject of the method for automatic structured extraction of image content provided in the embodiment of the present application may be an automatic structured extraction device for image content, or a control module in the automatic structured extraction device for image content that is used to execute the method for automatic structured extraction of image content. In the embodiment of the present application, the method for automatic structured extraction of image content performed by the automatic structured extraction device for image content is taken as an example to illustrate the device for automatic structured extraction of image content provided in the embodiment of the present application.

[0230] like Figure 2 As shown, in a second aspect of the embodiment of the present application, a device for automatically extracting structured content from a picture is provided, and the device may include:

[0231] An acquisition module 210 is used to acquire a target image;

[0232] The OCR processing module 220 is used to perform OCR processing on the target image to obtain text information in the target image;

[0233] The text processing module 230 is used to perform standardization processing on the text information to obtain standardized text information;

[0234] The prompt word design module 240 is used to identify the information field of the standardized text information;

[0235] The large model extraction module 250 is used to determine prompt words according to the information field, and use the prompt words to guide the information structured extraction model to extract structured information from the standardized text information.

[0236] Specifically, Figure 3As shown in the figure, the device introduces a closed-loop feedback mechanism to fine-tune the system through user feedback, continuously optimizing the accuracy and efficiency of structured extraction of image content. The following is a detailed description of each module and the feedback fine-tuning process:

[0237] Image upload module

[0238] Detailed description: Users upload image data through a friendly web interface or desktop application. The interface provides intuitive drag-and-drop functionality, image preview, and basic image editing tools such as cropping and rotating. During the upload process, the device uses adaptive compression technology to dynamically adjust the image quality according to the user's network bandwidth to ensure fast upload while maintaining sufficient image details for subsequent processing. After the upload is completed, the device provides a clear confirmation message and image preview.

[0239] OCR Processing Module

[0240] Detailed description: The OCR processing module on the server side first receives the uploaded image file and performs a series of preprocessing operations, which may include image denoising, contrast adjustment, binarization, etc., to improve the accuracy of text recognition. Then, a deep learning algorithm is applied, combined with the CNN+RNN model, to recognize the text in the image. A large number of labeled image data sets are used for supervised learning to train CNN and RNN models to recognize different types of text. Transfer learning is applied to use CNN models pre-trained on large data sets (such as ImageNet) as feature extractors to accelerate model training and improve accuracy. During fine-tuning, techniques such as learning rate decay and early stopping are used to prevent overfitting and ensure the generalization ability of the model.

[0241] Text preprocessing module

[0242] Detailed description: The text preprocessing module receives the text output by the OCR module and performs a multi-step cleaning and standardization process. This includes removing meaningless symbols, correcting OCR errors, and unifying punctuation formats. Regular expressions are applied to match and delete non-printing characters, extra spaces, vertically misaligned punctuation marks, etc. in the text, and character set filtering rules are used to remove or replace errors or unusual characters that may be generated during the OCR process. Common OCR errors (such as mistaking "0" (zero) for "O" (letter O)) are corrected.

[0243] Prompt word design module

[0244] Detailed description: The prompt word design module is the core of this system, which brings together the wisdom of experts in multiple fields such as medicine, government affairs, finance, and e-commerce. The prompt word library of this module is carefully selected and manually organized, covering professional terms and common expressions in each field. These prompt words are not selected randomly, but are summarized by field experts based on rich industry knowledge and experience based on the analysis of actual cases and a large amount of text data.

[0245] Large model extraction module

[0246] Detailed description: The large model extraction module mainly relies on the pre-trained ChatGLM-6B-6B language model and carefully designed prompt words to cope with text information extraction tasks in most scenarios. When faced with complex scenarios or scenarios with special requirements for accuracy, a customized fine-tuning method is adopted to adjust the model parameters in detail to meet specific needs. This approach ensures the applicability of the model in a wide range of scenarios while providing sufficient flexibility and accuracy for special needs. Through this strategy, more accurate information extraction can be achieved for complex scenarios while maintaining high efficiency.

[0247] Fine-tuning steps:

[0248] Dataset preparation:

[0249] Collect and organize annotated data in specific fields, which will be used for model training in the fine-tuning phase. Each piece of data is divided into two parts: context and target:

[0250] The context part is used to accept user input. The target part is used to specify the output of the model.

[0251] Sample input and output:

[0252] {

[0253] "context": "You are a professional medical information extraction expert, good at using advanced artificial intelligence technology and natural language processing (refer to the prompt words above)......The text content is: People with urinary retention are prone to secondary urinary tract infection.",

[0254] "target": "```json\n[ { "entity": "Urinary retention",type": "dis"},{ "entity": "Urinary tract infection","type": "dis"} ]\n```"

[0255] }

[0256] Model training:

[0257] # LoRA Finetune

[0258] python train.py \

[0259] --train_path data / training set\

[0260] --dev_path data / test_set\

[0261] --use_lora True \

[0262] --lora_rank 8 \

[0263] --batch_size 1 \

[0264] --num_train_epochs 50 \

[0265] --save_freq 1000 \

[0266] --learning_rate 3e-5 \

[0267] --logging_steps 100 \

[0268] --max_source_seq_len 400 \

[0269] --max_target_seq_len 300 \

[0270] --save_dir checkpoints / finetune \

[0271] --img_log_dir "log / fintune_log" \

[0272] --img_log_name "ChatGLM Fine-Tune" \

[0273] --device cuda:0

[0274] Data output module

[0275] Detailed description: The data output module is responsible for converting the extracted structured information into a user-readable and actionable format. The module supports multiple data output formats, such as JSON, Markdown, CSV, etc., to meet the needs of different users. In addition, the module also includes data validation and cleaning processes to ensure the accuracy and consistency of the output information. Users can download structured data through the web interface or integrate the data into other applications through the API interface.

[0276] User feedback module

[0277] Detailed description: The user feedback module is a key part of the closed-loop feedback mechanism. Users can evaluate the extraction results and provide feedback through the interface. The device collects this feedback and analyzes common error types and changes in user needs. This information is used to adjust and optimize the prompt word design, model parameters, and preprocessing strategies to continuously improve the overall performance of the device.

[0278] System optimization module

[0279] Detailed description: The system optimization module adjusts the system configuration automatically or under the guidance of experts based on user feedback and system performance monitoring data. This may include updating the optimization prompt word set, adjusting the fine-tuning parameters of the large model, etc. The system optimization module ensures that the technical solution can adapt to new challenges and continue to provide high-quality services.

[0280] The above-mentioned embodiment device reduces the dependence on a large amount of labeled data, which means that the cost and time of manual labeling can be reduced, thereby reducing the overall project cost and speeding up the model development and deployment. The generalization ability of the strong model not only performs well in a specific field, but also can adapt to new or cross-domain tasks, thereby improving the applicability and flexibility of the model. Improving the scalability of the model enables the model to be quickly adjusted and optimized when faced with new fields and new needs, reducing the time for retraining and deployment, and accelerating the response to market and technological changes. By improving the self-learning ability of the model and reducing the dependence on high-quality labeled data, the performance of the model under various data conditions can be improved, and user satisfaction can be improved.

[0281] The automatic structured extraction device for image content in the embodiment of the present application can be a device, or a component, integrated circuit, or chip in a terminal. The device can be a mobile electronic device or a non-mobile electronic device. Exemplarily, the mobile electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, an in-vehicle electronic device, a wearable device, an ultra-mobile personal computer (UMPC), a netbook, or a personal digital assistant (PDA), etc. The non-mobile electronic device can be a server, a network attached storage (NAS), a personal computer (PC), a television (TV), a teller machine or a self-service machine, etc., which is not specifically limited in the embodiment of the present application.

[0282] The automatic structured extraction device for image content in the embodiment of the present application may be a device having an operating system. The operating system may be an Android operating system, an iOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.

[0283] The automatic structured extraction device for image content provided in the embodiment of the present application can achieve Figure 1 To avoid repetition, the various processes implemented by the method embodiment are not described here.

[0284] Alternatively, if Figure 4 As shown, an embodiment of the present application also provides an electronic device 400, including a processor 401, a memory 402, and a program or instruction stored in the memory 402 and executable on the processor 401. When the program or instruction is executed by the processor 401, each process of the above-mentioned embodiment of the method for automatic structured extraction of image content is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0285] It should be noted that the electronic devices in the embodiments of the present application include the mobile electronic devices and non-mobile electronic devices mentioned above.

[0286] Figure 5 A schematic diagram of the hardware structure of an electronic device to implement an embodiment of the present application.

[0287] The electronic device 500 includes but is not limited to: a radio frequency unit 501, a network module 502, an audio output unit 503, an input unit 504, a sensor 505, a display unit 506, a user input unit 507, an interface unit 508, a memory 509, and a processor 510.

[0288] Those skilled in the art will appreciate that the electronic device 500 may also include a power source (such as a battery) for supplying power to various components, and the power source may be logically connected to the processor 510 through a power management system, thereby implementing functions such as managing charging, discharging, and power consumption management through the power management system. Figure 5 The electronic device structure shown in the figure does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently, which will not be described in detail here.

[0289] It should be understood that in the embodiment of the present application, the input unit 504 may include a graphics processor (GPU) 5041 and a microphone 5042, and the graphics processor 5041 processes the image data of the static picture or video obtained by the image capture device (such as a camera) in the video capture mode or the image capture mode. The display unit 506 may include a display panel 5061, and the display panel 5061 may be configured in the form of a liquid crystal display, an organic light emitting diode, etc. The user input unit 507 includes a touch panel 5071 and other input devices 5072. The touch panel 5071 is also called a touch screen. The touch panel 5071 may include two parts: a touch detection device and a touch controller. Other input devices 5072 may include but are not limited to a physical keyboard, a function key (such as a volume control button, a switch button, etc.), a trackball, a mouse, and a joystick, which will not be repeated here. The memory 509 can be used to store software programs and various data, including but not limited to applications and operating systems. The processor 510 can integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, the user interface, and the application program, etc., and the modem processor mainly processes wireless communication. It is understandable that the above-mentioned modem processor may not be integrated into the processor 510.

[0290] An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, each process of the above-mentioned embodiment of the automatic structured extraction method of image content is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0291] The processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0292] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned embodiment of the method for automatic structured extraction of image content, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0293] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.

[0294] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.

[0295] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for enabling a terminal (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present application.

[0296] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.

Claims

1. A method for automatically extracting structured image content, characterized in that: include: Get the target image; Performing OCR processing on the target image to obtain text information in the target image; Performing standardization processing on the text information to obtain standardized text information; Identifying an information field of the standardized text information; Determine prompt words according to the information field, and use the prompt words to guide the information structured extraction model to extract structured information from the standardized text information. The prompt words are carefully selected and manually sorted, covering professional terms and common expressions in the fields of medicine, government affairs, finance, and e-commerce. They are summarized by domain experts based on rich industry knowledge and experience based on actual cases and analysis of a large amount of text data; The acquiring of the target image comprises: detecting a network bandwidth of a transmission network; adjusting an image quality of the target image according to the network bandwidth; and acquiring the target image through the transmission network; The detection of the network bandwidth of the transmission network includes performing periodic network bandwidth detection, sending a small data packet to the server at fixed intervals, measuring the round-trip time, and smoothing multiple bandwidth measurement results using an exponential moving average to obtain a more stable bandwidth estimation value. The calculation formula is as follows: in, B is bandwidth; S is the packet size; T is the round trip time; a is the smoothing factor; B ema is the smoothed bandwidth estimate; B current is the currently measured bandwidth value; B previous is the previous smoothing bandwidth value; The adjusting the image quality of the target image according to the network bandwidth includes: calculating a compression ratio of the target image according to the bandwidth estimation value, and compressing the target image according to the compression ratio, wherein the calculation formula of the compression ratio is as follows: in, Q is the compression ratio, which indicates the compression quality of the target image; B is the bandwidth value of the current network; Q max is the high quality compression factor; Q min is a low quality compression factor; B max is the high bandwidth threshold; B min is the low bandwidth threshold; The structured extraction model is obtained by training the ChatGLM-6B model and fine-tuning with LoRA; the rank of LoRA fine-tuning is 8, the batch size is set to 1, the training rounds are 50, the learning rate is set to 3e-5, and the logging frequency is to record the training log every 100 steps; The performing OCR processing on the target image to obtain text information in the target image includes: Performing denoising, contrast adjustment and binarization processing on the target image to obtain an image to be identified; Using a trained text recognition model to recognize the image to be recognized, and obtaining text information in the target image, wherein the text recognition model is obtained through transfer learning training; The binarization process is a deep learning enhanced binarization process, which uses a small convolutional neural network to predict the optimal binarization thresholds for different areas of the image, and performs image binarization according to the thresholds predicted by the small convolutional neural network to adapt to uneven lighting and complex backgrounds.

2. The method for automatic structured extraction of image content according to claim 1, characterized in that: The step of performing standardization processing on the text information to obtain standardized text information includes: Removing useless symbols from the text information; Correcting erroneous information in the text message; The punctuation format in the text information is unified.

3. The method for automatic structured extraction of image content according to claim 1, characterized in that: The prompt words are extracted by the following method: Determine the information domain of the text message; According to the information domain, key information is extracted from the text information using a keyword extraction model to obtain the prompt word.

4. The method for automatic structured extraction of image content according to claim 3, characterized in that: After extracting key information from the text information according to the information domain and using a keyword extraction model to obtain the prompt word, the method further includes: Extracting structured information from the standardized text information using the prompt word guided information structured extraction model; The key information is adjusted using the structured information feedback.

5. A device for automatically extracting structured image content, characterized in that: include: Acquisition module, used to acquire the target image; An OCR processing module, used to perform OCR processing on the target image to obtain text information in the target image; A text processing module, used for performing standardization processing on the text information to obtain standardized text information; A prompt word design module, used for identifying the information field of the standardized text information; A large model extraction module is used to determine prompt words according to the information field, and use the prompt words to guide the information structured extraction model to extract structured information from the standardized text information. The prompt words are carefully selected and manually sorted, covering professional terms and common expressions in the fields of medicine, government affairs, finance, and e-commerce. They are summarized by domain experts based on rich industry knowledge and experience according to actual cases and analysis of a large amount of text data; The acquisition module is also used to detect the network bandwidth of the transmission network; adjust the image quality of the target image according to the network bandwidth; and acquire the target image through the transmission network; The detection of the network bandwidth of the transmission network includes performing periodic network bandwidth detection, sending a small data packet to the server at fixed intervals, measuring the round-trip time, and smoothing multiple bandwidth measurement results using an exponential moving average to obtain a more stable bandwidth estimation value. The calculation formula is as follows: in, B is bandwidth; S is the packet size; T is the round trip time; a is the smoothing factor; B ema is the smoothed bandwidth estimate; B current is the currently measured bandwidth value; B previous is the previous smoothing bandwidth value; The adjusting the image quality of the target image according to the network bandwidth includes: calculating a compression ratio of the target image according to the bandwidth estimation value, and compressing the target image according to the compression ratio, wherein the calculation formula of the compression ratio is as follows: in, Q is the compression ratio, which indicates the compression quality of the target image; B is the bandwidth value of the current network; Q max is the high quality compression factor; Q min is a low quality compression factor; B max is the high bandwidth threshold; B min is the low bandwidth threshold; The structured extraction model is obtained by training the ChatGLM-6B model and fine-tuning with LoRA; the rank of LoRA fine-tuning is 8, the batch size is set to 1, the training rounds are 50, the learning rate is set to 3e-5, and the logging frequency is to record the training log every 100 steps; The text processing module is specifically used to perform denoising, contrast adjustment and binarization processing on the target image to obtain a to-be-recognized image; and to recognize the to-be-recognized image using a trained text recognition model to obtain text information in the target image, wherein the text recognition model is obtained through transfer learning training; The binarization process is a deep learning enhanced binarization process, which uses a small convolutional neural network to predict the optimal binarization thresholds for different areas of the image, and performs image binarization according to the thresholds predicted by the small convolutional neural network to adapt to uneven lighting and complex backgrounds.

6. An electronic device, characterized in that: include: A processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements the steps of the method for automatic structured extraction of image content as described in any one of claims 1 to 5.

7. A readable storage medium, characterized in that: The readable storage medium stores a program or instruction, and when the program or instruction is executed by the processor, the steps of the method for automatic structured extraction of image content as described in any one of claims 1 to 5 are implemented.

Citation Information

Patent Citations

  • Key information extraction method and system based on large language model

    CN118210879A