Document processing method and computing device

By identifying and processing document structure information, dividing document blocks and applying appropriate processing algorithms, the knowledge base construction problems of poor normative and complex structures are solved, and the answer accuracy and completeness of large language models are improved.

CN120508641APending Publication Date: 2025-08-19XFUSION DIGITAL TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510415796.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-02
Publication Date
2025-08-19

AI Technical Summary

Technical Problem

The existing technology cannot effectively build a knowledge base with poor normative and complex structured documents, resulting in the lack of knowledge and model hallucinations of large language models when answering questions.

Method used

By identifying the structure information of the document, dividing the content data into document blocks, and determining the preset processing algorithm according to the layout, processing the content data in each document block, constructing structured data with the document block as storage units, and building a knowledge base.

Benefits of technology

It improves the matching accuracy and accuracy of content data, reduces the inaccuracy and inaccuracy of prompt words, ensures the correctness of the results generated by large language models, and avoids the lack of knowledge and model illusions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120508641A_ABST
    Figure CN120508641A_ABST
Patent Text Reader

Abstract

The document processing method is used for identifying and processing information recorded by a document and comprises the steps that the document to be processed is obtained, the information recorded by the document to be processed comprises structure information and content data, and the structure information is used for dividing the content data; obtaining structure information of the to-be-processed document; dividing the content data according to the structure information to obtain at least one document block; determining a preset processing algorithm corresponding to each document block according to the format of the content data in each document block; determining content data in each document block according to a preset processing algorithm; and obtaining a processed document according to the structure information and the content data in each document block. In the application, the processed document is structured data taking the document block as a storage unit, so that when the content data of the question input by the user is matched from the knowledge base, the content data in different document blocks can be matched from the knowledge base, and the precision and accuracy of the matched content data are higher.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence technology, and in particular to a document processing method and computing device. Background Art

[0002] Generally speaking, in the process of building a large language model application, in order to reduce the phenomenon of knowledge loss (not knowing the correct answer) and model hallucination (giving the wrong answer) when the large language model answers questions, giving the large language model sufficient and accurate prompts before answering the questions is one of the most effective solutions. In the field of Retrieval-Augmented Generation (RAG) technology, the content data in the knowledge base directly affects the accuracy and adequacy of the prompt words. However, for documents with poor standardization and complex structure, it is impossible to directly build a knowledge base based on existing documents. Therefore, a document processing method is needed to process documents with poor standardization and complex structure to build a knowledge base. Summary of the Invention

[0003] In order to solve the above problems, the present application provides a document processing method and computing device that can process documents with poor standardization and complex structure to build a knowledge base.

[0004] In a first aspect, the present application provides a document processing method for identifying and processing information recorded in a document, including: obtaining a document to be processed, the information recorded in the document to be processed including structural information and content data, the structural information being used to divide the content data; obtaining the structural information of the document to be processed; dividing the content data according to the structural information to obtain at least one document block; determining a preset processing algorithm corresponding to each document block according to the layout of the content data in each document block; determining the content data in each document block according to the preset processing algorithm; and obtaining a processed document according to the structural information and the content data in each document block.

[0005] In this application, for documents with poor standardization and complex structures, content data is divided according to structural information to obtain at least one document block; and the content data in each document block is determined according to a preset processing algorithm. Thus, the processed document includes at least one document block, which is obtained by dividing the content data according to structural information. Therefore, the processed document is a type of structured data stored in document blocks. Constructing a knowledge base based on processed documents solves the problem of being unable to directly construct a knowledge base based on existing documents for documents with poor standardization and complex structures. Thus, when matching the content data of a user-entered question from the knowledge base, content data from different document blocks can be matched from the knowledge base, resulting in higher precision and accuracy of the matched content data. Consequently, the generated prompt words are more accurate and precise, and the generated results of the large language model are more accurate, avoiding the problem of inaccurate and imprecise prompt words caused by excessive redundancy in the matching data. This reduces or eliminates the phenomenon of knowledge gaps and model hallucinations that occur when the large language model answers questions. In addition, according to the content data layout in the document block, the content data is processed using preset processing algorithms corresponding to different layouts, which ensures the integrity of the content data and avoids the loss of certain content data (such as information loss when the layout is an image, table, etc.); thereby ensuring the adequacy of the generated prompt words, and further ensuring that the generation results of the large language model are more accurate, reducing or avoiding the phenomenon of knowledge loss and model hallucinations in the large language model when answering questions.

[0006] In a possible implementation, the above-mentioned obtaining of the structural information of the document to be processed includes: obtaining text data of the document to be processed; and determining the structural information of the document to be processed according to the text data.

[0007] In this implementation, structural information of the document to be processed is determined based on the document's text data. For example, if the text data includes title information or structural terms, this portion of the text data can be used as structural information for document segmentation. This ensures that the at least one document block segmented based on the structural information better reflects the data characteristics of the document to be processed.

[0008] In a possible implementation, the determining of the text data of the document to be processed includes: when the document to be processed is in an uneditable state, obtaining the text data of the document to be processed according to a text recognition algorithm.

[0009] In this implementation, the text recognition algorithm can accurately identify the structural information and content data in the non-editable document, thereby ensuring the accuracy of the structural information and content data in the document.

[0010] In a possible implementation, dividing the content data according to the structural information to obtain at least one document block includes: determining a division position in the document to be processed according to the structural information; and dividing the content data into at least one document block according to the division position.

[0011] In this implementation, the document's partitioning location is determined based on structural information; based on the partitioning location, the content data is divided into at least one document block. This allows the document to be divided into at least one document block based on the structural information, and the document's content data in the knowledge base is structured and stored based on the structural information. Consequently, when matching knowledge base content data to questions, the matching accuracy is higher, and the generated prompt words are more accurate.

[0012] In one possible implementation, the above-mentioned determination of the preset processing algorithm corresponding to each document block based on the layout of the content data in each document block includes: identifying the layout of the content data in each document block based on the layout recognition algorithm; and determining the preset processing algorithm corresponding to each document block based on the layout.

[0013] In this implementation, the layout recognition algorithm has a high degree of recognition of the layout of the content data in the document block, thereby ensuring the accuracy of the recognition result of the layout of the content data.

[0014] In one possible implementation, the layout of the content data in each document block includes an image; determining the content data in each document block according to a preset processing algorithm includes: when the layout of the content data in the document block includes an image, obtaining content description information of the image in the document block; storing the image in the document block to obtain storage address information of the image in the document block; and determining the content data corresponding to the image in the document block according to at least one of the content description information and the storage address information.

[0015] In this implementation, the image's content description and storage address are used as the processing result of the document block, resulting in more accurate image information within the knowledge base. Based on the image's content description, it's possible to determine what the image depicts and what information it conveys. Consequently, when matching content data related to the question from the knowledge base, more precise images with a higher degree of match can be found, improving the accuracy of the matched content data and the accuracy of the generated prompt words.

[0016] In one possible implementation, the layout of the content data in each document block includes text and / or tables; and the content data in each document block is determined according to a preset processing algorithm, including: when the layout of the content data in the document block includes text, obtaining the content data corresponding to the text in the document block according to a text recognition algorithm; when the layout of the content data in the document block includes a table, obtaining the content data corresponding to the table in the document block according to a table recognition algorithm.

[0017] In this implementation, text recognition algorithms and table recognition algorithms are tools for recognizing text and tables, such as optical character recognition technology, which can accurately recognize the content data of text layout and table layout, ensuring the accuracy of the content data of text layout and table layout.

[0018] In a possible implementation, the method further includes: determining whether a cross-page table exists in the document block; and when a cross-page table exists in the document block, merging the cross-page tables to obtain a complete table.

[0019] In this implementation, a complete table can be obtained by merging tables across pages, which solves the problem of poor recognition effect of tables across pages and improves the matching accuracy of content data in the knowledge base.

[0020] In one possible implementation, the above-mentioned determination of whether a cross-page table exists in a document block includes: when the end position of the current page is the first table and the starting position of the next page is the second table, inputting the first table and the second table into a classification model to output a classification result; and judging whether the first table and the second table are cross-page tables based on the classification result.

[0021] In this implementation, the classification model has a high recognition accuracy, which ensures the accuracy of the judgment results of cross-page tables.

[0022] In a possible implementation, the structure information includes multiple header information.

[0023] In this implementation, title information is a common form of structural information. Structural information can also be structural words, such as "Part I", "Part II", "First", "Then", etc. The embodiment of this application does not limit the form of structural information.

[0024] In a second aspect, the present application provides a knowledge base construction method, comprising: processing a document to be processed according to the document processing method of the first aspect to obtain a processed document; and constructing an entity knowledge base based on the processed document.

[0025] On the third aspect, the present application provides a question-answering method, comprising: constructing a knowledge base according to the knowledge base construction method of the second aspect; when receiving a question input by a user, recalling content data matching the question from the knowledge base; inputting the question and the recalled content data into a large language model to generate an answer to the question.

