Electric power communication character extraction method and device, storage medium and computer equipment

By compressing the preset text extraction model, filtering redundant attention heads and quantizing parameters, and constructing a lightweight model, the problems of low efficiency and high error rate in power communication text extraction are solved, achieving efficient automatic extraction and accurate extraction.

CN121236740AInactive Publication Date: 2025-12-30EAST CHINA BRANCH OF STATE GRID CORP
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511057066.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-30
Publication Date
2025-12-30
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Existing technologies for extracting text from power communication systems are inefficient and prone to errors. Manual extraction is time-consuming and labor-intensive, and errors can occur due to oversight.

Method used

A pre-defined text extraction model is used for compression processing, including a denoising layer, a multi-head self-attention layer, and a feedforward network layer. Redundant attention heads are filtered out by training on a sample dataset and using a constrained loss function. Combined with parameter quantization and mixed precision quantization, a lightweight model is constructed to improve extraction efficiency and accuracy.

Benefits of technology

It enables efficient and automatic extraction of text from power communication systems, improving extraction efficiency and accuracy while reducing computational resource requirements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121236740A_ABST
    Figure CN121236740A_ABST
Patent Text Reader

Abstract

The invention discloses an electric power communication character extraction method and device, a storage medium and computer equipment, relates to the technical field of character information extraction, and mainly aims to improve the extraction efficiency and extraction precision of electric power communication characters. The method comprises the following steps: acquiring a to-be-identified electric power communication text image; obtaining a preset character extraction model, and performing compression processing on the preset character extraction model to obtain the compressed preset character extraction model; and inputting the to-be-identified electric power communication text image into the compressed preset character extraction model for character extraction to obtain characters corresponding to the to-be-identified electric power communication text image. The method is suitable for the scene of extracting the electric power communication characters.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of text information extraction technology, and in particular to a method, apparatus, storage medium, and computer equipment for extracting text in power communication. Background Technology

[0002] As the "nerve center" of the smart grid, the power communication network carries critical services such as real-time control, dispatch automation, and relay protection of the power system. Its reliability directly affects the safe and stable operation of the power system. Given the characteristics of power communication networks, including multi-service integration, high reliability, and strong security, a communication management system covering the entire business system and its entire lifecycle needs to be established. This system should combine preventative maintenance, condition-based operation management, intelligent operation and maintenance, and dynamic mode verification to ensure that network resources are always in a healthy and available state. Currently, to meet the increasingly diverse needs of users, the structure of power communication systems is becoming increasingly complex, requiring efficient management. To improve the efficiency of the power communication management system, it is necessary to digitize and structure unstructured data such as scanned copies of channel verification forms, PDF versions of "three measures and one plan," documents containing graphical routing diagrams, and on-site images. This facilitates the storage of relevant data and the system's intelligent analysis of the data. In power communication operation and management, verification forms and "three measures and one plan" documents are typically in the form of scanned PDF copies, along with documents containing graphical routing diagrams and on-site images. To improve the informatization level of the power communication management system, it is necessary to convert image data into text data and integrate it into the power communication management system.

[0003] Currently, text is typically extracted from images manually. However, this manual extraction method is time-consuming and labor-intensive, and errors can occur due to staff negligence. Summary of the Invention

[0004] This invention provides a method, apparatus, storage medium, and computer equipment for extracting text from power communication, which mainly improves the extraction efficiency and accuracy of text from power communication.

[0005] According to a first aspect of the present invention, a method for extracting text in power communication is provided, comprising:

[0006] Acquire the image of the power communication text to be identified;

[0007] Obtain a preset text extraction model and compress the preset text extraction model to obtain the compressed preset text extraction model;

[0008] The power communication text image to be identified is input into the compressed preset text extraction model to extract the text, thereby obtaining the text corresponding to the power communication text image to be identified.

[0009] Optionally, the preset text extraction model includes an encoder and a decoder. The encoder includes a denoising layer, a first multi-head self-attention layer, and a first feedforward network layer. The decoder includes a mask multi-head self-attention layer, a second multi-head self-attention layer, and a second feedforward network layer.

[0010] The preset text extraction model is compressed to obtain the compressed preset text extraction model, including:

[0011] Obtain a sample compressed dataset, wherein the sample compressed dataset includes sample power images and the actual text annotation information corresponding to the sample power images. Input the sample power images into the preset text extraction model for forward propagation. During the forward propagation process, determine the input data and output data of each network layer in the preset text extraction model, and determine the weight matrix of each attention head in the first multi-head self-attention layer.

[0012] Based on the output data of the last network layer in the preset text extraction model and the actual text annotation information, the loss function of the preset text extraction model is determined, and based on each weight matrix, function constraint terms are determined, and the function constraint terms are used to constrain the loss function to obtain the constrained loss function.

[0013] Based on the constraint loss function, the preset text extraction model is trained, and the constraint weight matrix of each attention head is determined during the training process.

[0014] Determine the proportion of elements in the constraint weight matrix of each attention head that are less than a preset threshold. Based on the proportion of elements, filter out redundant attention heads in each attention head and remove the redundant attention heads in the first multi-head self-attention layer to obtain the compressed first multi-head self-attention layer.

