A method and apparatus for generating query graphs, electronic equipment, and storage medium.

By using a relation detection model to perform relation detection and secondary identification on query questions, the target linked entities are identified, and a local query graph is generated. This solves the query error problem caused by similar entity attributes and relations in knowledge graphs, and improves the accuracy of the query graph and retrieval efficiency.

CN115544270BActive Publication Date: 2026-05-26CHINA TELECOM CORP LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
CHINA TELECOM CORP LTD
Filing Date
2022-10-18
Publication Date
2026-05-26

AI Technical Summary

Technical Problem

Existing knowledge graphs struggle to distinguish search directions when entities with similar attributes and relationships, or when different entities with similar attributes and relationships, leading to errors in query graph generation and an inability to accurately obtain the desired search results.

Method used

The query is analyzed using a relation detection model to identify multiple linked entities. A query graph is generated based on the target linked entities. Secondary relation detection is used to identify the target linked entities, enhancing information extraction capabilities and focusing on the generation of local query graphs.

Benefits of technology

It improves the accuracy and retrieval efficiency of query graphs, reduces the reliance on knowledge graph traversal calculations, and can quickly generate local query graphs starting from the central entity of the query question, thus enhancing information extraction capabilities.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115544270B_ABST
    Figure CN115544270B_ABST
Patent Text Reader

Abstract

This invention provides a method, apparatus, electronic device, and storage medium for generating a query graph. The method includes: acquiring a first query statement and a relation detection model for performing relation detection on the query statement; determining multiple linked entities of the first query statement; performing relation detection on the first query statement using the relation detection model, sorting the multiple linked entities to determine a target linked entity set from the multiple linked entities; generating a second query statement based on the first query statement; performing relation detection on the second query statement using the relation detection model, determining target linked entities from the target linked entity set, and generating a query graph based on the target linked entities. This invention enhances information extraction capabilities, does not rely on knowledge graph traversal calculations, and focuses on generating a local query graph by starting from the central entity of the query statement based on secondary relation detection, making the generated query graph more accurate.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of information search technology, and in particular to a method and apparatus for generating query graphs, electronic devices, and storage media. Background Technology

[0002] Existing knowledge graphs are usually triples, which consist of a head entity, a tail entity, and a relation. The head entity, relation, and tail entity can also be referred to as the subject, predicate, and object, respectively.

[0003] For a given query, once the subject (head entity) and predicate (relation) are determined, the object, which is the answer to the query, can be obtained from the triples in the knowledge graph.

[0004] However, when the attributes and relationships of the same entity in a knowledge graph are similar, or when different entities are similar, it may be difficult to distinguish the retrieval direction in the knowledge graph, which may result in an inaccurate query graph.

[0005] For example, in the query questions "Yao Ming's team doctor" and "Yao Ming's teammates", the head entities of the triples are the same and the relation names are similar. In the actual query process, it is easy to make a matching error, which will lead to an incorrect query graph and make it difficult to obtain the expected search results. Summary of the Invention

[0006] In view of the above problems, a method, apparatus, electronic device, and storage medium for generating a query graph are proposed to overcome or at least partially solve the above problems, including:

[0007] A method for generating a query graph, the method comprising:

[0008] Obtain the first query statement and the relation detection model for performing relation detection on the query statement;

[0009] Identify the multiple linked entities in the first query;

[0010] The first query is subjected to relation detection using a relation detection model. Multiple linked entities are sorted to determine the target set of linked entities from the multiple linked entities.

[0011] The second query is generated based on the first query, wherein the second query is generated by formatting each link entity in the target link entity set based on the first query.

[0012] The second query is subjected to relation detection using a relation detection model. The target link entities are identified from the target link entity set, and a query graph is generated based on the target link entities.

[0013] Optionally, a relation detection model is used to perform relation detection on the first query, and multiple linked entities are sorted to determine the target set of linked entities from the multiple linked entities, including:

[0014] Determine the first score information for each of the multiple linked entities;

[0015] Based on a pre-defined knowledge graph, determine the first set of relations and the associated second set of relations for each linked entity;

[0016] The relationship detection module is used to perform relationship detection between the first query and the first and second relationship sets respectively, and generate a second score information of reliable relationship for each linked entity;

[0017] Based on the first score information and the second score information, determine the target score information for each linked entity;

[0018] Based on the ranking information of the target scores from high to low, the target link entity set is determined from multiple link entities.

[0019] Optionally, a relation detection module is used to perform relation detection on the first query statement with the first relation set and the second relation set respectively, generating a second score information on reliable relations for each linked entity, including:

[0020] Determine the first query vector information of the first query;

[0021] Determine the first relation vector information for each first relation in the first relation set;

[0022] Determine the second relation vector information for each second relation in the second relation set;

[0023] Based on the first question vector information, the first relation vector information, and the second relation vector information, generate the second score information of reliable relations for each linked entity.

[0024] Optionally, based on the first question vector information, the first relation vector information, and the second relation vector information, a second score information for reliable relations for each linked entity is generated, including:

[0025] Determine the first cosine similarity information between the first question vector information and the first relation vector information;

[0026] Determine the second cosine similarity information between the first question vector information and the second relation vector information;

[0027] Based on the first cosine similarity information, sorting from high to low, determine the first relation subset of the first relation set;

[0028] Based on the first relation subset and the second relation set, a reliable relation set is obtained;

[0029] Based on the reliable relationship set, the first cosine similarity information, and the second cosine similarity information, a second score information for the reliable relationship of each linked entity is generated.

[0030] Optionally, a relation detection model is used to perform relation detection on the second query, and the target link entities are determined from the target link entity set, including:

[0031] A relation detection module is used to detect relations in the second query and the second relation set, generating a third score for the relations of each linked entity.

[0032] Based on the third score information and the target score information, the target link entity is determined from the target link entity set.

[0033] Optionally, a query graph is generated based on the target linked entities, including:

[0034] Generate a query subgraph of target linked entities based on a pre-defined knowledge graph;

[0035] When no query result corresponding to the first query question is found in the query subgraph, the related entities that are not in the query subgraph are determined based on the preset knowledge graph;

[0036] When the matching degree between the relational entity and the first query question is greater than the preset matching degree threshold, the associated entity and the corresponding relationship of the associated entity are added to the query subgraph to generate the query graph.

[0037] Optionally, the training steps of the relationship detection model include:

[0038] Obtain the target query statement for training the relation detection model, and determine the target query statement vector based on the preset representation parameters of the relation detection model;

[0039] Determine the relation-level and word-level segmentation information of the target query, and based on the representation parameters of the preset relation detection model, determine the relation-level segmentation vector of the relation-level segmentation information and the word-level segmentation vector of the word-level segmentation information;

[0040] Generate the target relation vector of the target query question based on the relation-level word segmentation vector and the word-level word segmentation vector;

[0041] Determine the target cosine similarity information between the target question vector and the target relation vector;

[0042] The representation parameters are adjusted based on the target cosine similarity information.

[0043] A query graph generation apparatus, the apparatus comprising:

[0044] The data acquisition module is used to acquire the first query question and the relation detection model for relation detection based on the query question;

[0045] The link entity generation module is used to determine multiple link entities for the first query question;

[0046] The first relation detection module is used to perform relation detection on the first query question through a relation detection model, sort multiple linked entities, and determine the target linked entity set from the multiple linked entities.

