Knowledge question and answer method and device, electronic equipment and storage medium

By querying the sample library in the knowledge question and answer system and using big models to generate graph database query statements, the accuracy problem of existing systems when handling complex and natural language queries is solved, and more efficient and accurate query results are achieved.

CN119760070APending Publication Date: 2025-04-04BEIJING BAIDU NETCOM SCI & TECH CO LTD

Patent Information

Application Number
CN202411814689.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-10
Publication Date
2025-04-04

AI Technical Summary

Technical Problem

The existing knowledge question and answer system is difficult to effectively handle complex and natural language queries, resulting in inaccurate query results or inability to meet user needs.

Method used

The query sample library obtains the target query example matching the input information, uses the big model to generate the graph database query statement, and searches in the graph database to obtain the results.

Benefits of technology

It improves the accuracy of the query statements generated by the graph database and the accuracy of the search results, can handle complex query logic, and has a wide range of applications.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119760070A_ABST
    Figure CN119760070A_ABST
Patent Text Reader

Abstract

The invention discloses a knowledge question answering method and device, electronic equipment and a storage medium, and relates to the technical field of computers, in particular to the artificial intelligence fields of large models, deep learning, natural language processing and the like. According to the specific implementation scheme, input information is obtained; obtaining a target query sample matched with the input information by querying a sample library; wherein the target query sample comprises a target query demand sample and a target graph database query statement sample corresponding to the target query demand sample; generating a first graph database query statement by utilizing the large model according to the input information and the target query sample; according to the first graph database query statement, performing retrieval in a graph database to obtain a retrieval result; and generating reply information of the input information according to the retrieval result.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, in particular to artificial intelligence fields such as large models, deep learning, and natural language processing, and specifically to a knowledge question-answering method, device, electronic device, and storage medium. Background Art

[0002] In the field of artificial intelligence, knowledge question answering aims to enable computer systems to understand and answer questions asked by humans in natural language. With the continuous development of artificial intelligence, knowledge question answering has been applied to intelligent customer service, online consultation and other fields. Summary of the invention

[0003] The present application provides a knowledge question answering method, device, electronic device and storage medium.

[0004] According to one aspect of the present application, a knowledge question answering method is provided, comprising:

[0005] Get input information;

[0006] Obtain a target query sample that matches the input information by querying a sample library; wherein the target query sample includes a target query requirement sample and a target graph database query statement sample corresponding to the target query requirement sample;

[0007] Generate a first graph database query statement using a large model according to the input information and the target query example;

[0008] According to the first graph database query statement, search the graph database to obtain search results;

[0009] Generate reply information for the input information according to the search result.

[0010] According to another aspect of the present application, a knowledge question answering device is provided, comprising:

[0011] A first acquisition module, used to acquire input information;

[0012] A query module, used to obtain a target query sample matching the input information by querying a sample library; wherein the target query sample includes a target query requirement sample and a target graph database query statement sample corresponding to the target query requirement sample;

[0013] A first generating module, configured to generate a first graph database query statement using a large model according to the input information and the target query example;

[0014] A retrieval module, used to search the graph database according to the first graph database query statement to obtain a retrieval result;

[0015] The second generating module is used to generate reply information of the input information according to the search result.

[0016] According to another aspect of the present application, there is provided an electronic device, including:

[0017] at least one processor; and

[0018] a memory communicatively connected to the at least one processor; wherein,

[0019] The memory stores instructions that can be executed by the at least one processor. The instructions are executed by the at least one processor so that the at least one processor can perform the method described in the above embodiment.

[0020] According to another aspect of the present application, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to execute the method according to the above embodiment.

[0021] According to another aspect of the present application, a computer program product is provided, including a computer program, wherein the computer program implements the steps of the method described in the above embodiment when executed by a processor.

[0022] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present application, nor is it intended to limit the scope of the present application. Other features of the present application will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present application.

[0024] Figure 1 A flowchart of a knowledge question answering method provided in one embodiment of the present application;

[0025] Figure 2 A flowchart of a knowledge question answering method provided in another embodiment of the present application;

[0026] Figure 3 A flowchart of a knowledge question answering method provided in another embodiment of the present application;

[0027] Figure 4 A schematic diagram of a knowledge question-answering process provided in an embodiment of the present application;

[0028] Figure 5 A schematic diagram of the structure of a knowledge question-answering device provided in one embodiment of the present application;

[0029] Figure 6It is a block diagram of an electronic device used to implement the knowledge question and answer method of an embodiment of the present application. DETAILED DESCRIPTION

[0030] The following is a description of exemplary embodiments of the present application in conjunction with the accompanying drawings, including various details of the embodiments of the present application to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present application. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description.