[0026] In a fourth aspect, the present application provides a document processing device for identifying and processing information recorded in a document, including: a first acquisition module for acquiring a document to be processed, the information recorded in the document to be processed including structural information and content data, the structural information being used to divide the content data; acquiring the structural information of the document to be processed; a first processing module for dividing the content data according to the structural information to obtain at least one document block; determining a preset processing algorithm corresponding to each document block according to the layout of the content data in each document block; determining the content data in each document block according to the preset processing algorithm; and obtaining a processed document according to the structural information and the content data in each document block.

[0027] In a possible implementation, when acquiring the structural information of the document to be processed, the first processing module is specifically configured to: acquire text data of the document to be processed; and determine the structural information of the document to be processed based on the text data.

[0028] In a possible implementation, when determining the text data of the document to be processed, the first processing module is specifically configured to obtain the text data of the document to be processed according to a text recognition algorithm when the document to be processed is in an uneditable state.

[0029] In one possible implementation, when dividing content data according to structural information to obtain at least one document block, the above-mentioned first processing module is specifically used to: determine the division position in the document to be processed according to the structural information; and divide the content data into at least one document block according to the division position.

[0030] In one possible implementation, when determining the preset processing algorithm corresponding to each document block based on the layout of the content data in each document block, the above-mentioned first processing module is specifically used to: identify the layout of the content data in each document block based on the layout recognition algorithm; and determine the preset processing algorithm corresponding to each document block based on the layout.

[0031] In one possible implementation, the layout of the content data in at least one document block includes an image. When determining the content data in each document block according to a preset processing algorithm, the first processing module is specifically configured to: when the layout of the content data in the document block includes an image, obtain content description information of the image in the document block; store the image in the document block to obtain storage address information of the image in the document block; and determine the content data corresponding to the image in the document block based on at least one of the content description information and the storage address information.

[0032] In one possible implementation, the layout of the content data in at least one document block includes text and / or a table. When determining the content data in each document block according to a preset processing algorithm, the first processing module is specifically configured to: when the layout of the content data in the document block includes text, obtain the content data corresponding to the text in the document block according to a text recognition algorithm; and when the layout of the content data in the document block includes a table, obtain the content data corresponding to the table in the document block according to a table recognition algorithm.

[0033] In a possible implementation, the first processing module is further configured to: determine whether a table spanning multiple pages exists in the document block; and when a table spanning multiple pages exists in the document block, merge the tables spanning multiple pages to obtain a complete table.

[0034] In one possible implementation, when determining whether a table that spans multiple pages exists in a document block, the first processing module is specifically configured to: when the end position of the current page is the first table and the starting position of the next page is the second table, input the first table and the second table into a classification model to output a classification result; and determine, based on the classification result, whether the first table and the second table are tables that span multiple pages.

[0035] In a possible implementation, the structure information includes multiple header information.

[0036] In the fifth aspect, the present application provides a knowledge base construction device, including: a second acquisition module for acquiring processed documents, which are obtained by processing the documents to be processed according to the document processing method of the first aspect; a second processing module for constructing an entity knowledge base based on the processed documents.

[0037] In the sixth aspect, the present application provides a question-answering device, including: a third acquisition module, used to acquire a knowledge base, which is constructed according to the knowledge base construction method of the second aspect; a third processing module, used to recall content data matching the question from the knowledge base when receiving a question input by a user; and input the question and the recalled content data into a large language model to generate an answer to the question.

[0038] In a seventh aspect, the present application provides a server, which is deployed with a large language model, and is used to execute the methods described in the first, second, and third aspects above and any possible implementation thereof.

[0039] In an eighth aspect, the present application provides a question-and-answer system, comprising a terminal device and a server, wherein the terminal device is used to receive questions input by a user, and the server is used to execute the methods described in the above first, second, and third aspects and any possible implementation thereof to generate answers.

[0040] In a ninth aspect, the present application provides a computing device comprising a processor and a memory. The memory is configured to store program code and transmit the program code to the processor; the processor is configured to execute the method described in the first, second, and third aspects and any possible implementation thereof according to instructions in the program code.

[0041] In the tenth aspect, the present application provides a computing device cluster, including at least one computing device, each computing device including a processor and a memory; the processor of at least one computing device is used to execute instructions stored in the memory of at least one computing device, so that the computing device cluster executes the method described in the above first, second, and third aspects and any possible implementation methods thereof.

[0042] In the eleventh aspect, the present application provides a computer-readable storage medium comprising computer program instructions. When the instructions are executed by a computing device cluster, the computing device cluster executes the method described in the first, second, and third aspects above and any possible implementation thereof, wherein the computing device cluster includes at least one computing device.

[0043] In a twelfth aspect, the present application provides a computer program product comprising instructions, which, when executed by a computing device cluster, enables the computing device cluster to execute the methods described in the above-mentioned first, second, and third aspects and any possible implementation thereof, wherein the computing device cluster includes at least one computing device.

[0044] In the thirteenth aspect, the present application provides a chip system, which includes a processor and a power supply circuit, the power supply circuit is used to supply power to the processor, and the processor is used to execute the methods described in the first, second, and third aspects above and any possible implementation methods thereof.

[0045] It can be understood that the beneficial effects of the second to thirteenth aspects can be found in the relevant description of the first aspect, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] The following is a brief introduction to the drawings required for describing the embodiments or prior art.

[0047] Figure 1aA schematic diagram of the working process of a large language model based on retrieval enhancement generation technology provided in an embodiment of the present application;

[0048] Figure 1b A schematic diagram of a question-answering system provided in an embodiment of the present application;

[0049] Figure 2 A flowchart of a question-and-answer method provided in an embodiment of the present application is shown;

[0050] Figure 3 A flowchart of a document processing method provided in an embodiment of the present application;

[0051] Figure 4 A schematic diagram of a process for constructing a knowledge base provided in an embodiment of the present application;

[0052] Figure 5 A schematic diagram of an example of a document provided in an embodiment of the present application;

[0053] Figure 6a A schematic diagram of an example of a document processing method provided in an embodiment of the present application;

[0054] Figure 6b A schematic diagram of another example of a document provided in an embodiment of the present application;

[0055] Figure 6c A schematic diagram of document blocks after a document is divided according to an embodiment of the present application;

[0056] Figure 6d A schematic diagram of an example of merging cross-page tables provided in an embodiment of the present application;

[0057] Figure 6e Schematic diagram of different formats of document blocks provided in the embodiments of the present application;

[0058] Figure 7 A schematic diagram of the structure of a document processing device provided in an embodiment of the present application;

[0059] Figure 8 A schematic diagram of the structure of a knowledge base construction device provided in an embodiment of the present application;

[0060] Figure 9 This is a schematic diagram of the structure of a question-and-answer device provided in an embodiment of the present application;

[0061] Figure 10 is a structural diagram of a computing device provided in an embodiment of the present application;

[0062] Figure 11 This is a schematic diagram of the structure of a computing device cluster provided in an embodiment of the present application;

[0063] Figure 12 This is a schematic diagram of the structure of another computing device cluster provided in an embodiment of the present application. DETAILED DESCRIPTION

[0064] The term "and / or" as used herein describes an association between related objects, indicating that three possible relationships exist. For example, "A and / or B" can represent: A exists alone, A and B exist simultaneously, or B exists alone. The symbol " / " as used herein indicates that the related objects are in an "or" relationship. For example, A / B means either A or B.

[0065] The terms "first" and "second" in this specification and claims are used to distinguish different objects rather than to describe a specific order of objects. For example, "first response message" and "second response message" are used to distinguish different response messages rather than to describe a specific order of response messages.

[0066] In the embodiments of this application, words such as "exemplary" or "for example" are used to indicate examples, illustrations, or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of this application should not be construed as being preferred or advantageous over other embodiments or designs. Rather, the use of words such as "exemplary" or "for example" is intended to present the relevant concepts in a concrete manner.

[0067] In the description of the embodiments of the present application, unless otherwise specified, "multiple" means two or more, for example, multiple processing units means two or more processing units, etc.; multiple elements means two or more elements, etc.

[0068] In order to facilitate understanding of the solution provided by the embodiment of the present application, a brief introduction to some of the terms involved in the solution is first given.

[0069] Enterprise Knowledge Base: A system or platform used within an enterprise to store, manage, and share knowledge resources. It stores various corporate documents, such as policies, processes, manuals, training materials, etc., and records the experiences and lessons learned from different projects and tasks, and is used to help employees solve problems encountered in their work.

[0070] Large Language Model (LLM): Also known as a large model, it is an artificial intelligence model that uses deep learning algorithms to train on large amounts of text data to learn language patterns and structures, thereby enabling it to understand and generate natural language text.