[0047] The query statement formatting module is used to generate a second query statement based on a first query statement. The second query statement is generated by formatting each link entity in the target link entity set based on the first query statement.

[0048] The second relation detection module is used to perform relation detection on the second query question using a relation detection model, determine the target link entities from the target link entity set, and generate a query graph based on the target link entities. A server includes a processor, a memory, and a computer program stored in the memory and capable of running on the processor. When executed by the processor, the computer program implements the query graph generation method described above.

[0049] A computer-readable storage medium storing a computer program, which, when executed by a processor, implements the above-described method for generating a query graph.

[0050] The embodiments of the present invention have the following advantages:

[0051] This invention, through obtaining a first query statement and a relation detection model for performing relation detection on the query statement, can identify multiple linked entities in the first query statement. Then, the relation detection model is used to perform relation detection on the first query statement, sorting the multiple linked entities to determine a target set of linked entities. This is followed by relation detection on a second query statement using the same model, identifying target linked entities from the target set, and generating a query graph based on the target linked entities. This enhances information extraction capabilities, eliminating reliance on knowledge graph traversal computation. It allows for a focus on generating a local query graph based on secondary relation detection, starting from the central entity of the query statement, resulting in a more accurate generated query graph. Attached Figure Description

[0052] To more clearly illustrate the technical solution of the present invention, the accompanying drawings used in the description of the present invention will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0053] Figure 1 It is a schematic diagram of a knowledge spectrum;

[0054] Figure 2 It is a flowchart of the steps of a retrieval process based on a knowledge graph;

[0055] Figure 3a It is a computational framework for LSTM as a whole;

[0056] Figure 3b This is a schematic diagram of a BiLSTM computation process;

[0057] Figure 4 It is a query graph generated based on triples;

[0058] Figure 5 This is a flowchart of the steps of a query graph generation method provided in an embodiment of the present invention;

[0059] Figure 6 This is a flowchart of another method for generating a query graph according to an embodiment of the present invention;

[0060] Figure 7 This is a flowchart of another method for generating a query graph according to an embodiment of the present invention;

[0061] Figure 8a This is a schematic diagram of the training process of a relationship detection model provided in an embodiment of the present invention;

[0062] Figure 8b This is a schematic diagram of a query graph generation process provided in an embodiment of the present invention;

[0063] Figure 9 This is a schematic diagram of the structure of a query graph generation device provided in an embodiment of the present invention. Detailed Implementation

[0064] To make the above-mentioned objects, features, and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without inventive effort are within the scope of protection of the present invention.

[0065] In practical applications, knowledge graphs can be used in the field of information search. With the continuous development of deep learning technology, knowledge graphs are widely used in fields such as intelligent dialogue, automatic question answering, decision analysis, and precise recommendation, and are an important foundational technology for data value mining and intelligent information services.

[0066] Knowledge graphs can be represented in the form of triples, i.e.:

[0067] G = (Entity hrad Relation, Entity tail )

[0068] in:

[0069] Entity hea ∈[Entity1,Entity2,…,Entity n ]

[0070] For head entities;

[0071] Entity tail ∈[Entity1,Entity2,…,Entity n ]

[0072] It is a tail entity;

[0073] Relation∈[Relation1,Relation2,…,Relation n ]

[0074] The head entity, relation, and tail entity can also be called the subject, predicate, and object, respectively. Knowledge graphs typically store relational data in this format.

[0075] Taking "Yao Ming's birthplace is Shanghai" and "Yao Ming's nationality is China" as examples, we can abstract "Yao Ming's birthplace is Shanghai" into a triple (Yao Ming, birthplace, Shanghai) and "Yao Ming's nationality is China" into a triple (Yao Ming, nationality, China), where the subjects of these two triples are the same.

[0076] like Figure 1 The image shown is a knowledge graph with "Yao Ming" as the main entity.

[0077] Where "type" represents the entity type; "place of birth", "spouse", and "nationality" are the relationship names; "Yao Ming" and "Ye Li" are entities of type Person; and "Shanghai" and "China" are entities of type Location.

[0078] The retrieval process of a knowledge graph, KBQA (Knowledge Base Question Answering), is as follows: when the search question is "Who is Yao Ming's spouse?", it starts from... Figure 1 From the results, we can confirm that the answer we searched for was "Ye Li".

[0079] Once the subject (head entity) and predicate (relation) of the search query are determined, the object can be obtained from the triples in the knowledge graph. Therefore, by extracting the subject and predicate for the search query and matching them with the triples in the knowledge graph, the object, which is the answer to the search query, can be obtained.

[0080] like Figure 2 The retrieval process for the knowledge graph shown is as follows:

[0081] (1) Search questions.

[0082] The search query is segmented into words and then embedded.

[0083] (2) Relationship detection.

[0084] Relation detection can include entity recognition and relation extraction for retrieval queries.

[0085] In practical applications, entity recognition and relation extraction can be abstracted as sequence labeling problems, which can be solved using Bidirectional Long Short-Term Memory (BiLSTM) networks. LSTM stands for Long Short-Term Memory, a type of recurrent neural network used to process temporal text data. An LSTM model consists of input words at each time step, cell states, temporary cell states, hidden states, forget gates, memory gates, and output gates.

[0086] The LSTM computation process can be summarized as follows: by forgetting and remembering new information in the cell state, useful information for subsequent time steps can be passed on, useless information is discarded, and a hidden state is output at each time step. Forgetting, remembering, and output are controlled by forgetting gates, remembering gates, and output gates calculated from the hidden state of the previous time step and the current input.

[0087] The overall computational framework of LSTM is as follows: Figure 3a As shown, BiLSTM combines forward LSTM and backward LSTM. For example, when encoding the phrase "I love China," the BiLSTM computation process is as follows: Figure 3b As shown.

[0088] (3) Generate query graph.

[0089] Query graph generation can include resource mapping rules, semantic reorganization, and the generation of subgraphs.

[0090] In practical applications, query graph generation mainly includes the following three steps:

[0091] Step 1: Select the main entity as the root node.

[0092] Step 2: Determine a directed path from the root node to the answer node, which may include one or more nodes. This path is called the core reasoning chain, where all nodes except the root node are called variables.

[0093] Step 3: One or more nodes are connected through predicates and variable nodes on the core inference chain.

[0094] like Figure 4 The image shown is a query graph corresponding to the question: "Who was the first actor to voice "MegGriffin" in the animated series "Family Guy"?"

[0095] In this context, "Famil Guy" and "Meg Griffin" in the rounded rectangle represent definite entities, y in the circle represents an existing variable, x in the gray circle is a variable that is the final answer, and argmin in the rhombus is an aggregation function. Since there is more than one voice actor for MegGriffin, this aggregation function is used to limit the range of answers.

[0096] In this query graph, "Family Guy" is the root entity, the path Family Guy->y->x is called the core reasoning chain, the chain y->Meg Griffin identifies the character, and the chain y->argmin restricts the character to be the earliest voice actor.

[0097] (4) Search results.

[0098] After determining the query graph, the answer can be generated according to natural language and reorganized to obtain the final search results.

[0099] Based on the knowledge graph of the above triples, the following problems exist:

[0100] Question 1: When drilling down in multiple dimensions and levels, knowledge graphs will generate many triples. If the triples are not constrained, the excessive number of branches in the knowledge graph drilling down will lead to excessively long retrieval time and the inability to release resources in a timely manner. For example, when it is necessary to query Yao Ming's average score in the NBA and how it compares to the average score of his teammates in different teams, multiple triples need to be matched for querying and comparison.