[0031] The following describes the knowledge question and answer method, device, electronic device and storage medium of the embodiments of the present application with reference to the accompanying drawings.

[0032] Figure 1 A flowchart of a knowledge question-answering method provided in one embodiment of the present application.

[0033] The knowledge question and answer method of the embodiment of the present application can be executed by the knowledge question and answer device of the embodiment of the present application, and the device can be configured in an electronic device.

[0034] Among them, the electronic device can be any device with computing capabilities, such as a personal computer, a mobile terminal, a server, etc. The mobile terminal can be, for example, a vehicle-mounted device, a mobile phone, a tablet computer, a personal digital assistant, a wearable device, and other hardware devices with various operating systems, touch screens and / or display screens.

[0035] like Figure 1 As shown, the knowledge question answering method includes:

[0036] Step 101, obtaining input information.

[0037] In the present application, information input by the user, that is, the user's input information, can be obtained. The input information can be in text form or in voice form. If it is in voice form, voice recognition can be performed, and subsequent processing can be performed after obtaining the text.

[0038] Step 102: Acquire target query samples matching the input information by querying the sample library.

[0039] In the present application, the sample library may include pairs of query requirement samples and graph database query statement samples, wherein the query requirement samples may be query statements in natural language form.

[0040] Exemplarily, the similarity between the input information and the query requirement samples in the sample library can be calculated, and the target query requirement samples matching the input information can be obtained based on the similarity. Then the query sample including the target query requirement sample and its corresponding target graph database query statement sample is the target query sample matching the input information.

[0041] Exemplarily, one or more query requirement examples with the highest similarity can be used as target query requirement examples matching the input information. It can be seen that the target query requirement example can be one or more, and the target query example can be one or more, and this is not limited.

[0042] Step 103, based on the input information and the target query example, using the big model, generate a first graph database query statement.

[0043] In the present application, prompt information can be constructed based on input information, target query examples, etc., and the prompt information can be input into the big model, so that the big model can use the target query examples as a reference to transform the input information and obtain the first graph database query statement.

[0044] For example, the query language of the graph database is Gremlin, and the target query examples include query requirement examples in natural language and Gremlin query statement examples corresponding to the query requirement examples. The big model can be used to convert the input information into Gremlin query statements with the target query examples as a reference, that is, NL2Gremlin (Natural Language to Gremlin).

[0045] Exemplarily, the large model may be an LLM (Large Language Model), which can handle a variety of natural language tasks, such as text classification, question answering, and dialogue.

[0046] Step 104: search the graph database according to the first graph database query statement to obtain search results.

[0047] In this application, raw data can be collected in advance and preprocessed to obtain source data, so as to complete cleaning, deduplication and other operations through preprocessing to ensure the availability and accuracy of the data. After that, knowledge extraction is performed based on the source data to identify key entities, attributes and the relationships between them. The extracted entities and attribute relationships are then organized into a graph structure to construct a knowledge graph, and the constructed knowledge graph is then imported into the graph database.

[0048] Exemplarily, the first graph database query statement can be executed on the graph database to obtain retrieval results.

[0049] Step 105: Generate reply information for the input information according to the search results.

[0050] Exemplarily, reply information may be generated directly based on the search results.

[0051] Since the search results may contain a lot of content, illustratively, the search results may be filtered according to the user's intention, and then a reply message may be generated based on the filtered content.

[0052] In an embodiment of the present application, a target query sample matching the input information is obtained by querying a sample library, and a graph database query statement corresponding to the input information is generated by utilizing a large model based on the input information and the target query sample. Thus, the large model converts the input information into a graph database query statement based on the target query sample as a reference, thereby improving the accuracy of the generated graph database query statement. Thus, the graph database query statement can be used to search in the graph database, which can not only improve the accuracy of the search results, and thus improve the accuracy of the reply, but also can handle complex queries based on the graph database, and has a wide range of applications.

[0053] Figure 2 A flowchart of a knowledge question and answer method provided in another embodiment of the present application.

[0054] like Figure 2 As shown, the knowledge question answering method includes:

[0055] Step 201, obtaining input information.

[0056] In the present application, step 201 can be implemented in any of the embodiments of the present application, so it will not be described in detail here.

[0057] Step 202: perform intent recognition on the input information to determine the user's intent of the input information.

[0058] Exemplarily, natural language processing technology can be used to perform semantic analysis on the input information to identify the user's intention. Exemplarily, the input information can also be input into an intention recognition model to perform intention recognition and determine the user's intention.

