Link prediction method and device and model training method and device

By generating and updating timing knowledge graphs, generating semantic description information, and combining large language models for link prediction, the problem of difficult to capture dynamic changes in entities and relationships in the prior art is solved, and the accuracy of link prediction is improved.

CN119692443APending Publication Date: 2025-03-25MASHANG CONSUMER FINANCE CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411609866.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-11
Publication Date
2025-03-25

AI Technical Summary

Technical Problem

Existing link prediction methods are difficult to effectively capture the dynamic changing characteristics of entities and relationships, resulting in poor accuracy when dealing with complex timing relationships.

Method used

By generating a timing knowledge graph, dynamically update the embedded data, and generate semantic description information based on this data, link prediction is carried out in combination with a large language model to capture the timing characteristics of entities and relationships.

Benefits of technology

Improves the accuracy of link prediction, can better process and understand the dependencies of embedded data, and provide a deeper semantic understanding.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119692443A_ABST
    Figure CN119692443A_ABST
Patent Text Reader

Abstract

The invention discloses a link prediction method and device and a model training method and device. The method comprises the following steps: firstly, generating a time sequence knowledge graph based on relational data of a first entity and a plurality of second entities; and when the relational data between the first entity and the second entity changes, updating the time sequence knowledge graph in response to the change, and extracting a plurality of embedded data from the updated time sequence knowledge graph. Then, semantic description information is generated based on the association relationship of the plurality of embedded data. And determining a target entity having a link relationship with the first entity in the target time period according to the semantic description information and the updated time sequence knowledge graph. In this way, the dynamic features of the time sequence knowledge graph and the semantic features of the semantic description information can be utilized at the same time, so that link prediction is more accurate.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of big data technology, and specifically to a link prediction method and device, and a model training method and device. Background Art

[0002] Link Prediction (LP) refers to the task of predicting the possible connection links that do not appear in a network based on the known partial network structure. The network may include but is not limited to social networks, knowledge graphs, and recommendation systems. Effective link prediction can provide potential connection predictions and supplement missing data, thereby providing important reference information for decision-making and planning. Summary of the invention

[0003] The purpose of this application is to provide a link prediction method and device, and a model training method and device.

[0004] In a first aspect, an embodiment of the present application provides a link prediction method, including:

[0005] Generate a temporal knowledge graph based on the relationship data between the first entity and the plurality of second entities;

[0006] In response to a change in the relationship data between the first entity and the second entity, updating the temporal knowledge graph, and extracting a plurality of embedded data from the updated temporal knowledge graph, the embedded data including vector representations of entities, relationships between the entities, and occurrence times of the relationships in the temporal knowledge graph;

[0007] Generate semantic description information based on multiple embedded data, where the semantic description information is used to express the association relationship between entities corresponding to the multiple embedded data;

[0008] According to the semantic description information and the updated temporal knowledge graph, link prediction is performed on the first entity to obtain a target entity that has a link relationship with the first entity in the target time period.

[0009] In a second aspect, an embodiment of the present application provides a model training method, comprising:

[0010] Acquire a training sample set, the training sample set includes multiple training samples, the training samples include first sample relationship data and a calibrated target entity, the first sample relationship data is relationship data between the first sample entity and multiple second sample entities;

[0011] Input each training sample in the training sample set into the model to be trained to perform link prediction, and obtain a first predicted target entity;

[0012] A loss function value is calculated according to the first prediction target and the calibrated target entity, and the parameters of the model to be trained are adjusted according to the loss function value.

[0013] In a third aspect, an embodiment of the present application provides a link prediction device, including:

[0014] A generation module, used to generate a time series knowledge graph based on the relationship data between the first entity and the plurality of second entities;

[0015] An updating module, configured to update the temporal knowledge graph in response to a change in the relationship data between the first entity and the second entity, and extract a plurality of embedded data from the updated temporal knowledge graph, wherein the embedded data includes vector representations of entities, relationships between the entities, and occurrence times of the relationships in the temporal knowledge graph;

[0016] A conversion module, used to generate semantic description information based on the multiple embedded data, where the semantic description information is used to express the association relationship between entities corresponding to the multiple embedded data;

[0017] The determination module is used to perform link prediction on the first entity based on the semantic description information and the updated temporal knowledge graph to obtain the target entity that has a link relationship with the first entity in the target time period.

[0018] In a fourth aspect, the present application provides a model training device, comprising:

[0019] An acquisition module is used to acquire a training sample set, the training sample set includes multiple training samples, the training samples include first sample relationship data and a calibration target entity, the first sample relationship data is relationship data between a first sample entity and multiple second sample entities;

[0020] A prediction module, used for inputting each training sample in the training sample set into the model to be trained to perform link prediction and obtain a first predicted target entity;

[0021] The parameter adjustment module is used to calculate the loss function value according to the first prediction target and the calibration target entity, and adjust the parameters of the model to be trained according to the loss function value.

[0022] In a fifth aspect, an embodiment of the present application also provides a computer device, including a memory and a processor, wherein the memory stores a plurality of instructions; the processor loads instructions from the memory to execute the steps of any link prediction method or any model training method provided in an embodiment of the present application.

[0023] In a sixth aspect, an embodiment of the present application also provides a computer-readable storage medium, which stores a plurality of instructions, and the instructions are suitable for a processor to load to execute the steps of any link prediction method or any model training method provided in the embodiment of the present application.

[0024] In the seventh aspect, an embodiment of the present application also provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, it implements the steps of any link prediction method or any model training method provided in the embodiment of the present application.

[0025] Using the scheme of the present application, first, a temporal knowledge graph is generated based on the relationship data between the first entity and multiple second entities. When the relationship data between the first entity and the second entity changes, the temporal knowledge graph is updated in response to the change, and multiple embedded data are extracted from the updated temporal knowledge graph. Then, semantic description information is generated based on the association relationship of multiple embedded data. Based on the semantic description information and the updated temporal knowledge graph, the target entity that has a link relationship with the first entity in the target time period is determined. In this way, the dynamically changing temporal knowledge graph can capture the dynamic changing characteristics of entities and relationships over time, and predict the link relationship within the target time period based on the semantic description information corresponding to the embedded data, providing a deeper semantic understanding. Compared with the link prediction scheme that does not refer to the temporal data, the present application can simultaneously utilize the dynamic characteristics of the temporal knowledge graph and the semantic characteristics of the semantic description information to better process and understand the dependency relationship of the embedded data, making the link prediction more accurate. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0027] Figure 1 It is a schematic diagram of an application environment of a link prediction method and a model training method provided in an embodiment of the present application;

[0028] Figure 2 It is a flowchart of a link prediction method provided in an embodiment of the present application;

[0029] Figure 3 It is a flowchart of a model training method provided in an embodiment of the present application;

[0030] Figure 4 A schematic diagram of a flow chart of a method for link prediction in model training provided in an embodiment of the present application;

[0031] Figure 5 is a structural schematic diagram of a link prediction device provided in an embodiment of the present application;

[0032] Figure 6It is a structural schematic diagram of a model training device provided in an embodiment of the present application;

[0033] Figure 7 It is a schematic diagram of the internal structure of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0034] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of the present application. At the same time, in the description of the embodiments of the present application, the terms "first", "second", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance. Thus, the features defined as "first" and "second" may explicitly or implicitly include one or more features. In the description of the embodiments of the present application, the meaning of "multiple" is two or more, unless otherwise clearly and specifically defined.

[0035] The link prediction method in one embodiment of the present application can be run on a local terminal device or a server. When the link prediction method is run on a server, the method can be implemented and executed based on a cloud interaction system, wherein the cloud interaction system includes a server and a client device.

[0036] In order to better understand the link prediction method and device, and the model training method and device provided in the embodiments of the present application, the application environment applicable to the embodiments of the present application is first described below.

[0037] See also Figure 1 , Figure 1 Schematic diagram of an application environment of a link prediction method and a model training method provided in an embodiment of the present application. As an example, the link prediction method is run on Figure 1 As an example, the server 110 shown in the figure can be connected to the terminal device 120 through a network. The network is used to provide a medium for a communication link between the server 110 and the terminal device 120. The network can include various connection types, such as wired communication links, wireless communication links, etc., which are not limited in the embodiments of the present application. Optionally, in other embodiments, the link prediction method and model training method can also be run in other types of computer devices such as smart phones and laptops.