[0101] Question 2: When entities with similar attributes and relations in a knowledge graph have similar attributes or different entities with similar relations, it is difficult to distinguish the drill-down direction, making it impossible to obtain the expected search results. For example, query 1 "Yao Ming's team doctor" and query 2 "Yao Ming's teammates" have the same head entity and similar relation names in their triples, which can easily lead to matching errors and result in an incorrect query graph.

[0102] In this embodiment of the invention, by extracting the link entities of the query question, filtering the link entities based on two relation detection and identification processes, determining the target link entities, and generating a query graph based on the target link entities, the information extraction capability is enhanced. At the same time, without relying on knowledge graph traversal calculations, it can start from the central entity of the query question and focus on the generation of a local query graph, making the generated query graph more accurate. Furthermore, by generating a local query graph for question retrieval, the answer to the question can be retrieved quickly, improving retrieval efficiency.

[0103] Reference Figure 5 The diagram illustrates a flowchart of a query graph generation method according to an embodiment of the present invention, which may specifically include the following steps:

[0104] Step 501: Obtain the first query statement and the relation detection model for performing relation detection on the query statement;

[0105] The first query can be a query entered by the user, and the first query can include multiple entities and relations.

[0106] The relation detection model can be used to detect and identify relations in a query. The input value is the query and the output value is the score of each relation in the query. The relation score can be used to sort the entities in the query. Thus, the relation detection model can determine the central entity in the query, that is, the entity with the highest score, and generate a query graph based on the central entity, thereby enhancing the information extraction capability and improving the query retrieval efficiency.

[0107] Specifically, the relationship detection model can be a hierarchical residual BiLSTM network model.

[0108] In one embodiment of the present invention, the training steps of the relationship detection model include:

[0109] Step S11: Obtain the target query statement used to train the relation detection model, and determine the target query statement vector information based on the preset representation parameters of the relation detection model.

[0110] In practical applications, a pre-defined relation detection model can represent both the query and its relation separately, using the same representation parameters in both processes. After representation, the incomputable query and relation can be transformed into a computer-readable vector, which can then be used to detect relations within the query.

[0111] During the training of the relation detection model, initial representation parameters can be set in the preset initial relation detection model. These representation parameters are relevant parameters that convert questions or relations back into computable vectors. A training set is then obtained, consisting of multiple target query questions. For each target query question, word segmentation is performed, thereby generating a target query vector based on the representation parameters.

[0112] In one example, based on the representation parameters of a pre-defined relation detection model, the target query vector information is determined, including:

[0113] The target query is input into the relation detection model. Based on the preset representation parameters of the relation detection model, the first hidden state vector set of the target query is determined. A second hidden state vector set is generated based on the first hidden state vector set. Pooling is performed on the first and second hidden state vector sets respectively to obtain the first target hidden state vector information and the second target hidden state vector information. The first hidden state vector information and the second target hidden state vector information are added together to obtain the target query vector information.

[0114] For example, a two-layer BiLSTM is used to represent the retrieval question Q, where the input question q = {q1, ..., q} N} (i.e., the target query question), the hidden state vector output by the first layer is That is, the first hidden state vector set, the input of the second layer is the hidden state vector output from the first layer, and the output hidden state vector is... That is, the second hidden state vector set.

[0115] In obtaining and Next, it is necessary to match the representations of both layers with the relationships, which allows the introduction of residual networks to separately address these relationships. and After performing a max pooling operation and summing the results, we obtain the representation of the search query, i.e., the embedding of the search query:

[0116]

[0117] in for The result after max pooling is the first target hidden state vector; for The result after max pooling is the hidden state vector of the second objective; h q This represents the target question vector.

[0118] For example, when the search query is "How many users in the entire company have been online for more than 10 years, have an annual income of more than 150,000, and are using HCV integration from physical channels, and have been billed?"

[0119] First, the search query is segmented into words, input into the relation detection model, and two layers of hidden state vectors are calculated. Then, max pooling is performed to obtain the embedding of the search query.

[0120] The hidden state vector of the first layer is: (0.012632, 0.032457, 0.478245, 0.223744, 0.781345, ...)

[0121] (0.125780, 0.012355, 0.135789, 0.351790, 0.235678, ...)

[0122] ...

[0123] The hidden state vector of the second layer is: (0.120356, 0.123890, 0.346780, 0.123567, 0.023567, ...)

[0124] (0.135789, 0.325808, 0.513802, 0.237804, 0.135152, ...)

[0125] ...

[0126] Max pooling results: (0.125780, 0.032457, 0.478245, 0.223744, 0.781345, ...)

[0127] (0.135789, 0.325808, 0.513802, 0.237804, 0.135152, ...)

[0128] Question representation: (0.261569, 0.358265, 0.992047, 0.461548, 0.916497, ...)

[0129] Step S12: Determine the relation-level word segmentation information and word-level word segmentation information of the target query, and based on the representation parameters of the preset relation detection model, determine the relation-level word segmentation vector information of the relation-level word segmentation information and the word-level word segmentation vector information of the word-level word segmentation information;

[0130] After determining the target query, relation-level segmentation and word-level segmentation can be performed on the target query to obtain relation-level segmentation information and word-level segmentation information of the target query. Relation-level segmentation and word-level segmentation are used to better focus on the local relationships of the target query.

[0131] For example: For the search query "How many users in the entire company have over 10 years of online experience, an annual income of over 150,000, and who have integrated HCV (Human Value Provider) across physical channels and are billed?", relation-level and word-level segmentation are performed, yielding the following segmentation results:

[0132] Relational-level word segmentation: Over 10 years of online experience, annual income of over 150,000, physical channels, HCV integration, number of billed users...

[0133] Word-level segmentation: 10, year, more than, internet age, year, income, at, 150,000 or more, entity, channel, HCV, integration, billing, number of users...

[0134] For the relation-level and word-level segmentation information of the target query, the same representation parameters as the query representation process can be used to obtain the relation-level segmentation vector information of the relation-level segmentation information and the word-level segmentation vector information of the word-level segmentation information.

[0135] Step S13: Generate target relation vector information for the target query statement based on relation-level word segmentation vector information and word-level word segmentation vector information;

[0136] After determining the relation-level word segmentation vector information and the word-level word segmentation vector information, the relation-level word segmentation vector information and the word-level word segmentation vector information can be concatenated to obtain the target relation vector information.

[0137] For example, the relation can be represented at both the word level and the overall relation level for a retrieval query. The input to the relation detection model is a relation or relation path.

[0138]

[0139] Where M1 is the number of words in all relations, and M2 is the number of relations in all relations or paths. The hidden state matrices at the word level and relation level are obtained by representing the parameters of the shared retrieval query representation BiLSTM (i.e., the BiLSTM parameters for the retrieval query representation, word-level representation, and relation-level representation are consistent across all three representation processes). Here, [:] represents matrix concatenation. Finally, max pooling is performed on all hidden state vectors of both matrices to obtain the final relation representation h. r .

[0140] The hidden state vector of the relation segmentation:

[0141] (0.891235, 0.794562, 0.561345, 0.238961, 0.136893, ...)

[0142] (0.023589, 0.067951, 0.578341, 0.790346, 0.275689, ...)

[0143] ...

[0144] Max pooling results (relationship representation): (0.891235, 0.794562, 0.578341, 0.790346, 0.275689…)