[0071] Prompt: refers to the input text used to guide or stimulate the model to perform a specific task. The purpose is to help the model understand the type of task the user wants to perform or the required output format.

[0072] Retrieval-Augmented Generation (RAG): RAG technology allows users to retrieve content data related to their questions from a configured knowledge base. The question and content data are combined to generate prompt words. Using these prompt words, a large language model can better understand and answer user questions, generating more accurate answers.

[0073] Optical Character Recognition (OCR) is a technology that uses computers to automatically identify and interpret text in images. It can convert text on paper documents, images, photos, and other media into text data that can be edited and processed by computers.

[0074] Table OCR Tool: Table OCR Tool uses optical character recognition (OCR) technology to identify and interpret table content in images. It can convert tables in images into editable and searchable table formats for subsequent processing and analysis.

[0075] Figure 1a This is a schematic diagram of the working process of a large language model based on retrieval-augmented generation technology provided in an embodiment of the present application. It can be understood that the method of generating answers by a large language model based on retrieval-augmented generation (RAG) technology can be executed by any device, equipment, platform, or device cluster with computing and processing capabilities. Figure 1a As shown in the figure, the working process of the large language model based on RAG technology mainly includes: obtaining the question input by the user; performing similarity matching and other matching methods based on the question to retrieve content data matching the question from the knowledge base; generating prompt words based on the question and the matching content data; inputting the prompt words into the large language model, and under the prompt of the prompt words, the large language model generates the answer to the question.

[0076] Generally speaking, in the process of building a large language model application, in order to reduce the phenomenon of knowledge loss (not knowing the correct answer) and model hallucination (giving the wrong answer) when the large language model answers questions, one of the most effective solutions is to give the large language model sufficient and accurate prompts before answering the questions.

[0077] It is understandable that in the field of RAG technology, the content data in the knowledge base directly affects the accuracy and adequacy of the prompt words. Therefore, building a reasonable knowledge base can improve the matching accuracy of content data, and thus improve the accuracy and adequacy of the prompt words, and can reduce the phenomenon of knowledge gaps (not knowing the correct answer) and model hallucinations (giving incorrect answers) when answering questions in large language models. Taking the enterprise knowledge base as an example, the enterprise knowledge base usually contains a large number of documents. These documents may be in PDF, Word, PPT, etc. These documents contain rich information and knowledge. Due to the poor standardization and complex document structure of enterprise documents, the document processing methods of related technologies cannot build an enterprise knowledge base with sufficient information and high accuracy.

[0078] Therefore, an embodiment of the present application provides a question-answering method that uses a document processing method to build a more reasonable knowledge base, thereby improving the accuracy and adequacy of the prompt words input into the large language model and improving the accuracy of the answers output by the large language model.

[0079] Figure 1b Schematic diagram of a question-answering system provided in an embodiment of the present application. Figure 1b As shown, an embodiment of the present application provides a question-answering system 100 (hereinafter referred to as "system 100"), which mainly includes: a terminal device 110 and a server 120. The terminal device 110 is used to obtain questions input by a user; the server 120 is deployed with a large language model, which is used to, when receiving a question input by a user, recall content data matching the question from the entity's knowledge base, and input the question and the recalled content data into the large language model to generate an answer to the question.

[0080] Furthermore, the server 120 may include one or more servers ( Figure 1b The server 120 may provide the method and / or apparatus provided in the embodiment of the present application to one or more terminal devices.

[0081] Furthermore, the terminal device 110 may be installed with an application related to the method and / or apparatus of the present application. The application or webpage may provide an interface. The terminal device 110 may receive questions entered by the user on the interface and send the questions to the server 120. The server 120 may deploy a large language model, which may build a knowledge base based on the entity's documents; retrieve content data matching the question from the entity's knowledge base; input the question and the retrieved content data into the large language model to generate an answer to the question; and optionally, output the answer to the user. This enables information exchange between the terminal device 110 and the server 120.

[0082] It should be understood that in some optional implementations, the terminal device 110 is deployed with a large language model, and the terminal device 110 can also complete the action of obtaining answers based on the received questions by itself without the need for server cooperation. The embodiments of the present application are not limited to this.

[0083] Next, the product form of the terminal device 110 is described. The terminal device 110 in the embodiment of the present application can be a mobile phone, a tablet computer, a wearable device, a vehicle-mounted device, an augmented reality (AR) / virtual reality (VR) device, a laptop computer, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), etc., and the embodiment of the present application does not impose any restrictions on this. Exemplary embodiments of the terminal device 110 involved in this solution include but are not limited to electronic devices equipped with iOS, Android, Windows, Harmony OS or other operating systems. The embodiment of the present application does not specifically limit the type of electronic device.

[0084] Next, the product form of the server 120 is described. It can be further understood that the server 120 can be a variety of servers, such as an X86 architecture server, and can specifically be a whole cabinet server, a blade server, a high-density server, a rack server, or a high-performance server. In other words, the embodiments of the present application do not specifically limit the specific category of the server. Furthermore, it can be understood that the structure of the server shown in Figure 1 does not constitute a limitation on the structure of the server. The server may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.

[0085] Furthermore, the server 120 can be configured as an independent physical server, or as a server cluster or distributed system composed of multiple physical servers. It can also be configured as a cloud server or cloud server cluster that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms. The cloud server cluster is deployed in several cloud data centers; the software can be an application that implements object control methods, etc., but is not limited to the above forms.

[0086] Next, the communication connection mode between the terminal device 110 and the server 120 is described. Exemplarily, the terminal device 110 and the server 120 are connected via a network, so that the terminal device 110 can access the cloud management platform deployed by the cloud server cluster. The network can be a wired network or a wireless network. For example, the wired network can be a cable network, an optical fiber network, a digital data network (DDN), etc., and the wireless network can be a telecommunications network, an intranet, the Internet, a local area network (LAN), a wide area network (WAN), a wireless local area network (WLAN), a metropolitan area network (MAN), a public switched telephone network (PSTN), a Bluetooth network, a ZigBee network, a mobile phone (Global System for Mobile Communications, GSM), a CDMA (Code Division Multiple Access) network, a CPRS (General Packet Radio Service) network, etc. or any combination thereof.

[0087] It will be appreciated that the network may use any known network communication protocol to enable communication between different terminal device layers and gateways. The network communication protocol may be various wired or wireless communication protocols, such as Ethernet, universal serial bus (USB), FireWire, global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), wideband code division multiple access (WCDMA), time-division code division multiple access (TD-SCDMA), long term evolution (LTE), new radio (NR), Bluetooth, wireless fidelity (Wi-Fi), and other communication protocols.

[0088] In one possible scenario, server 120 can serve as a cloud (a software platform that uses application virtualization technology and integrates multiple functions such as software search, download, use, management, and backup). In actual use, server 120 can deploy a cloud management platform and a data center, and the terminal device 110 and the cloud can interact through the cloud management platform. In addition, the data center can deploy nodes, where the nodes in the data center can be virtual machine instances, container instances, physical servers, etc.

[0089] In another possible scenario, the model training method and script generation method provided in the embodiments of the present application can be implemented through software. The software includes a terminal device and a server, wherein the terminal device 110 is a terminal device running the software, and the server 120 is a server running the software. During the process of the terminal device 110 running the software, the server running on the server 120 can be called to implement the model training method and script generation method provided in the embodiments of the present application.

[0090] That is to say, the model training method and script generation method provided in the embodiments of the present application can be applied to the above-mentioned terminal device 110, and can also be applied to the server 120. In specific implementation, it can be run on the terminal device 110 or the server 120 in the form of software. For example, the software can be a service or an application. The embodiments of the present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The embodiments of the present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.

[0091] Figure 2 This is a flow chart of a question-answering method provided in an embodiment of the present application. It is understood that the question-answering method can be executed by any device, equipment, platform, or equipment cluster with computing and processing capabilities. Figure 2 As shown, the embodiment of the present application provides a question-answering method, which mainly includes the following steps:

[0092] Step S210: Acquire the entity's document. A document can be any document that records structural information and content data. "Document" here refers to a document before processing, also known as a document to be processed.

[0093] In the embodiments of this application, an entity represents the subject of a document. For example, an entity is an enterprise, and the entity's documents refer to the documents of this enterprise. The knowledge base constructed is the knowledge base of this enterprise. The content data in the knowledge base can be any information about the enterprise, such as the enterprise's "main business," "development history," "operating status," and "key executives," thereby assisting the enterprise in internal knowledge dissemination and external publicity. Entities can also be government departments, hospitals, schools, etc.

[0094] In the embodiments of the present application, structural information refers to information related to the text structure of a document, such as a title, structural terms (e.g., "Part I," "Part II," "First," "Then"), etc. Content data refers to the text content of a document, such as the specific content of the document. Content data can be recorded in the form of text, tables, images, etc.