[0059] Optionally, for input information whose user intent is unclear or too broad, multiple rounds of interaction can be conducted with the user through preset dialogue templates or context-based reasoning, gradually guiding the user to clarify his or her needs, thereby completing the user's intent.

[0060] Step 203, rewrite the input information according to the user's intention to obtain the target query requirement.

[0061] Since the user's query requirements in the input information may not be clear, the input information can be rewritten according to the user's intention to obtain the target query requirements, ensuring that the target query requirements can accurately reflect the user's original intention and avoid introducing unnecessary ambiguity or errors.

[0062] For example, the user input information is "I want to go to City A tonight", and the input information is rewritten to obtain the target query demand "Check whether there are any trains to City A".

[0063] Step 204: According to the target query requirement, obtain the target query sample by querying the sample library.

[0064] Exemplarily, the semantic similarity between the target query requirement and the query requirement samples in the sample library can be calculated, and the target query requirement samples matching the input information can be obtained based on the semantic similarity. Then, the query sample including the target query requirement sample and its corresponding target graph database query statement sample is the target query sample matching the input information. Thus, query samples are searched based on semantic matching, which improves the accuracy of query samples.

[0065] Exemplarily, the sample library can be constructed in the following manner: the user's historical query needs and the frequency of use of the historical query needs can be obtained, and the historical query needs can be identified to determine the usage scenarios of the historical query needs; query need samples are determined from the historical query needs based on the frequency of use and the usage scenarios; the query need samples are labeled to obtain graph database query statements; and then a sample library is constructed based on the query need samples and the graph database query statements corresponding to the query need samples.

[0066] Therefore, based on the usage frequency and usage scenarios of historical query requirements, query requirement samples and their corresponding graph database query statements used to build the sample library are screened, thereby improving the quality of query samples in the sample library.

[0067] For example, historical query requirements with a usage frequency exceeding a preset frequency can be used as candidate query requirements, and historical query requirements of different usage scenarios can be selected from the candidate query requirements, and then a sample library can be constructed based on the historical query requirements of each usage scenario. In this way, the sample library contains query samples that cover different usage scenarios and have a high usage frequency, so that the query samples in the sample library can be used as a reference for converting query requirements in different usage scenarios to graph database query statements, and have a wide range of applications.

[0068] Step 205: query the knowledge base according to the user's intention and the target query example to obtain auxiliary knowledge.

[0069] The knowledge in the knowledge base may be knowledge used to assist in converting natural language into graph database query statements.

[0070] In this application, auxiliary knowledge related to the input information can be extracted from the knowledge base in combination with user intent and target query samples. The auxiliary knowledge can include entities, attributes, relationships, etc., which are the basis for the subsequent generation of graph database query statements. The auxiliary knowledge can be used to supplement the input information.

[0071] For example, the user inputs the information "Who is the boss of company a?" and the auxiliary knowledge retrieved is "The boss refers to the legal person."

[0072] Step 206, based on the target query requirements, target query examples and auxiliary knowledge, using the big model, generate a first graph database query statement.

[0073] In the present application, the prompt template used to guide the big model to generate a graph database query statement can be filled in according to input information, target query requirements, target query examples, auxiliary knowledge, etc., to obtain corresponding prompt information, and the prompt information is input into the big model. The big model converts the input information into a first graph database query statement according to the target query requirements and auxiliary knowledge and with reference to the target query examples.

[0074] Step 207: search the graph database according to the first graph database query statement to obtain search results.

[0075] In the present application, step 207 can be implemented in any of the embodiments of the present application, so it will not be described in detail here.

[0076] Since the first graph database query statement may contain syntax errors or logic errors or may not conform to the graph database structure, based on this, the first graph database query statement can optionally be error identified. If the first graph database query statement contains an error, the first graph database query statement can be corrected according to the error type of the first graph database query statement to obtain a second graph database query statement, and then a search is performed in the graph database based on the second graph database query statement to obtain a search result.

[0077] Exemplarily, a large model can be used to perform error identification on the first graph database query statement based on graph database query language specifications, typical logical problems, graph database structural features, etc., to determine whether there is an error in the first graph database query statement; if there is an error, determine the error type and error location of the first graph database query statement.

[0078] Exemplarily, the large model can be used to correct the first graph database query statement according to the error type of the first graph database query statement to obtain the second graph database query statement. Exemplarily, the second graph database query statement can also continue to identify errors until the corrected graph database query statement is correct and then used for graph database retrieval to obtain retrieval results.

[0079] Therefore, by performing error identification on the graph database query statement generated by the large model, if there is an error, the graph database query statement is corrected, and the corrected graph database query statement is used for retrieval, the accuracy of the retrieval results is improved, and then the accuracy of the reply is improved.