[0015] A diagonal matrix is ​​introduced into the compressed first multi-head self-attention layer to obtain a compressed mask multi-head self-attention layer. The parameters of the compressed first multi-head self-attention layer are reused in the second multi-head self-attention layer to obtain a parameter-reused second multi-head self-attention layer. The preset text extraction model with the compressed first multi-head self-attention layer, the compressed mask multi-head self-attention layer, and the parameter-reused second multi-head self-attention layer is used as the compressed preset text extraction model.

[0016] Optionally, based on each of the weight matrices, the function constraint terms are determined, including:

[0017] Determine the total number H of attention heads in the first multi-head self-attention layer, and based on the total number H of attention heads and the weight matrix A of each attention head i...i Determine the function constraint term L constraint ,in, λ is the regularization coefficient.

[0018] Optionally, the loss function is constrained using the function constraint terms to obtain a constrained loss function, including:

[0019] The loss function is constrained by the aforementioned function constraint terms to obtain the constrained loss function L. total ,in, L original Let be the loss function.

[0020] Optionally, the preset text extraction model is compressed to obtain a compressed preset text extraction model, including:

[0021] The parameter sensitivity of each network layer in the preset text extraction model is determined, and based on the parameter sensitivity, each network layer is divided into sensitive layers and non-sensitive layers.

[0022] The parameters of the sensitive layer are quantized using 16-bit floating-point quantization, and the parameters of the non-sensitive layer are quantized using 8-bit integer quantization. The final quantized preset text extraction model is used as the compressed preset text extraction model.

[0023] Optionally, the preset text extraction model is compressed to obtain a compressed preset text extraction model, including:

[0024] An initial lightweight text extraction model is constructed, wherein the initial lightweight text extraction model includes a lightweight image feature extraction module and a lightweight text extraction module;

[0025] Obtain the lightweight power communication text image required for lightweighting the preset text extraction model;

[0026] Based on the lightweight power communication text image, the differences in image feature extraction between the encoder in the preset text extraction model and the lightweight image feature extraction module, as well as the differences in text extraction between the decoder in the preset text extraction model and the lightweight text extraction module are determined.

[0027] Based on the differences in image feature extraction, a feature extraction loss function is determined, and based on the differences in text extraction, a text extraction loss function is determined.

[0028] Based on the feature extraction loss function and the text extraction loss function, a joint loss function is determined, and based on the joint loss function, the initial lightweight text extraction model is iteratively trained to obtain the compressed preset text extraction model.

[0029] Optionally, before obtaining the preset text extraction model, the method further includes:

[0030] Construct a pre-defined initial text extraction model;

[0031] Obtain a sample dataset, wherein the sample dataset includes sample power communication images with annotation information, wherein the annotation information is text in the sample power communication images;

[0032] The sample dataset is divided into a training set, a validation set, and a test set. The preset initial text extraction model is trained using the training set, validated using the validation set, and tested using the test set. Finally, the validated preset initial text extraction model that meets the test conditions is taken as the preset text extraction model.

[0033] According to a second aspect of the present invention, an apparatus for extracting text from electrical communications is provided, comprising:

[0034] The acquisition unit is used to acquire the power communication text image to be identified;

[0035] A compression unit is used to acquire a preset text extraction model and compress the preset text extraction model to obtain the compressed preset text extraction model.

[0036] The text extraction unit is used to input the power communication text image to be identified into the compressed preset text extraction model to extract the text and obtain the text corresponding to the power communication text image to be identified.

[0037] According to a third aspect of the present invention, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the above-described method for extracting electrical communication text.

[0038] According to a fourth aspect of the present invention, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the above-described method for extracting electrical communication text.

[0039] According to the present invention, a method, apparatus, storage medium, and computer device for extracting text from power communication images are provided. Compared with the current method of manually extracting text from power communication images, the present invention obtains a preset text extraction model, compresses the preset text extraction model, and finally uses the compressed preset text extraction model to extract the text from the power communication text image to be recognized. Thus, automatically extracting text from the power communication text image to be recognized using a model can improve the efficiency and accuracy of text extraction. Furthermore, the embodiments of the present invention, by compressing the preset text extraction model, significantly reduce the number of model parameters and computational load, thereby further improving text extraction efficiency and solving computational resource constraints. Attached Figure Description

[0040] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this application, illustrate exemplary embodiments of the invention and, together with their description, serve to explain the invention and do not constitute an undue limitation thereof. In the drawings:

[0041] Figure 1 A flowchart of a method for extracting text from power communication provided by an embodiment of the present invention is shown;

[0042] Figure 2 This diagram illustrates the structure of a preset text extraction model provided in an embodiment of the present invention.

[0043] Figure 3 This diagram illustrates a multi-head self-attention layer structure provided by an embodiment of the present invention.

[0044] Figure 4 A flowchart of another method for extracting text from power communication provided by an embodiment of the present invention is shown;

[0045] Figure 5 A schematic diagram of the structure of a device for extracting text from power communication according to an embodiment of the present invention is shown;

[0046] Figure 6 A schematic diagram of another device for extracting text from power communication provided in an embodiment of the present invention is shown;

[0047] Figure 7 A schematic diagram of the physical structure of a computer device provided in an embodiment of the present invention is shown. Detailed Implementation

