Method and system for recalling table in PDF (Portable Document Format) and storage medium

By typing and keyword extraction of PDF documents, combining TF-IDF scores and correlation scores, table blocks are formed and vectorized, the problem of RAG technology ignoring the connection between the main text and the table when processing PDF documents tables is achieved, and efficient and accurate table recall and information retrieval are achieved.

CN119917654APending Publication Date: 2025-05-02UNIV OF SCI & TECH OF CHINA
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510022926.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-07
Publication Date
2025-05-02

AI Technical Summary

Technical Problem

When processing tables in PDF documents, existing RAG technology ignores the intrinsic connection between the text and the table, resulting in the generative model being unable to accurately combine relevant table information with the text content, affecting the accuracy and comprehensiveness of the generated results.

Method used

By layout recognition of PDF document content, identifying and annotating table parts and non-table parts, generating table summary and extracting keywords, calculating TF-IDF scores of query words in non-table parts, evaluating the correlation scores of each part and the table, sorting and extracting context information, forming table blocks and vector processing, uploading them to vector database, realizing efficient recall of tables.

Benefits of technology

It significantly improves the accuracy and efficiency of table recall in PDF documents, can more accurately capture the inherent connection between tables and text, improves the efficiency of information acquisition, and enhances the practicality and operability of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119917654A_ABST
    Figure CN119917654A_ABST
Patent Text Reader

Abstract

The invention discloses a method and a system for recalling a table in a PDF (Portable Document Format) and a storage medium, and relates to the technical field of retrieval enhancement generation. Comprising the following steps: performing layout identification on document content, and identifying and marking a table part and each non-table part of a document; extracting contents of a first row and a first column of the table from the table part, generating a keyword, taking the keyword as a query word of a retrieval model, and calculating a TF-IDF score of the query word in a non-table part; according to the text type and / or the distance table position and / or the TF-IDF score, calculating the correlation score of each non-table part and the table; sorting the non-table parts based on the correlation scores, and extracting sorted context information; and combining the context information, the table summary and the table keyword to form a table block, and uploading the table block to a vector database after vectorization processing to serve as an index block of the table. The method aims at effectively and organically combining table data and text content and fully mining the internal relation between a table and a text.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of retrieval enhancement generation, and in particular to a method, system and storage medium for recalling a table in a PDF. Background Art

[0002] With the rapid development of natural language processing (NLP) technology, generative models (such as the GPT series) have demonstrated powerful text generation capabilities in many fields. However, these generative models usually rely on a large amount of training data and a predefined knowledge base. Therefore, when faced with real-time, dynamic and highly specialized information needs, the content they generate has problems such as insufficient accuracy and incomplete knowledge coverage. In order to make up for this shortcoming, Retrieval-Augmented Generation (RAG) technology came into being and gradually became an effective means to solve this problem.

[0003] The basic idea of ​​RAG technology is to combine information retrieval with generation models, obtain relevant information from external knowledge bases through the retrieval module, and then generate more accurate and richer texts by combining this information with the generation model. The basic framework of RAG technology mainly includes four core parts: information processing module, vector database module, query module and answer generation module. During the processing, the information processing module first pre-processes and vectorizes the document content in various formats to facilitate subsequent efficient retrieval; the vector database module uses efficient vector storage and retrieval technology to ensure that relevant information can quickly respond to query requirements; the query module uses vector retrieval technology to obtain the most relevant content from the database through user input queries; finally, the answer generation module combines the retrieved information to generate the final answer or content, thereby improving the accuracy and comprehensiveness of the generated results.

[0004] At present, when processing tables, RAG technology usually summarizes or extracts the contents of the table and inputs the summarized information into the generative model. However, this method ignores the intrinsic connection between the main text and the table, especially the interpretation and analysis of the table data in the main text and its connection with the main text content. As a result, when performing retrieval, the generative model often cannot accurately combine the relevant table information with the main text content, thus affecting the accuracy and comprehensiveness of the final generated results.

[0005] Therefore, how to effectively combine table data with the text content and fully explore the intrinsic connection between the table and the text has become a technical problem that needs to be solved urgently. Summary of the invention

