Graph generation method, apparatus, device, and storage medium
By determining edge information based on search trees and MCTS, chemical molecular structure diagrams are generated, solving the accuracy problem of sequence-to-graph conversion and improving the rate and efficiency of chemical synthesis.
Patent Information
- Application Number
- CN202111386176.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-22
- Publication Date
- 2025-12-12
- Estimated Expiration
- 2041-11-22
AI Technical Summary
Existing technologies struggle to quickly and accurately convert sequence-based chemical formulas into graphical molecular structure diagrams, impacting the rate and efficiency of chemical synthesis.
The edge information of the graph is determined by a search tree-based method. By combining Monte Carlo Tree Search (MCTS) and neural networks, the final search tree is gradually constructed to determine the edge information, thereby generating the representation graph.
It improves the accuracy and applicability of sequence-to-graph conversion, and enhances the rate and efficiency of chemical synthesis.
Smart Images

Figure CN114329083B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to the field of computers, in particular to the fields of artificial intelligence such as game search, machine learning, natural language understanding, knowledge graph, and the like, and more particularly to a graph generation method and device, an apparatus, and a storage medium. BACKGROUND
[0002] Sequence to Graph technology refers to a technology of converting a sequence into a graph, which has a wide range of applicable scenarios and application values. For example, in the field of chemical synthesis, a chemical molecule usually has two main forms of representation, a sequence form of molecular formula and a graph form of molecular structure graph. In practice, the molecular structure graph often needs to be determined through complex experimental analysis, and direct analysis of the molecular structure graph from the molecular formula for rapid inspection is of great help to improve the rate of chemical synthesis. SUMMARY
[0003] The present disclosure provides a graph generation method, device, apparatus, and storage medium.
[0004] According to an aspect of the present disclosure, a graph generation method is provided, including: determining vertex information of vertices of a representation graph of a target object based on a representation sequence of the target object; determining edge information of edges of the representation graph based on a search tree; and generating the representation graph based on the vertex information and the edge information.
[0005] According to another aspect of the present disclosure, a graph generation apparatus is provided, including: a first determining module configured to determine vertex information of vertices of a representation graph of a target object based on a representation sequence of the target object; a second determining module configured to determine edge information of edges of the representation graph based on a search tree; and a generating module configured to generate the representation graph based on the vertex information and the edge information.
[0006] According to another aspect of the present disclosure, an electronic device is provided, including: at least one processor; and a memory connected with the at least one processor in communication; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of the aspects described above.
[0007] According to another aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to perform the method according to any one of the aspects described above.
[0008] According to another aspect of the present disclosure, there is provided a computer program product comprising a computer program which, when executed by a processor, implements the method according to any one of the aspects described above.
[0009] According to the technical solution of the present disclosure, the graph generation effect can be improved.
[0010] It should be understood that the content described in this part is not intended to identify key or important features of the embodiments of the present disclosure, nor to limit the scope of the present disclosure. Other features of the present disclosure will become apparent from the following description. BRIEF DESCRIPTION OF DRAWINGS
[0011] The accompanying drawings are used to better understand the present solution and do not constitute a limitation on the present disclosure. Among them:
[0012] Figure 1 is a schematic diagram according to a first embodiment of the present disclosure;
[0013] Figure 2 is a schematic diagram according to a second embodiment of the present disclosure;
[0014] Figure 3 is a schematic diagram according to a third embodiment of the present disclosure;
[0015] Figure 4 is a schematic diagram according to a fourth embodiment of the present disclosure;
[0016] Figure 5 is a schematic diagram according to a fifth embodiment of the present disclosure;
[0017] Figure 6 is a schematic diagram according to a sixth embodiment of the present disclosure;
[0018] Figure 7 is a schematic diagram according to a seventh embodiment of the present disclosure;
[0019] Figure 8 is a schematic diagram of an electronic device for implementing the graph generation method according to the embodiments of the present disclosure. DETAILED DESCRIPTION
[0020] Exemplary embodiments of the present disclosure are described below with reference to the accompanying drawings, which include various details of the embodiments of the present disclosure to help understanding, and should be considered as merely exemplary. Therefore, those of ordinary skill in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Also, in order to be clear and concise, the description below omits the description of well-known functions and structures.
[0021] Figure 1 is a schematic diagram according to a first embodiment of the present disclosure, which provides a graph generation method, the method comprising:
[0022] 101. Determine vertex information of vertices of the graph based on the sequence of representations of the target object.
[0023] 102. Determine edge information of edges of the graph based on the search tree.
[0024] 103. Generate a representation graph of the target object based on the vertex information and the edge information.
[0025] The execution subject of the embodiment can be referred to as a graph generation device, which can be software, hardware or a combination of software and hardware. The device can be located in an electronic device. The electronic device can be located in a server or a user terminal. The server can be a local server or a cloud server. The user terminal can include a mobile device (such as a mobile phone or a tablet computer), a vehicle-mounted terminal (such as a car machine), a wearable device (such as a smart watch or a smart bracelet), a smart home device (such as a smart television or a smart speaker), and the like.
[0026] The graph generation method can be applied to various scenarios, such as language structure analysis, chemical molecule generation, and DNA protein analysis.
[0027] The target object is an object to which the graph technology is applied, and can be reasonably selected according to different application scenarios. The target object has multiple representations, including at least a sequence and a graph.
[0028] The information of the sequence form of the target object can be referred to as the sequence of representations of the target object, and the information of the graph form of the target object can be referred to as the graph of representations of the target object. The sequence can be referred to as sequence (sequence), and the graph can be referred to as graph (graph).
[0029] Specifically, the target object can include a chemical molecule, a protein molecule, a text in the field of natural language processing, and the like.
[0030] For example, for a chemical molecule, its sequence of representations can be a molecular formula, and its graph of representations can be a molecular structure graph.
[0031] For example, for a protein molecule, its sequence of representations can be a DNA sequence, and its graph of representations can be a protein structure graph.
[0032] For example, for a text, its sequence of representations can be a text sequence. For example, the text can be divided into multiple words, each word serving as a sequence unit, and multiple sequence units forming a text sequence. The graph of representations can be a dependency graph of the text.
[0033] For example, refer to Figure 2, the text "I send her a red apple", after tokenization, the words obtained are "I", "send", "her", "a", "red", "apple", and the sequence composed of these words can be called a text sequence, that is, a representation sequence of the target object, at this time, the target object is the text, the representation sequence of the target object is the text sequence, and the representation graph of the target object is the dependency relation graph.
[0034] A graph (Graph) is composed of vertices and edges, and is usually represented as G(V, E), where G represents a graph, V is a set of vertices in the graph G, and E is a set of edges in the graph G.
[0035] The vertices of a graph are the objects described by the graph, for example, see Figure 2 Each vertex of the graph corresponds to a word.
[0036] Each vertex can be represented as Vi, which can be called vertex information, where i is the index of the vertex, i = 1, 2,..., N, and N is the number of vertices.
[0037] V can be represented as: V = {V1, V2,..., VN}.
[0038] The edges of a graph are the connections between two vertices, for example, there is an edge between the vertex corresponding to "send" and the vertex corresponding to "I".
[0039] The edges of a graph can be divided into directed edges and undirected edges, based on Figure 2 the example, the edge is a directed edge, which can be represented as <Vi, Vj>, which indicates that the direction of the edge is from Vi to Vj. Where Vi and Vj are two vertices that have a connection relationship, i and j are the indices of the vertices, and are positive integers, i is not equal to j.
[0040] The edges of a graph can also have a weight, in the dependency relation graph, the weight can be specifically the label value of the dependency relation, see Figure 2 , such as "subject-predicate", "predicate-object", etc.
[0041] E can be represented as: E = {E1, E2,..., EM}, Ek = [<Vi, Vj>, label value], Ek can be called edge information, k is the index of the edge, k = 1, 2,..., M, and M is the number of edges.
[0042] The vertex information can be represented as Vi, which can be determined based on the representation sequence.
[0043] The representation sequence is composed of at least one sequence unit, for example, Figure 2 the sequence unit of the text sequence is a word, based on Figure 2 the example, the text sequence includes 6 sequence units.
[0044] The number of vertices of the graph is the same as the number of sequence units of the text sequence, and each vertex corresponds to a sequence unit.
[0045] For example, based on the example of Figure 2 including 6 sequence units, it is determined that the graph includes 6 vertices, i.e., the corresponding vertex information can be represented as: V1, V2, …, V6.
[0046] The edge information can be determined based on the search tree.
[0047] A tree is a data structure composed of at least one finite node with a hierarchical relationship. Each node in the tree has zero, one or more (at least two) child nodes, and the node without a parent node is called the root node. Each non-root node has and only one parent node. Except for the root node, each child node can be divided into multiple disjoint sub-trees.
[0048] There are many application scenarios of trees, one of which is a search tree.
[0049] The search tree is a tree involved in the game search (or called adversarial search) algorithm.
[0050] Game search is a search method in which multiple agents participate in artificial intelligence. Generally, a search tree is first constructed, and the search goal of each agent in the multiple agents is to find a node with the maximum or minimum evaluation value in the search tree. Computer chess, computer go and the like use game search.
[0051] Game search can be specifically Monte Carlo tree search (MCTS). Correspondingly, the search tree can be a Monte Carlo tree.
[0052] The search tree can guide the agent to make decisions and choose appropriate branches.
[0053] In the sequence-to-graph technology, the search tree can be used to determine the edge information. The specific determination process of the edge information can be referred to in the subsequent description.
[0054] Since the vertex information such as V1, V2, etc. can be determined based on the representation sequence, and the edge information such as E1, E2, etc. can be determined based on the search tree. Therefore, the vertex information and the edge information can be obtained, and after obtaining the vertex information and the edge information, the corresponding graph can be generated based on the vertex information and the edge information.
[0055] For example, referring to Figure 3 , it is assumed that the determined vertex information includes: V1, V2 and V3, and the determined edge information includes: E1 = [<V1, V2>, w1], E2 = [(<V1, V3>, w2)], then the graph G can be generated.
[0056] In the embodiments of the present disclosure, the edge information is determined based on the search tree, which can improve the accuracy and applicability, thereby improving the graph generation effect of the sequence-to-graph scheme.
[0057] As described above, the vertices of the graph can be determined based on the number of sequence units, the edges of the graph are determined based on the search tree, and there is at least one edge, for example, multiple edges, which can be determined at the same or different decision stages. Each decision stage can determine one or more edges.
[0058] Further, in each decision stage, a plurality of iteration processes can be performed to construct a final decision tree.
[0059] The related content of the decision stage and the iteration process will be described below.
[0060] Figure 4 is a schematic diagram of the fourth embodiment of the present disclosure. The present embodiment is described for the sequence-to-graph of text. The present embodiment provides a graph generation method, which comprises:
[0061] 401. Obtain a text sequence.
[0062] The text sequence can include a plurality of sequence units. For example, in Chinese, the sequence unit can be a word.
[0063] 402. Determine vertex information of vertices of a graph to be generated based on the number of sequence units in the text sequence.
[0064] Wherein, assuming that the number of sequence units is N, the number of vertices of the graph to be generated is also N, and accordingly, the vertex information of each vertex can be represented as Vi, i=1, 2,..., N.
[0065] That is, each vertex can form a vertex set, and the vertex set V={V1, V2,... VN}.
[0066] 403. Determine a current decision stage.
[0067] Wherein, initially, initialization can be performed, and the current decision stage is initialized as an initial decision stage. In addition, edge information can also be initialized, for example, the initialized edge information is empty.
[0068] The current decision stage is used to determine the edge information of the outgoing edge of the current vertex, the current vertex is a vertex in the graph that has an outgoing edge, and the outgoing edge is an edge with the current vertex as the starting point.
[0069] Wherein, the incoming edge refers to the edge with the vertex as the terminal point, and the outgoing edge refers to the edge with the vertex as the starting point. Generally, for a certain vertex, its incoming edge can be 0 or 1, and its outgoing edge can be 0, 1 or multiple.
[0070] For example, referring to Figure 3 For an edge <V1, V2>, it is an out-edge of V1 and an in-edge of V2.
[0071] 404. Construct a final search tree of the current decision stage.
[0072] 405. Determine edge information of an out-edge of the current vertex based on the final search tree of the current decision stage.
[0073] Different decision stages correspond to different final search trees. For example, the final search tree of the first decision stage is referred to as the first search tree, and the final search tree of the second decision stage is referred to as the second search tree.
[0074] Therefore, a first set of edge information can be determined based on the first search tree, and a second set of edge information can be determined based on the second search tree. Each set of edge information can be one or more.
[0075] For different decision stages, the process of constructing a respective final search tree and determining respective edge information based on the respective final search tree is similar. Therefore, each decision stage can be taken as a current decision stage, and the corresponding operation can be performed for the current decision stage.
[0076] By determining the edge information of the out-edge of the current vertex based on the final search tree of the current decision stage, the edge information can be determined step by step. Therefore, through the execution process of multiple decision stages, the entire edge information of the graph can be obtained.
[0077] The above 404 and 405 are further described below.
[0078] For 404, it can specifically include:
[0079] 4041. Obtain an initial search tree of the current decision stage, the initial search tree including a root node, the root node corresponding to edge information of an in-edge of the current vertex, the in-edge being an edge ending at the current vertex.
[0080] 4042. Take the initial search tree as a search tree to be updated in a first iteration process, perform an iteration process at least once to obtain an updated search tree of a last iteration process, and take the updated search tree of the last iteration process as the final search tree.
[0081] The search tree includes nodes with a parent-child relationship hierarchy, and a node without a parent node is a root node. Each node of the search tree corresponds to a kind of edge information.
[0082] The final search tree of each decision stage can be obtained based on iterations on the initial search tree of the corresponding decision stage. The root node of the initial search tree corresponds to the edge information of the incoming edge of the current vertex. Initially, the edge information of the incoming edge can be set to empty. If a vertex has no incoming edge, the edge information of the incoming edge can be considered empty.
[0083] Taking multiple iterations as an example, each iteration process is used to update the search tree.
[0084] The search tree at the start of each iteration process can be referred to as the search tree to be updated, and the search tree at the end of each iteration process can be referred to as the updated search tree.
[0085] Therefore, for the current decision stage, multiple iterations can be performed starting from the initial search tree of the current decision stage, thereby obtaining the final search tree of the current decision stage.
[0086] Figure 4 Taking M decision stages and K iteration processes in each decision stage as an example.
[0087] Wherein M and K are positive integers set values.
[0088] The execution content of each iteration process can be referred to in the subsequent description.
[0089] The search tree is a tree structure, that is, it includes nodes of different levels, and the nodes of different levels are in a parent-child relationship. The node without a parent node is called a root node (root). A node can have 0, 1 or multiple child nodes.
[0090] The nodes in the search tree correspond to state information. In this embodiment, the state information is specifically edge information. For example, the first node is the parent node of the second node, the first node corresponds to the first edge information E1, and the second node corresponds to the second edge information E2. If the second node is searched from the first node, it indicates that the second edge information E2 is converted from the first edge information E1, that is, the second edge information (the edge information of the outgoing edge of the vertex) is solved from the first edge information (the edge information of the incoming edge of the vertex).
[0091] After obtaining the initial search tree, at least one iteration process can be performed on the initial search tree. The specific number of times can be set, for example, 1000 times.
[0092] The execution flow of each iteration process in the at least one iteration process is similar, assuming that each iteration process is the current iteration process respectively. For the current iteration process, the search tree to be updated in the current iteration process is updated to the updated search tree of the current iteration process. If the current iteration process is the next iteration process, the updated search tree of the current iteration process is taken as the search tree to be updated of the next iteration process. The search tree to be updated of the first iteration process is the initial search tree, and the updated search tree of the last iteration process is the final search tree of the current decision stage.
[0093] For example, the initial search tree is T0, the iteration process of the current decision stage is twice, the first iteration process is to update the search tree from T0 to T1, and the second iteration process is to update from T1 to T2. Then, T2 is taken as the final search tree of the current decision stage.
[0094] By performing the at least one iteration process on the initial search tree, the accuracy of the final search tree can be improved.
[0095] In some embodiments, the performing the at least one iteration process comprises performing each iteration process, and the performing each iteration process comprises:
[0096] For the search tree to be updated of each iteration process, a child node is sequentially selected from the root node of the search tree to be updated until a to-be-expanded child node in the search tree to be updated is reached, and a selection path is generated, wherein the nodes on the selection path are the sequentially selected child nodes.
[0097] A new child node is generated for the to-be-expanded child node.
[0098] The new child node is simulated to obtain a simulation result of the new child node.
[0099] Based on the simulation result, the node information of the nodes on the selection path is updated to obtain the updated search tree of each iteration process.
[0100] For example, at the beginning, the edge information can be empty, and there is only a virtual root node. At this time, the root node can be taken as the to-be-expanded node, so that the child node of the root node is expanded.
[0101] For another example, after the historical processing process, multiple nodes exist on the search tree to be updated. At this time, a selection path can be formed.
[0102] The last child node of the selection path is the to-be-expanded node, and the to-be-expanded child node refers to the node with unsearched edges.
[0103] For the to-be-expanded node, a new child node can be generated.
[0104] After the simulation of the new child node, the whole selection path can be traced back to update the node information of each node.
[0105] Specifically, each iteration in the at least one iteration process is similar. The following takes one iteration process of MCTS as an example for illustration.
[0106] As shown in Figure 5 , one iteration process of the search tree of MCTS can be divided into four steps, specifically, selection, expansion, simulation and backpropagation.
[0107] Selection: starting from the root node, one node is selected each time until the child node to be expanded is reached, which forms a selection path, Figure 5 indicated by the line segment with an arrow.
[0108] Expansion: after reaching the child node to be expanded, a new child node is expanded (or added) and the initial value of the node information is configured for the new child node. Figure 5 indicated by the rightmost node in the lowermost layer.
[0109] Simulation: the new child node is simulated (or simulated) to obtain the simulation result of the new child node. Figure 5 indicated by the triangle.
[0110] Backpropagation: according to the simulation result, starting from the expanded new child node, the selection path is traced back, and the node information of the nodes involved in the backpropagation path is updated.
[0111] Among them, in the selection, the node can be selected based on the tree policy. In the simulation, the simulation result can be obtained based on the default policy.
[0112] Through selection, expansion, simulation and backpropagation, the update of the search tree can be realized.
[0113] The node information can be recorded in each node of the search tree, for example, in a general chess game, the node information is A and B, wherein A is the number of wins, and B is the total number of times.
[0114] In the sequence-to-graph, the node information can include: reward information and traversal times.
[0115] The reward information can include: average reward value Q and total reward value W.
[0116] The node information can further include other information, which can be set according to actual needs.
[0117] The initial value of the node information can be set, for example, W = Q = N = 0.
[0118] For N, if a node is selected at the time of selection, the traversal times N of the node is increased by 1.
[0119] For W and Q, they can be obtained based on a neural network (NN), which can be referred to as a value network. The value network can be obtained after being pre-trained.
[0120] In some embodiments, the node information includes value information and traversal times; the simulation of the new child node to obtain a simulation result of the new child node includes inputting the current edge information into a value network for processing to output the simulation result of the new node, the simulation result including a current value of the new node; and the updating of the node information of the nodes on the selected path based on the simulation result includes increasing the traversal times by 1 and updating the value information based on the current value and the updated traversal times.
[0121] For example, the current value of the new child node is v, the existing average value of the parent node of the new child node is Q0, the existing total value is W0, and the existing traversal times is N0. Then, the updated N1 of the parent node is N0+1, the updated total value W1 is W0+v, and the updated average value Q1 is W1 / N1.
[0122] Through simulation and backtracking, the updating of the node information can be realized.
[0123] For the selection process in the above four processes:
[0124] When selecting a node based on an intratree strategy, a score value can be calculated based on an upper confidence bound (UCB) algorithm, and then a node with a larger / smaller score value is selected.
[0125] The score value of the UCB algorithm is a value related to the average value Q and the upper limit U, for example, the calculation formula can be:
[0126]
[0127] wherein, i is an index of a node, Si is a score of node i, Qi is an average reward of node i, Ni is a number of traversals of node i, Ui is an upper confidence bound value of node i, and n is a number of sub-nodes available for selection. Qi represents exploit and Ui represents explore.
[0128] Further, in order to improve the exploration efficiency, the Hoeffding inequality can be applied to update the score value calculation method of UCB.
[0129] For each iteration process, the updated search tree of each iteration process can be obtained through the above selection, expansion, simulation, and backtracking.
[0130] After performing the iteration process for a set number of times or for a set duration or other set conditions, the final search tree of each decision stage can be obtained.
[0131] For example, referring to Figure 6 Starting from the initial search tree corresponding to the edge information of the outgoing edge of the current vertex of the current decision stage, MCTS can be performed. For the newly added sub-nodes in MCTS, the current reward value v can be obtained using the value network. Then, the current reward value v is used to backtrack in MCTS, thereby obtaining the final search tree of the current decision stage. The root node of the final search tree is filled with black. Then, the edge information of the outgoing edge of the current vertex can be determined using the final search tree.
[0132] The node information of each node in the final search tree is recorded. The root node of the final search tree corresponds to the current edge information. Therefore, based on the node information of the sub-nodes of the root node of the final search tree, the edge information of the outgoing edge of the current vertex can be obtained.
[0133] In some embodiments, determining the edge information of the outgoing edge of the current vertex based on the final search tree of the current decision stage comprises: inputting the node information of the sub-nodes of the root node of the final search tree into a policy network for processing to obtain a network output; and determining the edge information of the outgoing edge of the current vertex based on the network output.
[0134] Further, determining the edge information of the outgoing edge of the current vertex based on the network output comprises: taking the network output as the edge information of the outgoing edge of the current vertex; or obtaining, based on an inference component, edge information in the network output that complies with the graph rule of the target object as the edge information of the outgoing edge of the current vertex.
[0135] The child node of the root node refers to the child node of the next level of the root node, that is, the child node directly connected with the root node. The node information of the child node, specifically the updated node information, can be used to obtain the to-be-determined edge information.
[0136] The node information of the child node can be input into a policy network for processing. The policy network and the reward network are both neural networks, and the specific structure can be selected according to actual needs, and can be obtained after pre-training.
[0137] The policy network can output one or more pieces of edge information. The edge information output by the policy network can be directly used as the to-be-determined edge information, or the edge information output by the policy network can be processed based on the reasoning component to filter out the edge information that does not meet the conditions and retain the edge information that meets the conditions as the to-be-determined edge information.
[0138] For example, the representation graph is also a tree structure and assumes that "send" is the root node. If the current node is "send", the final search tree of the decision stage corresponding to "send" can be constructed through the above process, and the root node of the final search tree corresponds to the edge information of the incoming edge of "send". The child nodes of the root node of the final search tree correspond to other words except "send". After inputting the node information of these child nodes into the policy network for processing, the edge information of the three edges from "send" to "I", "send" to "she", and "send" to "apple" can be output, that is, the edge information of the outgoing edge of "send".
[0139] The determination process of the edge information of the outgoing edge of the remaining nodes is similar. In addition, when determining the root node of the tree structure representation graph, such as "send", the edge information of the outgoing edge of the virtual root node can be determined based on the virtual root node, so as to determine the actual root node, such as "send".
[0140] For the reasoning component, the reasoning component can be determined in advance to determine whether the edge meets the graph rule. For example, the reasoning component is a grammar component, which can check whether the two words corresponding to the edge meet the grammar rule, and filter out the edge that does not meet the rule.
[0141] The edge information can be obtained through the policy network. Since the policy network can select a suitable structure according to actual needs, for example, the output node of the policy network can be multiple, so that multiple information can be output at a time, that is, multiple edge information can be output at a time, thereby improving the execution efficiency.
[0142] By using the reasoning component, the edge that does not meet the graph rule can be excluded, thereby improving the accuracy and robustness.
[0143] The policy network can output multiple pieces of edge information, so that multiple edges can be determined at a time, thereby improving the efficiency.
[0144] It can be understood that the contents not described in detail in the embodiments can be referred to the related descriptions in other embodiments.
[0145] It can be understood that the timing relationship between the above steps is not limited if there is no necessary timing limitation.
[0146] Figure 7 FIG. 7 is a schematic diagram of a seventh embodiment of the present disclosure, and the seventh embodiment provides a graph generation apparatus, which comprises a first determination module 701, a second determination module 702, and a generation module 703.
[0147] The first determination module 701 is configured to determine vertex information of vertices of a representation graph of a target object based on a representation sequence of the target object; the second determination module 702 is configured to determine edge information of edges of the representation graph based on a search tree; and the generation module 703 is configured to generate the representation graph based on the vertex information and the edge information.
[0148] In some embodiments, the edge information is determined at at least one decision stage, and the apparatus further comprises a construction module configured to construct a final search tree of each of the at least one decision stage as a current decision stage, the current decision stage being used to determine edge information of an outgoing edge of a current vertex, the current vertex being a vertex in the representation graph having an outgoing edge, and the outgoing edge being an edge with the current vertex as a starting point; and the second determination module 702 is further configured to determine the edge information of the outgoing edge of the current vertex based on the final search tree of the current decision stage.
[0149] In some embodiments, the construction module comprises an acquisition unit configured to acquire an initial search tree of the current decision stage, the initial search tree comprising a root node corresponding to edge information of an incoming edge of the current vertex, the incoming edge being an edge with the current vertex as a terminal point; and an update unit configured to take the initial search tree as a search tree to be updated in a first iteration process, perform at least one iteration process to obtain an updated search tree in a last iteration process, and take the updated search tree in the last iteration process as the final search tree.
[0150] In some embodiments, the performing the iteration process at least once includes performing each iteration process, and the updating unit is further configured to: for a search tree to be updated in the each iteration process, sequentially selecting child nodes from a root node of the search tree to be updated until reaching a child node to be expanded in the search tree to be updated, and generating a selection path, wherein nodes on the selection path are the sequentially selected child nodes; generating a new child node for the child node to be expanded; performing simulation on the new child node to obtain a simulation result of the new child node; and updating node information of the nodes on the selection path based on simulation information of the new child node to obtain an updated search tree of the each iteration process.
[0151] In some embodiments, the node information includes reward information and traversal times, and the updating unit is further configured to:
[0152] inputting the current edge information into a reward network for processing to output a simulation result of the new child node, wherein the simulation result includes a current reward value of the new child node; increasing the traversal times by 1; and updating the reward information based on the current reward value and the updated traversal times.
[0153] In some embodiments, the second determining module 702 is further configured to: input node information of a child node of a root node of the final search tree into a strategy network for processing to obtain a network output; and determine edge information of an out-edge of the current vertex based on the network output.
[0154] In some embodiments, the second determining module 702 is further configured to: take the network output as the edge information of the out-edge of the current vertex; or obtain, based on an inference component, edge information in the network output that meets a graph rule of the target object as the edge information of the out-edge of the current vertex.
[0155] In the embodiments of the present disclosure, the edge information is determined based on the search tree, which can improve the accuracy and applicability, thereby improving the graph generation effect of the sequence-to-graph scheme.
[0156] It can be understood that the same or similar contents in different embodiments in the embodiments of the present disclosure can be mutually referred to.
[0157] It can be understood that “first”, “second”, and the like in the embodiments of the present disclosure are only used for distinction, and do not represent importance level, time sequence, and the like. “Multiple” in the embodiments of the present disclosure refers to at least two.
[0158] In the technical scheme of the present disclosure, the collection, storage, use, processing, transmission, provision, and disclosure of user personal information involved in the technical scheme comply with the relevant legal regulations and do not violate public order and good customs.
[0159] According to embodiments of this disclosure, this disclosure also provides an electronic device, a readable storage medium, and a computer program product.
[0160] Figure 8 A schematic block diagram of an example electronic device 800 that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workbenches, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0161] like Figure 8 As shown, the electronic device 800 includes a computing unit 801, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 802 or a computer program loaded from a storage unit 808 into a random access memory (RAM) 803. The RAM 803 may also store various programs and data required for the operation of the electronic device 800. The computing unit 801, ROM 802, and RAM 803 are interconnected via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.
[0162] Multiple components in electronic device 800 are connected to I / O interface 805, including: input unit 806, such as keyboard, mouse, etc.; output unit 807, such as various types of displays, speakers, etc.; storage unit 808, such as disk, optical disk, etc.; and communication unit 809, such as network card, modem, wireless transceiver, etc. Communication unit 809 allows electronic device 800 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0163] The computing unit 801 can be various general and / or special purpose processing components with processing and computing capabilities. Some examples of the computing unit 801 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various specialized artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 801 performs various methods and processes described above, such as the graph generation method. For example, in some embodiments, the graph generation method can be implemented as a computer software program tangibly embodied in a machine-readable medium, such as the storage unit 808. In some embodiments, part or all of the computer program can be loaded and / or installed onto the electronic device 800 via the ROM 802 and / or the communication unit 809. When the computer program is loaded onto the RAM 803 and executed by the computing unit 801, one or more steps of the graph generation method described above can be performed. Alternatively, in other embodiments, the computing unit 801 can be configured to perform the graph generation method by any other suitable means, such as by means of firmware.
[0164] Various implementations of the systems and techniques described above can be realized in digital electronic circuitry, integrated circuitry, a field programmable gate array (FPGA), an application specific integrated circuit (ASIC), a system on a chip (SOC), a complex programmable logic device (CPLD), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include implementation in one or more computer programs that are executable and / or interpretable on a programmable system including at least one programmable processor, which can be special or general purpose, coupled to receive data and instructions from, and to transmit data and instructions to, a storage system, at least one input device, and at least one output device.
[0165] Program code for carrying out methods of the present disclosure can be written in any combination of one or more programming languages. The program code can be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the program code, when executed by the processor or controller, produces the functions / operations specified in the flowcharts and / or the block diagrams. The program code can be executed entirely on a machine, partially on a machine, partially on a machine and partially on a remote machine or entirely on a remote machine or server.
[0166] In the context of this disclosure, a machine-readable medium can be a tangible medium that contains or stores a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include but is not limited to an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of the machine-readable storage medium will include one or more lines of electrical connections, portable computer disks, hard disk drives, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or Flash memory), optical fibers, portable compact disc read-only memories (CD-ROMs), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0167] To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the computer. Other kinds of devices can be used to provide for interaction with a user as well; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form, including acoustic, speech, or tactile input.
[0168] The systems and techniques described here can be implemented in a computing system that includes a back end component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front end component (e.g., a user computer having a graphical user interface or a Web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such back end, middleware, or front end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network (LAN), a wide area network (WAN), and the Internet.
[0169] The computer system can include clients and servers. This relationship can be. remote, where each server is stored on a remote computer from a client. The clients and the servers can be connected through a communication network. The relationship can be a client-server relationship over a network. Servers can be cloud servers, also known as cloud computing servers or cloud hosts, which are a host product in the cloud computing service system. The servers can be servers of a distributed system, or servers combined with a blockchain.
[0170] It should be understood that the various forms of flow shown above can be reordered, steps added or removed. For example, the steps described in the present disclosure can be performed in parallel, sequentially, or in a different order, as long as the desired results of the technical solutions of the present disclosure can be achieved, which are not limited herein.
[0171] The above detailed description does not constitute a limitation on the protection scope of the present disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modifications, equivalent replacements and improvements made within the spirit and principles of the present disclosure shall be included in the protection scope of the present disclosure.
Claims
1. A method for generating a graph, comprising: determining vertex information of vertices of a representation graph of a target object based on a sequence of representations of the target object; determining edge information of edges of the representation graph based on a search tree, including: determining edge information of out-edges of a current vertex based on a final search tree of a current decision stage, the current vertex being a vertex in the representation graph having out-edges, the out-edges being edges starting from the current vertex; generating the representation graph based on the vertex information and the edge information; the target object being a text, the sequence of representations being a sequence of texts, and the representation graph being a dependency graph of the text; the vertices corresponding to sequence units of the sequence of texts one-to-one; the edge information including a label value of a dependency relationship; a root node of the final search tree corresponding to edge information of in-edges of the current vertex, child nodes of the root node of the final search tree corresponding to sequence units other than the current vertex, and the edge information of the out-edges of the current vertex being obtained based on node information of the child nodes; the final search tree being obtained through at least one iteration process, each iteration process including: for a search tree to be updated of the iteration process, selecting child nodes one by one from a root node of the search tree to be updated until reaching a sub-node to be expanded in the search tree to be updated, and generating a selection path, the nodes on the selection path being the child nodes selected one by one; generating a new child node for the sub-node to be expanded; simulating the new child node to obtain a simulation result of the new child node; and updating node information of the nodes on the selection path based on simulation information of the new child node to obtain an updated search tree of the iteration process. 2.The method of claim 1, further comprising: obtaining an initial search tree of the current decision stage, the initial search tree including a root node corresponding to edge information of in-edges of the current vertex, the in-edges being edges ending at the current vertex; and taking the initial search tree as a search tree to be updated of a first iteration process, and performing the iteration process at least once to obtain an updated search tree of a last iteration process, and taking the updated search tree of the last iteration process as the final search tree. 3.The method of claim 1, wherein: the node information includes reward information and traversal times; the simulating the new child node to obtain a simulation result of the new child node includes: inputting current edge information into a reward network for processing to output the simulation result of the new child node, the simulation result including a current reward value of the new child node; and the updating the node information of the nodes on the selection path based on the simulation result of the new child node includes: increasing the traversal times by 1, and updating the reward information based on the current reward value and the updated traversal times. 4. The method of claim 1, wherein, inputting node information of child nodes of a root node of the final search tree into a policy network for processing to obtain a network output; determining edge information of an out-edge of the current vertex based on the network output.
5. The method of claim 4, wherein, The determining edge information of the out-edge of the current vertex based on the network output comprises: taking the network output as the edge information of the out-edge of the current vertex; or obtaining, based on an inference component, edge information in the network output that meets a graph rule of the target object as the edge information of the out-edge of the current vertex.
6. A graph generation apparatus, comprising: a first determination module configured to determine vertex information of a vertex of a representation graph of a target object based on a representation sequence of the target object; a second determination module configured to determine edge information of an edge of the representation graph based on a search tree, comprising: determining edge information of an out-edge of a current vertex based on a final search tree of a current decision stage; the current vertex being a vertex in the representation graph that has an out-edge, the out-edge being an edge with the current vertex as a starting point; a generation module configured to generate the representation graph based on the vertex information and the edge information; the target object being a text, the representation sequence being a text sequence, and the representation graph being a dependency graph of the text; the vertex corresponding to a sequence unit of the text sequence one by one; the edge information comprising a label value of a dependency relationship; a root node of the final search tree corresponding to edge information of an in-edge of the current vertex, child nodes of the root node of the final search tree corresponding to other sequence units except the current vertex, and the edge information of the out-edge of the current vertex being obtained based on node information of the child nodes; the final search tree being obtained through at least one iteration process, each iteration process comprising: for a search tree to be updated of the iteration process, sequentially selecting child nodes from a root node of the search tree to be updated until reaching a sub-node to be expanded in the search tree to be updated, and generating a selection path, the nodes on the selection path being the sequentially selected child nodes; generating a new child node for the sub-node to be expanded; simulating the new child node to obtain a simulation result of the new child node; updating node information of the nodes on the selection path based on simulation information of the new child node to obtain an updated search tree of the iteration process.
7. The apparatus of claim 6, further comprising a construction module, the construction module comprising: an acquisition unit configured to acquire an initial search tree of the current decision stage, the initial search tree comprising a root node, the root node corresponding to edge information of an in-edge of the current vertex, the in-edge being an edge with the current vertex as a terminal point; an update unit configured to take the initial search tree as a search tree to be updated of a first iteration process, perform at least one iteration process to obtain an updated search tree of a last iteration process, and take the updated search tree of the last iteration process as the final search tree.
8. The apparatus of claim 7, wherein: the node information comprises reward information and traversal times; the update unit is further configured to: inputting the current edge information into a reward network for processing to output a simulation result of the new child node, the simulation result including a current reward value of the new child node; increasing the number of traversals by 1, and updating the reward information based on the current reward value and the updated number of traversals.
9. The apparatus of claim 6, wherein, The second determination module is further configured to: input node information of a child node of a root node of the final search tree into a policy network for processing to obtain a network output; determine edge information of an out-edge of the current vertex based on the network output.
10. The apparatus of claim 9, wherein, The second determination module is further configured to: input the network output as the edge information of the out-edge of the current vertex; or obtain, based on an inference component, edge information in the network output that meets a graph rule of the target object as the edge information of the out-edge of the current vertex. 11.An electronic device, comprising: at least one processor; and a memory connected to the at least one processor in communication; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-5.
12. A non-transitory computer readable storage medium having stored thereon computer instructions, wherein, The computer instructions are used to enable the computer to perform the method according to any one of claims 1-5. 13.A computer program product comprising a computer program which, when executed by a processor, implements the method according to any one of claims 1-5.
Citation Information
Patent Citations
Semantic analysis model training method and device, electronic equipment and storage medium
CN112560496A