[0095] Step S220: Process the content data based on the structural information to construct a knowledge base of the entity. The knowledge base includes at least one document block, which is obtained by dividing the content data based on the structural information. The content data in each document block is processed using a preset processing algorithm corresponding to a different format.

[0096] Step S230: When a question input by a user is received, content data matching the question is retrieved from the entity's knowledge base.

[0097] In step S240 , the question and the recalled content data are input into the large language model to generate an answer to the question.

[0098] In an embodiment of the present application, the knowledge base includes at least one document block, which is obtained by dividing content data according to structural information. Therefore, the knowledge base is a structured data with document blocks as storage units. In this way, when matching questions input by users, content data in different document blocks can be matched from the knowledge base, and the precision and accuracy of the matched content data are higher. As a result, the accuracy of the generated prompt words is higher, and the generation results of the large language model are more correct, reducing or avoiding the phenomenon of knowledge loss (not knowing the correct answer) and model hallucination (giving incorrect answers) when the large language model answers questions. In addition, according to the layout of the content data in the document block, the content data is processed using preset processing algorithms corresponding to different layouts, ensuring the integrity of the content data and avoiding the loss of certain content data (such as information loss when the layout is an image, table, etc.). This ensures the adequacy of the generated prompt words and further ensures that the generation results of the large language model are more accurate, reducing or avoiding the phenomenon of knowledge loss (not knowing the correct answer) and model hallucination (giving incorrect answers) when the large language model answers questions.

[0099] The technical solution of the embodiment of the present application can be applied to any application scenario. For example, for the office scenario of enterprise employees, the question-answering method of the embodiment of the present application can be used to process various documents of the enterprise, establish an enterprise knowledge base, and assist the enterprise in knowledge dissemination and external publicity by setting up a question-answering device corresponding to the question-answering method. For another example, in the long run, the questions of users have similarities. The document processing method of the embodiment of the present application is used to build a knowledge base, which includes excellent cases of question and answer, and improves the accuracy of the prompt words input into the large language model during the question and answer process. For another example, in the field of government services, such as the service consultation scenario of the government hall, the question-answering method of the embodiment of the present application is used to build a knowledge base, which can improve the accuracy of the answers output by the large language model when users ask questions, thereby improving the user experience.

[0100] The document processing process and the knowledge base construction process in step 220 are further illustrated below.

[0101] Figure 3 This is a flowchart of a document processing method provided in an embodiment of the present application. It is understood that the document processing method can be executed by any device, equipment, platform, or equipment cluster with computing and processing capabilities. Figure 3 As shown, an embodiment of the present application provides a document processing method, which is used to identify and process information recorded in a document. The document processing method mainly includes the following steps:

[0102] Step S221: Acquire the structural information of the document. The "document" here refers to the document before processing, also known as the document to be processed.

[0103] The following is a further exemplary description of identifying structural information in a document.

[0104] Optionally, the document is pre-processed to convert the document into text data; and the structural information and content data of the document are obtained based on the text data of the document.

[0105] Exemplarily, the editability of a document is determined and a corresponding preprocessing method is employed. When a document is in an editable state, such as Word, Excel, or an editable PDF file, the document is converted into text data by reading the document (e.g., reading an encoded file stored on a server). An editable PDF file refers to a PDF file whose content data is stored on a server in an encoded manner. For example, the encoded file stored on the server is read to obtain text data of the editable PDF file.

[0106] Furthermore, when a document is in an uneditable state, such as an image or a non-editable PDF file, a text recognition algorithm, such as optical character recognition (OCR), is used to convert the document into text data. Based on the document's text data, the document's structural information and content data are obtained. A non-editable PDF file refers to a PDF file whose content data, such as text, is stored on the server as an image.

[0107] Furthermore, the text recognition algorithm can accurately identify the structural information and content data in non-editable documents, ensuring the accuracy of the structural information and content data in the documents.

[0108] Optionally, the text data of the document is input into the large language model, and the prompt word engineering of the large language model is used to instruct the large language model to analyze and output the structural information of the document.

[0109] Furthermore, the large language model has a strong ability to understand text and can understand the text context very well; the large language model can extract information from the text data of the document and output structural information with high accuracy.

[0110] For example, the structural information may be different levels of headings in a document. The prompt words input into the large language model may be "Please analyze the text in the following document and extract the different levels of headings in the document."

[0111] Step S222: Divide the content data according to the structural information to obtain at least one document block.

[0112] The following further illustrates exemplary division of content data into at least one document block based on structural information.

[0113] In the embodiments of the present application, the structural information of a document can be any information that can be used to divide a document into one or more parts. For example, the structural information can be a title in a document; based on the title, the document data in each title can be divided into a document block. For another example, the structural information can be structural words that have the function of dividing a document, such as "Part I," "Part II," "First," "Then," etc.; based on these words, the document can be divided into one or at least one document block.

[0114] Optionally, a division position in the document is determined according to the structural information; and the content data is divided into at least one document block according to the division position.

[0115] Furthermore, based on the structural information, a division position within the document is determined; based on the division position, the content data is divided into at least one document block. In this way, the document is divided into at least one document block based on the structural information, and the content data of the document in the knowledge base is structured and stored based on the structural information. Consequently, when matching the knowledge base content data to the question, the matching content data is more accurate, and the generated prompt words are more precise.

[0116] Generally, the layout of the content data that spans across pages is identified, and based on the different layouts, it is further determined whether to splice the contents of different pages. The layout of the content data may be text, images, tables, etc. In the first case, when the layout of the content data that spans across pages is text, text recognition can be performed using optical character recognition (OCR) technology, and the recognized text can be merged. In the second case, generally, the layout of the content data that spans across pages will not be an image, that is, the image will not be divided and set in adjacent pages, and the image will generally appear as a whole in the content data of a certain page. In the third case, the layout of the content data that spans across pages may also be a table. The following is a further exemplary description of the processing of the span-page table.

[0117] Optionally, it is determined whether there is a table spanning pages in the document block; if there is a table spanning pages in the document block, the tables spanning pages are merged to obtain a complete table.

[0118] Furthermore, by merging tables across pages, a complete table can be obtained, which solves the problem of poor recognition effect of tables across pages and improves the matching accuracy of content data in the knowledge base.

[0119] It should be noted that if the cross-page tables are not merged, when generating the prompt word, there may be phenomena such as not matching the appropriate table, matching only one table, or identifying the cross-page table as two independent tables. In this way, when matching the content data in the knowledge base, the recognition effect of the cross-page table is poor, and the error in the matched content data is large. In the embodiment of the present application, by merging the cross-page tables, a complete table can be obtained, which solves the problem of poor recognition effect of the cross-page table.

[0120] Optionally, the layout of the content data in the document is determined based on a layout recognition algorithm. If the layout of the content data at the end position of the current page is a table, which is also referred to as the first table; at the same time, the layout of the content data at the start position of the next page is also a table, which is also referred to as the second table; then the tables in the two adjacent pages may be cross-page tables. Exemplarily, the first table at the end position of the previous page and the second table at the start position of the next page are input into a classification model to output a classification result; based on the classification result, it is determined whether the first table at the end position of the previous page and the second table at the start position of the next page are cross-page tables.

[0121] Furthermore, the classification model has high recognition accuracy, ensuring the accuracy of the judgment results of cross-page tables. The classification model can be, for example, any neural network model with classification function, such as a neural network model based on a binary classification algorithm, such as the Bidirectional Encoder Representations from Transformers (BERT) model.

[0122] Step S223: Determine the preset processing algorithm corresponding to each document block according to the format of the content data in each document block.

[0123] Optionally, the layout of the content data in the document block is identified using a layout recognition algorithm. The layout of the content data refers to the recording format of the content data. For example, the layout of the content data can be text, images, tables, etc. In other words, the content data may include one or more paragraphs of text, one or more images, one or more tables, etc.

[0124] Furthermore, the layout recognition algorithm has a high degree of recognition of the layout of the content data in the document block, thereby ensuring the accuracy of the recognition result of the layout of the content data.

[0125] Exemplarily, a layout recognition algorithm can be any algorithm for identifying the layout of content data in a document block. An example of a layout recognition algorithm is template-based layout recognition, which uses predefined templates to match and extract layout information from a document. This method is suitable for structured documents such as forms and invoices. Another example of a layout recognition algorithm is machine learning-based layout recognition, which utilizes machine learning algorithms to train neural network models to automatically learn and recognize different types of layout information. This method is suitable for unstructured documents such as newspapers and magazines.

[0126] Step S224: Determine the content data in each document block according to a preset processing algorithm.

[0127] Optionally, the content data in each document block is divided into at least one document sub-block according to the layout of the content data in each document block; the content data in each document sub-block is processed according to a preset processing algorithm corresponding to the layout of each document sub-block to obtain a processing result for each document sub-block.

