A data generation method, device, medium and electronic equipment
By using multi-round message passing to generate key-value pair cached state data in graph-structured data and inputting it into a large language model, the problem of semantic detail loss caused by irreversible compression in graph-structured data is solved, and the accuracy of data generation is improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- ALIPAY (HANGZHOU) INFORMATION TECH CO LTD
- Filing Date
- 2026-05-07
- Publication Date
- 2026-07-31
AI Technical Summary
In existing technologies for reasoning or generation tasks based on graph-structured data, the irreversible compression of text encoders leads to the loss of key semantic details in the original node data, which limits the expressive power and accuracy of the model and makes it impossible to recover the lost information.
By acquiring initial prompt words and their associated graph data, key-value pair cached state data of nodes is generated using multi-round message passing, and this data is used as context input to a large language model to replace the aggregation algorithm of graph neural networks, thus preserving the fine-grained semantic features of nodes for data generation.
It improves the accuracy of target data generation, avoids irreversible losses caused by data compression, and makes full use of the semantic understanding capabilities of large language models.
Smart Images

Figure CN122491492A_ABST
Abstract
Description
Technical Field
[0001] This specification relates to one or more embodiments in the field of large model inference technology, and more particularly to a data generation method, apparatus, medium and electronic device. Background Technology
[0002] With the rapid development of big data and artificial intelligence technologies, graph-structured data, as an important form of data organization, has been widely used in various application scenarios. A large amount of real-world data is organized in graph-structured data form, such as paper citation networks, social media networks, and e-commerce product graphs. In graph-structured data, not only can structured edges connect nodes to represent complex relationships between entities, but the rich unstructured text content contained within the nodes themselves (such as summaries, posts, and product descriptions) can also provide fine-grained semantic information, thereby supporting deeper data analysis and reasoning tasks.
[0003] Typically, when performing reasoning or generation tasks based on graph-structured data, the original node data contained in each node needs to be irreversibly compressed into a fixed, low-dimensional embedding vector by an external text encoder (e.g., pre-trained language models such as Word2Vec, GloVe, or BERT). Subsequently, a graph neural network (GNN) performs multiple rounds of message passing based on these compressed embedding vectors to capture structural dependencies and semantic relationships between nodes, generating a global representation of the nodes. This supports subsequent downstream tasks such as node classification, link prediction, graph generation, and data-to-text generation. However, because the compression process of the text encoder essentially involves the selection and abstraction of the original text's semantics—its core objective being to retain the core features of the text within a limited dimension, it cannot accommodate all fine-grained semantic details. Furthermore, this compression process is irreversible. Therefore, once key semantic details (such as a specific term or contextual logic) are lost in the initial compression stage, subsequent graph-structured reasoning will never be able to compensate for this information loss, thus severely limiting the model's expressive power and accuracy. Summary of the Invention
[0004] In view of the above, one or more embodiments of this specification provide the following technical solutions: According to a first aspect of one or more embodiments of this specification, a data generation method is proposed, comprising: Obtain initial prompt words and their associated graph data; the associated graph data is used to provide a basis for generating target data based on the initial prompt words. Determine the key-value pair cache state data for each node in the association graph data; wherein, for each node, the key-value pair cache state data of that node is obtained after multiple rounds of message passing based on the association graph data; in any round of message passing, the original node data of that node, the key-value pair cache state data of all neighboring nodes of that node updated in the previous round of message passing, and the hidden state data of that node updated in the previous round of message passing are input into a preset large language model to obtain the key-value pair cache state data of that node updated in the current round of message passing; The key-value pair cached state data of each node in the association graph data is used as context data and input into the large language model along with the initial prompt word to generate the target data through the large language model.
[0005] According to a second aspect of one or more embodiments of this specification, a data generation apparatus is provided, comprising: The acquisition module is used to acquire initial prompt words and their associated graph data; the associated graph data is used to provide a basis for generating target data based on the initial prompt words. The generation module is used to input the key-value pair cached state data of each node in the association graph data as context data, along with the initial prompt word, into a preset large language model to generate the target data through the large language model. Specifically, for each node, the key-value pair cached state data is obtained after multiple rounds of message passing based on the association graph data. In any round of message passing, the original node data of the node, the node feature data of the node's neighboring nodes, and the hidden state data of the node updated in the previous round of message passing are input into the large language model to obtain the updated key-value pair cached state data of the node in the current round of message passing.
[0006] According to a third aspect of one or more embodiments of this specification, an electronic device is provided, comprising: a processor; a memory for storing processor-executable instructions; wherein the processor performs the executable instructions to implement the steps of the data generation method described above.
[0007] According to a fourth aspect of one or more embodiments of this specification, a computer-readable storage medium is provided that stores computer instructions thereon, which, when executed by a processor, implement the steps of the data generation method described above.
[0008] According to a fifth aspect of one or more embodiments of this specification, a computer program product is provided, comprising a computer program / instructions that, when executed by a processor, implement the steps of the data generation method described above.
[0009] In this method, firstly, initial prompt words and association graph data are obtained to provide a basis for generating target data based on the obtained initial prompt words. Then, the key-value pair cache state data of each node in the association graph data is determined. For each node, the key-value pair cache state data of the node is obtained after multiple rounds of message passing based on the association graph data. In any round of message passing, the original node data of the node, the key-value pair cache state data of all the node's neighbor nodes updated in the previous round of message passing, and the hidden state data of the node updated in the previous round of message passing are input into a preset large language model to obtain the key-value pair cache state data of the node updated in the current round of message passing. Finally, the key-value pair cache state data of each node in the association graph data is used as context data and input along with the initial prompt words into the large language model to generate target data through the large language model.
[0010] As can be seen from the above method, on the one hand, multiple rounds of message passing can be carried out based on key-value pair cached state data, so that each node can directly update the node based on the key-value pair cached state data retained by the neighbor node in the previous round of message passing. Since the key-value pair cached data itself is the intermediate representation generated by the large language model during the inference process, it retains the fine-grained semantic features of the original text of the node, thereby realizing the flow of as complete fine-grained semantic features as possible during message passing, so as to avoid the problem of irreversible data loss due to data compression. On the other hand, in each round of message passing, the original node data of the given node, along with the updated key-value pair cached state data of all its neighboring nodes from the previous round, are input into a large language model. This allows the large language model to fuse node features, replacing the aggregation algorithm in the message passing process of the graph neural network. By leveraging the semantic understanding capabilities of the large language model, message passing can be performed based on the topological relationship information in the graph structure data and the complete semantic information in the original node data. Finally, the key-value pair cached state data of each node extracted by the large language model is used as context data and re-inputted along with the initial prompt words entered by the user to generate the final target data. This approach improves the accuracy of generating target data based on the relational graph data and the initial prompt words. Attached Figure Description
[0011] Figure 1 This is a schematic diagram of a round of message passing process provided in an exemplary embodiment.
[0012] Figure 2 This is a schematic diagram of the architecture of a data generation system provided in an exemplary embodiment.
[0013] Figure 3This is a flowchart illustrating a data generation method provided in an exemplary embodiment.
[0014] Figure 4 This is a schematic diagram of a large language model structure provided in an exemplary embodiment.
[0015] Figure 5 This is a schematic diagram of a target data generation process provided in an exemplary embodiment.
[0016] Figure 6 This is a schematic structural diagram of a device provided in an exemplary embodiment.
[0017] Figure 7 This is a block diagram of a data generation apparatus provided in an exemplary embodiment. Detailed Implementation
[0018] To make the objectives, technical solutions, and advantages of this specification clearer, the technical solutions of this specification will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this specification, and not all of them. Based on the embodiments in this specification, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this specification.
[0019] The user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this manual are all information and data authorized by the user or fully authorized by all parties. The collection, use and processing of related data shall comply with the relevant laws, regulations and standards of the relevant countries and regions, and corresponding operation portals shall be provided for users to choose to authorize or refuse.
[0020] In this specification, to facilitate understanding, we will first introduce the Graph Neural Network (GNN) related to the solution provided in this specification.
[0021] Graph Neural Networks (GNNs) are deep learning models specifically designed for processing graph-structured data. Graph-structured data typically consists of nodes and edges connecting the nodes, where nodes represent entities and edges represent relationships between entities.
[0022] For example, in an academic citation network, each node can represent an academic paper, and the edges between nodes can represent citation relationships (i.e., one paper cites another paper); in a social media network, each node can represent a user, and the edges between nodes can represent follow relationships or friend relationships; in an e-commerce product graph, each node can represent a product, and the edges between nodes can represent associations such as joint purchases, similar attributes, or complementary combinations.
[0023] As can be seen from the above, unlike text, images, and videos, graph data does not have a fixed order. The connections between its nodes exhibit an irregular and complex topological structure, making it difficult for deep learning models such as convolutional neural networks or recurrent neural networks to process directly. Therefore, graph neural networks utilize an iterative message-passing mechanism to enable each node to aggregate information from its neighbors, thereby updating its own feature representation for use in downstream tasks. Specifically, for example... Figure 1 As shown.
[0024] Figure 1 This is a schematic diagram of a round of message passing process provided in an exemplary embodiment.
[0025] Combination Figure 1 As can be seen, graph neural networks perform multiple rounds of message passing based on graph structure data. In each round, the central node collects the node features of its neighbors, fuses them using aggregation functions (such as summation, averaging, or attention weighting), and then performs a nonlinear transformation to obtain the updated node representation of the central node. After multiple rounds of message passing, each node's representation will contain its own attributes as well as the topological structure and semantic information of its surrounding neighborhood, thus enabling it to be used for downstream tasks such as node classification, link prediction, and graph classification.
[0026] For example, in a social network graph structure, to predict a user's interest tag, the graph neural network aggregates the node features of the graph node corresponding to the user in the first round of message passing, as well as the node features of the neighboring nodes directly connected to the user's graph node in the graph structure data (i.e., the nodes corresponding to the user's friends, the nodes corresponding to the user's family members, etc.). In the second round of message passing, it further aggregates the node features of the neighboring nodes of the user's neighboring nodes (i.e., two-hop neighbors, such as: friends of friends). Through this layer-by-layer diffusion method, the final user representation will contain the overall interest tendency of their social circle, thus more accurately predicting the user's interest tag.
[0027] As can be seen from the above process, graph neural networks require a prerequisite for multi-round message passing: the initial node features of each node in the graph structure data must first be obtained before multi-round message passing can be performed based on these initial node features. This limits the accuracy of the graph structure data processing results (e.g., the accuracy of the predicted user interest tags mentioned above) to the quality of the initial node features. For example, if the initial node features of each node in the graph structure data cannot fully and accurately reflect the original node data contained in that node, then subsequent message passing will be performed on a biased basis, leading to error accumulation and amplification.
[0028] Therefore, if the original node data contained in each node is irreversibly compressed into a fixed, low-dimensional embedding vector by an external text encoder (e.g., Word2Vec, GloVe, or BERT pre-trained language models) as the initial node feature of each node, a large number of key semantic details in the original node data (such as specific terms, negation relations, transition logic, fine-grained entity descriptions, etc.) will be lost during the compression process.
[0029] For example, suppose there exists a social network graph where each node represents a user review. Two reviews are given: Review A: "The service at this restaurant is terrible, but the food is delicious." and Review B: "The service is terrible, and the food is terrible." When a BERT model is used to compress each review into a single vector, the two vectors obtained after compression may be very close because the text content of the two sentences is extremely similar. When the graph neural network aggregates nodes, it might assume that A and B convey the same information, thus biasing the overall evaluation of the restaurant.
[0030] Furthermore, and more importantly, this information loss is irreversible. Once the original text is compressed into static embedding vectors, subsequent graph neural network message passing, regardless of the number of rounds, cannot re-access or recover this lost original semantic information, thus fundamentally limiting the model's expressive power and accuracy. This is especially true for rich text graph data, where the original node data within a node is itself complex long text data, such as product reviews, academic papers, and social media posts. This type of long text data often contains a large amount of fine-grained information that is crucial for downstream tasks. This leads to a more severe loss of semantic details in the initial node features extracted by the external text encoder, further reducing the accuracy of the output results obtained by the graph neural network when performing downstream tasks.
[0031] Based on this, this specification provides a data generation method. On the one hand, it can perform multi-round message passing based on key-value pair cached state data, so that each node can directly update the node based on the key-value pair cached state data retained by the neighboring node in the previous round of message passing. Since the key-value pair cached data itself is the intermediate representation generated by the large language model during the inference process, it retains the fine-grained semantic features of the original text of the node, thereby realizing the flow of as complete fine-grained semantic features as possible during message passing, so as to avoid the problem of irreversible data loss due to data compression. On the other hand, in each round of message passing, the original node data of the given node, along with the updated key-value pair cached state data of all its neighboring nodes from the previous round, are input into a large language model. This allows the large language model to fuse node features, replacing the aggregation algorithm in the message passing process of the graph neural network. By leveraging the semantic understanding capabilities of the large language model, message passing can be performed based on the topological relationship information in the graph structure data and the complete semantic information in the original node data. Finally, the key-value pair cached state data of each node extracted by the large language model is used as context data and re-inputted along with the initial prompt words entered by the user to generate the final target data. This approach improves the accuracy of generating target data based on the relational graph data and the initial prompt words.
[0032] The technical solutions provided in the various embodiments of this specification are described in detail below with reference to the accompanying drawings.
[0033] Figure 2 This is a schematic diagram of the architecture of a data generation system provided in an exemplary embodiment. For example... Figure 2 As shown, the system may include a server 21, a network 22, and several electronic devices, such as a PC (Personal Computer) 23, a mobile phone 24, etc.
[0034] Server 21 can be a physical server containing an independent host, or it can be a virtual server hosted in a host cluster. During operation, server 21 can run server-side programs for a specific application to implement the relevant functions of that application. For example, when server 21 runs a data generation service program, it can function as a corresponding data generation service platform.
[0035] PC23 and mobile phone24 are just some of the types of electronic devices that users can use. In reality, users can obviously also use electronic devices such as tablets, laptops, PDAs (Personal Digital Assistants), wearable devices (such as smart glasses, smartwatches, etc.), etc., and one or more embodiments in this specification do not limit this. During operation, the electronic device can run a client-side program of an application to achieve the relevant functions of that application. For example, when the electronic device runs a data generation service program, it can act as a client for that data generation service. The client application of the aforementioned data generation service can be launched and run on the electronic device. This client-side program can be a native application installed on the electronic device, or it can be a mini-program, quick app, or other similar form. Of course, when using web technologies such as HTML5 or similar, the relevant functions can be achieved through a page displayed by a browser. This browser can be a standalone browser application or a browser module embedded in some applications.
[0036] As for the network 22 that enables interaction between electronic devices such as PC23 and mobile phones 24 and server 21, communication can be achieved using either wired or wireless networks, depending on the communication methods supported by the respective electronic devices. This manual does not impose any restrictions on this. For example, PC23 can support both wired and wireless communication, so it can use either wired or wireless networks as needed. Mobile phones 24 typically only support wireless communication, so they can use wireless networks for communication.
[0037] Figure 3 This is a flowchart illustrating a data generation method provided in an exemplary embodiment, including: S300: Obtain the initial prompt word and the association graph data of the initial prompt word; the association graph data is used to provide a basis for generating target data based on the initial prompt word.
[0038] In this specification, the executing entity for implementing the data generation method can refer to computing devices located at the back end of a business process, such as servers or cloud computing clusters, or terminal devices with data processing capabilities, such as personal computers or mobile terminals. For ease of description, the following explanation uses a server as the executing entity.
[0039] Specifically, in practical applications, users may need to perform reasoning tasks based on complex graph structure data using a large language model, such as obtaining the answer to a question based on graph structure data using a large language model, or generating images or reports based on graph structure data using a large language model. In this case, users can input initial prompt words through a client that establishes a communication connection with the server (e.g., a browser interface on a personal computer, an application interface on a mobile terminal, etc.).
[0040] The initial prompt can be a question text described in natural language, such as: "What dishes can tomatoes be used to make?".
[0041] In addition, the initial prompts mentioned above can also be other descriptive instruction texts, such as "Please summarize the core viewpoints of this paper and the main conclusions in its cited literature" or "Based on the current product knowledge graph, recommend the three products with the highest similarity to the input product, and generate product set details images of the current product and these three products."
[0042] After receiving the initial prompt word input by the user, the server can determine the graph structure data associated with that prompt word, i.e., the association graph data. This association graph data can be a subgraph in a pre-built knowledge graph, graph structure data extracted and constructed from multiple data sources based on the initial prompt word input by the user, or graph structure data uploaded by the user through the client, etc.
[0043] The aforementioned association graph data can contain multiple nodes and edges between nodes. Each node contains corresponding original node data (such as text description, document content, etc.), while the edges are used to represent the semantic associations or structural relationships between nodes.
[0044] Furthermore, after obtaining the initial prompt and the association graph data, the server can use the association graph data as the basis for generating the target data indicated by the initial prompt, generate the target data based on this, and finally return the target data to the user.
[0045] It should be noted that when the aforementioned association graph data is a subgraph in a pre-constructed knowledge graph, the server can obtain the association graph data from the above content by performing feature extraction on the received initial prompt word to determine the prompt word feature data, and then querying the subgraph data that matches the prompt word feature data from the preset graph structure data as the association graph data for the initial prompt word. Specifically, the similarity between the hidden state data of each node in the aforementioned subgraph data and the prompt word feature data is higher than a preset similarity threshold.
[0046] Specifically, the server can query nodes from the preset graph structure data whose similarity between the hidden state data and the prompt word feature data is higher than a preset similarity threshold, and use them as target nodes. Finally, based on each target node, subgraph data matching the initial prompt word can be obtained.
[0047] In practical applications, the aforementioned association graph data of the initial prompt words can also be based on at least one document uploaded by the user that is related to the initial prompt words, or it can be constructed by the server through a search engine, based on at least one document related to the initial prompt words retrieved from various data sources or internal knowledge bases.
[0048] Specifically, the server can divide the aforementioned document into multiple text blocks, and then input each text block into a large language model to perform entity recognition and relation extraction on each text block. The extracted entities are used as nodes, and the relationships between entities are used as edges, thereby constructing a graph structure data containing multiple nodes and edges, which serves as the association graph data of the initial prompt words.
[0049] Of course, the server can also treat each text block as a node and establish edges between nodes based on the semantic similarity, contextual continuity, or document structural relationships (such as adjacent paragraphs or hierarchical headings in the same document) between any two text blocks, thereby constructing a graph structure data based on text blocks. In this construction method, the original node data of each node is the content of the corresponding text block, and the edges between nodes are used to represent the semantic associations or logical connections between text blocks.
[0050] S302: Determine the key-value pair cache state data of each node in the association graph data; wherein, for each node, the key-value pair cache state data of the node is obtained after multiple rounds of message passing based on the association graph data; in any round of message passing, the original node data of the node, the key-value pair cache state data of all neighboring nodes of the node updated in the previous round of message passing, and the hidden state data of the node updated in the previous round of message passing are input into a preset large language model to obtain the key-value pair cache state data of the node updated in the current round of message passing.
[0051] S304: The key-value pair cached state data of each node in the association graph data is used as context data and input into the large language model along with the initial prompt word to generate the target data through the large language model.
[0052] Furthermore, after obtaining the initial prompt word and its associated graph data, the server can determine the key-value pair cache state data of each node in the associated graph data.
[0053] Specifically, the server can perform multiple rounds of message passing based on the association graph data to determine the key-value pairs cached state data for each node in the association graph data.
[0054] In any round of message passing, the server can input the original node data of the node, the key-value pair cache state data of all the node's neighboring nodes updated in the previous round of message passing, and the hidden state data of the node updated in the previous round of message passing into a preset large language model to obtain the key-value pair cache state data of the node updated in this round of message passing.
[0055] As can be seen from the above, the server can use a large language model to fuse node features, replacing the aggregation algorithm in the message passing process of a graph neural network. In this case, because the key-value pair cached state data of each node in the relational graph data is extracted through multiple rounds of message passing, and each round of passing aggregates each node and its neighboring nodes in the relational graph data using a large language model, this ensures that the topological relationships in the graph structure data can be fully utilized. At the same time, the semantic understanding capability of the large language model can be used to fuse node features based on the original node data of each node and the key-value pair cached state data of its neighboring nodes.
[0056] To facilitate understanding, the structure of the large language model will be explained in detail below, as follows: Figure 4 As shown.
[0057] Figure 4 This is a schematic diagram of a large language model structure provided in an exemplary embodiment.
[0058] Combination Figure 4 As can be seen, the large language model contains multiple Transformer layers. Each Transformer layer includes: an attention module (e.g., a full attention module, a multi-head self-attention module, or a causal attention module) and a feedforward neural network module. Each of these modules can be preceded by a normalization layer and followed by a residual connection layer. The normalization and reference connection layers are used to mitigate gradient message problems and accelerate model convergence.
[0059] When performing reasoning tasks through a large language model, it can be divided into two logical stages: the encoding stage and the decoding stage. The encoding stage and the decoding stage are not completed by independent encoders and decoders, but by controlling the different input content into the large language model in each round, the large language model can perform the tasks of "understanding the context" (encoding stage) and "generating" (decoding stage).
[0060] In practical applications, different large language models can have different specific architectures. For ease of understanding, the following will use... Figure 4 Taking the large language model shown in the figure as an example, the process of the large language model performing reasoning tasks will be explained in detail.
[0061] Specifically, when a large language model performs inference tasks: During the encoding phase, the large language model receives an input sequence (which can be a sequence of tokens composed of multiple input tokens, obtained by encoding the input data through the large language model's embedding layer), and then processes the input sequence. For each token in the input sequence, the large language model processes it sequentially through multiple Transformer layers. In any Transformer layer, the attention module first receives the output of the previous Transformer layer as input, which contains the feature representations of all tokens in the input sequence.
[0062] Based on this, the attention module of the Transformer layer multiplies the feature representation of each token in the input sequence by three sets of learnable weight matrices to obtain the query vector (Query, Q), key vector (Key, K), and value vector (Value, V) corresponding to the token.
[0063] Furthermore, for each token's query vector, the attention module of the Transformer layer can calculate the dot product of the query vector and the key vectors of all tokens in the input sequence (including itself) to obtain an attention score. This attention score is used to characterize the relevance between the token and each other token. For example, the higher the attention score between the token and another token, the higher the relevance between the token and that other token.
[0064] Furthermore, the attention module of the Transformer layer can divide the attention score between the token and each other token by a preset scaling factor (which can be set according to actual needs). Specifically, for each other token, if the other token is located after the current token in the input sequence, the attention score between the current token and the other token can be modified to negative infinity, so that the large language model pays more attention to other tokens located before the current token during generation. The scaled attention score can then be input into a preset activation function, Softmax, to transform it into a probability distribution, i.e., attention weights.
[0065] Finally, the attention module of the Transformer layer can perform a weighted summation of the value vector corresponding to each token based on the attention weights mentioned above, to obtain the context-aware representation of each token.
[0066] Furthermore, after determining the context-aware representation of each token in the input sequence, the attention module of the Transformer layer can process it in the residual connection layer and the normalization layer. Then, the processed context-aware representation is input into the feedforward neural network module to undergo independent nonlinear transformations through the fully connected layer and activation function (such as the GELU function) contained in the feedforward neural network module to obtain the hidden state feature representation corresponding to each token in the input sequence.
[0067] During the decoding phase, the large language model can generate each token in the output sequence in an autoregressive manner based on the latent state feature representations output from the encoding phase.
[0068] Specifically, the Transformer layer structure from the encoding phase can be reused in the decoding phase for the current generation of the first... t Each token can be used as a query by the large language model, and combined with the generated tokens numbered 1 to 1. t Attention is calculated using the key vector and value vector of one token.
[0069] Each time a new token needs to be generated, the large language model can receive the already generated output sequence as input. When generating the token for the first time, the already generated output sequence can contain a start character (e.g., ...). <s>(or [BOS]). After obtaining the current input, the large language model can be processed through each Transformer layer.
[0070] In the attention module of any Transformer layer, for each query token in the current input sequence (especially the token at the last position, i.e. the current position to be predicted), the dot product of its key vector with the key vectors of all tokens in the input sequence (only the current and previous positions) is calculated to obtain the attention score.
[0071] Subsequently, the attention module sets the attention score of all future positions (i.e., positions after the current query token position) to negative infinity. After scaling factor adjustment, normalization is performed using the Softmax function, ensuring that the attention weight of the current token is only distributed to tokens before the current token and the token at the current position, thereby guaranteeing causal consistency during autoregressive generation.
[0072] Next, the attention module can perform a weighted summation of the above value vector based on the normalized attention weights to obtain the context-aware representation of the current token. Then, this context-aware representation can be processed sequentially through residual connections, layer normalization, and feedforward neural network modules to extract high-dimensional hidden state features.
[0073] Finally, the decoder inputs the latent state features corresponding to the last token into the output mapping layer (usually a linear layer and a softmax function), mapping them to a probability distribution over the vocabulary. The large language model samples the next token based on this probability distribution, appends this token to the end of the input sequence, and repeats the above iterative process until a terminator (such as...) is generated. <eos>(or reaches the preset maximum generation length.)
[0074] Based on the above, it can be seen that the key-value pair cached state data mentioned above can refer to the set of key vectors and value vectors pre-calculated and stored by the attention modules of each Transformer layer for the generated historical tokens during the decoding stage.
[0075] Furthermore, based on the detailed process of the large language model performing inference tasks described above, the following section details the process by which the server uses the large language model to fuse node features, replacing the aggregation algorithm in the message passing process of the graph neural network. Specifically, as follows... Figure 5 As shown.
[0076] Figure 5 This is a schematic diagram of a target data generation process provided in an exemplary embodiment.
[0077] Combination Figure 5 As can be seen, the server can also divide the generation process of the target data into two logical stages: the encoding stage and the decoding stage. In the encoding stage, the server can use a large language model to perform multi-round message passing based on the association graph data to obtain the key-value pair cached state data of each node in the association graph data. In the decoding stage, the server can use the key-value pair cached state data of each node in the association graph data as context data, and input it along with the initial prompt words into the large language model to generate the target data through the large language model.
[0078] In addition, the large language model also has two cache modules: Memory h (hidden state data cache) and MemoryKV (key-value pair cache), which are used to store the key-value pair cached state data and hidden state data of each node generated by the large language model in each round of message passing.
[0079] Specifically, during the encoding phase, the server can concatenate the original node data of each node in the association graph data, the key-value pair cache state data of all its neighboring nodes updated in the previous round of message passing, and the hidden state data of the node updated in the previous round of message passing to obtain an input sequence. This input sequence can then be input into a large language model, allowing the large language model to determine the relevance between each input token in the input sequence and each input token preceding it. Based on this relevance, the large language model aggregates each input token preceding it to obtain a context-aware representation of the input token. The key vector and value vector used by the large language model to represent the relevance for each token in the input sequence during the processing of the input sequence are used as the key-value pair cache state data updated for that node in the current round of message passing.
[0080] In the input sequence, the token corresponding to the hidden state data updated by the node in the previous round of message passing can be identified as the target token, and the target token is ordered after other tokens in the input sequence. Based on this, the context-aware representation of each token included in the hidden state data updated by the node in the previous round of message passing, updated in the current round of message passing, can be used as the hidden state data updated by the node in the current round of message passing.
[0081] Furthermore, after a specified number of rounds of message passing, for each node in the association graph data, the server can use the updated key-value pair cache state data of that node, output by the large language model in the last round of message passing, as the final key-value pair cache state data of that node.
[0082] The specified number of rounds can be set according to actual needs, and this manual does not impose any restrictions on it.
[0083] In practical applications, when performing the first round of message passing, the server can concatenate the original node data of each node in the relational graph data, the original node data of its neighboring nodes, and the initial hidden state data of the node obtained through random generation. This concatenation is then input into a large language model for the first round of message passing. Based on the large language model, the server outputs the updated hidden state data of the node in the first round of message passing, as well as the updated key-value pair cached state data, for subsequent rounds of message passing. However, since directly using randomly initialized hidden state data as the starting point for iteration makes it difficult to effectively incorporate the semantic information of the node itself, and the initial state lacks relevance to the graph structure context, the model needs multiple iterations to converge to a meaningful node representation during subsequent message passing. Therefore, the server can also perform an initialization process before the actual first round of message passing.
[0084] Specifically, the server can also input the original node data and preset initial summary feature data of each node in the association graph data into the large language model mentioned above to obtain the initial hidden state data of the node and the initial key-value pair cache state data of the node.
[0085] Furthermore, the server can use the initial hidden state data of the aforementioned node as the hidden state data of the node updated in the previous round of message passing used in the first round of message passing, and use the initial key-value pair cache state data of the aforementioned node as the key-value pair cache state data of the node updated in the previous round of message passing used in the first round of message passing.
[0086] It should be noted that, in practical applications, the key-value pair cached state data of each node in the above-mentioned association graph data can be temporarily determined by the server after obtaining the initial prompt word and the association graph data of the initial prompt word, based on the association graph data and after multiple rounds of message passing, or it can be determined and persistently stored by the server in advance based on the association graph data and after multiple rounds of message passing before obtaining the initial prompt word.
[0087] In the case where the key-value pair cache state data of each node in the aforementioned association graph data is pre-calculated and persistently stored by the server, the server can directly determine the key-value pair cache state data of each node in the association graph data from the corresponding storage medium after obtaining the initial prompt word and the association graph data of the initial prompt word.
[0088] In addition, in practical applications, to enable the initial prompt word to participate in subsequent message transmission as part of the graph structure, thereby enhancing the contextual association between the prompt word and the graph data, the server can also modify the subgraph data that matches the initial prompt word after obtaining it through the above method. This modification creates nodes in the subgraph data to represent the initial prompt word, and the modified subgraph data is then identified as the associated graph data of the initial prompt word. This allows the initial prompt word itself to be processed as a node in the graph during subsequent message transmission, thereby improving the accuracy of the large language model in generating target data.
[0089] Finally, after determining the key-value pair cache state data of each node in the association graph data, the server can use this cache state data as context data and input it along with the initial prompt words into the large language model to generate the target data. The data type of the target data can be determined based on the initial prompt words obtained by the server.
[0090] For example, if the initial prompt is "generate a text describing the properties of the compound in this molecular graph", then the target data is a piece of natural language text describing the properties of the compound; if the initial prompt is "generate user interest tags based on this social network graph", then the target data is a list of interest tags corresponding to each node.
[0091] As can be seen from the above, the server can perform multi-round message passing based on key-value pairs of cached state data. This allows each node to directly update its cached state data based on the key-value pairs retained by its neighboring nodes in the previous round of message passing. Since the key-value pair cached data itself is an intermediate representation generated by the large language model during inference, it retains the fine-grained semantic features of the original text of the nodes. This achieves the goal of preserving as complete fine-grained semantic features as possible during message passing, thus avoiding the problem of irreversible data loss due to data compression. On the other hand, in each round of message passing, the original node data of the given node, along with the updated key-value pair cached state data of all its neighboring nodes from the previous round, are input into a large language model. This allows the large language model to fuse node features, replacing the aggregation algorithm in the message passing process of the graph neural network. By leveraging the semantic understanding capabilities of the large language model, message passing can be performed based on the topological relationship information in the graph structure data and the complete semantic information in the original node data. Finally, the key-value pair cached state data of each node extracted by the large language model is used as context data and re-inputted along with the initial prompt words entered by the user to generate the final target data. This approach improves the accuracy of generating target data based on the relational graph data and the initial prompt words.
[0092] Figure 6 This is a schematic structural diagram of a device provided in an exemplary embodiment. For example... Figure 6 As shown, device 600 mainly consists of a communication interface 602, a user interface 604, a processor 606, and a data storage 608. These components are interconnected and communicate with each other via a system bus, network, or other connection mechanism 610. The communication interface 602 enables device 600 to communicate with other devices, access networks, and transmission networks via analog or digital modulation. For example, the communication interface 602 may include a chipset and antenna for wireless communication with a radio access network or access point. Furthermore, the communication interface 602 can be a wired interface such as Ethernet, Token Ring, or a USB port, or a wireless interface such as Wi-Fi, Bluetooth, Global Positioning System (GPS), or a wide-area wireless interface (e.g., WiMAX or LTE). Of course, the communication interface 602 can also support other forms of physical layer interfaces and standard or proprietary communication protocols. The communication interface 602 may also include multiple physical communication interfaces, such as Wi-Fi, Bluetooth, and wide-area wireless interfaces.
[0093] User interface 604 includes receiving user input and providing output to the user. Therefore, user interface 604 may include input components such as a keypad, keyboard, touch-sensitive or presence-sensitive panel, computer mouse, trackball, joystick, microphone, still camera, and video camera, and output components such as a display screen (which may be combined with a touch-sensitive panel), CRT, LCD, LED, display using DLP technology, printer, and other similar devices known or developed in the future. User interface 604 may also generate auditory output via speakers, speaker jacks, audio output ports, audio output devices, headphones, and other similar devices known or developed in the future. In some embodiments, user interface 604 may include software, circuitry, or other forms of logic capable of transmitting and receiving data from external user input / output devices. Additionally or alternatively, device 600 may support remote access from other devices via communication interface 602 or another physical interface (not shown). User interface 604 may be configured to receive user input, the position and movement of which may be indicated by indicators or cursors described herein. User interface 604 may also be configured as a display device for rendering or displaying text fragments.
[0094] Processor 606 may contain one or more general-purpose processors and / or special-purpose processors.
[0095] Data storage 608 may include one or more volatile and / or non-volatile storage components and may be integrated wholly or partially with processor 606. Data storage 608 may include removable and non-removable components.
[0096] Processor 606 is capable of executing program instructions 618 (e.g., compiled or uncompiled program logic and / or machine code) stored in data storage 608 to perform the various functions described herein. Data storage 608 may contain a non-transitory computer-readable medium on which program instructions are stored, which, when executed by device 600, enable device 600 to perform any methods, processes, or functions disclosed in this specification and / or the accompanying drawings. Execution of program instructions 618 by processor 606 may result in processor 606 using data 612.
[0097] For example, program instructions 618 may include an operating system 622 (e.g., an operating system kernel, device drivers, and / or other modules) installed on device 600 and one or more applications 620 (e.g., a browser, social application, or game application). Similarly, data 612 may include operating system data 616 and application data 614. Operating system data 616 is primarily accessible to the operating system 622, while application data 614 is primarily accessible to one or more applications 620. Application data 614 may reside in a file system visible or hidden from the user of device 600.
[0098] Application 620 can communicate with operating system 622 through one or more application programming interfaces (APIs). These APIs help application 620 read and / or write application data 614, transmit or receive information via communication interface 602, receive or display information on user interface 604, etc.
[0099] In some terminology, application 620 may be simply referred to as "app". Furthermore, application 620 can be downloaded to device 600 through one or more online app stores or app markets. However, applications can also be installed on device 600 in other ways, such as through a web browser or a physical interface on device 600 (e.g., a USB port).
[0100] Please refer to Figure 7 Data generation devices can be applied to, for example Figure 6 The device shown is used to implement the technical solution of this specification. The data generation apparatus may include: The acquisition module 701 is used to acquire an initial prompt word and its associated graph data; the associated graph data is used to provide a basis for generating target data based on the initial prompt word. The determining module 702 is used to determine the key-value pair cache state data of each node in the association graph data; wherein, for each node, the key-value pair cache state data of the node is obtained after multiple rounds of message passing based on the association graph data; in any round of message passing, the original node data of the node, the key-value pair cache state data of all the neighboring nodes of the node updated in the previous round of message passing, and the hidden state data of the node updated in the previous round of message passing are input into a preset large language model to obtain the key-value pair cache state data of the node updated in the current round of message passing; The generation module 703 is used to obtain an initial prompt word; extract features from the initial prompt word to determine the prompt word feature data of the initial prompt word; query subgraph data that matches the prompt word feature data from preset graph structure data, and use it as the association graph data of the initial prompt word; the similarity between the hidden state data of the nodes contained in the subgraph data and the prompt word feature data is higher than a preset similarity threshold.
[0101] Optionally, the acquisition module 701 is specifically used to: acquire an initial prompt word; extract features from the initial prompt word to determine the prompt word feature data of the initial prompt word; query subgraph data that matches the initial prompt word from preset graph structure data, and use it as the association graph data of the initial prompt word; the similarity between the hidden state data of the nodes contained in the subgraph data and the prompt word feature data is higher than a preset similarity threshold.
[0102] Optionally, the acquisition module 701 is specifically used to: acquire an initial prompt word; query subgraph data that matches the initial prompt word from preset graph structure data; modify the subgraph data to create nodes in the subgraph data to represent the initial prompt word, and determine the modified subgraph data as the association graph data of the initial prompt word.
[0103] Optionally, for each node in the association graph data, the key-value pair cache state data of that node updated in the previous message passing round used in the first round of message passing is the initial key-value pair cache state data of that node; the hidden state data of that node updated in the previous message passing round used in the first round of message passing is the initial hidden state data of that node; the initial key-value pair cache state data and the initial hidden state data are extracted by inputting the original node data of that node and the preset initial summary feature data into the large language model.
[0104] Optionally, the determining module 702 is specifically used to concatenate the original node data of the node, the key-value pair cache state data of all neighboring nodes of the node updated in the previous round of message passing, and the hidden state data of the node updated in the previous round of message passing to obtain an input sequence; input the input sequence into the large language model, so that the large language model determines the relevance between each input token in the input sequence and each input token preceding the input token in the input sequence for each input token in the input sequence, and aggregates each preceding input token according to the relevance to obtain a context-aware representation of the input token, and uses the key vector and value vector calculated by the large language model for each token in the input sequence to represent the relevance as the key-value pair cache state data updated by the node in the current round of message passing.
[0105] Optionally, in the input sequence, the token corresponding to the hidden state data updated by the node in the previous round of message passing is determined as the target token, and the target token is in the input sequence after other tokens; The determining module 702 is further configured to obtain the hidden state data of the node updated in this round of message passing based on the context-aware representation of the target token.
[0106] Optionally, in the association graph data, each node is used to represent the rich text data involved in the initial prompt word, and the edge between every two nodes is used to represent the semantic association relationship between the rich text data corresponding to every two nodes.
[0107] For ease of description, the above devices are described by dividing them into various modules or units based on their functions. Of course, when implementing one or more of these specifications, the functions of each module or unit can be implemented in the same or different software and / or hardware, or a module that performs the same function can be implemented by a combination of multiple sub-modules or sub-units, etc. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division; in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed.
[0108] Based on the same concept as the methods described above, this specification also provides an electronic device, including: a processor; a memory for storing processor-executable instructions; wherein the processor performs the steps of the method as described in any of the above embodiments by executing the executable instructions.
[0109] Based on the same concept as the methods described above, this specification also provides a computer-readable storage medium having computer instructions stored thereon that, when executed by a processor, implement the steps of the methods as described in any of the above embodiments.
[0110] Based on the same concept as the methods described above, this specification also provides a computer program product, including a computer program / instructions that, when executed by a processor, implement the steps of the methods as described in any of the above embodiments.
[0111] What those skilled in the art will understand is: In this specification, the terms "comprising," "including," or any other variations thereof are intended to cover a non-exclusive inclusion, such that a process, method, product, 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, product, or apparatus. Without further limitation, the presence of additional identical or equivalent elements in a process, method, product, or apparatus that includes said elements is not excluded.
[0112] In this specification, "a," "an," and "the" do not specifically refer to the singular, but may also include the plural.
[0113] In this specification, ordinal numbers such as "first," "second," etc., do not necessarily indicate order; they are often used to distinguish between objects. For example, "first server" and "second server" usually refer to two servers. To differentiate between these two servers, they are described as "first server" and "second server." Of course, sometimes these two servers may be the same server.
[0114] In this specification, unless explicitly stated otherwise, "receiving and sending data" does not necessarily mean direct receiving and sending; it can also mean indirect receiving and sending. For example, A receiving data sent by B can be understood as A directly receiving the data sent by B, or it can be understood as A indirectly receiving the data sent by B through other entities such as C. Similarly, B sending data to A can be understood as B sending the data directly to A, or it can be understood as B indirectly sending the data to A through other entities such as C. Here, C can be one entity, or it can be two or more entities.
[0115] In this specification, unless explicitly stated otherwise, the relationships between structures can be direct or indirect. For example, when describing "A is connected to B," unless it is explicitly stated that A and B are directly connected, it should be understood that A can be directly connected to B or indirectly connected to B. Similarly, when describing "A is on top of B," unless it is explicitly stated that A is directly above B (AB is adjacent and A is above B), it should be understood that A can be directly above B or indirectly above B (AB is separated by other elements, and A is above B). And so on.
[0116] This specification uses specific terms to describe embodiments thereof. Terms such as "an embodiment," "one embodiment," and / or "some embodiments" refer to a particular feature, structure, or characteristic associated with at least one embodiment of this specification. Therefore, it should be emphasized and noted that references to "an embodiment," "one embodiment," or "an alternative embodiment" in different locations throughout this specification do not necessarily refer to the same embodiment. Furthermore, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described herein, as well as the features of those different embodiments or examples.
[0117] Although one or more embodiments of this specification provide method steps as described in the embodiments or flowcharts, it is understood that the order of steps listed in the embodiments or flowcharts is only one of many possible execution orders and does not represent the only execution order. Therefore, when the claims involve method steps, any changes or adjustments to the order of such steps, or the parallelism between steps, are also within the scope of protection of the claims.< / eos> < / s>
Claims
1. A data generation method, comprising: Obtain the initial prompt word and the associated graph data of the initial prompt word; The association graph data is used to provide a basis for generating target data based on the initial prompt words; Determine the key-value pair cache state data for each node in the association graph data; wherein, for each node, the key-value pair cache state data of that node is obtained after multiple rounds of message passing based on the association graph data; in any round of message passing, the original node data of that node, the key-value pair cache state data of all neighboring nodes of that node updated in the previous round of message passing, and the hidden state data of that node updated in the previous round of message passing are input into a preset large language model to obtain the key-value pair cache state data of that node updated in the current round of message passing; The key-value pair cached state data of each node in the association graph data is used as context data and input into the large language model along with the initial prompt word to generate the target data through the large language model.
2. The method as described in claim 1, wherein obtaining the initial prompt word and the association graph data of the initial prompt word specifically includes: Get the initial prompt word; Feature extraction is performed on the initial prompt word to determine the prompt word feature data of the initial prompt word; Subgraph data matching the prompt word feature data is retrieved from the preset graph structure data and used as the associated graph data of the initial prompt word; the similarity between the hidden state data of the nodes contained in the subgraph data and the prompt word feature data is higher than a preset similarity threshold.
3. The method as described in claim 1, wherein obtaining the initial prompt word and the association graph data of the initial prompt word specifically includes: Get the initial prompt word; Retrieve sub-graph data that matches the initial prompt word from the preset graph structure data; The subgraph data is modified to create nodes in the subgraph data to represent the initial prompt word, and the modified subgraph data is determined as the association graph data of the initial prompt word.
4. The method as described in claim 1, wherein for each node in the association graph data, the key-value pair cache state data of the node updated in the previous message passing round used in the first round of message passing is the initial key-value pair cache state data of the node; the hidden state data of the node updated in the previous message passing round used in the first round of message passing is the initial hidden state data of the node; the initial key-value pair cache state data and the initial hidden state data are extracted by inputting the original node data of the node and the preset initial summary feature data into the large language model.
5. The method as described in claim 1, wherein the original node data of the node, the key-value pair cache state data updated by all neighboring nodes of the node in the previous round of message passing, and the hidden state data of the node updated in the previous round of message passing are input into the large language model to obtain the key-value pair cache state data of the node updated in the current round of message passing, specifically including: The input sequence is obtained by concatenating the original node data of the node, the key-value pair cache state data of all the node's neighboring nodes updated in the previous round of message passing, and the hidden state data of the node updated in the previous round of message passing. The input sequence is input into the large language model, so that for each input token in the input sequence, the large language model determines the relevance between the input token and each input token preceding it in the input sequence, and aggregates each preceding input token according to the relevance to obtain a context-aware representation of the input token. The key vector and value vector calculated by the large language model for each token in the input sequence to represent the relevance during the processing of the input sequence are used as the updated key-value pair cache state data of the node in this round of message passing.
6. The method of claim 5, wherein in the input sequence, the token corresponding to the hidden state data updated by the node in the previous round of message passing is determined as the target token, and the target token is ordered after other tokens in the input sequence; the method further comprises: Based on the context-aware representation of the target token, the hidden state data of the node updated in this round of message passing is obtained.
7. The method as described in claim 1, wherein in the association graph data, each node is used to represent the rich text data involved in the initial prompt word, and the edge between every two nodes is used to represent the semantic association relationship between the rich text data corresponding to every two nodes.
8. A data generation apparatus, comprising: The acquisition module is used to acquire the initial prompt word and the associated graph data of the initial prompt word; The association graph data is used to provide a basis for generating target data based on the initial prompt words; The determination module is used to determine the key-value pair cache state data of each node in the association graph data; wherein, for each node, the key-value pair cache state data of the node is obtained after multiple rounds of message passing based on the association graph data; in any round of message passing, the original node data of the node, the key-value pair cache state data of all the neighboring nodes of the node updated in the previous round of message passing, and the hidden state data of the node updated in the previous round of message passing are input into a preset large language model to obtain the key-value pair cache state data of the node updated in the current round of message passing; The generation module is used to take the key-value pair cached state data of each node in the association graph data as context data, and input it along with the initial prompt word into the large language model, so as to generate the target data through the large language model.
9. An electronic device, comprising: processor; A memory for storing processor-executable instructions; wherein the processor implements the steps of the method as described in any one of claims 1-7 by executing the executable instructions.
10. A computer-readable storage medium having stored thereon computer instructions that, when executed by a processor, implement the steps of the method as claimed in any one of claims 1-7.
11. A computer program product comprising a computer program / instructions that, when executed by a processor, implement the steps of the method as claimed in any one of claims 1-7.