A knowledge extraction method, device and equipment of a document and a storage medium
By combining rule templates and prompt word templates with a large language model, the problem of low knowledge extraction coverage and insufficient accuracy in existing technologies is solved, and comprehensive and accurate extraction of document knowledge is achieved.
Patent Information
- Application Number
- CN202610530409.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-04-21
- Publication Date
- 2026-07-21
AI Technical Summary
Existing document knowledge extraction methods suffer from low knowledge extraction coverage and poor scalability due to their uniform processing approach, and single methods such as rule matching or deep learning models cannot meet user needs.
Knowledge extraction is performed by combining rule templates and prompt word templates with a large language model. By loading corresponding extraction resources for different types of documents, preliminary extraction is performed using rule templates, followed by deep semantic understanding using a large language model. Finally, the extraction results are merged to improve accuracy and scalability.
It achieves comprehensive and accurate extraction of document knowledge, ensuring the comprehensiveness and accuracy of knowledge extraction, and adapting to the personalized needs of different types of documents.
Smart Images

Figure CN122433726A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of artificial intelligence and knowledge engineering technology, and in particular to a method, apparatus, device and storage medium for extracting knowledge from documents. Background Technology
[0002] With the development of intelligent manufacturing, enterprises have accumulated a large number of technical documents, such as assembly manuals, maintenance guides, and operating procedures. These documents usually contain rich professional knowledge and operational experience and are important knowledge assets of enterprises. Therefore, knowledge extraction from the above-mentioned technical documents plays an important role in the development of enterprises.
[0003] Currently, when extracting knowledge from documents, a uniform processing method is usually used for different types of documents, which can lead to omissions in knowledge extraction. In addition, a single processing method is usually used for the same document, such as relying entirely on rule matching or relying entirely on deep learning models. However, rule matching leads to low coverage and poor scalability, while deep learning models can lead to inaccurate key information. Therefore, existing document knowledge extraction methods cannot meet the actual needs of users. Summary of the Invention
[0004] This invention provides a method, apparatus, device, and storage medium for extracting knowledge from documents, so as to achieve accurate and comprehensive knowledge extraction from documents.
[0005] According to a first aspect of the present invention, a document knowledge extraction method is provided, comprising: preprocessing a received document to obtain a preprocessed document, and loading a corresponding extraction resource according to the type of the preprocessed document, wherein the extraction resource includes a rule template and a prompt word template; The document is subjected to knowledge extraction using the rule template to obtain rule extraction results, and a knowledge structure tree is constructed based on the rule extraction results, wherein each node in the knowledge structure tree represents a chapter or paragraph; Dynamic prompts are generated based on the knowledge structure tree and the prompt template. Knowledge elements are then extracted from the preprocessed document using a large language model based on the dynamic prompts. The knowledge structure tree and the knowledge elements are fused together, and the fusion result is used as the extracted knowledge of the document.
[0006] According to another aspect of the present invention, a document knowledge extraction apparatus is provided, the apparatus comprising: a preprocessing module, configured to preprocess a received document to obtain a preprocessed document, and load corresponding extraction resources according to the type of the preprocessed document, wherein the extraction resources include rule templates and prompt word templates; The rule-based knowledge extraction module is used to extract knowledge from the document using the rule template to obtain rule extraction results, and to construct a knowledge structure tree based on the rule extraction results, wherein each node in the knowledge structure tree represents a chapter or paragraph. The knowledge extraction module based on the large language model is used to generate dynamic prompt words according to the knowledge structure tree and the prompt word template, and to extract knowledge elements from the preprocessed document based on the dynamic prompt words through the large language model. The knowledge fusion module is used to fuse the knowledge structure tree with the knowledge elements, and use the fusion result as the extracted knowledge of the document.
[0007] According to another aspect of the present invention, a storage medium for computer-executable instructions is provided, on which a computer program is stored, which, when executed by a processor, implements the method as described in any of the embodiments of the present invention.
[0008] The technical solution of this invention loads different rule templates and prompt word templates for knowledge extraction based on different types of documents, thereby ensuring the comprehensiveness of knowledge extraction. While extracting knowledge based on rule matching of rule templates, it also uses a large language model to extract knowledge by combining dynamic prompt words obtained from prompt word templates, and combines the extraction results of both to finally extract knowledge, thereby ensuring the accuracy and scalability of knowledge extraction.
[0009] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description
[0010] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0011] Figure 1 This is a flowchart of a document knowledge extraction method provided in Embodiment 1 of the present invention; Figure 2 This is a flowchart of another document knowledge extraction method provided in Embodiment 2 of the present invention; Figure 3 This is a schematic diagram of the structure of a document knowledge extraction device according to Embodiment 3 of the present invention; Figure 4 This is a structural block diagram of an electronic device provided according to Embodiment 4 of the present invention. Detailed Implementation
[0012] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0013] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, apparatus, product, or terminal device that includes a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or terminal devices.
[0014] Example 1 Figure 1 This is a flowchart of a document knowledge extraction method provided in Embodiment 1 of the present invention. This embodiment is applicable to situations involving document knowledge extraction. The method can be executed by a document knowledge extraction device, which can be implemented in hardware and / or software, and can be integrated into an electronic device with data processing capabilities. Figure 1 As shown, the method includes: S101, preprocess the received document to obtain the preprocessed document, and load the corresponding extraction resources according to the type of the preprocessed document.
[0015] Optionally, the received document is preprocessed to obtain a preprocessed document, including: identifying the document's format and determining a format conversion tool for the document based on the identified format; using the format conversion tool to convert the document's format to obtain a standard document with a unified system format, and cleaning the standard document to obtain a cleaned document; wherein, structural tags are retained in the standard document; the original directory hierarchy of the document is obtained, and the cleaned document is divided into paragraphs based on the directory hierarchy and structural tags to obtain a preprocessed document.
[0016] Specifically, this implementation receives user-submitted documents through the file system or application interface and preprocesses the documents to ensure their cleanliness before knowledge extraction. First, the document's format is identified by its file extension and content signature, such as PDF, DOCX, EXCEL, or TXT. This implementation does not limit the specific format type. For text files, character encoding is automatically detected to avoid garbled characters; for binary documents, if encrypted, the corresponding parsing library is called for preliminary screening and separate processing. After identifying the document's format, a format conversion tool is determined based on the format. This tool converts documents of various heterogeneous formats into a unified, primarily plain text standard document within the system, such as MARKDOWN or JSON. During the conversion process, the original document's structural markup is preserved to the greatest extent possible. For example, PDF chapter titles, DOCX style headings, and HTML tags are mapped to the MARKDOWN format with hierarchical markup, while non-text, unparseable elements (such as complex tables and images) are stripped away.
[0017] In this embodiment, after obtaining the standard document, it is further cleaned. Specifically, this cleaning involves removing unnecessary control characters, converting soft and hard line breaks, standardizing whitespace characters (converting multiple spaces / tabs to one), processing HTML / XML entity encoding, and removing headers, footers, page numbers, watermarks, and other "noise" text that is not helpful for semantic understanding, resulting in a cleaned document with noise removed. This embodiment is merely illustrative and does not limit the specific content of the cleaning; anything that removes noise that interferes with knowledge extraction is within the scope of this application. Additionally, this embodiment also obtains the directory structure of the original document and the structural markers contained in the cleaned document. Based on heuristic rules, such as blank lines, indentation, or bullet points, the cleaned document is divided into paragraphs to obtain a preprocessed document.
[0018] Optionally, the corresponding extraction resources are loaded according to the type of the preprocessed document, including: performing feature extraction on the preprocessed document to obtain multi-dimensional features, wherein the multi-dimensional features include structural features, lexical features, and format features; inputting the multi-dimensional features into a pre-trained classifier to obtain the type, wherein the type includes assembly manual, maintenance guide, operating procedure, technical specification, or company standard; querying from the type strategy mapping library according to the type to obtain the corresponding processing strategy, wherein the type strategy mapping library includes the correspondence between type and processing strategy; and dynamically loading the corresponding rule template and prompt word template from the template library according to the processing strategy, wherein the rule template includes structural patterns, regular expressions, syntactic patterns, and domain dictionary.
[0019] Specifically, in this embodiment, after obtaining the preprocessed document, multidimensional features of the preprocessed document are extracted, including structural features, lexical features, and format features. Structural features include the number of paragraphs, average paragraph length, and heading level depth; lexical features include keyword distribution extracted through a word embedding model, frequency of domain-specific terms, and n-gram statistics; format features include standard and specification documents, which are generally in PDF format. Of course, this embodiment does not limit the specific content of the extracted multidimensional features. After obtaining the multidimensional features of the preprocessed document, these features can be input into a pre-trained classifier, such as a lightweight neural network. Since the classifier has learned the distribution patterns of different types of documents in the feature space during the training phase, it can classify the preprocessed document into a predefined type by recognizing the multidimensional features, such as assembly manuals, maintenance guides, operating procedures, technical specifications, or company standards. Again, this embodiment does not limit the specific type of the preprocessed document. The system stores a type strategy mapping library, which includes the correspondence between types and processing strategies. Therefore, the system queries the type strategy mapping library to obtain the corresponding processing strategy based on the type. For example, for types such as technical specifications or company standards, the system will select a strategy that focuses on extracting entities such as document number, reference clause, organization and role, responsibility, indicators, and date. For assembly manuals, instructions, or guides, a strategy that focuses on the "step-by-step" operation process and the "structured" components will be used, such as action instructions, steps, objects, conditions, goals, and results. Of course, this embodiment is only an example and does not limit the specific content of the processing strategies corresponding to each type.
[0020] In this embodiment, the template library includes extraction resources corresponding to different processing strategies. These extraction resources specifically include rule templates and prompt word templates. For example, rule templates include structural patterns, regular expressions, syntactic patterns, and domain dictionaries, and the regular expressions and related information contained in different rule templates are different. Prompt word templates include a basic framework for subsequent large language model calls, providing task descriptions, role definitions, and output formats for knowledge extraction of this document type. The role definitions and related information contained in different prompt word templates are also different. Therefore, this embodiment identifies the document type to ultimately determine the appropriate rule template and prompt word template for subsequent personalized knowledge extraction. Of course, this embodiment is merely an example and does not limit the specific content of the extraction resources corresponding to the preprocessed document.
[0021] S102, use rule templates to extract knowledge from documents to obtain rule extraction results, and construct a knowledge structure tree based on the rule extraction results.
[0022] Optionally, a rule template is used to extract knowledge from the document to obtain rule extraction results, and a knowledge structure tree is constructed based on the rule extraction results. This includes: using the structural patterns in the rule template to extract knowledge from the preprocessed document to obtain a document outline; using regular expressions and syntactic patterns in the rule template to extract knowledge from the preprocessed document to obtain key information, including standard numbers and referenced document numbers; using the domain dictionary in the rule template to extract knowledge from the preprocessed document to obtain technical terms and entity names; and integrating the document outline, key information, technical terms, and entity names to construct a knowledge structure tree.
[0023] In this embodiment, after obtaining the rule template, rapid and accurate shallow knowledge extraction can be performed on the preprocessed document. This is particularly suitable for highly structured and semi-structured content. The extraction process is based on different rules within the rule template. Specifically, the structural patterns (title number continuity check or chapter nesting rules) in the rule template are used to extract knowledge from the preprocessed document, obtaining a precise and hierarchical document outline. Regular expressions and syntactic patterns in the rule template are used to extract knowledge from the preprocessed document, accurately matching and extracting key information with fixed patterns, such as standard numbers and referenced document numbers. Finally, a domain dictionary in the rule template is used to extract knowledge from the preprocessed document, obtaining professional terms and entity names (such as equipment, materials, mechanical parameters, electrical parameters, equipment status, etc.), providing an entity foundation for subsequent relation extraction. Finally, all the document outlines, key information, technical terms, and entity names extracted based on the rules are integrated to construct a structured knowledge structure tree. Each node in the knowledge structure tree represents a chapter or paragraph, and the structure tree has the characteristics of high accuracy and high interpretability.
[0024] S103: Generate dynamic prompts based on the knowledge structure tree and prompt templates, and extract knowledge elements from the preprocessed document using a large language model based on the dynamic prompts.
[0025] Optionally, dynamic prompts are generated based on the knowledge structure tree and prompt templates. A large language model is then used to extract knowledge elements from the preprocessed document based on these dynamic prompts. This includes: receiving user adjustment instructions; adjusting the prompt template according to the instructions to obtain the adjusted prompt template; generating dynamic prompts for the knowledge structure tree based on the adjusted prompt template; dividing the preprocessed document into blocks to obtain multiple text blocks; combining each text block with the dynamic prompts to obtain prompt combination combinations; and extracting knowledge elements from each prompt combination using a large language model. These knowledge elements include entities, relationships, attributes, and events.
[0026] Specifically, in this implementation, before extracting knowledge from the preprocessed document using a large language model, dynamic prompts are generated based on the acquired knowledge structure tree and prompt word template. Furthermore, the prompt word template obtained for the document type can be adjusted according to user commands. For example, users can fill the prompt word template with variables such as desired output format and specific recognition requirements to obtain an adjusted prompt word template. Dynamic prompts for the knowledge structure tree are then generated based on the adjusted prompt word template, for example: "Document type is 'Supplier Management Requirements'. The rule engine has identified the supplier as [Company A] and the purchaser as [Company B]. Please focus on analyzing clause 3.4, accurately extracting the delivery time, deliverables, and acceptance criteria, and outputting them in JSON format." By adjusting the prompt word template according to user commands, the document type is referenced when obtaining dynamic prompts, satisfying the user's extraction needs and improving the user experience.
[0027] In this embodiment, after obtaining the dynamic prompt words, a large language model is used to perform support extraction on the preprocessed document based on the dynamic prompt words. This stage mainly utilizes the powerful reasoning and generalization capabilities of the large language model to handle extraction tasks that require deep semantic understanding and complex contextual reasoning. Considering the context window limitations of the large language model, To control the length of a single processing run, the preprocessed document is intelligently segmented into multiple text blocks according to semantic boundaries (chapter or paragraph). An overlapping segmentation strategy is employed to ensure that key information is not interrupted at block boundaries, maintaining contextual coherence. After obtaining multiple text blocks, each block is combined with the dynamically acquired prompt words to generate multiple prompt word combinations. These combinations are then input into a large language model via the application port. The large language model outputs natural language or semi-structured text based on the prompt word combinations. The system then parses this text to obtain the final knowledge extraction results, such as knowledge elements like entities, relationships, attributes, and events. This implementation is merely illustrative and does not limit the specific content of the knowledge elements extracted by the large language model.
[0028] It should be noted that after acquiring the knowledge elements, this embodiment will further clean and standardize them. For example, it will correct possible format errors, unify the expression of dates or numbers, map synonyms to standard terms, and format the data according to a predefined ontology to ensure structural alignment with the output of the rule engine. Of course, this embodiment is only an example and does not limit the specific processing method of the knowledge elements. As long as it facilitates the subsequent data fusion, it is within the protection scope of this application.
[0029] S104 integrates the knowledge structure tree with knowledge elements and uses the fusion result as the extracted knowledge of the document.
[0030] Optionally, the knowledge structure tree and knowledge elements are merged, and the fusion result is used as the extracted knowledge of the document. This includes: comparing the knowledge structure tree and knowledge elements to obtain conflict points and non-conflict points; obtaining the first type of knowledge elements corresponding to the non-conflict points; determining the knowledge type corresponding to the conflict points based on the weights of the conflict points in the knowledge structure tree and knowledge elements, wherein the knowledge type includes the second type of knowledge elements or nodes of the knowledge structure tree; determining whether the knowledge type is the second type of knowledge element; if so, directly merging the first type of knowledge elements and the second type of knowledge elements to obtain extracted knowledge; otherwise, converting the nodes into the second type of knowledge elements and merging the first type of knowledge elements and the second type of knowledge elements to obtain extracted knowledge.
[0031] Specifically, in this embodiment, after obtaining the knowledge structure tree obtained through rule matching and the knowledge elements extracted by the large language model, the knowledge structure tree and the knowledge elements are compared to identify conflict points and non-conflict points. Conflict points are the parts that are inconsistent between the two, and the specific content and type of conflict points are labeled, such as different entity attribute values or incorrect relation subjects. This embodiment does not limit the specific type of conflict points. Furthermore, for non-conflict points, the corresponding first-type knowledge elements, i.e., the extraction results from the large language model, are obtained. For conflict points, different weights are assigned to knowledge structure trees and knowledge elements from different sources to determine the knowledge type corresponding to the conflict point. Generally, rule engines have higher reliability in extracting patterned information, and the corresponding knowledge structure tree has higher weights. Large language models have higher reliability in extracting information requiring semantic disambiguation and complex reasoning, and the corresponding knowledge elements have higher weights. Therefore, for conflict points, the extraction results with higher weights are used. Specifically, when the weight of a knowledge element is high, the second type of knowledge element corresponding to the conflict point is directly obtained, and the first type of knowledge element and the second type of knowledge element are fused to obtain extracted knowledge. However, when the weight of the knowledge structure tree is high, it is necessary to determine the node of the conflict point on the knowledge structure tree, convert the node into the second type of knowledge element, and then fuse it with the first type of knowledge element to obtain extracted knowledge. That is, the fusion result of this application is finally displayed in the form of knowledge elements corresponding to the large language model.
[0032] The technical solution of this invention loads different rule templates and prompt word templates for knowledge extraction based on different types of documents, thereby ensuring the comprehensiveness of knowledge extraction. While extracting knowledge based on rule matching of rule templates, it also uses a large language model to extract knowledge by combining dynamic prompt words obtained from prompt word templates, and combines the extraction results of both to finally extract knowledge, thereby ensuring the accuracy and scalability of knowledge extraction.
[0033] Example 2 Figure 2 This is a flowchart of another document knowledge extraction method provided by an embodiment of the present invention. Based on the above embodiment, after using the fusion result as the extracted knowledge of the document, this embodiment further includes: performing automated quality checks on the extracted knowledge to obtain abnormal data points; performing credibility scoring on the extracted knowledge to obtain questionable data points; generating review tasks based on the abnormal and questionable data points, and sending the review tasks to designated users for review; receiving user feedback on the review tasks, updating the extraction results based on the feedback results, and saving the updated extraction results to the knowledge base, such as... Figure 2 As shown, the method includes: S201, preprocess the received document to obtain the preprocessed document, and load the corresponding extraction resources according to the type of the preprocessed document.
[0034] Optionally, the received document is preprocessed to obtain a preprocessed document, including: identifying the document's format and determining a format conversion tool for the document based on the identified format; using the format conversion tool to convert the document's format to obtain a standard document with a unified system format, and cleaning the standard document to obtain a cleaned document; wherein, structural tags are retained in the standard document; the original directory hierarchy of the document is obtained, and the cleaned document is divided into paragraphs based on the directory hierarchy and structural tags to obtain a preprocessed document.
[0035] Optionally, the corresponding extraction resources are loaded according to the type of the preprocessed document, including: performing feature extraction on the preprocessed document to obtain multi-dimensional features, wherein the multi-dimensional features include structural features, lexical features, and format features; inputting the multi-dimensional features into a pre-trained classifier to obtain the type, wherein the type includes assembly manual, maintenance guide, operating procedure, technical specification, or company standard; querying from the type strategy mapping library according to the type to obtain the corresponding processing strategy, wherein the type strategy mapping library includes the correspondence between type and processing strategy; and dynamically loading the corresponding rule template and prompt word template from the template library according to the processing strategy, wherein the rule template includes structural patterns, regular expressions, syntactic patterns, and domain dictionary.
[0036] S202, use rule templates to extract knowledge from documents to obtain rule extraction results, and construct a knowledge structure tree based on the rule extraction results.
[0037] Optionally, a rule template is used to extract knowledge from the document to obtain rule extraction results, and a knowledge structure tree is constructed based on the rule extraction results. This includes: using the structural patterns in the rule template to extract knowledge from the preprocessed document to obtain a document outline; using regular expressions and syntactic patterns in the rule template to extract knowledge from the preprocessed document to obtain key information, including standard numbers and referenced document numbers; using the domain dictionary in the rule template to extract knowledge from the preprocessed document to obtain technical terms and entity names; and integrating the document outline, key information, technical terms, and entity names to construct a knowledge structure tree.
[0038] S203: Generate dynamic prompts based on the knowledge structure tree and prompt templates, and extract knowledge elements from the preprocessed document using a large language model based on the dynamic prompts.
[0039] Optionally, dynamic prompts are generated based on the knowledge structure tree and prompt templates. A large language model is then used to extract knowledge elements from the preprocessed document based on these dynamic prompts. This includes: receiving user adjustment instructions; adjusting the prompt template according to the instructions to obtain the adjusted prompt template; generating dynamic prompts for the knowledge structure tree based on the adjusted prompt template; dividing the preprocessed document into blocks to obtain multiple text blocks; combining each text block with the dynamic prompts to obtain prompt combination combinations; and extracting knowledge elements from each prompt combination using a large language model. These knowledge elements include entities, relationships, attributes, and events.
[0040] S204 integrates the knowledge structure tree with knowledge elements and uses the fusion result as the extracted knowledge of the document.
[0041] Optionally, the knowledge structure tree and knowledge elements are merged, and the fusion result is used as the extracted knowledge of the document. This includes: comparing the knowledge structure tree and knowledge elements to obtain conflict points and non-conflict points; obtaining the first type of knowledge elements corresponding to the non-conflict points; determining the knowledge type corresponding to the conflict points based on the weights of the conflict points in the knowledge structure tree and knowledge elements, wherein the knowledge type includes the second type of knowledge elements or nodes of the knowledge structure tree; determining whether the knowledge type is the second type of knowledge element; if so, directly merging the first type of knowledge elements and the second type of knowledge elements to obtain extracted knowledge; otherwise, converting the nodes into the second type of knowledge elements and merging the first type of knowledge elements and the second type of knowledge elements to obtain extracted knowledge.
[0042] S205: Perform automated quality checks on extracted knowledge to identify anomalous data points, and perform credibility scoring on extracted knowledge to identify questionable data points.
[0043] In this embodiment, after acquiring the extracted knowledge, automated quality check rules are executed. For example, this includes checking whether required fields are empty, whether values are within a reasonable range, and whether entity relationships are logically consistent (e.g., "signing date" should not be later than "effective date"). Anomaly data points are identified by running a series of quality rules. Additionally, this embodiment also obtains the confidence score of each extracted knowledge point during conflict detection in the aforementioned fusion steps, automatically marking suspicious data points with confidence scores below a threshold or that violate quality rules. The specific number of anomaly and suspicious data points is not limited in this embodiment.
[0044] S206: Generate an audit task based on abnormal data points and questionable data points, and send the audit task to the designated user for auditing.
[0045] In this implementation, both abnormal data points and questionable data points are extraction results that may have problems and need to be further reviewed by humans. Therefore, this implementation will obtain information such as the context, conflict history, and confidence level of the marked extraction results, and package the above information to generate a clear review task, which will be pushed to the manual review platform or workflow system and assigned to domain experts for detailed review.
[0046] S207: Receive user feedback on the review task, update the extraction results based on the feedback, and save the updated extraction results to the knowledge base.
[0047] Once domain experts and other reviewers have completed their reviews, the system will receive feedback from users on the review task, such as corrections, confirmations, or deletions. Based on the user feedback, the system will update the extracted results and save the updated results to the knowledge base. The updated results will also be recorded and can serve as valuable training data for subsequent model fine-tuning and rule optimization.
[0048] The technical solution of this invention loads different rule templates and prompt word templates for knowledge extraction based on different types of documents, thereby ensuring the comprehensiveness of knowledge extraction. While extracting knowledge based on rule matching of rule templates, it also uses a large language model to extract knowledge by combining dynamic prompt words obtained from prompt word templates, and combines the extraction results of both to finally extract knowledge, thereby ensuring the accuracy and scalability of knowledge extraction.
[0049] Example 3 Figure 3 This is a schematic diagram of a document knowledge extraction device provided in an embodiment of the present invention. Figure 3As shown, the device includes: a preprocessing module 310, a rule-based knowledge extraction module 320, a large language model-based knowledge extraction module 330, and a knowledge fusion module 340.
[0050] The preprocessing module 310 is used to preprocess the received document to obtain the preprocessed document, and load the corresponding extraction resources according to the type of the preprocessed document. The extraction resources include rule templates and prompt word templates. The rule-based knowledge extraction module 320 is used to extract knowledge from documents using rule templates to obtain rule extraction results, and to construct a knowledge structure tree based on the rule extraction results. Each node in the knowledge structure tree represents a chapter or paragraph. The knowledge extraction module 330 based on the large language model is used to generate dynamic prompt words based on the knowledge structure tree and prompt word template, and to extract knowledge elements from the preprocessed document based on the dynamic prompt words through the large language model. The knowledge fusion module 340 is used to merge the knowledge structure tree with knowledge elements and use the fusion result as the extracted knowledge of the document.
[0051] Optionally, the preprocessing module includes a preprocessing unit for recognizing the document's format and determining the appropriate format conversion tool for the document based on the recognized format. The document is converted using a format conversion tool to obtain a standard document with a unified system format, and then the standard document is cleaned to obtain a clean document; the structural markup is preserved in the standard document. Obtain the original directory hierarchy of the document, and divide the cleaned document into paragraphs based on the directory hierarchy and structural tags to obtain the preprocessed document.
[0052] Optionally, the preprocessing module includes a resource extraction unit for extracting features from the preprocessed document to obtain multidimensional features, wherein the multidimensional features include structural features, lexical features and format features. Input multidimensional features into a pre-trained classifier to obtain types, including assembly manuals, maintenance guides, operating procedures, technical specifications, or company standards. The corresponding processing strategy is retrieved from the type strategy mapping library based on the type. The type strategy mapping library includes the correspondence between types and processing strategies. According to the processing strategy, the corresponding rule templates and prompt word templates are dynamically loaded from the template library. The rule templates include structural patterns, regular expressions, syntactic patterns and domain dictionaries.
[0053] Optionally, a rule-based knowledge extraction module is used to extract knowledge from the preprocessed document using the structural patterns in the rule template to obtain the document outline; The regular expressions and syntactic patterns in the rule template are used to extract key information from the preprocessed document, including the standard number and the referenced document number. The domain dictionary in the rule template is used to extract knowledge from the preprocessed document to obtain professional terms and entity names; The document outline, key information, technical terms, and entity names are integrated to construct a knowledge structure tree.
[0054] Optionally, a knowledge extraction module based on a large language model is used to receive the user's adjustment instructions, adjust the prompt word template according to the adjustment instructions, and obtain the adjusted prompt word template. Dynamic prompts are generated for the knowledge structure tree based on the adjusted prompt template; The preprocessed document is divided into blocks to obtain multiple text blocks, and each text block is combined with a dynamic prompt word to obtain a prompt word combination; Knowledge elements are extracted from each combination of prompt words using a large language model. These knowledge elements include entities, relationships, attributes, and events.
[0055] Optionally, a knowledge fusion module is used to compare the knowledge structure tree with knowledge elements to identify conflict points and non-conflict points; Obtain the first type of knowledge element corresponding to the non-conflict point, and determine the knowledge type corresponding to the conflict point based on the weight of the conflict point in the knowledge structure tree and the knowledge element. The knowledge type includes the second type of knowledge element or the node of the knowledge structure tree. Determine if the knowledge type is a second type of knowledge element. If so, directly merge the first and second types of knowledge elements to extract the knowledge. Otherwise, convert the node to a second type of knowledge element and merge the first and second types of knowledge elements to extract the knowledge.
[0056] Optionally, the device also includes an auditing module for automatically performing quality checks on the extracted knowledge to obtain abnormal data points and for performing credibility scoring on the extracted knowledge to obtain questionable data points. An audit task is generated based on abnormal and questionable data points, and then sent to a designated user for auditing. Receive user feedback on the review task, update the extraction results based on the feedback, and save the updated extraction results to the knowledge base.
[0057] The document knowledge extraction device provided in this embodiment of the invention can execute the document knowledge extraction method provided in any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the method.
[0058] Example 4 Figure 4A schematic diagram of an electronic device 10, which can be used to implement embodiments of the present invention, is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.
[0059] The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the invention described and / or claimed herein.
[0060] like Figure 4 As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12 or a random access memory (RAM) 13, communicatively connected to the at least one processor 11. The memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes based on the computer program stored in the ROM 12 or loaded from storage unit 18 into the RAM 13. The RAM 13 can also store various programs and data required for the operation of the electronic device 10. The processor 11, ROM 12, and RAM 13 are interconnected via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0061] Multiple components in electronic device 10 are connected to I / O interface 15, including: input unit 16, such as keyboard, mouse, etc.; output unit 17, such as various types of displays, speakers, etc.; storage unit 18, such as disk, optical disk, etc.; and communication unit 19, such as network card, modem, wireless transceiver, etc. Communication unit 19 allows electronic device 10 to exchange information / data with other electronic devices through computer networks such as the Internet and / or various telecommunications networks.
[0062] Processor 11 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Processor 11 performs the various methods and processes described above, such as document knowledge extraction methods.
[0063] That is, the received document is preprocessed to obtain a preprocessed document, and the corresponding extraction resources are loaded according to the type of the preprocessed document. The extraction resources include rule templates and prompt word templates. The document is used to extract knowledge using rule templates to obtain rule extraction results, and a knowledge structure tree is constructed based on the rule extraction results. Each node in the knowledge structure tree represents a chapter or paragraph. Dynamic prompts are generated based on the knowledge structure tree and prompt templates. Knowledge elements are then extracted from the preprocessed document using a large language model based on the dynamic prompts. The knowledge structure tree and knowledge elements are integrated, and the integration result is used as the extracted knowledge of the document.
[0064] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution apparatus, device, or electronic device. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor devices, or any suitable combination thereof. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage electronics, magnetic storage electronics, or any suitable combination thereof.
[0065] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.
[0066] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.
Claims
1. A method for knowledge extraction from documents, characterized in that, The method includes: The received document is preprocessed to obtain a preprocessed document, and the corresponding extraction resources are loaded according to the type of the preprocessed document. The extraction resources include rule templates and prompt word templates. The document is subjected to knowledge extraction using the rule template to obtain rule extraction results, and a knowledge structure tree is constructed based on the rule extraction results, wherein each node in the knowledge structure tree represents a chapter or paragraph; Dynamic prompts are generated based on the knowledge structure tree and the prompt template. Knowledge elements are then extracted from the preprocessed document using a large language model based on the dynamic prompts. The knowledge structure tree and the knowledge elements are fused together, and the fusion result is used as the extracted knowledge of the document.
2. The method according to claim 1, characterized in that, The step of preprocessing the received document to obtain a preprocessed document includes: The document is formatted, and a format conversion tool is determined based on the format identified. The document is converted using the aforementioned format conversion tool to obtain a standard document with a unified system format, and the standard document is then cleaned to obtain a cleaned document; wherein, structural markers are retained in the standard document; Obtain the original directory hierarchy of the document, and divide the cleaned document into paragraphs according to the directory hierarchy and the structural tags to obtain the preprocessed document.
3. The method according to claim 1, characterized in that, The step of loading the corresponding extracted resources according to the type of the preprocessed document includes: Feature extraction is performed on the preprocessed document to obtain multidimensional features, wherein the multidimensional features include structural features, lexical features and format features; The multidimensional features are input into a pre-trained classifier to obtain the type, wherein the type includes assembly manual, maintenance guide, operating procedure, technical specification or company standard; The corresponding processing strategy is obtained by querying the type strategy mapping library according to the type, wherein the type strategy mapping library includes the correspondence between types and processing strategies; According to the processing strategy, the corresponding rule templates and prompt word templates are dynamically loaded from the template library. The rule templates include structural patterns, regular expressions, syntactic patterns, and domain dictionaries.
4. The method according to claim 3, characterized in that, The step of extracting knowledge from the document using the rule template to obtain rule extraction results, and constructing a knowledge structure tree based on the rule extraction results, includes: The preprocessed document is used to extract knowledge and obtain a document outline using the structural pattern in the rule template. The preprocessed document is used to extract key information by employing the regular expressions and syntactic patterns in the rule template, wherein the key information includes the standard number and the referenced document number; The domain dictionary in the rule template is used to extract knowledge from the preprocessed document to obtain professional terms and entity names; The knowledge structure tree is constructed by integrating the document outline, the key information, the technical terms, and the entity names.
5. The method according to claim 1, characterized in that, The process of generating dynamic prompts based on the knowledge structure tree and the prompt template, and extracting knowledge elements from the preprocessed document using a large language model based on the dynamic prompts, includes: Receive adjustment instructions from users, adjust the prompt word template according to the adjustment instructions, and obtain the adjusted prompt word template; The dynamic prompts for the knowledge structure tree are generated based on the adjusted prompt template; The preprocessed document is divided into blocks to obtain multiple text blocks, and each text block is combined with the dynamic prompt word to obtain a prompt word combination; The knowledge elements are extracted from each combination of prompt words using the large language model. The knowledge elements include entities, relationships, attributes, and events.
6. The method according to claim 1, characterized in that, The step of fusing the knowledge structure tree with the knowledge elements and using the fusion result as the extracted knowledge of the document includes: The knowledge structure tree is compared with the knowledge elements to identify conflict points and non-conflict points; Obtain the first type of knowledge element corresponding to the non-conflict point, and determine the knowledge type corresponding to the conflict point according to the weight of the conflict point on the knowledge structure tree and the knowledge element, wherein the knowledge type includes the second type of knowledge element or the node of the knowledge structure tree; Determine whether the knowledge type is a second type of knowledge element. If so, directly merge the first type of knowledge element and the second type of knowledge element to obtain the extracted knowledge. Otherwise, convert the node into the second type of knowledge element and merge the first type of knowledge element and the second type of knowledge element to obtain the extracted knowledge.
7. The method according to any one of claims 1 to 6, characterized in that, After using the fusion result as the extracted knowledge of the document, it also includes: The extracted knowledge is subjected to automated quality checks to obtain abnormal data points, and the extracted knowledge is subjected to credibility scoring to obtain questionable data points. An audit task is generated based on the abnormal data points and the questionable data points, and the audit task is sent to a designated user for auditing. Receive user feedback on the review task, update the extraction results based on the feedback, and save the updated extraction results to the knowledge base.
8. A document knowledge extraction device, characterized in that, The device includes: The preprocessing module is used to preprocess the received document to obtain the preprocessed document, and load the corresponding extraction resources according to the type of the preprocessed document, wherein the extraction resources include rule templates and prompt word templates; The rule-based knowledge extraction module is used to extract knowledge from the document using the rule template to obtain rule extraction results, and to construct a knowledge structure tree based on the rule extraction results, wherein each node in the knowledge structure tree represents a chapter or paragraph. The knowledge extraction module based on the large language model is used to generate dynamic prompt words according to the knowledge structure tree and the prompt word template, and to extract knowledge elements from the preprocessed document based on the dynamic prompt words through the large language model. The knowledge fusion module is used to fuse the knowledge structure tree with the knowledge elements, and use the fusion result as the extracted knowledge of the document.
9. An electronic device, characterized in that, The electronic device includes: One or more processors; Storage device for storing one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors implement the method as described in any one of claims 1-7.
10. A storage medium for computer-executable instructions, wherein a computer program is stored thereon, characterized in that, When the program is executed by the processor, it implements the method as described in any one of claims 1-7.