[0006] The main purpose of the present invention is to provide a method, system and storage medium for recalling tables in PDF, aiming to effectively combine table data with text content and fully explore the intrinsic connection between the table and the text.

[0007] In order to achieve the above object, the present invention proposes a method for recalling a table in a PDF, comprising the following steps: Perform layout recognition on the content of PDF documents, identify and mark the table part and non-table parts of the PDF document; Generate a table summary based on the table part, extract the first row and first column of the table from the table part, generate keywords, use the keywords as query words of the retrieval model, and calculate the TF-IDF score of the query words in the non-table part; Calculate the relevance score of each non-table part to the table based on the text type and / or the distance position from the table and / or the TF-IDF score; Rank each non-tabular part based on the relevance score and extract the ranked context information; The context information, table summary, and table keywords are combined to form a table block, which is then uploaded to the vector database after vectorization processing as the table index block; The query module retrieves and queries the target table block in the vector database, and presents the retrieved target table to the user.

[0008] In one embodiment of the present application, the non-table parts at least include a text part, a title part, a table title part, and a picture part.

[0009] In one embodiment of the present application, the retrieval model is constructed by the BM25 algorithm.

[0010] In one embodiment of the present application, searching and querying a target table block in a vector database by a query module, and presenting the retrieved target table to a user, includes the following steps: After receiving the user query, the retrieval model is used to retrieve the target table block in the vector database and return the target table block most relevant to the query; Combine the retrieved target table blocks with the original query to form a comprehensive context; Based on the comprehensive context, the generative model is used to generate the final answer or content and output it to the user.

[0011] In one embodiment of the present application, the generation model is ChatGPT.

[0012] The present application also discloses a system for implementing the above method, comprising: Layout recognition module, used to recognize and mark the table part and various non-table parts in the PDF document; A keyword extraction module is used to extract the content of the first row and the first column from the table part to generate query words; A text analysis module to calculate the TF-IDF scores of query terms in the non-tabular part; A sorting module, for sorting the non-tabular parts according to the relevance scores and extracting the sorted context information; A vectorization module, used to combine context information, table summary, and table keywords to form table blocks and vectorize them, and upload them to the vector database; and The query module is used to retrieve relevant table blocks from the vector database based on user query information and present them to the user.

[0013] The present application also discloses a computer-readable storage medium storing computer-executable instructions. When the instructions are executed in a computer system, the above method can be implemented.

[0014] The adoption of the above technical solution can significantly improve the accuracy and efficiency of table recall in PDF documents. By accurately recognizing the layout of the PDF document content, the table can be efficiently distinguished from other non-table content. In the process of generating summaries and extracting keywords in the table part, the most critical information in the table can be captured, thereby improving the relevance of the query. When calculating the relevance score, combining multiple factors such as text type, position, and TF-IDF score, the matching degree of each part with the table can be more accurately evaluated, thereby improving the quality of table recall. Through vectorization processing and uploading to the vector database, the query process becomes more efficient and accurate, and tables related to the query target can be quickly located in large-scale documents. In the end, users can get accurate table recall results, improve the efficiency of information acquisition, and enhance the practicality and operability of the system. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] The present invention is described in detail below with reference to specific embodiments and accompanying drawings, wherein: Figure 1 It is a schematic structural diagram of the first embodiment of the present invention. DETAILED DESCRIPTION

[0016] In order to make the purpose, technical solution and advantages of the present invention clearer, the present invention is described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the following specific embodiments are only used to explain the present invention and do not constitute a limitation to the present invention.

[0017] like Figure 1 As shown, in order to achieve the above purpose, the present invention proposes a method for recalling a table in a PDF, comprising the following steps: Perform layout recognition on the content of PDF documents, identify and mark the table part and non-table parts of the PDF document; Generate a table summary based on the table part, extract the first row and first column of the table from the table part, generate keywords, use the keywords as query words of the retrieval model, and calculate the TF-IDF score of the query words in the non-table part; Calculate the relevance score of each non-table part to the table based on the text type and / or the distance position from the table and / or the TF-IDF score; Rank each non-tabular part based on the relevance score and extract the ranked context information; The context information, table summary, and table keywords are combined to form a table block, which is then uploaded to the vector database after vectorization processing as the table index block; The query module retrieves and queries the target table block in the vector database, and presents the retrieved target table to the user.