[0128] Furthermore, the content data undergoes a two-stage division. In the first stage, the content data is divided into at least one document block based on the structural information. In the second stage, the content data within each document block is divided into at least one document sub-block based on the layout of the content data within each document block. This facilitates content data processing, as each document sub-block corresponds to a specific layout, and the corresponding preset processing algorithm can be used to process the content data within a document sub-block.

[0129] The format of the content data of the document block can be any one or more of a variety of formats such as text, picture, table, etc. Below, taking text, picture, and table as examples, the preset processing algorithms of different formats are exemplarily described.

[0130] Optionally, if the layout of the content data in the document block includes an image, the image in the document block is input into the multimodal large model. The multimodal large model can analyze and understand the multimodal input data (such as an image) and output the content description information of the image; store the image and obtain the storage address information of the image; and use at least one of the content description information and the storage address information as the processing result of the document block.

[0131] Furthermore, the image's content description and storage address information are used as the processing result of the document block, making the image information in the knowledge base more accurate. Based on the image's content description, it is possible to determine what the image depicts and what information it conveys. Therefore, when matching content data related to the question from the knowledge base, more precise images with a higher degree of match can be found, improving the accuracy of the matched content data and the accuracy of the generated prompt words.

[0132] Furthermore, in the related art, only the layout of the document is recognized. For example, when an image is recognized, only the image is stored. In this way, when matching from the knowledge base, the matching algorithm cannot recognize the image, which leads to the problem of image information loss and large content data matching errors. In the embodiment of the present application, the knowledge base includes content description information and storage address information of the image. In this way, when matching from the knowledge base, the matching algorithm can recognize the image based on the content description information and read the image based on the storage address information, thereby solving the problem of image information loss.

[0133] Among them, the multimodal large model refers to a neural network model that can process multiple modal information (such as text, images, audio, etc.) at the same time. The multimodal large model is trained by multimodal data, so that the multimodal large model can better understand and generate cross-modal content. For example, in an embodiment of the present application, the input of the multimodal large model is an image, and the output is the content description information of the image.

[0134] Step S225: Obtain a processed document based on the structural information and the content data in each document block. The processed document is also called a processed document.

[0135] Figure 4 This is a flow chart of a knowledge base construction method provided in an embodiment of the present application. It is understood that the knowledge base construction method can be executed by any device, equipment, platform, or equipment cluster with computing and processing capabilities. Figure 4 As shown, the embodiment of the present application provides a knowledge base construction method, which mainly includes the following steps:

[0136] The above steps S221 to S225 are not repeated here.

[0137] Step S226: Build a knowledge base based on the processed documents. Furthermore, when a question is received from a user, content data matching the question can be retrieved from the knowledge base; the question and the retrieved content data are input into the large language model to generate an answer to the question.

[0138] In other words, steps S221 through S225 described above constitute a "document processing method" for processing documents from an entity such as an enterprise, thereby obtaining processed documents. Furthermore, a knowledge base can be constructed based on the documents processed by this "document processing method." Therefore, steps S221 through S226 described above can be understood as a "knowledge base construction method."

[0139] In the embodiment of the present application, the process of constructing the knowledge base is the process of structurally storing the processed content data according to the structural information, which will not be described in detail in the embodiment of the present application.

[0140] Figure 5 This is a schematic diagram of an example of a document provided in the embodiments of this application. Figure 5 As shown in the example, the structural information is represented by titles at different levels. For example, the first-level title is "Document Title"; the second-level titles are "Title 1" and "Title 2"; the third-level titles of "Title 1" are "Title 1.1"; and the third-level titles of "Title 2" are "Title 2.1" and "Title 2.2". It should be noted that "Document Title", "Title 1", "Title 1.1", "Title 2", "Title 2.1", "Title 2.2", etc. are merely exemplary representations of titles at different levels. In a specific document, the titles at different levels are the corresponding titles of the document.

[0141] Optionally, different content data exists under each title of different levels. The layout of the content data can be different layouts such as text, pictures (such as Picture 1), and tables (such as Table 1). The content data of the "Document Title" is "***"; the content data of "Title 1" is "***"; the content data of "Title 1.1" is "***"; the content data of "Title 2" is "***", and the content data of "Title 2.1" is "***; According to Figure 1, ***; (a picture)"; the content data of "Title 2.2" is "***; The following Table 1 is the parameter values of various performance parameters of the *** server; (a table)". Figure 3 The phrase "Here is the content of Title X" is a description of the omitted content "***" of Title X, and is not content data.

[0142] Furthermore, the document processing method of the embodiment of the present application is used to process Figure 3 For example, the documents in can be used to obtain the knowledge base shown in Table 1.

[0143] In Table 1, the knowledge base is structured data divided by structural information. For example, the content data of a document is divided into six document blocks based on the document title. The "Here is the content of Title X" in the table is a description of the omitted content "***" of Title X, not the content data.

[0144] Among them, the structural information of the first document block is "document main title" and there is no content data.

[0145] Among them, the structural information of the second document block is "Document Title-Title 1", which means that the structural information of the second document block is the second-level title "Title 1" in the first-level title "Document Title"; the content data is "***".

[0146] Among them, the structural information of the third document block is "Document Title-Title 1-Title 1.1", which means that the structural information of the third document block is the third-level title "Title 1.1" in the second-level title "Title 1" in the first-level title "Document Title"; the content data is "***".

[0147] Among them, the structural information of the fourth document block is "Document Title-Title 2", which means that the structural information of the fourth document block is the second-level title "Title 2" in the first-level title "Document Title"; the content data is "***".

[0148] Among them, the structural information of the fifth document block is "Document Main Title-Title 2-Title 2.1", which means that the structural information of the fifth document block is the third-level title "Title 2.1" in the second-level title "Title 2" in the first-level title "Document Main Title"; the content data is "***; Picture 1 describes the three-dimensional structure of the *** server; the address of Picture 1 is xxxx.xxxx.xxxx".

[0149] Furthermore, the fifth document block also includes two document sub-blocks. The layout of the content data of the first document sub-block is text, and the preset processing algorithm corresponding to the "text" layout is sampled for processing, and the processing result is "***"; the layout of the content data of the second document sub-block is image, and the image in the second document sub-block is also called the target image. The preset processing algorithm corresponding to the "target image" layout is sampled for processing, and the processing result of the image is "Picture 1 describes the three-dimensional structure of the *** server; the address of Picture 1 is xxxx.xxxx.xxxx".

[0150] Furthermore, "Image 1 depicts the 3D structure of the *** server" is the content description information in the image processing result; "The address of Image 1 is xxxx.xxxx.xxxx" is the storage address information in the image processing result. This way, when matching content data in the knowledge base, not only can the image itself be matched, but the image's content description information can also be used to improve the matching accuracy of content data with the "image" format.

[0151] For example, the question input by the user is "What is the structure of the *** server?" When matching the content data of the knowledge base, the image can be accurately matched based on the content description information of the image "Picture 1 describes the three-dimensional structure of the *** server."

[0152] Table 1 An example of a knowledge base

[0153]

[0154] In order to further illustrate the technical solutions of the embodiments of the present application, an exemplary description is given below with reference to specific examples.

[0155] Figure 6a This is a schematic diagram of an example of a document processing method provided in an embodiment of the present application. Figure 6a As shown, in one example, a document processing method mainly includes the following steps:

[0156] Step S510: Obtain a document. The document is also called a document to be processed.

[0157] Figure 6b Schematic diagram of another example of the document provided in the embodiment of this application. Figure 6bAs shown in another example, the structural information of the document includes a first-level title and a second-level title. The first-level title is "Introduction to X Digital Technology Co., Ltd."; the second-level titles are "Main Business," "Development History," "Operational Status," and "Key Executives."

[0158] The content data in the first-level title "Introduction to X Digital Technology Co., Ltd." is "X Digital Technology Co., Ltd. is a global leading provider of computing power infrastructure and computing power services, committed to accelerating the digital transformation of the industry. The company was established on **th, **th, **** and is located in ** City, ** Province."

[0159] The content data of the secondary title "Main Business" is "Licensed projects: sales of special products for computer information system security; import and export of goods; import and export of technology, etc. General projects: technical services, technical development, technical consulting, technical exchanges, technology transfer, technology promotion; manufacturing of computer software, hardware and peripheral equipment, etc."

[0160] The content data of the secondary title "Development History" is "X Digital Technology Co., Ltd. is committed to becoming a global leading computing infrastructure and service provider, adhering to the core value of customer-centricity. X Digital Technology Co., Ltd. continues to enable around the three core technologies of hardware, software, and engineering, and has established multiple research centers around the world to serve customers in many countries and regions around the world. Figure 1 shows the server produced by X Digital Technology Co., Ltd. (an image). As shown in Table 1, X Digital Technology Co., Ltd. has gone through several important development stages since its establishment: Table 1 Development History of X Digital Technology Co., Ltd. (a table)". The content data of the secondary title "Operating Status" is "X Digital Technology Co., Ltd. is in good operating condition, with revenue exceeding * billion yuan in 2023 and revenue expected to exceed * billion yuan in 2024. The company focuses on computing power and ecological development, and has achieved rapid revenue growth."