[0080] Step 208: Generate reply information for the input information based on the search results.

[0081] In the present application, step 208 can be implemented in any of the embodiments of the present application, so it will not be described in detail here.

[0082] In an embodiment of the present application, the intent of the input information is identified to determine the user intent, and the input information is rewritten according to the user intent to obtain a target query requirement. According to the target query requirement, a target query sample is obtained by querying a sample library, thereby improving the accuracy of the target query sample. Further, according to the user intent and the target query sample, a query is performed in the knowledge base to obtain auxiliary knowledge. Thus, the large model converts the input information according to the target query requirement, with reference to the target query sample and in combination with the auxiliary knowledge, to generate a graph database query statement, thereby improving the accuracy of the graph database query statement.

[0083] Figure 3 A flowchart of a knowledge question and answer method provided in another embodiment of the present application.

[0084] like Figure 3 As shown, the knowledge question answering method includes:

[0085] Step 301, obtaining input information.

[0086] Step 302: Obtain target query samples that match the input information by querying the sample library.

[0087] Step 303, based on the input information and the target query example, using the big model, generate a first graph database query statement.

[0088] Step 304: search the graph database according to the first graph database query statement to obtain search results.

[0089] In the present application, steps 301 to 304 may be implemented in any of the embodiments of the present application, and therefore will not be described in detail herein.

[0090] Step 305: Determine whether the content to be queried satisfies the chart generation condition according to the input information.

[0091] In the present application, the input information may be subjected to intent recognition to determine the user's intent, and based on the user's intent, it may be determined whether the content to be queried satisfies the conditions for generating a chart.

[0092] For example, if the input information is "What was the daily sales volume of product p in the past week?", the user's intention is to view the daily sales volume of product p in the past week, including two parameters: time and sales volume. This user intention meets the conditions for generating a chart.

[0093] Step 306 , in response to satisfying the chart generation condition, determining a target chart type from various chart types according to the input information and the search result.

[0094] In order to meet different display requirements, icon types may include line charts, pie charts, bar charts, relationship charts, etc. Exemplarily, the input information may be subjected to intent recognition to determine the user's intent, and based on the user's intent, the data characteristics of the search results, etc., combined with the application scenarios of each chart type, determine which chart type to use to intuitively display the query results from each chart type, that is, determine the target chart type from each chart type.

[0095] For example, if the search results are not the data that the user directly wants, a computational analysis can be performed based on the input information and the search results to obtain the analysis results, and the result data required by the user can be generated based on the analysis results, and the target chart type can be determined based on the user's intention and the characteristics of the result data. The computational analysis can include but is not limited to data aggregation, statistical analysis, relational reasoning, etc.

[0096] Step 307: Generate a chart of the target chart type according to the search results.

[0097] Exemplarily, if the search results can satisfy the user's query requirements, that is, the search results are the data that the user wants, a corresponding chart can be directly generated based on the search results according to the definition of the target chart type.

[0098] Exemplarily, if the search result is not the data that the user directly wants, then the result data obtained by performing calculation analysis based on the search result can be combined with the definition of the target chart type to generate a chart of the target chart type.

[0099] Optionally, the generated chart can be optimized and adjusted, such as adjusting the color, font size, etc., so as to improve the readability and aesthetics of the chart.

[0100] Step 308, generating reply information according to the input information and the chart.

[0101] In the present application, the input information and the chart etc. may be combined to generate the reply information. For example, a text description of the chart may be generated, and the input information, the chart and the text description may be combined to generate the reply information.

[0102] In order to improve the quality of the reply, optionally, the input information and the chart can be fused to obtain a fusion result, and the reply features can be determined based on the input information and the context information of the input information. The fusion result can then be adjusted based on the reply features to obtain the reply information.

[0103] For example, reply features may include the tone, style, structure, etc. of the reply. Tone is the embodiment of the emotional color and attitude in the reply, which can convey different emotional atmospheres such as friendliness, seriousness, humor, etc. Style is the overall characteristics and expression of the reply, such as formal, informal, professional, casual, etc. Structure is the organizational form and logical relationship of the reply, such as the arrangement of the beginning, middle, and end.

[0104] Exemplarily, the tone, style and other contextual information of the input information may be determined based on the input information and the contextual information of the input information to determine the reply features.

[0105] Exemplarily, a large model may be used to determine response features based on input information and contextual information of the input information, and the fusion result may be adjusted based on the response features to obtain response information.

[0106] Therefore, the reply features can be determined based on the input information and its contextual information, and the fusion results can be optimized based on the reply features to generate more natural replies that are closer to user expectations, thereby improving the quality of the reply.