[0145] Step S14: Determine the target cosine similarity information between the target question vector and the target relation vector;

[0146] After obtaining the target question vector and the target relation vector, the target cosine similarity value between the target question vector and the target relation vector can be calculated.

[0147] Step S15: Adjust the representation parameters based on the target cosine similarity information.

[0148] After generating the cosine similarity of the relation for each target query, the representation parameters can be adjusted based on the cosine similarity to enable the relation detection model to better represent the relation of the query.

[0149] Specifically, a ranking loss function can be defined based on cosine similarity. Ranking loss is a loss function in the field of information retrieval, and its purpose is to train a model to perform a specific ranking of items in a set. It uses triples, namely the retrieval question, the relations contained in the retrieval question, and the relations not contained in the retrieval question; as follows:

[0150] l rel =max(0, γ-s) rel (r + ;q)+s rel (r - ;q))

[0151] Among them, s bel (r + ;q) represents the loss when the relation is correct, s rel (r -;q) represents the loss when the relation is incorrect, and γ is a pre-set constant used to adjust the magnitude of the loss. From the definition of loss, the representation of the relation included in the search query and the representation of the search query itself have high similarity and are close in the vector space; the representation of the relation not included in the search query and the representation of the search query itself have low similarity and are far apart in the vector space. This degree of similarity depends on the data distribution, so a constant needs to be preset based on experience to adjust the distribution of the loss, avoiding computational errors caused by large differences in data magnitude.

[0152] By calculating the loss function of multiple query questions, the representation function in the relation detection model is adjusted so that the relation detection model can better detect relations.

[0153] Step 502: Determine the multiple linked entities of the first query question;

[0154] After determining the first query question, multiple linked entities can be extracted from the first query question using a preset entity linking tool, and these multiple linked entities constitute a linked entity set.

[0155] For example, the linked entity set for a query like "How many users in the entire company have been online for more than 10 years, have an annual income of more than 150,000, and are integrated with physical channels and HCV?" is: Total number of users in the entire company, Total number of users in the entire company by online age, Total number of users in the entire company by online age - income, Total number of users in the entire company by online age - income - channel, Total number of users in the entire company by online age - income - channel - integrated... Total number of users in the entire company by online age - income - integrated - channel... Total number of users in the entire company by online age - channel - integrated - income... Total number of users in the entire company by online age - channel - income - integrated...

[0156] Step 503: Perform relation detection on the first query using a relation detection model, sort multiple linked entities, and determine the target linked entity set from the multiple linked entities;

[0157] After obtaining the relationship detection model and the first query, the first query can be input into the relationship detection model to perform relationship detection and output the relationship score. The higher the score, the higher the confidence of the relationship. Based on the relationship score, the linked entities associated with the relationship can be sorted to determine the sorting information of multiple linked entities. Based on the sorting information, a preset number of linked entities with higher scores can be determined and formed into a target linked entity set.

[0158] Step 504: Generate a second query based on the first query, wherein the second query is generated by formatting each link entity in the target link entity set based on the first query;

[0159] Formatting the entities in the first query query yields the second query query. Specifically, this can be done using the tag " <e>Replace the entities to be formatted in the query statement to format the query statement. For each linked entity, the corresponding query statement can be generated through formatting.

[0160] By formatting the entities in the query, the position of each word in the query relative to the entity can be distinguished.

[0161] For example: formatting the entity "entire company" in the query question results in the new query question "please ask". <e>How many users have been online for over 10 years, have an annual income of over 150,000, and are using a combination of physical and HCV channels for billing?

[0162] Step 505: Perform relation detection on the second query question using a relation detection model, determine the target link entities from the target link entity set, and generate a query graph based on the target link entities.

[0163] After generating the second query, it can be input into the relation detection model for further relation detection and identification. This allows for scoring of all relations associated with each linked entity in the target linked entity set. Based on the scoring process of the secondary relation detection model, each linked entity in the target linked entity set can be sorted to determine the target linked entity, which can be the entity with the highest score in the relation detection model.

[0164] After identifying the target linked entity, a query graph of the target linked entity can be generated based on the knowledge graph. The query graph is used to retrieve the answer to the first query question.

[0165] In this embodiment of the invention, the target linked entity is determined by secondary relation detection and identification, and then a query graph is generated. This enhances the information extraction capability and does not rely on knowledge graph traversal calculation. Starting from the central entity of the query question, it focuses on the generation of a local query graph, making the generated query graph more accurate. At the same time, compared with continuous traversal retrieval in the knowledge graph, generating a local query graph from the central entity for querying can improve retrieval efficiency.

[0166] Reference Figure 6 The diagram illustrates a flowchart of another query graph generation method provided by an embodiment of the present invention, which may specifically include the following steps:

[0167] Step 601: Obtain the first query statement and the relation detection model for performing relation detection on the query statement;

[0168] Step 602: Determine the multiple linked entities of the first query;

[0169] Step 603: Determine the first score information for multiple linked entities;

[0170] For each linked entity, a preset initial score can be set, i.e., the first score. Specifically, the initial score for each linked entity can be given through the linked entity tool.

[0171] Step 604: Determine the first set of relations and the associated second set of relations for each linked entity based on the preset knowledge graph;

[0172] After identifying the linked entities, a subgraph can be generated in the preset knowledge graph based on each linked entity. A first set of relations can be generated based on the subgraph, and a second set of relations associated with each linked entity can also be generated.

[0173] The second set of relations may include the relations between entities within the subgraph and the relations between entities in the subgraph and entities outside the subgraph. Specifically, the outermost entity in the subgraph is determined, and entities not in the subgraph are connected to the outermost entity based on the knowledge spectrum, thereby determining the relations between entities in the subgraph and entities outside the subgraph.

[0174] For example, a subgraph includes entities A and B, and relation ab. In a knowledge graph, entity A inside the subgraph is connected to entity C outside the subgraph through relation ac. Thus, the second set of relations for entity A can include relations ab and relations ac.

[0175] Step 605: The relationship detection module is used to perform relationship detection on the first query question with the first relationship set and the second relationship set respectively, and generate the second score information of reliable relationship for each linked entity;

[0176] After determining the first relation set and the second relation set, a relation detection model can be used to detect the relation between the first query and the first relation set, and then to detect the relation between the first query and the second relation set.

[0177] Based on the scores of relations in the first and second relation sets, the score of the most reliable relation for each linked entity can be determined, i.e., the second score information. In relation detection, the higher the score, the more reliable the relation.

[0178] In one embodiment of the present invention, step 605 may include the following sub-steps:

[0179] Sub-step S21: Determine the first query vector information of the first query query;

[0180] In practical applications, the first query can be represented as a first query vector by the representation parameters of a well-trained relation detection model.

[0181] Sub-step S22: Determine the first relation vector information for each first relation in the first relation set;

[0182] Each linked entity's first relation set can include multiple first relations. Each first relation is represented as a first relation vector information by the representation parameters of the trained relation detection model.

[0183] Sub-step S23: Determine the second relation vector information for each second relation in the second relation set;

[0184] The second relation set of each linked entity can include multiple second relations. Each second relation is represented as a second relation vector information by the representation parameters of the trained relation detection model.

[0185] Sub-step S24: Based on the first question vector information, the first relation vector information, and the second relation vector information, generate the second score information of the reliable relationship for each linked entity.