[0038] It should be understood that Figure 1The server 110, network and terminal device 120 are merely illustrative. Any number of servers, networks and terminal devices may be configured as required. For example, the server 110 may be a physical server or a server cluster composed of multiple servers, and the terminal device 120 may be a mobile phone, a tablet, a desktop computer, a laptop computer, and the like. It is understood that the embodiments of the present application may also allow multiple terminal devices 120 to access the server 110 at the same time.

[0039] As another implementation, the link prediction method and model training method provided in the embodiment of the present application can be applied to different computer devices. For example, the link prediction method is applied to electronic device A, the model training method is applied to electronic device B, and so on. The embodiment of the present application does not limit the computer device to which the above method is applied.

[0040] The following is a detailed description in conjunction with the accompanying drawings. In this embodiment, the execution subject is taken as an example of the server 110. It should be noted that the description order of the following embodiments is not intended to limit the preferred order of the embodiments. Although the logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in an order different from that shown in the accompanying drawings.

[0041] The link prediction method and model training method provided in this embodiment can be applied to any scenario where link prediction is required, and the method can be applied to products in these scenarios. Take the link prediction of the knowledge graph as an example. The link prediction of the knowledge graph refers to the prediction of the relationship between entities that may exist but have not yet been observed through existing entities and relationships given a partial knowledge graph. Traditional static knowledge graphs can effectively express static relationships between entities, but cannot capture the evolution of entities and relationships over time. With the introduction of time information, a dynamic temporal knowledge graph (Temporal Knowledge Graph, TKG) can be constructed, new entities and relationships can be added to the knowledge graph, and the corresponding time data can be recorded. Therefore, a temporal knowledge graph refers to a knowledge graph that models and represents the temporal attributes of entities and relationships based on the knowledge graph. The temporal knowledge graph not only contains the static attributes of entities and relationships, but also considers the dynamic relationship of these attributes changing over time.

[0042] However, since time series data is usually sparse, there may not be enough data observed at certain time points. Therefore, the time series knowledge graph may be sparse and incomplete. In addition, time series data may contain multiple patterns, and the time series patterns are relatively complex. For example, time series patterns may be periodic, trending, and sudden changes. Therefore, when establishing a time series knowledge graph based on time series relationships, it is necessary to consider the information interaction and dependency relationships at multiple time points in order to effectively predict the time series evolution of entities and relationships. However, due to the complexity of time series patterns, the prediction of dynamic relationship changes in the time series knowledge graph is prone to poor accuracy.

[0043] Based on this, the embodiment of the present application helps to understand and predict the dynamic changing relationship in the time series knowledge graph by combining the time series knowledge graph and the large language model (Large Language Model, LLM). In addition, the large language model can also understand and use contextual information, including time information, so that it can more accurately infer possible future relationships or links. In this way, the time series patterns of entities and relationships can be learned based on known time series data, and link predictions at future moments can be performed accordingly. In an example, the large language model may include but is not limited to models such as GPT (Generative Pre-trained Transformer) and BERT (Bidirectional Encoder Representations from Transformers). In this way, not only can the modeling accuracy of the time series knowledge graph of complex time series relationships be improved, but also the complex challenges of data sparsity and time series patterns can be effectively addressed, and accurate and reliable prediction capabilities can be provided for multiple technical fields, such as financial duration analysis, personalized recommendation system optimization, medical health management, and scientific research, thereby supporting intelligent decision-making and service optimization.

[0044] Figure 2 is a flowchart of a link prediction method provided in an embodiment of the present application. Figure 2 The specific process of the link prediction method can be as follows: steps 201-204, etc., which are introduced in detail below.

[0045] Step 201: Generate a temporal knowledge graph based on the relationship data between a first entity and multiple second entities.

[0046] The link prediction in the embodiment of the present application is based on the time series knowledge graph to predict entities that may have a link relationship with the first entity. Therefore, the embodiment of the present application will first build an initial time series knowledge graph based on the second entity that has generated relationship data with the first entity. Among them, the first entity is the subject that needs to be predicted for the link, and the second entity is the entity that has relationship data with the first entity. Among them, the relationship data may include the time data corresponding to the relationship between the first entity and the second entity.

[0047] In addition, in the time series knowledge graph, embedded data can be used as vector representations of entities and relationships to capture the semantic relationship and similarity between entities and relationships. In the time series knowledge graph, embedded data can include time data. Incorporating time data into embedded data can better represent the dynamic changes of entities and relationships in the time dimension. Both embedded data and time data can be represented in the form of vectors.

[0048] Taking the information recommendation application scenario based on the time series graph as an example, in the time series knowledge graph, the first entity can be the object to be recommended, and the second entity can be the recommended information that has relationship data with the object to be recommended. Among them, the relationship data is the data that represents the interaction between the object to be recommended and the recommended information. For example, assuming that the information recommendation is a product recommendation, the first entity can be the user, and the second entity can be the product that has relationship data with the user. The relationship data between the user and the product can include but is not limited to purchase, collection and browsing. Taking purchase as the relationship data as an example, assuming that user A purchased product 1 on January 1 and product 2 on January 3. Then user A can be the first entity, and product 1 and product 2 are two second entities. There is a purchase relationship 1 between the user and product 1, and the time data 1 corresponding to relationship 1 is January 1. There is a purchase relationship 2 between the user and product 2, and the time data 2 corresponding to the relationship is January 3. Therefore, a time series knowledge graph can be constructed based on the first entity user A, the second entity products 1 and 2, relationship 1, relationship 2, time data 1 and time data 2.

[0049] Step 202: In response to a change in the relationship data between the first entity and the second entity, the temporal knowledge graph is updated, and a plurality of embedded data are extracted from the updated temporal knowledge graph.

[0050] In an embodiment of the present application, in a knowledge graph, an embedding vector is a representation method for mapping entities and relationships to a continuous vector space. The embedding vector is used to capture the semantic relationship and semantic similarity between entities and relationships. The entity embedding vector is used to identify entities in the knowledge graph, and the relationship embedding vector is used to identify relationships in the knowledge graph. In an embodiment of the present application, the embedded data is an embedding vector in the knowledge graph. The embedded data may include entity embedding data and embedded data of relationships between entities. Compared with the static knowledge graph in the related art, the embedded data of the embodiment of the present application adds data with time characteristics, i.e., embedded data, to form a temporal knowledge graph with time characteristics. The embedded data may include vector representations of entities, relationships between entities, and the time of occurrence of relationships in the temporal knowledge graph. By adding the embedded data corresponding to the first entity, the second entity, and the relationship data to the time data, the dynamic changes of entities and relationships in the time dimension can be better reflected. Based on this, the temporal knowledge graph in the embodiment of the present application can continuously update the entities and relationships in the temporal knowledge graph over time to extract dynamically changing embedded data.

[0051] In one example, when a newly added second entity is received, the relationship data between the first entity and the second entity will also change. At this time, the composition of the time series knowledge graph can be updated based on the change in the relationship data between the first entity and the second entity. For example, the newly added second entity is added to the time series knowledge graph, the relationship data between the first entity and the newly added second entity is added, and the time information corresponding to the newly added second entity is encoded into the relationship data. Then, the embedded data corresponding to the first entity, the second entity, and the relationship data are extracted from the updated time series knowledge graph to obtain multiple embedded data. In this way, the embedded data in the time series knowledge graph can be dynamically extracted to ensure the real-time nature of the link prediction input, thereby improving the accuracy of the link prediction.

[0052] Step 203: Generate semantic description information based on the multiple embedded data, where the semantic description information is used to express the association relationship between entities corresponding to the multiple embedded data.

[0053] In an embodiment of the present application, an association path between multiple entities can be formed based on multiple embedded data. The association path is a sequence representing the semantic relationship between entities. The semantic relationship can be a connection between the relationships between multiple entities. By analyzing the association path, the semantic relationship between the second entity can be obtained, and based on the semantic relationship, other entities that may have an association relationship can be predicted. Taking the purchase of goods by users as an example, assuming that the association relationship between multiple goods is a temporal relationship in time, the association path is arranged based on the order of time.

[0054] In order to better analyze the semantic relationship between entities in the temporal knowledge graph, the embodiment of the present application can use a large language model to analyze semantic description information. Among them, semantic description information refers to information that can describe the semantic meaning and characteristics of entities, relationships or attributes in natural language or other text forms, and can provide text descriptions for explaining and understanding each element in the temporal knowledge graph.