[0048] The present invention will be described in detail below with reference to the accompanying drawings and embodiments. It should be noted that, unless otherwise specified, the embodiments and features described in the present application can be combined with each other.

[0049] Currently, manually extracting text messages from power communications is time-consuming and labor-intensive, and errors can occur due to staff negligence.

[0050] To address the aforementioned problems, embodiments of the present invention provide a method for extracting text from power communication systems, such as... Figure 1 As shown, the method includes:

[0051] 101. Obtain the image of the power communication text to be identified.

[0052] Among them, the power communication text images to be identified can be scanned copies of channel verification forms, three measures and one plan (pdf format) collected from different regions and periods, and documents containing graphical routing. They should also include on-site pictures, which may have serious stains, creases, and pictures taken under different lighting conditions such as strong light, weak light or shadow, and using equipment with different resolutions.

[0053] 102. Obtain the preset text extraction model and compress it to obtain the compressed preset text extraction model.

[0054] Among them, such as Figure 2 As shown, the preset text extraction model includes an encoder and a decoder. The encoder includes a denoising layer, a multi-head self-attention layer, and a feed-forward network layer. The decoder mainly consists of three modules: a mask multi-head self-attention layer, a multi-head self-attention layer, and a feed-forward network layer.

[0055] In this embodiment of the invention, to save computing resources and improve model processing speed, the model first needs to be compressed. Therefore, step 102 includes: obtaining a compressed sample dataset, wherein the compressed sample dataset includes sample power images and corresponding actual text annotation information; inputting the sample power images into the preset text extraction model for forward propagation; determining the input data and output data of each network layer in the preset text extraction model during the forward propagation process, and determining the weight matrix of each attention head in the first multi-head self-attention layer; determining the loss function of the preset text extraction model based on the output data of the last network layer and the actual text annotation information; determining function constraint terms based on each weight matrix; and using the function constraint terms to constrain the loss function to obtain a constrained loss function; based on the constraint... The text extraction model is trained using a bundle loss function. During training, the constraint weight matrix of each attention head is determined. The proportion of elements in the constraint weight matrix of each attention head that are less than a preset threshold is determined. Based on the proportion of elements, redundant attention heads are selected from each attention head, and the redundant attention heads in the first multi-head self-attention layer are removed to obtain a compressed first multi-head self-attention layer. A diagonal matrix is ​​introduced into the compressed first multi-head self-attention layer to obtain a compressed mask multi-head self-attention layer. The parameters of the compressed first multi-head self-attention layer are reused in the second multi-head self-attention layer to obtain a parameter-reused second multi-head self-attention layer. The preset text extraction model with the compressed first multi-head self-attention layer, the compressed mask multi-head self-attention layer, and the parameter-reused second multi-head self-attention layer is used as the compressed preset text extraction model. The method for determining the function constraint term includes: determining the total number H of attention heads in the first multi-head self-attention layer, and based on the total number H of attention heads and the weight matrix A of each attention head i... i Determine the function constraint term L constraint ,in, λ is the regularization coefficient. The method for determining the constraint loss function includes: constraining the loss function using the function constraint terms to obtain the constraint loss function L. total ,in, L original Let be the loss function.

[0056] Specifically, the sample power images are first input into a pre-defined text extraction model, which then outputs predicted text. Based on the difference between the predicted text and the actual text annotations corresponding to the sample power images, the loss function of the pre-defined text extraction model (such as mean squared error loss function, cross-entropy loss function, etc.) is determined. Simultaneously, during the forward propagation process of the sample power images into the pre-defined text extraction model, when propagating to the first multi-head self-attention layer, each attention head in the first multi-head self-attention layer independently calculates a weight matrix. Then, based on the weight matrix, a function constraint term is calculated and added to the loss function to obtain the constraint loss. The loss function is then used, and based on the constraint loss function, the preset text extraction model is trained again. This involves inputting another sample power image into the network layers of the preset text extraction model for forward propagation. During propagation, the weight matrix (constraint weight matrix) of each attention head in the first multi-head self-attention layer is determined again. In each element of the constraint weight matrix, the ratio (element proportion) of elements smaller than a preset threshold (set according to actual needs) is determined. Attention heads smaller than the preset proportion threshold are identified as redundant attention heads, and these redundant attention heads in the first multi-head self-attention layer are removed. Figure 3 As shown, the compressed first multi-head self-attention layer is obtained. The parameters of the compressed first multi-head self-attention layer are reused in the decoder's multi-head self-attention layer. Simultaneously, the compression of the multi-head self-attention layer mainly focuses on compressing the Q and K of the self-attention. Assuming the compression factor is T, then... V∈R H×W×C .

[0057] The calculation of the self-attention mechanism is as follows:

[0058] att = cor × V

[0059]

[0060] Where Q is the query matrix, and the dimension of Q is... K is the key matrix, and the dimension of K is...

[0061] cor is the correlation matrix, V is the value matrix, and the dimension of V is R. H×W×C d kHere, Q represents the dimension of the key vector, softmax is the activation function, H represents the number of training samples, W represents the image width or input sequence length, C represents the feature dimension, and T is the compression ratio. When Q and K are compressed simultaneously, the dimension of the correlation coefficient cor remains unchanged, thus achieving model compression and reducing computational cost. Furthermore, the feed-forward network layer mainly consists of two linear functions. The masked multi-head self-attention layer is essentially a multi-head self-attention layer multiplied by a diagonal matrix, ensuring the rationality of model training.