[0186] After obtaining the first question vector, the first relation vector information, and the second relation vector, the reliability of the relationship of each linked entity can be evaluated based on the first question vector, the first relation vector information, and the second relation vector information to determine the reliable relationship of each linked entity, and then determine the second score information of the reliable relationship.

[0187] In another embodiment of the present invention, sub-step S24 includes the following sub-steps:

[0188] Sub-step S31: Determine the first cosine similarity information between the first question vector information and the first relation vector information;

[0189] In practical applications, the cosine similarity of the vectors can be calculated based on the vector information of the first question and the vector information of the first relation to obtain the first cosine similarity information.

[0190] Sub-step S32: Determine the second cosine similarity information of the first question vector information and the second relation vector information;

[0191] The cosine similarity of the vectors is calculated based on the vector information of the first question and the vector information of the second relation to obtain the second cosine similarity information.

[0192] Sub-step S33: Based on the first cosine similarity information, sort from high to low to determine the first relation subset of the first relation set;

[0193] The first relations in the first relation set are sorted from high to low based on the first cosine similarity information, and a preset number of first relations at the top of the sorting constitute the first relation subset.

[0194] Sub-step S34: Based on the first relation subset and the second relation set, obtain the reliable relation set;

[0195] After obtaining the first set of relations, the intersection of the first set of relations with the second set of relations is taken to determine the reliable set of relations for each linked entity.

[0196] Sub-step S35: Based on the reliable relationship set, the first cosine similarity information, and the second cosine similarity information, generate the second score information of the reliable relationship for each linked entity.

[0197] For each relation in the reliable relation set of each linked entity, the cosine similarity information corresponding to that relation is determined based on the previously calculated first and second cosine similarity information. Each relation in the reliable relation set is then sorted from highest to lowest according to its cosine similarity information. The relation with the highest cosine similarity value is then identified, and the second score information of the reliable relation corresponding to the linked entity is determined based on the cosine similarity information of that relation. The higher the cosine similarity of a relation, the higher its score.

[0198] Step 606: Determine the target score information for each linked entity based on the first score information and the second score information;

[0199] After generating the second score information, for each linked entity, the initial first score information and the second score information of the reliable relationship of the linked entity can be summed and used as the target score information for each linked entity.

[0200] Step 607: Based on the ranking information of the target score information from high to low, determine the target link entity set from multiple link entities.

[0201] After obtaining the target score information, the multiple linked entities are sorted from high to low according to the target score information, and the top-ranked preset number of linked entities are taken to form the target linked entity set.

[0202] Step 608: Generate a second query based on the first query, wherein the second query is generated by formatting each link entity in the target link entity set based on the first query;

[0203] Step 609: Perform relation detection on the second query question using a relation detection model, determine the target link entities from the target link entity set, and generate a query graph based on the target link entities.

[0204] In one embodiment of the present invention, relation detection is performed on the second query statement using a relation detection model to determine the target link entity from the target link entity set, including:

[0205] A relation detection module is used to perform relation detection on the second query and the second relation set, generating third score information for the relation of each link entity in the target link entity; based on the third score information and the target score information, the target link entity is determined from the target link entity set.

[0206] In practical applications, after obtaining the second query question for each link entity in the target link entity set, the representation parameters of the trained relation detection model can be applied to perform relation detection on the second query question and the second relation set, generating the third score information for the relation of each link entity. Then, the third score information for each link entity in the target link entity set and the target score information obtained in the aforementioned step 606 are added together to determine the target link entity with the highest score.

[0207] In one example, a relation detection module is used to perform relation detection on the second query and the second relation set, generating third score information for the relations of each linked entity in the target linked entity, including:

[0208] Determine the second query vector information of the second query; determine the second relation vector information of each second relation in the second relation set; determine the third cosine similarity information of the second query information and the second relation vector information, and determine the third score information of the relation for each link entity in the target link entity based on the third cosine similarity information.

[0209] In practical applications, the second query statement can be represented as a second query statement vector using the representation parameters of a trained relation detection model. Furthermore, each second relation in the second relation set can be represented as a second relation vector using the same parameters. Cosine similarity is then calculated between the second query statement vector and each second relation vector to obtain a third cosine similarity. Based on this third cosine similarity, a third score for each link entity in the target linked entity can be determined. In this embodiment, linked entities are sorted using entity and relation scores to better filter entities. Then, through secondary relation detection, the target linked entities are identified, and a query graph is generated. This enhances information extraction capabilities without relying on knowledge graph traversal calculations. Starting from the central entity of the query statement, it focuses on generating a local query graph, making the generated query graph more accurate. Moreover, compared to continuous traversal retrieval in the knowledge graph, generating a local query graph from the central entity improves retrieval efficiency.

[0210] Reference Figure 7 The diagram illustrates a flowchart of another query graph generation method provided by an embodiment of the present invention, which may specifically include the following steps:

[0211] Step 701: Obtain the first query statement and the relation detection model for relation detection based on the query statement;

[0212] Step 702: Determine the multiple linked entities of the first query;

[0213] Step 703: Perform relation detection on the first query using a relation detection model, sort multiple linked entities, and determine the target linked entity set from the multiple linked entities;

[0214] Step 704: Generate a second query statement based on the first query statement, wherein the second query statement is generated by formatting each link entity in the target link entity set based on the first query statement;

[0215] Step 705: Perform relation detection on the second query using a relation detection model to determine the target link entities from the target link entity set.

[0216] Step 706: Generate a query subgraph of the target linked entities based on the preset knowledge graph;

[0217] After identifying the target linking entity, the set of binary pairs consisting of the target linking entity and the target relation can be determined based on the most reliable relation of the target linking entity (target relation).

[0218] After determining the set of binary tuples, each node in the set of binary tuples can be determined, and all nodes connected by any relation can be searched in the preset knowledge graph. These nodes are then used as target nodes, and a query subgraph is generated based on the target nodes.

[0219] The query subgraph contains the central entity of the first query question, so the query subgraph can be directly used to query the first query question. When the answer to the first query question can be found in the query subgraph, the current round of query ends.

[0220] Step 707: When no query result corresponding to the first query question is found in the query subgraph, determine the related entities that are not in the query subgraph and are connected to the outermost target entity in the query subgraph based on the preset knowledge spectrum.

[0221] When no query result corresponding to the first query question is found in the query subgraph, you can extend outward from the outermost entity (i.e. the target entity) of the query subgraph to determine the related entities in the knowledge graph that are connected to the target entity but are not in the query subgraph.

[0222] For example, a query subgraph consists of entity A, entity B, and relation ab. In a knowledge graph, entity A within the query subgraph is connected to entity C outside the query subgraph through relation ac. Thus, entity A is the target entity, and entity C is the associated entity.

[0223] Step 708: When the matching degree between the relational entity and the first query question is greater than the preset matching degree threshold, add the associated entity and the corresponding relationship of the associated entity to the query subgraph to generate a query graph.

[0224] After identifying the associated entities, the maximum overlap character sequence method can be used to calculate the matching degree between each n-gram in the first query and the associated entity.

[0225] When the matching degree information of the associated entities is higher than the preset matching degree threshold, the query subgraph is extended outward by the associated entities and their corresponding relationships until the answer entity and path of the query question are obtained, thereby generating an accurate query graph.

[0226] In this embodiment of the invention, the query graph generation process is optimized from a single generation to a two-stage generation. Starting from the central entity, the retrieval and coverage are progressively performed until the answer entity and path to the query are obtained. This enhances information extraction capabilities, improves query accuracy, and increases query efficiency.