[0018] Specifically, first, use layout recognition technology to analyze the pages of the PDF document. This step includes marking the regions of each part of the PDF document, identifying and distinguishing the text part, title part, table part, and image part. The layout recognition technology processes the document, identifies the boundaries of the table, and separates the table from other content (such as text, pictures, etc.). Through this step, the table part and other non-table parts (such as text, title, etc.) can be accurately marked.

[0019] After the table part is identified, a summary of the table is first generated. The table summary includes the refinement of the core content of the table, usually extracting the key information of the table, such as the field name, value, and trend or analysis conclusion in the table. Then, keywords are extracted from the first row and first column of the table. Keywords can describe the data dimension or data type in the table. Keywords will be used as query terms in the retrieval model to calculate the relevance of non-table parts.

[0020] Using the extracted table keywords, search in non-table parts (such as the text and title parts) and calculate the TF-IDF (term frequency-inverse document frequency) score of each keyword. The TF-IDF score reflects the importance of each keyword in the document. The higher the score, the more important the keyword is in the document. By calculating the TF-IDF scores of various non-table parts, their relevance to the table content can be evaluated.

[0021] The relevance score of each non-table part to the table is calculated based on the text type (such as body, title, etc.), the distance from the table, and the TF-IDF score. This process takes into account the relevance of the text content, the relative position of the text to the table, and the TF-IDF score of each keyword. Finally, each non-table part will calculate a comprehensive relevance score based on these factors.

[0022] Based on the calculated relevance scores, the non-tabular parts are sorted. By sorting, it is possible to determine which non-tabular parts are most relevant to the target table. The sorted context information is extracted and used as a description or explanation part related to the target table.

[0023] The extracted context information, table summary, and table keywords are combined to form a table block. This table block contains the key information of the table, the context related to the table, and the summary description of the table. Next, vectorization processing technology is used to convert this information into a high-dimensional vector. Finally, the vector of this table block will be uploaded to the vector database and stored as the index block of the table.

[0024] When the user enters the query target, the query module will retrieve the table blocks most relevant to the query target table in the vector database according to the user's query request. The retrieval process uses vector-based similarity calculation, which can efficiently return the table content related to the user's query. The system will present the retrieved target table to the user to meet the query requirements.

[0025] The adoption of the above technical solution can significantly improve the accuracy and efficiency of table recall in PDF documents. By accurately recognizing the layout of the PDF document content, the table can be efficiently distinguished from other non-table content. In the process of generating summaries and extracting keywords in the table part, the most critical information in the table can be captured, thereby improving the relevance of the query. When calculating the relevance score, combining multiple factors such as text type, position, and TF-IDF score, the matching degree of each part with the table can be more accurately evaluated, thereby improving the quality of table recall. Through vectorization processing and uploading to the vector database, the query process becomes more efficient and accurate, and tables related to the query target can be quickly located in large-scale documents. In the end, users can get accurate table recall results, improve the efficiency of information acquisition, and enhance the practicality and operability of the system.

[0026] In one embodiment of the present application, the non-table parts at least include a text part, a title part, a table title part, and a picture part.

[0027] Specifically, first, the page analysis of the PDF document is performed using the layout recognition technology, and the document content is divided into different areas, including the text part, the title part, the table part, the table title part, and the picture part. Through the layout recognition technology, the specific location and content of each part can be accurately identified and marked. For example, the text part contains the main content of the document, the title part contains the main title of the document, the table title part contains the title of the table, and the picture part includes images or charts.

[0028] After the table part is identified and annotated, a summary of the table is generated first. This summary extracts the core information of the table, including the key fields, values, and main trends reflected in the table. The purpose of the table summary is to describe the content of the table concisely and accurately. On this basis, keywords are extracted from the first row and first column of the table. The keywords are used as query terms in the retrieval model to calculate the TF-IDF scores related to the query terms in the non-table part.

