Treatment method
By constructing a graph of initial and target nodes in the knowledge graph question-answering system, the problems of low answer accuracy and high computational cost in existing technologies are solved, achieving efficient and accurate answer generation and low-cost computation, thus improving the system's versatility.
Patent Information
- Application Number
- CN202511151665.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-15
- Publication Date
- 2025-12-19
AI Technical Summary
Existing knowledge graph question answering (KGQA) systems suffer from problems such as low answer accuracy, high computational cost, low processing efficiency, and poor versatility, especially in large-scale graphs where it is difficult to accurately locate the context containing the answer.
By determining initial nodes based on user input, constructing a second graph using the first matching degree, and filtering target nodes based on the second matching degree of expanded nodes, a third graph is finally constructed. This reduces the size of the knowledge graph, thereby improving the accuracy of answers and computational efficiency, and reducing human intervention.
It improves the accuracy and computational efficiency of answers in knowledge graph question answering systems, reduces computational costs, enhances the versatility of the method, and reduces the need for human intervention.
Smart Images

Figure CN121168596A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of information technology, and particularly relates to a processing method. BACKGROUND
[0002] Knowledge Graph based Question-Answering (KGQA) has obvious advantages in the field of intelligent question answering. Since the problem semantics can be deeply mined, the reasoning process and logical relationship can be visually displayed, and the answer with better explainability can be generated, the KGQA can reduce the labor cost while improving the operation efficiency, and thus is widely applied in the fields of knowledge reasoning, root cause analysis and problem positioning.
[0003] The core of the KGQA is to find the context related to the question and answer in the graph, but since the information granularity of the entity (i.e. the node) in the knowledge graph is small and atomized, the KGQA in the related technology has the problems of low efficiency, high calculation cost and low accuracy of the answer. SUMMARY
[0004] Therefore, the embodiments of the present application provide at least a processing method.
[0005] The technical scheme of the embodiments of the present application is implemented as follows:
[0006] The processing method provided by the embodiments of the present application comprises:
[0007] In response to a user input, a second graph is determined based on at least one initial node in a first graph. The initial node is determined based on a first matching degree between each node in the first graph and a target input, the target input is determined based on the user input, and the second graph comprises the initial node and at least one extended node in the first graph which is in the same path as the initial node;
[0008] At least one target node is determined from the extended nodes based on a second matching degree between each extended node in the second graph and the target input;
[0009] A third graph is determined based on the initial node and the target node;
[0010] A target output corresponding to the target input is determined and output to the user based on the third graph.
[0011] It should be understood that the above general description and the following detailed description are only exemplary and explanatory, but not limiting the technical scheme of the present application. BRIEF DESCRIPTION OF DRAWINGS
[0012] Figure 1An implementation flow of a processing method provided by an embodiment of the present application is shown Figure 1 ;
[0013] Figure 2 An implementation flow of a processing method provided by an embodiment of the present application is shown Figure 2 ;
[0014] Figure 3 An assembly structure diagram of a processing device provided by an embodiment of the present application is shown
[0015] Figure 4 An assembly structure diagram of an electronic device provided by an embodiment of the present application is shown. DETAILED DESCRIPTION
[0016] In order to make the objectives, technical solutions and advantages of the present application clearer, the technical solutions of the present application are further described in detail below in conjunction with the accompanying drawings and embodiments, and the described embodiments should not be regarded as limiting the present application, and all other embodiments obtained by those skilled in the art without making creative efforts fall within the scope of protection of the present application.
[0017] In the following description, the terms "first / second / third" are merely to distinguish similar objects, and do not represent a specific order of the objects. Understandably, the "first / second / third" can be interchanged with a specific order or sequence as allowed, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein. Unless otherwise defined, all technical and scientific terms used herein have the same meaning as understood by those skilled in the art to which the present application belongs. The terms used herein are only for the purpose of describing the present application and are not intended to limit the present application. In addition, it should be noted that only parts related to the present application are shown in the drawings for ease of description.
[0018] A knowledge graph is a structured semantic network composed of entities (i.e., nodes) and relationships between entities (i.e., edges), used to represent concepts, things and their associated relationships in the real world, and widely applied in intelligent question answering, recommendation systems, natural language processing and other fields.
[0019] In the processing process of question answering based on a knowledge graph, the final complete answer needs to integrate information contained in multiple graph entities and relationships between entities, and the similarity of entities and / or relationships containing information required by the answer to the question itself is not necessarily the highest.
[0020] Exemplarily, in the case of the question "Server port cannot be accessed due to firewall restrictions. Who to solve?", entities in the knowledge graph such as "server", "network port", and "firewall" can be matched by text similarity, but the answer required by the user is essentially the technical personnel responsible for operation and maintenance, or the network security approval department that can solve the problem. In this way, matching all nodes in the knowledge graph separately is low in efficiency and the accuracy of the retrieved answer is also low.
[0021] Therefore, it is difficult to accurately locate the context (entities in the graph, relationships between entities, and / or attributes of entities, etc.) containing the answer based on only the traditional information retrieval method to analyze the question.
[0022] In the related art, the following solutions exist for KGQA:
[0023] 1) Query expansion and pattern matching based method: convert the user question into a logical query statement to capture the question semantics. This method requires a large number of manually constructed query patterns and rule templates, and has poor generalization.
[0024] 2) Simple graph search based method: use the breadth-first search algorithm (BFS) or the depth-first search algorithm (DFS) to traverse the knowledge graph to find nodes and / or relationships that may contain the answer. This method has the problem of low accuracy due to missing important information or introducing irrelevant information, and the method is affected by the size of the graph, and in the case of a large graph, the processing efficiency is low.
[0025] 3) Deep learning method based on graph neural network: use graph neural network (GNN) or pre-trained model for graph entity (i.e. node) linking and relationship matching. This method requires a large amount of labeled data for training, has high computational complexity, and is difficult to adapt to different domains or new query types.
[0026] 4) End-to-end large language model (LLM) guided expansion: current KGQA based on LLM mostly uses an iterative method of calling LLM and guiding subgraph expansion to generate answers. This method requires high-frequency calling of LLM in the iteration process, and has high computational cost.
[0027] In summary, the main defects of the existing KGQA solutions include: low accuracy of answers; dependence on manual work, poor generality; high computational cost; low processing efficiency, etc.
[0028] Embodiments of the present application provide a processing method, which can be executed by an electronic device. The electronic device can be a server, a notebook computer, a tablet computer, a desktop computer, a smart television, a set-top box, a mobile device (such as a mobile phone, a portable video player, a personal digital assistant, a dedicated messaging device, a portable game device), or any other device with data processing capability. As shown in FIG. 13, the processing method includes the following steps S101-S104: Figure 1
[0029] In step S101, in response to a user input, a second graph is determined based on at least one initial node in a first graph. The initial node is determined based on a first matching degree between each node in the first graph and a target input. The target input is determined based on the user input. The second graph includes the initial node and at least one extended node in the first graph that is in the same path as the initial node.
[0030] Here, the user input represents a user's inquiry request, which can be input content corresponding to the user's input operation of inquiry. For example, the user input can be content directly input by the user, or input data obtained by processing the user input. The form of the user input can include, but is not limited to, text, audio, video, and / or image. For example, the user input can include at least one of input text, input audio, input text obtained by converting input audio to text, input image, text information in the input image, input video, and image information in the input video.
[0031] The target input can be the user input or input data obtained based on the user input. For example, the target input can include, but is not limited to, at least one of the user input, a named entity extracted from the user input, a keyword or noun phrase extracted from the user input, and a text similar in meaning to the text extracted from the user input (such as a synonym or a translated word).
[0032] In some embodiments, the user input can be input by the user through an inquiry interface. The inquiry interface can include, but is not limited to, at least one of an inquiry interface, an application program with inquiry function, and an artificial intelligence model.
[0033] The first graph can include a complete knowledge graph as prior knowledge.
[0034] By way of example, the knowledge graph can be defined as a graph structure KG, and KG=(V, E).
[0035] Wherein, V is the set of nodes in the graph structure KG. Each node v in the set V can represent an entity or concept in the knowledge graph. Each node v can have a name of string or numeric type, and at least one attribute. The attribute can include, but is not limited to, the type of the node, the characteristics of the node and / or description, etc.
[0036] E is the set of edges in the graph structure KG. Each edge e in set E represents a relationship between entities and connects two entities. Edges can be directed, for example, e = (v1, v2), that is, edge e can be an edge from node v1 to node v2, or they can be undirected, indicating a bidirectional relationship between entities. Each edge e has attributes, which can include, but are not limited to, the type of relationship and / or weight.
[0037] The fact that the extended node and the initial node are on the same path indicates that the initial node and the corresponding extended node are directly connected in the second graph by an edge, or indirectly connected by an edge sequence containing multiple edges.
[0038] Matching degree is an indicator used to measure the degree of relevance between nodes or relationships in a knowledge graph and user input or its corresponding target input or user query request. It represents the correlation between the two. The higher the matching degree, the more similar or related the two are.
[0039] In some implementations, the first matching degree can be used to characterize the degree of text-level correlation between nodes in the first graph and the target input.
[0040] Understandably, since the nodes in the second and third graphs all originate from the first graph, the first matching degree can also be used to characterize the text-level correlation between the nodes in the second and third graphs and the target input.
[0041] Step S102: Based on the second matching degree between each extended node in the second graph and the target input, determine at least one target node from each extended node.
[0042] Here, the second matching degree can be used to characterize the correlation between the extended node in the second graph and the user query request corresponding to the target input, or the probability that the large model generates the target output based on the extended node, which is also the probability that the extended node is selected as the target node. The second matching degree and the first matching degree represent different dimensions of the correlation with the target input.
[0043] In some implementations, the second matching degree can be obtained by evaluating the semantic relevance between each extended node in the second graph and the target input.
[0044] In some embodiments, determining the at least one target node from the each extended node based on the second matching degree between the each extended node and the target input can comprise at least one of:
[0045] determining the extended node in the second graph with the second matching degree between the extended node and the target input being greater than a second matching degree threshold as the target node;
[0046] ordering the each extended node in the second graph according to the second matching degree between the each extended node and the target input from high to low to obtain a second node sequence; and determining the first target number of extended nodes in the second node sequence as the target node.
[0047] In some embodiments, the second matching degree between the each extended node in the second graph and the target input can be determined based on a semantic similarity between the each extended node and the target input, and an intent similarity between the each extended node and the target input. The semantic similarity can correspond to the first matching degree described above, for example, can be a text vector similarity.
[0048] For example, the semantic similarity between the each extended node and the target input and the intent matching degree between the extended node and / or the relationship related to the extended node and the user query request corresponding to the target input can be weighted and aggregated to obtain the second matching degree between the each extended node and the target input.
[0049] In some embodiments, the step S102 described above can comprise the following steps S1021 to S1023:
[0050] Step S1021, determining a candidate target node from the initial node in the second graph;
[0051] Step S1022, determining a candidate matching degree between the each candidate target node and the target input based on the second matching degree between the each extended node in the second graph and the target input; the candidate target node is determined based on the extended node;
[0052] Step S1023, determining the at least one target node from the each candidate target node based on the candidate matching degree between the each candidate target node and the target input.
[0053] For example, after determining the initial node, further obtaining an initial node set V initial consisting of the initial node, all initial nodes v s ∈V initial can be added to a target node set V target corresponding to the target subgraph (i.e. the third graph in step S103) consisting of the initial node and the target node;
[0054] Then, starting from the initial node, the extended node to be investigated is selected as a candidate target node;
[0055] Determine each candidate target node v c ∈V candidates The candidate matching degree between the target input and the target node;
[0056] The candidate target node whose candidate matching degree meets the screening condition is determined as the target node, and is added to the target node set V target ;
[0057] Finally, based on the initial node and all target nodes in the target node set V target , a third graph is constructed.
[0058] Exemplarily, the way of determining the candidate target node can include at least one of the following:
[0059] All extended nodes of the second graph, or at least one extended node, are determined as the candidate target node;
[0060] In the process of iteratively expanding and constructing the third graph through multiple rounds, for each round, the candidate target node corresponding to the round is determined respectively, so as to further determine the target node corresponding to the round based on the candidate target node corresponding to each round respectively.
[0061] In implementation, for the way of constructing the third graph through multiple rounds of expansion, in the process of determining the target node, the above step S1021 can include the following step S10211:
[0062] Step S10211, starting from the initial node, for each round, based on the determined target node, the candidate target node of the round is determined in a set manner;
[0063] The above step S1023 can include the following steps S10231 to S10232:
[0064] Step S10231, for each round, based on the candidate matching degree of the candidate target node, the target node corresponding to the round is determined from the candidate target node corresponding to the round according to the set screening condition, and is added to the target node set;
[0065] Step S10232, after iteration round by round, in the case of meeting the set termination condition, the expansion process is ended, and a third graph is constructed according to the initial node and all target nodes in the target node set.
[0066] In each round, the manner of determining the candidate target node can be that, all the adjacent nodes of the newly added target node in the target node set which are directly connected to the newly added target node in the target node set in the last round of expansion (i.e. 1-hop), and not in the target node set, are taken as the candidate target nodes to be investigated in this round, i.e. the manner of hop-by-hop expansion.
[0067] In some embodiments, the candidate matching degree of the candidate target node can be determined based on the second matching degree of the expansion node in the second graph; the candidate matching degree can be used to represent the correlation between the candidate target node and the user query request corresponding to the target input, and in the manner of constructing the third graph through multiple rounds of expansion, the expansion potential of the candidate target node can also be represented.
[0068] For example, in the manner of constructing the third graph through multiple rounds of expansion, the candidate matching degree corresponding to the candidate target node can be determined based on the second matching degree corresponding to the candidate target node and the second matching degrees corresponding to the uninvestigated expansion nodes in the same path as the candidate target node.
[0069] Step S103, determining the third graph based on the initial node and the target node.
[0070] Here, after obtaining the initial node and the target node, the third graph can be constructed based on the initial node, the target node and the relationship between the nodes.
[0071] Step S104, determining and outputting the target output corresponding to the target input to the user based on the third graph.
[0072] It can be understood that, since the target node is an expansion node different from the initial node selected from the second graph based on the second matching degree, in the case where the third graph is constructed based on the initial node and the target node, the number of nodes of the third graph is less than the number of nodes of the second graph, and less than the number of nodes of the first graph, and the size of the third graph is less than the size of the second graph, and less than the size of the first graph.
[0073] Here, the third graph as the context subgraph corresponding to the user input contains the core information of the question corresponding to the user input, i.e. the basis for generating the final answer.
[0074] Since the target input is determined based on the user input, the target output corresponds to the user input, and the target output can be the final answer corresponding to the user input.
[0075] In some embodiments, the target processing model can be used to determine and output the target output corresponding to the target input to the user based on the third graph.
[0076] For example, the target output can be determined and output to the user based on the third graph by a large language model or an artificial intelligence model.
[0077] In the embodiments of the present application, the initial node determined based on the first matching degree between the target input and the first graph is used to expand the node, the target node is determined based on the second matching degree between the expanded node and the target input, and the target output corresponding to the target input is determined based on the third graph composed of the initial node and the target node. In this way, on the one hand, the relevance between the target output and the target input determined based on the user input can be improved based on the first matching degree and the second matching degree, and the accuracy of the target output, i.e., the accuracy of the answer in the knowledge graph-based question and answer scenario, is further improved. On the other hand, the knowledge range for determining the target output can be reduced by reducing the scale of the knowledge graph twice, and the computing efficiency is improved while the computing cost is reduced. On the other hand, the present solution does not require human intervention and does not need to be trained and learned, thereby saving manpower and improving the universality of the method.
[0078] In some embodiments, before the determination of the second graph based on at least one initial node in the first graph in step S101 described above, the processing method can further include step S111:
[0079] Step S111, determining the target input.
[0080] Here, the target input can be a text or a text set containing at least one text.
[0081] For example, the original text corresponding to the user input (i.e., the question) can be represented as q, and the target input can be represented as a text set Text(q).
[0082] In some embodiments, the target input includes the user input, at least one named entity, and / or at least one noun phrase, and the processing method can further include at least one of the following steps S1111 to S1112:
[0083] Step S1111, performing named entity recognition on the user input to obtain the named entity in the user input.
[0084] A named entity (Named Entity) is an entity with specific meaning in a natural language text. For example, the named entity can include but is not limited to at least one of a person name, a place name, an organization name, a time, a date, a currency amount, etc. The named entity usually has uniqueness or identifiability and can be used as a key node in the construction of a knowledge graph. For example, “a company” can be an organization name, “Beijing” can be a place name, and “2024” can be time information.
[0085] In some embodiments, a set of named entities can be extracted from the user input by a named entity recognition (NER) technique.
[0086] Exemplarily, in a case where the original text corresponding to the user input (i.e., the question) is q, the set of named entities corresponding to the question q can be denoted as NE(q).
[0087] It can be understood that, in a case where no named entity exists in the user input after performing the named entity recognition on the user input, the set of named entities is an empty set.
[0088] Step S1112, performing a syntax analysis on the user input to obtain a noun phrase in the user input.
[0089] A noun phrase is a linguistic unit composed of one or more nouns and their modifiers, used to express a specific thing, concept or event. For example, in the question “Server port cannot be accessed due to firewall restriction, who to solve?”, “server port” can be a noun phrase expressing the core object of the question.
[0090] In some embodiments, a set of noun phrases can be extracted from the user input by a syntax analysis technique.
[0091] Syntax analysis is a process of parsing sentence structure, aiming to identify the grammatical relationships between words in a sentence, such as subject-predicate-object structure, state-complement-supplement relationship, etc. Through syntax analysis, structured information such as noun phrases, verb phrases, etc. in the sentence can be extracted.
[0092] Exemplarily, in a case where the original text corresponding to the user input (i.e., the question) is q, the set of noun phrases corresponding to the question q can be denoted as NP(q).
[0093] It can be understood that, in a case where no noun phrase exists in the user input after performing the syntax analysis on the user input, the set of noun phrases is an empty set.
[0094] In some embodiments, the target input can be a set of texts including the user input, each element in the set of named entities, and each element in the set of noun phrases.
[0095] Exemplarily, in a case where the original text corresponding to the user input (i.e., the question) is q, the target input can be denoted as a set of question-related texts Text(q). The composition of Text(q) can be referred to formula (1):
[0096] Text(q) = {q} ∪ NE(q) ∪ NP(q) (1).
[0097] In the embodiments of the present application, the user input is expanded to a target input containing a named entity and / or a noun phrase. In this way, the relevance of the nodes in the first graph to the user input can be more comprehensively evaluated according to the multi-faceted information corresponding to the user input, i.e., the target input, thereby improving the accuracy of the first matching degree, further improving the accuracy of the target output obtained based on the third graph composed of the initial nodes, and improving the user experience.
[0098] In some embodiments, before determining the second graph based on at least one initial node in the first graph in step S101, the processing method can further include step S112:
[0099] Step S112, determining a first matching degree between each node in the first graph and the target input.
[0100] The first matching degree is used to represent the text correlation degree between the nodes in the first graph and the target input. For example, the first matching degree can be determined based on the text vector similarity.
[0101] For example, the first text vector corresponding to each node in the first graph and the second text vector corresponding to the target input can be obtained, and the first matching degree between each node in the first graph and the target input can be obtained by determining the text vector similarity between the first text vector and the second text vector.
[0102] For example, the nodes in the knowledge graph can be represented as v, and v e V. Each node v corresponds to a respective node name and a text description (textual explanation) or additional attribute information of the node. In this case, the node name and the text description or additional attribute information of the node can be directly concatenated as the text content text(v) corresponding to the node v.
[0103] When calculating the text vector similarity, the text needs to be first represented as a vector. For example, a pre-trained language model (Bidirectional Encoder Representations from Transformers, BERT) can be used to complete this task.
[0104] For a text segment t, the text vector obtained after conversion by the BERT model can be represented as BERT(t).
[0105] In some embodiments, when calculating the semantic similarity between any two texts, a cosine similarity algorithm can be used.
[0106] For example, the process of calculating the semantic similarity between texts t1 and t2 using the cosine similarity algorithm can be seen in formula (2):
[0107]
[0108] wherein BERT(t1)·BERT(t2) is the inner product of vectors, and ||·|| represents the length of the vector.
[0109] In combination with formula (2), based on the text content corresponding to each node in the knowledge graph and the target input corresponding to the user input, the text vector similarity between each node in the knowledge graph and the target input is determined, and then the first matching degree between each node and the target input can be obtained.
[0110] Exemplarily, the process of determining the first matching degree similarity(v, q) between the node v in the knowledge graph and the target input Text(q) can refer to formula (3):
[0111]
[0112] wherein t q is a loop variable, and text(v) is the text content in Text(q); in the case where the target input contains multiple elements t q , text(v) can be calculated respectively with each element t q in Text(q), and the maximum value is selected as the final similarity(v, q). In this way, the semantic relationship between the user input and the node can be more comprehensively obtained, thereby reducing the problem of inaccurate evaluation of the first matching degree due to the dependence on partial text content.
[0113] It can be understood that the extended node is a node selected from the first graph, and therefore, in the case where the node v is an extended node, the semantic similarity similarity(v, q) between the node v and the target input Text(q) is the semantic similarity between the extended node and the target input.
[0114] In some embodiments, the above step S112 can include the following steps S1121 to S1122:
[0115] Step S1121, determining the first sub-matching degree, the second sub-matching degree and / or the third sub-matching degree between each node in the first graph and the user input, at least one named entity and / or at least one noun phrase, respectively.
[0116] Here, the first sub-matching degree can be used to represent the text correlation degree between each node in the first graph and the user input.
[0117] In some embodiments, the first sub-matching degree can be determined based on the text vector similarity between each node in the first graph and the user input.
[0118] For each named entity in the at least one named entity in the user input, a second sub-matching degree corresponding to the named entity can be used to represent a text correlation degree between each node in the first graph and the named entity.
[0119] In some embodiments, in the case where one user input corresponds to multiple named entities, for each node in the first graph, a second sub-matching degree between the node and each named entity can be obtained respectively.
[0120] In some embodiments, the second sub-matching degree can be determined based on a text vector similarity between each node in the first graph and the named entity.
[0121] For each noun phrase in the at least one noun phrase in the user input, a third sub-matching degree corresponding to the noun phrase can be used to represent a correlation degree between each node in the first graph and the noun phrase.
[0122] In some embodiments, in the case where one user input corresponds to multiple noun phrases, for each node in the first graph, a third sub-matching degree between the node and each noun phrase can be obtained respectively.
[0123] In some embodiments, the third sub-matching degree can be determined based on a text vector similarity between each node in the first graph and the noun phrase.
[0124] Step S1122, for each node in the first graph, the highest sub-matching degree among the first sub-matching degree, the second sub-matching degree and / or the third sub-matching degree corresponding to the node is determined as the first matching degree corresponding to the node.
[0125] Here, after the calculation of the above three sub-matching degrees is completed, the maximum value among the three sub-matching degrees is taken as the final first matching degree corresponding to each node. In this way, different expression manners of the user's question are comprehensively considered, and the most relevant matching dimension can be selected as the final evaluation basis.
[0126] For example, in the case where the text similarity between the node and the complete user input is not high, but the text similarity between the node and one named entity in the user input is high, the node can still be considered as a node with high matching degree with the user input. In this way, the deviation caused by single dimension evaluation can be reduced, and in the case where the user's input expression is not accurate enough, a node with high correlation with the key information can also be found.
[0127] In this way, the most relevant node to the user input can be quickly screened out in a large-scale knowledge graph, laying a foundation for subsequent second matching degree evaluation and sub-graph expansion.
[0128] In the embodiments of the present application, the user input is disassembled into multiple facets, and the corresponding sub-matching degrees are calculated respectively. In this way, on the one hand, the relevance of the nodes in the first graph to the user input can be more comprehensively evaluated, and the possibility of missing potential useful information can be reduced; on the other hand, this multi-angle matching degree determination method can improve the accuracy of selecting the initial node, provide more reliable input for subsequent second matching degree evaluation and construction of the third graph, and thus improve the processing efficiency and accuracy of obtaining the target output.
[0129] In some embodiments, the step S101 of determining the second graph based on at least one initial node in the first graph can include the following steps S113 to S115:
[0130] Step S113, determining the initial node.
[0131] The initial node selected from the first graph can serve as a seed node for subsequent expansion to obtain the second graph and the third graph.
[0132] The initial node serves as a basic node for expansion to obtain the second graph. Based on the initial node, the expansion of the node can obtain an expanded node, and the second graph can be constructed based on the initial node and the expanded node.
[0133] In some embodiments, the step S113 can include the following step S1131:
[0134] Step S1131, determining the node in the first graph whose first matching degree satisfies a matching degree condition as the initial node.
[0135] Here, the matching degree condition can represent a condition that the first matching degree corresponding to the node satisfies when the matching degree between the node and the target input is higher than a preset value. Based on the matching degree condition, the relevance of the initial node to the target input can be improved, i.e., the accuracy of the initial node can be improved. Moreover, since the second graph and the third graph are constructed based on the initial node, the accuracy of the second graph and the third graph can be further improved. In addition, since the final target output is determined based on the third graph, the accuracy of the final target output can be further improved.
[0136] In some embodiments, the matching degree condition can include at least one of the following:
[0137] The first matching degree corresponding to the node is greater than a first matching degree threshold value;
[0138] The first matching degree corresponding to the node is located in the first target number of nodes in the first node sequence; the first node sequence is obtained by sorting the nodes in the first graph according to the first matching degree between the nodes and the target input from high to low.
[0139] Exemplarily, in the case that the first matching degree is the first matching degree similarity(v, q) between the node v and the target input Text(q) in the above processing method, the process of selecting the initial node from the first graph can include the following steps S11311 to S11312:
[0140] Step S11311, determining the first matching degree similarity(v, q) between each node v in the first graph and the target input Text(q).
[0141] Step S11312, selecting the node whose first matching degree similarity(v, q) exceeds the first matching degree threshold θ or the node ranked in the top K according to the first matching degree similarity(v, q) as the initial node; K corresponds to the above first target number.
[0142] In implementation, in the case of determining the initial node according to the first matching degree threshold, the node whose first matching degree exceeds the first matching degree threshold θ can be represented as {v∈V∣similarity(v, q)≥θ}. Wherein, V is the node set of the first graph. The value of the first matching degree threshold θ can be determined according to actual conditions. Exemplarily, the value of θ can be 0.7.
[0143] In implementation, in the case of determining the initial node according to the first node sequence, the value of the target number K can be determined according to the actual size of the graph and the like. Exemplarily, the value of K can be 10.
[0144] Step S114, determining the extended node based on the initial node.
[0145] The extended node in the first graph which is in the same path as the initial node can include the extended node directly connected to the initial node through an edge in the first graph, or the extended node indirectly connected to the initial node through an edge sequence containing multiple edges.
[0146] For example, the extended node in the same path as the initial node can include the adjacent node of the initial node.
[0147] For another example, the extended node in the same path as the initial node can include the adjacent node of the adjacent node of the initial node.
[0148] In some embodiments, the extended node corresponding to each initial node can also be determined by the hop-by-hop expansion manner.
[0149] For example, for each initial node, the node jumped through a preset number of times from the initial node along the topology of the first graph and finally stopped at can be determined as the extended node corresponding to the initial node.
[0150] In some embodiments, the extended nodes corresponding to each initial node can be determined based on the matching degree between the nodes in the same path as the initial node and the target input.
[0151] For example, for each initial node, the nodes in all nodes in the same path as the initial node that satisfy the preset matching degree condition can be determined as the extended nodes corresponding to the initial node.
[0152] In some embodiments, the above step S114 can include the following step S1141:
[0153] Step S1141, based on the first graph, performing hop-by-hop expansion on each initial node along the path where the initial node is located to obtain the extended nodes.
[0154] For example, starting from the above initial node set V initial , a breadth-first search (BFS) method is used to perform hop-by-hop node expansion: when expanding each hop, the 1-hop adjacent nodes (nodes that have not been expanded) of the current obtained extended nodes in the first graph can be added to the extended node set formed by the extended nodes, and the node expansion can be stopped when the preset maximum expansion step (i.e., the hop number threshold) is reached, and / or all nodes to be expanded in the next hop already exist in the extended node set; further, the second graph is determined according to the obtained initial nodes and the extended nodes.
[0155] Step S115, determining the second graph based on the initial nodes and the extended nodes.
[0156] In some embodiments, the above step S115 can include the following step S1151:
[0157] Step S1151, constructing the second graph based on the initial nodes and the extended nodes; the number of nodes in the second graph is less than the number of nodes in the first graph.
[0158] Here, after obtaining all the extended nodes, the second graph is constructed based on the initial nodes and the extended nodes. The second graph is a subgraph structure relative to the original first graph, and is an intermediate graph obtained in the process of generating the third graph based on the first graph.
[0159] It can be understood that, since the extended nodes are different from the initial nodes and are selected from the first graph based on the first matching degree, when the second graph is constructed based on the initial nodes and the extended nodes, the number of nodes in the second graph is less than the number of nodes in the first graph, and the size of the second graph is less than the size of the first graph.
[0160] In the embodiments of the present application, by reducing the range of the searched knowledge graph and narrowing the input graph structure for model calculation, the calculation cost can be reduced, the information with low relevance can be removed, and the timeliness of the question and answer response can be improved.
[0161] In some embodiments, after the second graph is extracted from the first graph, a third graph can be determined based on the second graph; or the third graph can be directly extracted from the first graph, in which case the first graph is the second graph.
[0162] In some embodiments, the above processing method can further include the following step S121:
[0163] Step S121, determining a second matching degree between each extended node and the target input based on the semantic similarity between each extended node and the target input and the intention matching degree between each extended node and each extended node and the target input.
[0164] Here, the intention matching degree represents the degree of relevance between the nodes or relationships in the graph and the user inquiry request corresponding to the target input, and focuses on reflecting the degree of relevance between the nodes or relationships and the target output expected by the user. Therefore, based on the intention matching degree between the extended node and the target input, the accuracy of the second matching degree representing the degree of relevance between the extended node and the target input can be improved, and the accuracy of determining the third graph can be further improved.
[0165] For example, for the question "Server port cannot be accessed due to firewall restriction, who can solve it?", the text similarity between the entities such as "network port" or "server network port" and the question is high, but the core of solving the problem is "who can solve it", that is, the user demand (the target output expected by the user) actually corresponds to the nodes of personnel type and / or organizational structure type.
[0166] Therefore, the second matching degree obtained by combining the semantic similarity and the intention similarity can balance the text relevance of the extended node and the target input and the intention relevance of the extended node and the user input, thereby improving the relevance between the target node and the target input determined based on the second matching degree, reducing the problem of inaccurate evaluation of the second matching degree based on a single quantitative indicator, and further improving the quality and accuracy of the target output generated based on the third graph composed of the target node.
[0167] In some embodiments, before the above step S121, the above processing method can further include the following step S1211:
[0168] Step S1211, determining the intention matching degree between each node and the target input.
[0169] In some embodiments, the intent matching degree can be evaluated based on semantic types of the nodes or the relationships.
[0170] In some embodiments, the intent matching degree can be evaluated by using a large language model.
[0171] In some embodiments, when determining the second matching degree between each extended node and the target input based on the semantic similarity between each extended node and the target input, and the intent matching degrees between each extended node and the target input and between each extended node and each extended node, the semantic similarity can correspond to the first matching degree, for example, can be a text vector similarity.
[0172] In some embodiments, the advantages of LLM in natural language understanding can be used to determine the intent matching degrees between each node and relationship in the knowledge graph and the target input corresponding to the user input.
[0173] For example, the input of the LLM can include semantic type data corresponding to each node and / or relationship between each two nodes, and the user input; the LLM is used to evaluate the matching degree between each node and / or relationship between each two nodes and the query request expressed by the user input; the output of the LLM can include the intent matching degree score between each node and / or relationship between each two nodes and the user input. The semantic type data can include at least one of the semantic type name, the semantic type description, the data sample corresponding to the semantic type (such as text(v) in the above processing method), and the like.
[0174] For example, the semantic type data of node v in the knowledge graph can be represented as type(v), the relationship between node v1 and node v2 can be represented as e, and e=(v1,v2)∈E, and the semantic type data of the relationship e can be represented as type(e) or type(v1,v2).
[0175] For example, using LLM, the process of determining the intent matching degree intent(v,q) between node v and the target input corresponding to the user input q can refer to formula (4):
[0176] intent(v,q)=LLM(type(v),q) (4).
[0177] For example, using LLM, the process of determining the intent matching degrees intent(e,q) and intent(v1,v2,q) between the relationship e between node v1 and the adjacent node v2 of node v1 and the user query request corresponding to the user input q can refer to formula (5) or (6):
[0178] intent(e,q) = LLM(type(e),q) (5)
[0179] intent(v1,v2,q) = LLM(type(v1,v2),q) (6).
[0180] In the embodiments of the present application, the second matching degree between the expansion node and the target input is determined by introducing two evaluation dimensions of semantic similarity and intent matching degree. In this way, the relevance of the expansion node and the target input can be more comprehensively evaluated, and the possibility of the expansion node containing the target output can be more accurately evaluated, thereby optimizing the process of obtaining the final third graph based on the initial node for path expansion, improving the quality and accuracy of the third graph, and further improving the accuracy and processing efficiency of obtaining the target output based on the third graph.
[0181] The restart random walk model (hereinafter referred to as RWR model or RWR process) is a random process model in a graph structure, which can be used to measure the correlation or similarity between nodes in the graph structure. The feature is that when transferring between nodes based on the graph topology in each round, there is a certain probability to return to the starting point. This makes the final probability of each node in the graph integrate its graph centrality feature and the relevance with the starting point. This model is often used to identify context subgraph structures with strong relevance in the graph, and then used for information retrieval and recommendation tasks.
[0182] In some embodiments, the second matching degree can be calculated using the restart random walk model; the above step S121 can include the following step S1221:
[0183] Step S1221, in the second graph, using the restart random walk model, according to the semantic similarity between each expansion node and the target input, and the intent matching degree between each expansion node and each expansion node and the target input respectively, determine the second matching degree between each expansion node and the target input respectively.
[0184] Illustratively, the RWR model can be used to define the initial probability distribution of each expansion node based on the semantic similarity between each expansion node and the target input, define the transition probability based on the intent matching degree between each expansion node and each expansion node and the target input respectively, and further calculate the second matching degree between each expansion node and the target input based on the iteration of the model to convergence.
[0185] In some embodiments, the above step S121 can include the following steps S1211 to S1213:
[0186] Step S1211, based on the semantic similarity between each expansion node and the target input, determine the initial probability of expanding the nodes adjacent to the expansion node from each expansion node.
[0187] In step S1212, the transition probability of each expansion node to the adjacent node of each expansion node is determined based on the adjacent node of each expansion node and the matching degree between each expansion node and the target input.
[0188] In step S1213, the second matching degree between each expansion node and the target input is obtained by using the RWR model based on the initial probability and the transition probability of each expansion node.
[0189] In some embodiments, the initial probability distribution of each expansion node can be defined based on the semantic similarity between each expansion node and the target input by using the RWR model.
[0190] The iterative calculation formula of the RWR model can be seen from formula (7):
[0191] P m =(1-d)P m-1 W+dP0 (7);
[0192] wherein P0 is the initial probability distribution of each expansion node; P m is the target probability distribution of each expansion node after m rounds of random walk, and P m is an n-dimensional row vector, and the target probability of the expansion node v after m rounds can be expressed as P m (v); W is the transition probability matrix when randomly walking between each expansion node, and W is an n-row n-column matrix in the case of n expansion nodes, and the element w i,j in the i-th row and j-th column of W represents the transition probability from the expansion node v i corresponding to the i-th row to the expansion node v j corresponding to the j-th column; d is the restart probability in RWR (exemplarily, d can be 0.15), which represents the probability of returning to the starting node when each round of transition between the expansion nodes.
[0193] In some embodiments, the target probability corresponding to each expansion node can be finally obtained by iterative calculation based on the initial probability of each expansion node and the transition probability of each expansion node to the adjacent node of each expansion node by using the RWR model, and the second matching degree between each expansion node and the user inquiry request is determined based on the target probability corresponding to each expansion node.
[0194] Here, the initial probability distribution of each expansion node includes an initial probability corresponding to each expansion node respectively; for each expansion node, the initial probability is a probability of starting from the expansion node in a process of expanding nodes adjacent to the expansion node from the expansion node.
[0195] It can be understood that in the case that the initial probability is determined by the semantic similarity, the closer the semantics in the knowledge graph to the expansion node of the target input, the higher the possibility of the expansion node as a starting point for subgraph expansion. Therefore, based on the semantic similarity to determine the initial probability of starting from the expansion node, the expansion node with higher semantic relevance to the target input can be preferentially selected when expanding the node, so that by focusing on the subgraph with higher semantic relevance to the user input, the efficiency of the subsequent expansion node can be improved, and the accuracy of the target output obtained and the relevance to the user input can be improved.
[0196] In the embodiment of the application, the restart random walk model is used to further improve the second matching degree for evaluating the degree of relevance between each expansion node and the target input, thereby improving the accuracy of the target output obtained based on the third graph and the adaptability to the user input.
[0197] In some embodiments, the above processing method can further include the following step S131:
[0198] Step S131, determining the semantic similarity between each node in the second graph and the target input.
[0199] Here, since each expansion node in the second graph is a node in the first graph, in the case that the first matching degree between each node in the first graph and the target input determined in step S112 is the semantic similarity, the semantic similarity of the corresponding node can be directly used as the semantic similarity between the node in the second graph and the target input, and then the initial probability corresponding to each expansion node can be determined based on this.
[0200] The above step S1211 can include the following step S12112:
[0201] Step S12212, for each expansion node, based on the semantic similarity between the expansion node and the target input and the semantic similarity between each node in the second graph and the target input, determining the initial probability of starting from the expansion node in a process of expanding nodes adjacent to the expansion node from the expansion node.
[0202] In some embodiments, the initial probability can be normalized to make the sum of the initial probabilities of all nodes equal to 1, facilitating subsequent calculation.
[0203] Exemplarily, the calculation process of the initial probability P0(v) of the node v in the second graph can refer to formula (8):
[0204]
[0205] wherein, u is a loop variable, representing a node in the node set V of the second graph, ∑ u∈V similarity(u,q) is a normalization factor.
[0206] It can be understood that, based on the initial probability corresponding to each node in the second graph, the initial probability distribution P0 of each node in the second graph can be obtained, which includes the initial probability corresponding to each extended node respectively.
[0207] In the embodiment of the application, for each extended node, the initial probability from the extended node in the process of extending the nodes adjacent to the extended node starting from the extended node is determined according to the semantic similarity between the extended node and the target input, and the semantic similarity between each node in the second graph and the target input. In this way, the possibility of selecting each extended node as the starting point of subgraph expansion from all nodes in the second graph can be more accurately obtained, so that the initial relevance between each extended node and the user input in the semantic dimension is better reflected based on the initial probability of each extended node starting from other nodes in the second graph.
[0208] In some embodiments, the above step S1212 can include the following step S12121:
[0209] Step S12121, for each extended node, based on the adjacent nodes of the extended node, and the intention matching degree between the relationship between each adjacent node of the extended node and the target input, respectively, determine the transition probability of the extended node to the adjacent node of the extended node.
[0210] In implementation, based on the adjacent nodes of each extended node and the intention matching degree between the relationship between each extended node and its adjacent nodes and the target input, the transition probability of each extended node to each adjacent node of each extended node can be obtained.
[0211] It can be understood that, the higher the intention matching degree between the target input, the higher the degree of relevance to the target input, that is, the higher the degree of relevance to the user inquiry request, the higher the probability of the node with higher intention matching degree as the target node, and the higher the probability of transition from the adjacent node of the node to the node.
[0212] Here, the transition probability matrix of the extended nodes includes the transition probability of each extended node to its adjacent nodes; for each extended node, the transition probability is the probability that, in the RWR process, the adjacent node of the extended node is the next node in the random walk.
[0213] The intent matching degree between the adjacent nodes of the extended node and the target input is used to characterize the relevance of the entities or concepts represented by the adjacent nodes of the extended node to the user intent corresponding to the user query request of the target input. It is used to evaluate the degree of association between the context information of the extended node (i.e., the adjacent nodes of the extended node) and the target output. The higher the degree of association, the more likely it is that the adjacent node will be selected as the next hop extended node in the random walk process.
[0214] The relationships between the expanding node and its adjacent nodes, and the intent matching degree between the expanding node and the target input, are used to characterize the relevance of the relationships between the expanding node and its adjacent nodes (i.e., the edges in the graph) to the user intent corresponding to the user query request of the target input. Since the expanding node is connected to its adjacent nodes through relationships, the higher the correlation between these relationships and the target output, the more likely it is that the adjacent node will be selected as the next hop expanding node in the random walk process.
[0215] For example, when there is a "responsible for management" relationship between the node "Network Administrator" and the node "Firewall Configuration", the degree of relevance between the node "Firewall Configuration" and the relationship "responsible for management", and the user's intention to find the responsible person, will affect the degree of association between the node "Network Administrator" and the target output, i.e., the degree of intent matching.
[0216] In related technologies, the transition probability matrix W of the RWR model is usually the adjacency matrix of the graph, where the element w in the i-th row and j-th column is... i,j Only the existence of edges between nodes is considered. For example, the element w in the i-th row and j-th column can be considered... i,j Assigning a value of 1 or 0 indicates whether node v exists or not in the graph, respectively. i To node v j The edge.
[0217] In this scheme, the transition probability matrix W is redefined using the degree of intent matching between edges and adjacent nodes and user query requests as weights.
[0218] The element w in the i-th row and j-th column of the redefined transition probability matrix W i,j That is, expanding node v i Move to the extended node v j The transition probability can be calculated using formula (9):
[0219]
[0220] The definition of intent(·) is given in formulas (4) to (6). Specifically, intent(v i ,v j ,q) represents the expression for user input q, from node v i Departure to node v i The adjacent node v j The degree of matching between the relationship and the intent of the target input corresponding to the user input q; intent(v j (,q) represents node v for user input q. i The adjacent node v j The degree of intent matching between the user input q and the target input; N(v i ) is node v i The set of adjacent nodes, i.e., N(v) i )={u∣u∈V,(v i ,u)∈E};intent(v i (u, q) represents the expression for user input q, starting from node v i Departure to node v i The intent(u,q) represents the degree of matching between a certain adjacent node u and the target input corresponding to the user input q; intent(u,q) can represent the degree of matching between node v and the user input q. i The weight of a certain adjacent node u;
[0221] Let be the factor used for normalization, representing the normalization factor for user input q, and the normalization factor for node v. i The degree of intent matching between all adjacent nodes of the originating node and the target input corresponding to the user input q, and the degree of matching between these nodes and the connected node v. i The product of the relationship between the neighboring nodes and the intention matching degree of the target input corresponding to the user input q is summed so that the sum of the row probabilities of the modified adjacency matrix W is 1, that is, the sum of the probabilities of moving from any node to other nodes is 1.
[0222] In this embodiment, for each extended node, the intent matching degree between the extended node and its neighboring nodes, as well as the relationships between the extended node and each of its neighboring nodes, and the target input is considered. This allows for a more comprehensive evaluation of the matching degree between the extended node's neighboring nodes and the user's expected output within the knowledge graph structure. This approach not only considers the correlation between the extended node itself and the user input but also incorporates the semantic information of its neighboring nodes and the relationships between them, thereby improving the accuracy of the obtained transition probability from the extended node to the corresponding neighboring node and further enhancing the accuracy of the second matching degree.
[0223] In some embodiments, the step S1213 described above can include the following step S12131:
[0224] The step S12131 comprises: based on the initial probability corresponding to each extension node and the transition probability between each extension node, performing iterative calculation by using the RWR model to obtain the second matching degree between each extension node and the target input.
[0225] The iterative calculation process of the RWR model can refer to formula (7). It can be understood that in the iterative calculation process of the RWR model, the target probability of each extension node is updated in each iteration. With the iteration, the target probability of the extension node with high semantic correlation and high matching degree of the target input intent will gradually increase, and vice versa. The target probability of the extension node with low semantic correlation and / or low matching degree of the target input intent will gradually decrease. Thus, when the model converges, the target probability of each extension node can reflect the comprehensive correlation between it and the target input, i.e., the second matching degree.
[0226] Exemplarily, when the target probability of the node is iteratively calculated by formula (7), a convergence threshold (for example, ∈ = 10 -5 ) can be set. When ||P m -P m-1 ||<∈, it can be judged that the result converges in the Tth round and ends the iteration, and the target probability distribution P T of all nodes after the Tth round is the comprehensive correlation score of each node, i.e., the second matching degree.
[0227] Exemplarily, based on the target probability P T (v) obtained by the node v in the converged Tth round, the process of determining the second matching degree score(v) corresponding to the node v can refer to formula (10):
[0228] score(v)=TP T (v) (10).
[0229] In the embodiments of the present application, for each expansion node, an initial probability of expanding a node adjacent to the expansion node from the expansion node is determined based on a semantic similarity between the expansion node and the target input; a transition probability of the expansion node transitioning to a node adjacent to the expansion node is determined based on the adjacent node of the expansion node and an intent matching degree between a relationship between the expansion node and each adjacent node of the expansion node and the target input; further, a second matching degree between the expansion node and the target input is obtained by using the RWR model based on the initial probability and the transition probability. In this way, the RWR model can be used to comprehensively evaluate the relevance between the graph nodes and the target output based on the topological structure characteristics of the graph (including the nodes and the relevance therebetween), fully combine the semantic similarity between the expansion node and the target input, the intent matching degree between the expansion node and the target input, and the intent matching degree between the relationship between the expansion node and the adjacent node of the expansion node and the target input, and improve the accuracy of the target output.
[0230] In some embodiments, the above step S102 can include the following steps S141 to S142:
[0231] Step S141, for each expansion node, determining a third matching degree corresponding to the expansion node based on the second matching degree between the expansion node and the target input.
[0232] In some embodiments, determining the third matching degree corresponding to the expansion node based on the second matching degree between the expansion node and the target input can include one of the following:
[0233] The second matching degree between the expansion node and the target input is directly determined as the third matching degree corresponding to the expansion node;
[0234] In the manner of constructing the third graph through multiple rounds of expansion, the third matching degree between the expansion node and the target input can be determined based on the second matching degree between the expansion node and the target input and the second matching degree between the context node of the expansion node and the target input.
[0235] The context node of the expansion node is an expansion node that is in the same path as the expansion node in the second graph and has not been examined (whether it is a target node has not been determined) in the previous expansion round, including an expansion node directly connected to the expansion node through an edge (the adjacent node of the expansion node) and / or an expansion node indirectly connected to the expansion node through an edge sequence containing multiple edges.
[0236] It can be understood that by combining the evaluation method of the second matching degree of the expansion node and the second matching degree related to the context node thereof, the relevance between the expansion node and the target input and the future expansion potential of the node in the multiple expansion rounds can be better comprehensively evaluated.
[0237] In the case that the expansion node is determined as the target node, the context node of the expansion node is the possible candidate target node in the next expansion round. Therefore, the second matching degree between the context node of the expansion node and the target input can represent the expansion potential of the current target node in the multi-round expansion process.
[0238] For example, in the case that the second matching degree between the context node of a certain expansion node and the target input is greater than the second matching degrees corresponding to other expansion nodes, it can be determined that the relevance between the node obtained by continuing to expand based on the expansion node and the target output is possibly higher, i.e., the expansion potential of the expansion node is greater; otherwise, the relevance between the node obtained by continuing to expand based on the expansion node and the target output is lower, and the expansion potential of the expansion node is smaller.
[0239] Therefore, in some embodiments, a high-order scoring function can be defined based on the second matching degree corresponding to the expansion node and the second matching degree corresponding to the context node of the expansion node, to further determine the expansion value score of the expansion node in the current expansion round, which is also the final evaluation score of the expansion node being determined as the target node, i.e., the third matching degree.
[0240] It can be understood that for each expansion node, the final third matching degree corresponding to the expansion node is obtained according to the second matching degree corresponding to the node; and based on the third matching degrees of the expansion nodes, at least one target node is obtained according to a preset screening condition. In this way, on the one hand, not only the relevance between the expansion node and the target input is considered, but also other dimensions that can evaluate the expansion potential of the expansion node are comprehensively considered to further comprehensively consider the expansion node and obtain the corresponding third matching degree, so that the knowledge context required for the target output to be formed (i.e., the more accurate target node) is more likely to be obtained; on the other hand, the number of nodes in the third graph finally formed is further reduced through screening, which can reduce the search range of the knowledge graph for generating the target output, reduce irrelevant information, redundant information and computing cost, and further improve the response speed and accuracy of determining the target output.
[0241] In some embodiments, the step S141 of determining the third matching degree corresponding to the expansion node based on the second matching degree between the expansion node and the target input can include the following step S1411:
[0242] Step S1411, determining the third matching degree corresponding to the expansion node based on the second matching degree corresponding to the expansion node and the second matching degree corresponding to the context node of the expansion node.
[0243] The context nodes of the expansion nodes include other expansion nodes in the second graph atlas that are in the same path as the expansion nodes.
[0244] In a case where the first set of context nodes is the same as the second set of context nodes, the size relationship between the third matching degree corresponding to the first expansion node and the third matching degree corresponding to the second expansion node is determined based on the size relationship between the second matching degree corresponding to the first expansion node and the second matching degree corresponding to the second expansion node; the first set of context nodes is a set composed of the context nodes of the first expansion node, and the second set of context nodes is a set composed of the context nodes of the second expansion node.
[0245] In a case where the first set of context nodes is different from the second set of context nodes, the size relationship between the third matching degree corresponding to the first expansion node and the third matching degree corresponding to the second expansion node is determined based on the size relationship between the second matching degree corresponding to the context nodes of the first expansion node and the second matching degree corresponding to the context nodes of the second expansion node.
[0246] For example, the second matching degree score(v) of the expansion node v and the set of context nodes V context of the expansion node are used to determine the calculation process of the high-order score (i.e., the third matching degree) contextual_score(v) of the expansion node v in the current round, which can be referred to as formula (11):
[0247] contextual_score(v)=eval_context(score(v),{score(u)|u∈V context (v)})(11);
[0249] wherein score(·) is the second matching degree calculated according to formula (10), and eval_context(·) is a high-order score function.
[0250] In some embodiments, the calculation method of the high-order score function eval_context(·) can include at least one of the following:
[0251] a calculation method based on numerical aggregation; for example, aggregation based on average value, weighted average value, maximum value / minimum value, and / or normalization exponential function (Softmax) weighted aggregation, etc.;
[0252] a calculation method based on graph structure propagation; for example, a method of weighted aggregation based on graph structure connectivity, centrality and other features; wherein the principle of the aggregation method can be different from the principle of the RWR model.
[0253] a computing method based on a graph neural network, for example, a method of computing based on a graph convolutional neural network (GCN), a graph attention network (GAT), etc.;
[0254] a computing method based on a logical rule.
[0255] In some embodiments, the third matching degree defined based on different high-order scoring functions should satisfy the following conditions:
[0256] For two extended nodes v1 and v2, in the case that the context node sets corresponding to the two nodes respectively are the same, and the second matching degrees corresponding to the two nodes respectively are also the same, the third matching degrees corresponding to the two nodes respectively are also the same.
[0257] In the case that the context node sets corresponding to the two nodes respectively are the same, and the second matching degree corresponding to node v1 is greater than the second matching degree corresponding to node v2, the third matching degree corresponding to node v1 is greater than the third matching degree corresponding to node v2.
[0258] For two nodes with the same second matching degree, and the context node u1∈V context (v1) of node v1, the context node u2∈V context (v2) of node v2, V context (v1)-{u1}=V context (v2)-{u2}, that is, in the case that the context node sets corresponding to node v1 and node v2 respectively are different, in the case that the second matching degree corresponding to u1 is greater than the second matching degree corresponding to u2, the third matching degree corresponding to node v1 is greater than the third matching degree corresponding to node v2; in the case that the second matching degree corresponding to u1 is equal to the second matching degree corresponding to u2, the third matching degree corresponding to node v1 is equal to the third matching degree corresponding to node v2.
[0259] For example, a context node set V context (v) can be defined, which is constructed by the direct adjacent nodes (i.e., nodes directly connected by an edge) of the extended node v, and further according to the maximum value of the second matching degrees corresponding to the direct adjacent nodes, a second-order scoring function contextual_score (2) (v) of the final score of node v is determined by weighted aggregation, and the calculation process is shown in formula (12):
[0260]
[0261] V context(v) is a set of unexamined direct adjacent nodes of the expansion node v to be examined (i.e., to be determined the third matching degree), and indicates the highest second matching degree corresponding to the adjacent node of the expansion node v.
[0262] It can be understood that in the case that the second matching degree corresponding to the context node of the expansion node v1 is higher than the second matching degree corresponding to the context node of the expansion node v2, the expansion node v1 has a greater expansion potential; in the case that the second matching degree corresponding to the context node of the expansion node v1 is lower than the second matching degree corresponding to the context node of the expansion node v2, the expansion node v1 has a smaller expansion potential.
[0263] According to whether the first context node set and the second context node set corresponding to the first expansion node and the second expansion node are the same, the size relationship between the third matching degrees of the expansion nodes is further determined according to the size relationship between the second matching degrees corresponding to the expansion nodes or the second matching degrees corresponding to the context nodes of the expansion nodes. In this way, the third matching degree can comprehensively evaluate the relevance of the node to the target output and the expansion value of the node in the future expansion round, so as to optimize the direction of graph expansion, avoid blind expansion of low-relevance nodes, reduce unnecessary consumption of computing resources, and further improve the efficiency, accuracy and relevance of generating the target output.
[0264] In step S142, at least one target node is selected from the expansion nodes based on the third matching degrees corresponding to the expansion nodes; the number of the target nodes is less than the number of the expansion nodes.
[0265] In some embodiments, the way of determining at least one target node from the expansion nodes can include at least one of the following:
[0266] The expansion node whose third matching degree with the target input is greater than the third matching degree threshold is determined as the target node.
[0267] The expansion nodes are sorted according to the third matching degrees with the target input from high to low to obtain a third node sequence; the first third target number of expansion nodes in the third node sequence are determined as the target nodes.
[0268] It can be understood that the process of determining the target nodes can have different embodiments.
[0269] In some embodiments, all the extended nodes of the second graph can be determined as target nodes, and the extended nodes in the second graph that are in the same path as the initial node can be determined as candidate target nodes; then for each of the determined candidate target nodes, the second matching degree between the candidate target node and the target input is directly determined as the third matching degree corresponding to the candidate target node; further, the target nodes are obtained from the candidate target nodes according to the above screening method based on the third matching degree; finally, the third graph is constructed according to the initial node and the target nodes.
[0270] In some embodiments, after the initial node is determined, multi-round extension (e.g., hop-by-hop extension) can be performed based on the initial node; in the process of multi-round extension, the next-hop nodes of the newly determined target nodes in the last round that have not been examined are determined as candidate target nodes; the third matching degrees corresponding to the candidate target nodes in each round are determined according to the second matching degrees corresponding to the candidate target nodes in each round and the second matching degrees corresponding to the context nodes of the candidate target nodes; further, the actual extended target nodes finally retained in each round of extension are obtained according to the above screening method based on the third matching degrees corresponding to the candidate target nodes in each round; finally, the target nodes determined in each round are combined to construct the third graph.
[0271] In implementation, in the process of constructing the third graph through multi-round extension, the stop condition for determining the target nodes based on multi-round extension and constructing the third graph can include at least one of the following:
[0272] There is no new node that can be extended;
[0273] The extension process reaches a preset maximum step M max ;
[0274] A heuristic rule or termination logic set is met, i.e., it is represented that there is no node with higher relevance to the target input that can be extended; exemplarily, the highest third matching degree corresponding to the extension nodes to be examined in the current round is less than the lowest third matching degree corresponding to the target nodes in the current target node set.
[0275] In implementation, the maximum step M max may include but is not limited to 4, 5, or 6, etc., which is not limited in the embodiments of the present application.
[0276] In implementation, the above multi-round extension process can be implemented by using a beam search algorithm to determine the target nodes and construct the third graph.
[0277] In some embodiments, the above processing method can further include the following step S161:
[0278] Step S161, based on the beam search algorithm, starting from the initial node in the second graph, determining the target node through multiple rounds of expansion, and constructing a third graph.
[0279] The beam search algorithm is a graph search algorithm combining the breadth-first search algorithm and the greedy algorithm, and defines a hop-by-hop search process based on a heuristic target function: before each round of expansion, the next hop node of the newly added node in the last round is expanded, the target function of all candidate and to-be-added expansion nodes is calculated, the target number (referred to as beam width) of nodes with the optimal target function value is selected as the newly added expansion node, and the search is terminated when the maximum depth is reached or no expansion node is added any more. The intermediate search results are combined to determine the final search results.
[0280] In some embodiments, the beam search algorithm can be used, the third matching degree of the candidate target node (i.e., the to-be-added expansion node) is used as the target function of the beam search algorithm, the beam width of each round of expansion is determined according to the third target number in the method of screening the target node based on the third node sequence, the termination condition is set, the target node is determined through hop-by-hop expansion, and the third graph is constructed.
[0281] Exemplarily, the third matching degree defined based on the high-order evaluation mode can be used as the target function, and in each round of hop-by-hop expansion, the candidate target node is scored, for example, contextual_score(v) or contextual_score (2) (v); from the nodes in each round of expansion, the Q nodes with the highest score are selected and added to the target node set V target , and the next round of expansion is continued; when the maximum step M max is reached, the expansion process is ended; finally, the third graph is constructed based on the initial node in the target node set V target and all target nodes.
[0282] It can be understood that for each extended node as a candidate target node, a third matching degree corresponding to the candidate target node is obtained by combining the second matching degree corresponding to the node and the second matching degree corresponding to the context node of the node; and based on the third matching degrees of the candidate target nodes, at least one target node is obtained according to the screening condition. In this way, on the one hand, not only the relevance of the extended node itself to the user inquiry request corresponding to the target input is considered, but also the relevance of the context node of the extended node to the user inquiry request is considered, so that the extended node is considered as a whole, and a knowledge context more likely to participate in forming the target output (i.e., a more accurate target node) can be obtained; on the other hand, the number of nodes in the third graph finally formed is further reduced through screening, which can reduce the search range of the knowledge graph for generating the target output, reduce irrelevant information, redundant information and computing cost, and further improve the response speed and accuracy of determining the target output.
[0283] In some embodiments, the step S104 described above can include the following steps S141 to S142:
[0284] Step S141, linearly representing the third graph.
[0285] In implementation, in the case of outputting the target output according to the third graph by the large language model, it is necessary to represent the third graph in the form of text so as to facilitate the processing of the large language model.
[0286] In some embodiments, the nodes and relationships in the third graph can be represented in the form of triples. For example, the node v1, the node v2, and the relationship e between the node v1 and the node v2 in the third graph can be represented as (v1, e, v2).
[0287] In some embodiments, the nodes and relationships in the third graph can be represented in a structured text format such as a lightweight data exchange format (JSON), an Extensible Markup Language (XML), a lightweight markup language (such as Markdown), and the like.
[0288] In some embodiments, the nodes and relationships in the third graph can be represented in the form of natural language description text based on a set template.
[0289] Step S142, generating and outputting the target output based on the third graph by using the large language model.
[0290] In some embodiments, the third graph represented in text can be spliced into the prompt word of the large language model query as a context, and the spliced prompt word is input into the large language model to generate the final target output through the large language model. Wherein, the target output is generated according to the nodes and relationships in the third graph, and the accuracy and coherence of the target output are further improved through semantic reasoning.
[0291] Exemplarily, the process of generating the target output based on the third graph SubGraph by the large language model can refer to formula (13):
[0292] Answer=LLM(SubGraph) (13).
[0293] On this basis, the embodiment of the application provides a processing method, which can be executed by an electronic device, for realizing intelligent question answering based on a knowledge graph. As shown in Figure 2 The processing method includes the following steps S201 to S209:
[0294] Step S201, obtaining a user question.
[0295] Here, the user question can correspond to the user input in the above processing method.
[0296] Step S202, obtaining a first graph.
[0297] Step S203, in response to the received user question, calculating the semantic similarity between the nodes in the first graph and the user input.
[0298] Here, the calculation process of the semantic similarity between the nodes in the first graph and the user input can refer to the process of calculating the first matching degree between the nodes in the first graph and the target input in the above processing method.
[0299] In implementation, the user question can be parsed to extract multi-faceted problem information such as named entities and noun phrases (corresponding to the target input in the above processing method), and further calculate the semantic similarity (corresponding to the first matching degree in the above processing method) with the entities in the knowledge graph (corresponding to the nodes in the first graph in the above processing method).
[0300] Step S204, determining an initial node set.
[0301] Here, the initial node set can be obtained by selecting the most relevant entity (i.e. the initial node) to the user input according to the semantic similarity between the nodes in the first graph and the user input calculated in step S203.
[0302] Step S205, initializing a second graph.
[0303] Here, a local knowledge graph (i.e., the second graph) can be initialized based on the initial node set, so that further filtering of nodes in the graph based on the local knowledge graph is performed subsequently, thereby obtaining a final context subgraph (i.e., the third graph in the above processing method) for question answering.
[0304] In step S206, the intention matching degree of the node and / or the relationship is evaluated based on the semantic type.
[0305] Here, the intention matching degree between the extended nodes in the local knowledge graph (i.e., the second graph) and / or the relationship between the extended nodes and the user input can be evaluated in combination with the semantic type in the above processing method.
[0306] In implementation, the intention matching degree of the node and / or the relationship can be evaluated using a large language model, and an intention matching degree score in the range of 0 to 1 is given.
[0307] In step S207, node score fusion is performed based on the improved RWR model.
[0308] Here, the improved RWR model can correspond to the RWR model determined according to the improved transition probability matrix W and the initial probability distribution P0 in the above processing method. The semantic similarity and the intention matching degree calculated in steps S203 and S206 are fused to calculate the relevance score of the node as the context for question answering (i.e., the second matching degree). Here, by replacing the original complete graph (i.e., the first graph) with the local knowledge graph (i.e., the second graph), the real-time calculation amount in the question answering process can be reduced.
[0309] The process of node score fusion can be referred to formulas (7) to (10) in the above processing method, and the obtained node score can correspond to the second matching degree in the above processing method.
[0310] In step S208, the third graph is extracted based on the second graph.
[0311] In implementation, the above processing method can be referred to, and the initial node is expanded hop by hop. The relevance score (i.e., the second matching degree) calculated in step S207 is used to define a score function for filtering the extended nodes. The extended node with the highest third matching degree in the local knowledge graph (i.e., the second graph) is selected as the target node hop by hop, and the final context subgraph (i.e., the third graph) most relevant to the user's question and answer is obtained.
[0312] In step S209, the answer is generated using a large model.
[0313] Here, the answer corresponding to the user's question can be determined using a large language model based on the context subgraph (i.e., the third graph) extracted in step S208. The answer can correspond to the target output in the above processing method.
[0314] In an aspect, by analyzing the semantic types of the nodes and the relationships of the knowledge graph, the intention matching degree is evaluated, the search target of the subgraph is optimized, and the query effect and efficiency of the question and answer scenario are improved. On the other hand, the semantic similarity and the intention matching degree are fused by using the network structure of the graph, the nodes are dynamically filtered through multi-hop subgraph expansion, the high computational overhead caused by global traversal is reduced, the actual query related part can be better focused, and the efficiency and accuracy of the algorithm are further improved. In another aspect, the whole process can be automatically constructed, without the need for manual predefinition of query modes or annotation of training data, and without the need for expert knowledge, which can save manpower and improve efficiency. In another aspect, the model does not need to be trained and adjusted for specific scenarios or fields, which can improve the universality of the method and reduce the computational resource overhead of high complexity. In another aspect, for each user query, a large language model can be used only in the steps corresponding to the intention matching degree evaluation and the answer generation, without the need for iterative calling, which can further reduce the computational cost caused by calling the large language model.
[0315] An embodiment of the present application provides a processing device, as shown in the figure, the processing device 300 comprises: Figure 3
[0316] A first determination module 310 is configured to determine a second graph based on at least one initial node in a first graph in response to a user input, wherein the initial node is determined based on a first matching degree between each node in the first graph and a target input, the target input is determined based on the user input, and the second graph comprises the initial node and at least one extended node in the first graph which is in the same path as the initial node.
[0317] A second determination module 320 is configured to determine at least one target node from each extended node in the second graph based on a second matching degree between each extended node in the second graph and the target input.
[0318] A third determination module 330 is configured to determine a third graph based on the initial node and the target node.
[0319] A first processing module 340 is configured to determine and output a target output corresponding to the target input to the user based on the third graph.
[0320] In some embodiments, the target input comprises the user input, at least one named entity, and / or at least one noun phrase, and the processing device can further comprise a second processing module configured to perform named entity recognition on the user input to obtain the named entity in the user input, and perform syntax analysis on the user input to obtain the noun phrase in the user input.
[0321] In some embodiments, the processing apparatus can further include a fourth determining module configured to determine a first sub-match degree, a second sub-match degree and / or a third sub-match degree between each node in the first graph and the user input, the at least one named entity and / or the at least one noun phrase, respectively; and determine, for each node in the first graph, a highest sub-match degree among the first sub-match degree, the second sub-match degree and / or the third sub-match degree corresponding to the node as the first match degree corresponding to the node.
[0322] In some embodiments, the processing apparatus can further include a fifth determining module configured to determine the second match degree between each of the extended nodes and the target input based on a semantic similarity between each of the extended nodes and the target input, and an intent match degree between each of the relationships between each of the extended nodes and each of the adjacent nodes of each of the extended nodes and the target input, respectively.
[0323] In some embodiments, the fifth determining module can be further configured to determine, based on the semantic similarity between each of the extended nodes and the target input, an initial probability of extending, from each of the extended nodes, the nodes adjacent to each of the extended nodes; determine, based on the adjacent nodes of each of the extended nodes and the intent match degree between each of the relationships between each of the extended nodes and each of the adjacent nodes of each of the extended nodes and the target input, a transition probability of transitioning, from each of the extended nodes, to each of the adjacent nodes of each of the extended nodes; and obtain, based on the initial probability and the transition probability corresponding to each of the extended nodes, respectively, the second match degree between each of the extended nodes and the target input by using a restart random walk model.
[0324] In some embodiments, the processing apparatus can further include a sixth determining module configured to determine a semantic similarity between each node in the second graph and the target input.
[0325] The fifth determining module can be further configured to, for each of the extended nodes, determine, based on the semantic similarity between each of the extended nodes and the target input and the semantic similarity between each node in the second graph and the target input, an initial probability of extending, from each of the extended nodes, the nodes adjacent to each of the extended nodes.
[0326] In some embodiments, the fifth determining module can be further configured to, for each of the extended nodes, determine, based on the adjacent nodes of each of the extended nodes and the intent match degree between each of the relationships between each of the extended nodes and each of the adjacent nodes of each of the extended nodes and the target input, a transition probability of transitioning, from each of the extended nodes, to each of the adjacent nodes of each of the extended nodes.
[0327] In some embodiments, the second determining module may further be used to: for each of the extended nodes, determine a third matching degree corresponding to the extended node based on the second matching degree between the extended node and the target input; based on the third matching degree corresponding to each of the extended nodes, filter from each of the extended nodes to obtain at least one target node; the number of target nodes is less than the number of extended nodes.
[0328] In some embodiments, the second determining module may further be used to: determine the third matching degree corresponding to the extended node based on the second matching degree corresponding to the extended node and the second matching degree corresponding to the context node of the extended node; the context node of the extended node includes other extended nodes in the second graph that are on the same path as the extended node;
[0329] Each of the extended nodes satisfies the following conditions:
[0330] When the first context node set and the second context node set are the same, the relationship between the third matching degree corresponding to the first extended node and the third matching degree corresponding to the second extended node is determined based on the relationship between the second matching degree corresponding to the first extended node and the second matching degree corresponding to the second extended node; the first context node set is the set composed of the context nodes of the first extended node, and the second context node set is the set composed of the context nodes of the second extended node;
[0331] When the first set of context nodes is different from the second set of context nodes, the relationship between the third matching degree corresponding to the first extended node and the third matching degree corresponding to the second extended node is determined based on the relationship between the second matching degree corresponding to the context node of the first extended node and the second matching degree corresponding to the context node of the second extended node.
[0332] In some embodiments, the first determining module may further be used to: determine the nodes in the first graph whose first matching degree satisfies the matching degree condition as the initial nodes; based on the first graph, expand each initial node hop-by-hop along the path where each initial node is located to obtain the expanded nodes; construct the second graph based on the initial nodes and the expanded nodes; the number of nodes in the second graph is less than the number of nodes in the first graph.
[0333] This application provides an electronic device, including a memory and a processor. For example... Figure 4 As shown, the electronic device 400 includes:
[0334] Memory 410 is used to store computer programs that can run on processor 420;
[0335] The processor 420 is used to execute the program stored in the memory 410 to implement the processing method applied to the processing device described above.
[0336] This application provides a computer program including computer-readable code. When the computer-readable code is run in a computer device, the processor in the computer device executes some or all of the steps in the above-described processing method.
[0337] This application provides a computer program product, including a computer program or instructions, which, when executed by a processor, implement some or all of the steps in the above-described processing method.
[0338] This application provides a computer-readable storage medium storing a computer program that can be executed by a processor to implement the above-described processing method.
[0339] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus, and electronic devices according to embodiments of this application. 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 apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0340] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function 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.
[0341] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0342] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application.
[0343] The descriptions of the above device embodiments are similar to those of the above method embodiments, and have similar beneficial effects. For technical details not disclosed in the device embodiments of this application, please refer to the descriptions of the method embodiments of this application for understanding.
[0344] It should be understood that the phrase "one embodiment" or "an embodiment" throughout the specification means that a specific feature, structure, or characteristic related to the embodiment is included in at least one embodiment of this application. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. Furthermore, these specific features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. It should be understood that in the various embodiments of this application, the sequence numbers of the above-described processes do not imply a sequential order of execution; the execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application. The sequence numbers of the above-described embodiments are merely descriptive and do not represent the superiority or inferiority of the embodiments.
[0345] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus 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 apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0346] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods, such as: multiple units or components can be combined, or integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the various components shown or discussed can be through some interfaces, and the indirect coupling or communication connection between devices or units can be electrical, mechanical, or other forms.
[0347] The units described above as separate components may or may not be physically separate. The components shown as units may or may not be physical units. They may be located in one place or distributed across multiple network units. Some or all of the units may be selected to achieve the purpose of this embodiment according to actual needs.
[0348] In addition, each functional unit in the various embodiments of this application can be integrated into one processing unit, or each unit can be a separate unit, or two or more units can be integrated into one unit; the integrated unit can be implemented in hardware or in the form of hardware plus software functional units.
[0349] Those skilled in the art will understand that all or part of the steps of the above method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it performs the steps of the above method embodiments. The aforementioned storage medium includes various media that can store program code, such as mobile storage devices, read-only memory (ROM), magnetic disks, or optical disks.
[0350] Alternatively, if the integrated units described above are implemented as software functional modules and sold or used as independent products, they can also be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, or the parts that contribute to related technologies, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, ROMs, magnetic disks, or optical disks.
[0351] The above description is merely an embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application.
Claims
1. A processing method, comprising: In response to user input, a second graph is determined based on at least one initial node in the first graph; The initial node is determined based on the first matching degree between each node in the first graph and the target input, and the target input is determined based on the user input. The second graph includes the initial node and at least one extended node in the first graph that is on the same path as the initial node. Based on the second matching degree between each of the extended nodes in the second graph and the target input, at least one target node is determined from each of the extended nodes; Based on the initial node and the target node, a third graph is determined; Based on the third graph, the target output corresponding to the target input is determined and output to the user.
2. The method of claim 1, wherein the target input includes the user input, at least one named entity, and / or at least one noun phrase, and the method further includes at least one of the following: Named entity recognition is performed on the user input to obtain the named entities in the user input; Syntactic analysis is performed on the user input to obtain the noun phrases in the user input.
3. The method according to claim 2, further comprising: Determine the first sub-matching degree, second sub-matching degree, and / or third sub-matching degree between each node in the first graph and the user input, the at least one named entity, and / or the at least one noun phrase; For each node in the first graph, the highest sub-matching degree among the first sub-matching degree, the second sub-matching degree, and / or the third sub-matching degree corresponding to the node is determined as the first matching degree corresponding to the node.
4. The method according to claim 1, further comprising: Based on the semantic similarity between each of the extended nodes and the target input, and the intent matching degree between each of the extended nodes and the relationship between each of the extended nodes and the target input, the second matching degree between each of the extended nodes and the target input is determined.
5. The method according to claim 4, wherein determining the second matching degree between each of the extended nodes and the target input based on the semantic similarity between each of the extended nodes and the target input, and the intent matching degree between each of the extended nodes and the relationship between each of the extended nodes and the target input, comprises: Based on the semantic similarity between each of the extended nodes and the target input, determine the initial probability of expanding the nodes adjacent to each of the extended nodes from each of the extended nodes; Based on the neighboring nodes of each of the extended nodes, and the intention matching degree between the relationship between each of the extended nodes and their neighboring nodes and the target input, the transfer probability of each of the extended nodes being transferred to their neighboring nodes is determined. Based on the initial probability and transition probability corresponding to each of the extended nodes, the second matching degree between each of the extended nodes and the target input is obtained by using the restart random walk model.
6. The method according to claim 5, further comprising: Determine the semantic similarity between each node in the second graph and the target input; The step of determining the initial probability of expanding the nodes adjacent to each of the expanded nodes based on the semantic similarity between each of the expanded nodes and the target input includes: For each of the extended nodes, based on the semantic similarity between the extended node and the target input, and the semantic similarity between each node in the second graph and the target input, the initial probability of starting from each of the extended nodes is determined during the process of expanding the nodes adjacent to each of the extended nodes.
7. The method according to claim 5, wherein determining the transition probability of each extended node to its adjacent node based on the intention matching degree between the adjacent nodes of each extended node and the relationship between each extended node and its adjacent nodes and the target input, comprises: For each of the extended nodes, the transfer probability of the extended node to the adjacent node is determined based on the adjacent nodes of the extended node and the intention matching degree between the extended node and each of the adjacent nodes of the extended node and the target input.
8. The method according to any one of claims 1 to 7, wherein determining at least one target node from the extended nodes based on a second matching degree between each of the extended nodes in the second atlas and the target input comprises: For each of the extended nodes, a third matching degree is determined based on the second matching degree between the extended node and the target input; Based on the third matching degree corresponding to each of the extended nodes, at least one target node is obtained by filtering from each of the extended nodes; the number of target nodes is less than the number of extended nodes.
9. The method according to claim 8, wherein determining the third matching degree corresponding to the extended node based on the second matching degree between the extended node and the target input comprises: Based on the second matching degree corresponding to the extended node and the second matching degree corresponding to the context node of the extended node, the third matching degree corresponding to the extended node is determined; the context node of the extended node includes other extended nodes in the second graph that are on the same path as the extended node; Each of the extended nodes satisfies the following conditions: When the first context node set and the second context node set are the same, the relationship between the third matching degree corresponding to the first extended node and the third matching degree corresponding to the second extended node is determined based on the relationship between the second matching degree corresponding to the first extended node and the second matching degree corresponding to the second extended node; the first context node set is the set composed of the context nodes of the first extended node, and the second context node set is the set composed of the context nodes of the second extended node; When the first set of context nodes is different from the second set of context nodes, the relationship between the third matching degree corresponding to the first extended node and the third matching degree corresponding to the second extended node is determined based on the relationship between the second matching degree corresponding to the context node of the first extended node and the second matching degree corresponding to the context node of the second extended node.
10. The method according to any one of claims 1 to 7, wherein determining the second map based on at least one initial node in the first map comprises: The nodes in the first graph whose matching degree satisfies the matching degree condition are determined as the initial nodes; Based on the first graph, each initial node is expanded hop-by-hop along the path where each initial node is located to obtain the expanded node; Based on the initial node and the extended node, the second graph is constructed; the number of nodes in the second graph is less than the number of nodes in the first graph.
Citation Information
Patent Citations
Sub-graph matching method and system based on target mode
CN114638321A
Cross-graph database shortest path calculation method and device, electronic equipment and medium
CN119622041A
Knowledge graph-based search request processing method and device, equipment and medium
CN119884384A
Question Answering Method and Apparatus Based on Knowledge Graph
US20220284060A1
Knowledge graph question-answer method and apparatus based on deep learning technology, and device
WO2021139283A1