[0055] Still taking the above example where the first entity is a user and the second entity is a product. Assume that the association relationship between products is the order of purchase. Based on the embedded data corresponding to user A, product 1, product 2, relationship 1, relationship 2, etc., semantic description information with a sequence can be generated, such as: user A purchased product 1 on January 1, and then purchased product 2 on January 3. The "immediately after" in the generated semantic description information is a prompt word corresponding to the sequence, and the prompt word is used to construct semantic description information with sequential characteristics.

[0056] The embodiment of the present application converts the embedded data into semantic description information to form a natural language with semantic relationships, provides context information and timing information for the large language model, and can further improve the accuracy of link prediction.

[0057] Step 204: perform link prediction on the first entity based on the semantic description information and the updated temporal knowledge graph to obtain a target entity that has a link relationship with the first entity in the target time period.

[0058] In an embodiment of the present application, a link relationship refers to an association relationship between entities that may be associated with the first entity, as predicted by the solution of the embodiment of the present application. As an example, based on link prediction, any entity that has a probability of being associated with the first entity in the future target time period greater than a set condition can be determined as a target entity that has a link relationship with the first entity (e.g., a high probability of being interested, a high probability of purchasing, a high probability of repurchasing, etc.). Among them, the target time period refers to any time period after the current time. The target entity refers to an entity that is predicted to have a link relationship with the first entity in the target time period.

[0059] The embodiment of the present application can perform link prediction for any time period based on the semantic description information and the updated temporal knowledge graph, and obtain the target entity that may have a link relationship with the first entity in the target time period. For example, if the semantic description information is "the user purchased product 1 on January 1, and then purchased product 2 on January 3", based on the timing information in the updated temporal knowledge graph, the product that the user may purchase on a certain day in the future can be predicted. For example, the user may purchase product 3 on January 5. Among them, product 3 has a certain correlation with product 1 and product 2, such as similarity, complementarity, etc. In this way, the user's purchasing behavior can be predicted. In addition, in the embodiment of the present application, the temporal knowledge graph has a temporal feature, and the characteristics of the user's purchasing behavior that change over time can be analyzed based on the popularity of the product in each time period, such as the purchase rate, click-through rate, and browsing rate, so as to make a more accurate prediction of the user's purchasing behavior.

[0060] In the embodiment of the present application, the dynamically changing time series knowledge graph can capture the dynamic changing characteristics of entities and relationships over time, and predict the link relationship within the target time period based on the semantic description information corresponding to the embedded data, providing a deeper semantic understanding. Compared with the link prediction scheme that does not refer to time series data, the present application can simultaneously utilize the dynamic characteristics of the time series knowledge graph and the semantic characteristics of the semantic description information to better process and understand the dependency relationship of the embedded data, making the link prediction more accurate.

[0061] In the time series knowledge graph of the embodiment of the present application, the relationship between the second entity is the first relationship, and the relationship between the first entity and the second entity is the second relationship. In step 201 of the embodiment of the present application, the second relationship between the first entity and each second entity and the time data corresponding to the second relationship can be determined based on the relationship data. For example, assume that the user is the first entity and the product is the second entity. The second relationship between the user and the product is a purchase relationship. Each purchase relationship corresponds to a time data, that is, the time when the user purchases the product. In this way, the first entity, the second entity, the second relationship between the first entity and the second entity, and the time data corresponding to the second relationship can be obtained.

[0062] Then, the first entity and the second entity are taken as nodes, the second relationship is taken as the edge connecting the first entity and the second entity, and the time data corresponding to the second relationship is taken as the attribute of the edge. Finally, based on the nodes, the edges connecting the nodes, and the attributes corresponding to the edges, a time series knowledge graph can be generated. In this way, the relationship between the first entity, multiple second entities, and the second relationship in the time dimension can be obtained more intuitively.

[0063] In one example, data preprocessing can be performed on the initial data obtained, such as the original first entity, second entity, second relationship, and time data. By marking the initial data obtained, recording the time data of each second relationship, and then removing the abnormal second relationship data, filtered data can be obtained. The filtered initial data is then cleaned to obtain standardized data. Taking the purchase of goods by users as an example, the second relationship of the transaction generated by the user is marked, and the time point of the second relationship is recorded. Then, abnormal transaction data and inconsistent data, such as refund transactions or duplicate records, are removed. Then, initial embedding data is generated for each user and product. Suppose a user purchased a book on January 1, and the transaction time is x. A , time marked as t A . Mark this record as T(t A )=(x A ,t A ). Then the function representation of anomaly detection and filtering can be: T′(x i ) = f filter (x i )·T(x i ). Among them, f filter (x i ) is an indicator function that returns 0 or 1 to indicate whether to keep transaction record x i , T′(x i ) is the initial data after filtering, T(x i ) is the initial data. For example, if a user buys the same book repeatedly within a few seconds, it may be a system error, so f filter (x i ) can mark this duplicate record as abnormal data and exclude it from subsequent processing. Next, clean the filtered initial data. The function representation of data cleaning can be: ″ (x i ) = f clean (T ′ (x i )), where f clean is a cleaning function used to further process and standardize data, T ″ (x i ) is the initial data after cleaning. In this way, in the initial time series knowledge graph, the initial embedded data v i The function representation of can be: i =f embed (x i ), where f embed is the initial embedding function, which represents the initial embedding data corresponding to users and products.

[0064] In step 202 of the embodiment of the present application, the first embedded data corresponding to the first entity and the second embedded data corresponding to the second entity can be determined based on the updated temporal knowledge graph. Then, a plurality of embedded data are obtained based on the first embedded data and the second embedded data. The first embedded data includes the first temporal feature of the first entity, and the second embedded data includes the second temporal feature corresponding to the second entity.

[0065] In an embodiment of the present application, the first embedded data is the embedded data of the first entity in the temporal knowledge graph, and the first embedded data includes the time data of the first entity. By encoding the time data, the temporal characteristics of the first entity can be obtained. The second embedded data includes the time data of the second entity. Similarly, by encoding the time data, the temporal characteristics of the second entity can be obtained. For example, if the user is the first entity, then the user's behavior of purchasing goods and the corresponding time data are the first embedded data of the first entity. If the goods are the second entity, then the sales situation of the goods and the time data are the second embedded data of the goods. In this way, multiple embedded data with temporal characteristics can be obtained based on the first embedded data corresponding to the user and the second embedded data corresponding to the goods.

[0066] In one example, assuming that the time code t i The corresponding function is t i =f time (t i ), where f time (t i ) is a timestamp encoding vector. For example, January 1 is encoded as a time vector, or a specific time, etc. The first embedded data of the first entity user It can be expressed as: in, represents the first embedded data corresponding to the previous time data t-1 of the current time data t, α u represents the learning rate, which is used to update the first embedding data corresponding to the user. For example, the first embedding data of the user can be updated according to the user's purchase behavior and time data. The second embedding data of the second entity product It can be expressed as: in, represents the second embedded data corresponding to the previous time data t-1 of the current time data t, α p represents the learning rate, which is used to update the second embedding data corresponding to the product. For example, the second embedding data of the product can be updated according to the changes in the sales of the product and the time data. In this way, the embedded data dynamically output It can be expressed as Among them, [;] represents vector concatenation. For example, the first embedded data corresponding to the user and the second embedded data corresponding to the product are concatenated to obtain multiple embedded data. By encoding the time data and adding it to the embedded data in the time series knowledge graph, multiple embedded data are obtained, which can more intuitively present the time series characteristics of the time series knowledge graph.

[0067] In step 203 of the embodiment of the present application, the plurality of embedded data may be converted into text data, and a first associated word for representing the first relationship between the plurality of second entities may be determined. Then, a second associated word for representing the associated structure between the text data may be generated based on the first associated word. Finally, the text data may be concatenated based on the second associated word to generate semantic description information.