[0029] The TF-IDF score is calculated using the query terms in the body, title, table title, and image parts. The TF-IDF score evaluates the relevance of each keyword to the non-table part by measuring the frequency and inverse document frequency of each keyword in the non-table part. For example, the body contains more table-related keywords, the title may contain high-weight keywords related to the table topic, and the table title helps to deepen the understanding of the table topic. For the image part, although the image itself cannot directly calculate the TF-IDF score, the text content in the image can be extracted through OCR technology or image recognition technology, and combined with the TF-IDF algorithm to extract keywords.

[0030] Based on the text type (such as body, title, table title, image, etc.), the position from the table, and the TF-IDF score, the relevance score of each non-tabular part to the target table is calculated. When calculating the relevance score, the importance of different text types is taken into account. For example, the title part usually has a high match with the table content, the table title part has a more direct relationship with the table, and the body part may provide more detailed background information. In addition, considering that the text is physically closer to the table, the table will have a higher relevance score. Finally, all non-tabular parts will calculate a score based on comprehensive factors, reflecting their relevance to the target table.

[0031] The non-table parts are sorted according to the relevance scores. After sorting, the most relevant contextual information is extracted, including text paragraphs that are highly matched with the table content. This contextual information will help the system generate more precise results. The contextual information can be an explanation of the table, background description, or other paragraphs related to the table content, which ultimately supports the table recall.

[0032] The extracted context information, table summary, and table keywords are combined to form a table block. The table block includes the key information of the table, the relevant context, and the table summary. Then, vectorization technology is used to convert these contents into high-dimensional vectors and express them in numerical form for efficient storage and calculation. Next, these vectors are uploaded to the vector database and stored as index blocks of the table.

[0033] When a user makes a query, the query module will retrieve the table blocks that are most relevant to the query target table in the vector database based on the user's query target. The retrieval process can accurately return the table blocks related to the query content by calculating the similarity between vectors. The retrieved target table will be presented to the user to meet the user's query needs.

[0034] The above technical solution can significantly improve the accuracy and efficiency of table recall in PDF documents. Through accurate layout recognition technology, the table part in the PDF document can be effectively distinguished from the text part, title part, table title part and picture part. The steps of generating table summaries and extracting table keywords enable the core content of the table to be effectively captured and provide accurate query terms for subsequent retrieval. By calculating factors such as TF-IDF scores, text types, and positions, the relevance of each non-table part to the target table is comprehensively evaluated, thereby improving the accuracy of the recall results. In the process of sorting and extracting contextual information, the system can more accurately extract text paragraphs that are highly relevant to the table content, further optimizing the recall results. Through vectorization processing and uploading to the vector database, efficient query retrieval can be performed, and the table blocks most relevant to the user's query target can be quickly located. Finally, users can obtain accurate and efficient table recall results, greatly improving the efficiency and quality of information retrieval.

[0035] In one embodiment of the present application, the retrieval model is constructed by the BM25 algorithm.

[0036] Specifically, when constructing the retrieval model, the BM25 algorithm is used to index the non-table part of the document. The BM25 algorithm is a sorting algorithm based on a probabilistic information retrieval model and is widely used in text information retrieval. BM25 scores the relevance of each keyword in the document by considering the term frequency (TF) and inverse document frequency (IDF) of each keyword in the document, and combining factors such as document length. In this implementation, the BM25 algorithm will calculate the relevance score of the text content related to the table by the degree of matching with the extracted table keywords.

[0037] By adopting the above technical solution, when extracting table keywords and using the BM25 algorithm for retrieval, the correlation between the text and the table content can be effectively evaluated. The BM25 algorithm can make full use of the distribution information of keywords and enhance the accuracy of retrieval by comprehensively considering the word frequency and inverse document frequency.

[0038] In one embodiment of the present application, searching and querying a target table block in a vector database by a query module, and presenting the retrieved target table to a user, includes the following steps: After receiving the user query, the retrieval model is used to retrieve the target table block in the vector database and return the target table block most relevant to the query; Combine the retrieved target table blocks with the original query to form a comprehensive context; Based on the comprehensive context, a generative model is used to generate the final answer or content and output it to the user.

