Intelligent question and answer method and device, equipment and medium
By combining knowledge graphs and language models in the medical question and answer system, receiving user query statements, matching knowledge graphs, generating candidate paths and filtering out target paths, the problem of insufficient accuracy of the existing medical question and answer system is solved, and higher answer accuracy and relevance are achieved.
Patent Information
- Application Number
- CN202510340257.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-20
- Publication Date
- 2025-06-20
AI Technical Summary
Existing medical Q&A systems have insufficient accuracy, manual systems are time-consuming and labor-intensive and may provide inaccurate answers, while systems based on large-scale language models may also lead to inaccuracy in their answers due to training errors and data biases.
By receiving the user's query statement, determine the entity objects therein and match the target knowledge graph from the preset database. Then, by wandering around the knowledge graph to generate candidate paths, calculate the syntax and semantic similarity between the candidate path and the query statement, filter out the target path, and integrate it into the prompt graph data and input it into the language model to generate query results.
By combining knowledge graphs and language models, the deep semantics of query statements can be more comprehensively understood, thereby improving the accuracy of answers and relevance to query statements.
Smart Images

Figure CN120181201A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and particularly to an intelligent question-answering method, device, equipment and medium. Background Art
[0002] In the medical field, the accuracy and reliability of information are fundamental to making medical decisions, which are directly related to the health and safety of patients. Currently, traditional medical question-answering systems are mainly divided into two categories: one is the artificial-based question-answering system, which relies on the professional knowledge and experience of a medical expert team. However, this process is extremely time-consuming and laborious. Due to the extensive and complex nature of medical knowledge, experts need to invest a large amount of energy in knowledge collation and answer design. However, due to the limitation of personal energy, this method may still provide inaccurate answers and is difficult to meet the growing demand for medical consultations. The other is the question-answering system based on large language models, which mainly relies on a large amount of text data crawled from the Internet for training. However, such systems also have limitations. Due to problems such as training errors and data biases, they may also lead to inaccurate answers. Therefore, how to improve the accuracy of the question-answering system has become an urgent problem to be solved. Summary of the Invention
[0003] The present invention provides an intelligent question-answering method, device, equipment and medium to solve the problem of how to improve the accuracy of the question-answering system.
[0004] In the first aspect, an intelligent question-answering method is provided, including: Receiving a query statement proposed by a user, determining entity objects included in the query statement, and matching a corresponding target knowledge graph from a preset database according to the entity objects included in the query statement; Determining entity nodes representing the same entity as each entity object from all target knowledge graphs, and for any entity node, performing a walk starting from the entity node in the knowledge graph corresponding to the entity node to obtain candidate paths; For any candidate path, calculating a first similarity value representing the syntactic similarity between the candidate path and the query statement, and calculating a second similarity value representing the semantic similarity between the candidate path and the query statement; According to the first similarity value and the second similarity value, screening all candidate paths to obtain target paths, forming prompt graph data from all target paths, and inputting the prompt graph data and the query statement into a language model to output a query result.
[0005] In the second aspect, an intelligent question-answering device is provided, including: A matching module, configured to receive a query statement proposed by a user, determine entity objects included in the query statement, and match a corresponding target knowledge graph from a preset database according to the entity objects included in the query statement; A first traversal module, configured to determine entity nodes representing the same entity as each entity object from all target knowledge graphs, and for any entity node, perform traversal starting from the entity node in the knowledge graph corresponding to the entity node to obtain candidate paths; A first calculation module, configured to calculate a first similarity value representing the syntactic similarity between a candidate path and the query statement, and calculate a second similarity value representing the semantic similarity between the candidate path and the query statement for any candidate path; An answering module, configured to screen all candidate paths according to the first similarity value and the second similarity value to obtain target paths, form prompt graph data from all target paths, input the prompt graph data and the query statement into a large language model, and output a query result.
[0006] In a third aspect, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the intelligent question-answering method in the first aspect are implemented.
[0007] In a fourth aspect, a computer-readable storage medium is provided. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the intelligent question-answering method in the first aspect are implemented.
[0008] In the solution implemented by the above intelligent question-answering method, device, device, and medium, by determining entity objects included in the query statement, matching a corresponding target knowledge graph from a preset database, determining entity nodes representing the same entity as each entity object from all target knowledge graphs, for any entity node, performing traversal starting from the entity node in the knowledge graph corresponding to the entity node to obtain candidate paths, calculating a first similarity value representing the syntactic similarity between a candidate path and the query statement, and calculating a second similarity value representing the semantic similarity between the candidate path and the query statement for any candidate path, screening all candidate paths according to the first similarity value and the second similarity value to obtain target paths, forming prompt graph data from all target paths, inputting the prompt graph data and the query statement into a language model, and outputting a query result.
[0009] Among them, by combining a knowledge graph with a language model, target paths that meet specific conditions in terms of both syntactic similarity and semantic similarity with the query statement are mined from the knowledge graph, and these paths are integrated into prompt graph data as auxiliary information when the language model processes the query statement, providing the model with richer, more accurate, and structured context knowledge, so that the language model can more comprehensively grasp the deep semantics of the question when answering the query, thereby improving the accuracy of the answer and its relevance to the query statement. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for describing the embodiments of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention, and those of ordinary skill in the art can obtain other drawings based on these drawings without creative efforts.
[0011] Figure 1 FIG. is a schematic diagram of an application environment of an intelligent question-answering method provided in Embodiment 1 of the present invention; Figure 2 FIG. is a schematic flowchart of an intelligent question-answering method provided in Embodiment 2 of the present invention; Figure 3 FIG. is a schematic flowchart of an intelligent question-answering method provided in Embodiment 3 of the present invention; Figure 4 FIG. is a schematic flowchart of an intelligent question-answering method provided in Embodiment 4 of the present invention; Figure 5 FIG. is a schematic flowchart of an intelligent question-answering method provided in Embodiment 5 of the present invention; Figure 6 FIG. is a schematic structural diagram of an intelligent question-answering device provided in Embodiment 6 of the present invention; Figure 7 FIG. is a schematic structural diagram of a computer device provided in Embodiment 7 of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0012] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are some, but not all, of the embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts fall within the protection scope of the present invention.
[0013] The intelligent question-answering method provided in Embodiment 1 of the present invention can be applied, for example, in Figure 1In the application environment, the server communicates with the client. The server provides an intelligent question and answer service, and the client triggers an intelligent question and answer task to the server. Among them, the client includes, but is not limited to, devices such as a palm computer, a desktop computer, a laptop computer, an ultra-mobile personal computer (UMPC), a netbook, a cloud computer device, and a personal digital assistant (PDA). The computer device corresponding to the server can be implemented by an independent server or a server cluster composed of multiple servers.
[0014] As Figure 2 shown, it is a schematic flowchart of an intelligent question and answer method provided by the second embodiment of the present invention, including the following steps: Step S201: Receive the query statement proposed by the user, determine the entity objects included in the query statement, and match the corresponding target knowledge graph from the preset database according to the entity objects included in the query statement.
[0015] In this embodiment, the query statement may refer to the question text proposed by the user, and the entity object may refer to a noun phrase or concept with a clear meaning and independent existence in the query statement; For example, in a medical scenario, the query statement may be: "What are the same symptom manifestations of the two diseases, heart disease and diabetes?" Then it can be determined that there are two entity objects in this query statement, namely heart disease and diabetes respectively. The preset database may refer to a database pre-set for storing knowledge graphs, and the target knowledge graph may refer to a knowledge graph that matches the query statement.
[0016] Specifically, receive the query statement proposed by the user, determine the entity objects included in the query statement, perform intent recognition on the query statement, determine the query field corresponding to the query statement, match the corresponding field database according to the query field, and match any knowledge graph including the entity objects in the query statement from the field database as the target knowledge graph.
[0017] Among them, the query field may refer to the knowledge field involved in the query statement; For example, in a medical scenario, the query field may include disease fields, drug fields, and medical device fields, etc. The field database may refer to a database for storing knowledge corresponding to the query field.
[0018] Step S202: Determine the entity nodes representing the same entity as each entity object from all the target knowledge graphs. For any entity node, in the knowledge graph corresponding to the entity node, start walking from the entity node to obtain a candidate path.
[0019] Step S203: For any candidate path, calculate a first similarity value representing the syntactic similarity between the candidate path and the query statement, and calculate a second similarity value representing the semantic similarity between the candidate path and the query statement.
[0020] In this embodiment, an entity node may refer to a node in the knowledge graph that represents the same entity as the entity object. A candidate path may refer to a path in the knowledge graph starting from an entity node. Syntactic similarity may refer to the similarity between the candidate path and the surface form or structure of the query statement. Semantic similarity may refer to the similarity between the candidate path and the meaning or context of the query statement. The first similarity value may refer to a score representing the syntactic similarity between the candidate path and the query statement, and the second similarity value may refer to a score representing the semantic similarity between the candidate path and the query statement.
[0021] Specifically, for any entity node, in the knowledge graph where the entity node is located, perform random walks starting from the entity node to obtain candidate paths. For any candidate path, calculate the first similarity value and the second similarity value between the candidate path and the query statement according to the attributes and relationships represented by the nodes in the candidate path.
[0022] Step S204: According to the first similarity value and the second similarity value, screen all the candidate paths to obtain target paths. Form hint graph data from all the target paths, and input the hint graph data and the query statement into a language model to output a query result.
[0023] In this embodiment, a target path may refer to a path obtained by screening candidate paths according to the first similarity value and the second similarity value. Hint graph data may refer to graph-structured data formed by target paths. A language model may refer to a pre-set large language model. For example, the language model may be an LLM model (Large Language Model) and a ChatGLM model (Chat General Language Mode), etc. A query result may refer to an answer output by the language model based on the hint graph data for the query statement.
[0024] Specifically, according to the first similarity value and the second similarity value, screen all the candidate paths, determine that the candidate paths reaching the threshold are target paths, form hint graph data from all the target paths, and input them together with the query statement into the language model to output a query result.
[0025] Optionally, after outputting the query result, the accuracy of the query result can also be evaluated to obtain an evaluation result; if the evaluation result does not meet the preset condition, then return to execute the step of walking starting from any entity node in the knowledge graph corresponding to the entity node until the evaluation result meets the preset condition.
[0026] Optionally, after determining the entity objects included in the query statement, for any entity object included in the query statement, an associated query associated with the entity object and the historical answer result of the corresponding associated query can be matched from the question mapping table. The question mapping table is used to store the mapping relationship between the entity object and the associated query, as well as the historical answer result of the corresponding associated query; after inputting the prompt graph data and the query statement into the large language model and outputting the query result, the associated query associated with the entity object and the historical answer result of the corresponding associated query are output in association, where the associated query can refer to the historical question text containing the entity object, and the historical answer result can refer to the historical result of the associated query.
[0027] In this embodiment, by combining the knowledge graph with the language model, target paths that meet specific conditions in terms of both syntactic similarity and semantic similarity with the query statement are mined from the knowledge graph, and these paths are integrated into prompt graph data as auxiliary information when the language model processes the query statement, providing the model with richer, more accurate, and structured context knowledge, so that the language model can more comprehensively grasp the deep semantics of the question when answering the query, thereby improving the accuracy of the answer and the relevance to the query statement.
[0028] As Figure 3 shown, it is a schematic flowchart of an intelligent question-answering method provided by Embodiment 3 of the present invention. The step of walking starting from any entity node in the knowledge graph corresponding to the entity node in step S202 to obtain candidate paths may include the following steps: Step S301: For any entity node, in the knowledge graph corresponding to the entity node, starting from the entity node, perform random walking with a preset probability to obtain candidate paths.
[0029] Step S302: Return to execute the step of performing random walking starting from the entity node with a preset probability until the preset walking stop condition is met, and obtain all candidate paths starting from the entity node.
[0030] In this embodiment, the preset probability may refer to the preset walking termination probability, and the preset walking stop condition may refer to the preset walking stop condition. For example, the preset walking stop condition may refer to the number of candidate paths reaching a preset value.
[0031] Specifically, for any entity node, in the knowledge graph where the entity node is located, starting from the entity node, perform a random walk with a preset probability. For example, the random walk can be based on depth-first search or breadth-first search to obtain candidate paths. When the number of all candidate paths starting from the entity node reaches a preset value, it is determined that the preset random walk stop condition is satisfied, and all candidate paths starting from the entity node are obtained.
[0032] In this embodiment, for any entity node, starting from the entity node, perform a random walk with a preset probability to obtain candidate paths. When the preset random walk stop condition is satisfied, all candidate paths starting from the entity node are obtained, avoiding endless path exploration in the knowledge graph and improving the path random walk efficiency.
[0033] As Figure 4 shown, it is a schematic flowchart of an intelligent question answering method provided in Embodiment 4 of the present invention. Calculating the first similarity value representing the syntactic similarity between the candidate path and the query statement in the above step S203 may include the following steps: Step S401: Perform word segmentation on the query statement to obtain each query sub-word, and form a query vocabulary set with all the query sub-words.
[0034] Step S402: For any node in the candidate path, determine the attribute value represented by the node, and form an attribute value set with the attribute values represented by all the nodes in the candidate path.
[0035] Step S403: Calculate the intersection of the query vocabulary set and the attribute value set, and calculate the union of the query vocabulary set and the attribute value set.
[0036] Step S404: Take the ratio of the intersection to the union as the first similarity value of the candidate path.
[0037] In this embodiment, the query sub-word may refer to a word or phrase obtained by word segmentation of the query statement. The query vocabulary set may refer to the set of all query sub-words corresponding to the query statement. The attribute value may refer to the attributes and relationship types of the entity represented by the node, and the attribute value set may refer to the set of attribute values represented by the node. For example, in a medical knowledge graph, the entity represented by the node may refer to the disease entity of a cold. The attributes represented by this node may include the symptom attributes of a cold, such as cough, fever, and runny nose, etc. The relationship types represented by this node may include the relationship between a cold and the drug entity for treating a cold, or the relationship between a cold and the doctor entity for treating a cold, etc.
[0038] Specifically, perform word segmentation on the query statement to obtain each query sub-word, form a query vocabulary set from all the query sub-words, for any node in the candidate path, determine the attribute value represented by the node, form an attribute value set from the attribute values represented by all the nodes, and use the ratio of the intersection of the query vocabulary set and the attribute value set to the union of the query vocabulary set and the attribute value set as the first similarity value of the candidate path.
[0039] In this embodiment, by calculating the union and intersection of the query vocabulary set corresponding to the query vocabulary and the attribute value set corresponding to the candidate path, and using the ratio of the union to the intersection as the first similarity value, when screening the candidate path according to the first similarity value, a candidate path with a high syntactic similarity to the query statement can be obtained, improving the accuracy of the target path obtained by screening.
[0040] Such as Figure 5 shown, is a flowchart of an intelligent question-answering method provided in Embodiment 5 of the present invention. Calculating the first similarity value representing the syntactic similarity between the candidate path and the query statement in the above step S203 may include the following steps: Step S501: Perform vector representation on the query statement to obtain a query vector.
[0041] Step S502: For any node in the candidate path, determine the attribute value represented by the node, and perform vector representation on the attribute values represented by all the nodes in the candidate path to obtain an attribute vector.
[0042] Step S503: Calculate the cosine similarity between the query vector and the attribute vector, and use the cosine similarity as the second similarity value of the candidate path.
[0043] In this embodiment, the query vector may refer to the vector representation of the query statement, and the attribute vector may refer to the vector representation of the attribute values represented by all the nodes in the candidate path.
[0044] Specifically, perform vectorization on the query statement to obtain a query vector, perform vectorization on the attribute values represented by all the nodes in the candidate path to obtain an attribute vector, and calculate the cosine similarity between the query vector and the attribute vector through the cosine similarity calculation formula, and use the cosine similarity as the second similarity value of the candidate path.
[0045] In this embodiment, by calculating the cosine similarity between the query vector corresponding to the query vocabulary and the attribute vector corresponding to the candidate path, and using the cosine similarity value as the second similarity value, when screening the candidate path according to the second similarity value, a candidate path with a high semantic similarity to the query statement can be obtained, improving the accuracy of the target path obtained by screening.
[0046] It should be understood that the magnitudes of the sequence numbers of the steps in the above embodiments do not mean the sequence of execution. The execution sequence of each process should be determined according to its function and internal logic, and should not constitute any limitation to the implementation process of the embodiments of the present invention.
[0047] As Figure 6 shown, a smart question-answering device provided in Embodiment VI of the present invention is in one-to-one correspondence with the smart question-answering method in the above embodiments. As Figure 6 shown, the smart question-answering device includes a matching module 61, a first traversal module 62, a first calculation module 63, and an answering module 64. The detailed description of each functional module is as follows: The matching module 61 is configured to receive a query statement proposed by a user, determine the entity objects included in the query statement, and match a corresponding target knowledge graph from a preset database according to the entity objects included in the query statement; The first traversal module 62 is configured to determine entity nodes representing the same entity as each entity object from all target knowledge graphs, and for any entity node, perform traversal starting from the entity node in the knowledge graph corresponding to the entity node to obtain candidate paths; The first calculation module 63 is configured to, for any candidate path, calculate a first similarity value representing the syntactic similarity between the candidate path and the query statement, and calculate a second similarity value representing the semantic similarity between the candidate path and the query statement; The answering module 64 is configured to screen all candidate paths according to the first similarity value and the second similarity value to obtain target paths, form prompt graph data from all target paths, and input the prompt graph data and the query statement into a large language model to output a query result.
[0048] Optionally, the above first traversal module 62 includes: A second traversal unit configured to, for any entity node, perform random traversal starting from the entity node in the knowledge graph with a preset probability to obtain candidate paths; A loop traversal unit configured to return to execute the step of performing random traversal starting from the entity node with a preset probability until a preset traversal stop condition is met, to obtain all candidate paths starting from the entity node.
[0049] Optionally, the above first calculation module 63 includes: A first formation unit configured to perform word segmentation on the query statement to obtain each query sub-word, and form a query vocabulary set from all query sub-words; A second formation unit, configured to determine, for any node in the candidate path, an attribute value represented by the node, and form an attribute value set with the attribute values represented by all nodes in the candidate path; A second calculation unit, configured to calculate the intersection of the query vocabulary set and the attribute value set, and calculate the union of the query vocabulary set and the attribute value set; A third calculation unit, configured to use the ratio of the intersection to the union as the first similarity value of the candidate path.
[0050] Optionally, the above first calculation module 63 includes: A first vectorization unit, configured to perform vector representation on the query statement to obtain a query vector; A second vectorization unit, configured to determine, for any node in the candidate path, an attribute value represented by the node, and perform vector representation on the attribute values represented by all nodes in the candidate path to obtain an attribute vector; A fourth calculation unit, configured to calculate the cosine similarity between the query vector and the attribute vector, and use the cosine similarity as the second similarity of the candidate path.
[0051] Optionally, the intelligent question answering device further includes: An associated query module, configured to, for any entity object included in the query statement, match, from a question mapping table, an associated query related to the entity object and a historical answer result corresponding to the associated query, where the question mapping table is used to store a mapping relationship between the entity object and the associated query, and the historical answer result corresponding to the associated query; An associated output module, configured to perform associated output on the associated query related to the entity object and the historical answer result corresponding to the associated query.
[0052] Optionally, the above matching module 61 includes: An intention recognition unit, configured to perform intention recognition on the query statement to determine a query domain corresponding to the query statement; A determination unit, configured to, according to the query domain, match a corresponding domain database, and match, from the domain database, any knowledge graph including the entity object in the query statement as the target knowledge graph.
[0053] Optionally, the intelligent question answering device further includes: An evaluation module, configured to perform accuracy evaluation on the query result to obtain an evaluation result; A loop execution module, configured to, if the evaluation result does not meet a preset condition, return to execute the step of performing a walk starting from the entity node in the knowledge graph corresponding to the entity node until the evaluation result meets the preset condition.
[0054] For the specific limitations of the intelligent question-answering device, reference can be made to the limitations on the intelligent question-answering method in the foregoing text, which will not be elaborated here. Each module in the above intelligent question-answering device can be implemented in whole or in part by software, hardware, and their combination. The above modules can be embedded in the processor in the computer device in the form of hardware or be independent of the processor, or can be stored in the memory in the computer device in the form of software, so as to facilitate the processor to call and execute the operations corresponding to the above respective modules.
[0055] Such as Figure 7 shown, is a schematic structural diagram of a computer device provided in Embodiment 7 of the present invention. The computer device in this embodiment includes: at least one processor ( Figure 7 only one is shown in the figure), a memory, and a computer program stored in the memory and executable on at least one processor. When the processor executes the computer program, the steps in any of the above embodiments of the intelligent question-answering method are implemented.
[0056] The computer device may include, but is not limited to, a processor and a memory. Those skilled in the art can understand that Figure 7 merely an example of a computer device, which does not constitute a limitation on the computer device. The computer device may include more or fewer components than shown in the figure, or combine some components, or different components. For example, it may also include a network interface, a display screen, and an input device, etc.
[0057] The so-called processor may be a CPU, and the processor may also be other general-purpose processors, digital signal processors (DSPs), application specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0058] The memory includes a readable storage medium, an internal memory, etc. Among them, the internal memory can be the memory of a computer device, and the internal memory provides an environment for the operation of the operating system and computer-readable instructions in the readable storage medium. The readable storage medium can be the hard disk of a computer device, and in some other embodiments, it can also be an external storage device of a computer device. For example, a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) card, a Flash Card, etc. equipped on the computer device. Further, the memory can also include both the internal storage unit of the computer device and the external storage device. The memory is used to store the operating system, application programs, a BootLoader, data, and other programs, etc. The other programs such as the program code of a computer program, etc. The memory can also be used to temporarily store the data that has been output or will be output.
[0059] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the above division of each functional unit and module is used as an example. In actual applications, the above functions can be allocated to different functional units and modules according to needs, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. Each functional unit and module in the embodiments can be integrated into a processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above integrated unit can be implemented in the form of hardware or in the form of a software functional unit. In addition, the specific names of each functional unit and module are only for the convenience of mutual distinction and do not limit the protection scope of this application. The specific working processes of the units and modules in the above device can refer to the corresponding processes in the foregoing method embodiments and will not be elaborated herein. If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, to implement all or part of the processes in the above method embodiments of this application, a computer program can be used to instruct the relevant hardware to complete. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by a processor, the steps of the above method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in the form of source code, object code, executable file or some intermediate form, etc. The computer-readable medium can at least include: any entity or device that can carry the computer program code, recording medium, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signal, telecommunication signal, and software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disc, etc. In some jurisdictions, according to legislation and patent practice, the computer-readable medium cannot be an electrical carrier signal and a telecommunication signal.
[0060] All or part of the processes in the above method embodiments of this application can also be completed by a computer program product. When the computer program product runs on a computer device, the computer device can be made to execute the steps in the above method embodiments.
[0061] In the above embodiments, the descriptions of each embodiment have their own emphases. For the parts not detailed or recorded in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0062] Those of ordinary skill in the art can realize that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be implemented by electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of this application.
[0063] In the embodiments provided in this application, it should be understood that the disclosed devices / computer devices and methods can be implemented in other ways. For example, the device / computer device embodiments described above are only illustrative. For example, the division of modules or units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed coupling or direct coupling or communication connection between each other can be through some interfaces. The indirect coupling or communication connection of devices or units can be in an electrical, mechanical or other form.
[0064] The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they can be located in one place, or can be distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0065] The above embodiments are only used to illustrate the technical solutions of this application, rather than to limit them; although this application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions recorded in the foregoing embodiments, or perform equivalent replacements for some of the technical features; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of each embodiment of this application, and should all be included in the protection scope of this application. The non-company software tools or components that appear in the embodiments of this application are only introduced by way of example and do not represent actual use.
Claims
1. An intelligent question-answering method, characterized in that: include: Receive a query statement proposed by a user, determine the entity objects contained in the query statement, and match the corresponding target knowledge graph from a preset database according to the entity objects contained in the query statement; Determine the entity node representing the same entity as each entity object from all target knowledge graphs, and for any entity node, walk from the entity node as the starting point in the knowledge graph corresponding to the entity node to obtain a candidate path; For any candidate path, calculating a first similarity value representing a grammatical similarity between the candidate path and the query statement, and calculating a second similarity value representing a semantic similarity between the candidate path and the query statement; According to the first similarity value and the second similarity value, all candidate paths are screened to obtain a target path, all target paths are formed into prompt graph data, the prompt graph data and the query statement are input into a language model, and a query result is output.
2. The intelligent question-answering method according to claim 1, characterized in that: For any entity node, in the knowledge graph corresponding to the entity node, walking with the entity node as the starting point to obtain a candidate path includes: For any entity node, in the knowledge graph corresponding to the entity node, take the entity node as the starting point, perform random walk with a preset probability, and obtain a candidate path; Return to the step of taking the entity node as the starting point and performing random walking with a preset probability until a preset walking stop condition is met, and obtain all candidate paths taking the entity node as the starting point.
3. The intelligent question-answering method according to claim 1, characterized in that: The calculating a first similarity value representing the grammatical similarity between the candidate path and the query statement includes: Performing word segmentation processing on the query statement to obtain query subwords, and forming all query subwords into a query vocabulary set; For any node in the candidate path, determine the attribute value represented by the node, and form an attribute value set with the attribute values represented by all nodes in the candidate path; Calculating the intersection of the query vocabulary set and the attribute value set, and calculating the union of the query vocabulary set and the attribute value set; The ratio of the intersection to the union is used as the first similarity value of the candidate path.
4. The intelligent question-answering method according to claim 1, wherein: The calculating a second similarity value representing the semantic similarity between the candidate path and the query statement includes: Performing vector representation on the query statement to obtain a query vector; For any node in the candidate path, determine the attribute value represented by the node, and perform vector representation on the attribute values represented by all nodes in the candidate path to obtain an attribute vector; The cosine similarity between the query vector and the attribute vector is calculated, and the cosine similarity is used as a second similarity value of the candidate path.
5. The intelligent question-answering method according to claim 1, wherein: After determining the entity object included in the query statement, the method further includes: For any entity object included in the query statement, matching the associated query associated with the entity object and the historical answer result of the corresponding associated query from the question mapping table, wherein the question mapping table is used to store the mapping relationship between the entity object and the associated query, and the historical answer result of the corresponding associated query; After inputting the prompt graph data and the query statement into the large language model and outputting the query result, the method further includes: The associated query associated with the entity object and the historical answer result of the corresponding associated query are associated and output.
6. The intelligent question-answering method according to claim 1, characterized in that: The matching of the entity objects contained in the query statement to the corresponding target knowledge graph from the preset database includes: Performing intent recognition on the query statement to determine the query field corresponding to the query statement; According to the query domain, the corresponding domain database is matched, and any knowledge graph containing the entity object in the query statement matched from the domain database is the target knowledge graph.
7. The intelligent question-answering method according to claim 1, characterized in that: After inputting the prompt graph data and the query statement into the large language model and outputting the query result, the method further includes: Performing accuracy evaluation on the query result to obtain an evaluation result; If the evaluation result does not meet the preset condition, return to execute the step of walking around any entity node in the knowledge graph corresponding to the entity node with the entity node as the starting point until the evaluation result meets the preset condition.
8. An intelligent question-answering device, characterized in that: include: A matching module is used to receive a query statement proposed by a user, determine the entity objects contained in the query statement, and match the corresponding target knowledge graph from a preset database according to the entity objects contained in the query statement; The first walking module is used to determine the entity node representing the same entity as each entity object from all target knowledge graphs, and for any entity node, walk with the entity node as the starting point in the knowledge graph corresponding to the entity node to obtain a candidate path; A first calculation module is used to calculate, for any candidate path, a first similarity value representing a grammatical similarity between the candidate path and the query statement, and to calculate a second similarity value representing a semantic similarity between the candidate path and the query statement; The answer module is used to screen all candidate paths according to the first similarity value and the second similarity value to obtain a target path, form prompt graph data for all target paths, input the prompt graph data and the query statement into a large language model, and output a query result.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the intelligent question-answering method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the intelligent question-answering method according to any one of claims 1 to 7 are implemented.