[0068] In an embodiment of the present application, the first relationship refers to the connection between multiple second entities. Based on multiple first relationships, an association path between second entities can be formed. The semantic relationship between the second entities can be obtained by analyzing the association path. For example, for the historical behavior of users purchasing goods, by analyzing a certain relationship between the goods, the semantic relationship between the goods is obtained, thereby determining the first relationship between the second entities. Then, based on the determined first relationship, the corresponding first associated words can be extracted. The first associated word is a relationship word that characterizes the first relationship between the second entities. In an embodiment of the present application, each first associated word has a corresponding second associated word. The second associated word is a word used to characterize the association structure between text data. For example, the second associated word in natural language can be a prompt word for guiding the generation of natural language. In this way, multiple embedded data are converted into text data respectively, and then the text data are spliced ​​based on the second associated word corresponding to the first associated word, so as to obtain the semantic description information input to the large language model. In this way, the semantic description information obtained by the large language model can characterize the information of the dynamic temporal characteristics of each entity and relationship in the temporal knowledge graph to improve the accuracy of link prediction.

[0069] In one example, take extracting the association paths between multiple commodities purchased by a user as an example. First, assume that the purchase history extraction function H(u i ) can be expressed as Among them, extract_hist is a function of extracting the product purchase history from the user's first embedded data. For example, which books did the user buy in the past week. Then, extract_path is extracted from the key path between products, which can be expressed as: Among them, p i,j is the first relationship between any two commodities, such as commodity i and commodity j, is the vector of product i and product j at any time t, P(pi,j ) is an association path based on the first relationship between multiple products. Assume that the first relationship between products is an association relationship based on purchase time. For example, user A purchased product 1 on January 1, and then purchased product 2 on January 3. Then the association path of the second entity product 1 and product 2 is sorted from product 1 to product 2 according to the purchase time. The association path can contain a first association word, which is a vector representation of the relationship between the second entities in the association path, that is, a relationship word. For example, assuming that the first association word represents the order of purchase time between the second entities, it can be encoded, such as using one-hot encoding to represent it as [0,1,0,0].

[0070] The first relationship extracted in the embodiment of the present application can be obtained based on common purchases, alternative purchases or any other type of user behavior. Specifically, it can be obtained through association rule mining or sequence pattern mining. Association rule mining is to discover frequent patterns and association rules between commodities through the association rule mining algorithm Apriori. Sequence pattern mining is when the second embedded data corresponding to the commodity contains time data, and the sequence pattern mining technology can be used to discover the commodity purchase pattern that appears in a specific time series. For example, it can be mined through a long short-term memory network.

[0071] Next, the first associated word represented by a vector in the associated path is converted into a second associated word represented by a text. The second associated word L i,j The function can be expressed as L i,j =prompt_gen(H(u i ),P(p i,j )), where prompt_gen is a function that converts the first associated word into the second associated word. For example, the first associated word corresponding to the first relationship of the user purchasing the product is converted into the corresponding second associated word that can be represented by text data, so as to construct a natural language description of the order of purchasing the products based on the prompt word. For example, if the first associated word is the order of the purchase time of the products, the corresponding second associated word can be: first, then, immediately after, etc. The function representation constructed by the natural language prompt word set L can be: Among them, ∪ represents the union of the prompt word set. The purpose of the natural language prompt word extraction function based on the association path is to convert the association path between the purchase history and the product into a natural language description. In one example, the extracted information can be filled into the template by implementing a series of defined natural language templates, for example: "User A purchased product X at {time}, and then purchased product Y at {time}", and the extracted user data, time data and product data are filled into the template to obtain the corresponding natural language, that is, the semantic description information. In another example, a sequence-to-sequence neural network model (such as Transformer) can also be used to convert the vector encoding of the extracted embedded data into a natural language description. Here, there is no restriction on the method of converting to natural language.

[0072] The embodiment of the present application can predict any time period based on the dynamic time series features extracted from the time series knowledge graph and the semantic description information. Specifically, in step 204, the first matching degree between the first entity and the third entity in the target time period can be determined according to the semantic description information and the updated time series knowledge graph, and the priority of each third entity can be determined according to the first matching degree. Among them, the third entity has an association relationship with the second entity. Then, the link prediction of the first entity is performed according to the priority of the third entity to obtain the target entity, and the target entity includes the third entity whose priority is within the set priority range.

[0073] In an embodiment of the present application, the first matching degree between the first entity and the third entity in the target time period is determined based on the semantic description information and the updated temporal knowledge graph. The third entity is an entity that has an association relationship with the second entity, for example, a similarity, complementarity, or preference relationship. The first matching degree can represent the probability that there may be a link relationship between the first entity and the third entity. For example, when the second entity purchased by the user is a computer, the third entity can be a computer with similarities, or an entity with an association relationship with the computer, such as a complementary mouse, keyboard, etc.

[0074] After determining the first matching degree between the first entity and the third entity, the priority of each third entity can be determined according to the first matching degree. Priority refers to arranging the matching degree between the third entity and the first entity in a certain order, and determining the priority order between the third entities according to the arrangement order. For example, based on the size of the first matching degree, sort from large to small to obtain the priority ranking of the third entities. Finally, the third entity that exists within the set priority range within the target time period is selected as the target entity. Among them, the setting priority can be set based on the needs of the user. For example, if the number of products recommended to the user is 10, the setting priority can be set to 10 to select the 10 products with the highest probability of user purchase for recommendation.

[0075] In some embodiments, if link prediction of multiple arbitrary time periods is required, the time period between the first time and the second time can be divided into multiple sub-time periods. The first time and the second time are any two times. For example, the first time can be taken as the current time, and the second time can be taken as any time after the current time. The target time period to be predicted is one of the multiple sub-time periods, that is, the target time period is between the first time and the second time. For example, the end time of the target time period can be taken as the second time.

[0076] In an embodiment of the present application, the first matching degree between the first entity and the third entity in the target time period is determined based on the interaction index of the third entity in the sub-time period. The interaction index is a frequency of generating relationship data between the third entity and other entities in the target time period. Considering the time series characteristics in different time periods, when predicting the third entity, the time series characteristics of the third entity that change over time can be added to the prediction process.

[0077] Specifically, first, the second matching degree between the first entity and the third entity in the target time period can be determined based on the semantic description information. Among them, the second matching degree refers to the probability of the third entity that may have a link relationship with the first entity, which is preliminarily predicted based on the semantic description information. However, the second matching degree does not take into account that the popularity of the third entity in different sub-time periods may be different. Therefore, it is also necessary to determine the interaction index of the third entity in the target time period based on the updated temporal knowledge graph. Finally, the second matching degree is corrected according to the interaction index to obtain the first matching degree that takes into account the influence of temporal characteristics.

[0078] In one example, the first entity is a user, and the third entity is a product. The interest between the user and the product is predicted by a score function between the user and the product. The score s(u i ,p j ) can be expressed as in, is the first embedded data corresponding to the user, is the second embedded data corresponding to the product. The second matching degree The function representation can be Among them, the second matching degree For user u i For product p j The probability of purchase, is the product bias term, and σ is the sigmoid function. Then, the time adjustment function g is added to the second matching function, expressed as Among them, Δt is the change from the first time to the second time, for example, the change from the current time to the predicted time. The first matching degree is the first matching degree. Finally, the output of link prediction O(u i ,Δt) can be expressed as: Among them, the output of link prediction O(u i ,Δt) is a group of users u i The items that may be of interest within time Δt, θ is the purchase probability threshold. For user u i For product p j The predicted purchase probability within time Δt takes into account the time adjustment function g(t i ,Δt). In this way, the time series characteristics of the third entity that change with time are added to the prediction process, which not only improves the accuracy of link prediction, but also can analyze the time series characteristics of each entity that change with time.

[0079] In an embodiment of the present application, it is also possible to predict whether there is a link relationship between the fourth entity newly added to the time series knowledge graph and the first entity. For example, the user's purchase probability for a new product is predicted. In response to the fourth entity being added to the time series knowledge graph, the third embedded data is determined based on the association relationship between the embedded data and the fourth entity. The fourth entity is an entity newly added to the time series knowledge graph. The third embedded data is obtained based on the embedded data in the existing embedded data that has an association relationship with the fourth entity. For example, the third embedded data of the new product Can be in, For new products new is the embedding data of the most similar existing items, and K is the number of most similar items considered.

