A method and device for data processing based on large language model
By combining the generative adversarial network and OCR model with large language model to process image text information, the problem of difficult term understanding in specific fields of large language model is solved, efficient and accurate text recognition and completion are achieved, and data processing automation is improved and flexibility.
Patent Information
- Application Number
- CN202410673099.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-28
- Publication Date
- 2024-12-17
- Estimated Expiration
- 2044-05-28
AI Technical Summary
When large language models process text information in images, it is difficult to accurately understand terms or expressions in specific fields, resulting in a decrease in the accuracy of data structured splitting.
Combining the generative adversarial network model and OCR model with large language model, ensure accuracy and automation by generating high-quality target images, identifying text data, comparing standard rules, completing texts, and calculating the rationality score of the completion plan. .
It improves the accuracy and automation of text recognition, reduces manual processing costs, and enhances the flexibility and reliability of data processing.
Smart Images

Figure CN118552968B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of data processing, and in particular to a method, system, electronic device and storage medium for performing data processing based on a large language model. Background Art
[0002] With the development of technology, there is a growing demand for automated processing of text information in paper documents and images. This includes digitizing paper documents, automatic form recognition, automated bill processing, etc., to improve work efficiency and reduce manual errors.
[0003] At present, text information in images is directly extracted and analyzed through large language models. However, since large language models still have certain limitations in understanding text semantics, they may not be able to accurately understand the terms or expressions in certain specific fields, resulting in a decrease in the accuracy of data structured splitting.
[0004] Therefore, a data processing method is needed that can accurately perform text recognition and solution completion. Summary of the invention
[0005] This application provides a method, system, electronic device and storage medium for data processing based on a large language model, which realizes efficient, accurate and automatic processing of text data in original images by combining a generative adversarial network model, an OCR (Optical Character Recognition) model and a large language model. This can not only improve the performance and efficiency of the data processing platform, but also reduce the cost of manual processing, providing strong support for various data processing tasks.
[0006] In a first aspect of the present application, a method for data processing based on a large language model is provided, which is applied to a data processing platform, and the method comprises:
[0007] When an original image is received, a target image is generated according to the original image using a preset first generative adversarial network model, and a preset OCR model is used to recognize the target image to extract first text data;
[0008] Comparing the first text data with a preset standard text rule to determine errors or omissions, and using a preset large language model to perform preliminary text completion on the first text data according to the errors or omissions to obtain second text data;
[0009] Generate multiple completion schemes according to the second text data by presetting a second generative adversarial network model, and calculate rationality scores of the multiple completion schemes according to preset rules;
[0010] The second text data is completed according to a first completion scheme, the first completion scheme and the second completion scheme are any two of the plurality of completion schemes, and the rationality score of the first completion scheme is greater than the rationality score of the second completion scheme.
[0011] By adopting the above technical solution, the original image is processed by the preset first generative adversarial network model, and a higher quality target image can be generated, which helps to improve the recognition accuracy of the text in the image by the OCR model. The introduction of the generative adversarial network model provides a more intelligent and effective method for image preprocessing and lays the foundation for the subsequent extraction of text data. After the first text data is extracted from the target image using the preset OCR model, the errors or omissions in the text can be accurately identified by comparing with the preset standard text rules. This comparison mechanism ensures the accuracy of the text data and provides a reliable data source for subsequent data processing. The large language model has a strong text generation and understanding ability, and can intelligently complete the errors or omissions to generate more complete and accurate second text data. This step significantly improves the automation of data processing and reduces the need for manual intervention. Multiple completion schemes are generated by the preset second generative adversarial network model, which further increases the flexibility and diversity of data processing. This method can produce a variety of possible completion results, providing a wealth of options for selecting the most reasonable completion scheme. The rationality scores of multiple completion schemes are calculated according to the preset rules, and the completion scheme is selected according to the scores, ensuring the objectivity and accuracy of the completion results. This method avoids the interference of subjective judgment and improves the reliability and consistency of data processing.
[0012] Optionally, the method further includes:
[0013] constructing a first neural network as a first generator, the first neural network being capable of receiving random noise as input and generating image data;
[0014] Constructing a second neural network as a first discriminator, wherein the second neural network is capable of distinguishing whether an input image is a real image or a generated image;
[0015] Iteratively training the first generator and the first discriminator until both the first generator and the first discriminator meet a first preset requirement;
[0016] The preset first generative adversarial network model is constructed by the first generator and the first discriminator.
[0017] By adopting the above technical solution, the first neural network is constructed as the first generator, and image data can be generated using random noise. This generation method enables the model to create a variety of images, providing rich materials for subsequent OCR recognition. At the same time, the ability of the generator is constantly improving with the deepening of training, and the quality of the generated images will gradually improve. The second neural network is constructed as the first discriminator, so that the model can distinguish whether the input image is a real image or a generated image. This step enhances the discriminative ability of the model and helps to continuously optimize the performance of the generator and the discriminator during the training process. Through iterative training, a competitive relationship is formed between the generator and the discriminator, which jointly promotes the improvement of model performance. During the iterative training process, when the first generator and the first discriminator both meet the first preset requirements, the training ends. This ensures that the model's ability to generate images and discriminate images has reached a high level, providing strong support for subsequent data processing tasks. The preset first generative adversarial network model is constructed by the first generator and the first discriminator, so that the model can comprehensively generate and discriminate capabilities and generate high-quality image data. This not only improves the accuracy of OCR recognition, but also enhances the robustness and reliability of the entire data processing process.
[0018] Optionally, the iteratively training the first generator and the first discriminator until the first generator and the first discriminator both meet a first preset requirement includes:
[0019] Fixing the parameters of the first generator, training the first discriminator to distinguish between real images and generated images, and updating the parameters of the first discriminator according to the discrimination result of the first discriminator;
[0020] Fixing the parameters of the first discriminator, training the first generator to generate images, and updating the parameters of the first generator according to the quality judgment score of the images;
[0021] The first generator and the first discriminator are trained alternately until a preset number of iterations is reached or the performance converges.
[0022] By adopting the above technical solution, fixing the parameters of the first generator and training the first discriminator, the model can learn how to distinguish between real images and generated images. In this process, the discriminator improves its discrimination ability by continuously adjusting its own parameters, so that it can more accurately identify the difference between real images and generated images. Fixing the parameters of the first discriminator and training the first generator enables the generator to generate image data that is closer to the real image. The generator optimizes its own parameters to generate images that can deceive the discriminator, thereby improving the quality and diversity of its generated images. The continuous iteration of this step significantly improves the generator's ability to generate images. Alternating the training of the first generator and the first discriminator can achieve mutual improvement between the two. The generator continuously improves its ability to generate images, while the discriminator continuously improves its ability to discriminate images. The competition and cooperation relationship between the two enables the entire model to achieve a balance in generating confrontation. By setting a preset number of iterations or performance convergence as the stop condition, it can ensure that the training process stops at the right time to avoid performance degradation caused by overtraining. At the same time, this also helps to control the training time and the use of computing resources.
[0023] Optionally, the using a preset OCR model to recognize the target image to extract the first text data includes:
[0024] Dividing the target image into a plurality of regions of the same size, and calculating statistics of each region respectively, wherein the statistics include average brightness and contrast;
[0025] A threshold is calculated according to the statistics of the target area, and a pixel block in the target area whose pixel value is greater than or equal to the threshold is set to a first color, and a pixel block in the target area whose pixel value is less than the threshold is set to a second color, wherein the target area is any one of the multiple areas of the same size;
[0026] Characters in the target image are recognized according to the first color and the second color, a first feature of the character is extracted, a text label is matched according to the first feature, and first text data is generated according to the text label.
[0027] By adopting the above technical solution, the target image is divided into multiple regions of the same size, and the statistics of each region (including average brightness and contrast) are calculated, so that the model can better understand the local features of the image. This method of region division and statistics calculation is helpful for the subsequent accurate recognition of characters in the image, because characters usually have specific brightness and contrast patterns. According to the threshold value obtained by the statistical calculation of the target area, the pixel blocks are set to different colors, which is actually a process of image binarization. By converting the image to black and white, the difference between the characters and the background can be highlighted, making it easier to recognize the characters. This binarization method is simple and effective, and is crucial to improving the accuracy of OCR recognition. According to the first features of the recognized characters (such as shape, size, structure, etc.), the model can match the corresponding text labels. This process makes full use of the inherent characteristics of the characters, making the recognition results more accurate and reliable. At the same time, by matching the text labels, the model can convert the characters in the image into editable and searchable text data, which facilitates subsequent data processing and analysis. The first text data is generated according to the matched text labels, realizing the conversion from image to text. This step not only improves the automation of data processing, but also enables the information in the image to be fully utilized and mined.
[0028] Optionally, the using a preset large language model to perform preliminary text completion on the first text data according to the error or omission to obtain the second text data includes:
[0029] The first context information where the erroneous words or sentences are located and the second context information where the missing information is located are analyzed by using the pre-learned language knowledge and grammar rules, and a replacement vocabulary is generated according to the first context information, and a complete vocabulary or sentence is generated according to the second context information.
[0030] By adopting the above technical solution, through the pre-learned language knowledge and grammatical rules, the large language model can conduct in-depth analysis of the context in which the wrong words or sentences and the missing information are located. This analysis capability enables the model to accurately understand the errors and omissions in the text, and provides a basis for the subsequent generation of alternative words or complete sentences. The process of generating alternative words based on the first context information can automatically correct the wrong words in the text. By considering the context information, the large language model can generate alternative words that are consistent with the original content and grammatically correct, thereby improving the accuracy of the text data. At the same time, the generation of complete words or sentences based on the second context information can fill in the missing information in the text. By understanding the context semantics, the large language model can infer the content of the missing part and generate appropriate complete words or sentences. This can not only improve the text information, but also maintain the coherence and logic of the text. Through the preliminary text completion of the large language model, the second text data can be obtained, which has significantly improved accuracy and completeness compared with the first text data. This provides a more reliable and effective data basis for subsequent data processing and analysis.
[0031] Optionally, the method further includes:
[0032] Constructing a third neural network as a second generator, wherein the third neural network is capable of receiving text data as input and generating a text completion solution;
[0033] Constructing a fourth neural network as a second discriminator, wherein the fourth neural network is capable of evaluating the consistency between the generated text completion solution and the real text;
[0034] Iteratively training the second generator and the second discriminator until both the second generator and the second discriminator meet a second preset requirement;
[0035] The preset second generative adversarial network model is constructed by the second generator and the second discriminator.
[0036] By adopting the above technical solution, by constructing a third neural network as the second generator, the generator can receive text data as input and generate a text completion solution. This enables the model to automatically generate a variety of possible completion solutions based on the input text data, providing a rich choice for subsequent text processing. Constructing a fourth neural network as the second discriminator enables the model to evaluate the consistency of the generated text completion solution with the real text. The role of the discriminator is to evaluate the quality of the generated completion solution to ensure that it meets the grammatical, semantic and style requirements of the real text. By iteratively training the second generator and the second discriminator until they both meet the second preset requirements, the model can continuously optimize the performance of the generator and the discriminator. The generator will gradually improve the quality and diversity of the generated text completion solution during the iteration process, while the discriminator will continuously improve the ability to evaluate the quality of the generated text. The preset second generative adversarial network model is constructed by the second generator and the second discriminator. The model can combine the advantages of the generator and the discriminator to generate a text completion solution that meets the requirements of the real text and has diversity. This provides a more flexible and reliable solution for subsequent text data processing.
[0037] Optionally, calculating the rationality scores of the plurality of completion solutions according to a preset rule includes:
[0038] For the target completion scheme, extract a second feature corresponding to the preset rule, the preset rule includes a grammatical rule, a semantic rule, a vocabulary matching rule and an information integrity rule, the second feature includes a vocabulary feature, a syntactic feature and a semantic feature, and the target completion scheme is any one of the multiple completion schemes;
[0039] The sub-score corresponding to each rule is calculated according to the feature, and a plurality of sub-scores are weighted and summed to obtain the rationality score of the target completion solution.
[0040] By adopting the above technical solution, the second feature corresponding to the preset rule is extracted, and multiple aspects of the completion scheme can be comprehensively evaluated. The preset rules include grammatical rules, semantic rules, vocabulary matching rules and information integrity rules, which together constitute the framework for the quality evaluation of the completion scheme. The second feature includes lexical features, syntactic features and semantic features, which can reflect the performance of the completion scheme in terms of vocabulary usage, sentence structure and semantic expression. The sub-score corresponding to each rule is calculated according to the extracted features, making the evaluation process more objective and accurate. By setting a corresponding scoring mechanism for different rules, the performance of the completion scheme under each rule can be quantified. This quantitative evaluation not only helps to compare the pros and cons of different completion schemes, but also provides a basis for subsequent weighted summation. The rationality score of the target completion scheme is obtained by weighted summing of multiple sub-scores, which can comprehensively consider the influence of multiple rules and obtain a comprehensive evaluation result. By setting different weights, the importance of different rules in the evaluation can be reflected, so that the evaluation results are more in line with actual needs.
[0041] In a second aspect of the present application, a system for data processing based on a large language model is provided, comprising an image processing module, a first completion module, a second completion module and a completion execution module, wherein:
[0042] An image processing module is configured to, when receiving an original image, generate a target image based on the original image using a preset first generative adversarial network model, and recognize the target image using a preset OCR model to extract first text data;
[0043] A first completion module is configured to compare the first text data with a preset standard text rule to determine errors or omissions, and use a preset large language model to perform preliminary text completion on the first text data according to the errors or omissions to obtain second text data;
[0044] A second completion module is configured to generate a plurality of completion schemes according to the second text data by using a preset second generative adversarial network model, and calculate rationality scores of the plurality of completion schemes according to preset rules;
[0045] The completion execution module is configured to complete the second text data according to a first completion scheme, the first completion scheme and the second completion scheme are any two of the multiple completion schemes, and the rationality score of the first completion scheme is greater than the rationality score of the second completion scheme.
[0046] In the third aspect of the present application, an electronic device is provided, including a processor, a memory, a user interface and a network interface, the memory is used to store instructions, the user interface and the network interface are both used to communicate with other devices, and the processor is used to execute the instructions stored in the memory so that the electronic device executes any one of the methods described above.
[0047] In a fourth aspect of the present application, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores instructions, and when the instructions are executed, any of the methods described above is executed.
[0048] In summary, one or more technical solutions provided in the embodiments of the present application have at least the following technical effects or advantages:
[0049] 1. The original image is processed by using the preset first generative adversarial network model to generate the target image, which improves the image quality and recognition rate. This step provides more accurate and reliable image data for subsequent OCR recognition, thereby improving the accuracy and completeness of text extraction;
[0050] 2. Use the preset OCR model to identify the target image and extract the first text data. The introduction of the OCR model enables the platform to automatically process the text information in the image, greatly improving the efficiency and accuracy of data processing;
[0051] 3. Compare the first text data with the preset standard text rules to find out the errors or omissions. This step helps to find and correct errors in the text data, ensuring the accuracy of subsequent processing. The introduction of the large language model enables the platform to automatically complete the text data based on rich language knowledge and grammatical rules, improving the integrity and readability of the data;
[0052] 4. Generate multiple completion schemes by presetting the second generative adversarial network model, and calculate the rationality scores of these schemes according to preset rules. According to the comparison results of the rationality scores, select the first completion scheme with the highest rationality score to complete the second text data. This step ensures the accuracy and reliability of the completion results and improves the performance of the entire data processing process. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] Figure 1 It is a flowchart of a method for data processing based on a large language model disclosed in an embodiment of the present application;
[0054] Figure 2 It is a module diagram of a system for performing data processing based on a large language model disclosed in an embodiment of the present application;
[0055] Figure 3It is a structural schematic diagram of an electronic device disclosed in an embodiment of the present application.
[0056] Explanation of the reference numerals: 201, image processing module; 202, first completion module; 203, second completion module; 204, completion execution module; 301, processor; 302, communication bus; 303, user interface; 304, network interface; 305, memory. DETAILED DESCRIPTION
[0057] In order to enable technicians in this field to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below in conjunction with the drawings in the embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this application, not all of the embodiments.
[0058] In the description of the embodiments of the present application, words such as "for example" or "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design described as "for example" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "for example" or "for example" is intended to present related concepts in a specific way.
[0059] In the description of the embodiments of the present application, the meaning of the term "multiple" refers to two or more. For example, multiple systems refer to two or more systems, and multiple screen terminals refer to two or more screen terminals. In addition, the terms "first" and "second" are used for descriptive purposes only and cannot be understood as indicating or implying relative importance or implicitly indicating the indicated technical features. Thus, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. The terms "include", "comprise", "have" and their variations all mean "including but not limited to", unless otherwise specifically emphasized.
[0060] This embodiment discloses a method for data processing based on a large language model. Figure 1 is a flow chart of a method for data processing based on a large language model disclosed in an embodiment of the present application, such as Figure 1 As shown, the method comprises the following steps:
[0061] S110: when an original image is received, a preset first generative adversarial network model is used to generate a target image according to the original image, and a preset OCR model is used to recognize the target image to extract first text data;
[0062] After receiving the original image, the preset first generative adversarial network model (GAN model) is used to process the original image. The GAN model is a deep learning model consisting of a generator and a discriminator. Through adversarial training between the two, the generator can learn the distribution of real data and generate new data. In this scenario, the task of the generator is to learn and improve the quality of the image to generate a target image that is easier for the OCR model to recognize. When processing an image, the generative adversarial network model will focus on the details, color, contrast, etc. of the image. By optimizing these elements, the generated image will improve clarity, reduce noise and distortion while maintaining the original information, making it more suitable for OCR model recognition. This process may involve operations such as image enhancement, denoising, and sharpening to achieve the purpose of improving recognition accuracy. After the generator generates the target image, it will use the preset OCR model to recognize it. The OCR model is a model specifically used to extract text information from an image. It usually includes steps such as image preprocessing, text positioning, and character recognition. In the preprocessing stage, the OCR model will perform a series of processing on the target image, such as binarization, denoising, smoothing, etc., to improve the quality of the image and increase the accuracy of recognition. The model will use deep learning techniques, such as convolutional neural networks (CNN), to locate and recognize text in the image. This process includes detecting text areas, segmenting characters, and converting characters into readable text information. The OCR model will output the first text data extracted from the target image. This data may include information such as the text content, format, and location in the image, providing an important basis for subsequent data processing and analysis.
[0063] Optionally, the method further includes:
[0064] constructing a first neural network as a first generator, the first neural network being capable of receiving random noise as input and generating image data;
[0065] Constructing a second neural network as a first discriminator, wherein the second neural network is capable of distinguishing whether an input image is a real image or a generated image;
[0066] Iteratively training the first generator and the first discriminator until both the first generator and the first discriminator meet a first preset requirement;
[0067] The preset first generative adversarial network model is constructed by the first generator and the first discriminator.
[0068] A first neural network is constructed as the first generator. The task of the first generator is to generate image data based on the input random noise. In order to complete this task, a complex neural network structure is designed, which contains multiple convolutional layers, pooling layers, activation functions and other components. These components work together to map the input random noise to the image space and generate an image with a certain structure and content. At the same time, a second neural network is constructed as the first discriminator. The task of the first discriminator is to distinguish whether the input image is a real image or an image generated by the generator. In order to achieve this function, a classifier network is designed, which receives the image as input and outputs a probability value indicating the probability that the image is a real image. The network structure of the first discriminator also contains multiple convolutional layers, fully connected layers, etc. to extract the features of the image and classify it. The first generator and the first discriminator are iteratively trained. During the training process, the parameters of the generator and the discriminator are updated alternately. Specifically, the parameters of the first discriminator are first fixed, and the first generator is trained to generate images that are more realistic and more difficult to distinguish by the discriminator. Then, the parameters of the first generator are fixed, and the first discriminator is trained to more accurately identify real images and generated images. This process is implemented through the back-propagation algorithm and the gradient descent optimizer to gradually optimize the performance of the first generator and the first discriminator. During the training process, a first preset requirement is set to determine whether the first generator and the first discriminator meet the training objectives. These requirements may include the quality of the generated image, the accuracy of the discriminator, etc. When the performance of the first generator and the first discriminator on the validation set meets the preset requirements, the training is stopped and the parameters of the model are saved. The preset first generative adversarial network model is constructed by the trained first generator and the first discriminator. This model can receive random noise as input and generate high-quality image data, providing better input for subsequent OCR recognition.
[0069] By constructing the first neural network as the first generator, the model can generate image data from random noise. This generation method greatly increases the diversity and flexibility of images and provides more possibilities for subsequent OCR recognition. The generator can learn the distribution characteristics of real images and generate images similar to them, thereby improving the quality and usability of images. The second neural network is constructed as the first discriminator to distinguish whether the input image is a real image or a generated image. The introduction of the discriminator forms an adversarial relationship between the generator and the discriminator. Through mutual competition and iterative optimization, the quality of the generated image and the recognition ability of the discriminator are further improved. This adversarial training method helps to generate more realistic and difficult to distinguish image data. The first generator and the first discriminator are iteratively trained until they both meet the first preset requirements. This step ensures that the generator and the discriminator can gradually improve their performance during the training process and meet the preset accuracy and stability requirements. Through continuous iterative optimization, the model can learn more about the characteristics and laws of real images, thereby generating better quality image data. The preset first generative adversarial network model is constructed by the trained first generator and the first discriminator. This model can combine the advantages of the generator and the discriminator to generate high-quality and diverse image data, providing better input for subsequent OCR recognition. This image processing method based on generative adversarial networks not only improves the efficiency and accuracy of image processing, but also provides strong support for subsequent text extraction and data analysis.
[0070] Optionally, the iteratively training the first generator and the first discriminator until the first generator and the first discriminator both meet a first preset requirement includes:
[0071] Fixing the parameters of the first generator, training the first discriminator to distinguish between real images and generated images, and updating the parameters of the first discriminator according to the discrimination result of the first discriminator;
[0072] Fixing the parameters of the first discriminator, training the first generator to generate images, and updating the parameters of the first generator according to the quality judgment score of the images;
[0073] The first generator and the first discriminator are trained alternately until a preset number of iterations is reached or the performance converges.
[0074] Fix the parameters of the first generator and start training the first discriminator. At this stage, the task of the first discriminator is to learn how to distinguish between real images and generated images. Input a batch of real images and a batch of images generated by the generator to the first discriminator, and the discriminator will output the probability that each image is a real image. Then, calculate the loss function based on the output of the discriminator and the real label, and update the parameters of the discriminator through the back propagation algorithm. This process aims to improve the ability of the first discriminator to distinguish between real images and generated images. Then, fix the parameters of the first discriminator and start training the first generator. At this stage, the task of the first generator is to learn how to generate images that are more realistic and more difficult for the discriminator to distinguish. Input random noise to the first generator, and the first generator will output the corresponding image. Input these generated images into the first discriminator to obtain the discrimination results of the first discriminator for each image. Calculate the loss function of the first generator based on the discrimination results, and update the parameters of the generator through the back propagation algorithm. This process aims to make the images generated by the generator closer to the real images, so as to deceive the discriminator. During the training process, the training of the first generator and the first discriminator is performed alternately until the preset number of iterations is reached or the performance converges. The preset number of iterations is an empirical value used to control the number of training rounds. Performance convergence means that the performance of the first generator and the first discriminator no longer improves significantly in multiple consecutive iterations, which usually means that the model has reached a relatively stable state. In a specific implementation, it can be judged whether the first preset requirement has been met by observing indicators such as the change in the loss function during the training process, the quality of the generated image, and the accuracy of the first discriminator. When these indicators reach the preset threshold or tend to be stable, it can be considered that the first generator and the first discriminator have met the training requirements, and the training can be stopped and the model parameters can be saved.
[0075] By fixing the parameters of the first generator and training the first discriminator, it is ensured that the first discriminator can accurately distinguish between real images and generated images. This helps to enhance the recognition ability of the discriminator, so that it can better guide the training of the generator in the subsequent iterative process. By fixing the parameters of the first discriminator and training the first generator, the first generator can adjust its parameters according to the feedback of the first discriminator to generate more realistic images that are more difficult to distinguish by the discriminator. This alternating training method forms a competitive relationship between the generator and the discriminator, which helps to improve the quality and diversity of the generated images. By alternating the training of the first generator and the first discriminator, continuous optimization of the model is achieved. During the iterative process, the performance of the first generator and the first discriminator will gradually improve until the preset number of iterations is reached or the performance converges. This iterative training method helps the model learn more image features and rules, thereby generating better quality image data. Through the above iterative training process, a preset first generative adversarial network model with excellent performance is constructed. The model can generate high-quality and diverse image data, providing better input for subsequent OCR recognition and text extraction. This image processing method based on generative adversarial networks not only improves the efficiency and accuracy of image processing, but also provides strong support for subsequent text analysis and data mining.
[0076] Optionally, the using a preset OCR model to recognize the target image to extract the first text data includes:
[0077] Dividing the target image into a plurality of regions of the same size, and calculating statistics of each region respectively, wherein the statistics include average brightness and contrast;
[0078] A threshold is calculated according to the statistics of the target area, and a pixel block in the target area whose pixel value is greater than or equal to the threshold is set to a first color, and a pixel block in the target area whose pixel value is less than the threshold is set to a second color, wherein the target area is any one of the multiple areas of the same size;
[0079] Characters in the target image are recognized according to the first color and the second color, a first feature of the character is extracted, a text label is matched according to the first feature, and first text data is generated according to the text label.
[0080] The target image is divided into multiple regions of the same size. The purpose of this step is to decompose the image into smaller units, so that each region can be independently calculated and thresholded. The size of the region can be adjusted according to the actual situation to accommodate images of different sizes and resolutions. The statistics of each region are calculated separately, including average brightness and contrast. Average brightness reflects the overall brightness level of the pixels in the region, while contrast describes the range of variation of the pixel brightness values in the region. These statistics help to understand the image characteristics of each region and provide a basis for subsequent binarization. The threshold is calculated based on the statistics of the target region. This threshold is used to divide the pixel blocks in the target region into two categories: pixel blocks with pixel values greater than or equal to the threshold are set to the first color (usually white), while pixel blocks with pixel values less than the threshold are set to the second color (usually black). This process is called binarization, which helps to highlight the difference between the characters and the background, making the characters easier to identify. After binarization, the characters in the target image can be identified based on the first color and the second color. Specifically, the outline and boundary of the characters are identified by detecting the shape, size, position and other features of the black pixel blocks. Extract the first features of these characters, which may include the outline features, texture features, structural features, etc. of the characters. The first features will be used in the subsequent text label matching process. Match the text labels according to the extracted character features. This step is to find the best matching label by comparing the character features with the labels in the predefined label library. After finding the matching labels, the first text data can be generated based on these labels. The first text data contains the character information recognized from the target image and can be used for subsequent text processing and analysis tasks.
[0081] Dividing the target image into multiple regions of the same size and calculating the statistics of each region (such as average brightness and contrast) helps to analyze the local features of the image more accurately. This method is particularly suitable for images with large changes in local brightness or contrast, and can extract character information more effectively. Calculating a threshold based on the statistics of the target region and binarizing the target region based on the threshold (i.e., setting the pixel block to the first color or the second color) helps to highlight the difference between the character and the background. After binarization, the outline and boundary of the character are clearer, thereby improving the accuracy of character recognition. Identify the characters in the target image based on the first color and the second color, and extract the first feature of the character. This process makes full use of color information to locate the characters and extract key features that help identify the characters. These features may be information about the shape, structure or texture of the characters, which play an important role in subsequent text label matching. Match the text label based on the extracted character features, and generate the first text data based on the matched text label. This step utilizes the recognition ability of the preset OCR model and the rich resources of the text label library to accurately convert the characters in the image into readable text data. This not only improves the accuracy of OCR recognition, but also provides a reliable data foundation for subsequent text processing and analysis.
[0082] S120, comparing the first text data with a preset standard text rule to determine errors or omissions, and using a preset large language model to perform preliminary text completion on the first text data according to the errors or omissions to obtain second text data;
[0083] The preset standard text rules are usually a series of specifications for text format, grammar, semantics, etc., which are used to ensure the accuracy and consistency of text data. During the comparison process, each character, word or sentence in the first text data will be checked one by one and matched with the standard rules. Once a situation that does not meet the rules is found, such as spelling errors, grammatical errors, format problems, etc., these errors or omissions will be marked. This process helps to identify potential problems in the text data and provide guidance for subsequent text completion. Use the preset large language model to perform preliminary text completion on the first text data based on errors or omissions. The large language model is an artificial intelligence technology based on deep learning that can understand and generate human language. Here, it plays the role of text completion. According to the comparison results, the large language model analyzes the type and contextual information of the errors or omissions, and then tries to generate text content that conforms to the standard text rules to fill these defects. This process may require the model to have an in-depth understanding of language structure, semantic relationships, etc. to ensure that the generated text data is both accurate and natural. Through the preliminary text completion of the large language model, the second text data can be obtained. Compared with the first text data, the second text data is more standardized and complete in terms of format, grammar and semantics. However, it should be noted that although the large language model has strong capabilities in text completion, it may also be limited by factors such as training data and model structure, resulting in certain errors or deficiencies in the generated text data. Therefore, in the embodiment of the present application, the accuracy and quality of the text data are further improved by combining the second generative adversarial network.
[0084] Optionally, the using a preset large language model to perform preliminary text completion on the first text data according to the error or omission to obtain the second text data includes:
[0085] The first context information where the erroneous words or sentences are located and the second context information where the missing information is located are analyzed by using the pre-learned language knowledge and grammar rules, and a replacement vocabulary is generated according to the first context information, and a complete vocabulary or sentence is generated according to the second context information.
[0086] Assume that there is a first text data, which contains an incorrect word "Apple Flower" and omits a sentence describing the color of apples. Use a large language model to perform preliminary text completion on the first text data based on errors or omissions. The large language model will identify the grammatical and semantic irrationality of the word "Apple Flower" through pre-learned language knowledge and grammatical rules. Because "Apple Flower" is not a word that conforms to the Chinese vocabulary rules, the model will determine that this is an error. The model will analyze the first context information where the incorrect word "Apple Flower" is located. For example, this word appears in a paragraph describing fruits, and the context may contain words for other fruits such as "apple", "pear", and "peach". Based on the first context information, the large language model will generate a list of alternative words that match the context both grammatically and semantically. In this example, "apple" is likely to be the correct word to replace "Apple Flower" because it is semantically consistent with other fruit words. The model will select the most appropriate alternative word to replace the incorrect word. In the embodiment of the present application, the model will select "apple" to replace "Apple Flower". After correcting the incorrect word, the large language model will continue to analyze the text data to find possible missing information. In this example, the model finds that the text lacks a description of the color of the apple. The model will further analyze the second contextual information where the missing information is located. For example, the text may mention the size, shape, and taste of the apple, but lacks a description of the color. Based on the second contextual information, the large language model will generate a series of possible completion words or sentences. In this example, the model may generate possible completion sentences such as "This apple is red" and "This apple is bright in color". The model will select the completion sentence that best matches the context and insert it into the appropriate position in the text. In an embodiment of the present application, the model may select the sentence "This apple is red" to complete the description of the color of the apple in the text.
[0087] By using pre-learned language knowledge and grammatical rules, the large language model can deeply analyze the context in which the wrong words or sentences and the missing information are located. This in-depth analysis helps the model accurately understand the structure, semantics and grammatical rules of the text, thereby providing a reliable basis for subsequent text completion. By generating alternative vocabulary based on the first context information, the large language model can correct the wrong words or sentences in the text. By comparing and matching the vocabulary and grammatical structures in the context, the model can find the alternative vocabulary that best fits the context, thereby improving the accuracy and readability of the text data. By generating complementary vocabulary or sentences based on the second context information, the large language model can fill in the missing information in the text. By analyzing the semantic and logical relationships in the context, the model can infer the missing vocabulary or sentences, making the text content more complete and coherent. The second text data is obtained through preliminary text completion. Compared with the first text data, the second text data is more standardized and complete in terms of grammar, semantics and format. This not only improves the readability of the text data, but also provides a better data foundation for subsequent text processing and analysis.
[0088] S130, generating a plurality of completion schemes according to the second text data by using a preset second generative adversarial network model, and calculating rationality scores of the plurality of completion schemes according to preset rules;
[0089] Using the trained second generative adversarial network model, multiple completion schemes can be generated according to the style and context of the second text data. These completion schemes may be sentences, paragraphs, or longer text fragments, depending on the design of the GAN model and the characteristics of the second text data. In order to evaluate the rationality of each completion scheme, a set of preset rules are set, which may include grammatical correctness, semantic coherence, matching degree with the second text data, etc. For each completion scheme, a score is given according to the preset rules to obtain a rationality score. The higher the score, the more the completion scheme conforms to the grammatical rules, the more coherent the semantics, and the higher the matching degree with the second text data. According to the rationality score, all completion schemes can be sorted, and one or more schemes with the highest scores are selected as the final completion results. If the results need to be further optimized, the parameters of the GAN model can be adjusted or the preset rules can be improved to improve the quality and rationality of the generated text.
[0090] Optionally, the method further includes:
[0091] Constructing a third neural network as a second generator, wherein the third neural network is capable of receiving text data as input and generating a text completion solution;
[0092] Constructing a fourth neural network as a second discriminator, wherein the fourth neural network is capable of evaluating the consistency between the generated text completion solution and the real text;
[0093] Iteratively training the second generator and the second discriminator until both the second generator and the second discriminator meet a second preset requirement;
[0094] The preset second generative adversarial network model is constructed by the second generator and the second discriminator.
[0095] Construct a third neural network as the second generator. The task of the second generator is to receive text data as input and generate corresponding text completion solutions. The third neural network can adopt a recurrent neural network (RNN) or a variant such as a long short-term memory network (LSTM) or a gated recurrent unit (GRU) structure to process sequence data. The input of the network can be the second text data, and after encoding, the second generator can generate multiple possible text completion solutions. Construct a fourth neural network as the second discriminator. The task of the second discriminator is to evaluate the consistency of the generated text completion solution with the real text, that is, to judge whether the generated text is real enough to be indistinguishable from the real text data. The fourth neural network may adopt the structure of a convolutional neural network (CNN) or a deep neural network (DNN) to extract text features and make true or false judgments. The input of the second discriminator can be the generated text completion solution and the real text data, and the output is a probability value indicating the probability that the input text is real. After completing the construction of the second generator and the second discriminator, start iterative training on them. The goal of the training is to enable the second generator to generate more and more real text completion solutions, while enabling the discriminator to judge the truth of the text more and more accurately. During the training process, adversarial training is adopted. First, the parameters of the second discriminator are fixed, and the second generator is trained to generate a text completion solution that can deceive the second discriminator; then, the parameters of the second generator are fixed, and the second discriminator is trained to more accurately identify the real and generated texts. This process is repeated until both the second generator and the second discriminator meet the preset performance requirements. The preset second requirements may include that the text completion solution generated by the second generator is highly consistent with the original text in terms of grammar, semantics and style, and the second discriminator reaches a certain level of accuracy for real and generated texts. Through the trained second generator and the second discriminator, a preset second generative adversarial network model is constructed. This model can receive text data as input, generate multiple text completion solutions, and evaluate the consistency of these solutions with the real text through the discriminator. In practical applications, this model can be used to complete the second text data to improve the integrity and readability of the text data.
[0096] By constructing the third neural network as the second generator, the powerful learning ability of the neural network can be used to capture language rules and patterns from the input text data and generate high-quality text completion solutions. The second generator can not only complete the missing information, but also generate text fragments that match the style and content of the original text according to the context, thereby improving the quality and diversity of text completion. The fourth neural network is constructed as the second discriminator to evaluate the consistency of the generated text completion solution with the real text. The discriminator judges whether the generated text is realistic enough by comparing the feature differences between the generated text and the real text. This setting not only helps to screen out high-quality text completion solutions, but also further encourages the generator to continuously optimize the generated text to make it closer to the style and expression of the real text. By iteratively training the second generator and the second discriminator, it can be ensured that the two continue to improve their capabilities in the confrontation process. The generator can gradually learn how to generate more realistic text completion solutions, while the discriminator can more accurately identify the differences between the generated text and the real text. This iterative training method not only improves the robustness of the model, enabling it to cope with various complex text completion scenarios, but also ensures the stability of the model and reduces the possibility of generating unreasonable or erroneous completion solutions. The preset second generative adversarial network model constructed by the second generator and the second discriminator can realize the automated text completion process. Compared with traditional manual completion or rule-based completion methods, this method is more efficient and accurate. It can generate multiple high-quality text completion solutions in a short time for users to choose or further process. This not only optimizes the text processing process and improves work efficiency, but also provides users with more choices and flexibility.
[0097] Optionally, calculating the rationality scores of the plurality of completion solutions according to a preset rule includes:
[0098] For the target completion scheme, extract a second feature corresponding to the preset rule, the preset rule includes a grammatical rule, a semantic rule, a vocabulary matching rule and an information integrity rule, the second feature includes a vocabulary feature, a syntactic feature and a semantic feature, and the target completion scheme is any one of the multiple completion schemes;
[0099] The sub-score corresponding to each rule is calculated according to the feature, and a plurality of sub-scores are weighted and summed to obtain the rationality score of the target completion solution.
[0100] Grammatical rules: ensure that the completed text is grammatically correct, without incorrect sentence structure or word collocation. Semantic rules: the completed content is semantically consistent with the original text, logically coherent, and without contradictions or ambiguities. Vocabulary matching rules: the vocabulary used in the completed text is consistent with the vocabulary in the original text in terms of style, theme or context. Information completeness rules: the completed text should provide complete information without omissions or repetitions. Lexical features: including word frequency, part of speech distribution, lexical diversity, etc., these features can reflect the characteristics of the completed text in terms of vocabulary use. Syntactic features: such as sentence length, sentence structure complexity, etc., reflect the characteristics of the completed text at the sentence level. Semantic features: text semantic information extracted by methods such as word vectors and topic models, used to evaluate the semantic match between the completed text and the original text. Use natural language processing tools (such as grammatical analyzers) to perform grammatical analysis on the completed text, and calculate the grammatical sub-score based on the analysis results. For example, you can set a full score for a text without grammatical errors, a partial score for a text with a few errors, and a low score for a text with more errors. Semantic sub-score: The semantic similarity between the completed text and the original text is calculated using a semantic similarity algorithm (such as cosine similarity), and the semantic sub-score is calculated based on the similarity value. The higher the similarity, the higher the semantic sub-score. Lexical matching sub-score: The lexical matching sub-score is calculated by comparing the lexical distribution, word frequency and other information of the completed text and the original text. For example, the TF-IDF algorithm can be used to calculate the importance of vocabulary and calculate the sub-score accordingly. Information completeness sub-score: The information completeness sub-score is calculated based on factors such as the amount of information provided by the completed text and the degree of information duplication. By comparing with the original text, it can be evaluated whether the completed text provides sufficient and non-duplicate information. According to the preset weights, the above four sub-scores are weighted and summed to obtain the rationality score of the completion solution. The weights can be adjusted according to the actual application scenarios and needs to reflect the importance of different rules in evaluating the completion solution.
[0101] By combining grammatical rules, semantic rules, vocabulary matching rules and information integrity rules, the completion scheme can be comprehensively evaluated from multiple dimensions. This multi-dimensional evaluation method ensures the accuracy and objectivity of the evaluation and avoids the one-sidedness that may be caused by a single rule. At the same time, extracting the second features (lexical features, syntactic features and semantic features) corresponding to the target completion scheme can more accurately reflect the characteristics of the completion scheme in grammar, semantics and vocabulary use, further improving the accuracy of the evaluation. By calculating the sub-scores corresponding to each rule and weighted summing up multiple sub-scores to obtain the rationality score of the target completion scheme, the quality of the completion scheme can be quantitatively evaluated. Different completion schemes can be sorted and screened according to the scores to select higher-quality schemes. At the same time, by adjusting the weights of different rules, the importance of certain rules can be emphasized or weakened according to actual needs, thereby achieving flexible control of the quality of the completion scheme. By calculating the rationality scores of multiple completion schemes, schemes with poor quality can be quickly identified and avoided from further analysis or application in subsequent processing. This reduces the number of invalid processing and improves the efficiency of text completion processing. At the same time, selecting a higher quality completion solution will also help improve the final text completion processing effect, making the generated text more in line with user needs and expectations. By calculating the rationality score of the completion solution, we can understand the difference in quality between completion solutions generated by different algorithms or models. This provides valuable feedback for optimizing the completion algorithm. According to the specific situation of the score distribution and the rule sub-score, we can adjust the algorithm parameters, improve the model structure or introduce new features to improve the performance and effect of the completion algorithm.
[0102] S140. Complete the second text data according to a first completion scheme, where the first completion scheme and the second completion scheme are any two of the plurality of completion schemes, and the rationality score of the first completion scheme is greater than the rationality score of the second completion scheme.
[0103] Among all the generated completion schemes, the rationality score of each scheme is compared. The rationality score is obtained by evaluating the grammatical correctness, semantic coherence, and matching degree of the completion scheme with the second text data based on preset rules. On this basis, the completion scheme with the highest rationality score is selected as the first completion scheme. The specific completion operation may include inserting a new sentence or paragraph at a specific position in the text, or replacing part of the original text. During the completion process, ensure that the newly inserted text is consistent with the original second text data in style and semantics to achieve a smooth transition and logical coherence. After the completion is completed, the results will be carefully checked to ensure that the completed text has no grammatical errors, unclear semantics, or logical confusion. If any problems are found, appropriate adjustments and optimizations will be made as needed to ensure the accuracy and readability of the final completion result.
[0104] This embodiment also discloses a system for data processing based on a large language model. Figure 2 is a module diagram of a system for data processing based on a large language model disclosed in an embodiment of the present application, such as Figure 2 As shown, the system includes an image processing module 201, a first completion module 202, a second completion module 203 and a completion execution module 204, wherein:
[0105] The image processing module 201 is configured to, when receiving an original image, generate a target image according to the original image using a preset first generative adversarial network model, and recognize the target image using a preset OCR model to extract first text data;
[0106] A first completion module 202 is configured to compare the first text data with a preset standard text rule to determine errors or omissions, and use a preset large language model to perform preliminary text completion on the first text data according to the errors or omissions to obtain second text data;
[0107] A second completion module 203 is configured to generate a plurality of completion schemes according to the second text data by using a preset second generative adversarial network model, and calculate rationality scores of the plurality of completion schemes according to preset rules;
[0108] The completion execution module 204 is configured to complete the second text data according to a first completion scheme, the first completion scheme and the second completion scheme are any two of the plurality of completion schemes, and the rationality score of the first completion scheme is greater than the rationality score of the second completion scheme.
[0109] Optionally, the system further includes a first training module, wherein the first training module is configured to:
[0110] constructing a first neural network as a first generator, the first neural network being capable of receiving random noise as input and generating image data;
[0111] Constructing a second neural network as a first discriminator, wherein the second neural network is capable of distinguishing whether an input image is a real image or a generated image;
[0112] Iteratively training the first generator and the first discriminator until both the first generator and the first discriminator meet a first preset requirement;
[0113] The preset first generative adversarial network model is constructed by the first generator and the first discriminator.
[0114] Optionally, the first training module is configured to:
[0115] Fixing the parameters of the first generator, training the first discriminator to distinguish between real images and generated images, and updating the parameters of the first discriminator according to the discrimination result of the first discriminator;
[0116] Fixing the parameters of the first discriminator, training the first generator to generate images, and updating the parameters of the first generator according to the quality judgment score of the images;
[0117] The first generator and the first discriminator are trained alternately until a preset number of iterations is reached or the performance converges.
[0118] Optionally, the image processing module 201 is configured to:
[0119] Dividing the target image into a plurality of regions of the same size, and calculating statistics of each region respectively, wherein the statistics include average brightness and contrast;
[0120] A threshold is calculated according to the statistics of the target area, and pixel blocks in the target area whose pixel values are greater than or equal to the threshold are set to a first color, and pixel blocks in the target area whose pixel values are less than the threshold are set to a second color;
[0121] Characters in the target image are recognized according to the first color and the second color, a first feature of the character is extracted, a text label is matched according to the first feature, and first text data is generated according to the text label.
[0122] Optionally, the first completion module 202 is configured to:
[0123] The first context information where the erroneous words or sentences are located and the second context information where the missing information is located are analyzed by using the pre-learned language knowledge and grammar rules, and a replacement vocabulary is generated according to the first context information, and a complete vocabulary or sentence is generated according to the second context information.
[0124] Optionally, the system further includes a second training module, wherein the second training module is configured to:
[0125] Constructing a third neural network as a second generator, wherein the third neural network is capable of receiving text data as input and generating a text completion solution;
[0126] Constructing a fourth neural network as a second discriminator, wherein the fourth neural network is capable of evaluating the consistency between the generated text completion solution and the real text;
[0127] Iteratively training the second generator and the second discriminator until both the second generator and the second discriminator meet a second preset requirement;
[0128] The preset second generative adversarial network model is constructed by the second generator and the second discriminator.
[0129] Optionally, the second completion module 203 is configured to:
[0130] For the target completion scheme, extract a second feature corresponding to the preset rule, the preset rule includes a grammatical rule, a semantic rule, a vocabulary matching rule and an information integrity rule, the second feature includes a vocabulary feature, a syntactic feature and a semantic feature, and the target completion scheme is any one of the multiple completion schemes;
[0131] The sub-score corresponding to each rule is calculated according to the feature, and a plurality of sub-scores are weighted and summed to obtain the rationality score of the target completion solution.
[0132] It should be noted that: when the device provided in the above embodiment realizes its function, only the division of the above functional modules is used as an example. In actual application, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the device and method embodiments provided in the above embodiment belong to the same concept, and the specific implementation process is detailed in the method embodiment, which will not be repeated here.
[0133] This embodiment also discloses an electronic device, referring to Figure 3 The electronic device may include: at least one processor 301 , at least one communication bus 302 , a user interface 303 , a network interface 304 , and at least one memory 305 .
[0134] The communication bus 302 is used to realize the connection and communication between these components.
[0135] The user interface 303 may include a display screen (Display) and a camera (Camera). Optionally, the user interface 303 may also include a standard wired interface and a wireless interface.
[0136] The network interface 304 may optionally include a standard wired interface or a wireless interface (such as a WI-FI interface).
[0137] Among them, the processor 301 may include one or more processing cores. The processor 301 uses various interfaces and lines to connect various parts in the entire server, and executes various functions of the server and processes data by running or executing instructions, programs, code sets or instruction sets stored in the memory 305, and calling data stored in the memory 305. Optionally, the processor 301 can be implemented in at least one hardware form of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), and programmable logic array (Programmable Logic Array, PLA). The processor 301 can integrate one or a combination of a central processing unit 301 (Central Processing Unit, CPU), an image processor 301 (Graphics Processing Unit, GPU) and a modem. Among them, the CPU mainly processes the operating system, user interface and application programs; the GPU is responsible for rendering and drawing the content to be displayed on the display screen; and the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 301, and it can be implemented separately through a chip.
[0138] Among them, the memory 305 may include a random access memory 305 (Random Access Memory, RAM), and may also include a read-only memory 305 (Read-Only Memory). Optionally, the memory 305 includes a non-transitory computer-readable storage medium. The memory 305 can be used to store instructions, programs, codes, code sets or instruction sets. The memory 305 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the above-mentioned various method embodiments, etc.; the data storage area may store data involved in the above-mentioned various method embodiments, etc. The memory 305 may also be at least one storage device located away from the aforementioned processor 301. As shown in the figure, the memory 305 as a computer storage medium may include an operating system, a network communication module, a user interface module, and an application program for a method for data processing based on a large language model.
[0139] exist Figure 3In the electronic device shown, the user interface 303 is mainly used to provide an input interface for the user and obtain data input by the user; and the processor 301 can be used to call the application program stored in the memory 305 for the method of performing data processing based on a large language model. When executed by one or more processors 301, the electronic device executes one or more methods in the above-mentioned embodiments.
[0140] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the order of the actions described, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required for the present application.
[0141] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0142] In the several embodiments provided in this application, it should be understood that the disclosed devices can be implemented in other ways. For example, the device embodiments described above are only schematic, such as the division of units, which is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some service interfaces, and the indirect coupling or communication connection of devices or units can be electrical or other forms.
[0143] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0144] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0145] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable memory 305. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a memory 305 and includes several instructions for a computer device (which can be a personal computer, server or network device, etc.) to perform all or part of the steps of the various embodiments of the present application. The aforementioned memory 305 includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk.
[0146] The above is only an exemplary embodiment of the present disclosure, and the scope of the present disclosure cannot be limited thereto. That is, any equivalent changes and modifications made according to the teachings of the present disclosure are still within the scope of the present disclosure. After considering the disclosure of the specification and the truth of practice, it will be easy for those skilled in the art to think of other embodiments of the present disclosure. This application is intended to cover any modification, use or adaptation of the present disclosure, which follows the general principles of the present disclosure and includes common knowledge or customary technical means in the technical field that are not recorded in the present disclosure. The description and examples are regarded as exemplary only, and the scope and spirit of the present disclosure are defined by the claims.
Claims
1. A method for data processing based on a large language model, characterized in that: Applied to a data processing platform, the method comprises: When an original image is received, a target image is generated according to the original image using a preset first generative adversarial network model, and a preset OCR model is used to recognize the target image to extract first text data; Comparing the first text data with a preset standard text rule to determine errors or omissions, and using a preset large language model to perform preliminary text completion on the first text data according to the errors or omissions to obtain second text data; Generate multiple completion schemes according to the second text data by presetting a second generative adversarial network model, and calculate rationality scores of the multiple completion schemes according to preset rules; The second text data is completed according to a first completion scheme, wherein the first completion scheme is a completion scheme with the highest rationality score among the plurality of completion schemes, The using a preset large language model to perform preliminary text completion on the first text data according to the error or omission to obtain the second text data includes: Analyze the first context information where the incorrect word or sentence is located and the second context information where the missing information is located by using the pre-learned language knowledge and grammar rules, generate a replacement word according to the first context information, and generate a complete word or sentence according to the second context information, Calculating the rationality scores of the plurality of completion solutions according to the preset rules includes: For the target completion scheme, extract a second feature corresponding to the preset rule, the preset rule includes a grammatical rule, a semantic rule, a vocabulary matching rule and an information integrity rule, the second feature includes a vocabulary feature, a syntactic feature and a semantic feature, and the target completion scheme is any one of the multiple completion schemes; The sub-score corresponding to each rule is calculated according to the feature, and a plurality of sub-scores are weighted and summed to obtain the rationality score of the target completion solution.
2. The method for data processing based on a large language model according to claim 1, characterized in that: The method further comprises: constructing a first neural network as a first generator, the first neural network being capable of receiving random noise as input and generating image data; Constructing a second neural network as a first discriminator, wherein the second neural network is capable of distinguishing whether an input image is a real image or a generated image; Iteratively training the first generator and the first discriminator until both the first generator and the first discriminator meet a first preset requirement; The preset first generative adversarial network model is constructed by the first generator and the first discriminator.
3. The method for data processing based on a large language model according to claim 2, characterized in that: The iterative training of the first generator and the first discriminator until both the first generator and the first discriminator meet the first preset requirement comprises: Fixing the parameters of the first generator, training the first discriminator to distinguish between real images and generated images, and updating the parameters of the first discriminator according to the discrimination result of the first discriminator; Fixing the parameters of the first discriminator, training the first generator to generate images, and updating the parameters of the first generator according to the quality judgment score of the images; The first generator and the first discriminator are trained alternately until a preset number of iterations is reached or the performance converges.
4. The method for data processing based on a large language model according to claim 1, characterized in that: The using a preset OCR model to recognize the target image to extract the first text data comprises: Dividing the target image into a plurality of regions of the same size, and calculating statistics of each region respectively, wherein the statistics include average brightness and contrast; A threshold is calculated according to the statistics of the target area, and a pixel block in the target area whose pixel value is greater than or equal to the threshold is set to a first color, and a pixel block in the target area whose pixel value is less than the threshold is set to a second color, wherein the target area is any one of the multiple areas of the same size; Characters in the target image are recognized according to the first color and the second color, a first feature of the character is extracted, a text label is matched according to the first feature, and first text data is generated according to the text label.
5. The method for data processing based on a large language model according to claim 1, characterized in that: The method further comprises: Constructing a third neural network as a second generator, wherein the third neural network is capable of receiving text data as input and generating a text completion solution; Constructing a fourth neural network as a second discriminator, wherein the fourth neural network is capable of evaluating the consistency between the generated text completion solution and the real text; Iteratively training the second generator and the second discriminator until both the second generator and the second discriminator meet a second preset requirement; The preset second generative adversarial network model is constructed by the second generator and the second discriminator.
6. A system for data processing based on a large language model, characterized in that: It includes an image processing module, a first completion module, a second completion module and a completion execution module, wherein: An image processing module is configured to, when receiving an original image, generate a target image based on the original image using a preset first generative adversarial network model, and recognize the target image using a preset OCR model to extract first text data; A first completion module is configured to compare the first text data with a preset standard text rule to determine errors or omissions, and use a preset large language model to perform preliminary text completion on the first text data according to the errors or omissions to obtain second text data; A second completion module is configured to generate a plurality of completion schemes according to the second text data by using a preset second generative adversarial network model, and calculate rationality scores of the plurality of completion schemes according to preset rules; a completion execution module, configured to complete the second text data according to a first completion scheme, wherein the first completion scheme is a completion scheme with the highest rationality score among the plurality of completion schemes, The using a preset large language model to perform preliminary text completion on the first text data according to the error or omission to obtain the second text data includes: Analyze the first context information where the incorrect word or sentence is located and the second context information where the missing information is located by using the pre-learned language knowledge and grammar rules, generate a replacement word according to the first context information, and generate a complete word or sentence according to the second context information, Calculating the rationality scores of the plurality of completion solutions according to the preset rules includes: For the target completion scheme, extract a second feature corresponding to the preset rule, the preset rule includes a grammatical rule, a semantic rule, a vocabulary matching rule and an information integrity rule, the second feature includes a vocabulary feature, a syntactic feature and a semantic feature, and the target completion scheme is any one of the multiple completion schemes; The sub-score corresponding to each rule is calculated according to the feature, and a plurality of sub-scores are weighted and summed to obtain the rationality score of the target completion solution.
7. An electronic device, characterized in that: It includes a processor, a memory, a user interface and a network interface, the memory is used to store instructions, the user interface and the network interface are both used to communicate with other devices, and the processor is used to execute the instructions stored in the memory so that the electronic device executes the method as described in any one of claims 1-5.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions, and when the instructions are executed, the method according to any one of claims 1 to 5 is performed.
Citation Information
Patent Citations
Automatic text generation method and device
CN108334497A
Semantic completion method and device and electronic equipment
CN111475635A