[0062] This invention employs regularization to dynamically filter redundant attention heads in a multi-head self-attention layer. During model training, regularization constraints are introduced to identify unnecessary heads with low contribution to semantic modeling based on the sparsity distribution of the output weights of each attention head, retaining 80% of the core attention heads. This core head set covers the ability to capture key semantic features in power communication documents, such as the association of technical terms and table structure dependencies. By pruning redundant heads, the computational units of the self-attention layer are effectively reduced, lowering model complexity at the network structure level while maintaining the integrity of contextual semantic modeling.

[0063] In another embodiment of the present invention, the preset text extraction model can be compressed in the following way: determine the parameter sensitivity of each network layer in the preset text extraction model, divide each network layer into sensitive layer and non-sensitive layer based on the parameter sensitivity; quantize the parameters of the sensitive layer using 16-bit floating-point quantization, and quantize the parameters of the non-sensitive layer using 8-bit integer quantization, and finally use the preset text extraction model after parameter quantization as the compressed preset text extraction model.

[0064] Specifically, during the training process of the preset text extraction model, the parameter sensitivity of each network layer is calculated through backpropagation. Based on this, the method includes: acquiring a first set of sample power images with annotation information, wherein the annotation information is text in the sample power images; inputting the first sample power images into the preset text extraction model for forward propagation, and determining the input data and output data of each network layer in the preset text extraction model during the forward propagation process; determining the loss function of the preset text extraction model based on the output data of the last network layer in the preset text extraction model and the corresponding text in the first sample power images; taking any network layer in the preset text extraction model except the last network layer as a current network layer, determining the partial derivative of the loss function with respect to the output data of the next network layer corresponding to the current network layer, and determining the next network layer... The activation derivative of the activation function at the input data of the next network layer is calculated; the partial derivative of the loss of the output data of the next network layer is multiplied by the activation derivative at the input data of the next network layer to obtain the partial derivative of the loss function with respect to the input data of the next network layer; the activation derivative of the activation function of the current network layer at the input data of the current network layer is determined, multiplied by the partial derivative of the loss of the input data of the next network layer, and the product is multiplied by the transpose of the weights of the next network layer to obtain the partial derivative of the loss function with respect to the input data of the current network layer; the transpose of the output data of the current network layer is multiplied by the partial derivative of the loss of the input data of the next network layer to obtain the parameter sensitivity of the next network layer; the transpose of the first sample power image is multiplied by the partial derivative of the loss of the input data of the current network layer to obtain the parameter sensitivity of the current network layer. Therefore, the sensitivity of each network layer (denoising layer, first multi-head self-attention layer, first feedforward network layer, mask multi-head self-attention layer, second multi-head self-attention layer, and second feedforward network layer) in the preset text extraction model can be determined in the above manner.

[0065] Furthermore, network layers with parameter sensitivity greater than a preset sensitivity threshold (set according to actual needs) are designated as sensitive layers, while those with parameter sensitivity less than or equal to the preset threshold are designated as non-sensitive layers. FP16 (16-bit floating-point) adopts the standard half-precision floating-point format, including 1 sign bit, 5 exponent bits, and 10 mantissa bits. Mapping the FP32 parameters of the sensitive layers to FP16 reduces storage and computational overhead while preserving parameter precision information as much as possible. Directly converting the parameter matrix of the sensitive layers to FP16 format achieves quantization of the sensitive layer parameters. In practical applications, 16-bit floating-point quantization can be implemented using the `tensor.half()` method. Meanwhile,

[0066] The maximum and minimum values ​​of parameters in insensitive layers are statistically analyzed. Based on symmetric or asymmetric quantization, scaling factors and zeros are determined. Floating-point parameters of insensitive layers are then quantized from FP32 to INT8 based on these scaling factors and zeros. In practical applications, the `torch.quantize_per_tensor` function can be used for 8-bit integer parameter quantization. Model parameter numerical optimization is then performed using FP16 / INT8 mixed-precision quantization. After model training, weight parameters in the network are processed hierarchically: sensitive layers affecting model accuracy (such as multi-head self-attention layers and feedforward layers) are represented using FP16 half-precision floating-point to ensure numerical computation stability; computationally intensive but less precision-sensitive layers (such as position embedding layers and nonlinear activation layers) are converted to INT8 integer representation. Through this mixed-precision strategy, while maintaining a controllable numerical parameter error rate, the model size is compressed to 1 / 4 of its original size, significantly reducing storage costs and GPU memory usage during inference, and improving computational efficiency.

[0067] 103. Input the power communication text image to be identified into the compressed preset text extraction model to extract the text and obtain the text corresponding to the power communication text image to be identified.