[0080] Then, the association relationship between the first entity and the fourth entity can be determined based on the first embedded data and the third embedded data, and a link prediction can be performed between the first entity and the fourth entity based on the association relationship to determine whether there is a link relationship between the first entity and the fourth entity within the target time period. new The function of the prediction score is expressed as: Among them, s(u i ,p new ) represents user u i and new products new The affinity score between them indicates the user's interest in the new product p new Then, through the zero-shot prediction function constructed in advance in, For user u i and new products newThe purchase probability of , σ is the sigmoid activation function, which will be a function that maps real numbers to probability values ​​(between 0 and 1). Zero-shot prediction output O zs (u i ) can be expressed as: zs (u i )={p new |>θ}, where O zs (u i ) is a group of users u i A collection of new items that may be of interest.

[0081] By introducing the zero-shooting function, the embodiment of the present application can predict the link relationship between the fourth entity newly added to the time series knowledge graph and the first entity, and can process the entities newly added to the time series knowledge graph, thereby enhancing the generalization and adaptability of link prediction in multiple time series knowledge graphs.

[0082] Taking the application scenario of link prediction for information recommendation as an example, the embodiment of the present application can recommend the entity information corresponding to the target entity that has a link relationship with the first entity in the target time period as recommended information to the recommended object corresponding to the first entity. The corresponding information recommendation is performed through the link prediction method in the above embodiment.

[0083] The link prediction method in the embodiment of the present application can perform link prediction through a pre-trained model. The model first generates a time series knowledge graph based on the relationship data of a first entity and multiple second entities. When the relationship data between the first entity and the second entity changes, in response to the change in the relationship data, the time series knowledge graph is updated, and multiple embedded data are extracted from the updated time series knowledge graph. Then, semantic description information is generated based on the association relationship of the multiple embedded data. Finally, based on the semantic description information and the updated time series knowledge graph, the target entity that has a link relationship with the first entity in the target time period is determined. Therefore, the embodiment of the present application also provides a model training method, and in practical applications, the parameters of the model can also be adjusted in real time to improve the accuracy and generalization ability of link prediction.

[0084] See also Figure 3 , Figure 3 It is a flow chart of a model training method for training the above-mentioned model provided in the embodiment of the present application. In the embodiment of the present application, the model training method can be implemented through steps 301-303, which are described in detail below.

[0085] Step 301: Obtain a training sample set, the training sample set includes multiple training samples, and the training samples include first sample relationship data and a calibrated target entity, wherein the first sample relationship data is relationship data between a first sample entity and multiple second sample entities.

[0086] In an embodiment of the present application, a training sample set is composed of multiple training samples. Each training sample includes first sample relationship data and a calibration target entity. Among them, the first sample relationship data is the relationship data between the first sample entity and multiple sample entities. The first sample entity is the subject that needs to perform link prediction, and the second sample entity is the entity that has first sample relationship data with the first sample entity. The first sample relationship data is the sample data that characterizes the relationship between the first sample entity and the second sample entity. In addition, the first sample relationship data may include sample time data corresponding to the first sample relationship data. The calibration target entity is at least one second sample entity that has a link relationship with the first sample entity. In addition, in model training and actual application, the training sample set can be added at any time to expand the amount of data and improve the generalization ability of the model.

[0087] Step 302: Input each training sample in the training sample set into the model to be trained to perform link prediction, and obtain a first predicted target entity.

[0088] In the embodiment of the present application, the model to be trained refers to an initial model that has not yet been trained for link prediction. Each training sample is input into the model to be trained, and the corresponding first prediction target entity can be obtained. The first prediction target entity is the output result of the model corresponding to the training sample. The first prediction target entity is an entity that may have a link relationship with the first sample entity.

[0089] Step 303: Calculate the loss function value according to the first prediction target and the calibrated target entity, and adjust the parameters of the model to be trained according to the loss function value.

[0090] In an embodiment of the present application, after obtaining the first predicted target entity, the first predicted target entity predicted by the model and the actual calibrated target entity are compared and analyzed, and the loss function value can be obtained according to the comparison and analysis results. For example, the loss function value can be determined by calculating the mean square error, cross entropy loss, log likelihood loss or cosine similarity between the first predicted target entity and the loss function value. Then, the training model is iteratively updated by minimizing the loss function through gradient descent or variant until the convergence condition of the model is reached to obtain a trained model. Among them, the convergence condition may include that the loss function value is less than a set threshold or remains unchanged, or the number of iterations reaches a set number of times, etc.

[0091] The embodiment of the present application trains the to-be-trained model based on the first sample relationship data between the first sample entity and the second sample entity, and adjusts the parameters of the to-be-trained model by the loss function value between the first predicted target entity and the calibrated target entity, thereby obtaining a trained model. In this way, the trained model can be used to predict the target entity that may have a link relationship with the first entity, so that the accuracy of the link prediction is higher.

[0092] Figure 4 Schematic diagram of a flow chart of a method for link prediction in model training provided in an embodiment of the present application. Figure 4 As shown, in step 302 of the embodiment of the present application, link prediction can be implemented through steps 401-403.

[0093] Step 401: Update the sample time series knowledge graph based on the second sample relationship data, and extract multiple sample embedding data from the updated sample time series knowledge graph. The sample time series knowledge graph is generated based on the first sample relationship data between the first sample entity and multiple second sample entities, and the sample embedding data includes the vector representation of the sample entities, the relationship between the sample entities, and the occurrence time of the relationship in the sample time series knowledge graph.

[0094] Step 402: Generate sample semantic description information based on the multiple sample embedded data, where the sample semantic description information is used to express the association relationship between the sample entities corresponding to the multiple sample embedded data.

[0095] Step 403: perform link prediction on the first sample entity according to the sample semantic description information and the updated sample time series knowledge graph to obtain a first predicted target entity that has a link relationship with the first sample entity in the target time period.

[0096] In an embodiment of the present application, the sample time series knowledge graph is a time series knowledge graph generated based on the first sample relationship data in model training. In the sample time series knowledge graph, sample embedding data can be used as a vector representation of sample entities and sample relationships, thereby capturing the semantic relationship and similarity between sample entities and sample relationships. In the sample time series knowledge graph, the sample embedding data may include sample time data, and incorporating the sample time data into the sample embedding data can better represent the dynamic changes of sample entities and sample relationships in the time dimension. Among them, both the sample embedding data and the sample time data can be represented in the form of vectors.

[0097] As time goes by, the sample time series knowledge graph can continuously update sample entities and sample relationships in order to extract dynamically changing sample embedded data. When a newly added second sample entity is received, the relationship data between the first sample entity and the second sample entity will also change. At this time, the second sample relationship data can be obtained based on the change of the first sample relationship data between the first sample entity and the second sample entity, and the composition of the sample knowledge graph can be updated based on the second sample relationship data. In this way, the sample embedded data in the sample time series knowledge graph can be dynamically extracted to ensure the real-time nature of the sample input in the link prediction, thereby improving the accuracy of the link prediction.

[0098] Then, semantic description information can be generated based on the association relationship of the extracted sample embedded data. The association relationship of the sample embedded data is an association path between multiple second sample entities obtained based on the second sample relationship data of the first sample entity and multiple second sample entities. Among them, the association path is a sequence representing a series of relationships between the second sample entities. By analyzing the association path, the semantic relationship between the second sample entities can be obtained, and based on the semantic relationship, other sample entities that may have an association relationship can be predicted. In order to better analyze the semantic relationship between each sample entity in the sample time series knowledge graph, the embodiment of the present application introduces a large language model that can analyze semantic description information. By converting the sample embedded data into corresponding sample semantic description information, a natural language with a semantic relationship is formed, and context information and timing information are provided to the large language model, which can further improve the accuracy of link prediction.

[0099] In the embodiment of the present application, the target time period refers to any time period after the current time. The first predicted target entity refers to the entity predicted to have a link relationship with the first sample entity in the target time period. The embodiment of the present application can perform link prediction for any time period based on the sample semantic description information and the updated sample time series knowledge graph to obtain the target entity that may have a link relationship with the first sample entity in the target time period.

[0100] The embodiment of the present application determines sample embedded data based on a dynamically changing sample time series knowledge graph, and then performs link prediction on a first predicted target entity that has a link relationship with the first sample entity in a target time period based on the semantic description information corresponding to the sample embedded data. The dynamic features of the sample time series knowledge graph and the semantic features of the semantic description information can be utilized simultaneously to make the link prediction of the model more accurate.