[0161] The content data of the secondary title "Key Executives" is "The executives of X Digital Technology Co., Ltd. mainly include: ***, who has served as chairman and general manager since **-month-**, ****. ***, who has served as director and senior vice president since **-month-**, ****. ***, who has served as product line president since **-month-**, ****."

[0162] Step S520: dividing the document structure as a whole.

[0163] Documents include Word and PDF formats. Word and most PDF documents can be encoded using background encoding. However, a small number of PDFs are in image format and require an OCR model to extract the text. Therefore, it's necessary to first determine whether the document is editable. For editable documents, the structure and content data can be directly obtained by reading the document. For non-editable documents, the structure and content data can be obtained using an OCR model.

[0164] In this embodiment, a common OCR solution is used to recognize non-editable documents, generating text data. This recognized text data is then fed into a large language model, which analyzes the structure of the entire document. Because OCR technology accurately recognizes text data and the large language model possesses advanced text understanding capabilities, structural information can be extracted from the input text data.

[0165] Optionally, after acquiring the text data, the large language model is used to extract structural information of the text data. In this example, the structural information is title information. The title information output by the large language model is shown in Table 2.

[0166] Table 2 An example of header information

[0167] Serial number Title Information 1 "About X Digital Technology Co., Ltd." 2 "About X Digital Technology Co., Ltd." / "Main Business" 3 "About X Digital Technology Co., Ltd." / "Development History" 4 "About X Digital Technology Co., Ltd." / "Business Status" 5 About X Digital Technology Co., Ltd. / Key Executives

[0168] Step S530: traverse the document and divide it into sections.

[0169] In the embodiment of the present application, based on the obtained document structure information as shown in Table 2, the document is traversed again, the location of each title is found as a block point, and the document is divided into at least one document block according to the chapter. Exemplarily, all document blocks are saved in the form of images according to the structure information.

[0170] Furthermore, based on the obtained structural information, the OCR-recognized content data is segmented to obtain at least one document block. For example, when the OCR technology is used again to analyze the title of the second chapter, the location of the second chapter title can be determined as a segmentation point based on the OCR-recognized content data. The location of the corresponding segmentation point in the image is then returned, the image is segmented, and the segmented image is stored.

[0171] For example, the image segmentation method can use the "python + paddleocr" technical solution. "Python + paddleocr" refers to using PaddleOCR in Python for optical character recognition (OCR). PaddleOCR is an OCR tool developed based on a deep learning framework that supports text recognition in multiple languages.

[0172] Figure 6c Schematic diagram of document blocks after document division provided in the embodiment of the present application. Figure 6c As shown, the document is divided into at least one document block according to chapters, and the at least one document block includes, for example, the "Introduction to X Digital Technology Co., Ltd." document block, the "Main Business" document block, the "Development History" document block, the "Operating Status" document block and the "Main Executives" document block.

[0173] Step S540: merging tables across multiple pages.

[0174] Furthermore, in order to improve the matching accuracy of the content data in the knowledge base, it is necessary to merge the cross-page tables to obtain a complete table. The process of merging cross-page tables mainly solves the problem of identifying and merging cross-page tables. In the embodiment of the present application, the document block containing cross-page content data is analyzed through the layout recognition technology. It is determined whether the cross-page content data is a cross-page table. If it is analyzed that there are tables at the end of the previous page and the beginning of the next two pages in a certain document block, optionally, a classification model is used to analyze whether the two cross-page tables are one table. When the two cross-page tables are one table, the two cross-page tables are merged.

[0175] Exemplarily, layout recognition can use the "PDFPlumber+Camelot" technology to identify and merge cross-page tables. "PDFPlumber+Camelot" are two Python libraries for processing PDF files, each with different functions and advantages. PDFPlumber provides a more advanced and friendly interface, suitable for handling the following tasks: extracting plain text and images from PDF documents; accurately parsing table data. Camelot is a library specifically for extracting table data, and its main features and uses include: table recognition and parsing table data. In the embodiment of the present application, the advantages of PDFPlumber and Camelot are combined to achieve separate processing of tables and non-table content. For example, PDFPlumber can be used to extract non-table text and images in PDF first, and then Camelot can be used to specifically process table data. This ensures that the table data is accurately extracted, and the non-table content can also be properly processed.

[0176] Figure 6d This is a schematic diagram of an example of merging cross-page tables provided in an embodiment of the present application. Figure 6d As shown in the example, taking the "Development History" document block as an example, two images are stored in the "Development History" document block. These two images are used to merge a cross-page table to obtain a complete table. All document blocks are stored as images according to their structural information. Merging a cross-page table simply merges the two images at the image level.

[0177] Step S550: layout analysis.

[0178] For example, all document blocks are saved in the form of pictures according to the structural information, and a collection of pictures classified according to the structural information of the document can be obtained. Layout recognition is required to further segment the text, images, and tables in each picture, and different preset processing algorithms are used for processing.

[0179] For example, a general OCR technology may be used to identify the text, image, table, and other layouts in each image, and the document blocks may be further segmented based on the recognition results.

[0180] Figure 6e Schematic diagram of different formats of document blocks provided in the embodiments of this application. Figure 6e As shown, in one example, taking the "development history" document block as an example, the layout of the content data of the "development history" document block includes text, tables and images.

[0181] For example, for the segmented text, OCR technology is used to extract the text, and the extracted text is used as the processing result corresponding to the text; for the segmented table, a table OCR tool is used to process it, and the extracted table data is used as the processing result corresponding to the table. The table OCR tool is also called a table recognition algorithm; for the segmented image, multimodal large model technology is used to perform content recognition, obtain content description information, and save the image to a specified location to obtain the storage address information of the image. At least one of the content description information and the storage address information is used as the processing result corresponding to the image. The processing result of the content data refers to the collection of processing results of the content data of different layouts in each document block. The processing result is also called processed content data.

[0182] For example, in this example, the knowledge base is finally obtained as shown in Table 3.

[0183] Table 3 Another example of a knowledge base

[0184]

[0185]

[0186] The document processing method proposed in the embodiment of the present application is a new working method for document processing. The document processing method can extract the structural information, image information, cross-page table information, etc. of the document in the process of processing the document, and then the text structure information, image information, and cross-page table information can be retained in the knowledge base. The accuracy of the prompt words is improved. The document processing method in the embodiment of the present application can ensure that the information in the document is fully retained, and the document can be saved in blocks according to its own directory structure. Due to the poor standardization of corporate documents and the complexity of the document structure, the knowledge base obtained by the document processing method in the embodiment of the present application is a structured data, which can convert corporate documents with complex document structure and poor standardization of content data into structured data stored according to structural information, thereby improving the matching accuracy of content data from the knowledge base.

[0187] The document processing method proposed in the embodiment of the present application is capable of: retaining text structure information; retaining image information; retaining cross-page table information; and being able to directly obtain the content data and structure information required by the large model RAG process. It solves the problems of lost structure information, poor cross-page table recognition, and lost image information in document parsing solutions in related technologies. In related technologies, text structure information is lost, such as content data is not divided into blocks according to titles, and the relationship between titles is retained; image information is lost, such as all images and internal information of images are discarded; cross-page table processing capabilities are poor, such as the inability to correctly process cross-page tables.

[0188] Next, based on the above content in the embodiments of the present application, a question-and-answer device, a knowledge base construction device, and a document processing device provided in the embodiments of the present application are introduced.

[0189] Figure 7 This is a schematic diagram of the structure of a document processing device provided in an embodiment of the present application. Figure 7 As shown, the embodiment of the present application provides a document processing device 700 for identifying and processing information recorded in a document, mainly including:

[0190] The first acquisition module 710 is used to acquire a document to be processed. The information recorded in the document to be processed includes structural information and content data. The structural information is used to divide the content data; the structural information of the document to be processed is acquired.

[0191] The first processing module 720 is used to divide the content data according to the structural information to obtain at least one document block; determine the preset processing algorithm corresponding to each document block according to the layout of the content data in each document block; determine the content data in each document block according to the preset processing algorithm; and obtain a processed document based on the structural information and the content data in each document block.

[0192] In a possible implementation, when obtaining the structural information of the document to be processed, the first processing module 720 is specifically configured to: obtain text data of the document to be processed; and determine the structural information of the document to be processed according to the text data.

[0193] In a possible implementation, when determining the text data of the document to be processed, the first processing module 720 is specifically configured to obtain the text data of the document to be processed according to a text recognition algorithm when the document to be processed is in an uneditable state.

[0194] In one possible implementation, when dividing content data according to structural information to obtain at least one document block, the above-mentioned first processing module 720 is specifically used to: determine the division position in the document to be processed according to the structural information; and divide the content data into at least one document block according to the division position.