[0227] The following combination Figures 8a-8b The above embodiments of the invention are described by way of example:

[0228] The query retrieval process can be divided into two parts: the first part is the training process of the relation detection model, such as... Figure 8a As shown; the second part is the query graph generation process, as follows: Figure 8b As shown.

[0229] The relationship detection model can be an improved hierarchical residual BiLSTM network for relationship recognition, such as... Figure 8a As shown, it includes the following steps:

[0230] Step S41: Retrieve the representation of question Q (i.e., the first query question).

[0231] A two-layer BiLSTM is used to represent the retrieval question Q, where the input question q = {q1, ..., q...} N } (i.e., the first query question), the hidden state vector output by the first layer is That is, the first state vector, the input of the second layer is the hidden state vector of the first layer, and the output is the hidden state vector. That is, the second state vector.

[0232] In obtaining and Next, it is necessary to match the representations of both layers with the relationships, which allows the introduction of residual networks to separately address these relationships. and After performing a max pooling operation and summing the results, we obtain the representation of the search query, i.e., the embedding of the search query:

[0233]

[0234] in, for The result after max pooling for The result after max pooling, h q The target question vector information.

[0235] Step S42: Relationship characterization at different granularities.

[0236] Relationships are represented at both the word level and the overall relation level for each retrieval query. The input to the relation detection model is a relation or relation path:

[0237]

[0238] Where M1 is the number of words in all relations, and M2 is the relation name in all relations or paths. The hidden state matrices at the word level and relation level are obtained by representing the query query representation using the shared parameters of the BiLSTM (i.e., the BiLSTM parameters for the query query representation, word-level representation, and relation-level representation are consistent across all three representation processes). Here, [:] represents matrix concatenation. Finally, max pooling is performed on all hidden state vectors of the two matrices to obtain the final relation representation h. r .

[0239] Step S43, layered matching.

[0240] Calculate the cosine similarity between the retrieval question representations and relation representations obtained in steps S41 and S42 to obtain the relation retrieval result R:

[0241] s rel (r;q)=cos(h r h q )

[0242] For example, the sentence is represented as (0.120356, 0.123890, 0.478245, 0.223744, 0.781345, ...).

[0243] The relationships are represented as (0.891235, 0.794562, 0.578341, 0.790346, 0.275689…).

[0244] The cosine similarity between the sentence representation and the relation representation is calculated, and the cosine value is 0.581512.

[0245] Since the BiLSTM parameters used for representing relations and retrieval questions are consistent, a ranking loss function can be defined. Ranking loss is a loss function in information retrieval aimed at training a model to perform a specific ranking of items in a set. Using triplet samples q, r... + r - Define a loss function, where q is the search query and r is the search term. + To retrieve relations contained in a question, r - To retrieve relations not included in the query, a loss function l is defined. rel as follows:

[0246] l rel =max(0, γ-s) rel (r + ;q)+s rel (r - ;q))

[0247] Among them, s rel (r + ;q) represents the loss when the relation is correct, s rel (r - ;q) represents the loss when the relation is incorrect, and γ is a preset constant used to adjust the magnitude of the loss. From the definition of loss, the representation of the relation contained in the search query and the representation of the search query have high similarity and are very close in the vector space; the representation of the relation not contained in the search query and the representation of the search query have low similarity and are very far in the vector space. This degree of similarity is determined based on the data distribution. By setting a constant γ to adjust the distribution of the loss, errors caused by large differences in data magnitude are avoided.

[0248] Steps S41 to S43 above propose an improved hierarchical residual BiLSTM network for relation recognition. It uses word-level matching criteria to match relations, and combines word-level and whole relation names for representation. It also uses deep BiLSTM to match retrieval questions with relations and residual training methods to accurately identify relations in the retrieval process.

[0249] By employing a two-layer BiLSTM, the retrieval question is input into a hierarchical residual BiLSTM network. This increases information extraction capability while allowing some layer parameters to approach zero. Residuals are then added for connection, ultimately forming a hierarchical residual BiLSTM for training. Finally, pooling results in a single vector. Simultaneously, candidate relations are input into the network from the right side, forming two embeddings: one with overall information and one at the word level. This two-level input allows the relation detection model to consider not only overall but also local information. Max pooling of the two embeddings into a single vector is then performed, and cosine similarity is calculated between the two vectors. The hierarchical residual BiLSTM enables more granular and efficient information extraction from retrieval questions while comprehensively considering both overall and local information of candidate relations.

[0250] like Figure 8b The specific steps for generating the query graph are as follows:

[0251] Step S51: Use the entity linking tool to generate a top K set of linked entities EL for the retrieval question Q (i.e., the first query question). K (q) is the set consisting of the entity in the retrieval question q and the entities related to it.

[0252] For example, when the search query is "How many users in the entire company have been online for more than 10 years, have an annual income of more than 150,000, and are integrated with physical channels and HCV, how many are billed?", the linked entity set is: total number of users in the entire company, total number of users in the entire company by online age, total number of users in the entire company by online age - income, total number of users in the entire company by online age - income - channel, total number of users in the entire company by online age - income - channel - integrated... total number of users in the entire company by online age - income - integrated - channel... total number of users in the entire company by online age - channel - integrated - income... total number of users in the entire company by online age - channel - income - integrated...

[0253] Step S52: Perform relation detection and identification on the retrieval question Q, and then perform relation detection and identification on the EL. K (q) Score all relationships.

[0254] For the retrieval question Q, a score s is generated for each relation (i.e., the first relation set) using hierarchical residual BiLSTM. rel (r; q), this process refers to steps S41 to S43.

[0255] Then, use s rel The relationship between the top l scores in (r; q) (i.e., the first relation subset) for EL K The entities in (q) are sorted. Specifically, for each linked entity e and its association Re (i.e., the second set of relations), given the entity linking tool score s... linker (i.e., the first score information) and the most reliable relationship The scores (i.e., the second score information) are added together, and the top K linked entities are then reordered:

[0256]

[0257] Among them, s rerank (e; q) represents the ranking score of the linked entities. Based on the above formula, linked entities with topK' << topK are selected, generating a new entity set EL'. K′ (q) (i.e., the set of target linked entities).

[0258] For example: Calculate the cosine similarity scores of the relations and search queries in the linked entity set using a relation detection model, and generate a top-K subset of linked entities by sorting them from high to low.

[0259] Linked entity subsets: Total number of users in the company, Total number of users in the company by network age, Total number of users in the company by network age-revenue-channel-integrated, Total number of users in the company by network age-revenue-integrated-channel, Total number of users in the company by network age-revenue-integrated-channel-billed, etc.

[0260] Step S53, for each e∈EL′ K′ (q) uses formatted retrieval questions as input to the relation detection model to perform relation detection and identification, thereby scoring all relations associated with entity e.

[0261] Reformat the search query Q: Replace the entity arguments of candidate entity e in the search query Q with the tag " <e>The purpose of formatting is to distinguish the position of each word in the search question Q relative to the entity.

[0262] Then, the formatted search query is input into a hierarchical residual BiLSTM network to predict each relation r∈R. e The score s of (i.e., the second relation set) rel (r; e, q) (i.e., the third score information).

[0263] For example: a set of formatted search questions:

[0264] How many users have been online for more than 10 years, have an annual income of more than 150,000, and are integrated with physical channels and HCV, are billed?