[0068] Specifically, the power communication text image to be identified is first segmented into uniformly sized small blocks. Each block is then added to its corresponding location embedding information. The resulting feature contains not only semantic information but also positional information. This feature serves as the input to the encoder in the pre-defined text extraction model. After the power communication text image is input into the compressed pre-defined text extraction model, the input data first passes through a denoising layer. This denoising layer primarily selects the smallest feature value in the channel dimension of the feature and sets it to zero. This operation effectively reduces the impact of noise on the calculation of global correlation, thereby improving the model's performance. The shape of the feature remains unchanged after the denoising module. The denoised image then undergoes the combined action of a first multi-head self-attention layer, a first feedforward network layer, a masked multi-head self-attention layer, a second multi-head self-attention layer, and a second feedforward network layer to extract the text content from the power communication text image. This invention uses a model to automatically extract text from power communication text images, which can improve the efficiency and accuracy of text extraction. At the same time, this invention compresses the preset text extraction model, which significantly reduces the number of model parameters and computational load, thereby further improving text extraction efficiency and solving computational resource issues.

[0069] According to the present invention, a method for extracting text from power communication images, compared with the current method of manually extracting text from power communication images, involves obtaining a preset text extraction model, compressing the preset text extraction model, and finally using the compressed preset text extraction model to extract the text from the power communication text image to be recognized. This method automatically extracts text from the power communication text image using a model, improving the efficiency and accuracy of text extraction. Furthermore, by compressing the preset text extraction model, the number of model parameters and computational load are significantly reduced, further improving text extraction efficiency and solving computational resource constraints.

[0070] Furthermore, to better illustrate the above process of extracting text from power communication systems, as a refinement and extension of the above embodiments, this invention provides another method for extracting text from power communication systems, such as... Figure 4 As shown, the method includes:

[0071] 201. Obtain the image of the power communication text to be identified.

[0072] Specifically, the power communication text image to be identified can be obtained from the power system's database.

[0073] 202. Construct a preset initial text extraction model.

[0074] 203. Obtain the sample dataset, which includes sample power communication images with annotation information, where the annotation information is the text in the sample power communication images.

[0075] 204. Divide the sample dataset into a training set, a validation set, and a test set. Use the training set to train the preset initial text extraction model, use the validation set to validate the trained preset initial text extraction model, and use the test set to test the validated preset initial text extraction model. Finally, use the validated preset initial text extraction model that meets the test conditions as the preset text extraction model.

[0076] For this embodiment of the invention, the model architecture of the preset initial text extraction model is the same as that of the preset text extraction model. To ensure that the dataset can comprehensively reflect the diversity of power communication operation and management documents, in addition to scanning copies of channel verification forms, "three measures and one plan" (PDF format), and documents containing graphical routing from different regions and periods, special attention should be paid to samples with special circumstances. For example, for on-site image data, there may be severe stains, creases, and images taken under different lighting conditions such as strong light, weak light, or shadow, and using equipment with different resolutions; all of these need to be collected extensively. At the same time, we cooperate with power communication companies to obtain various document images from their actual business scenarios to ensure the authenticity and practicality of the data. Afterwards, the collected images are manually annotated, and the text content is marked to provide accurate labels for model training. In the data annotation process, a multi-person annotation and cross-validation method is adopted. For each image, multiple annotators annotate it separately, and the annotation content covers the text content, table structure (including table header, row title, column title, cell merging, etc.), paragraph division, special symbols, and the location and content (if any) of handwritten text and seals. After annotation, cross-validation is used to check the consistency of the annotation results. For annotations with discrepancies, an expert team reviews and corrects them to ensure accuracy and consistency, providing reliable labels for model training. During model training, a pre-defined initial text extraction model is first built, followed by downloading a sample dataset from the internet. The dataset is ensured to contain all necessary files, including various power communication images. The annotation files are converted to a format understandable by the pre-defined initial text extraction model. Finally, the model is trained, validated, and tested. Specifically, the dataset can be partitioned first: using random or specific strategies (such as stratified sampling), the sample dataset is divided into training, validation, and test sets. For example, the labeled dataset can be divided into training, validation, and test sets according to a certain ratio for model training, parameter tuning, and performance evaluation. To balance "sufficiency of training data," "reliability of the validation process," and "objectivity of test evaluation," and considering model complexity, the labeled dataset can be divided into training, validation, and test sets in a 7:2:1 ratio. During the partitioning process, data balance is fully considered to ensure a reasonable distribution of different document types (channel verification forms, three measures and one plan) and different document characteristics (such as clarity versus fuzziness, presence or absence of handwriting and seals) across each subset, avoiding data bias that could negatively impact model training and evaluation. The model is then trained using the training set, validated using the validation set, and tested using the test set to evaluate its performance on unseen data. Metrics such as mCP, precision, and recall on the test set are calculated and recorded. If the model performance does not meet requirements, it can return to the training phase for further iterations or adjustments. This process yields a pre-defined text extraction model that meets the requirements.

[0077] 205. Compress the preset text extraction model to obtain the compressed preset text extraction model.

[0078] In this embodiment of the invention, after obtaining and constructing the preset text extraction model, it is also necessary to compress the preset text extraction model. Therefore, step 205 specifically includes: constructing an initial lightweight text extraction model, wherein the initial lightweight text extraction model includes a lightweight image feature extraction module and a lightweight text extraction module; obtaining a lightweight power communication text image required for lightweighting the preset text extraction model; based on the lightweight power communication text image, determining the image feature extraction difference between the encoder and the lightweight image feature extraction module in the preset text extraction model, and the text extraction difference between the decoder and the lightweight text extraction module in the preset text extraction model; based on the image feature extraction difference, determining a feature extraction loss function, and based on the text extraction difference, determining a text extraction loss function; based on the feature extraction loss function and the text extraction loss function, determining a joint loss function, and based on the joint loss function, iteratively training the initial lightweight text extraction model to obtain the compressed preset text extraction model.