[0195] In one possible implementation, when determining the preset processing algorithm corresponding to each document block based on the layout of the content data in each document block, the above-mentioned first processing module 720 is specifically used to: identify the layout of the content data in each document block based on the layout recognition algorithm; and determine the preset processing algorithm corresponding to each document block based on the layout.

[0196] In one possible implementation, the layout of the content data in at least one document block includes an image. When determining the content data in each document block according to a preset processing algorithm, the first processing module 720 is specifically configured to: when the layout of the content data in the document block includes an image, obtain content description information of the image in the document block; store the image in the document block and obtain storage address information of the image in the document block; and determine the content data corresponding to the image in the document block based on at least one of the content description information and the storage address information.

[0197] In one possible implementation, the layout of the content data in at least one document block includes text and / or a table. When determining the content data in each document block according to a preset processing algorithm, the first processing module 720 is specifically configured to: when the layout of the content data in the document block includes text, obtain the content data corresponding to the text in the document block according to a text recognition algorithm; and when the layout of the content data in the document block includes a table, obtain the content data corresponding to the table in the document block according to a table recognition algorithm.

[0198] In a possible implementation, the first processing module 720 is further configured to: determine whether a table spanning multiple pages exists in the document block; and when a table spanning multiple pages exists in the document block, merge the tables spanning multiple pages to obtain a complete table.

[0199] In one possible implementation, when determining whether a table spanning multiple pages exists in a document block, the first processing module 720 is specifically configured to: when the end position of the current page is the first table and the starting position of the next page is the second table, input the first table and the second table into a classification model to output a classification result; and determine, based on the classification result, whether the first table and the second table are tables spanning multiple pages.

[0200] In a possible implementation, the structure information includes multiple header information.

[0201] Figure 8 This is a schematic diagram of the structure of a knowledge base construction device provided in an embodiment of the present application. Figure 8 As shown, the present application provides a knowledge base construction device 800, which mainly includes:

[0202] The second acquisition module 810 is configured to acquire a processed document, which is obtained by processing the document to be processed according to the document processing method.

[0203] The second processing module 820 is used to build an entity knowledge base based on the processed documents.

[0204] Figure 9 This is a schematic diagram of the structure of a question-answering device provided in an embodiment of the present application. Figure 9 As shown, the present application provides a question-answering device 900, which mainly includes:

[0205] The third acquisition module 910 is used to acquire a knowledge base, which is constructed according to the above-mentioned knowledge base construction method.

[0206] The third processing module 920 is used to, when receiving a question input by a user, recall content data matching the question from the knowledge base; and input the question and the recalled content data into the large language model to generate an answer to the question.

[0207] It should be noted that the multiple functional modules shown in the above-mentioned document processing device 700, knowledge base construction device 800, and question-answering device 900 (hereinafter referred to as the "device of the embodiment of the present application") can all be implemented through software or hardware. For example, the implementation of the first processing module 720 will be described below using the first processing module 720 as an example. Similarly, the implementation of the other functional modules shown in the device of the embodiment of the present application can also refer to the implementation of the first processing module 720.

[0208] As an example of a software functional unit, the first processing module 720 may include code running on a computing instance. The computing instance may include at least one of a physical host (computing device), a virtual machine, and a container. Furthermore, the computing instance may be one or more. For example, the first processing module 720 may include code running on multiple hosts / virtual machines / containers. It should be noted that the multiple hosts / virtual machines / containers used to run the code may be distributed in the same region or in different regions. Furthermore, the multiple hosts / virtual machines / containers used to run the code may be distributed in the same availability zone (AZ) or in different AZs, each AZ including one data center or multiple geographically close data centers. Typically, a region may include multiple AZs.

[0209] Similarly, multiple hosts / virtual machines / containers running the code can be distributed within the same virtual private cloud (VPC) or across multiple VPCs. Typically, a VPC is set up within a region. Cross-region communication between two VPCs within the same region, or between VPCs in different regions, requires a communication gateway within each VPC to interconnect the VPCs.

[0210] As an example of a hardware functional unit, the first processing module 720 may include at least one computing device, such as a server. Alternatively, the first processing module 720 may be implemented using an application-specific integrated circuit (ASIC) or a programmable logic device (PLD). The PLD may be a complex programmable logical device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof.

[0211] The multiple computing devices included in the first processing module 720 can be distributed in the same region or in different regions. The multiple computing devices included in the first processing module 720 can be distributed in the same AZ or in different AZs. Similarly, the multiple computing devices included in the first processing module 720 can be distributed in the same VPC or in multiple VPCs. The multiple computing devices can be any combination of servers, ASICs, PLDs, CPLDs, FPGAs, GALs, and other computing devices.

[0212] It should be noted that, in other embodiments, the apparatus of the embodiment of the present application may be further provided with one or more modules for performing any steps included in the above-mentioned implementation. The steps that the one or more modules in the apparatus of the embodiment of the present application are responsible for implementing may be specified as needed. The functions of the apparatus of the embodiment of the present application may also be implemented using more or fewer modules than those in the embodiment of the present application. The one or more modules in the apparatus of the embodiment of the present application are used to respectively implement different steps in the above-mentioned method, thereby realizing all the functions of the apparatus of the embodiment of the present application.

[0213] The present application also provides a computing device 1000. Figure 10 As shown, computing device 1000 includes a bus 1002, a processor 1004, a memory 1006, and a communication interface 1008. Processor 1004, memory 1006, and communication interface 1008 communicate with each other via bus 1002. Computing device 1000 can be a server, such as a central server, an edge server, or a local server in a local data center, or an electronic device such as a desktop computer, a laptop computer, or a smartphone. It should be understood that this application does not limit the number of processors and memories in computing device 1000.

[0214] The bus 1002 may be a peripheral component interconnect (PCI) bus, a peripheral component interconnect Express (PCIe) bus, an extended industry standard architecture (EISA) bus, a unified bus (UBus or UB), a compute express link (CXL), a cache coherent interconnect for accelerators (CCIX), etc. Among them, the unified bus is also called a Lingqu bus. The bus can be divided into an address bus, a data bus, a control bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 10 The bus 1004 may include a path for transmitting information between various components of the computing device 1000 (eg, the memory 1006, the processor 1004, and the communication interface 1008).

[0215] The processor 1004 may include any one or more computing devices such as a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP) or a digital signal processor (DSP), an ASIC, an FPGA, a CPLD, an NPU, a SoC, an offload card, an accelerator card, etc.

[0216] Memory 1006 may include volatile memory, such as random access memory (RAM). Processor 1004 may also include non-volatile memory, such as read-only memory (ROM), flash memory, a hard disk drive (HDD), or a solid state drive (SSD). In addition, memory 1006 may also be implemented using storage class memory (SCM), phase change memory (PCM), or other types of storage media.

[0217] It is worth noting that the same type of storage medium can be configured in the same computing device to implement the function of memory 1006, or two or more types of storage media can be configured to implement the function of memory 1006. This application does not limit this.

[0218] The memory 1006 stores executable program code, and the processor 1004 executes the executable program code to respectively implement the functions of the aforementioned one or more modules, thereby implementing the method described in the above embodiment. In other words, the memory 1006 stores instructions for executing the method described in the above embodiment.

[0219] Alternatively, the memory 1006 stores executable code, and the processor 1004 executes the executable code to respectively implement the functions of the device of the embodiment of the present application, thereby implementing the method described in the above embodiment. In other words, the memory 1006 stores instructions for executing the method described in the above embodiment.

[0220] The communication interface 1008 uses a transceiver module such as, but not limited to, a network interface card or a transceiver to implement communication between the computing device 1000 and other devices or a communication network.

[0221] As a possible implementation, the computing device 1000 may also include a chip system, which includes a processor and a power supply circuit, the power supply circuit is used to power the processor, and the processor is used to execute the operation steps corresponding to the method of the embodiment of the present application. For the sake of brevity, it is not described here. Among them, the processor can be implemented by a GPU, or by a computing device or AI chip such as a DPU, NPU, XPU, SoC, offload card, accelerator card, etc.

[0222] As a possible implementation, the computing device 1000 may include multiple types of processors 1004, that is, the computing device 1000 is a heterogeneous device. For example, the computing device 1000 includes a CPU and a GPU, and at least one of the processors 1004 may perform the corresponding operation steps of the method of the embodiment of the present application. For the sake of brevity, it is not further described here.

[0223] Embodiments of the present application also provide a computing device cluster. The computing device cluster includes at least one computing device. The computing device can be a server, such as a central server, an edge server, or a local server in a local data center. In some embodiments, the computing device can also be an electronic device such as a desktop computer, a laptop computer, or a smartphone.

[0224] like Figure 11As shown, the computing device cluster includes at least one computing device 1000. The memory 1006 in one or more computing devices 1000 in the computing device cluster may store the same instructions for executing the method described in the above embodiment.