[0265] Please tell me the company's policy in accordance with... <e>How many users with an annual income of over 150,000 who are integrated with physical channels and HCV have paid billing?

[0266] Format the search query, that is, use meaningless symbols for the parts related to candidate entities. <e>The improved relation detection model is then used to calculate cosine similarity scores for the formatted retrieval question q and the relations r contained in the linked entity subset.

[0267] Step S53: Generate a set of binary tuples.

[0268]

[0269] The target linked entities in the linked entity subset are determined by combining the maximum scores from the two tests, and the entity relation tuple is output. The query element represents a formatted question. <e>The entity and relation r that are replaced.

[0270] For example: binary set query: <number of users across the entire company by network age - revenue - integration - channel - billing users, by billing>.

[0271] Step S54, query the set of binary tuples.

[0272] The highest score generated in steps S51 to S52 This is called a query. For each node v in the query, all nodes connected to v with any relation are collected to generate a subgraph (i.e., a query subgraph) associated with the original query. The generated query contains the answer path that can answer the retrieval question Q, and the question-and-answer retrieval is complete; otherwise, proceed to step S55.

[0273] Step S55, the entity set connected to the query.

[0274] Perform entity linking on this subgraph to identify all entities not in the query that are connected to the outermost entity in the subgraph formed by the query.

[0275] Step S56: n-gram matching entities, calculate scores.

[0276] The matching score between each n-gram in the retrieval question Q and the entity c in the entity set is calculated by detecting the maximum overlapping character sequence.

[0277] Step S57: Determine if the matching score is greater than the threshold. If the matching score is greater than the threshold, then the constraint entities c and r will be... c Add to the query; otherwise, output the final query subgraph, which also contains the path answer.

[0278] The matching score between each n-gram in the retrieval question q and the entity c is calculated by detecting the maximum overlapping character sequence.

[0279] Steps S51 to S57 above propose a query graph generation method for two-part relation detection. This method first detects relations with high confidence in the current retrieval, and then reorders different central entities based on whether the central entity can be connected to these relations. Then, it performs relation detection again based on different central entities to find the answer path. This method can be performed without relying on knowledge graph traversal calculation, starting from the central entity of the question, focusing on the generation of local subgraphs, and gradually exploring the answer path to generate the answer corresponding to the question.

[0280] Combining the two parts above can improve the existing network, enhance its information extraction capabilities, and enable the model to consider not only the overall information of entities and relationships, but also local information. It also optimizes the query graph generation process, changing from single generation to two-stage generation, and gradually covers the search until the answer entity and path of the search query are obtained.

[0281] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of actions. However, those skilled in the art should understand that the embodiments of the present invention are not limited to the described order of actions, because according to the embodiments of the present invention, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions involved are not necessarily essential to the embodiments of the present invention.

[0282] Reference Figure 9 The diagram shows a schematic representation of a query graph generation device according to an embodiment of the present invention, which may specifically include the following modules:

[0283] Data acquisition module 901 is used to acquire the first query question and the relation detection model for relation detection based on the query question;

[0284] Link entity generation module 902 is used to determine multiple link entities of the first query query;

[0285] The first relationship detection module 903 is used to perform relationship detection on the first query question through the relationship detection model, sort the plurality of link entities, and determine the target link entity set from the plurality of link entities;

[0286] The query statement formatting module 904 is used to generate a second query statement based on the first query statement, wherein the second query statement is generated by formatting each entity in the first query statement;

[0287] The second relation detection module 905 is used to perform relation detection on the second query question through the relation detection model, generate a set of binary tuples of target link entities, and generate a query graph based on the set of binary tuples, wherein the target link entities are the link entities in the set of target link entities.

[0288] In one embodiment of the present invention, the first relationship detection module 903 may include:

[0289] The first score information determination submodule is used to determine the first score information of each link entity among the plurality of link entities;

[0290] The relation set determination submodule is used to determine the first relation set and the associated second relation set for each linked entity based on a preset knowledge graph.

[0291] The second score determination submodule is used to perform relationship detection on the first query statement with the first relationship set and the second relationship set respectively using the relationship detection module, and generate second score information for reliable relationships for each linked entity;

[0292] The target score determination submodule is used to determine the target score information for each linked entity based on the first score information and the second score information;

[0293] The target link entity set determination submodule is used to determine the target link entity set from the plurality of link entities based on the target score information sorted from high to low.

[0294] In one embodiment of the present invention, the second score determination submodule includes:

[0295] The first question vector determination unit is used to determine the first question vector information of the first query question.

[0296] The first relation vector determination unit is used to determine the first relation vector information of each first relation in the first relation set;

[0297] The second relation vector determination unit is used to determine the second relation vector information of each second relation in the second relation set;

[0298] The second score information determination unit is used to generate second score information for reliable relationships for each linked entity based on the first question vector information, the first relationship vector information, and the second relationship vector information.

[0299] In one embodiment of the present invention, the second score information determination unit may include:

[0300] The first cosine similarity information determination subunit is used to determine the first cosine similarity information between the first question vector information and the first relation vector information;

[0301] The second cosine similarity information determination subunit is used to determine the second cosine similarity information between the first question vector information and the second relation vector information;

[0302] The first relation subset determination subunit is used to determine the first relation subset of the first relation set according to the sorting of the first cosine similarity information from high to low.

[0303] A reliable relation set determination subunit is used to obtain a reliable relation set based on the first relation subset and the second relation set;

[0304] The second score information determination subunit is used to generate second score information for reliable relationships for each linked entity based on the reliable relationship set, the first cosine similarity information, and the second cosine similarity information.

[0305] In one embodiment of the present invention, the second relationship detection module 905 may include:

[0306] The third score determination submodule is used to perform relationship detection on the second query and the second relationship set using the relationship detection module, and generate third score information for the relationship of each link entity in the target link entity;

[0307] The target link entity determination submodule is used to determine the target link entity from the target link entity set based on the third score information and the target score information.

[0308] In one embodiment of the present invention, the second relationship detection module 905 may include:

[0309] The query subgraph generation submodule is used to generate a query subgraph of the target linked entity based on a preset knowledge spectrum graph;

[0310] The associated entity determination submodule is used to determine, based on the preset knowledge graph, associated entities that are not in the query subgraph and are connected to the outermost target entity in the query subgraph when no query result corresponding to the first query question is found in the query subgraph.

[0311] The query graph generation submodule is used to add the associated entity and the associated relationship corresponding to the associated entity to the query subgraph to generate a query graph when the matching degree between the relational entity and the first query question is greater than a preset matching degree threshold.

[0312] In one embodiment of the present invention, the device further includes:

[0313] The target query vector information determination module is used to acquire the target query for training the relation detection model, and determine the target query vector information of the target query based on the preset representation parameters of the relation detection model.

[0314] The hierarchical vector determination submodule is used to determine the relation-level word segmentation information and word-level word segmentation information of the target query, and to determine the relation-level word segmentation vector information of the relation-level word segmentation information and the word-level word segmentation vector information of the word-level word segmentation information based on the representation parameters of the preset relation detection model;

[0315] The target relation vector information determination module is used to generate target relation vector information of the target query question based on the relation-level word segmentation vector information and the word-level word segmentation vector information.

[0316] The target cosine similarity information determination submodule is used to determine the target cosine similarity information between the target question vector information and the target relationship vector information;