[0079] Specifically, a lightweight power communication text image is acquired. During the model lightweighting process, the encoder in the preset text extraction model extracts the first image features of the lightweight power communication text image, and the lightweight image feature extraction module extracts the second image features of the lightweight power communication text image. The difference between the two image features is determined, and a feature extraction loss function is determined based on this difference. Then, the decoder extracts the text from the first image features, and the lightweight text extraction module extracts the text from the second image features. Based on the difference between the two text features, a text extraction loss function is determined, and weight coefficients corresponding to the feature extraction loss function and the text extraction loss function are determined respectively. Based on the weight coefficients, the feature extraction loss function and the text extraction loss function are added to obtain a joint loss function. Finally, the initial lightweight text extraction model is iteratively trained using the joint loss function to obtain the compressed preset text extraction model. This embodiment of the invention, by lightweighting the model, can save computational resources in the text extraction process, reduce energy consumption, improve text extraction efficiency, and reduce the complexity of text extraction.

[0080] 206. Input the power communication text image to be identified into the compressed preset text extraction model to extract the text and obtain the text corresponding to the power communication text image to be identified.

[0081] Specifically, the power communication text image to be identified is input into a compressed preset text extraction model, which then directly outputs the text from the image. In this embodiment, a parameter sharing strategy is used in the multi-layer attention modules of the encoder and decoder to reuse attention matrices across different layers. Specifically, attention layers with symmetrical structures (such as the i-th and i+2-th layers of the encoder) share the same set of attention parameters, avoiding redundant storage of matrix parameters with the same function. During inference, shared parameters are dynamically invoked for cross-layer calculations, reducing the computational load of cross-layer processing and further optimizing model efficiency. The aforementioned multi-level parameter compression technology forms a collaborative optimization system: a structural optimization layer prunes redundant computational units, a numerical optimization layer reduces parameter storage precision, a lightweight architecture layer reduces network depth, and a dynamic sharing mechanism avoids redundant calculations. Through the combined effect of these four elements, without affecting the model's ability to extract key information from documents in the power communication field, the number of model parameters and computational overhead are systematically reduced, providing a feasible technical solution for real-time inference of power communication management systems in lightweight scenarios such as edge computing devices and mobile terminals.

[0082] According to another method for extracting text from power communication images provided by this invention, compared with the current method of manually extracting text from power communication images, this invention obtains a preset text extraction model, compresses the preset text extraction model, and finally uses the compressed preset text extraction model to extract the text from the power communication text image to be recognized. Thus, automatically extracting text from the power communication text image to be recognized using a model can improve the efficiency and accuracy of text extraction. Furthermore, by compressing the preset text extraction model, the number of model parameters and computational load are significantly reduced, thereby further improving text extraction efficiency and solving computational resource constraints.

[0083] Furthermore, as Figure 1 In a specific implementation, embodiments of the present invention provide a device for extracting text from power communication systems, such as... Figure 5 As shown, the device includes: an acquisition unit 31, a compression unit 32, and a text extraction unit 33.

[0084] The acquisition unit 31 can be used to acquire the power communication text image to be identified.

[0085] The compression unit 32 can be used to obtain a preset text extraction model and compress the preset text extraction model to obtain the compressed preset text extraction model.

[0086] The text extraction unit 33 can be used to input the power communication text image to be identified into the compressed preset text extraction model to extract the text and obtain the text corresponding to the power communication text image to be identified.

[0087] In specific application scenarios, the preset text extraction model includes an encoder and a decoder. The encoder includes a denoising layer, a first multi-head self-attention layer, and a first feedforward network layer. The decoder includes a masked multi-head self-attention layer, a second multi-head self-attention layer, and a second feedforward network layer. To compress the preset text extraction model, such as... Figure 6 As shown, the compression unit 32 includes a determination module 321, a constraint module 322, a training module 323, and a filtering module 324.

[0088] The determining module 321 can be used to obtain a sample compressed dataset, wherein the sample compressed dataset includes sample power images and actual text annotation information corresponding to the sample power images, input the sample power images into the preset text extraction model for forward propagation, determine the input data and output data of each network layer in the preset text extraction model during the forward propagation process, and determine the weight matrix of each attention head in the first multi-head self-attention layer.

[0089] The constraint module 322 can be used to determine the loss function of the preset text extraction model based on the output data of the last network layer in the preset text extraction model and the actual text annotation information, and to determine the function constraint terms based on each weight matrix, and to use the function constraint terms to constrain the loss function to obtain the constrained loss function.

[0090] The training module 323 can be used to train the preset text extraction model based on the constraint loss function, and determine the constraint weight matrix of each attention head during the training process.

[0091] The filtering module 324 can be used to determine the proportion of elements in the constraint weight matrix of each attention head that are less than a preset threshold. Based on the proportion of elements, redundant attention heads are filtered out in each attention head, and the redundant attention heads in the first multi-head self-attention layer are removed to obtain the compressed first multi-head self-attention layer.