[0225] In some possible implementations, the memory 1006 of one or more computing devices 1000 in the computing device cluster may also store some instructions for executing the methods described in the above embodiments. In other words, the combination of one or more computing devices 1000 can jointly execute the instructions for executing the methods described in the above embodiments.

[0226] It should be noted that the memory 1006 in different computing devices 1000 in the computing device cluster can store different instructions, each for performing part of the functions of the apparatus of the embodiment of the present application. In other words, the instructions stored in the memory 1006 in different computing devices 1000 can implement the functions of one or more modules in the apparatus of the embodiment of the present application.

[0227] In some possible implementations, one or more computing devices in a computing device cluster may be connected via a network, which may be a wide area network or a local area network. Figure 12 A possible implementation is shown. Figure 12 As shown, two computing devices 1000A and 1000B are connected via a network. Specifically, the connection to the network is achieved through a communication interface in each computing device. In this type of possible implementation, the memory 1006 in the computing device 1000A stores instructions for the functions of one or more modules in the apparatus of the embodiment of the present application. At the same time, the memory 1006 in the computing device 1000B stores instructions for the functions of another one or more modules in the apparatus of the embodiment of the present application.

[0228] It should be understood that Figure 12 The functionality of the computing device 1000A shown in FIG. 1 may also be implemented by multiple computing devices 1000. Similarly, the functionality of the computing device 1000B may also be implemented by multiple computing devices 1000.

[0229] The present application embodiment also provides another computing device cluster. The connection relationship between the computing devices in the computing device cluster can be similarly referred to as Figure 11 and Figure 12 The connection mode of the computing device cluster is different in that the memory 1006 in one or more computing devices 1000 in the computing device cluster may store the same instructions for executing the method in the above embodiment.

[0230] In some possible implementations, the memory 1006 of one or more computing devices 1000 in the computing device cluster may also store some instructions for executing the aforementioned data processing method. In other words, the combination of one or more computing devices 1000 can jointly execute the instructions for executing the aforementioned method.

[0231] In addition to the above-mentioned method and electronic device, an embodiment of the present application may also provide a computer program product, which includes computer program instructions, which, when executed by a processor, cause the processor to perform the steps in the method according to various embodiments of the present application described in the "Method" section above of this specification. Wherein, the computer program product can be written in any combination of one or more programming languages to write computer program code for performing the operations of the embodiments of the present application, and the programming language includes an object-oriented programming language such as Java, C++, etc., and also includes a conventional procedural programming language such as "C" language or a similar programming language. Wherein, the computer program code can be in source code form, object code form, executable file or some intermediate form, etc. The computer program code can be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In some examples, when the computer program instructions are executed by a computing device cluster comprising at least one computing device, at least one computing device in the computing device cluster is caused to execute the method in the above-mentioned embodiment.

[0232] In addition, an embodiment of the present application may also provide a computer-readable storage medium having computer program instructions stored thereon, which, when executed by a processor, causes the processor to execute the steps in the method according to various embodiments of the present application described in the "Method" section above. The computer-readable storage medium may adopt any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may, for example, include but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or components, or any combination thereof. More specific examples of readable storage media (a non-exhaustive list) include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. It should be noted that the content contained in the computer-readable medium may be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electrical carrier signals and telecommunication signals. In some examples, when the instructions are executed by a computing device cluster including at least one computing device, the at least one computing device in the computing device cluster executes the method in the above embodiments.

[0233] It is understood that the processor in the embodiments of the present application may be a central processing unit (CPU), or may be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field programmable gate arrays (FPGA), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. The general-purpose processor may be a microprocessor or any conventional processor.

[0234] The method steps in the embodiments of the present application can be implemented by hardware or by a processor executing software instructions. The software instructions can be composed of corresponding software modules, which can be stored in random access memory (RAM), flash memory, read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), registers, hard disks, mobile hard disks, CD-ROMs or any other form of storage medium known in the art. An exemplary storage medium is coupled to the processor so that the processor can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and the storage medium can be located in an ASIC.

[0235] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted via the computer-readable storage medium. The computer instructions can be transmitted from one website, computer, server or data center to another website, computer, server or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) method. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid state drive (SSD)).

[0236] It will be understood that the various numerical numbers involved in the embodiments of the present application are merely distinctions for the convenience of description and are not intended to limit the scope of the embodiments of the present application.

[0237] In the above embodiments, the description of each embodiment has its own focus. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant description of other embodiments.

[0238] The basic principles of the present application have been described above in conjunction with specific embodiments. However, it should be noted that the advantages, strengths, and effects mentioned in this application are merely illustrative and not restrictive, and it should not be assumed that these advantages, strengths, and effects are required of each embodiment of this application. In addition, the specific details disclosed above are merely illustrative and facilitating understanding, and are not restrictive. The above details do not limit this application to necessarily being implemented using the above specific details.

[0239] The block diagrams of the devices, devices, equipment, and systems involved in this application are merely illustrative examples and are not intended to require or imply that they must be connected, arranged, or configured in the manner shown in the block diagrams. As will be appreciated by those skilled in the art, these devices, devices, equipment, and systems can be connected, arranged, or configured in any manner. Words such as "include," "comprise," "have," and the like are open-ended words, meaning "including but not limited to," and can be used interchangeably therewith. The words "or" and "and" used herein refer to the words "and / or" and can be used interchangeably therewith, unless the context clearly indicates otherwise. The word "such as" used herein refers to the phrase "such as but not limited to," and can be used interchangeably therewith.

[0240] It should also be noted that in the apparatus, device, and method of the present application, each component or each step can be decomposed and / or recombined, and such decomposition and / or recombination should be regarded as equivalent solutions of the present application.

[0241] The above description has been provided for the purpose of illustration and description. Furthermore, this description is not intended to limit the embodiments of the present application to the forms disclosed herein. Although a number of example aspects and embodiments have been discussed above, those skilled in the art will recognize certain variations, modifications, alterations, additions, and sub-combinations thereof.

[0242] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the protection scope of the technical solutions of the embodiments of the present application.

Claims

1. A document processing method for identifying and processing information recorded in a document, characterized in that: include: Acquire a document to be processed, wherein the information recorded in the document to be processed includes structural information and content data, wherein the structural information is used to divide the content data; Obtaining structural information of the document to be processed; Dividing the content data according to the structural information to obtain at least one document block; Determining a preset processing algorithm corresponding to each document block according to the format of the content data in each document block; Determining content data in each document block according to the preset processing algorithm; A processed document is obtained according to the structural information and the content data in each document block.

2. The method according to claim 1, characterized in that The obtaining of the structural information of the document to be processed includes: Acquiring text data of the document to be processed; The structural information of the document to be processed is determined according to the text data.

3. The method according to claim 2, characterized in that Determining the text data of the document to be processed includes: When the document to be processed is in an uneditable state, text data of the document to be processed is obtained according to a text recognition algorithm.

4. The method according to any one of claims 1 to 3, characterized in that The step of dividing the content data according to the structural information to obtain at least one document block includes: Determining a division position in the document to be processed according to the structural information; The content data is divided into at least one document block according to the division position.

5. The method according to any one of claims 1 to 4, characterized in that Determining a preset processing algorithm corresponding to each document block according to the format of the content data in each document block includes: Identifying the layout of the content data in each of the document blocks according to a layout recognition algorithm; According to the format, a preset processing algorithm corresponding to each document block is determined.

6. The method according to any one of claims 1 to 5, characterized in that The layout of the content data in each document block includes images; Determining the content data in each document block according to the preset processing algorithm includes: When the layout of the content data in the document block includes an image, obtaining content description information of the image in the document block; storing the image in the document block and obtaining storage address information of the image in the document block; Determine content data corresponding to the image in the document block according to at least one of the content description information and the storage address information.

7. The method according to any one of claims 1 to 6, characterized in that The layout of the content data in each document block includes text and / or tables; Determining the content data in each document block according to the preset processing algorithm includes: When the format of the content data in the document block includes text, obtaining content data corresponding to the text in the document block according to a text recognition algorithm; When the format of the content data in the document block includes a table, the content data corresponding to the table in the document block is obtained according to a table recognition algorithm.

8. The method according to any one of claims 1 to 7, characterized in that The method further comprises: Determine whether there is a cross-page table in the document block; When the cross-page table exists in the document block, the cross-page tables are merged to obtain a complete table.

9. The method according to claim 8, characterized in that The determining whether there is a cross-page table in the document block includes: When the end position of the previous page is the first table and the start position of the next page is the second table, the first table and the second table are input into the classification model to output a classification result; According to the classification result, it is determined whether the first table and the second table are spread-page tables.

10. A computing device, characterized in that The computing device includes: a processor and a memory; The memory is used to store program code and transmit the program code to the processor; The processor is configured to execute the steps of a document processing method according to any one of claims 1 to 9 according to the instructions in the program code.