[0107] In an embodiment of the present application, it is determined whether the content to be queried satisfies the chart generation conditions based on the input information. If the chart generation conditions are met, a suitable chart type is selected based on the input information and the search results, and a corresponding chart is generated based on the search results. Then, based on the input information and the chart, a final reply information is generated. The reply information can intuitively display the graph database search results through charts, thereby improving the reply quality.

[0108] In order to facilitate understanding of the knowledge question answering method of the embodiment of the present application, the following takes Gremlin as an example. Figure 4 Provide explanation. Figure 4 A schematic diagram of a knowledge question and answer process provided in an embodiment of the present application.

[0109] like Figure 4 As shown in the figure, the process of knowledge question answering includes three parts: building the NL2Gremlin sample library, knowledge question answering, and building a graph database.

[0110] Among them, building the NL2Gremlin sample library includes sample annotation, data enhancement and sample storage.

[0111] Sample annotation: The user's historical input information can be analyzed to determine which query requirements have a usage frequency exceeding the preset threshold and can cover different usage scenarios as query requirement samples, and the corresponding Gremlin query statements can be written for the query requirement samples for annotation.

[0112] Data enhancement: Data enhancement methods can be used to expand samples, increase the number of samples, and improve sample coverage.

[0113] Sample storage: You can query the required samples for vectorization and store them in the vector database. You can create a suitable table structure in the database, specify the parameter name and type, store sample information, and facilitate retrieval and use of samples.

[0114] Among them, building a graph database includes data collection, knowledge extraction, and knowledge storage.

[0115] Data collection: You can collect raw data through public Internet data, cooperative data, co-constructed data, etc., pre-process the raw data, complete cleaning, deduplication and other operations to ensure the availability and accuracy of the data, and store the processed source data in the data warehouse.

[0116] Knowledge extraction: Extract knowledge based on source data, identify key entities, attributes and their relationships, organize the extracted entities and attribute relationships into a graph structure, and build a knowledge graph.

[0117] Knowledge storage: Choose HugeGraph, which can support the storage and query of large-scale graph data, import the constructed knowledge graph into the graph database for further optimization and indexing to support efficient query and analysis.

[0118] The knowledge question and answer section is as follows:

[0119] Intent recognition: Natural language processing technology can be used to perform semantic analysis on user input queries to identify the user's main intent, including understanding the topic, scope, and possible specific questions that the user wants to query. For queries with unclear or overly broad intent, multiple rounds of interaction with the user can be conducted through preset dialogue templates or context-based reasoning to gradually guide the user to clarify their needs and thus complete the user's intent.

[0120] Input information rewriting: After identifying the user's intent, the original query entered by the user can be rewritten to obtain the rewritten query, which is the above-mentioned target query requirement. In addition, during the rewriting process, it can be ensured that the rewritten query can accurately reflect the user's original intent while avoiding the introduction of unnecessary ambiguity or errors.

[0121] Sample search: After receiving the rewritten query, the semantic matching algorithm can be used to find the sample that is closest to the current query semantics from the sample library.

[0122] Knowledge generation: Based on user intent and the examples found, knowledge items related to the query are extracted from the knowledge base. These knowledge items may include entities, attributes, relationships, etc. The extracted knowledge is integrated and organized to form a structured knowledge representation.

[0123] NL2Gremlin: Fill the rewritten query, found examples, and generated knowledge into the prompt template, and then call the big model to generate Gremlin query statements.

[0124] Reflection and error correction: Since the generated Gremlin query statements may contain syntax errors, logical errors, or problems that do not conform to the database structure, the self-assessment capabilities of the big model can be used to reflect on and identify errors in the generated query statements, and automatically repair the identified errors based on common error types, database structure characteristics, etc. Repairs can include correcting syntax errors, adjusting query logic, and optimizing query performance.

[0125] Knowledge retrieval: Use the generated Gremlin query statements to search the graph database and obtain knowledge items related to the query, which may include entity information, relationship networks, attribute descriptions, etc. In addition, the retrieved knowledge can be filtered and sorted to select the knowledge items that best meet user needs based on user intent and query requirements.

[0126] Data analysis: Based on the user's original query and the retrieved knowledge, necessary calculations and analyses are performed, such as data aggregation, statistical analysis, relational reasoning, etc., and then the specific data and information required by the user are generated based on the results of the calculations and analyses. These data and information may be presented in the form of numerical values, text, charts, etc.

[0127] Chart generation: Based on the user's original query and result data, you can select the appropriate chart type to draw. This includes bar charts, line charts, pie charts, relationship charts, etc., to intuitively display query results and data relationships. In addition, you can also optimize and adjust the generated charts, such as adjusting colors, fonts, labels, etc., to improve the readability and aesthetics of the charts.