[0092] The determining module 321 can also be used to introduce a diagonal matrix into the compressed first multi-head self-attention layer to obtain a compressed mask multi-head self-attention layer, reuse the parameters of the compressed first multi-head self-attention layer to the second multi-head self-attention layer to obtain a parameter-reused second multi-head self-attention layer, and use the preset text extraction model with the compressed first multi-head self-attention layer, the compressed mask multi-head self-attention layer, and the parameter-reused second multi-head self-attention layer as the compressed preset text extraction model.

[0093] In specific application scenarios, in order to determine the function constraint terms, the constraint module 322 can be used to determine the total number H of attention heads in the first multi-head self-attention layer, based on the total number H of attention heads and the weight matrix A of each attention head i. i Determine the function constraint term L constraint ,in, λ is the regularization coefficient.

[0094] In specific application scenarios, in order to constrain the loss function using function constraint terms, the constraint module 322 can be used to constrain the loss function using the function constraint terms to obtain the constrained loss function L. total ,in, L original Let be the loss function.

[0095] In specific application scenarios, in order to compress the preset text extraction model, the compression unit 32 also includes a partitioning module 325 and a parameter quantization module 326.

[0096] The partitioning module 325 can be used to determine the parameter sensitivity of each network layer in the preset text extraction model, and based on the parameter sensitivity, divide each network layer into sensitive layers and non-sensitive layers.

[0097] The parameter quantization module 326 can be used to quantize the parameters of the sensitive layer using 16-bit floating-point quantization and to quantize the parameters of the non-sensitive layer using 8-bit integer quantization. Finally, the preset text extraction model after parameter quantization is used as the compressed preset text extraction model.

[0098] In specific application scenarios, in order to compress the preset text extraction model, the compression unit 32 further includes a construction module 327, an acquisition module 328, and a training module 329.

[0099] The construction module 327 can be used to construct an initial lightweight text extraction model, wherein the initial lightweight text extraction model includes a lightweight image feature extraction module and a lightweight text extraction module.

[0100] The acquisition module 328 can be used to acquire lightweight power communication text images required for lightweighting the preset text extraction model.

[0101] The determining module 321 can also be used to determine, based on the lightweight power communication text image, the image feature extraction difference between the encoder in the preset text extraction model and the lightweight image feature extraction module, as well as the text extraction difference between the decoder in the preset text extraction model and the lightweight text extraction module.

[0102] The determining module 321 can also be used to determine a feature extraction loss function based on the differences in image feature extraction, and to determine a text extraction loss function based on the differences in text extraction.

[0103] The training module 329 can be used to determine a joint loss function based on the feature extraction loss function and the text extraction loss function, and to iteratively train the initial lightweight text extraction model based on the joint loss function to obtain the compressed preset text extraction model.

[0104] In specific application scenarios, in order to obtain a preset text extraction model, the device also includes a construction unit 34.

[0105] The construction unit 34 can be used to construct a preset initial text extraction model; obtain a sample dataset, wherein the sample dataset includes sample power communication images with annotation information, the annotation information being the text in the sample power communication images; divide the sample dataset into a training set, a validation set, and a test set; train the preset initial text extraction model using the training set; validate the trained preset initial text extraction model using the validation set; test the validated preset initial text extraction model using the test set; and finally, use the validated preset initial text extraction model that meets the test conditions as the preset text extraction model.

[0106] It should be noted that other corresponding descriptions of the functional modules involved in the power communication text extraction device provided in this embodiment of the invention can be found in the following references: Figure 1 The corresponding description of the method shown will not be repeated here.

[0107] Based on the above, Figure 1Accordingly, this embodiment of the invention also provides a computer-readable storage medium storing a computer program that, when executed by a processor, performs the following steps: acquiring a power communication text image to be identified; acquiring a preset text extraction model and compressing the preset text extraction model to obtain a compressed preset text extraction model; inputting the power communication text image to be identified into the compressed preset text extraction model for text extraction to obtain the text corresponding to the power communication text image to be identified.

[0108] Based on the above, Figure 1 The method shown and as Figure 5 The embodiment of the device shown in the invention also provides a physical structure diagram of a computer device, such as... Figure 7 As shown, the computer device includes: a processor 41, a memory 42, and a computer program stored in the memory 42 and executable on the processor. Both the memory 42 and the processor 41 are mounted on a bus 43. When the processor 41 executes the program, it performs the following steps: acquiring a power communication text image to be identified; acquiring a preset text extraction model and compressing the preset text extraction model to obtain a compressed preset text extraction model; inputting the power communication text image to be identified into the compressed preset text extraction model for text extraction to obtain the text corresponding to the power communication text image to be identified.

[0109] The present invention obtains a preset text extraction model, compresses the preset text extraction model, and finally uses the compressed preset text extraction model to extract text from the power communication text image to be recognized. This automatic extraction of text from the power communication text image using the model improves the efficiency and accuracy of text extraction. Furthermore, by compressing the preset text extraction model, the number of model parameters and computational load are significantly reduced, further improving text extraction efficiency and solving computational resource constraints.

