Information query method and device based on knowledge graph, equipment and storage medium
By constructing target entity vectors and query patterns, answers can be directly retrieved from the knowledge graph, solving the problem of high corpus dependence in existing technologies and achieving highly accurate information retrieval.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA UNICOM SMART CONNECTION TECH LTD
- Filing Date
- 2023-06-30
- Publication Date
- 2026-06-05
AI Technical Summary
Existing knowledge graph-based information query models require extensive corpora for training, resulting in low prediction performance and low accuracy of query results.
By constructing the target entity vector of the text to be queried, determining the target query pattern, and obtaining graph feature items, the entity words are associated with the corresponding graph feature items using the target query pattern to generate a graph query statement, and the answer can be directly queried in the knowledge graph.
It can improve the accuracy of query results without relying on a large amount of corpus data, and ensure the accuracy of feature association, thereby improving the accuracy of query results.
Smart Images

Figure CN116842246B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence technology, and in particular to an information query method, apparatus, device, and storage medium based on knowledge graphs. Background Technology
[0002] With the continuous development of internet applications, the technology of using knowledge graphs for information retrieval has received increasing attention. One related technology involves using a pre-trained model to directly output the corresponding knowledge graph query for a natural language question, and then using the knowledge graph query to locate the relevant answer within the knowledge graph. However, such models require a large amount of data to train, and their predictive performance is not high, resulting in low accuracy of the query results. Summary of the Invention
[0003] To overcome the technical problems existing in related technologies, this application provides an information query method, apparatus, device and storage medium based on knowledge graph.
[0004] In a first aspect, embodiments of this application provide an information query method based on a knowledge graph, including:
[0005] Based on the entity words in the text to be queried and the entity types corresponding to the entity words, construct the target entity vector of the text to be queried;
[0006] Determine the target query pattern corresponding to the target entity vector, and obtain the graph feature items corresponding to the target query pattern; wherein, the target query pattern is used to indicate the query process of the text to be queried in the knowledge graph;
[0007] The entity words are associated with the corresponding graph feature terms using the target query pattern;
[0008] Generate corresponding graph query statements based on the target query pattern and graph feature items associated with entity words;
[0009] The knowledge graph is queried according to the graph query statement to obtain the corresponding first query result.
[0010] Secondly, embodiments of this application provide an information query device based on a knowledge graph, including:
[0011] The construction module is used to construct the target entity vector of the text to be queried based on the entity words in the text to be queried and the entity types corresponding to the entity words;
[0012] The determination module is used to determine the target query pattern corresponding to the target entity vector and obtain the graph feature items corresponding to the target query pattern; wherein, the target query pattern is used to indicate the query process of the text to be queried in the knowledge graph;
[0013] The association module is used to associate the entity words with the corresponding graph feature items using the target query pattern;
[0014] The generation module is used to generate corresponding graph query statements based on the target query pattern and graph feature items associated with entity words;
[0015] The query module is used to query the knowledge graph according to the graph query statement and obtain the corresponding first query result.
[0016] Thirdly, embodiments of this application provide an electronic device, including: a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the knowledge graph-based information query method provided in the first aspect of embodiments of this application.
[0017] Fourthly, embodiments of this application provide a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the knowledge graph-based information query method provided in the first aspect of embodiments of this application.
[0018] The technical solution provided in this application, after obtaining the target entity vector of the text to be queried, determines the target query pattern corresponding to the target entity vector and obtains the graph feature items corresponding to the target query pattern. It then uses the target query pattern to associate entity words with the corresponding graph feature items, generates a corresponding graph query statement based on the target query pattern and the graph feature items associated with entity words, and queries the knowledge graph based on the graph query statement to obtain the corresponding first query result. In other words, this solution can locate the answer corresponding to the text to be queried without relying on a large amount of corpus data. Furthermore, by using the target query pattern to assist in associating entity words in the text to be queried with the graph feature items required for graph querying, it ensures the accuracy of feature association, thereby improving the accuracy of the generated graph query statement and ultimately increasing the accuracy of the query results. Attached Figure Description
[0019] Figure 1 A flowchart illustrating a knowledge graph-based information query method provided in an embodiment of this application;
[0020] Figure 2 Another flowchart illustrating the knowledge graph-based information query method provided in this application embodiment;
[0021] Figure 3 A schematic diagram of a knowledge graph-based information query device provided in an embodiment of this application;
[0022] Figure 4This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0023] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions in this application will be further described in detail through the following embodiments and accompanying drawings. It should be understood that the specific embodiments described herein are only for explaining this application and are not intended to limit this application.
[0024] In existing information query scenarios, to ensure users can accurately obtain the information they want, a pre-trained model is typically used to directly output the graph query statement corresponding to the user's natural language question, and then the graph query statement is used to locate the corresponding answer in the knowledge graph. However, the above model requires a large amount of corpus data to train, resulting in excessive dependence on corpus data and poor predictive performance, thus leading to low accuracy of query results. Therefore, the technical solution provided in this application can improve the accuracy of information query results.
[0025] It should be noted that the execution subject of the following method embodiments can be an information query device based on a knowledge graph. This device can be implemented as part or all of an electronic device through software, hardware, or a combination of software and hardware. Optionally, the electronic device can be a client, including but not limited to smartphones, tablets, e-book readers, and in-vehicle terminals. Of course, the electronic device can also be an independent server or a server cluster. The embodiments of the present invention do not limit the specific form of the electronic device. The following method embodiments are described using an electronic device as an example.
[0026] Figure 1 This is a flowchart illustrating a knowledge graph-based information query method provided in an embodiment of this application. Figure 1 As shown, the method may include:
[0027] S101. Construct the target entity vector of the text to be queried based on the entity words in the text to be queried and the entity types corresponding to the entity words.
[0028] The text to be queried refers to the text for which the answer needs to be located, which is natural language text.
[0029] Specifically, the Jieba tokenization tool and a custom dictionary can be used to tokenize the text to be queried and extract the word types; then, dependency syntactic analysis is used to extract the keywords and keyword types in the text to be queried; further, the tokenization results, word type results, and keyword recognition results are input into a pre-trained entity recognition model, and the entity words and the corresponding entity types in the text to be queried are determined through this entity recognition model. Among them, the above entity recognition model can include an embedding layer, a BERT layer, and a fully connected layer. Further, a custom dictionary can also be used to convert some colloquial entity words identified into standardized entity words, such as standardizing "several seats" to "number of seats".
[0030] After obtaining the entity words and the corresponding entity types in the text to be queried, the entity words and the corresponding entity types are respectively merged to obtain entity word vectors and entity type vectors, and the entity word vectors and entity type vectors are combined to obtain the target entity vector of the text to be queried.
[0031] Exemplarily, in the field of vehicle information query, assuming the text to be queried is "What are the seat numbers of the Lingrui models?", the entity words and the corresponding entity types in this text to be queried are recognized, and recognition results such as "vehicle series - Lingrui", "attribute - number of seats", etc. are obtained, and a target entity vector of the text to be queried is constructed based on this recognition result, and the obtained target entity vector is [[vehicle series, attribute], [Lingrui, number of seats]].
[0032] S102. Determine the target query pattern corresponding to the target entity vector, and obtain the graph feature items corresponding to the target query pattern.
[0033] The target query pattern is used to indicate the query process of the text to be queried in the knowledge graph. The knowledge graph includes a large amount of point knowledge and edge knowledge. A target query pattern can consist of input nodes, output nodes, and query content. The input node is the target node to be queried in the knowledge graph, the output is the implicit output node, and the query content is the actual output node. That is, the format of the target query pattern can be input node_output node(query content). For example, when the target query pattern is "keyword_vehicle(attrs)", the query process indicated by this pattern is "first query the vehicle model by keyword, then query the attributes based on the vehicle model". Another example is "compare_keyword_vehicle(attrs)", which indicates the query process "first determine the vehicle model by keyword, then compare the attributes of multiple vehicle models (such as fuel consumption)". Yet another example is "condition_series(attrs)", which indicates the query process "query the attributes of all vehicles under a certain condition".
[0034] The above-mentioned graph features are the features required when using graph query statements. Different target query patterns correspond to different graph features. For example, when the target query pattern is "keyword_vehicle(attrs)", the graph features corresponding to this target query pattern include keyword features, vehicle type features, and attribute features, etc.
[0035] As an optional implementation, the process of determining the target query pattern corresponding to the target entity vector may be as follows: obtaining a pre-constructed mapping table; wherein the mapping table includes reference entity vectors of multiple historical query texts and query patterns corresponding to each reference entity vector; determining a first matching degree between the target entity vector and multiple reference entity vectors; and determining the query pattern corresponding to the reference entity vector whose first matching degree satisfies a first preset condition as the target query pattern.
[0036] Specifically, the reference entity vectors for historical query texts are constructed based on the entity words and their corresponding entity types within the historical query texts. Furthermore, query patterns and graph feature terms corresponding to each reference entity vector are predefined, and a corresponding mapping table is built. Taking automotive information queries as an example, the mapping table can be as shown in Table 1 below:
[0037] Table 1
[0038]
[0039]
[0040] After obtaining the target entity vector of the text to be queried, the similarity between the target entity vector and each reference entity vector in the mapping table is calculated to obtain the first matching degree between the target entity vector and each reference entity vector. The query pattern corresponding to the reference entity vector whose first matching degree satisfies a first preset condition is determined as the target query pattern. For example, the query pattern corresponding to the reference entity vector with the highest first matching degree can be determined as the target query pattern of the text to be queried. After determining the target query pattern, the graph feature item corresponding to the target query pattern can be obtained from the above mapping table.
[0041] For example, continuing with the car information query, assuming the target entity vector of the text to be queried is "vehicle-seat", then the target query pattern corresponding to the target entity vector is determined to be "keyword_vehicle(attrs)" through the above mapping table, and the graph features required when querying using this target query pattern are "vertex" (i.e., point feature), "vertex" (i.e. attribute feature), and "manufacturer" (i.e. manufacturer feature) through the above mapping table.
[0042] S103. Use the target query pattern to associate the entity words with the corresponding graph feature items.
[0043] In this step, the feature association methods mainly include pre-filled slots, slot filling using the target query pattern, and post-filled slots.
[0044] Among them, the pre-filled slot refers to the filling with fixed but not fixed features, such as brand, manufacturer, etc.
[0045] Slot filling using target query patterns refers to determining the required feature values in the graph feature items by parsing the target query patterns, that is, using the target query patterns to associate entity words in the query text with the corresponding graph feature items.
[0046] Post-filling mainly refers to checking the results after filling in slots to determine the accuracy of feature association.
[0047] For example, taking the query text "How many seats does the Lingrui have?" as an example, the target entity vector of the query text is "[[vehicle series, attribute], [Lingrui, number of seats]]". By looking up the table, we can find that the target query pattern corresponding to this target entity vector is "keyword_vehicle(attrs)", and the required graph feature item for the query is "{"vertex":[],"attrs":[],"manufacturer":[]}". Since the keyword in the target query pattern corresponds to the graph feature item "vertex", we can associate the entity word "Lingrui" under the entity type "keyword" in the query text with the graph feature item "vertex", and associate "number of seats" under the entity type "attribute" in the query text with the graph feature item "attrs". For the graph feature item "manufacturer", the corresponding feature value can be filled in using a pre-filled slot method, such as "Jiangling Ford".
[0048] S104. Generate a corresponding graph query statement based on the target query pattern and the graph feature items associated with entity words.
[0049] The knowledge graph stores point knowledge and edge knowledge, supporting various query methods such as querying points, querying points based on attributes, subgraph queries, and pipeline queries. Different query methods correspond to different graph query statements. Therefore, corresponding graph query statements can be generated based on the determined target query pattern and graph feature terms associated with entity words.
[0050] As an optional implementation, the above S104 process can be: obtaining the graph statement to be filled corresponding to the target query pattern; filling the entity words associated with the target query pattern and graph feature items into the corresponding positions in the graph statement to be filled, thereby obtaining the graph query statement.
[0051] Different query patterns correspond to different graph statements to be filled. After obtaining the target query pattern, the corresponding graph statement to be filled can be obtained based on the target query pattern. Next, the target query pattern is used as an edge knowledge label to fill the corresponding position in the graph statement to be filled, and the entity words associated with the graph feature items are used as point knowledge indexes and the attributes corresponding to the point knowledge to fill the corresponding positions in the graph statement to be filled, thus obtaining the graph query statement.
[0052] For example, the target query pattern "keyword_vehicle(attrs)" indicates querying the attributes of vehicle models based on keywords. This is a query method for querying attributes according to points, and the corresponding graph statement to be filled is "GO FROM〈vertex〉OVER〈keyword_vehilcle〉YIELD$$.〈vehicle.attr〉as attr". Among them, the 〈〉 in the graph statement to be filled are the graph feature information that needs to be filled; then, the entity words associated with the graph feature items and the target query pattern are filled into the corresponding positions in the graph statement to be filled, and the obtained graph query statement is "GO FROM Lingrui OVER keyword_vehilcle YIELD$$.Number of seats as attr".
[0053] S105. Query the knowledge graph according to the graph query statement to obtain a corresponding first query result.
[0054] After obtaining the graph query statement, the exacute function can be used to execute the graph query statement, so as to query and obtain the corresponding first query result in the knowledge graph.
[0055] Optionally, before the above S101, the above knowledge graph can be constructed in advance using the knowledge in the relevant technical field. Specifically, the knowledge in the relevant technical field can be formatted into point knowledge and edge knowledge, and the corresponding knowledge graph can be constructed based on the point knowledge and edge knowledge. For example, for information query in the automotive field, relevant knowledge about automotive products can be obtained, such as common vehicle fault acceptance and guidance, common vehicle use problems, three-pack related problems, maintenance-related problems, vehicle identification numbers,随车工具及购车活动类知识等 (the description here seems to be incomplete in the original Chinese, but I'll translate as is), format the relevant knowledge about automotive products into point knowledge (such as "brand_name":"Ford") and edge knowledge (such as {"head":"Lingjie","edge":"series_brand","tail":"Ford","weight":"10.0"}), and construct a point knowledge index and an edge knowledge label, and batch import the above point knowledge and edge knowledge into the graph, so as to obtain an automotive knowledge graph. <00——0124>The knowledge graph-based information query method provided in this application, after obtaining the target entity vector of the text to be queried, determines the target query pattern corresponding to the target entity vector and obtains the graph feature items corresponding to the target query pattern. It then uses the target query pattern to associate entity words with the corresponding graph feature items, generates a corresponding graph query statement based on the target query pattern and the graph feature items associated with entity words, and queries the knowledge graph based on the graph query statement to obtain the corresponding first query result. In other words, this solution can locate the answer corresponding to the text to be queried without relying on a large amount of corpus data. Furthermore, by using the target query pattern to assist in associating entity words in the text to be queried with the graph feature items required for graph querying, it ensures the accuracy of feature association, thereby improving the accuracy of the generated graph query statement and ultimately increasing the accuracy of the query results.
[0057] In practical applications, query results often contain a lot of information. To provide users with more accurate information, it is necessary to further refine the query results. Therefore, based on the above embodiments, optionally, as follows: Figure 2 As shown, the method may further include:
[0058] S201. When the first query result includes multiple response texts, determine the target response text that matches the query text from the multiple response texts.
[0059] After obtaining the first query result, if the first query result contains a lot of content, the first query result can be segmented, with each segment corresponding to a response text, resulting in multiple response texts; then each response text is analyzed to determine the target response text that matches the query text from the multiple response texts.
[0060] Optionally, the target response text can be determined through the following process: classifying the content of each response text to obtain the corresponding category words for each response text; determining the second matching degree between the entity words of the query text and each category word; and determining the response text corresponding to the category words whose second matching degree satisfies the second preset condition as the target response text.
[0061] Specifically, multiple sample data points can be acquired, and the content of these sample data points can be combined to create category terms. These sample data points, along with their labeled data, can then be used as training data to train a text classifier. This trained text classifier can then be used to categorize the content of each response text, yielding the corresponding category terms for each response text. For example, for inquiries about car-related activities, the category terms for each response text could include promotion, discount, subsidy, time, benefits, fund, and car purchase interest rate, etc.
[0062] Next, the entity words (i.e., search terms) of the query text are compared with the category words corresponding to each response text using cosine similarity calculation to obtain the corresponding second matching degree. The response texts corresponding to the category words whose second matching degree meets the second preset condition are determined as the target response texts. For example, the response text corresponding to the category word with the highest second matching degree is determined as the target response text.
[0063] S202. Extract the summary information of the target response text.
[0064] Specifically, the textRank algorithm can be used to extract summary information from the target response text.
[0065] S203. Determine the summary information as the target query result corresponding to the text to be queried.
[0066] In this embodiment, the target response text that matches the user's query text can be mined from the first query result, and the summary information of the target response text can be used as the target query result, which realizes more granular information query, making the located query results more accurate and more consistent with the user's question.
[0067] To improve the accuracy of information query results, optionally, after step S105, the first query result can be corrected, based on the above embodiments. Here, multiple verification methods can be used to verify the first query result. If the verification passes, the first query result is returned to the user; if the verification fails, the first query result is corrected.
[0068] Furthermore, optionally, the first query result can be corrected in one of the following ways:
[0069] Method 1: Obtain the first entity word and the second entity word in the text to be queried; determine the predicted context words of the first entity word in the text to be queried using a pre-trained context prediction model; correct the first query result when the predicted context words do not contain the second entity word.
[0070] In this context, the second entity word is the actual context word of the first entity word in the query text. The aforementioned context prediction model can be obtained by iteratively training the word2vec Continuous Bag of Words (CBOW) model using training data. After identifying entity words in the query text, some entity words can be used as the first entity word, and the remaining entity words as the second entity word. The first entity word is then input into the context prediction model, which determines the predicted context word of the first entity word in the query text. Next, the second entity word is compared with the predicted context word. If the predicted context word contains the second entity word, it indicates that the first and second entity words in the query text are entity-related, and the accuracy of the first query result is high, requiring no correction. If the predicted context word does not contain the second entity word, it indicates that the first and second entity words in the query text are not entity-related, and the error rate of the first query result is high, requiring correction.
[0071] In practical applications, entity words may also have alternative names. For example, "Ford" might be "Ford" and "BMW" might be "BMW". To address this, an alias database can be pre-built. The alternative name corresponding to the second entity word can be determined from the alias database. The alternative name and the second entity word are then compared with the predicted context words. If the predicted context words do not contain the alternative name or the second entity word, the first query result is corrected.
[0072] For example, suppose the text to be queried is an incorrect statement, such as "How many seats does the BMW Lingrui have?". By performing entity relevance checks on the text, we can find that "BMW" and "Lingrui" are not related. Thus, the theoretical query result for this text should be empty. If the actual first query result is not empty, it can be corrected, such as by setting the first query result to empty.
[0073] Method 2: Determine whether the query items in the text to be queried conform to common sense; if it is determined that the query items do not conform to common sense, correct the first query result.
[0074] Specifically, common sense includes common sense about entity attributes and common sense about entity relationships. In practical applications, a general knowledge table can be used to determine whether the query items in the text to be queried conform to common sense. There are two types of general knowledge tables: relational general knowledge tables and attribute general knowledge tables. The relational general knowledge table is used to determine whether the relationships between the queried entities conform to common sense. For example, for the query text "Why is BMW logistics so slow?", the relational general knowledge table shows that there is no query relationship between the brand and logistics; only BMW's after-sales service is related to logistics. Therefore, querying the relationship between "BMW" and "logistics" would be judged as a common sense error, and the first query result needs to be corrected.
[0075] The attribute common sense table is used to determine whether the attributes of the queried entity conform to common sense. For example, "ten-seater" BMW and "National II emission standard Lingrui" are common sense errors. If the text to be queried contains such common sense errors, the first query result needs to be corrected. For example, the first query result can be set to empty.
[0076] Method 3: When it is determined that there are unassociated entity words in the text to be queried, the entity words under the corresponding graph feature item are replaced with unassociated entity words using the target query mode; and the step of generating the corresponding graph query statement according to the target query mode and the graph feature item with associated entity words in S104 of the above embodiment is continued until the corresponding second query result is obtained; the intersection of the second query result and the first query result is determined as the target query result corresponding to the text to be queried.
[0077] When there are unassociated entity words in the text to be queried, the unassociated entity words can be used to replace the same type of entity in the previous query process. That is, the entity words under the corresponding graph feature item are replaced with the unassociated entity words using the target query pattern, and the above query process is executed again to obtain the second query result. The intersection of the second query result and the first query result is determined as the target query result.
[0078] For example, suppose the query text is "How many seats does the BMW Lingrui have?". The first query result is obtained by using "Lingrui" and "seat count" as graph feature values. In the supplementary query, the unassociated entity "BMW" in the query text can be replaced with the entity "Lingrui" from the previous query. That is, "BMW" and "seat count" are used as graph feature values again for the supplementary query, resulting in the second query result. Since neither the brands "BMW" nor "Ford" have publicly available models, the target query result is empty.
[0079] In this embodiment, after obtaining the first query result, the first query result can be verified in various ways, including entity relevance verification, alias processing, common sense verification, and supplementary queries. If the first query result fails verification, the first query result is corrected, thereby improving the accuracy of the first query result.
[0080] Figure 3 This is a schematic diagram of a knowledge graph-based information query device provided in an embodiment of this application. Figure 3 As shown, the device may include: a construction module 301, a determination module 302, an association module 303, a generation module 304, and a query module 305.
[0081] Specifically, the construction module 301 is used to construct the target entity vector of the text to be queried based on the entity words in the text to be queried and the entity types corresponding to the entity words;
[0082] The determining module 302 is used to determine the target query pattern corresponding to the target entity vector and obtain the graph feature items corresponding to the target query pattern; wherein, the target query pattern is used to indicate the query process of the text to be queried in the knowledge graph;
[0083] The association module 303 is used to associate the entity words with the corresponding graph feature items using the target query pattern;
[0084] The generation module 304 is used to generate a corresponding graph query statement based on the target query pattern and the graph feature items associated with entity words;
[0085] The query module 305 is used to query the knowledge graph according to the graph query statement to obtain the corresponding first query result.
[0086] Based on the above embodiments, optionally, the determining module 302 is specifically used to obtain a pre-constructed mapping relationship table; determine the first matching degree between the target entity vector and the plurality of reference entity vectors; and determine the query mode corresponding to the reference entity vector whose first matching degree satisfies the first preset condition as the target query mode; wherein, the mapping relationship table includes reference entity vectors of a plurality of historical query texts and query modes corresponding to each reference entity vector.
[0087] Based on the above embodiments, optionally, the generation module 304 is specifically used to obtain the graph statement to be filled corresponding to the target query pattern; fill the entity words associated with the target query pattern and the graph feature items into the corresponding positions in the graph statement to be filled, and obtain the graph query statement.
[0088] Optionally, based on the above embodiments, the device further includes a details query module.
[0089] Specifically, the detailed query module is used to determine the target response text that matches the text to be queried from the multiple response texts when the first query result includes multiple response texts; extract the summary information of the target response text; and determine the summary information as the target query result corresponding to the text to be queried.
[0090] Based on the above embodiments, optionally, the detail query module is further configured to classify the content of each response text to obtain the classification words corresponding to each response text; determine the second matching degree between the entity words of the text to be queried and each classification word; and determine the response text corresponding to the classification words whose second matching degree satisfies the second preset condition as the target response text.
[0091] Optionally, based on the above embodiments, the device further includes: a query result correction module;
[0092] Specifically, the query result correction module is used to obtain the first entity word and the second entity word in the text to be queried; wherein, the second entity word is the actual context word of the first entity word in the text to be queried; the predicted context word of the first entity word in the text to be queried is determined by a pre-trained context prediction model; and the first query result is corrected when the predicted context word does not contain the second entity word.
[0093] Optionally, based on the above embodiments, the query result correction module is further configured to determine the alternative noun corresponding to the second entity word; compare the alternative noun and the second entity word with the predicted context words respectively; if the predicted context words do not contain the alternative noun and the second entity word, then correct the first query result.
[0094] Optionally, based on the above embodiments, the query result correction module is further configured to, when determining that there are unassociated entity words in the text to be queried, replace the entity words under the corresponding graph feature item with the unassociated entity words using the target query pattern; and continue to execute the step of generating the corresponding graph query statement according to the target query pattern and the graph feature item with associated entity words, until the corresponding second query result is obtained; and determine the intersection of the second query result and the first query result as the target query result corresponding to the text to be queried.
[0095] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of this application, such as... Figure 4 As shown, the device includes a processor 40, a memory 41, an input device 42, and an output device 43; the number of processors 40 in the device can be one or more. Figure 4Taking a processor 40 as an example; the processor 40, memory 41, input device 42, and output device 43 in this device can be connected via a bus or other means. Figure 4 Taking the example of a connection between China and Israel via a bus.
[0096] The memory 41, as a computer-readable storage medium, can be used to store software programs, computer-executable programs, and modules, such as the program instructions / modules corresponding to the knowledge graph-based information query method in the embodiments of this application (e.g., the construction module 101, determination module 102, association module 103, generation module 104, and query module 105 in the knowledge graph-based information query device). The processor 40 executes various functional applications and data processing of the device by running the software programs, instructions, and modules stored in the memory 41, thereby realizing the aforementioned knowledge graph-based information query method.
[0097] The memory 41 may primarily include a program storage area and a data storage area. The program storage area may store the operating system and at least one application program required for a given function; the data storage area may store data created based on the use of the electronic device. Furthermore, the memory 41 may include high-speed random access memory and non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state storage device. In some instances, the memory 41 may further include memory remotely located relative to the processor 40, which can be connected to the device / terminal / server via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
[0098] Input device 42 can be used to receive input digital or character information, and to generate key signal inputs related to user settings and function control of the electronic device. Output device 43 may include display devices such as a display screen.
[0099] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, the computer program performing the following steps when executed by a processor:
[0100] Based on the entity words in the text to be queried and the entity types corresponding to the entity words, construct the target entity vector of the text to be queried;
[0101] Determine the target query pattern corresponding to the target entity vector, and obtain the graph feature items corresponding to the target query pattern; wherein, the target query pattern is used to indicate the query process of the text to be queried in the knowledge graph;
[0102] The entity words are associated with the corresponding graph feature terms using the target query pattern;
[0103] Generate corresponding graph query statements based on the target query pattern and graph feature items associated with entity words;
[0104] The knowledge graph is queried according to the graph query statement to obtain the corresponding first query result.
[0105] The knowledge graph-based information query device, electronic device, and storage medium provided in the above embodiments can execute the knowledge graph-based information query method provided in any of the above embodiments, and have the corresponding functional modules and beneficial effects of executing the method. Technical details not described in detail in the above embodiments can be found in the knowledge graph-based information query method provided in any of the above embodiments.
[0106] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0107] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.
Claims
1. A knowledge graph-based information retrieval method, characterized in that, include: Based on the entity words in the text to be queried and the entity types corresponding to the entity words, construct the target entity vector of the text to be queried; Determine the target query pattern corresponding to the target entity vector, and obtain the graph feature items corresponding to the target query pattern; wherein, the target query pattern is used to indicate the query process of the text to be queried in the knowledge graph; The entity words are associated with the corresponding graph feature terms using the target query pattern; Generate corresponding graph query statements based on the target query pattern and graph feature items associated with entity words; The knowledge graph is queried according to the graph query statement to obtain the corresponding first query result; Obtain the first entity word and the second entity word from the text to be queried; wherein the second entity word is the actual context word of the first entity word in the text to be queried; Using a pre-trained context prediction model, the predicted context words of the first entity word in the query text are determined; When the predicted context words do not contain the second entity word, the first query result is corrected.
2. The method according to claim 1, characterized in that, Determining the target query pattern corresponding to the target entity vector includes: Obtain a pre-constructed mapping table; wherein the mapping table includes reference entity vectors of multiple historical query texts and query patterns corresponding to each reference entity vector; Determine the first matching degree between the target entity vector and the plurality of reference entity vectors; The query pattern corresponding to the reference entity vector whose first matching degree satisfies the first preset condition is determined as the target query pattern.
3. The method according to claim 1, characterized in that, The step of generating a corresponding graph query statement based on the target query pattern and graph feature terms associated with entity words includes: Obtain the graph statement to be filled corresponding to the target query pattern; The entity words associated with the target query pattern and the graph feature items are filled into the corresponding positions in the graph statement to be filled, thus obtaining the graph query statement.
4. The method according to claim 1, characterized in that, Also includes: When the first query result includes multiple response texts, the target response text that matches the query text is determined from the multiple response texts; Extract the summary information of the target response text; The summary information is determined as the target query result corresponding to the text to be queried.
5. The method according to claim 4, characterized in that, The step of determining the target response text that matches the query text from the plurality of response texts includes: The content of each response text is classified to obtain the corresponding category words for each response text; Determine the second matching degree between the entity words of the query text and each category word; The response text corresponding to the category words whose second matching degree meets the second preset condition is determined as the target response text.
6. The method according to claim 1, characterized in that, When the predicted context words do not contain the second entity word, the first query result is corrected, including: Identify the alternative noun corresponding to the second entity word; The alternative noun and the second entity word are compared with the predicted context words respectively; If the predicted context words do not contain the alternative noun and the second entity word, then the first query result is corrected.
7. The method according to claim 1, characterized in that, Also includes: When it is determined that there are unassociated entity words in the text to be queried, the entity words under the corresponding graph feature item are replaced with the unassociated entity words using the target query mode; And continue to execute the step of generating the corresponding graph query statement based on the target query pattern and the graph feature items associated with entity words, until the corresponding second query result is obtained; The intersection of the second query result and the first query result is determined as the target query result corresponding to the text to be queried.
8. An information query device based on a knowledge graph, characterized in that, include: The construction module is used to construct the target entity vector of the text to be queried based on the entity words in the text to be queried and the entity types corresponding to the entity words; The determination module is used to determine the target query pattern corresponding to the target entity vector and obtain the graph feature items corresponding to the target query pattern; wherein, the target query pattern is used to indicate the query process of the text to be queried in the knowledge graph; The association module is used to associate the entity words with the corresponding graph feature items using the target query pattern; The generation module is used to generate corresponding graph query statements based on the target query pattern and graph feature items associated with entity words; The query module is used to query the knowledge graph according to the graph query statement and obtain the corresponding first query result; The query result correction module is used to obtain a first entity word and a second entity word in the text to be queried; wherein the second entity word is the actual context word of the first entity word in the text to be queried; the predicted context word of the first entity word in the text to be queried is determined by a pre-trained context prediction model; and the first query result is corrected when the predicted context word does not contain the second entity word.
9. An electronic device, characterized in that, include: A memory and a processor, the memory storing a computer program, the processor executing the computer program to implement the steps of the method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.