[0128] Reply generation: The result data, charts, and the user's original query can be combined to integrate and format the content, including embedding the result data into charts, combining charts with text descriptions, etc. In addition, the big model can be called to optimize and generate the integrated content. For example, the big model automatically adjusts the tone, style, and structure of the reply based on the contextual information of the query entered by the user to generate a final reply that meets the user's expectations.

[0129] The knowledge question-and-answer method of the embodiment of the present application generates reply information based on graph data and large models, can process complex query logic, provide real-time data analysis and decision support, and maintain high interpretability and domain adaptability.

[0130] In order to implement the above embodiment, the embodiment of the present application also proposes a knowledge question and answer device. Figure 5 A schematic diagram of the structure of a knowledge question and answer device provided in one embodiment of the present application.

[0131] like Figure 5 As shown, the knowledge question answering device 500 includes:

[0132] A first acquisition module 510, used to acquire input information;

[0133] The query module 520 is used to obtain a target query example matching the input information by querying a sample library; wherein the target query example includes a target query requirement example and a target graph database query statement example corresponding to the target query requirement example;

[0134] A first generating module 530 is used to generate a first graph database query statement using a large model according to the input information and the target query example;

[0135] A retrieval module 540 is used to search the graph database according to the first graph database query statement to obtain a retrieval result;

[0136] The second generating module 550 is used to generate reply information of the input information according to the search result.

[0137] Optionally, the query module 520 is used to:

[0138] Performing intent recognition on the input information to determine the user intent of the input information;

[0139] According to the user's intention, the input information is rewritten to obtain a target query requirement;

[0140] According to the target query requirement, the target query sample is obtained by querying the sample library.

[0141] Optionally, the first generating module 530 is used to:

[0142] According to the user intention and the target query example, query the knowledge base to obtain auxiliary knowledge;

[0143] According to the target query requirements, the target query examples and the auxiliary knowledge, the first graph database query statement is generated using the big model.

[0144] Optionally, the query module 520 is used to:

[0145] Semantically matching the target query requirement with each query requirement sample in the sample library;

[0146] The query sample with the highest semantic matching degree in the query sample library and the graph database query statement corresponding to the query sample with the highest semantic matching degree are determined as the target sample.

[0147] Optionally, the second generating module 550 is used to:

[0148] Determine whether the content to be queried satisfies the chart generation condition according to the input information;

[0149] In response to satisfying a chart generation condition, determining a target chart type from among various chart types according to the input information and the search result;

[0150] generating a chart of the target chart type according to the search results;

[0151] The reply information is generated according to the input information and the chart.

[0152] Optionally, the second generating module 550 is used to:

[0153] Fusing the input information and the graph to obtain a fusion result;

[0154] determining a response feature according to the input information and context information of the input information;

[0155] The fusion result is adjusted according to the reply feature to obtain the reply information.

[0156] Optionally, the retrieval module 540 is used to:

[0157] Performing error identification on the first graph database query statement;

[0158] In response to an error in the first graph database query statement, correcting the first graph database query statement according to an error type of the first graph database query statement to obtain a second graph database query statement;

[0159] According to the second graph database query statement, a search is performed in the graph database to obtain the search result.

[0160] Optionally, the device further comprises:

[0161] A second acquisition module is used to acquire historical query requirements and usage frequencies of the historical query requirements;

[0162] An identification module, used to identify the historical query demand to determine the usage scenario of the historical query demand;

[0163] A determination module, configured to determine a query requirement sample from the historical query requirements according to the usage frequency and the usage scenario;

[0164] A construction module is used to construct the sample library according to the query requirement sample and the graph database query statement corresponding to the query requirement sample.

[0165] It should be noted that the explanation of the aforementioned knowledge question and answer method embodiment is also applicable to the knowledge question and answer device of this embodiment, so it will not be repeated here.

[0166] In an embodiment of the present application, a target query sample matching the input information is obtained by querying a sample library, and a graph database query statement corresponding to the input information is generated by utilizing a large model based on the input information and the target query sample. Thus, the large model converts the input information into a graph database query statement based on the target query sample as a reference, thereby improving the accuracy of the generated graph database query statement. Thus, the graph database query statement can be used to search in the graph database, which can not only improve the accuracy of the search results, and thus improve the accuracy of the reply, but also can handle complex queries based on the graph database, and has a wide range of applications.

[0167] According to an embodiment of the present application, the present application also provides an electronic device, a readable storage medium and a computer program product.

