Knowledge graph multi-hop question and answer method and system, storage medium and electronic equipment
Through large model reasoning and knowledge graph multi-hop question and answer methods, multi-hop questions are rewritten into sub-questions, entities and relationships are identified, solving the problem of low accuracy of multi-hop question and answer in the existing technology, and achieving high accuracy and strong traceability of question and answer. Effect.
Patent Information
- Application Number
- CN202411885744.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-20
- Publication Date
- 2025-01-21
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In the knowledge graph multi-hop question and answer, the answer deviates from the normal results due to the error in the text similarity prediction path, and the model's intention to identify the target problem is low, its logic is not strong, and its accuracy is low.
Large model reasoning is used to determine the question type by obtaining the target question and knowledge graph. If it is a multi-hop problem, it is rewritten into sub-questions. Based on the knowledge graph and question and answer reasoning model, entity and relationship recognition is performed to obtain query results.
It improves the accuracy and traceability of the multi -jump question and answer of knowledge maps, effectively improves the answering efficiency of simple questions, and reduces the difficulty of entity and relationship recognition.
Smart Images

Figure CN119338012A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of deep learning, and in particular relates to a knowledge graph multi-hop question answering method, system, storage medium and electronic device. Background Art
[0002] Knowledge graph multi-hop question answering is a technology that uses the relationship between multiple entities in the knowledge graph to perform question reasoning and can solve some complex problems.
[0003] Generally, the knowledge graph multi-hop question answering method includes given a target question and a target knowledge graph, predetermining the node features and relationship features corresponding to each node in the target knowledge graph, determining the target node corresponding to the target entity in the query statement of the target question, and then predicting the association relationship between the query result and the target node, i.e., the predicted path, based on the sentence features of the target node and the query statement. In the case of multi-hop question answering, this method predicts the association relationship between the query result and the target node based on the sentence features of the target node and the query statement, and then determines the query result based on the predicted association relationship.
[0004] In the prior art, in order to realize multi-hop question answering of knowledge graphs, multiple paths are predicted step by step through text similarity, and then the wrong paths are eliminated through entities and relationships to finally get the final answer. Among them, the query statement is predicted step by step through the text similarity to answer the answer of each path. Once an error occurs in one of the paths, the final answer will definitely deviate from the normal result. Since the query statements are asked in a variety of ways, the model's recognition of the intent of the target question only through text similarity will be very ineffective, resulting in weak selection logic for each path, resulting in very low multi-hop question answering accuracy of the overall knowledge graph. Summary of the invention
[0005] In view of the shortcomings of the prior art mentioned above, the purpose of the present invention is to provide a knowledge graph multi-hop question answering method, system, storage medium and electronic device, which realize knowledge graph multi-hop question answering based on large model reasoning, with high accuracy and strong traceability.
[0006] In a first aspect, the present invention provides a knowledge graph multi-hop question answering method, the method comprising the following steps: obtaining a target question and a corresponding knowledge graph; determining whether the target question is a multi-hop question or a single-hop question; if it is a multi-hop question, rewriting the target question into multiple sub-questions; for each sub-question or the single-hop question, obtaining a query result corresponding to the target question based on the knowledge graph and the question-answering reasoning model.
[0007] In an implementation manner of the first aspect, it is determined based on a BERT model whether the target problem is a multi-hop problem or a single-hop problem.
[0008] In an implementation of the first aspect, rewriting the target problem into multiple sub-problems includes the following steps: identifying attributes included in the target problem; Generate a subquestion for each attribute.
[0009] In an implementation of the first aspect, for each sub-question or the single-hop question, obtaining a query result corresponding to the target question based on the knowledge graph and the question-answering reasoning model includes the following steps: For each sub-problem or the single-hop problem, perform entity and relationship recognition to obtain entity and relationship recognition results; Retrieving the entity and relationship recognition results in the knowledge graph to obtain related knowledge graph information; The associated knowledge graph information and the target question are input into the question-answering reasoning model to obtain the query result corresponding to the target question.
[0010] In an implementation manner of the first aspect, entity and relationship identification is performed based on a GlobalPointer algorithm.
[0011] In an implementation manner of the first aspect, the question-answering reasoning model adopts a large language model.
[0012] In an implementation of the first aspect, the knowledge graph is a government affairs knowledge graph.
[0013] In a second aspect, the present invention provides a knowledge graph multi-hop question answering system, the system comprising an acquisition module, a judgment module, a rewriting module and a reasoning module; The acquisition module is used to obtain the target question and the corresponding knowledge graph; The judging module is used to judge whether the target problem is a multi-hop problem or a single-hop problem; The rewriting module is used to rewrite the target problem into multiple sub-problems if it is a multi-hop problem; The reasoning module is used to obtain the query result corresponding to the target question based on the knowledge graph and the question-answering reasoning model for each sub-question or the single-hop question.
[0014] In a third aspect, the present invention provides an electronic device, the electronic device comprising: a processor and a memory; The memory is used to store computer programs; The processor is used to execute the computer program stored in the memory so that the electronic device performs the above-mentioned knowledge graph multi-hop question and answer method.
[0015] In a fourth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by an electronic device, implements the above-mentioned knowledge graph multi-hop question-answering method.
[0016] As described above, the knowledge graph multi-hop question answering method, system, storage medium and electronic device described in the present invention have the following beneficial effects.
[0017] (1) Implement multi-hop question answering on knowledge graph based on large model reasoning, with high accuracy and strong traceability.
[0018] (2) Through multi-hop judgment, the efficiency of answering simple questions is effectively improved.
[0019] (3) By rewriting the target question, the difficulty of entity and relationship recognition can be effectively reduced. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 Shown is a schematic diagram of a scene of an electronic device in an embodiment of the present invention.
[0021] Figure 2 Shown is a flowchart of the knowledge graph multi-hop question answering method in one embodiment of the present invention.
[0022] Figure 3 Shown is a schematic diagram of the architecture of the knowledge graph multi-hop question answering method in one embodiment of the present invention.
[0023] Figure 4 Shown is a structural diagram of the knowledge graph multi-hop question-answering system in one embodiment of the present invention.
[0024] Figure 5 It is a schematic structural diagram of an electronic device of the present invention in one embodiment. DETAILED DESCRIPTION
[0025] The following describes the embodiments of the present invention by specific examples, and those skilled in the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that the following embodiments and features in the embodiments can be combined with each other without conflict.
[0026] It should be noted that the illustrations provided in the following embodiments are only schematic illustrations of the basic concept of the present invention, and thus the drawings only show components related to the present invention rather than being drawn according to the number, shape and size of components in actual implementation. In actual implementation, the type, quantity and proportion of each component may be changed arbitrarily, and the component layout may also be more complicated.
[0027] The following embodiments of the present invention provide a knowledge graph multi-hop question answering method, which can be applied to Figure 1 The electronic device shown. The electronic device described in the present invention may include a mobile phone 11 with a wireless charging function, a tablet computer 12, a laptop computer 13, a wearable device, a vehicle-mounted device, an augmented reality (AR) / virtual reality (VR) device, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), etc. The embodiment of the present invention does not impose any restrictions on the specific type of the electronic device.
[0028] For example, the electronic device may be a station (STAION, ST) in a WLAN with a wireless charging function, a cellular phone, a cordless phone, a Session Initiation Protocol (SIP) phone, a Wireless Local Loop (WLL) station, a Personal Digital Assistant (PDA) device, a handheld device with a wireless charging function, a computing device or other processing device, a computer, a laptop computer, a handheld communication device, a handheld computing device, and / or other devices for communicating on a wireless system and a next generation communication system, such as a mobile terminal in a 5G network, a mobile terminal in a future evolved Public Land Mobile Network (PLMN), or a mobile terminal in a future evolved Non-terrestrial Network (NTN).
[0029] For example, the electronic device can communicate with the network and other devices through wireless communication. The above wireless communication can use any communication standard or protocol, including but not limited to Global System of Mobilecommunication (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Long Term Evolution (LTE), email, Short Messaging Service (SMS), BT, GNSS, WLAN, NFC, FM, and / or IR technology, etc. The GNSS can include Global Positioning System (GPS), Global Navigation Satellite System (GLONASS), Beidou Satellite Navigation System (BDS), Quasi-Zenith Satellite System (QZSS) and / or Satellite Based Augmentation Systems (SBAS).
[0030] The technical solutions in the embodiments of the present invention will be described in detail below in conjunction with the accompanying drawings in the embodiments of the present invention.
[0031] like Figure 2 and Figure 3 As shown, in one embodiment, the knowledge graph multi-hop question answering method of the present invention includes steps S1 to S4.
[0032] Step S1: Obtain the target question and the corresponding knowledge graph.
[0033] Specifically, firstly, the target question query and its corresponding knowledge graph K_Graph are obtained. For example, when the target question is related to weather, the knowledge graph is a weather-related knowledge graph; when the target question is related to government affairs, the knowledge graph is a government affairs knowledge graph.
[0034] Step S2: Determine whether the target problem is a multi-hop problem or a single-hop problem.
[0035] Specifically, the target question is determined to be a multi-hop question or a single-hop question based on the BERT (Bidirectional Encoder Representation from Transformers) model. The BERT model is based on the Transformer architecture and uses pre-training and fine-tuning to deeply represent natural language, which can be applied to classification, question answering, summarization and other fields.
[0036] For example, the target question "When was Zhang San born?" can be judged as a single-hop question, which only involves Zhang San's date of birth. The target question "Who were born at the same time as Zhang San?" can be judged as a multi-hop question, which involves multiple questions such as Zhang San's date of birth and people born on this date.
[0037] Step S3: If it is a multi-hop problem, rewrite the target problem into multiple sub-problems.
[0038] Specifically, for multi-hop questions, in order to reduce the difficulty of entity and relationship recognition and improve the accuracy of query results, the target question is rewritten into multiple sub-questions. Preferably, the Qwen1.5-14B-Chat model is used to rewrite the question, which is given in the form of a list and assigned as question.
[0039] In one embodiment, the attributes contained in the target question are identified, and then split into several small questions [q1, q2, …] according to the attribute values, that is, a sub-question is generated for each attribute. In this case, question=[q1, q2, …]. It should be noted that each sub-question can only contain one attribute. The combined meaning of the multiple sub-questions is consistent with the overall meaning of the target question, and no extension of the question can occur.
[0040] For example, for the target question "Who are the people born at the same time as Zhang San?", the sub-question is [Zhang San's date of birth is A, who are the people whose date of birth is A? ].
[0041] For a single-hop question, let question=[q1] and q1=query.
[0042] Step S4: For each sub-question or the single-hop question, obtain the query result corresponding to the target question based on the knowledge graph and the question-answering reasoning model.
[0043] Specifically, in one embodiment, for each sub-question or the single-hop question, obtaining the query result corresponding to the target question based on the knowledge graph and the question-answering reasoning model includes the following steps.
[0044] 41) For each sub-problem or the single-hop problem, perform entity and relationship recognition to obtain entity and relationship recognition results.
[0045] Among them, entity and relationship recognition is performed based on the GlobalPointer algorithm. For example, for the target question "Who were born at the same time as Zhang San?", the entity and relationship recognition result ent2rel = [Zhang San, date of birth].
[0046] 42) Retrieve the entity and relationship recognition results in the knowledge graph to obtain related knowledge graph information.
[0047] Among them, the entity and relationship recognition results ent2rel are searched in the knowledge graph K_Graph, and the cypher statement used for the search is --match (e1)-[r:]-(e2) where e1.name=ent2rel[0]and r.name=ent2rel[1] return e2, so as to obtain the related knowledge graph information.
[0048] 43) Inputting the associated knowledge graph information and the target question into the question-answering reasoning model to obtain the query result corresponding to the target question.
[0049] Among them, the associated knowledge graph information and the target question are input into the question-answering reasoning model for reasoning. If the answer is insufficient corpus, i=i+1, if i is greater than the question list length, None is returned; if i is less than the question list length, it returns to step 41) for iteration; if the inference answer is returned, the collected triple information is sufficient to answer, and the question-answering interface can obtain the query result corresponding to the target question that is easy for humans to read.
[0050] In one embodiment, the question-answering reasoning model adopts a large language model, such as the Qwen1.5-14B model.
[0051] The protection scope of the knowledge graph multi-hop question answering method described in the embodiment of the present invention is not limited to the execution order of the steps listed in this embodiment. All solutions implemented by adding, reducing or replacing steps in the prior art based on the principles of the present invention are included in the protection scope of the present invention.
[0052] An embodiment of the present invention also provides a knowledge graph multi-hop question and answer system, which can implement the knowledge graph multi-hop question and answer method described in the present invention. However, the implementation device of the knowledge graph multi-hop question and answer system described in the present invention includes but is not limited to the structure of the knowledge graph multi-hop question and answer system listed in this embodiment. All structural deformations and replacements of the prior art made according to the principles of the present invention are included in the protection scope of the present invention.
[0053] like Figure 4 As shown, in one embodiment, the knowledge graph multi-hop question answering system of the present invention includes an acquisition module 41, a judgment module 42, a rewriting module 43 and a reasoning module 44.
[0054] The acquisition module 41 is used to obtain the target question and the corresponding knowledge graph.
[0055] The determination module 42 is connected to the acquisition module 41 and is used to determine whether the target problem is a multi-hop problem or a single-hop problem.
[0056] The rewriting module 43 is connected to the judging module 42 and is used to rewrite the target problem into multiple sub-problems if it is a multi-hop problem.
[0057] The reasoning module 44 is connected to the rewriting module 43, and is used to obtain the query result corresponding to the target question based on the knowledge graph and the question-answering reasoning model for each sub-question or the single-hop question.
[0058] Among them, the structures and principles of the acquisition module 41, the judgment module 42, the rewriting module 43 and the reasoning module 44 correspond one by one to the steps in the above-mentioned knowledge graph multi-hop question-answering method, so they will not be repeated here.
[0059] In the several embodiments provided by the present invention, it should be understood that the disclosed system, device or method can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of modules / units is only a logical function division, and there may be other division methods in actual implementation, such as multiple modules or units can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or modules or units, which can be electrical, mechanical or other forms.
[0060] The modules / units described as separate components may or may not be physically separated, and the components displayed as modules / units may or may not be physical modules, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules / units may be selected according to actual needs to achieve the purpose of the embodiments of the present invention. For example, the functional modules / units in the various embodiments of the present invention may be integrated into one processing module, or each module / unit may exist physically separately, or two or more modules / units may be integrated into one module / unit.
[0061] Those of ordinary skill in the art should further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0062] The embodiment of the present invention also provides a computer-readable storage medium. A person of ordinary skill in the art can understand that all or part of the steps in the method for implementing the above embodiment can be completed by instructing the processor through a program, and the program can be stored in a computer-readable storage medium, and the storage medium is a non-transitory medium, such as a random access memory, a read-only memory, a flash memory, a hard disk, a solid-state hard disk, a magnetic tape, a floppy disk, an optical disc, and any combination thereof. The above storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or a data center that includes one or more available media. The available medium can be a magnetic medium (for example, a floppy disk, a hard disk, a tape), an optical medium (for example, a digital video disc (DVD)), or a semiconductor medium (for example, a solid-state disk (SSD)), etc.
[0063] An embodiment of the present invention further provides an electronic device, which includes a processor and a memory.
[0064] The memory is used to store computer programs.
[0065] The memory includes: ROM, RAM, disk, USB flash drive, memory card or CD and other media that can store program codes.
[0066] The processor is connected to the memory and is used to execute the computer program stored in the memory so that the electronic device executes the above-mentioned knowledge graph multi-hop question and answer method.
[0067] Preferably, the processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components.
[0068] like Figure 5 As shown, the electronic device of the present invention is in the form of a general computing device. The components of the electronic device may include but are not limited to: one or more processors or processing units 51, a memory 52, and a bus 53 connecting different system components (including the memory 52 and the processing unit 51).
[0069] Bus 53 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor or a local bus using any of a variety of bus architectures. For example, these architectures include but are not limited to Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MAC) bus, Enhanced ISA bus, Video Electronics Standards Association (VESA) local bus and Peripheral Component Interconnect (PCI) bus.
[0070] Electronic devices typically include a variety of computer system readable media. These media can be any available media that can be accessed by the electronic device, including volatile and non-volatile media, removable and non-removable media.
[0071] The memory 52 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 521 and / or cache memory 522. The electronic device may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 523 may be used to read and write non-removable, non-volatile magnetic media ( Figure 5 not shown, usually called a "hard drive"). Although Figure 5Not shown, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to the bus 53 via one or more data medium interfaces. The memory 52 may include at least one program product having a set (e.g., at least one) of program modules that are configured to perform the functions of the various embodiments of the present invention.
[0072] A program / utility 524 having a set (at least one) of program modules 5241 may be stored, for example, in the memory 52, such program modules 5241 including but not limited to an operating system, one or more application programs, other program modules, and program data, each of which or some combination thereof may include an implementation of a network environment. The program modules 5241 generally perform the functions and / or methods of the embodiments described herein.
[0073] The electronic device may also communicate with one or more external devices (e.g., keyboards, pointing devices, displays, etc.), one or more devices that enable a user to interact with the electronic device, and / or any device that enables the electronic device to communicate with one or more other computing devices (e.g., network cards, modems, etc.). Such communication may be performed via input / output (I / O) interface 54. Furthermore, the electronic device may also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) via network adapter 55. Figure 5 As shown, the network adapter 55 communicates with other modules of the electronic device via the bus 53. It should be understood that, although not shown in the figure, other hardware and / or software modules can be used in conjunction with the electronic device, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0074] The above embodiments are merely illustrative of the principles and effects of the present invention, and are not intended to limit the present invention. Anyone familiar with the art may modify or alter the above embodiments without departing from the spirit and scope of the present invention. Therefore, all equivalent modifications or alterations made by a person of ordinary skill in the art without departing from the spirit and technical concept disclosed by the present invention shall still be covered by the claims of the present invention.
Claims
1. A knowledge graph multi-hop question answering method, characterized in that: The method comprises the following steps: Get the target question and the corresponding knowledge graph; Determining whether the target problem is a multi-hop problem or a single-hop problem; If it is a multi-hop problem, rewrite the target problem into multiple sub-problems; For each sub-question or the single-hop question, obtaining a query result corresponding to the target question based on the knowledge graph and the question-answering reasoning model; For each sub-question or the single-hop question, obtaining the query result corresponding to the target question based on the knowledge graph and the question-answering reasoning model includes the following steps: For each sub-problem or the single-hop problem, perform entity and relationship recognition to obtain entity and relationship recognition results; Retrieving the entity and relationship recognition results in the knowledge graph to obtain related knowledge graph information; The associated knowledge graph information and the target question are input into the question-answering reasoning model to obtain the query result corresponding to the target question.
2. The knowledge graph multi-hop question answering method according to claim 1, characterized in that: Based on the BERT model, it is determined whether the target problem is a multi-hop problem or a single-hop problem.
3. The knowledge graph multi-hop question answering method according to claim 1, characterized in that: Rewriting the target problem into multiple sub-problems includes the following steps: identifying attributes included in the target problem; Generate a subquestion for each attribute.
4. The knowledge graph multi-hop question answering method according to claim 1, characterized in that: Entity and relationship recognition based on GlobalPointer algorithm.
5. The knowledge graph multi-hop question answering method according to claim 1, characterized in that: The question-answering reasoning model adopts a large language model.
6. The knowledge graph multi-hop question answering method according to claim 1, characterized in that: The knowledge graph is a government affairs knowledge graph.
7. A knowledge graph multi-hop question answering system, characterized in that: The system includes an acquisition module, a judgment module, a rewriting module and a reasoning module; The acquisition module is used to obtain the target question and the corresponding knowledge graph; The judging module is used to judge whether the target problem is a multi-hop problem or a single-hop problem; The rewriting module is used to rewrite the target problem into multiple sub-problems if it is a multi-hop problem; The reasoning module is used to obtain the query result corresponding to the target question based on the knowledge graph and the question-answering reasoning model for each sub-question or the single-hop question; For each sub-question or the single-hop question, obtaining the query result corresponding to the target question based on the knowledge graph and the question-answering reasoning model includes the following steps: For each sub-problem or the single-hop problem, perform entity and relationship recognition to obtain entity and relationship recognition results; Retrieving the entity and relationship recognition results in the knowledge graph to obtain related knowledge graph information; The associated knowledge graph information and the target question are input into the question-answering reasoning model to obtain the query result corresponding to the target question.
8. An electronic device, characterized in that: The electronic device comprises: a processor and a memory; The memory is used to store computer programs; The processor is used to execute the computer program stored in the memory so that the electronic device performs the knowledge graph multi-hop question answering method described in any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by an electronic device, it implements the knowledge graph multi-hop question answering method described in any one of claims 1 to 6.
Citation Information
Patent Citations
Knowledge graph question and answer method, terminal equipment and storage medium
CN115114420A
Construction drawing review specification-oriented knowledge extraction and knowledge graph construction method and system
CN115905553A
Construction method of literature and blog knowledge graph system
CN116340541A
Complex question and answer method based on subject domain knowledge graph
CN116821312A
Multi-round dialogue method, system and device based on knowledge graph and storage medium
CN117076633A