Multi-table power technology standard PDF analysis method and system
By performing multi-table analysis and reconstruction of power technology standard PDF files to generate coherent and smooth text corpus, the problem that traditional methods are difficult to effectively deal with and utilize PDF table information is solved, and the construction efficiency and accuracy of defective corpus is improved.
Patent Information
- Application Number
- CN202411560604.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-04
- Publication Date
- 2025-02-14
AI Technical Summary
Traditional text extraction methods are difficult to effectively process and utilize table information in PDF files with power technology standards, resulting in the burial of many important professional information, affecting the construction efficiency and accuracy of the main transformer defect corpus.
A multi-table power technology standard PDF analysis method is proposed. By converting PDF files into table images, table border and corner point positioning detection, table structure analysis, cell content recognition, table header cell classification and table structure reconstruction, Finally, a large language model is used to generate a coherent text corpus.
It realizes efficient extraction and utilization of table information in power technology standard PDF files, improves the efficiency and accuracy of the construction of main transformer defect corpus, and provides a more intuitive and standard text corpus.
Smart Images

Figure CN119445599A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to data processing technology in the field of electric power technology, and in particular to a PDF parsing method and system for multi-table electric power technology standards. Background Art
[0002] As the core equipment in the power system, the stable operation of the main transformer is crucial to the safety and reliability of the power grid. With the rapid development of artificial intelligence technology, the traditional means of main transformer defect risk identification has gradually shifted to the use of emerging technologies such as large language models and knowledge graphs to achieve main transformer defect risk identification from multimodal data such as technical standards, fault reports, inspection images and operation data, which also puts higher requirements on the construction of the main transformer defect corpus. There are a large number of documents related to main transformer defects in the professional technical documents of the power industry. Among them, PDF files, as the most common document format, contain a large number of tables. These tables record rich professional information, including equipment type, equipment components, defect description, classification basis, defect classification, state quantity, judgment basis, load rate, etc. These data are of great significance for the operation, maintenance and management of the main transformer. However, the traditional text extraction method has limited processing capabilities for tables, and the information in the table is often difficult to be effectively extracted and utilized, resulting in a lot of valuable professional information being buried in the complex table structure. Therefore, how to efficiently obtain corpus from the tables in the PDF files of power technical standards is of great significance. Summary of the invention
[0003] Technical problem to be solved by the present invention: In view of the above-mentioned problems in the prior art, a multi-table electric power technical standard PDF parsing method and system are provided. The present invention aims to realize the effective extraction and utilization of information in the tables of multi-table electric power technical standard PDF documents, so as to improve the efficiency and accuracy of transformer defect corpus construction.
[0004] In order to solve the above technical problems, the technical solution adopted by the present invention is: A PDF parsing method for multi-table electric power technical standards includes the following steps: Convert power technical standard PDF files into table images; Perform table and corner point positioning detection on the table image to obtain the table border; Parse the table structure of the table image to obtain the cell rectangular frame; Recognize text rectangles and text content for table images; Match the cell rectangle and the text rectangle to determine the text content of the cell; Classify the header cells of the cell rectangle into header cells and ordinary cells; Reconstruct the table structure by combining the identified header cells, common cells and text contents; Based on the reconstructed table content, a large language model is used to generate coherent text corpus.
[0005] Optionally, performing table and corner point location detection on the table image includes: Use the specified neural network model to extract the table borders of each table from the table image ; The table image is extracted using the specified neural network model, and the four corner points of each table are named corner 1, corner 2, corner 3 and corner 4 in a clockwise direction, and their coordinates are , , and ; The corner points that satisfy the following constraints are retained and belong to the same table to achieve group filtering of corner points: , In the above formula, is the coordinate of the i-th corner point, is the coordinate of the jth corner point, is the position constraint threshold, Related to the image size of the table, ,in is the image area size of the table; Determine the rectangular area of the table based on the corner points after grouping and filtering : , In the above formula, , , , ; The table border of the same table and rectangular area The upper left corner and lower right corner of the table are averaged to form the table border of the same table. and rectangular area Merge to get a new table border.
[0006] Optionally, the table structure parsing for the table image to obtain the cell rectangular frame includes: converting the table image into a binary image, applying an iterative 3×3 kernel mean filter to generate a conversion image to expand some pixels in the binary image that are 1 to increase the sharpness and detail of the table lines in the image; using the specified neural network model to extract the cell rectangular frame of each table cell from the conversion image, including the upper left corner coordinates and the lower right corner coordinates .
[0007] Optionally, matching the cell rectangular frame with the text rectangular frame to determine the text content of the cell includes: for each text rectangular frame, calculating the intersection-and-union ratio between the text rectangular frame and each cell rectangular frame: , In the above formula, is the intersection-and-union ratio, and Represents the text rectangle and cell rectangle respectively. express and The intersection area of express and The union area of Indicates finding the area of the region; for each text rectangle, select the region with the largest intersection and union ratio that exceeds the preset threshold The cell rectangular box is used as the cell rectangular box matched by the text rectangular box, thereby determining the text content of the text rectangular box to be the text content corresponding to the matched cell rectangular box.
[0008] Optionally, the cell rectangular box is classified into header cells by using the CoPETransformer model improved based on the Transformer encoder to classify the cell rectangular box into header cells and ordinary cells, wherein the Transformer encoder is composed of a position encoding module and a plurality of stacked multi-head self-attention mechanism modules and a feedforward network layer, and the improvement includes improving the multi-head self-attention mechanism module of the Transformer encoder, and each attention head in the improved multi-head self-attention mechanism module is for an input length of , the dimension is The processing of the input sequence includes: first processing it into three linear projections to obtain the query ,key ,value , combined with the diagonal matrix Encode the collaborative position information and combine it to calculate the attention size: , In the above formula, is the attention size of the attention head in the i-th stacked multi-head self-attention mechanism module, is the activation function, is the attention size of the attention head in the multi-head self-attention mechanism module stacked at the i-1th layer, and the output of the attention head is calculated according to the following formula : , In the above formula, As value; finally, the output of each attention head After connection, it is input into the feedforward network layer of the multi-head self-attention mechanism module stacked in this layer.
[0009] Optionally, the step of combining the identified header cells, common cells and text content to reconstruct the table structure includes: for each header cell of the table ,in Representative The horizontal coordinate of the upper left corner of the cell, Representative The vertical coordinate of the upper left corner of the cell, Representative The horizontal coordinate of the lower right corner of the cell, Representative The vertical coordinate of the lower right corner vertex of the cell determines the horizontal coordinate of the leftmost cell of the header and the rightmost horizontal axis Get the row-wise border of the header cell ; Introduce a boundary tolerance threshold ,in Indicates the minimum width of all cells, combined with the border tolerance threshold Perform merged cell judgment and table reconstruction, including: traversing the cells one by one and comparing them two by two. , then the cell is judged to be a merged cell in the row direction, and its corresponding text should be filled into the cell in the column direction. If there is no merged cell in the row direction in the header, all the merged cells of the header type are arranged in the order of the horizontal axis, and finally the reconstructed table structure is obtained.
[0010] Optionally, the generating a coherent text corpus based on the reconstructed table content using a large language model includes: constructing an instruction data set; fine-tuning instructions for the selected large language model using the instruction data set; constructing a universal and regular prompt word, using the header of the reconstructed table structure and the attributes corresponding to the header as keywords to embed into the prompt word and generating a coherent text corpus using the large language model one by one.
[0011] In addition, the present invention also provides a multi-table electric power technical standard PDF parsing system, comprising a microprocessor and a memory connected to each other, wherein the microprocessor is programmed or configured to execute the multi-table electric power technical standard PDF parsing method.
[0012] In addition, the present invention also provides a computer-readable storage medium, in which a computer program or instruction is stored. The computer program or instruction is programmed or configured to execute the multi-table electric power technical standard PDF parsing method through a processor.
[0013] In addition, the present invention also provides a computer program product, including a computer program or instructions, which are programmed or configured to execute the multi-table power technical standard PDF parsing method through a processor.
[0014] Compared with the prior art, the present invention mainly has the following advantages: 1. The present invention proposes a method for parsing a PDF table of electric power technical standards for extracting main transformer defect corpus, involving the steps of PDF to image conversion, table area detection, table structure parsing, cell content recognition, header cell recognition, table structure reconstruction, recognition, text corpus generation, etc. Each step can flexibly change the technical solution within each step according to different task requirements or current technology update conditions.
[0015] 2. The present invention proposes a table coordinate information position encoding Transformer (CoPETransformer) table header recognition model, which improves the accuracy of table header recognition by optimizing the position encoding module in the Transformer model.
[0016] 3. The present invention fine-tunes the GPT model by artificially constructing a small sample instruction data set, so that the fine-tuned GPT model has better performance in the task of converting table content into text corpus. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 Schematic diagram of the basic flow of the method of the embodiment of the present invention.
[0018] Figure 2 The figure is a schematic diagram of a specific process of the method according to an embodiment of the present invention.
[0019] Figure 3 Schematic diagram of table content relationship used in an embodiment of the present invention.
[0020] Figure 4 It is a schematic diagram of table structure reconstruction in an embodiment of the present invention. DETAILED DESCRIPTION
[0021] The embodiments of the present invention will be described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and cannot be understood as limiting the present invention. In the description of the present invention, if there is a description of the first, the second, etc., it is only for the purpose of distinguishing the technical features, and cannot be understood as indicating or implying the relative importance or implicitly indicating the number of the indicated technical features or implicitly indicating the order of the indicated technical features. If it involves the description of the orientation, such as the orientation or position relationship indicated by the upper and lower indications, the above-mentioned orientation description is only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present invention. Unless otherwise clearly defined, the terms such as setting, installing, connecting, etc. in the description of the present invention should be understood in a broad sense, and the technicians in the relevant technical field can reasonably determine the specific meaning of the above terms in the present invention in combination with the specific content of the technical solution.
[0022] like Figure 1 As shown, the multi-table electric power technical standard PDF parsing method of this embodiment includes the following steps: S1, converting the electric power technical standard PDF file into a table image; S2, performing table and corner point location detection on the table image to obtain the table border; S3, performing table structure analysis on the table image to obtain a cell rectangular frame; S4, recognizing text rectangles and text content for table images; S5, matching the cell rectangular frame and the text rectangular frame to determine the text content of the cell; S6, classifying the cell rectangular frame into header cells and common cells; S7, reconstructing the table structure by combining the recognized header cells, common cells and text contents; S8, based on the reconstructed table content, uses a large language model to generate coherent text corpus.
[0023] In step S1 of this embodiment, when converting the electric power technical standard PDF file into a table image, a tool such as PyMuPDF can be selected to parse the electric power technical standard PDF file related to the main transformer defect corpus, and each page of the PDF file can be converted into a separate image file, and the image is used as the basic data for subsequent table processing. In addition, other tools or methods can also be used to convert the electric power technical standard PDF file into a table image as needed.
[0024] In step S2 of this embodiment, performing table and corner point location detection on the table image includes: S2.1, extract the table borders of each table using the specified neural network model from the table image ; S2.2, extract the four corner points of each table using the specified neural network model, and name them corner 1, corner 2, corner 3 and corner 4 in clockwise direction, with coordinates respectively , , and ; S2.3, the corner points that satisfy the following constraints are retained and belong to the same table to achieve group filtering of corner points: , In the above formula, is the coordinate of the i-th corner point, is the coordinate of the jth corner point, is the position constraint threshold, Related to the image size of the table, ,in is the image area size of the table; S2.4, determine the rectangular area of the table based on the corner points after grouping and filtering : , In the above formula, , , , ; S2.5, the table border of the same table and rectangular area The upper left corner and lower right corner of the table are averaged to form the table border of the same table. and rectangular area Merge to get a new table border.
[0025] As an optional implementation, Figure 2 As shown, in step S2.1 of this embodiment, the table image is extracted using a specified neural network model to extract the table borders of each table. The neural network model used is the existing Faster RCNN network. In addition, other types of neural network models can be used as needed. Using the Faster RCNN network for table detection: input the image file into the VGG16 backbone network to extract features, and feed the extracted features into the region candidate network (RPN) to initially obtain the candidate boxes that meet the requirements and the corresponding position information; then compare the candidate regions output by the region candidate network RPN with the features obtained from the last layer of the VGG16 backbone network. Figure 1 It is fed to the region of interest (ROI) pooling layer to generate a fixed-size feature map; finally, the table object is identified through classification and regression and the corresponding coordinate position is obtained. In this step, the detected table border is defined as .
[0026] As an optional implementation, in step S2.2 of this embodiment, the neural network model used when extracting the four corner points of each table from the table image using a specified neural network model is the existing Faster RCNN network. In addition, other types of neural network models can also be used as needed. The detection of table corner points is the same as the table detection step, and finally the corner point area and corresponding position information are obtained. For the corner points in a rectangular table, they are named corner 1, corner 2, corner 3, and corner 4 in a clockwise direction; they can also be defined as , , , Finally, the rectangular area determined by the corner point group With table border Merge to improve table detection accuracy by averaging the coordinates of the upper left and lower right vertices of R and the upper left and lower right vertices of T to obtain a new table bounding box.
[0027] In step S3 of this embodiment, performing table structure analysis on the table image to obtain a cell rectangular frame includes: converting the table image into a binary image, applying an iterative 3×3 kernel mean filter to generate a conversion image to expand some pixels in the binary image that are 1 to increase the sharpness and detail of the table lines in the image; extracting the cell rectangular frame of each table cell using a specified neural network model from the conversion image, including the upper left corner coordinates and the lower right corner coordinates .
[0028] As an optional implementation, in step S3 of this embodiment, the neural network model used when extracting the cell rectangle of each table cell from the converted image using the specified neural network model is the existing Mask RCNN network. In addition, other types of neural network models can also be used as needed. The Mask RCNN network is an instance segmentation model extended from Faster RCNN. The specific modules are as follows: (1) Feature Pyramid Network (FPN): The image is input into the pre-trained FPN network model to obtain the corresponding feature map; (2) Region Proposal Network (RPN): After the feature map obtains a large number of regions of interest (ROIs) through RPN, the foreground and background are binary classified using the Softmax classifier, and more accurate candidate frame position information is obtained through bilinear interpolation and non-maximum suppression of local regions of interest filtering; (3) Region of Interest Recommendation (ROIAlign): The filtered ROI enters the ROIAlign layer, and each ROI generates a fixed-size feature map; (4) 3 branches: Finally, the process passes through 3 branches, one branch enters the fully connected layer (FCN) for masking, and the other branches enter the FCN for object classification and boundary generation. Finally, the table image processed by the Mask RCNN network can output the coordinates of the upper left corner of each cell identified and the lower right corner coordinates .
[0029] In step S4 of this embodiment, the text rectangular frame and text content are recognized for the table image by jointly using the DBNet network and the CRNN model to perform OCR recognition on the cell content. The recognition result is the rectangular frame coordinates and the corresponding text content of each text area in the table image. In addition, other types of neural network models can also be used as needed.
[0030] In step S5 of this embodiment, matching the cell rectangular frame with the text rectangular frame to determine the text content of the cell includes: for each text rectangular frame, calculating the intersection-and-union ratio between the text rectangular frame and each cell rectangular frame: , In the above formula, is the intersection-and-union ratio, and Represents the text rectangle and cell rectangle respectively. express and The intersection area of express and The union area of Indicates finding the area of the region; for each text rectangle, select the region with the largest intersection and union ratio that exceeds the preset threshold The cell rectangular box is used as the cell rectangular box that matches the text rectangular box, so as to determine that the text content of the text rectangular box is the text content corresponding to the matching cell rectangular box. The rectangular box of the cell area is matched with the rectangular box of the text line area according to the intersection-and-union ratio, and the text information in each text line area is assigned to the corresponding cell. The specific steps are as follows: For each line of text, traverse all cells and calculate the intersection-and-union ratio (IoU) of their rectangular boxes. IoU is defined as the ratio of the intersection area of two rectangles to the area of the union, where the intersection area is the area of the overlapping part of the two rectangles, and the union area is the area of the non-overlapping part of the two rectangles plus the area of the overlapping part. According to the IoU value, each text block is matched to the most suitable cell. Usually, the cell with the largest IoU value is selected as the cell to which the text block belongs. In this embodiment, threshold filtering correction adjustment is further added to avoid incorrect matching. When the IoU value exceeds the set threshold ( ) will be considered to match the cell. Through the above steps, ensure that each text line is matched to a unique cell.
[0031] As a tool for displaying organization and content, tables usually present information in the form of rows and columns. By classifying information and classifying it according to certain standards, it can decompose complex content information into more organized forms and express the hierarchical relationship or mutual connection between content, such as the parallel and subordinate relationship between different cells in the header; the inclusion relationship between the header cell and the attribute, etc. The table content relationship diagram is shown below: Figure 3 As shown in the figure, the left side is a regular table, and the right side is a complex table with merged cells in the header. Clearly distinguishing between header cells and non-header cells in the table provides key information for subsequent table structure reconstruction. Figure 2 As shown, in step S6 of this embodiment, the cell rectangular frame is classified into header cells and ordinary cells using the CoPETransformer model improved based on the Transformer encoder. The Transformer encoder is composed of a position encoding module and a plurality of stacked multi-head self-attention mechanism modules and a feedforward network layer. The improvement includes improving the multi-head self-attention mechanism module of the Transformer encoder, and each attention head in the improved multi-head self-attention mechanism module is for an input length of , the dimension is The processing of the input sequence includes: first processing it into three linear projections to obtain the query ,key ,value , combined with the diagonal matrix Encode the collaborative position information and combine it to calculate the attention size: , In the above formula, is the attention size of the attention head in the i-th layer stacked multi-head self-attention mechanism module, is the activation function, is the attention size of the attention head in the multi-head self-attention mechanism module stacked at the i-1th layer, and the output of the attention head is calculated according to the following formula : , In the above formula, As value; finally, the output of each attention head After connection, it is input into the feedforward network layer of the multi-head self-attention mechanism module stacked in this layer. Transformer is a model that is easy to optimize and expand. Different classification task models can be optimized by adjusting the model's input representation, self-attention mechanism, position encoding and other components. In this embodiment, a header cell recognition model is constructed by designing and optimizing the position encoding module and self-attention mechanism in Transformer. The cell text content and coordinate position are vectorized and input into the model. For the case where the text content length in different cells is not uniform, the vector should be padded to keep the input size uniform; the model output uses a softmax activation function with an output dimension of 2 to convert the output into a probability distribution of header cells and other cells. The encoder architecture of the transformer consists of many stacked multi-head self-attention mechanism modules and feedforward layer blocks. Multi-head self-attention, generally speaking, given an input with a sequence length of n and a dimension of d, it is first processed into three linear projections, namely query ,key ,value , more specifically, given a sequence length , the dimension is The input is first processed into three linear projections to calculate the attention size on the query and key respectively. : , In this embodiment, the cell coordinate position encoding (CoordinatePositionEncode, CoPE) is added on this basis: the scheme of integrating position information into the Transformer model can be roughly divided into two categories: absolute position encoding and relative position encoding. The position encoding can be combined with the input of the model or the attention parameter matrix in each layer can be adjusted. In this embodiment, CoPE is used to encode the relative position in the model. This method applies the matrix constructed by sine and cosine functions to the query of each attention head in each layer. and key , which enables the model to have information reflecting the relative distance between different cells. When we input the cells that need to be identified and classified into the Transformer encoder, since the spatial location information of different cell categories in the table is obvious, the location information is crucial to enhance the network's ability to distinguish the location of the header cell and other attribute cells. Calculate the attention size after CoPE encoding is merged The method is: , in is a diagonal matrix. Each input position has a coordinate transformation matrix on the diagonal. More specifically, given an input position and the diagonal matrix , enter the location The diagonal of has the following coordinate transformation matrix: , In the above formula, is the rotation angle. The multi-head attention mechanism is one of the core components of the Transformer model, and each attention head usually learns different patterns to handle potential tasks. In cell category classification, in order to distinguish the header cells from other categories of cells in the table, the model should learn at least two key patterns. In the header cell recognition model, the model is improved by introducing residual attention (RA) to specialize each attention head to a specific pattern. Residual Attention (RA) adds a connection to each attention parameter matrix to propagate the attention size of the previous layer to optimize the cell category classification task effect, so that the encoding merge calculation attention size can be obtained: , In the above formula, is the attention size of the attention head in the i-th stacked multi-head self-attention mechanism module, is the activation function, is the attention size of the attention head in the i-1th layer stacked multi-head self-attention mechanism module.
[0032] After the table header recognition step, the table structure is reconstructed based on the coordinate information of each cell in the current table and the corresponding category attributes. In step S7 of this embodiment, the table structure is reconstructed based on the recognized table header cells, ordinary cells and text content, including: for each table header cell ,in Representative The horizontal coordinate of the upper left corner of the cell, Representative The vertical coordinate of the upper left corner of the cell, Representative The horizontal coordinate of the lower right corner of the cell, Representative The vertical coordinate of the lower right corner vertex of the cell determines the horizontal coordinate of the leftmost cell of the header and the rightmost horizontal axis Get the row-wise border of the header cell ; Introduce a boundary tolerance threshold ,in Indicates the minimum width of all cells, combined with the border tolerance threshold Perform merged cell judgment and table reconstruction, including: traversing the cells one by one and comparing them two by two. , it is determined that the cell is a merged cell in the row direction, and the corresponding text of the cell should be filled into the cell in the column direction. If there is no merged cell in the row direction in the header, the merged cells of all header types are arranged in the order of the horizontal coordinates, and finally the reconstructed table structure is obtained. In this embodiment, it is specifically as follows Figure 4 As shown, table reconstruction is helpful to provide more standard and intuitive structural information in subsequent text corpus generation.
[0033] In step S7 of this embodiment, the method of generating a coherent text corpus based on the reconstructed table content using a large language model includes: constructing an instruction data set; fine-tuning the instruction data set for the selected large language model; constructing a universal and regular prompt word (prompt), using the header of the reconstructed table structure and the attributes corresponding to the header as keywords to embed into the prompt word, and generating a coherent text corpus using the large language model one by one. Figure 2 As shown, as an optional implementation, the large language model in this embodiment adopts the GPT model. In addition, other large language models can be used as needed. In this embodiment, for the table with rearranged structure, the column names in the header and the corresponding contents are more generalized than the natural coherent text, so we will further process the table content to form a coherent text corpus to provide more corpus data for the construction of large language models in specific fields. In this embodiment, relative to the naturally coherent text sentences, the text in the header cells and their corresponding attribute cells in the table can be regarded as keywords or entities in a coherent text. Therefore, in the present invention, text corpus generation is regarded as a keyword sentence making task, by constructing a small-scale instruction data set, and fine-tuning the pre-trained GPT model to improve the model's ability to understand the requirements, and finally the fine-tuned model is used to perform the text corpus generation task. The steps of text corpus generation are as follows: 1) Constructing a small-scale instruction dataset: The present invention ensures the high quality and interpretability of the dataset by artificially constructing an instruction dataset, so that the training samples can be flexibly controlled to adapt to the task requirements during fine-tuning.
[0034] 2) Select the GPT model: GPT refers to the technology based on Generative Pre-trained Transformer. It is a natural language processing technology based on big data and deep learning. Through pre-training on a large-scale corpus, it can learn the statistical laws of language, the correlation between words, and the language generation rules in the context. When generating sentences, the self-attention mechanism in the GPT model captures the relationship and dependency between the words in the sentence when the sentence is generated. Therefore, when a keyword is given, the model will try to associate the keyword with the context in which it may appear to generate context-related sentences.
[0035] 3) Instruction fine-tuning: Instruction fine-tuning can also be called "supervised fine-tuning", which means that there is a standard answer for the input text, and the model is trained with the standard answer. Generally, instruction fine-tuning is required after pre-training. After instruction fine-tuning, the pre-trained model can show a strong ability to follow instructions. Some fine-tuning examples are as follows: { "instruction": "Compose a sentence based on a given set of headers and the contents corresponding to the set of headers", "input": "The table header is the equipment type, equipment voltage level or capacity, and inspection cycle. The corresponding content of the table header is: transformer and resistor, voltage 66KV and above, 1-3 years", "output": "When the equipment voltage level of transformers and reactors is 66KV and above, the inspection cycle is 1-3 years" }, { "instruction": "The table headers are equipment, inspection items, inspection content, and defect description. Please combine the corresponding contents of the table headers: main transformer, presence or absence of flashover discharge, and slight flashover discharge into one sentence according to the table headers.", "input": " ", "output": "For the inspection items of the main transformer, the inspection content includes checking whether there is flashover discharge phenomenon. In fact, it was found that there was slight flashover discharge phenomenon." }, After fine-tuning the above instructions, we manually constructed a general and regular prompt, using the table headers and the corresponding attributes of the headers as keywords to generate the corresponding text corpus one by one. The specific prompt design template can be as follows: the headers are [<>, <>, <>...], and the contents corresponding to the headers [<>, <>, <>...] are combined into a sentence. After fine-tuning the instructions, the GPT model can understand the intention of the prompt more accurately, optimize the contextual expression of the text corpus, and make the output sentence connection smoother, more natural, and more readable and understandable.
[0036] To sum up, in order to solve the shortcomings of the prior art, this embodiment proposes a multi-table power technical standard PDF parsing method for extracting power technical standard PDF table parsing of main transformer defect corpus. This embodiment converts the document into an image, comprehensively utilizes Faster RCNN, Mask RCNN and ORC and other technologies to detect and parse the table, and then proposes a table coordinate information position encoding Transformer (CoPETransformer) header recognition model to improve the header recognition accuracy. Finally, the GPT model is fine-tuned by artificially constructing a small sample instruction data set, and the reconstructed structured table is converted into text corpus using the fine-tuned GPT model.
[0037] In addition, this embodiment also provides a multi-table electric power technical standard PDF parsing system, including a microprocessor and a memory connected to each other, wherein the microprocessor is programmed or configured to execute the multi-table electric power technical standard PDF parsing method.
[0038] In addition, this embodiment also provides a computer-readable storage medium, in which a computer program or instruction is stored. The computer program or instruction is programmed or configured to execute the multi-table electric power technical standard PDF parsing method through a processor.
[0039] In addition, this embodiment also provides a computer program product, including a computer program or instructions, which are programmed or configured to execute the multi-table power technical standard PDF parsing method through a processor.
[0040] Those skilled in the art should understand that the technical solutions provided by the embodiments of the present application may be in the form of methods, systems, or computer program products. Therefore, the present application may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application may take the form of a computer program product implemented on one or more computer-readable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes. The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the process Figure 1 A process or multiple processes and / or boxes Figure 1 These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing device to work in a specific way, so that the instructions stored in the computer-readable memory produce a product including an instruction device, which implements the functions specified in the process. Figure 1 A process or multiple processes and / or boxes Figure 1 These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide for implementing the process in the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0041] The above is only a preferred embodiment of the present invention, and the protection scope of the present invention is not limited to the above embodiments. All technical solutions under the concept of the present invention belong to the protection scope of the present invention. It should be pointed out that for ordinary technicians in this technical field, some improvements and modifications without departing from the principle of the present invention should also be regarded as the protection scope of the present invention.
Claims
1. A PDF parsing method for multi-table electric power technical standards, characterized in that: The steps include: Convert power technical standard PDF files into table images; Perform table and corner point positioning detection on the table image to obtain the table border; Parse the table structure of the table image to obtain the cell rectangular frame; Recognize text rectangles and text content for table images; Match the cell rectangle and the text rectangle to determine the text content of the cell; Classify the header cells of the cell rectangle into header cells and ordinary cells; Reconstruct the table structure by combining the identified header cells, common cells and text contents; Based on the reconstructed table content, a large language model is used to generate coherent text corpus.
2. The multi-table electric power technical standard PDF parsing method according to claim 1 is characterized in that: The table and corner point location detection for the table image includes: Use the specified neural network model to extract the table borders of each table from the table image ; The table image is extracted using the specified neural network model, and the four corner points of each table are named corner 1, corner 2, corner 3 and corner 4 in a clockwise direction, and their coordinates are , , and ; The corner points that satisfy the following constraints are retained and belong to the same table to achieve group filtering of corner points: , In the above formula, is the coordinate of the i-th corner point, is the coordinate of the jth corner point, is the position constraint threshold, Related to the image size of the table, ,in is the image area size of the table; Determine the rectangular area of the table based on the corner points after grouping and filtering : , In the above formula, , , , ; The table border of the same table and rectangular area The upper left corner and lower right corner of the table are averaged to form the table border of the same table. and rectangular area Merge to get a new table border.
3. The multi-table electric power technical standard PDF parsing method according to claim 1 is characterized in that: The method of performing table structure analysis on a table image to obtain a cell rectangular frame includes: converting the table image into a binary image, applying an iterative 3×3 kernel mean filter to generate a conversion image to expand some pixels in the binary image that are 1 to increase the sharpness and detail of the table lines in the image; extracting the cell rectangular frame of each table cell from the conversion image using a specified neural network model, including the upper left corner coordinates and the lower right corner coordinates .
4. The multi-table electric power technical standard PDF parsing method according to claim 1, characterized in that: The matching of the cell rectangular frame and the text rectangular frame to determine the text content of the cell includes: for each text rectangular frame, respectively calculating the intersection-and-union ratio between the text rectangular frame and each cell rectangular frame: , In the above formula, is the intersection-and-union ratio, and Represents the text rectangle and cell rectangle respectively. express and The intersection area of express and The union area of Indicates the area of the region; for each text rectangle, select the region with the largest intersection and union ratio that exceeds the preset threshold The cell rectangular box is used as the cell rectangular box matched by the text rectangular box, thereby determining the text content of the text rectangular box to be the text content corresponding to the matched cell rectangular box.
5. The multi-table electric power technical standard PDF parsing method according to claim 1, characterized in that: The cell rectangular frame is classified into header cells by using the CoPETransformer model based on the Transformer encoder to classify the cell rectangular frame into header cells and ordinary cells. The Transformer encoder is composed of a position encoding module and a plurality of stacked multi-head self-attention mechanism modules and a feedforward network layer. The improvement includes improving the multi-head self-attention mechanism module of the Transformer encoder, and each attention head in the improved multi-head self-attention mechanism module is for an input length of , the dimension is The processing of the input sequence includes: first processing it into three linear projections to obtain the query ,key ,value , combined with the diagonal matrix Encode the collaborative position information and combine it to calculate the attention size: , In the above formula, is the attention size of the attention head in the i-th stacked multi-head self-attention mechanism module, is the activation function, is the attention size of the attention head in the multi-head self-attention mechanism module stacked at the i-1th layer, and the output of the attention head is calculated according to the following formula : , In the above formula, As value; finally, the output of each attention head After connection, it is input into the feedforward network layer of the multi-head self-attention mechanism module stacked in this layer.
6. The multi-table electric power technical standard PDF parsing method according to claim 1, characterized in that: The table structure reconstruction based on the identified header cells, common cells and text contents includes: for each table header cell ,in Representative The horizontal coordinate of the upper left corner of the cell, Representative The vertical coordinate of the upper left corner of the cell, Representative The horizontal coordinate of the lower right corner of the cell, Representative The vertical coordinate of the lower right corner vertex of the cell determines the horizontal coordinate of the leftmost cell of the header and the rightmost horizontal axis Get the row-wise border of the header cell ; Introduce a boundary tolerance threshold ,in Indicates the minimum width of all cells, combined with the border tolerance threshold Perform merged cell judgment and table reconstruction, including: traversing the cells one by one and comparing them two by two. , then the cell is judged to be a merged cell in the row direction, and its corresponding text should be filled into the cell in the column direction. If there is no merged cell in the row direction in the header, all the merged cells of the header type are arranged in the order of the horizontal axis, and finally the reconstructed table structure is obtained.
7. The multi-table electric power technical standard PDF parsing method according to claim 1, characterized in that: The method of generating a coherent text corpus based on the reconstructed table content using a large language model includes: constructing an instruction data set; fine-tuning instructions using the instruction data set for the selected large language model; constructing a general and regular prompt word, using the header of the reconstructed table structure and the attributes corresponding to the header as keywords to embed into the prompt word, and generating a coherent text corpus using the large language model one by one.
8. A multi-table power technical standard PDF parsing system, comprising a microprocessor and a memory connected to each other, characterized in that: The microprocessor is programmed or configured to execute the multi-table electric power technical standard PDF parsing method as claimed in any one of claims 1 to 7.
9. A computer-readable storage medium having a computer program or instruction stored therein, characterized in that: The computer program or instruction is programmed or configured to execute the multi-table electric power technical standard PDF parsing method described in any one of claims 1 to 7 through a processor.
10. A computer program product comprising a computer program or instructions, characterized in that The computer program or instruction is programmed or configured to execute the multi-table electric power technical standard PDF parsing method described in any one of claims 1 to 7 through a processor.
Citation Information
Cited By
Complex table intelligent analysis method based on multi-modal fusion and semantic analysis
CN121303073A
Image processing method and device
CN121415429A
Header identification and conversion method based on large model and RAG enhanced retrieval
CN121636564A
A table header identification and conversion method based on a large model and RAG enhanced retrieval
CN121636564B
Oil and gas pipeline disaster scene knowledge graph construction method and system based on large language model
CN122154867A