[0168] Figure 6 A schematic block diagram of an example electronic device 600 that can be used to implement an embodiment of the present application is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workbenches, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present application described and / or required herein.

[0169] like Figure 6 As shown, the device 600 includes a computing unit 601, which can perform various appropriate actions and processes according to a computer program stored in a ROM (Read-Only Memory) 602 or a computer program loaded from a storage unit 608 to a RAM (Random Access Memory) 603. In the RAM 603, various programs and data required for the operation of the device 600 can also be stored. The computing unit 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An I / O (Input / Output) interface 605 is also connected to the bus 604.

[0170] A number of components in the device 600 are connected to the I / O interface 605, including: an input unit 606, such as a keyboard, a mouse, etc.; an output unit 607, such as various types of displays, speakers, etc.; a storage unit 608, such as a disk, an optical disk, etc.; and a communication unit 609, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 609 allows the device 600 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0171] The computing unit 601 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 601 include, but are not limited to, a CPU (Central Processing Unit), a GPU (Graphic Processing Units), various dedicated AI (Artificial Intelligence) computing chips, various computing units running machine learning model algorithms, DSP (Digital Signal Processor), and any appropriate processor, controller, microcontroller, etc. The computing unit 601 performs the various methods and processes described above, such as the knowledge question and answer method. For example, in some embodiments, the knowledge question and answer method may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 608. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 600 via the ROM 602 and / or the communication unit 609. When the computer program is loaded into the RAM 603 and executed by the computing unit 601, one or more steps of the knowledge question and answer method described above may be executed. Alternatively, in other embodiments, the computing unit 601 may be configured to perform the knowledge question answering method in any other appropriate manner (eg, by means of firmware).

[0172] Various embodiments of the systems and techniques described above herein may be implemented in digital electronic circuit systems, integrated circuit systems, FPGAs (Field Programmable Gate Arrays), ASICs (Application-Specific Integrated Circuits), ASSPs (Application Specific Standard Products), SOCs (System On Chips), CPLDs (Complex Programmable Logic Devices), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include: being implemented in one or more computer programs that may be executed and / or interpreted on a programmable system including at least one programmable processor that may be a dedicated or general-purpose programmable processor that may receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0173] The program code for implementing the method of the present application can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, implements the functions / operations specified in the flow chart and / or block diagram. The program code can be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0174] In the context of the present application, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or any suitable combination of the foregoing. More specific examples of machine-readable storage media may include electrical connections based on one or more lines, portable computer disks, hard disks, RAM, ROM, EPROM (Electrically Programmable Read-Only-Memory) or flash memory, optical fiber, CD-ROM (Compact Disc Read-Only Memory), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0175] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (Cathode-Ray Tube) or LCD (Liquid Crystal Display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0176] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: LAN (Local Area Network), WAN (Wide Area Network), the Internet, and blockchain networks.

[0177] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship between the client and the server is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or a cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services (Virtual Private Server). The server may also be a server of a distributed system, or a server combined with a blockchain.

[0178] According to an embodiment of the present application, the present application also provides a computer program product, which, when an instruction processor in the computer program product is executed, executes the knowledge question and answer method proposed in the above embodiment of the present application.

[0179] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this application can be executed in parallel, sequentially or in different orders, as long as the expected results of the technical solution disclosed in this application can be achieved, and this document is not limited here.

[0180] The above specific implementations do not constitute a limitation on the protection scope of this application. It should be understood by those skilled in the art 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 application should be included in the protection scope of this application.

Claims

1. A knowledge question answering method, comprising: Get input information; Obtain a target query sample that matches the input information by querying a sample library; wherein the target query sample includes a target query requirement sample and a target graph database query statement sample corresponding to the target query requirement sample; Generate a first graph database query statement using a large model according to the input information and the target query example; According to the first graph database query statement, search the graph database to obtain search results; Generate reply information for the input information according to the search result.

2. The method of claim 1, wherein: The step of obtaining a target query sample matching the input information by querying a sample library includes: Performing intent recognition on the input information to determine the user intent of the input information; According to the user's intention, the input information is rewritten to obtain a target query requirement; According to the target query requirement, the target query sample is obtained by querying the sample library.

3. The method of claim 2, wherein: The step of generating a first graph database query statement based on the input information and the target query example using a large model includes: According to the user intention and the target query example, query the knowledge base to obtain auxiliary knowledge; According to the target query requirements, the target query examples and the auxiliary knowledge, the first graph database query statement is generated using the big model.

4. The method of claim 2, wherein: The step of obtaining the target query sample by querying the sample library according to the target query requirement includes: Semantically matching the target query requirement with each query requirement sample in the sample library; The query sample with the highest semantic matching degree in the query sample library and the graph database query statement corresponding to the query sample with the highest semantic matching degree are determined as the target sample.

