Method and apparatus for generating textual description of graph data, storage medium, and electronic device
The graph data is converted through the pre-trained graph-to-text model, and combined with the graph neural network and large language model to generate accurate text descriptions, solving the efficiency and accuracy of graph data descriptions and achieving efficient text generation.
Patent Information
- Application Number
- PCT/CN2024/126537
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-01-23
- Filing Date
- 2024-10-22
- Publication Date
- 2025-07-31
AI Technical Summary
The prior art is difficult to quickly and accurately describe the graph data in text, resulting in high professionalism and time consumption.
The pre-trained target graph-to-text model is used to convert graph data, and the encoder decoder model of graph neural network and Transformer architecture is used to generate text description labels based on large language models and central information. Model parameters are optimized through iterative training to improve description accuracy and diversity.
It realizes fast and accurate text description of graph data, reduces professional requirements and time consumption, and improves the efficiency and quality of description.
Smart Images

Figure CN2024126537_31072025_PF_FP_ABST
Abstract
Description
Method, device, storage medium and electronic device for generating text description of graph data
[0001] Related applications
[0002] This application claims priority to Chinese patent application number 2024100952465, filed on January 23, 2024, entitled “Method, device, storage medium and electronic device for generating text description of graph data”, the entire text of which is hereby incorporated by reference. Technical Field
[0003] The present application relates to the field of graph processing technology, and in particular to a method, device, storage medium, electronic device, and computer program product for generating text descriptions of graph data. Background Art
[0004] A graph is an abstract data type whose data structure consists of a finite set of nodes and an unordered or ordered set of pairs of edges. In our daily lives, a vast amount of data exists in the form of such graphs, such as social network data and protein structure data. Unlike ordinary text, images, and other data, the information described by a graph is logically complex and has diverse content. Therefore, describing it holistically requires considerable expertise and time.
[0005] Summary of the Invention
[0006] Embodiments of the present application provide a method, device, storage medium, electronic device, and computer program product for generating a text description of graph data.
[0007] According to one aspect of an embodiment of the present application, a method for generating a text description of graph data is provided, including: obtaining target graph data to be described; converting the target graph data using a pre-trained target graph-to-text model to obtain a target text description corresponding to the target graph data, wherein the target graph-to-text model is obtained by iteratively training an initial graph-to-text model with multiple groups of sample data, each group of sample data includes: a graph data sample and a corresponding text description label, and the text description label is determined by a first text description obtained by describing the graph data sample by the target object and a second text description obtained based on the centrality information of the graph data sample.
[0008] Optionally, the training process of the target graph-to-text model includes: determining an initial graph-to-text model, wherein the initial graph-to-text model includes: an encoder based on a graph neural network and a decoder based on a Transformer architecture; obtaining multiple sets of sample data; inputting each set of sample data into the initial graph-to-text model in turn for iterative training to obtain the target graph-to-text model.
[0009] Optionally, multiple groups of sample data are obtained, including: obtaining multiple graph data samples; for each graph data sample, obtaining a first text description of the target object describing the graph data sample; performing a centrality analysis on the graph data sample to obtain centrality information, and generating a second text description based on a preset text description template and the centrality information; using a large language model to integrate information of the first text description and the second text description to obtain corresponding text description labels; and forming multiple groups of sample data from multiple graph data samples and the text description labels corresponding to each graph data sample.
[0010] Optionally, each group of sample data is input into the initial image-to-text model in turn for iterative training to obtain a target image-to-text model, including: for each group of sample data, extracting features from the image data sample through an encoder to obtain a corresponding image embedding representation, and decoding the image embedding representation using a decoder to obtain a corresponding predicted text description; using a preset text similarity method to determine the text similarity between the text description labels in each group of sample data and the predicted text description, and determining a loss function based on the text similarity; adjusting the model parameters of the initial image-to-text model according to the loss function to obtain a target image-to-text model.
[0011] Optionally, the graph data sample is encoded by an encoder to obtain a corresponding graph embedding representation, including: determining multiple graph nodes within the graph data sample, and determining a node embedding representation of each graph node; and determining a graph embedding representation corresponding to the graph data sample based on the mean of the node embedding representations of multiple graph nodes.
[0012] Optionally, the graph embedding representation is decoded using a decoder to obtain a corresponding predicted text description, including: using the decoder to process the graph embedding representation to obtain a first predicted word; repeatedly using the decoder to process the previous predicted word and the graph embedding representation to obtain a current predicted word; and combining multiple current predicted words in sequence according to the output order of the decoder to obtain a predicted text description.
[0013] Optionally, the text similarity method includes at least one of the following: a text similarity method based on cosine similarity, a text similarity method based on Jaccard similarity, and a text similarity method based on Hamming distance.
[0014] Optionally, the data structure of the target graph data includes a finite set as a node set, and a set of unordered pairs or ordered pairs as edges.
[0015] Optionally, the target graph data is at least one of the following: an organizational chart, a network topology graph, and a social network graph.
[0016] Optionally, obtaining the plurality of graph data samples includes: obtaining a plurality of graph data samples from an open source dataset.
[0017] Optionally, obtaining a first text description of the graph data sample by the target object includes: obtaining a first text description of the graph data sample manually described by a professional of the graph data sample.
[0018] Optionally, the compared text similarity includes: semantic similarity and character similarity.
[0019] According to another aspect of an embodiment of the present application, a device for generating a text description of graph data is also provided, including: an acquisition module for acquiring target graph data to be described; a text generation module for converting the target graph data using a pre-trained target graph-to-text model to obtain a target text description corresponding to the target graph data, wherein the target graph-to-text model is obtained by iteratively training an initial graph-to-text model using multiple groups of sample data, and each group of sample data includes: a graph data sample and a corresponding text description label, and the text description label is determined by a first text description obtained by describing the graph data sample by the target object and a second text description obtained based on the centrality information of the graph data sample.
[0020] According to another aspect of an embodiment of the present application, a non-volatile storage medium is further provided, which includes a stored computer program, wherein the device where the non-volatile storage medium is located executes the above-mentioned method for generating a text description of graph data by running the computer program.
[0021] According to another aspect of an embodiment of the present application, an electronic device is further provided, which includes: a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to execute the above-mentioned text description generation method of graph data through the computer program.
[0022] According to another aspect of an embodiment of the present application, a computer program product is further provided, including a computer program, wherein the computer program implements the above-mentioned method for generating a text description of graph data when executed by a processor.
[0023] In an embodiment of the present application, target graph data to be described is obtained; the target graph data is converted using a pre-trained target graph-to-text model to obtain a target text description corresponding to the target graph data, wherein the target graph-to-text model is obtained by iteratively training an initial graph-to-text model with multiple groups of sample data, and each group of sample data includes: a graph data sample and a corresponding text description label, and the text description label is determined by a first text description obtained by the target object describing the graph data sample and a second text description obtained based on the centrality information of the graph data sample. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0025] FIG1 is a hardware structure block diagram of a computer terminal for implementing an optional method for generating a text description of graph data according to an embodiment of the present application;
[0026] FIG2 is a flow chart of an optional method for generating a text description of graph data according to an embodiment of the present application;
[0027] FIG3 is a schematic diagram of an optional graph data sample according to an embodiment of the present application;
[0028] FIG4 is a schematic diagram of an optional method for generating a predicted text description according to an embodiment of the present application;
[0029] FIG5 is a result diagram of an optional apparatus for generating text descriptions of graph data according to an embodiment of the present application. DETAILED DESCRIPTION
[0030] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0031] In order to enable those skilled in the art to better understand the present invention, the following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of this application.
[0032] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in a sequence other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0033] In addition, the relevant information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for display, data for analysis, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties. For example, an interface is set up between this system and the relevant user or organization. Before obtaining relevant information, it is necessary to send an acquisition request to the aforementioned user or organization through the interface, and obtain the relevant information after receiving the consent information fed back by the aforementioned user or organization.
[0034] In order to better understand the embodiments of the present application, the technical terms involved in the embodiments of the present application are explained as follows:
[0035] Graph embedding (also known as network embedding) is a vector representation of each node in a graph consisting of nodes and edges, also known as an embedding vector. Graph embedding maps graph data (typically high-dimensional, dense matrices) into low-dimensional, dense vectors, effectively addressing the difficulty of efficiently inputting graph data into machine learning algorithms.
[0036] Centrality represents the importance of each node in a graph. Generally speaking, degree centrality is a relatively easy-to-understand centrality, where importance is defined as the in-degree of a node.
[0037] A large language module is a model trained using deep learning techniques for generating and understanding natural language text. This model can predict the next word or character, understand the syntax and semantics of a language, generate coherent text, and perform language-related tasks such as machine translation, text summarization, and question-answering. Large language models are typically based on neural network structures and trained using large corpora. They are capable of learning and representing complex language patterns and structures. One of the most famous large language models is OpenAI's GPT (Generative Pre-trained Transformer) series.
[0038] Transe is a method for learning relationships between nodes in a graph. It captures the structural information in the graph by learning the transformation relationships between nodes. Generally speaking, the Transe method is widely used in relation extraction and reasoning tasks in knowledge graphs.
[0039] Deepwalk is a method for learning node representations in graphs. It generates node sequences by simulating random walks and then uses these node sequences to learn vector representations of the nodes. Generally, the Deepwalk method can be used for tasks such as graph classification, node classification, and link prediction.
[0040] Example 1
[0041] According to an embodiment of the present application, a method embodiment of a method for generating a text description of graph data is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0042] The method embodiments provided in the embodiments of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Figure 1 shows a hardware structure block diagram of a computer terminal for implementing a text description generation method for graph data. As shown in Figure 1, the computer terminal 10 may include one or more (102a, 102b, ..., 102n are used in the figure to illustrate) processors 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 104 for storing data, and a transmission device 106 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the BUS bus), a network interface, a power supply and / or a camera. It will be understood by those skilled in the art that the structure shown in Figure 1 is only illustrative and does not limit the structure of the above-mentioned electronic device. For example, the computer terminal 10 may also include more or fewer components than those shown in Figure 1, or have a configuration different from that shown in Figure 1.
[0043] It should be noted that the one or more processors 102 and / or other data processing circuits described above may generally be referred to herein as "data processing circuitry." The data processing circuitry may be embodied in whole or in part as software, hardware, firmware, or any other combination thereof. Furthermore, the data processing circuitry may be a single, independent processing module, or may be incorporated in whole or in part into any of the other components of the computer terminal 10. As described in the embodiments of the present application, the data processing circuitry serves as a processor control (e.g., selection of a variable resistor terminal path connected to an interface).
[0044] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the text description generation method of the graph data in the embodiment of the present application. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, that is, implementing the text description generation method of the graph data of the above-mentioned application. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include a memory remotely located relative to the processor 102, and these remote memories may be connected to the computer terminal 10 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0045] The transmission device 106 is configured to receive or transmit data via a network. A specific example of the aforementioned network may include a wireless network provided by the communications provider of the computer terminal 10. In one embodiment, the transmission device 106 includes a network interface controller (NIC), which can be connected to other network devices via a base station to enable communication with the Internet. In another embodiment, the transmission device 106 may be a radio frequency (RF) module, which is configured to communicate with the Internet wirelessly.
[0046] The display may be, for example, a touch screen liquid crystal display (LCD) that enables a user to interact with a user interface of the computer terminal 10 .
[0047] In the above operating environment, FIG2 is a flow chart of an optional method for generating a text description of graph data according to an embodiment of the present application. As shown in FIG2 , the method includes at least steps S202 to S204, wherein:
[0048] Step S202: Obtain target graph data to be described.
[0049] The target graph data can be any graph data to be described, whose data structure includes a finite set of nodes and sets of unordered or ordered pairs of edges. Examples include organizational charts, network topology diagrams, and social network diagrams. The target graph data to be described can be determined based on actual business scenarios.
[0050] Step S204: convert the target graph data using a pre-trained target graph-to-text model to obtain a target text description corresponding to the target graph data.
[0051] Among them, the above-mentioned target graph-to-text model is obtained by iteratively training the initial graph-to-text model with multiple groups of sample data. Each group of sample data includes: a graph data sample and a corresponding text description label, and the text description label is determined by the first text description obtained by the target object describing the graph data sample and the second text description obtained based on the centrality information of the graph data sample.
[0052] Based on the scheme defined in the above steps S202 to S204, it can be known that in an embodiment, the target graph data to be described is obtained; and the target graph data is converted using a pre-trained target graph-to-text model, so that a relatively accurate target text description corresponding to the target graph data can be quickly obtained.
[0053] It can be seen that the image-to-text model trained with graph data samples, the first text description obtained by describing the graph data samples using the target object, and the text description labels determined by the second text description obtained based on the centrality information of the graph data samples can improve the accuracy and diversity of the model description, and realize the efficient and accurate use of the image-to-text model to generate the text description corresponding to the graph data, thereby solving the technical problem that related technologies cannot quickly and accurately perform text descriptions on graph data.
[0054] The above method of this embodiment is further introduced below.
[0055] As an optional implementation, in the technical solution provided in step S204 above, the training process of the target graph-to-text model may include:
[0056] Step S1: Determine the initial image-to-text model.
[0057] Among them, the initial graph-to-text model includes: an encoder based on the Graph Neural Network (GNN) and a decoder based on the Transformer architecture.
[0058] Step S2: Acquire multiple groups of sample data.
[0059] Optionally, in the technical solution provided in step S2 above, the specific implementation process of the method includes:
[0060] Step S21, obtaining multiple graph data samples;
[0061] Step S22: For each graph data sample, obtain the first text description of the target object describing the graph data sample; perform centrality analysis on the graph data sample to obtain centrality information, and generate a second text description based on a preset text description template and centrality information; use a large language model to integrate the first text description and the second text description to obtain a corresponding text description label.
[0062] Step S23 , forming multiple groups of sample data from multiple graph data samples and text description labels corresponding to each graph data sample.
[0063] Specifically, in the technical solution provided by the above steps S21-S23, multiple graph data samples can be first obtained from the open source dataset, and for each graph data sample, its corresponding text description label can use the large language model to manually generate a description A (i.e., the first text description) by professionals who have a relatively good understanding of the graph data sample, and obtain centrality information by analyzing the centrality features of the graph data sample, and integrate it with the description B (i.e., the second text description) generated by a preset text description template.
[0064] For example, FIG3 is a schematic diagram of an optional graph data sample according to an embodiment of the present application. As shown in FIG3 , the process of generating a text description label corresponding to the graph data sample is as follows:
[0065] First, professionals describe the graph data sample shown in Figure 3 and generate description A: This graph belongs to the medical field and mainly contains information such as diseases, corresponding symptoms of diseases, and commonly used drugs for treating diseases, which can be used to assist medical treatment;
[0066] Then, statistics are collected on the centrality and other information within the graph data sample shown in Figure 3, and descriptions B are generated according to a preset template. That is, centrality evaluation methods such as "degree centrality" are used to evaluate the importance of nodes in the graph. Then, based on the importance of nodes, descriptions are generated according to the template. If the template is: "[more important nodes], etc. are important entities in this graph", and the graph data sample shown in Figure 3 shows that "cold" and "fever" are more important according to degree centrality analysis, the description B generated based on the template is: cold, fever, etc. are more important entities in this graph.
[0067] Finally, descriptions A and B are input into the large language model. The prompt template fed into the large language model is: "The following sentences describe a certain graph data structure. Please combine these sentences to describe the graph: 1) Describe A; 2) Describe B." For the graph data sample shown in Figure 3, the question fed into the large language model is: "The following sentences describe a certain graph data structure. Please combine these sentences to describe the graph." 1) Cold, fever, etc. are important entities in this graph. 2) This graph belongs to the medical field and primarily contains information about diseases, their corresponding symptoms, and commonly used medications for treating them. It can be used to assist in medical care. The final text description label generated by the large prediction model is: "This graph is a medical graph data structure. It primarily depicts diseases, their corresponding symptoms, and commonly used medications for treating them." In this graph, cold and fever are important entities. This graph can be used to assist in medical work, providing doctors and patients with detailed information about diseases, symptoms, and treatment options. In summary, this graph aims to help medical professionals and patients better understand and address various diseases, providing strong support for clinical diagnosis and treatment.
[0068] In step S3, each set of sample data is sequentially input into the initial graph-to-text model for iterative training to obtain a target graph-to-text model.
[0069] Optionally, in the technical solution provided in step S3 above, the specific implementation process of the method includes:
[0070] In step S31, for each set of sample data, the encoder is used to extract features of the graph data sample to obtain a corresponding graph embedding representation, and the decoder is used to decode the graph embedding representation to obtain a corresponding predicted text description.
[0071] Specifically, in the technical solution provided in the above step S31, the above graph embedding representation can be obtained by the following method: determining multiple graph nodes within the graph data sample, and determining the node embedding representation of each graph node; determining the graph embedding representation corresponding to the graph data sample based on the mean of the node embedding representations of multiple graph nodes.
[0072] Specifically, the generation scheme of the above graph embedding representation is as follows:
[0073] First, we use graph embedding representation methods such as Transe and Deepwalk to obtain a node embedding representation (i.e., a high-dimensional vector representation, also known as a node embedded representation) for each graph node in the graph data sample. If the dimension of the embedding representation is set to 3, then the node embedding representation of each graph node in the graph data sample shown in Figure 3 is also a 3-dimensional vector, for example: [0.21, 0.35, 0.62].
[0074] Secondly, the mean of the node embedding representation of each node is calculated to obtain the graph embedding representation corresponding to the entire graph data sample, denoted as E.
[0075] In addition, in the technical solution provided in the above step S31, the above-mentioned predicted text description can be obtained by the following method: using the decoder to process the graph embedding representation to obtain the first predicted word; repeatedly using the decoder to process the previous predicted word and the graph embedding representation to obtain the current predicted word; combining multiple current predicted words in sequence according to the output order of the decoder to obtain the predicted text description.
[0076] Specifically, the generation scheme of the above-mentioned predicted text description is shown in FIG4 , including:
[0077] First, the entire image embedding representation E is fed into the GPT model (which internally contains a decoder based on the Transformer architecture) to obtain the first predicted description word w1 for the image data sample;
[0078] Next, the whole image embedding representation E and the first predicted description word w1 are fed into the GPT model to obtain the second predicted description word w2 of the image data sample. The whole image embedding representation E, the first predicted description word w1 and the second predicted description word w2 are then fed into the GPT model to obtain the third predicted description word w3 of the image data sample. This process is repeated until the predicted description word wn is obtained.
[0079] Finally, these predicted description words are combined in sequence according to the prediction order, that is, the first predicted description word w1, the second predicted description word w2, ..., the nth predicted description word wn are combined to obtain the predicted text description.
[0080] Step S32: using a preset text similarity method to determine the text similarity between the text description labels and the predicted text descriptions in each group of sample data, and determining a loss function based on the text similarity.
[0081] The text similarity method includes at least one of the following: a text similarity method based on cosine similarity, a text similarity method based on Jaccard similarity, and a text similarity method based on Hamming distance. In addition, the text similarity compared above may include, but is not limited to, semantic similarity and character similarity.
[0082] The technical solution provided in the above step S32 can be understood as, for each set of sample data, using the graph-to-text model to predict the text description of the graph data sample to obtain the predicted text description, and using the text similarity method to calculate the text similarity between the predicted text description and the text description label in the sample data; then, using multiple text similarities to determine the loss function.
[0083] Step S33 , adjusting the model parameters of the initial image-to-text model according to the loss function to obtain a target image-to-text model.
[0084] In the technical solution provided by steps S31-S33 above, the initial image-to-text model predicts text descriptions for each image data sample. A text similarity method is then used to calculate the text similarity between the text description label and the corresponding predicted text description. This similarity is then used as the evaluation basis for the loss function to update and adjust the model parameters of the initial image-to-text model to obtain the target image-to-text model. A higher similarity indicates a better image-to-text model.
[0085] Through the above embodiments, it is possible to quickly generate text descriptions of graph data, reducing the professional requirements and time consumption when generating graph descriptions.
[0086] Example 2
[0087] Based on Example 1 of the present application, an embodiment of a device for generating a text description of graph data is also provided. When the device is running, it executes the method for generating a text description of graph data described in the above embodiment. FIG5 is a schematic structural diagram of an optional device for generating a text description of graph data according to an embodiment of the present application. As shown in FIG5 , the device for generating a text description of graph data includes at least an acquisition module 51 and a text generation module 52, wherein:
[0088] An acquisition module 51 is used to acquire target graph data to be described;
[0089] The text generation module 52 is used to convert the target graph data using a pre-trained target graph-to-text model to obtain a target text description corresponding to the target graph data, wherein the target graph-to-text model is obtained by iteratively training the initial graph-to-text model with multiple groups of sample data, and each group of sample data includes: a graph data sample and a corresponding text description label, and the text description label is determined by a first text description obtained by the target object describing the graph data sample and a second text description obtained based on the centrality information of the graph data sample.
[0090] Step S1: Determine the initial image-to-text model.
[0091] Among them, the initial graph-to-text model includes: an encoder based on the Graph Neural Network (GNN) and a decoder based on the Transformer architecture.
[0092] Step S2: Acquire multiple groups of sample data.
[0093] Optionally, in the technical solution provided in step S2 above, the specific implementation process of the method includes:
[0094] Step S21, obtaining multiple graph data samples;
[0095] Step S22: For each graph data sample, obtain the first text description of the target object describing the graph data sample; perform centrality analysis on the graph data sample to obtain centrality information, and generate a second text description based on a preset text description template and centrality information; use a large language model to integrate the first text description and the second text description to obtain a corresponding text description label.
[0096] Step S23 , forming multiple groups of sample data from multiple graph data samples and text description labels corresponding to each graph data sample.
[0097] Specifically, in the technical solution provided by the above steps S21-S23, multiple graph data samples can be first obtained from the open source dataset, and for each graph data sample, its corresponding text description label can use the large language model to manually generate a description A (i.e., the first text description) by professionals who have a relatively good understanding of the graph data sample, and obtain centrality information by analyzing the centrality features of the graph data sample, and integrate it with the description B (i.e., the second text description) generated by a preset text description template.
[0098] In step S3, each set of sample data is sequentially input into the initial graph-to-text model for iterative training to obtain a target graph-to-text model.
[0099] Optionally, in the technical solution provided in step S3 above, the specific implementation process of the method includes:
[0100] In step S31, for each set of sample data, the encoder is used to extract features of the graph data sample to obtain a corresponding graph embedding representation, and the decoder is used to decode the graph embedding representation to obtain a corresponding predicted text description.
[0101] Specifically, in the technical solution provided in the above step S31, the above graph embedding representation can be obtained by the following method: determining multiple graph nodes within the graph data sample, and determining the node embedding representation of each graph node; determining the graph embedding representation corresponding to the graph data sample based on the mean of the node embedding representations of multiple graph nodes.
[0102] In addition, in the technical solution provided in the above step S31, the above-mentioned predicted text description can be obtained by the following method: using the decoder to process the graph embedding representation to obtain the first predicted word; repeatedly using the decoder to process the previous predicted word and the graph embedding representation to obtain the current predicted word; combining multiple current predicted words in sequence according to the output order of the decoder to obtain the predicted text description.
[0103] Step S32: using a preset text similarity method to determine the text similarity between the text description labels in each group of sample data and the corresponding predicted text descriptions, and determining a loss function based on the text similarity.
[0104] The text similarity method includes at least one of the following: a text similarity method based on cosine similarity, a text similarity method based on Jaccard similarity, and a text similarity method based on Hamming distance.
[0105] Step S33 , adjusting the model parameters of the initial image-to-text model according to the loss function to obtain a target image-to-text model.
[0106] In the technical solution provided by steps S31-S33 above, the initial image-to-text model predicts text descriptions for each image data sample. A text similarity method is then used to calculate the text similarity between the text description label and the predicted text description. This similarity is then used as the evaluation basis for the loss function to update and adjust the model parameters of the initial image-to-text model to obtain the target image-to-text model. A higher similarity indicates a better image-to-text model.
[0107] It should be noted that the various modules in the above-mentioned text description generation device for graph data can be program modules (for example, a set of program instructions that implement a certain specific function) or hardware modules. For the latter, it can be expressed in the following forms, but is not limited to this: the expression form of each of the above-mentioned modules is a processor, or the functions of each of the above-mentioned modules are implemented by a processor.
[0108] The features described in the embodiment of the aforementioned method for generating a text description of graph data are applicable to the embodiment of the device for generating a text description of graph data. The preferred implementation of the embodiment of the device for generating a text description of graph data can be found in the relevant description in the embodiment of the aforementioned method for generating a text description of graph data, and will not be repeated here.
[0109] Example 3
[0110] According to an embodiment of the present application, a non-volatile storage medium is also provided, in which a program is stored. When the program is running, the device where the non-volatile storage medium is located is controlled to execute the text description generation method of the graph data in Example 1.
[0111] Optionally, the device where the non-volatile storage medium is located implements the following steps by running the program:
[0112] Step S202, obtaining target graph data to be described;
[0113] Step S204: Use the pre-trained target graph-to-text model to convert the target graph data to obtain a target text description corresponding to the target graph data, wherein the target graph-to-text model is obtained by iteratively training the initial graph-to-text model with multiple groups of sample data, and each group of sample data includes: a graph data sample and a corresponding text description label, and the text description label is determined by a first text description obtained by the target object describing the graph data sample and a second text description obtained based on the centrality information of the graph data sample.
[0114] The features described in the embodiment of the method for generating a text description of the aforementioned graph data are applicable to the embodiment of the non-volatile storage medium. The preferred implementation of the embodiment of the non-volatile storage medium can be found in the relevant description in the embodiment of the method for generating a text description of the aforementioned graph data, and will not be repeated here.
[0115] According to an embodiment of the present application, an electronic device is also provided, wherein the electronic device includes one or more processors; a memory for storing one or more programs, which, when the one or more programs are executed by the one or more processors, enables the one or more processors to run the programs, wherein the program is configured to execute the text description generation method of the graph data in the above-mentioned embodiment 1 when running.
[0116] Optionally, the processor is configured to implement the following steps by executing a computer program:
[0117] Step S202, obtaining target graph data to be described;
[0118] Step S204: Use the pre-trained target graph-to-text model to convert the target graph data to obtain a target text description corresponding to the target graph data, wherein the target graph-to-text model is obtained by iteratively training the initial graph-to-text model with multiple groups of sample data, and each group of sample data includes: a graph data sample and a corresponding text description label, and the text description label is determined by a first text description obtained by the target object describing the graph data sample and a second text description obtained based on the centrality information of the graph data sample.
[0119] The features described in the embodiment of the method for generating a text description of the aforementioned graph data are applicable to the embodiment of the electronic device. The preferred implementation of the embodiment of the electronic device can refer to the relevant description in the embodiment of the method for generating a text description of the aforementioned graph data, which will not be repeated here.
[0120] The serial numbers of the above embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0121] In the above embodiments of the present application, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0122] According to an embodiment of the present application, a computer program product is further provided, including a computer program, which, when executed by a processor, implements the steps of the method for generating a text description of graph data according to the above embodiment:
[0123] Step S202, obtaining target graph data to be described;
[0124] Step S204: Use the pre-trained target graph-to-text model to convert the target graph data to obtain a target text description corresponding to the target graph data, wherein the target graph-to-text model is obtained by iteratively training the initial graph-to-text model with multiple groups of sample data, and each group of sample data includes: a graph data sample and a corresponding text description label, and the text description label is determined by a first text description obtained by the target object describing the graph data sample and a second text description obtained based on the centrality information of the graph data sample.
[0125] The features described in the embodiment of the method for generating a text description of graph data described above are applicable to the embodiment of the computer program product. The preferred implementation of the embodiment of the computer program product can be found in the relevant description in the embodiment of the method for generating a text description of graph data described above, and will not be repeated here.
[0126] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only exemplary. For example, the division of units can be a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0127] Units described as separate components may or may not be physically separate, and components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple units. Some or all of the units may be selected to achieve the purpose of the present embodiment according to actual needs.
[0128] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0129] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the relevant technology, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, server or network device, etc.) to execute all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.
[0130] The above is only a preferred embodiment of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
[0131] The technical features of the above-mentioned embodiments can be combined arbitrarily. In order to make the description concise, not all possible combinations of the technical features in the above-mentioned embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0132] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the patent application. It should be noted that a person of ordinary skill in the art may make various modifications and improvements without departing from the spirit of the present application, and these modifications and improvements fall within the scope of protection of the present application. Therefore, the scope of protection of the present patent application shall be determined by the appended claims.
Claims
1. A method for generating a text description of graph data, comprising: Obtaining target graph data to be described; Using a pre-trained target graph-to-text model to transform the target graph data to obtain a target text description corresponding to the target graph data, wherein the target graph-to-text model is obtained by iteratively training an initial graph-to-text model with multiple groups of sample data, and each group of the sample data includes: a graph data sample and a corresponding text description label, and the text description label is determined by a first text description obtained by a target object describing the graph data sample and a second text description obtained based on the centrality information of the graph data sample.
2. The method according to claim 1, wherein, The training process of the target graph-to-text model includes: Determining the initial graph-to-text model, wherein the initial graph-to-text model includes: an encoder based on a graph neural network and a decoder based on a Transformer architecture; Obtaining multiple groups of the sample data; Sequentially inputting each group of the sample data into the initial graph-to-text model for iterative training to obtain the target graph-to-text model.
3. The method according to claim 2, wherein Obtaining multiple groups of the sample data includes: Obtaining multiple of the graph data samples; For each of the graph data samples, obtaining a first text description of the graph data sample described by the target object; performing centrality analysis on the graph data sample to obtain the centrality information, and generating the second text description according to a preset text description template and the centrality information; using a large language model to integrate information of the first text description and the second text description to obtain the corresponding text description label; Composing multiple groups of the sample data from the multiple graph data samples and the text description label corresponding to each graph data sample.
4. The method according to claim 2, wherein, Sequentially inputting each group of the sample data into the initial graph-to-text model for iterative training to obtain the target graph-to-text model, including: For each group of the sample data, extracting features of the graph data sample through the encoder to obtain a corresponding graph embedding representation, and using the decoder to decode the graph embedding representation to obtain a corresponding predicted text description; Using a preset text similarity method to determine the text similarity between the text description label and the predicted text description in each group of the sample data, and determining a loss function based on the text similarity; Adjusting the model parameters of the initial graph-to-text model according to the loss function to obtain the target graph-to-text model.
5. The method according to claim 4, wherein, Encoding the graph data sample through the encoder to obtain a corresponding graph embedding representation, including: Determining multiple graph nodes in the graph data sample, and determining the node embedding representation of each of the graph nodes; Determining the graph embedding representation corresponding to the graph data sample based on the mean of the node embedding representations of the multiple graph nodes.
6. The method according to claim 4, wherein, Using the decoder to decode the graph embedding representation to obtain a corresponding predicted text description, including: Using the decoder to process the graph embedding representation to obtain a first predicted word; Repeatedly using the decoder to process the previous predicted word and the graph embedding representation to obtain the current predicted word; Combine the multiple current predicted words in sequence according to the output order of the decoder to obtain the predicted text description.
7. The method according to claim 4, wherein The text similarity method includes at least one of the following: a text similarity method based on cosine similarity, a text similarity method based on Jaccard similarity, and a text similarity method based on Hamming distance.
8. The method according to any one of claims 1 to 7, wherein, The data structure of the target graph data includes a finite set as the node set and a set of unordered pairs or ordered pairs as the edges.
9. The method according to any one of claims 1 to 8, wherein, The target graph data is at least one of the following: an organizational structure diagram, a network topology diagram, and a social network diagram.
10. The method according to claim 3, wherein The obtaining of the multiple graph data samples includes: Obtain multiple graph data samples from an open source dataset.
11. The method according to claim 3, wherein Obtaining the first text description of the target object describing the graph data sample includes: Obtain the first text description of the graph data sample manually described by a professional of the graph data sample.
12. The method according to claim 4 or 7, wherein The text similarities to be compared include: semantic similarity and character similarity.
13. A text description generation device for graph data, comprising: An acquisition module, configured to acquire target graph data to be described; A text generation module, configured to use a pre-trained target graph-to-text model to convert the target graph data to obtain a target text description corresponding to the target graph data, wherein the target graph-to-text model is obtained by iteratively training an initial graph-to-text model with multiple groups of sample data, and each group of the sample data includes: a graph data sample and a corresponding text description label, and the text description label is determined by a first text description obtained by a target object describing the graph data sample and a second text description obtained based on the centrality information of the graph data sample.
14. A non-volatile storage medium, wherein, A non-volatile storage medium stores a computer program, wherein the device where the non-volatile storage medium is located executes the text description generation method for graph data according to any one of claims 1 to 7 by running the computer program.
15. An electronic device, comprising: A memory and a processor, the processor is configured to run a program stored in the memory, wherein the program runs to execute the text description generation method for graph data according to any one of claims 1 to 7.
16. A computer program product comprising a computer program, wherein, The computer program, when executed by a processor, implements the steps of the method according to any one of claims 1 to 12.
Citation Information
Patent Citations
Atlas-based text generation method and system, electronic equipment and storage medium
CN112559761A
Text generation method and dialogue text generation method
CN116561269A
Language model training method and device based on knowledge graph
CN116796004A
Graph data text description generation method and device, storage medium and electronic equipment
CN117933385A
Methods and systems for automatic call data generation
US20230030405A1