[0101] In an embodiment of the present application, in the sample time series knowledge graph, the relationship between the second sample entity is the first sample relationship, and the relationship between the first sample entity and the second sample entity is the second sample relationship. In an embodiment of the present application, the second sample relationship between the first sample entity and each second sample entity and the sample time data corresponding to the second sample relationship can be first determined based on the first sample relationship data. Then, the first sample entity and the second sample entity are used as nodes, the second sample relationship is used as an edge connecting the first sample entity and the second sample entity, and the time data corresponding to the second sample relationship is used as the attribute of the edge to generate a sample time series knowledge graph.

[0102] In step 401 of the embodiment of the present application, the first sample embedded data corresponding to the first sample entity and the second sample embedded data corresponding to the second sample entity can be determined based on the updated sample time series knowledge graph. The first sample embedded data is the embedded data corresponding to the first sample entity, and the first sample embedded data includes the first sample time series feature of the first sample entity. The first sample time series feature is obtained by encoding the time data corresponding to the first sample entity. The second sample embedded data is the embedded data corresponding to the second sample entity, and the second sample embedded data includes the second sample time series feature corresponding to the second sample entity. The second sample time series feature is obtained by encoding the time data corresponding to the second sample entity. Then, according to the first sample embedded data and the second sample embedded data, a plurality of sample embedded data can be obtained.

[0103] In an embodiment of the present application, step 402 may first convert multiple sample embedding data into sample text data, and determine a first sample relationship for characterizing multiple second sample entities. Then, determine a first sample association word corresponding to the first sample relationship. Then, generate a second sample association word representing the association structure of the sample semantic description information based on the first sample association word. Finally, splice the sample text data based on the second sample association word to generate sample semantic description information.

[0104] In an embodiment of the present application, the first sample relationship refers to the relationship between multiple second sample entities. Based on multiple first sample relationships, an association path between second sample entities can be formed. The semantic relationship between the second sample entities can be obtained by analyzing the association path. Then, the corresponding first sample association words can be extracted based on the determined first sample relationship. The first sample association word is a relationship word that characterizes the first sample relationship between the second sample entities. In an embodiment of the present application, each first sample association word has a corresponding second sample association word. The second sample association word is a word used to characterize the association structure of the sample semantic description information. For example, the second sample association word in the natural language can be a prompt word used to guide the generation of natural language. In this way, the multiple sample embedding data are converted into sample text data respectively, and then the sample text data are spliced ​​based on the second sample association word corresponding to the first sample association word, so as to obtain the sample semantic description information input to the large language model. In this way, the sample semantic description information obtained by the large language model can characterize the information of the dynamic temporal characteristics of each sample entity and sample relationship in the sample temporal knowledge graph, so as to improve the accuracy of the model link prediction.

[0105] In step 403 of the embodiment of the present application, the first matching degree between the first sample entity and the second predicted target entity within the target time period can be determined based on the sample semantic description information and the updated sample time series knowledge graph, and the priority of each second predicted target entity can be determined based on the first matching degree, and the second predicted target entity has an associated relationship with the first sample entity. The first matching degree refers to the probability that a link relationship may exist between the first sample entity and the second predicted target entity. Then, link prediction is performed on the first sample entity based on the priority of the second predicted target entity to obtain the first predicted target entity. The first predicted target entity includes a second predicted target entity whose priority is within a set priority range. Among them, the set priority can be set based on user needs.

[0106] In one example, the time period between the first sample time and the second sample time can be divided into a plurality of sample sub-time periods. The first sample time and the second sample time are any two times. For example, the first sample time can be taken as the current time, and the second sample time can be taken as any time after the current time. The sample time period to be predicted is one of the plurality of sample sub-time periods, that is, the target time period is between the first sample time and the second sample time. For example, the end time of the target time period can be taken as the second sample time.

[0107] In an embodiment of the present application, the first matching degree between the first sample entity and the second predicted target entity in the target time period can be determined based on the interaction index of the second predicted target entity. Among them, the interaction index characterizes the frequency of the second predicted target entity generating relationship data with other sample entities in the target time period, which can also be called a "popularity index". Specifically, the second matching degree between the first sample entity and the second predicted target entity in each sample sub-time period can be determined according to the sample semantic description information. The second matching degree refers to the probability of the second predicted target entity that may have a link relationship with the first sample entity, which is initially predicted based on the sample semantic description information. However, the second matching degree does not take into account that the popularity of the second predicted target entity in different sample sub-time periods may be different. Therefore, it is also necessary to determine the interaction index of the second predicted target entity in each sample sub-time period based on the updated sample time series knowledge graph. Finally, based on the interaction index and the second matching degree, the first matching degree is obtained. In this way, the time series characteristics of the second predicted target entity that change over time can be added to the prediction process, which not only improves the accuracy of the link prediction, but also can analyze the time series characteristics of the second predicted target entity that change over time.

[0108] In an embodiment of the present application, in response to the third sample entity being added to the sample time series knowledge graph, the third sample embedded data is determined based on the association relationship between the sample embedded data and the third sample entity. Among them, the third sample entity is an entity newly added to the sample time series knowledge graph. The third sample embedded data is obtained based on the sample time series data associated with the third sample entity in the existing sample embedded data. Then, the association relationship between the first sample entity and the third sample entity is determined based on the first sample embedded data and the third sample embedded data, and whether there is a link relationship between the first sample entity and the third sample entity is determined based on the association relationship. In this way, the model in the embodiment of the present application can also process new sample entities that have not been prompted, and enhance the generalization and applicability of link prediction in multiple sample time series knowledge graphs.

[0109] The embodiment of the present application can also evaluate the model performance by real-time monitoring of the first accuracy and the satisfaction of the first sample entity. Based on these feedbacks, the system adjusts the model parameters and training strategies to optimize the recommendation effect. Among them, the function of the recommendation accuracy evaluation can be expressed as: Where N is the number of training samples consisting of the first sample entity and the second sample entity in the test set, I is the indicator function, To calibrate the target entity. The function of satisfaction evaluation can be expressed as: The feedback is the first sample entity u i For the first predicted target entity p iThe satisfaction score obtained from the feedback. The function of model performance evaluation Performance is expressed as: Performance = α·Accuracy+β·Satisfaction, where α and β are weight parameters used to balance the importance of accuracy and satisfaction. The function of parameter adjustment is expressed as: Among them, Θ new Updated model parameters, Θ old is the model parameter before updating. η is the learning rate, which is a positive scaling factor used to control the step size in the gradient direction. is the gradient of the loss function J with respect to the model parameters θ, which indicates the fastest growth direction of the loss function under the current parameters. In gradient descent, we hope to update the parameters in the opposite direction of the gradient (that is, the direction that reduces the loss the fastest). D is the training sample set, which is the data used to calculate the loss function and gradient.

[0110] In practical applications, the trained model in the embodiment of the present application can be integrated with the front end of the terminal device through the application programming interface (API) to provide corresponding link prediction services. For example, it can be integrated with the front end of the e-commerce platform to provide personalized product recommendation services for millions of online customers. At the same time, it can also provide analysis reports on product trends according to the needs of merchants and market operation teams. Assuming A is an application integration function, the trained model receives the optimized model parameters Θ+ΔΘ and the e-commerce platform demand Q, and can output personalized recommendations R and trend reports C. The function is expressed as: (R, C) = A(Θ+ΔΘ, Q). In this specific application environment, the model that integrates the dynamic characteristics of the time series knowledge graph and the semantic understanding ability of the large language model in the embodiment of the present application can help the e-commerce platform to achieve accurate product recommendations and improve user experience. At the same time, it can also provide strong data support for the platform's market analysis and product management.

[0111] Taking the e-commerce platform as an example, the e-commerce platform generates millions of transaction records every day, which accumulate over time. Therefore, the link prediction technology of the time series knowledge graph can be used to analyze and predict the correlation between users' purchasing behavior and products, recommend products to users in real time, and predict the possible purchasing trends of users in the future. In order to achieve this goal, the e-commerce platform uses the above-mentioned trained model, which is called the TKGLLM model. By fusing TKG and LLM, it predicts the products that users may purchase in a certain target time period in the future and recommends products to users.

[0112] The following is an explanation of how the TKGLLM model is constructed. First, based on the transaction records between users and products on the e-commerce platform, the transaction records are time-stamped to record the time point when the transaction occurred. Subsequently, the algorithm removes abnormal transaction records and inconsistent data, such as refund transactions or duplicate transaction records, and obtains the initial embedding vectors for each user and product, which are used as the basis for model input. The e-commerce platform then regularly receives new transaction data and updates the embedding vectors of users and products. These vectors incorporate time information through time encoding technology, which can reflect the user's purchasing dynamics and changes in product popularity trends.