5. The method of claim 1, wherein: Generating reply information of the input information according to the search result includes: Determine whether the content to be queried satisfies the chart generation condition according to the input information; In response to satisfying a chart generation condition, determining a target chart type from among various chart types according to the input information and the search result; generating a chart of the target chart type according to the search results; The reply information is generated according to the input information and the chart.

6. The method of claim 5, wherein: The step of generating the reply information according to the input information and the chart includes: Fusing the input information and the chart to obtain a fusion result; determining a response feature according to the input information and context information of the input information; The fusion result is adjusted according to the reply feature to obtain the reply information.

7. The method of claim 1, wherein: The searching in the graph database according to the first graph database query statement to obtain the search results includes: Performing error identification on the first graph database query statement; In response to an error in the first graph database query statement, correcting the first graph database query statement according to an error type of the first graph database query statement to obtain a second graph database query statement; According to the second graph database query statement, a search is performed in the graph database to obtain the search result.

8. The method according to any one of claims 1 to 7, further comprising: Obtaining historical query demands and usage frequencies of the historical query demands; Identify the historical query demand to determine the usage scenario of the historical query demand; Determining query demand samples from the historical query demands according to the usage frequency and the usage scenario; The sample library is constructed according to the query requirement sample and the graph database query statement corresponding to the query requirement sample.

9. A knowledge question-answering device, comprising: A first acquisition module, used to acquire input information; A query module, used to obtain a target query sample matching the input information by querying a sample library; wherein the target query sample includes a target query requirement sample and a target graph database query statement sample corresponding to the target query requirement sample; A first generating module, configured to generate a first graph database query statement using a large model according to the input information and the target query example; A retrieval module, used to search the graph database according to the first graph database query statement to obtain a retrieval result; The second generating module is used to generate reply information of the input information according to the search result.

10. The device of claim 9, wherein: The query module is used to: Performing intent recognition on the input information to determine the user intent of the input information; According to the user's intention, the input information is rewritten to obtain a target query requirement; According to the target query requirement, the target query sample is obtained by querying the sample library.

11. The device of claim 10, wherein: The first generating module is used for: According to the user intention and the target query example, query the knowledge base to obtain auxiliary knowledge; According to the target query requirements, the target query examples and the auxiliary knowledge, the first graph database query statement is generated using the big model.

12. The device of claim 10, wherein: The query module is used to: Semantically matching the target query requirement with each query requirement sample in the sample library; The query sample with the highest semantic matching degree in the query sample library and the graph database query statement corresponding to the query sample with the highest semantic matching degree are determined as the target sample.

13. The device of claim 9, wherein: The second generating module is used for: Determine whether the content to be queried satisfies the chart generation condition according to the input information; In response to satisfying a chart generation condition, determining a target chart type from among various chart types according to the input information and the search result; generating a chart of the target chart type according to the search results; The reply information is generated according to the input information and the chart.

14. The device of claim 13, wherein: The second generating module is used for: Fusing the input information and the graph to obtain a fusion result; determining a response feature according to the input information and context information of the input information; The fusion result is adjusted according to the reply feature to obtain the reply information.

15. The device of claim 9, wherein: The retrieval module is used to: Performing error identification on the first graph database query statement; In response to an error in the first graph database query statement, correcting the first graph database query statement according to an error type of the first graph database query statement to obtain a second graph database query statement; According to the second graph database query statement, a search is performed in the graph database to obtain the search result.

16. The apparatus according to any one of claims 9 to 15, further comprising: A second acquisition module is used to acquire historical query requirements and usage frequencies of the historical query requirements; An identification module, used to identify the historical query demand to determine the usage scenario of the historical query demand; A determination module, configured to determine a query requirement sample from the historical query requirements according to the usage frequency and the usage scenario; A construction module is used to construct the sample library according to the query requirement sample and the graph database query statement corresponding to the query requirement sample.

17. An electronic device comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 8.

18. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1-8.

19. A computer program product, comprising a computer program, which, when executed by a processor, implements the steps of the method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Data set construction method and device, electronic equipment and storage medium

    CN116070114A

  • Implementation method for automatically generating complex graph database query statement service

    CN116340584A

  • Human-computer interaction method, device and equipment and storage medium

    CN116610775A

  • Graph query method and system based on local knowledge base and natural language large model

    CN117009492A

  • Data query method and device, storage medium and electronic equipment

    CN117033744A

Cited By

  • Method and device for converting natural language query into GQL statement

    CN121833767A