[0110] It is obvious to those skilled in the art that the modules or steps of the present invention described above can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. Optionally, they can be implemented using computer-executable program code, thereby storing them in a storage device for execution by a computing device. In some cases, the steps shown or described can be performed in a different order than those presented herein, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, the present invention is not limited to any particular combination of hardware and software.

[0111] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. A method of extracting power communication text, characterized by, The method comprises the following steps: acquiring a power communication text image to be recognized; acquiring a preset character extraction model, and performing compression processing on the preset character extraction model to obtain a compressed preset character extraction model; inputting the power communication text image to be recognized into the compressed preset character extraction model for character extraction to obtain characters corresponding to the power communication text image to be recognized.

2. The method of claim 1, wherein, The preset character extraction model comprises an encoder and a decoder, the encoder comprises a denoising layer, a first multi-head self-attention layer and a first feedforward network layer, and the decoder comprises a mask multi-head self-attention layer, a second multi-head self-attention layer and a second feedforward network layer; The compression processing on the preset character extraction model comprises the following steps: acquiring a sample compression data set, wherein the sample compression data set comprises sample power images and actual character label information corresponding to the sample power images, inputting the sample power images into the preset character extraction model for forward propagation, determining input data and output data of each network layer in the preset character extraction model during the forward propagation, and determining a weight matrix of each attention head in the first multi-head self-attention layer; determining a loss function of the preset character extraction model based on the output data of the last network layer in the preset character extraction model and the actual character label information, determining a function constraint term based on each weight matrix, and constraining the loss function by using the function constraint term to obtain a constrained loss function; training the preset character extraction model based on the constrained loss function, and determining a constraint weight matrix of each attention head during the training; determining a proportion of elements less than a preset threshold in the constraint weight matrix of each attention head, screening out redundant attention heads in each attention head based on the proportion of elements, and removing the redundant attention heads in the first multi-head self-attention layer to obtain a compressed first multi-head self-attention layer; introducing a diagonal matrix into the compressed first multi-head self-attention layer to obtain a compressed mask multi-head self-attention layer, reusing parameters of the compressed first multi-head self-attention layer to the second multi-head self-attention layer to obtain a parameter-reused second multi-head self-attention layer, and taking the preset character extraction model with the compressed first multi-head self-attention layer, the compressed mask multi-head self-attention layer and the parameter-reused second multi-head self-attention layer as the compressed preset character extraction model.

3. The method of claim 2, wherein, determining a function constraint term based on each weight matrix comprises: determining a total number H of attention heads in the first multi-head self-attention layer, determining a weight matrix A of each attention head i based on the total number H of attention heads i , determining a function constraint term L constraint , wherein, λ is a regularization coefficient.

4. The method of claim 3, wherein, constraining the loss function by using the function constraint term to obtain a constrained loss function comprises: The loss function is constrained by using the function constraint term, to obtain a constrained loss function L total wherein, L original is the loss function.

5. The method of claim 1, wherein, The compression processing on the preset character extraction model comprises the following steps: determining parameter sensitivity of each network layer in the preset character extraction model, and dividing each network layer into a sensitive layer and a non-sensitive layer based on the parameter sensitivity; Quantize parameters of the sensitive layer by using a 16-bit floating-point quantization manner, and quantize parameters of the non-sensitive layer by using an 8-bit integer quantization manner, and finally, the preset character extraction model after parameter quantization is taken as the compressed preset character extraction model.

6. The method of claim 1, wherein, The preset character extraction model is compressed to obtain the compressed preset character extraction model, including: An initial lightweight character extraction model is constructed, wherein the initial lightweight character extraction model includes a lightweight image feature extraction module and a lightweight character extraction module; A lightweight power communication text image required for lightweighting the preset character extraction model is obtained; Based on the lightweight power communication text image, image feature extraction differences between an encoder in the preset character extraction model and the lightweight image feature extraction module, and character extraction differences between a decoder in the preset character extraction model and the lightweight character extraction module are determined; Based on the image feature extraction differences, a feature extraction loss function is determined, and based on the character extraction differences, a character extraction loss function is determined; Based on the feature extraction loss function and the character extraction loss function, a joint loss function is determined, and based on the joint loss function, the initial lightweight character extraction model is iteratively trained to obtain the compressed preset character extraction model.

7. The method of claim 1, wherein, Before obtaining the preset character extraction model, the method further includes: A preset initial character extraction model is constructed; A sample data set is obtained, wherein the sample data set includes sample power communication images with annotation information, and the annotation information is characters in the sample power communication images; The sample data set is divided into a training set, a validation set and a test set, the preset initial character extraction model is trained by using the training set, the preset initial character extraction model after training is verified by using the validation set, and the preset initial character extraction model after verification is tested by using the test set, and finally, the preset initial character extraction model after verification that meets the test condition is taken as the preset character extraction model.

8. An electric power communication character extraction device characterized by comprising: including: An acquisition unit is configured to acquire a power communication text image to be recognized; A compression unit is configured to acquire a preset character extraction model and compress the preset character extraction model to obtain a compressed preset character extraction model; A character extraction unit is configured to input the power communication text image to be recognized into the compressed preset character extraction model for character extraction to obtain characters corresponding to the power communication text image to be recognized.

9. A computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the method of any one of claims 1 to 7.

10. A computer device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The computer program is executed by the processor to implement the steps of the method of any one of claims 1 to 7.