[0113] Next, analyze the user's purchase path, extract the user's purchase history and the association path between products, and convert this information into natural language prompts. Train the language model based on the generated natural language prompts so that it can understand the purchase pattern in the e-commerce field. After the model training is completed, fine-tune it through natural language prompts to make the model more suitable for the data of the e-commerce platform. Among them, the pre-trained language model Θ pre The function can be expressed as: pre =LM\_pretrain(L), where LM\_pretrain is the set of natural language prompts used and L is the function for pre-training. Fine-tuned language model Θ fine The function can be expressed as: fine =LM\_finetune(Θ pre ,L), where LM\_finetune is the set of natural language prompts used and L is the function for fine-tuning. The optimized language model Θ opt The function can be expressed as: opt =LM\_optimize(Θ fine ,L), where LM_optimize is the function that optimizes the model and L is the set of natural language prompts. Then, through the trained model Θ opt Link prediction is performed to analyze the products that users may be interested in and predict the user's future purchasing behavior. At the same time, taking into account the time factor, the popularity of products in a specific time period can be predicted.

[0114] In order to test the adaptability of the e-commerce platform, the TKGLLM model in the embodiment of the present application also adds the training of zero-shot learning. The platform regularly introduces new products and observes the model's predictive ability for these new products. In addition, the generalization ability of the model can also be tested under different market environments. In addition, the model performance can be evaluated by real-time monitoring of indicators such as the accuracy of product recommendations and user satisfaction. Based on these feedbacks, the model parameters and training strategies are adjusted to optimize the recommendation effect. The final optimized model can be integrated with the front end of the e-commerce platform through API to provide personalized product recommendation services for millions of online users. In addition, an analysis report on product trends can be provided according to the needs of merchants and market operation teams. In this specific application environment, the TKGLLM model can help the e-commerce platform to achieve accurate product recommendations, improve user experience, and provide strong data support for the market analysis and product management of the platform.

[0115] Therefore, the TKGLLM model in the embodiment of the present application has the following advantages compared with the related art.

[0116] First, the TKGLLM model combines the power of dynamic embeddings and large language models to more accurately capture and understand the dynamic changes of entities and relations in the graph. Dynamic embeddings enable the model to capture the evolution of entities and relations over time, while large language models provide a deep semantic understanding of the context. This combination makes TKGLLM more accurate than traditional models in predicting future or missing links.

[0117] Secondly, traditional link prediction models have difficulty in effectively handling the complexity of the time dimension. The TKGLLM model, through the design of the time series knowledge graph, can better process and understand the patterns and dependencies in time series data. This enables the model to better perform time series analysis and prediction when faced with prediction tasks involving timestamps. At the same time, the TKGLLM model guides predictions through natural language prompts, which provides a natural way to adapt to new fields or unseen data. Natural language prompts allow the model to quickly adapt to new tasks with a small number of examples, thereby improving the generalization ability of the model.

[0118] In application scenarios such as e-commerce platforms, the TKGLLM model can use the temporal knowledge graph to generate more personalized recommendations. Because the model takes into account changes in user behavior and preferences over time, it can provide recommendations that are more in line with the user's current interests, thereby improving user experience and satisfaction. In addition, the TKGLLM model can better handle and understand unseen prompts by combining a large language model. This means that the model can make effective predictions even when faced with new situations or new types of data that have not been encountered during model training.

[0119] In applications that require complex decision-making, such as financial services or health diagnosis, the TKGLLM model can provide more accurate data analysis and predictions, thereby supporting more effective decision-making. The deep understanding and prediction capabilities of the time series knowledge graph provide decision makers with a more comprehensive information perspective. In addition, through the optimized model structure and algorithm, the TKGLLM model may be more efficient than related technologies when performing link prediction, reducing the demand for computing resources. This makes it possible to deploy and use this model in resource-constrained environments, expanding its scope of application.

[0120] In summary, the TKGLLM model provides significant advantages over related technologies in many aspects, including but not limited to improved prediction accuracy, the ability to handle complex time series data, and its application potential in personalized recommendation and decision support.

[0121] It should be understood that, although each step in the flowcharts involved in the above-mentioned embodiments is displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0122] Based on the same inventive concept, the embodiment of the present application also provides a link prediction device for implementing the link prediction method involved above, and a model training device for implementing the model training method. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in the embodiments of one or more link prediction devices and model training devices provided below can refer to the limitations of the link prediction method and model training method above, and the specific limitations will not be repeated here.

[0123] Figure 5 Schematic diagram of the structure of a link prediction device provided in an embodiment of the present application. Figure 5As shown, the link prediction device 500 may include a generation module 501, an update module 502, a conversion module 503 and a determination module 504. The generation module 501 is used to generate a temporal knowledge graph based on the relationship data between a first entity and multiple second entities. The update module 502 is used to update the temporal knowledge graph in response to changes in the relationship data between the first entity and the second entity, and extract multiple embedded data from the updated temporal knowledge graph, the embedded data including entities in the temporal knowledge graph, the relationship between the entities and the vector representation of the time of occurrence of the relationship. The conversion module 503 is used to describe the semantic information based on multiple embedded data, and the semantic description information is used to express the association relationship between the entities corresponding to the multiple embedded data. The determination module 504 is used to perform link prediction on the first entity based on the semantic description information and the updated temporal knowledge graph, and obtain the target entity that has a link relationship with the first entity in the target time period.

[0124] Among them, the generation module 501, the update module 502, the conversion module 503 and the determination module 504 can be used to respectively execute steps 201-204 in the embodiment corresponding to the above-mentioned link prediction method. For the specific implementation methods of these modules and more details, please refer to the corresponding method part, which will not be repeated here one by one.

[0125] Figure 6 Schematic diagram of a model training device provided in an embodiment of the present application. Figure 6 As shown, the model training device 600 may include an acquisition module 601, a prediction module 602 and a parameter adjustment module 603. Among them, the acquisition module 601 is used to obtain a training sample set, the training sample set includes multiple training samples, the training samples include first sample relationship data and a calibrated target entity, and the first sample relationship data is the relationship data between the first sample entity and multiple second sample entities. The prediction module 602 is used to input each training sample in the training sample set into the model to be trained for link prediction to obtain the first predicted target entity. The parameter adjustment module 603 is used to calculate the loss function value according to the first predicted target and the calibrated target entity, and adjust the parameters of the model to be trained according to the loss function value.

[0126] Among them, the acquisition module 601, the prediction module 602 and the parameter adjustment module 603 can be used to execute steps 301-303 in the embodiments corresponding to the above-mentioned model training method respectively. For the specific implementation methods of these modules and more details, please refer to the corresponding method part, which will not be repeated here one by one.

[0127] Based on the same inventive concept, the embodiment of the present application also provides a computer device, which can be a server or a terminal device, and the computer device includes a memory and a processor, and a computer program is stored in the memory. When the processor executes the computer program, the steps of the above-mentioned link prediction method and model training method are implemented. Various functions are thereby realized, such as: generating a time series knowledge graph based on the relationship data between the first entity and multiple second entities; updating the time series knowledge graph in response to changes in the relationship data between the first entity and the second entity, and extracting multiple embedded data from the updated time series knowledge graph; generating semantic description information based on the association relationship of multiple embedded data; determining the target entity that has a link relationship with the first entity in the target time period according to the semantic description information and the updated time series knowledge graph.

[0128] The embodiment of the present application determines embedded data based on a dynamically changing time series knowledge graph, and then performs link prediction on a target entity that has a link relationship with a first entity in a target time period based on the semantic description information corresponding to the embedded data. It can simultaneously utilize the dynamic features of the time series knowledge graph and the semantic features of the semantic description information to make the link prediction more accurate.

[0129] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.

[0130] In one embodiment, the computer device is a terminal device, for example, its internal structure diagram can be as follows: Figure 7 As shown. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. The processor, the memory and the input / output interface are connected via a system bus, and the communication interface, the display unit and the input device are connected to the system bus via the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be implemented through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, a link prediction method and a model training method are implemented. The display unit of the computer device is used to form a visually visible image, and can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen. The input device of the computer device can be a touch layer covered on the display screen, or a button, trackball or touchpad set on the computer device casing, or an external keyboard, touchpad or mouse, etc.