[0317] The characterization parameter adjustment module is used to adjust the characterization parameters based on the target cosine similarity information.

[0318] One embodiment of the present invention also provides a server, which may include a processor, a memory, and a computer program stored in the memory and capable of running on the processor. When the computer program is executed by the processor, it implements the above-described query graph generation method.

[0319] An embodiment of the present invention also provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, it implements the method for generating the query graph as described above.

[0320] As the device embodiment is basically similar to the method embodiment, the description is relatively simple, and relevant parts can be found in the description of the method embodiment.

[0321] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.

[0322] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, apparatus, or computer program products. Therefore, embodiments of the present invention can take the form of entirely hardware embodiments, entirely software embodiments, or embodiments combining software and hardware aspects. Furthermore, embodiments of the present invention can take the form of computer program products implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0323] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing terminal device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal device, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0324] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing terminal device to operate in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0325] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal equipment, causing a series of operational steps to be performed on the computer or other programmable terminal equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable terminal equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0326] Although preferred embodiments of the present invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of the embodiments of the present invention.

[0327] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or terminal device. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or terminal device that includes said element.

[0328] The above provides a detailed description of the query graph generation method, apparatus, electronic device, and storage medium. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, those skilled in the art will recognize that, based on the ideas of the present invention, there will be changes in the specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation of the present invention.< / e> < / e> < / e> < / e> < / e> < / e>

Claims

1. A method for generating a query graph, characterized in that, The method includes: Obtain the first query statement and the relation detection model for performing relation detection on the query statement; Identify the multiple linked entities of the first query; The relationship detection model is used to detect the relationship in the first query, and the multiple link entities are sorted to determine the target link entity set from the multiple link entities. A second query is generated based on the first query, wherein the second query is generated by replacing each link entity in the target link entity set of the first query with a preset format marker; The second query is subjected to relation detection using the relation detection model, target link entities are determined from the target link entity set, and a query graph is generated based on the target link entities. The step of performing relation detection on the first query using the relation detection model and sorting the plurality of link entities to determine the target link entity set from the plurality of link entities includes: Determine the first score information for each of the plurality of linked entities; Based on a preset knowledge graph, a first set of relations and an associated second set of relations are determined for each linked entity; wherein, the first set of relations is the relations between entities within a subgraph formed by each linked entity, and the second set of relations is the relations between entities within a subgraph formed by each linked entity and the relations between entities in the subgraph and entities outside the subgraph; Determine the first query vector information of the first query; Determine the first relation vector information for each first relation in the first relation set; Determine the second relation vector information for each second relation in the second relation set; Determine the first cosine similarity information between the first question vector information and the first relation vector information; Determine the second cosine similarity information between the first question vector information and the second relation vector information; Based on the sorting of the first cosine similarity information from high to low, determine the first relation subset of the first relation set; The target relation set is obtained by taking the intersection of the first relation subset and the second relation set. Based on the target relation set, the first cosine similarity information, and the second cosine similarity information, a second score is generated for each linked entity. Based on the first score information and the second score information, determine the target score information for each linked entity; Based on the ranking information of the target scores from high to low, a target link entity set is determined from the plurality of link entities.

2. The method according to claim 1, characterized in that, The step of performing relation detection on the second query using the relation detection model, and determining the target link entities from the target link entity set, includes: The relationship detection model is used to perform relationship detection on the second query and the second relationship set, and a third score information for the relationship of each link entity in the target link entity is generated. Based on the third score information and the target score information, the target link entity is determined from the target link entity set.

3. The method according to claim 1 or 2, characterized in that, The generation of the query graph based on the target link entity includes: Generate a query subgraph of the target linked entities based on a preset knowledge graph; When no query result corresponding to the first query question is found in the query subgraph, the associated entities that are not in the query subgraph are determined based on the preset knowledge graph; When the matching degree between the associated entity and the first query is greater than a preset matching degree threshold, the associated entity and the corresponding relationship of the associated entity are added to the query subgraph to generate a query graph.

4. The method according to claim 1 or 2, characterized in that, The training steps of the relationship detection model include: Obtain the target query statement used to train the relation detection model, and determine the target query statement vector information based on the preset representation parameters of the relation detection model; The relation-level word segmentation information and word-level word segmentation information of the target query are determined, and based on the representation parameters of the preset relation detection model, the relation-level word segmentation vector information of the relation-level word segmentation information and the word-level word segmentation vector information of the word-level word segmentation information are determined; Based on the relation-level word segmentation vector information and the word-level word segmentation vector information, generate the target relation vector information of the target query question; Determine the target cosine similarity information between the target question vector information and the target relation vector information; The representation parameters are adjusted based on the target cosine similarity information.

5. A query graph generation apparatus, characterized in that, The device includes: The data acquisition module is used to acquire the first query question and the relation detection model for relation detection based on the query question; The link entity generation module is used to determine multiple link entities for the first query query. The first relationship detection module is used to perform relationship detection on the first query statement through the relationship detection model, and to sort the plurality of link entities in order to determine the target link entity set from the plurality of link entities; The query statement formatting module is used to generate a second query statement based on the first query statement, wherein the second query statement is generated by replacing each link entity in the target link entity set of the first query statement with a preset format marker; The second relationship detection module is used to perform relationship detection on the second query question through the relationship detection model, determine the target link entity from the target link entity set, and generate a query graph based on the target link entity; The first relationship detection module includes: The first score information determination submodule is used to determine the first score information of each link entity among the plurality of link entities; The relation set determination submodule is used to determine a first relation set and an associated second relation set for each linked entity based on a preset knowledge graph; wherein, the first relation set is the relationship between entities within a subgraph formed by each linked entity, and the second relation set is the relationship between entities within a subgraph formed by each linked entity and the relationship between entities in the subgraph and entities outside the subgraph; The second score determination submodule is used to perform relationship detection on the first query with the first relationship set and the second relationship set respectively using the relationship detection module, and generate second score information for each linked entity; The target score determination submodule is used to determine the target score information for each linked entity based on the first score information and the second score information; The target link entity set determination submodule is used to determine the target link entity set from the plurality of link entities based on the sorting information from high to low of the target score information; The second score determination submodule includes: The first question vector determination unit is used to determine the first question vector information of the first query question. The first relation vector determination unit is used to determine the first relation vector information of each first relation in the first relation set; The second relation vector determination unit is used to determine the second relation vector information of each second relation in the second relation set; The second score information determination unit is used to generate second score information for reliable relationships for each linked entity based on the first question vector information, the first relationship vector information, and the second relationship vector information. The second score information determination unit includes: The first cosine similarity information determination subunit is used to determine the first cosine similarity information between the first question vector information and the first relation vector information; The second cosine similarity information determination subunit is used to determine the second cosine similarity information between the first question vector information and the second relation vector information; The first relation subset determination subunit is used to determine the first relation subset of the first relation set according to the sorting of the first cosine similarity information from high to low. The target relation set determination subunit is used to take the intersection of the first relation subset and the second relation set to obtain the target relation set; The second score information determination subunit is used to generate second score information for reliable relationships for each linked entity based on the target relationship set, the first cosine similarity information, and the second cosine similarity information.

6. A server, characterized in that, It includes a processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein the computer program, when executed by the processor, implements a query graph generation method as described in any one of claims 1 to 4.

7. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium, which, when executed by a processor, implements a query graph generation method as described in any one of claims 1 to 4.