[0039] Specifically, a query input by a user is first received. The query may be a question, a descriptive text, or other types of query requests. The user query may involve data related to the table, the content contained in the table, or the information presented by the table.

[0040] After receiving a user query, the system uses a retrieval model (such as the BM25 algorithm) to retrieve content related to the query target table block in a pre-stored vector database. The retrieval model returns the target table block most relevant to the query by calculating the similarity between the query and the table blocks stored in the database. Specifically, the retrieval process first converts the user query into a query vector, and matches the table blocks in the database through vector similarity calculation, and selects the most relevant table block as the candidate result.

[0041] The retrieval model returns the target table block that is most relevant to the user's query from the vector database. The table block contains the key information of the table and the context data related to the table, which can be a summary of the table, extracted keywords, context description, etc. The returned target table block is the data block that best answers the user's query needs.

[0042] Combine the retrieved target table block with the user's original query to form a comprehensive context. At this point, the content in the target table block will be matched and integrated with the requirements in the user's query. For example, if the user query involves some specific data or background information in the table, the relevant information in the table block will be combined with the query to generate a complete context for further processing by the generative model.

[0043] Based on the comprehensive context, the generative model (such as the GPT series model or similar natural language generation model) will generate the final answer or content based on the combination of the table block and the query content. The generative model uses the information in the context for reasoning and generation to ensure that the generated answer is highly relevant to the user's query needs and can accurately and thoroughly answer the user's questions or provide relevant information.

[0044] Finally, the generated answers or content will be output and presented to the user. The user can further understand the relevant data or information of the target table based on the answers provided by the system.

[0045] By adopting the above technical solution, the accuracy and efficiency of table recall can be effectively improved by retrieving and querying the target table blocks in the vector database. Through the retrieval model, the system can quickly find the most relevant content to the query from a large number of table blocks, and combine it with the original query to generate a comprehensive context. This process ensures that the recall results of table information are not only highly matched with the table content, but also meet the specific needs of the user's query. By using a generative model to generate the final answer based on a comprehensive context, the accuracy, logic and richness of the answer can be greatly improved, thereby improving the user experience.

[0046] In one embodiment of the present application, the generation model is ChatGPT.

[0047] The present application also discloses a system for implementing the above method, comprising: Layout recognition module, used to recognize and mark the table part and various non-table parts in the PDF document; A keyword extraction module is used to extract the content of the first row and the first column from the table part to generate query words; A text analysis module to calculate the TF-IDF scores of query terms in the non-tabular part; A sorting module, for sorting the non-tabular parts according to the relevance scores and extracting the sorted context information; A vectorization module, used to combine context information, table summary, and table keywords to form table blocks and vectorize them, and upload them to the vector database; and The query module is used to retrieve relevant table blocks from the vector database based on user query information and present them to the user.

[0048] Specifically, the layout recognition module is responsible for identifying and annotating the table part and various non-table parts in the PDF document. After receiving the PDF document, the layout recognition module parses the page layout of the PDF and divides the page into multiple areas, including the text part, the title part, the table part, the table title part, and the image part. The layout recognition module uses advanced layout analysis algorithms, such as the layout analysis model based on deep learning, to automatically identify and annotate different parts in the document. By accurately identifying each area, the layout recognition module provides clear structural information for the subsequent table recall and information retrieval process.

[0049] After the table part is successfully identified, the keyword extraction module extracts the contents of the first row and first column from the table. The first row usually contains the column headings of the table, and the first column contains the row headings of the table. The keyword extraction module uses text processing techniques such as part-of-speech tagging, named entity recognition, keyword extraction algorithms, etc. to extract key search terms from these parts. The keywords will be input as query terms into the subsequent retrieval model for relevance calculation in the non-table part.

[0050] The text analysis module is responsible for calculating the TF-IDF score of the query terms in the non-tabular part. By traversing the body part, title part, table title part, and image part of the PDF document, the module matches the query terms and calculates the TF-IDF value of each query term in the non-tabular part. TF-IDF is an algorithm that measures the importance of words in a document based on term frequency (TF) and inverse document frequency (IDF). By calculating the TF-IDF value of each query term, the module can evaluate the relevance of the query term to each part of the document.