[0131] Those skilled in the art will understand that Figure 7 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0132] Based on the same inventive concept, an embodiment of the present application also provides a computer-readable storage medium, which may include: a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, etc.

[0133] Since the computer program stored in the computer-readable storage medium can execute any one of the link prediction methods or model training methods provided in the embodiments of the present application, the beneficial effects that can be achieved by any one of the link prediction methods or model training methods provided in the embodiments of the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.

[0134] Based on the same inventive concept, the embodiment of the present application further provides a computer program product or a computer program, which includes a computer instruction, and the computer instruction is stored in a computer-readable storage medium. The processor of the computer device reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the computer device executes the method provided in various optional implementations in the above embodiments.

[0135] It should be noted that the object data (including but not limited to user device information, user personal information, etc.) and conversation data involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data need to comply with relevant laws, regulations and standards of relevant countries and regions. A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods.

[0136] Any reference to the memory, database or other media used in the embodiments provided in the present application may include at least one of non-volatile and volatile memory. Non-volatile memory may include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (Re RAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory may include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM may be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc.

[0137] The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. The non-relational database may include a distributed database based on blockchain, etc., but is not limited thereto. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but is not limited thereto.

[0138] In the above-mentioned link prediction device, model training device, computer-readable storage medium, computer equipment, and computer program product embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, refer to the relevant descriptions of other embodiments. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working process and beneficial effects of the link prediction device, model training device, computer-readable storage medium, computer program product, computer equipment and its corresponding units described above can refer to the description of the link prediction method and model training method in the above embodiments, and will not be repeated here.

[0139] The technical features of the above embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above 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.

[0140] The above is a detailed introduction to a link prediction method and device, a model training method and device, a computer device, a computer-readable storage medium, and a computer program product provided in the embodiments of the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for technical personnel in this field, according to the ideas of the present application, there will be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. A link prediction method, characterized in that: include: Generate a temporal knowledge graph based on the relationship data between the first entity and the plurality of second entities; In response to a change in the relationship data between the first entity and the second entity, the temporal knowledge graph is updated, and a plurality of embedded data are extracted from the updated temporal knowledge graph, wherein the embedded data includes vector representations of entities, relationships between entities, and occurrence times of the relationships in the temporal knowledge graph; generating semantic description information based on the plurality of embedded data, wherein the semantic description information is used to express association relationships between entities corresponding to the plurality of embedded data; Based on the semantic description information and the updated temporal knowledge graph, link prediction is performed on the first entity to obtain a target entity that has a link relationship with the first entity in a target time period.

2. The method according to claim 1, characterized in that The generating semantic description information based on the plurality of embedded data comprises: Converting the plurality of embedded data into text data, and determining a first associated word for characterizing a first relationship between the plurality of the second entities; generating, according to the first associated words, a second associated word for representing the associated structure between the text data; The text data is concatenated based on the second associated words to generate the semantic description information.

3. The method according to claim 1, characterized in that The performing link prediction on the first entity according to the semantic description information and the updated temporal knowledge graph to obtain a target entity having a link relationship with the first entity in a target time period includes: Determine, according to the semantic description information and the updated temporal knowledge graph, a first matching degree between the first entity and a third entity within the target time period, and determine a priority of each of the third entities according to the first matching degree, wherein the third entity has an association relationship with the second entity; Perform link prediction on the first entity according to the priority of the third entity to obtain the target entity, where the target entity includes the third entity whose priority is within a set priority range.

4. The method according to claim 3, characterized in that The determining, according to the semantic description information and the updated temporal knowledge graph, a first matching degree between the first entity and the third entity within the target time period includes: determining, according to the semantic description information, a second matching degree between the first entity and the third entity within the target time period; Determining an interaction index of the third entity within the target time period based on the updated time series knowledge graph; The first matching degree is obtained according to the interaction index and the second matching degree.

5. The method according to claim 1, characterized in that: The extracting a plurality of embedded data from the updated temporal knowledge graph includes: Based on the updated temporal knowledge graph, determine first embedded data corresponding to the first entity and second embedded data corresponding to the second entity; Obtaining the plurality of embedded data according to the first embedded data and the second embedded data; The first embedded data includes a first time series feature of the first entity, and the second embedded data includes a second time series feature corresponding to the second entity.

6. The method according to claim 5, characterized in that Also includes: In response to a fourth entity being added to the temporal knowledge graph, determining third embedded data according to an association relationship between the embedded data and the fourth entity; According to the first embedded data and the third embedded data, the association relationship between the first entity and the fourth entity is determined, and a link prediction is performed between the first entity and the fourth entity according to the association relationship to determine whether there is a link relationship between the first entity and the fourth entity within the target time period.

7. The method according to any one of claims 1 to 6, characterized in that The method further comprises: The entity information corresponding to the target entity that has a link relationship with the first entity in the target time period is used as recommendation information and recommended to the to-be-recommended object corresponding to the first entity.

8. A model training method, characterized in that: include: Acquire a training sample set, the training sample set comprising a plurality of training samples, the training samples comprising first sample relationship data and a calibrated target entity, the first sample relationship data being relationship data between a first sample entity and a plurality of second sample entities; Inputting each training sample in the training sample set into the model to be trained to perform link prediction, and obtaining a first predicted target entity; A loss function value is calculated according to the first prediction target and the calibrated target entity, and the parameters of the model to be trained are adjusted according to the loss function value.

9. The method according to claim 8, characterized in that The link prediction includes: The sample time series knowledge graph is updated based on the second sample relationship data, and a plurality of sample embedding data are extracted from the updated sample time series knowledge graph; wherein the sample time series knowledge graph is generated based on the first sample relationship data between the first sample entity and the plurality of second sample entities, and the sample embedding data includes a vector representation of the sample entities, the relationship between the sample entities, and the occurrence time of the relationship in the sample time series knowledge graph; generating sample semantic description information based on the plurality of sample embedding data, wherein the sample semantic description information is used to express association relationships between sample entities corresponding to the plurality of sample embedding data; According to the sample semantic description information and the updated sample time series knowledge graph, link prediction is performed on the first sample entity to obtain a first predicted target entity that has a link relationship with the first sample entity in a target time period.

10. A link prediction device, characterized in that: include: A generation module, used to generate a time series knowledge graph based on the relationship data between the first entity and the plurality of second entities; An updating module, configured to update the temporal knowledge graph in response to a change in the relationship data between the first entity and the second entity, and extract a plurality of embedded data from the updated temporal knowledge graph, wherein the embedded data includes vector representations of entities, relationships between entities, and occurrence times of relationships in the temporal knowledge graph; A conversion module, used to generate semantic description information based on the multiple embedded data, wherein the semantic description information is used to express the association relationship between entities corresponding to the multiple embedded data; A determination module is used to perform link prediction on the first entity based on the semantic description information and the updated temporal knowledge graph to obtain a target entity that has a link relationship with the first entity in a target time period.

11. A model training device, characterized in that: include: An acquisition module, configured to acquire a training sample set, wherein the training sample set includes a plurality of training samples, wherein the training samples include first sample relationship data and a calibration target entity, wherein the first sample relationship data is relationship data between a first sample entity and a plurality of second sample entities; A prediction module, used for inputting each training sample in the training sample set into the model to be trained to perform link prediction and obtain a first predicted target entity; A parameter adjustment module is used to calculate a loss function value according to the first prediction target and the calibrated target entity, and adjust the parameters of the model to be trained according to the loss function value.

12. A computer device, characterized in that: It comprises a memory and a processor, wherein the memory stores a plurality of instructions; the processor loads instructions from the memory to execute the steps of the link prediction method according to any one of claims 1 to 7 or the model training method according to claim 8 or 9.

13. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a plurality of instructions, which are suitable for loading by a processor to execute the steps of the link prediction method according to any one of claims 1 to 7 or the model training method according to claim 8 or 9.

14. A computer program product, characterized in that The computer program product comprises a computer program, and the computer program is used by a processor to execute the steps of the link prediction method according to any one of claims 1 to 7 or the model training method according to claim 8 or 9.

Citation Information

Cited By

  • AI Agent implementation method for social contact and related device

    CN120256876A