[0051] The sorting module sorts the non-tabular parts by relevance based on the TF-IDF scores calculated by the text analysis module. The module combines the calculated relevance scores with the text type (such as body, title, table title, etc.) and the position information from the table to assign a final relevance score to each non-tabular part. The sorting module sorts the non-tabular parts by these scores, selects the most relevant contextual information, and extracts paragraphs that closely match the table content.

[0052] The vectorization module combines the sorted context information, table summary, and table keywords into a table block. A table block is a structure that contains table-related information and context, which can provide complete information support for the generation model. The vectorization module uses vectorization technology to convert these text information into high-dimensional vectors. The vectorized table blocks will be uploaded to the vector database for efficient query retrieval.

[0053] The query module is responsible for retrieving relevant table blocks in the vector database based on the user's query information. When the user enters a query, the query module first converts the user query into a query vector. Then, by calculating the similarity between the query vector and the table block vector in the database, the query module returns the table block most relevant to the query from the vector database. Finally, the query module presents the retrieved target table to the user to meet the user's query needs.

[0054] The above technical solution can effectively improve the recall and retrieval efficiency of table contents in PDF documents. Users can obtain high-quality and accurate table recall and answer generation results, which improves the overall efficiency and quality of information retrieval.

[0055] The present application also discloses a computer-readable storage medium storing computer-executable instructions. When the instructions are executed in a computer system, the above method can be implemented.

[0056] The above description is only a preferred embodiment of the present invention, and does not limit the patent scope of the present invention. All equivalent structural changes made by using the contents of the present invention specification and drawings under the inventive concept of the present invention, or directly / indirectly applied in other related technical fields are included in the patent protection scope of the present invention.

Claims

1. A method for recalling a table in a PDF, characterized in that: The following steps are involved: Perform layout recognition on the content of PDF documents, identify and mark the table part and non-table parts of the PDF document; Generate a table summary based on the table part, extract the first row and first column of the table from the table part, generate keywords, use the keywords as query words of the retrieval model, and calculate the TF-IDF score of the query words in the non-table part; Calculate the relevance score of each non-table part to the table based on the text type and / or the distance position from the table and / or the TF-IDF score; Rank the non-tabular parts based on the relevance scores and extract the ranked context information; The context information, table summary, and table keywords are combined to form a table block, which is then uploaded to the vector database after vectorization processing as the table index block; The query module retrieves and queries the target table block in the vector database, and presents the retrieved target table to the user.

2. The method for recalling a table in a PDF as claimed in claim 1, characterized in that: The non-table parts at least include a text part, a title part, a table title part, and a picture part.

3. The method for recalling a table in a PDF as claimed in claim 1, characterized in that: The retrieval model is constructed by the BM25 algorithm.

4. The method for recalling a table in a PDF as claimed in claim 1, characterized in that: Retrieving and searching the target table block in the vector database through the query module, and presenting the retrieved target table to the user, includes the following steps: After receiving the user query, the retrieval model is used to retrieve the target table block in the vector database and return the target table block most relevant to the query; Combine the retrieved target table blocks with the original query to form a comprehensive context; Based on the comprehensive context, a generative model is used to generate the final answer or content and output it to the user.

5. The method for recalling a table in a PDF as claimed in claim 4, characterized in that: The generative model is ChatGPT.

6. A system for implementing the method of any one of claims 1 to 5, characterized in that: include: Layout recognition module, used to recognize and mark the table part and various non-table parts in the PDF document; A keyword extraction module is used to extract the content of the first row and the first column from the table part to generate query words; A text analysis module to calculate the TF-IDF scores of query terms in the non-tabular part; A sorting module, for sorting the non-table parts according to the relevance scores and extracting the sorted context information; A vectorization module, used to combine context information, table summary, and table keywords to form table blocks and vectorize them, and upload them to the vector database; and The query module is used to retrieve relevant table blocks from the vector database based on user query information and present them to the user.

7. A computer-readable storage medium storing computer-executable instructions, which, when executed in a computer system, can implement the method of any one of claims 1 to 5.

Citation Information

Cited By

  • Table content structured processing method and device, medium and product

    CN121747136A