Model training method and device, electronic equipment and storage medium

By introducing the correlation scoring and attention mechanism of the knowledge graph embedding model in the entity recommendation model, the target node characteristics are generated, and the problem of insufficient information in the existing technology is solved, and the relevance and accuracy of recommendations is improved.

CN119601035APending Publication Date: 2025-03-11TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510080267.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-16
Publication Date
2025-03-11

AI Technical Summary

Technical Problem

The existing entity recommendation model lacks information when estimating entity click-through rate, resulting in the need to improve the correlation between the recommended entity and the specific query request.

Method used

By calling the knowledge graph embedding model, the correlation score between entity nodes is determined, and the knowledge graph embedding model is trained based on these scores, the node characteristics and neighbor node characteristics of the sample entity are obtained, and the attention mechanism is used to aggregate neighbor node characteristics to generate target node characteristics, which are used to train the entity recommendation model.

Benefits of technology

Effectively weighing the computational complexity and prediction accuracy of the entity recommendation model improves the correlation between the final recommended entity and the specific query request.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119601035A_ABST
    Figure CN119601035A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a model training method and device, electronic equipment and a storage medium, and the method comprises the steps: determining a first correlation score of any two nodes in a knowledge graph through calling a knowledge graph embedding model, and training the knowledge graph embedding model based on the first correlation score; sampling a sample neighbor node set of the sample entity nodes in the knowledge graph, and calling the knowledge graph embedding model to determine sample node features, each first-order neighbor node feature and a second correlation score between the sample entity nodes and each first-order neighbor node; aggregating the first-order neighbor node features based on an attention mechanism constructed by the second correlation score to obtain first-order attention features, and fusing the first-order attention features with the sample node features to obtain target node features; and the entity recommendation model is called to determine the estimated click rate of the sample entity based on the target node features, and the entity recommendation model is trained based on the estimated click rate, so that the calculation complexity and the prediction precision of the entity recommendation model can be balanced, and the correlation of the recommended entity is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of artificial intelligence technology, and in particular to a model training method, device, electronic device and storage medium. Background Art

[0002] Entity recommendation is a common means of displaying information on the Internet. At present, entity recommendation models are usually used in the fine ranking stage to estimate the click-through rate of entities, and then select corresponding entities for recommendation and display. In related technologies, query semantic features related to the entity to be recommended are usually obtained, and the click-through rate is predicted after being input into the entity recommendation model. However, the amount of information obtained by the entity recommendation model in this way is not much, so the correlation between the final recommended entity and the specific query request needs to be improved. Summary of the invention

[0003] The following is a summary of the subject matter of the detailed description of the present disclosure. This summary is not intended to limit the scope of the claims.

[0004] The embodiments of the present disclosure provide a model training method, device, electronic device and storage medium, which can effectively balance the computational complexity and prediction accuracy of the entity recommendation model, thereby improving the relevance between the final recommended entity and the specific query request.

[0005] On the one hand, the present disclosure provides a model training method, including:

[0006] Calling the knowledge graph embedding model to determine a first correlation score between any two entity nodes in the knowledge graph, and training the knowledge graph embedding model based on the first correlation score;

[0007] Obtain a sample entity node corresponding to the sample entity in the knowledge graph and a sample neighbor node set sampled from the sample entity node in the knowledge graph, and call the trained knowledge graph embedding model to determine the sample node features of the sample entity node, the first-order neighbor node features of each first-order neighbor node in the sample neighbor node set, and a second correlation score between the sample entity node and each of the first-order neighbor nodes;

[0008] Aggregating the first-order neighbor node features based on the attention mechanism constructed by the second relevance score to obtain a first-order attention feature, and fusing the first-order attention feature with the sample node feature to obtain a target node feature of the sample entity;

[0009] The entity recommendation model is called to determine the estimated click rate of the sample entity based on the target node feature, and the entity recommendation model is trained based on the estimated click rate.

[0010] On the other hand, an embodiment of the present disclosure provides a model training device, including:

[0011] A first training module, configured to call a knowledge graph embedding model to determine a first correlation score between any two entity nodes in the knowledge graph, and to train the knowledge graph embedding model based on the first correlation score;

[0012] A sampling module, used to obtain a sample entity node corresponding to a sample entity in the knowledge graph and a sample neighbor node set sampled from the sample entity node in the knowledge graph, and call the trained knowledge graph embedding model to determine the sample node features of the sample entity node, the first-order neighbor node features of each first-order neighbor node in the sample neighbor node set, and a second correlation score between the sample entity node and each of the first-order neighbor nodes;

[0013] a fusion module, configured to aggregate the first-order neighbor node features based on the attention mechanism constructed by the second relevance score to obtain a first-order attention feature, and fuse the first-order attention feature with the sample node feature to obtain a target node feature of the sample entity;

[0014] The second training module is used to call the entity recommendation model to determine the estimated click rate of the sample entity based on the target node feature, and train the entity recommendation model based on the estimated click rate.

[0015] Furthermore, the first training module is also used for:

[0016] Call the knowledge graph embedding model to determine the head entity node features of the head entity node, the tail entity node features of the tail entity node, and the edge features of the edge relationship in any triple of the knowledge graph;

[0017] An attention mechanism constructed based on the head entity node feature, the tail entity node feature, and the edge feature determines a first correlation score between the head entity node and the tail entity node.

[0018] Furthermore, the first training module is also used for:

[0019] Obtain a trainable first linear transformation matrix and a second linear transformation matrix;

[0020] Constructing a query feature based on the inner product between the first linear transformation matrix and the head entity node feature, and constructing a key feature based on the inner product between the second linear transformation matrix and the tail entity node feature;

[0021] The inner product between the query feature, the key feature and the edge feature is normalized to obtain a first correlation score between the head entity node and the tail entity node.

[0022] Furthermore, the first training module is also used for:

[0023] Taking the triple in the knowledge graph as a positive sample, constructing a negative sample by replacing the head entity node or the tail entity node in the triple, and calling the knowledge graph embedding model to determine a third relevance score corresponding to the negative sample;

[0024] A target loss is determined according to the first relevance score and the third relevance score, and the knowledge graph embedding model is trained based on the target loss.

[0025] Furthermore, the first training module is also used for:

[0026] Determine a first loss, a second loss, and a third loss respectively according to the first correlation score and the third correlation score, wherein the first loss is used to maximize the difference between the first correlation score and the third correlation score, the second loss is used to control the difference between the first correlation score and the third correlation score, and the third loss is used to maximize the first correlation score while minimizing the third correlation score;

[0027] The first loss, the second loss and the third loss are weightedly summed to obtain a target loss.

[0028] Furthermore, the sampling module is also used for:

[0029] Traversing the knowledge graph, for the currently traversed central entity node, sampling the first neighbor node set of the central entity node in the knowledge graph, wherein the first neighbor node set includes the first neighbor node subset of the central entity node at the kth level, and the first neighbor node subset includes the neighbor nodes sampled by the central entity node at the kth level, where k is an integer, k≥1;

[0030] Associating each of the central entity nodes with the corresponding first neighbor node set and writing them into a cache;

[0031] The sample entity node and the sample neighbor node set corresponding to the sample entity in the knowledge graph are matched from the cache.

[0032] Furthermore, the sampling module is also used for:

[0033] For all neighbor nodes of the kth class of the central entity node, the trained knowledge graph embedding model is called to determine a fourth correlation score between the central entity node and each of the neighbor nodes, all neighbor nodes of the kth class are sorted according to the size of the fourth correlation score, and a first neighbor node subset of the kth class is sampled from the sorting result according to the first ranking threshold;

[0034] The first neighbor node subsets of k levels are combined to obtain the first neighbor node set of the central entity node.

[0035] Furthermore, the sampling module is also used for:

[0036] Matching the central entity node and the first neighbor node set corresponding to the sample entity in the knowledge graph from the cache;

[0037] For the first neighbor node subset of the kth level in the first neighbor node set, sampling again according to a second ranking threshold to obtain a second neighbor node subset of the kth level, wherein the second ranking threshold is less than the first ranking threshold;

[0038] The second neighbor node subsets of k levels are combined to obtain a sample neighbor node set of the central entity node.

[0039] Furthermore, the sampling module is also used for:

[0040] When k=1, the first-order attention feature is fused with the sample node feature to obtain the target node feature of the sample entity node at the first level, and the first-order neighbor node feature is updated based on the second-order neighbor node feature of the second-order neighbor node of the sample entity node;

[0041] When k>1, based on the first-order neighbor node features updated at the k-1th level and the target node features obtained at the k-1th level, determine the fifth correlation score between the sample entity node and each of the first-order neighbor nodes, aggregate the first-order neighbor node features updated at the k-1th level based on the attention mechanism constructed by the fifth correlation score to obtain a k-order attention feature, fuse the k-order attention feature with the target node features obtained at the k-1th level to obtain the target node features of the sample entity at the k-th level, and update the n-order neighbor node features of the n-order neighbor nodes of the sample entity node based on the n+1-order neighbor node features of the n+1-order neighbor nodes of the sample entity node, where n is an integer, n∈[1,k].

[0042] Furthermore, the sampling module is also used for:

[0043] Determine a sixth correlation score between the second-order neighbor node of the sample entity node and each of the first-order neighbor nodes;

[0044] Aggregating the second-order neighbor node features of the second-order neighbor node based on the attention mechanism constructed by the sixth relevance score to obtain a second-order attention feature;

[0045] The second-order attention feature is fused with the first-order neighbor node feature to obtain an updated first-order neighbor node feature.

[0046] Furthermore, the above fusion module is also used for:

[0047] Normalizing the second relevance score to obtain an attention weight;

[0048] The first-order neighbor node features are weighted summed according to the attention weights to aggregate the first-order neighbor node features to obtain first-order attention features.

[0049] Furthermore, the second training module is also used for:

[0050] Acquire the query semantic feature associated with the sample entity, and concatenate the query semantic feature with the target node feature to obtain a concatenated feature;

[0051] The entity recommendation model is called to determine the estimated click rate of the sample entity based on the concatenated features.

[0052] On the other hand, an embodiment of the present disclosure further provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the above-mentioned model training method when executing the computer program.

[0053] On the other hand, an embodiment of the present disclosure further provides a computer-readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement the above-mentioned model training method.

[0054] On the other hand, the embodiment of the present disclosure further provides a computer program product, which includes a computer program, and the computer program is stored in a computer-readable storage medium. The processor of the computer device reads the computer program from the computer-readable storage medium, and the processor executes the computer program, so that the computer device executes the above-mentioned model training method.

[0055] The disclosed embodiments include at least the following beneficial effects: by calling the knowledge graph embedding model to determine the first correlation score between any two entity nodes in the knowledge graph, and training the knowledge graph embedding model based on the first correlation score, the structural information of the knowledge graph and the semantic association information between entities can be more accurately captured by introducing the first correlation score. On this basis, by obtaining the sample entity nodes corresponding to the sample entities in the knowledge graph and the sample neighbor node set obtained by sampling the sample entity nodes in the knowledge graph, the computational complexity can be reduced by sampling, so that the sample node features of the sample entity nodes and the first-order neighbor node features of each first-order neighbor node in the sample neighbor node set are determined by calling the trained knowledge graph embedding model. And the second correlation score between the sample entity node and each first-order neighbor node, based on the attention mechanism constructed by the second correlation score, the first-order neighbor node features are aggregated to obtain the first-order attention feature, and when the first-order attention feature is fused with the sample node feature, the target node feature of the sample entity can be efficiently obtained, and then the entity recommendation model is called to determine the estimated click-through rate of the sample entity based on the target node feature, and the entity recommendation model is trained based on the estimated click-through rate. The disclosed embodiment can introduce a knowledge graph when training the entity recommendation model to enrich the amount of information obtained by the entity recommendation model, and realize two-stage training, effectively balancing the computational complexity and prediction accuracy of the entity recommendation model, thereby improving the correlation between the final recommended entity and the specific query request.

[0056] Other features and advantages of the present disclosure will be set forth in the following description, and in part will be apparent from the description, or may be learned by practicing the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0057] The accompanying drawings are used to provide further understanding of the technical solution of the present disclosure and constitute a part of the specification. Together with the embodiments of the present disclosure, they are used to explain the technical solution of the present disclosure and do not constitute a limitation on the technical solution of the present disclosure.

[0058] Figure 1 A schematic diagram of an optional implementation environment provided for an embodiment of the present disclosure;

[0059] Figure 2 An optional flowchart of a model training method provided in an embodiment of the present disclosure;

[0060] Figure 3 A schematic diagram of a sampling process of a sample neighbor node set provided in an embodiment of the present disclosure;

[0061] Figure 4 An effect diagram of entity recommendation on a browser search result page provided by an embodiment of the present disclosure;

[0062] Figure 5A schematic diagram of the process of calculating the correlation score provided in an embodiment of the present disclosure;

[0063] Figure 6 A schematic diagram of updating the knowledge graph embedding model training provided by an embodiment of the present disclosure;

[0064] Figure 7 is a schematic diagram of the process of target loss calculation provided by an embodiment of the present disclosure;

[0065] Figure 8 A schematic diagram of a first neighbor node set provided by an embodiment of the present disclosure;

[0066] Fig. 9 A schematic diagram of multi-stage first neighbor node subset sampling provided by an embodiment of the present disclosure;

[0067] Fig.10 A schematic diagram of secondary sampling of a neighbor node set provided in an embodiment of the present disclosure;

[0068] Fig.11 is a schematic diagram of secondary sampling of a neighbor node set provided by another embodiment of the present disclosure;

[0069] Fig.12 A schematic diagram of iterative update of target node features provided by an embodiment of the present disclosure;

[0070] Fig.13 A schematic diagram of a model training architecture provided for an embodiment of the present disclosure;

[0071] Fig.14 A schematic diagram of the effect of the application model training method provided by one embodiment of the present disclosure;

[0072] Fig.15 A schematic diagram of the effect of an application model training method provided by another embodiment of the present disclosure;

[0073] Fig.16 A schematic diagram of the effect of an application model training method provided by another embodiment of the present disclosure;

[0074] Fig.17 An optional specific flow chart of the model training method provided in the embodiment of the present disclosure;

[0075] Fig.18 An optional structural diagram of a model training device provided in an embodiment of the present disclosure;

[0076] Fig.19 A partial structural block diagram of a terminal provided in an embodiment of the present disclosure;

[0077] Fig. 20 A partial structural block diagram of a server provided in an embodiment of the present disclosure. DETAILED DESCRIPTION

[0078] In order to make the purpose, technical solution and advantages of the present disclosure more clear, the present disclosure is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present disclosure and are not used to limit the present disclosure.

[0079] It should be noted that in various specific embodiments of the present disclosure, when it comes to the need to perform relevant processing based on data related to the characteristics of the target object such as the target object attribute information or attribute information set, the permission or consent of the target object will be obtained first, and the collection, use and processing of these data will comply with relevant laws, regulations and standards. Among them, the target object can be a user. In addition, when the embodiment of the present disclosure needs to obtain the attribute information of the target object, the separate permission or separate consent of the target object will be obtained through a pop-up window or by jumping to a confirmation page. After clearly obtaining the separate permission or separate consent of the target object, the necessary target object-related data used to enable the normal operation of the embodiment of the present disclosure will be obtained.

[0080] In the embodiments of the present disclosure, the term "module" or "unit" refers to a computer program or a part of a computer program with a predetermined function, and works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories) or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be part of an overall module or unit that includes the function of the module or unit.

[0081] To facilitate understanding of the technical solution provided by the embodiments of the present disclosure, some key terms used in the embodiments of the present disclosure are explained here:

[0082] The fine ranking stage is a key component in the recommendation system chain. It is used to more accurately predict and rank each candidate recommendation item in the candidate set containing multiple candidate recommendation items screened out in the recall stage and the rough ranking stage in the recommendation system chain.

[0083] Knowledge Graph is a structured semantic knowledge base that describes conceptual entities in the physical world and the relationships between multiple conceptual entities through nodes and edges. Knowledge Graph is used to organize and identify information in a machine-understandable way. Knowledge Graph is not only a collection of data, but also contains structural semantic information about the data, which can support more complex queries and reasoning, and help extract implicit knowledge and features.

[0084] Knowledge Graph Embedding (KGE) is a method that maps entities and relations in a knowledge graph into a low-dimensional vector space. The position of each point in the vector space has semantic meaning, so that this vector representation can be used to capture the semantic information between entities and relations.

[0085] A triple is a basic structural form used to represent knowledge in a knowledge graph. It consists of three parts: a subject, a predicate, and an object. The predicate represents a relation in the knowledge graph, and the subject and object represent the head entity node and the tail entity node connected by the relation, respectively. Therefore, a triple can also be formally represented as (h, r, t). Specifically, a knowledge graph can be equivalently represented as a set of triples equal to the number of edges.

[0086] As an important means of Internet information display, entity recommendation has been widely used in various online platforms and services, aiming to provide users with more personalized and accurate content recommendations. In the recommendation system chain of entity recommendation, the refined ranking stage is an important link, which is closely related to the quality and relevance of the entities finally recommended to users. At present, the entity recommendation model is generally used in the refined ranking stage of the recommendation system to estimate the click-through rate of each candidate entity, so as to select the most attractive entities for recommendation display based on the estimated results. However, in related technologies, the input information of the entity recommendation model is limited, and it mainly depends on the query semantic features related to the entity to be recommended. Although the query semantic features can reflect the user's query intention and interest preference to a certain extent, due to the limitation of the amount of information, the entity recommendation model is difficult to fully and deeply understand the user's real needs, and it is difficult to accurately capture the complex relationship between each entity and the specific query request, resulting in deficiencies in the relevance and accuracy of the final recommended entities.

[0087] Based on this, the embodiments of the present disclosure propose a model training method, device, electronic device and storage medium, which determines the first correlation score between any two entity nodes in the knowledge graph by calling the knowledge graph embedding model, and trains the knowledge graph embedding model based on the first correlation score. By introducing the first correlation score, the structural information of the knowledge graph and the semantic association information between entities can be more accurately captured. On this basis, by obtaining the sample entity nodes corresponding to the sample entities in the knowledge graph and the sample neighbor node set obtained by sampling the sample entity nodes in the knowledge graph, the sampling method can be used to reduce the computational complexity, so that the sample node features of the sample entity nodes and the first-order neighbors of each first-order neighbor node in the sample neighbor node set can be determined by calling the trained knowledge graph embedding model. Node features and the second correlation score between the sample entity node and each first-order neighbor node, and aggregate the first-order neighbor node features based on the attention mechanism constructed by the second correlation score to obtain the first-order attention feature. When the first-order attention feature is fused with the sample node feature, the target node feature of the sample entity can be efficiently obtained, and then the entity recommendation model is called to determine the estimated click-through rate of the sample entity based on the target node feature, and the entity recommendation model is trained based on the estimated click-through rate. Therefore, the embodiment of the present disclosure can introduce the knowledge graph when training the entity recommendation model to enrich the amount of information obtained by the entity recommendation model, realize the two-stage training of the entity recommendation model, and effectively balance the computational complexity and the prediction accuracy of the entity recommendation model, thereby improving the correlation between the final recommended entity and the specific query request.

[0088] The method provided in the embodiments of the present disclosure can be applied to different scenarios, including but not limited to cloud technology, artificial intelligence, Internet services and the like.

[0089] Reference Figure 1 , Figure 1 A schematic diagram of an optional implementation environment provided for an embodiment of the present disclosure, the implementation environment includes a terminal 101 and a server 102, wherein the terminal 101 and the server 102 are connected via a communication network.

[0090] The terminal 101 may be a mobile phone, a computer, an intelligent voice interaction device, an intelligent wearable device, an intelligent home appliance, a vehicle-mounted terminal, etc., but is not limited thereto. The terminal 101 and the server 102 may be directly or indirectly connected via wired or wireless communication, which is not limited in the embodiments of the present disclosure.

[0091] Exemplarily, terminal 101 can collect data related to entities in the entity recommendation process, such as input search keywords, entity click-through rate, etc. Terminal 101 can perform preliminary data cleaning and preprocessing on the collected data, such as noise removal, format conversion, etc. Terminal 101 sends the processed data to server 102, so that server 102 can use the sample data and feedback provided by terminal 101 for subsequent training of the entity recommendation model.

[0092] Server 102 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. In addition, server 102 can also be a node server in a blockchain network.

[0093] Exemplarily, the server 102 may pre-store a knowledge graph embedding model and an entity recommendation model. The server 102 constructs and updates the knowledge graph by receiving the entity data provided by the terminal 101, calls the knowledge graph embedding model to determine the first correlation score between any two entity nodes in the knowledge graph, and trains the knowledge graph embedding model based on the first correlation score; then, using the sample entity nodes corresponding to the sample entities in the knowledge graph and the sample neighbor node set obtained by sampling the sample entity nodes in the knowledge graph, calls the trained knowledge graph embedding model to determine the sample node features of the sample entity nodes, the first-order neighbor node features of each first-order neighbor node in the sample neighbor node set, and the second correlation score between the sample entity node and each first-order neighbor node; then, based on the attention mechanism constructed by the second correlation score, aggregates the first-order neighbor node features to obtain the first-order attention features, fuses the first-order attention features with the sample node features to obtain the target node features of the sample entity; then, calls the entity recommendation model to determine the estimated click-through rate of the sample entity based on the target node features, and trains the entity recommendation model based on the estimated click-through rate.

[0094] Reference Figure 2 , Figure 2 An optional flow chart of a model training method provided for an embodiment of the present disclosure, the model training method can be executed by a server, or can also be executed by a terminal, or can also be executed by a server in conjunction with a terminal, the model training method includes but is not limited to the following steps 201 to 204.

[0095] Step 201: calling the knowledge graph embedding model to determine a first correlation score between any two entity nodes in the knowledge graph, and training the knowledge graph embedding model based on the first correlation score;

[0096] Among them, the nodes in the knowledge graph can refer to entities or concepts in the knowledge graph, such as people, places, objects, organizations, etc. Each node has one or more types and can also contain attribute information to describe the characteristics of the entity. For example, in the knowledge graph describing a novel, the node can represent the novel, the author, the character, etc.; and the edge relationship between two nodes in the knowledge graph is represented as the association between the two entities. Similarly, the relationship can also include different types and can also contain attribute information to describe the characteristics of the relationship. For example, in the above-mentioned novel knowledge graph, the relationship can represent "created", "style", "sequel / prequel", etc.; therefore, two nodes in the knowledge graph can refer to the nodes of two entities or concepts, which are connected to each other through a specific relationship.

[0097] It is worth noting that the knowledge graph embedding model can be called to calculate the relevance score for any two entity nodes in the encyclopedic knowledge graph. Specifically, the encyclopedic knowledge graph can refer to a knowledge base containing a large number of entities, relationships and attributes, covering a wide range of fields and topics. The knowledge graph can be obtained from an open source database, for example, through an API interface or tool provided by the open source database, or the knowledge graph can also be constructed based on relevant entity and relationship data collected from various data sources (such as text, databases, web pages, etc.). Due to the large scale of the knowledge graph and the relatively stable data in the short term without major changes, the knowledge graph embedding model can be updated regularly, such as once a day or every 12 hours, to avoid the cost overhead caused by frequent updates.

[0098] It should be noted that each node and relationship in the knowledge graph is represented by a vector. Specifically, the entire knowledge graph is split by edge, and each edge relationship and head and tail entity node are formally represented as a triple (h, r, t), where h represents the node number of the head node, t represents the node number of the tail node, and r represents the relationship number of the edge relationship. For each entity and each edge relationship, the corresponding embedding vector is initialized to obtain the embedding vector triple Among them, the embedding vectors of the head and tail entity nodes share an embedding table for storage, while the embedding vectors of the edge relationship are stored in another embedding table. The embedding table can be understood as a matrix that stores the embedding vectors. The knowledge graph embedding model can convert the discrete features of high-dimensional coefficients into low-dimensional dense embedding vectors, which can retain the semantics of entities and relationships. Since the head and tail entity nodes (such as people, items, etc.) and edge relationships (such as interactions and relationships between people and items) have different data characteristics, entity nodes carry richer attributes and features, while edge relationships reflect more of the connection and interaction between entities. Therefore, storing and processing different types of data in different embedding tables can simplify the complexity of the model and effectively reduce the difficulty of model training.

[0099] Specifically, taking a simple social network of multiple characters as an example, which contains multiple characters (i.e., entity nodes) and friend relationships (i.e., edge relationships) between the characters, it is necessary to generate embedding vectors for multiple characters and each friend relationship for subsequent recommendation tasks. Suppose there are 5 characters, namely A, B, C, D and E, and assign a unique node number to each character, for example, the node number of A is 001, the node number of B is 002, and so on; at the same time, suppose that the 5 characters have the following friend relationships: AB, BC, CD, DE and AE, representing the friend relationship between the characters of two lines, and also assign a unique relationship number to each friend relationship, for example, the relationship number of AB is 001, the relationship number of BC is 002, and so on; create a matrix of size (5, d) as a matrix for storing entity nodes. An embedding table for body nodes, where 5 represents the number of characters (entity nodes) and d represents the dimension of the embedding vector, which can be adjusted according to the specific task. Each row of the embedding table (i.e., matrix) corresponds to the embedding vector of a character (entity node). For example, the first row of the matrix corresponds to the embedding vector of character A. In addition, a matrix of size (5, e) is created as an embedding table for storing relationships, where 5 represents the number of relationships, which can be adjusted according to the actual number of relationships between nodes, that is, the number of relationships can be the same as or different from the number of entity nodes, and e represents the dimension of the embedding vector of the relationship, which can also be adjusted according to the specific task. Similarly, each row of the embedding table for storing the embedding vector of the relationship can also correspond to the embedding vector of a relationship. For example, the first row of the embedding table corresponds to the embedding vector of relationship AB.

[0100] Among them, the relevance score can refer to an indicator used to measure the degree of relevance between any two entity nodes in the knowledge graph, which can be calculated through the knowledge graph embedding model, so that the relevance score can be used to evaluate the proximity of two entities in the vector space. That is to say, the higher the relevance score between two entity nodes in the knowledge graph, the more semantically similar or closely related they are; the relevance score can be applied to a variety of application scenarios. For example, in the recommendation system, items that may be of interest to the user can be recommended based on the relevance score between the user and the item; in the information retrieval system, relevant search results can be returned based on the relevance score between the query term and the entity node; in the question-and-answer system, the answer that meets the question can be retrieved from the knowledge graph based on the relevance score between the question and the answer.

[0101] Among them, the knowledge graph embedding model is used to convert the graph structure data of the knowledge graph into a vector structure. These vector representations retain the structural information of the entities in the knowledge graph, and can also reflect the semantic relationship between entities through vector operations. In the knowledge graph embedding model, a corresponding relevance scoring function can be pre-defined to measure the relevance between two entities. The relevance scoring function can be based on calculating the distance or similarity between the embedding vectors of the two entities to evaluate the relevance between the two entities. For example, the relevance scoring function can use methods such as Euclidean distance and cosine similarity to calculate the distance or similarity between the two entity vectors, thereby obtaining a relevance score between them. Specifically, the relevance scoring function can be constructed based on functions such as TransE, TransH, and TransR that use distance as a scoring reference, modeling the relationship between the two entities as a distance transformation from the head entity to the tail entity, and determining the relevance score through the distance difference after the transformation. The relevance scoring function can also be constructed based on functions such as DistMult, HolE, and ComplEx that use similarity as a scoring reference, and determining the relevance score by calculating the similarity of the projections of the embedding vectors of the two entities in the direction of the relationship vector. Since the knowledge graph embedding model has a simple structure and lightweight computation, it can effectively reduce computational overhead and quickly learn the generalized features of the entire knowledge graph data.

[0102] In one possible implementation, the knowledge graph embedding model is first trained using the entity node data in the knowledge graph. During the training process, the knowledge graph embedding model will continuously adjust the embedding vectors of the entity nodes and relationships. After the training is completed, the embedding vectors of each entity node and relationship can be obtained. For two given entity nodes e1 and e2, the pre-trained knowledge graph embedding model can be used to extract the embedding vectors Ve1 and Ve2 of the two entity nodes. Then, the cosine similarity of the entity nodes on the vectors can be used to measure the correlation between them. The value range of cosine similarity is [-1,1]. If the cosine similarity of the two entity nodes is closer to 1, it means that the two entity nodes are more similar. If the cosine similarity is closer to -1, it means that the two entity nodes are less similar. The calculated cosine similarity value can be directly used as the first correlation score between the two entity nodes.

[0103] In one possible implementation, after obtaining the first correlation scores of any two entity nodes in the knowledge graph, the sample correlation scores between the entity nodes can be obtained, and the loss function is used to calculate the difference between the first correlation score and the sample correlation score as the loss value. Through optimization algorithms such as gradient descent, the parameters of the knowledge graph embedding model are updated according to the gradient information of the loss function to make the loss value as small as possible. In the process of training the knowledge graph embedding model, the model parameters that are continuously updated include the embedding vectors of the entity nodes and the relationships, that is, they are stored in the embedding tables of the entity nodes and the relationships, respectively.

[0104] It is worth noting that when using relevance scoring to train the knowledge graph embedding model, a variety of loss functions can be selected to optimize the model parameters. For example, the cross entropy loss function, the boundary ranking loss function, and the mean square error loss function can be used.

[0105] Step 202: Obtain the sample entity node corresponding to the sample entity in the knowledge graph and the sample neighbor node set sampled from the sample entity node in the knowledge graph, and call the trained knowledge graph embedding model to determine the sample node features of the sample entity node, the first-order neighbor node features of each first-order neighbor node in the sample neighbor node set, and the second correlation score between the sample entity node and each first-order neighbor node.

[0106] Among them, the sample entity node can refer to a specific node representing the sample entity in the knowledge graph. The sample entity node stores detailed information about the sample entity, such as the name, attributes, and relationship with other entities of the sample entity; in the knowledge graph, for a given sample entity node, the corresponding neighbor nodes can be obtained by sampling, and the sample neighbor node set can be obtained by combining. These neighbor nodes can refer to entity nodes that have a direct relationship with the sample entity node. For example, in the knowledge graph in the field of e-commerce, if the sample entity node is a "customer", then the neighbor nodes of the sample entity node may include entity nodes such as products and orders purchased by the customer. There are many methods for sampling the neighbor node set, such as random sampling, sampling based on relationship type, sampling based on node distance, and the number of nodes for constructing the neighbor node set can be limited. Specifically, sample entities can be extracted from text through natural language processing technology such as named entity recognition, and the identified sample entities can be matched with entity nodes in the knowledge graph. The similarity between the sample entity and each entity node in the knowledge graph can be calculated using the entity linking tool, and the entity node with the highest similarity is selected as the matching result, that is, the sample entity node corresponding to the sample entity in the knowledge graph is obtained.

[0107] It is worth noting that sampling based on relationship types can refer to selecting entity nodes that have established edge relationships with entity nodes, or selecting entity nodes that have established specified edge relationships with entity nodes. For example, there are multiple types of relationships between entity nodes. Taking the sports knowledge graph as an example, person A participated in sports competitions B and C as an athlete, and person B is the coach of person A. The relationship established between the entity node corresponding to person A and the entity node corresponding to sports competition B and the entity node corresponding to sports competition C is "participating", while the relationship established between the entity node corresponding to person A and the entity node corresponding to person B is "being taught". Therefore, the type of relationship established between the same entity node and different entity nodes may be different. In addition, in addition to using a single sampling method, multiple sampling methods can also be mixed to sample neighbor nodes. For example, entity nodes that have established specified edge relationships with entity nodes can be first selected as candidate nodes, and then these candidate nodes are screened according to the correlation scores with the sample entity nodes to obtain a set of neighbor nodes.

[0108] Specifically, refer to Figure 3 , Figure 3: This is a schematic diagram of the sampling process of the sample neighbor node set provided by an embodiment of the present disclosure. Assume that the knowledge graph contains 7 entity nodes, namely A, B, C, D, E, F and G, wherein the edge relationships among the 7 entities are AB, AC, AE, AG, BD, CD and CF, respectively. Taking entity node A as the sample entity node as an example, the correlation scores between entity node A and the remaining entity nodes B, C, D, E, F and G in the knowledge graph are 0.96, 0.90, 0.82, 0.70, 0.65 and 0.85, respectively; if the neighbor nodes of the sample entity node A are sampled by random sampling, a preset number of them can be randomly selected from the remaining entity nodes B, C, D, E, F and G; or, entity nodes that have established edge relationships with the sample entity node A can be sampled as neighbor nodes, that is, the neighbor node set includes entity nodes B, C, E and G; or, entity nodes with a correlation score higher than 0.80 with entity node A can be sampled as neighbor nodes, that is, the sample neighbor node set includes entity nodes B, C, D and G.

[0109] In a possible implementation, in the knowledge graph embedding model, the embedding vectors of each entity node and relationship are low-dimensional representations obtained through learning. After the knowledge graph embedding model is trained, a corresponding embedding table will be generated. Each entity node and each relationship corresponds to an embedding vector, which is stored in the corresponding embedding table. In addition to the embedding vector of the entity node, the embedding table may also include corresponding attributes. Therefore, for a given sample entity node and a set of sample neighbor nodes, the corresponding embedding vector, that is, the corresponding node feature, can be found through the embedding table. In other words, the sample node feature of the sample entity node may refer to the embedding vector, attribute, and other properties of the entity node. Correspondingly, the first-order neighbor node features of each first-order neighbor node in the sample neighbor node set may refer to the embedded vectors, attributes and other information corresponding to these neighbor nodes; similarly, for a given sample entity node and each first-order neighbor node in the sample neighbor node set, the trained knowledge graph embedding model may be used to determine the second correlation score between the sample entity node and each first-order neighbor node, wherein the principle of using the knowledge graph embedding model to calculate the correlation scores between different nodes is the same, that is, the specific calculation process of the second correlation score between the sample entity node and each first-order neighbor node may refer to the above-mentioned embodiment of calculating the first correlation score, which will not be repeated here.

[0110] Step 203: Aggregate first-order neighbor node features based on the attention mechanism constructed by the second relevance score to obtain first-order attention features, and fuse the first-order attention features with the sample node features to obtain target node features of the sample entity;

[0111] In one possible implementation, a graph neural network can be used to sample and aggregate the first-order neighbor nodes of a sample entity. For example, a GraphSAGE (Graph Sample and Aggregate) model can be used to implement this. Specifically, a second relevance score is introduced as an attention weight, and the attention weight is used to perform weighted sum aggregation on each first-order neighbor node to the sample entity node, thereby avoiding ignoring the different importance of different neighbor nodes to the central node due to the use of a fixed aggregation function for aggregation. Therefore, an improved graph neural network model based on the attention mechanism can be used, with the sample entity node as the central node, and the node features of the first-order neighbor nodes are sampled from the knowledge graph. The second relevance score is used as the attention for graph convolution aggregation, and the aggregated features are fused and updated with the node features of the central node, and then input into the entity recommendation model to calculate the estimated click-through rate and update the loss optimization parameters.

[0112] Specifically, the attention mechanism constructed based on the second relevance score can be used to calculate the first-order neighbor node features of each first-order neighbor node of the sample entity node, so as to aggregate the information of each first-order neighbor node and obtain the first-order attention features of each first-order neighbor node after aggregation. For example, the second relevance score between the sample entity node and each first-order neighbor node can be normalized first, and the normalized second relevance score can be used as the attention coefficient of the corresponding first-order neighbor node feature, and the weighted sum of each first-order neighbor node feature is obtained to obtain the first-order attention feature. Therefore, the first-order neighbor node feature can refer to the node feature corresponding to the first-order neighbor node, and the first-order attention feature can refer to the aggregation of the first-order neighbor node features in the first-order neighbor node set, which is a comprehensive representation of each first-order neighbor node, so that it can contain the context information of the sample entity node, which helps to provide more comprehensive information, and because the attention mechanism is used in the aggregation process, the first-order attention feature pays more attention to the first-order neighbor node with higher relevance to the central node, i.e., the sample entity node, which can help the model learn the similarities and differences between different nodes, help improve the generalization ability of the model, and promote the model to understand the relationship between different nodes.

[0113] In a possible implementation, after obtaining the first-order attention features after aggregating the features of each first-order neighbor node, the first-order attention features are fused with the original sample node features of the sample entity node to obtain the target node features of the sample entity, and the sample node features of the sample entity node are updated. Specifically, in the fusion process, the information from the first-order neighbor nodes is combined with the information of the sample entity node itself. The first-order neighbor node features provide additional context and background knowledge for the sample node features, forming a more comprehensive and rich node feature representation, so that the obtained target node features can contain their own information and context information in the knowledge graph. At the same time, as the central entity The node features of a node will be dynamically updated as the neighboring nodes change, so that the knowledge graph structure embedding model can adapt to the update changes of the knowledge graph and capture the evolution of each entity node. For example, taking the entity recommendation system as an example, assuming that you want to recommend products to the target user, when constructing the node features of the target user, you can integrate the preference information of the target user's friends (ie, neighboring nodes) and the purchased product information. Generally speaking, the target user's interests will be affected by his friends. By integrating the information of neighboring nodes, the target user's node features will contain more information about the target user's preferences, so that you can more accurately understand the target user's interests and needs, and improve the accuracy of the entity recommendation system.

[0114] In a possible implementation, there are multiple feature fusion methods for fusing the first-order attention features with the sample node features, for example, splicing fusion, addition fusion, multiplication fusion and nonlinear fusion; specifically, the first-order attention features and the sample node features can be spliced ​​in the depth (or feature) dimension, and all information of the aggregation results and the central node features can be retained through splicing to form a new feature vector, namely, the target node feature, which helps the model learn a more comprehensive feature representation; or, the first-order attention features and the sample node features are added element by element, and bitwise addition is performed. It is possible to superimpose the aggregation results of the first-order attention features with the information of the sample node features, enhance the semantic information of the features, update the node features of the sample entity nodes, and obtain the target node features; or, multiply the first-order attention features with the sample node features element by element, and by bitwise multiplication, additional message passing between the sample entity nodes and the first-order neighbor nodes is added, which helps to improve the generalization ability of the model; in addition, nonlinear functions, such as neural network layers, polynomial functions, etc., can be used to fuse the first-order attention features with the sample node features. Through nonlinear fusion, the complex relationship between nodes can be captured, thereby improving the representation ability of the model.

[0115] Step 204: Call the entity recommendation model to determine the estimated click rate of the sample entity based on the target node features, and train the entity recommendation model based on the estimated click rate.

[0116] In one possible implementation, the estimated click-through rate may refer to one of the estimated indicators in the entity recommendation system. The purpose of estimating indicators for each entity recommendation item is to better measure and compare the attractiveness or value that different entities may have on users. The estimated indicators can reflect the interaction behavior or potential interest between users and entities, and are an important basis for the decision-making of the recommendation system. The click-through rate can indicate the probability of a user clicking on a certain entity recommendation item, and can directly reflect the user's interest in the entity recommendation item. In addition to the click-through rate, other estimated indicators can also be used in the recommendation system, such as conversion rate, dwell time, number of likes, number of comments, etc. These estimated indicators can reflect the user's interest and satisfaction with the entity recommendation items from different angles. In addition, In practical applications, multiple estimation indicators can be comprehensively considered to evaluate the quality of entity recommendation items, and different estimation indicators can be selected according to specific business scenarios and user needs. For example, in the product recommendation scenario, the recommended products can be evaluated by combining click-through rate, conversion rate and dwell time; in the news recommendation scenario, the reading time and the number of shares can be considered; in the video recommendation scenario, the viewing time and the completion rate can be considered; that is, the entity recommendation model can be called to determine the estimation indicator of the sample entity based on the target node characteristics. This estimation indicator can be the estimated click-through rate, or at least one of the estimation indicators such as conversion rate, dwell time, number of likes and number of comments, and the entity recommendation model can be trained using the estimation indicator.

[0117] In one possible implementation, an entity recommendation model may refer to a machine learning model for recommending entities related to user interests or needs. In a recommendation system, the entity recommendation model recommends products, content, or services that may be of interest to users by analyzing entity features and preferences provided by users. Specifically, the entity recommendation model can predict the user's interest in unexposed or newly emerged entities by learning and analyzing the interaction data between users and entities. These entities can be products, news articles, videos, music, users, or any other objects that can be represented in a recommendation system.

[0118] Among them, the target node feature refers to the attribute feature used to describe the target entity (i.e., the recommended entity), and the target node feature is obtained by fusing the information of the target entity and its neighboring nodes, thereby inputting rich feature information into the entity recommendation model, which can effectively improve the accuracy of the output results of the entity recommendation model.

[0119] It is worth noting that the entity recommendation model can refer to a model trained with a large amount of historical data (such as interaction data between users and entities). During the training process, the entity recommendation model will learn how to predict the estimated click rate of users to entities based on node features. The entity recommendation model can also directly adopt the entity recommendation model used in related technologies. After the target node features that have been fused with the first-order attention features and the sample node features are input into the pre-trained entity recommendation model, the entity recommendation model will calculate an estimated click rate based on the target node features. This estimated click rate indicates the possibility of users clicking on the sample entity. After obtaining the estimated click rate, a suitable loss function can be selected according to the requirements of the recommendation task, such as the cross entropy loss function and the mean square error loss function. The real click rate of the entity is obtained from the collected data set, and the loss is calculated with the estimated click rate. The gradient is then calculated based on the loss function, and the parameters of the model are updated through the back propagation algorithm. Through continuous iterative training until the model converges, a trained entity recommendation model is obtained. The trained entity recommendation model can then be deployed in a production environment for actual entity recommendation tasks, or the entity recommendation model can be updated to maintain the prediction accuracy of the entity recommendation model. Since the data update frequency and entity recommendation model update frequency are high during the entity recommendation process, if the full data of the knowledge graph is directly used for training and updating, the computational overhead is large and time-consuming. Therefore, the disclosed embodiment does not need to use the full data of the knowledge graph. It takes the sample entity node as the central node and samples the features of a part of the neighboring nodes from the knowledge graph to reduce the computational complexity of the model. It also constructs an attention mechanism based on the correlation score for feature fusion. The fused node features are input into the entity recommendation model for click-through rate estimation and loss optimization parameter update, thereby improving the model's depth of learning of knowledge graph features and the accuracy of prediction.

[0120] In one possible implementation, the model training method provided by the embodiment of the present disclosure can be applied to the scenario of browser search, by calling the knowledge graph embedding model to predetermine the correlation scores between the various entity nodes in the knowledge graph, and at the same time store the embedding vectors of all entities and relationships in the knowledge graph in the embedding table, and train the knowledge graph embedding model based on the correlation scores, so that in the process of model training, the embedding vectors of all entities and relationships are trained synchronously to improve the breadth of knowledge graph data training coverage; then, determine the sample entity nodes of the sample entity in the knowledge graph, and sample neighbor nodes for the sample entity nodes in the knowledge graph to obtain a sample neighbor node set, and then call the trained knowledge graph embedding model The sample node features of the sample entity node and the first-order neighbor node features of each first-order neighbor node in the sample neighbor node are determined from the embedding table, and the correlation score between the sample entity node and each first-order neighbor node is determined; then, the first-order neighbor node features are aggregated based on the attention mechanism constructed by these correlation scores to obtain the first-order attention features, and then the first-order attention features are fused with the sample node features to update the target node features of the sample entity, so as to call the entity recommendation model to determine the estimated click-through rate of the sample entity based on the target node features, and then train the entity recommendation model according to the estimated click-through rate. The trained entity recommendation model can be applied to the actual entity recommendation task, refer to Figure 4 , Figure 4 It is a browser search result page entity recommendation effect diagram provided by an embodiment of the present disclosure. A search keyword can be input into a search bar 410 in a browser display interface 400. Various search result cards 420 will be displayed in the browser display interface 400, and entity recommendation cards 430 will be interspersed between various search result cards 420. Among them, the search keyword may refer to the search term used when searching in a browser, including active search terms and passive search terms clicked based on recommendations. The search result page may refer to a page presented by a list of returned content results obtained through a search when using a browser. Specifically, a target entity in a knowledge graph is determined through the search keyword, and then the target entity features of the target entity and the candidate entity features of each candidate entity are determined. Then, the trained entity recommendation model is called to determine the estimated click-through rate of each candidate entity based on the target entity features and the candidate entity features, and each candidate entity is sorted and displayed in the browser display interface 400 according to the estimated click-through rate, such as Figure 4As shown, after the search keyword "person A" is entered in the browser display interface 400, a search result card 420 of the target entity "person A" matching the search keyword will be displayed, and below the search result card 420, a plurality of entity recommendation cards 430 "person B", "person C" and "person D" are displayed that recommend the target entity's interpersonal relationships. In other words, entities "person B", "person C" and "person D" are more strongly correlated with the target entity "person A". Based on the input target entity, other related candidate entities can be predicted as the next search keyword that the user may be interested in, thereby providing convenience for the user's next search.

[0121] It should be noted that, in addition to being applicable to the search results page scenario of a search engine, the model training method provided in the embodiments of the present disclosure can also be extended and applied to a variety of other scenarios, such as the product recommendation scenario of an e-commerce platform, or the video content recommendation scenario of a video platform, or the content recommendation scenario of a social platform, etc.

[0122] In one possible implementation, when calculating the first correlation score between two entity nodes, the knowledge graph embedding model can be called first to determine the head entity node features of the head entity node, the tail entity node features of the tail entity node, and the edge features of the edge relationship in any triple of the knowledge graph, and then the first correlation score between the head entity node and the tail entity node is determined based on the attention mechanism constructed based on the head entity node features, the tail entity node features, and the edge features.

[0123] Among them, the knowledge graph embedding model can synchronously map the head entity, tail entity and edge relationship in the knowledge graph into a low-dimensional vector space, and obtain the head entity node feature of the head entity, the tail entity node feature of the tail entity and the edge relationship feature of the edge relationship respectively. When calculating the first correlation score between two entity nodes, the attention mechanism can dynamically adjust the importance of each part according to the head entity node, the tail entity node and the edge relationship, so as to obtain a more accurate correlation score. This is because in the knowledge graph, the edge relationship between entity nodes not only represents the correlation between them, but also contains rich semantic information. For example, in social networks, the attention relationship between users may represent the similarity in terms of interest, influence, etc.; in academic knowledge graphs, the citation relationship between papers may represent the correlation in terms of research direction, influence, etc. Therefore, when calculating the correlation score between two entity nodes, the edge relationship and attention mechanism can be introduced to enrich the feature information, which can capture the complex semantic relationship between entity nodes and improve the accuracy of the correlation score.

[0124] Specifically, the head entity node feature, the tail entity node feature and the edge feature can be fused, wherein the three features can be directly concatenated to obtain the fused feature, or the three features can be weighted summed to obtain the fused feature. Then, an attention function (such as a dot product function, a bilinear function, etc.) can be called to calculate the fused feature to obtain the attention weight of each element in the fused feature, and then the fused feature is weighted summed using the attention weight to obtain the sum feature. The sum feature contains comprehensive information about the head entity node, the tail entity node and the edge relationship. The first correlation score between the two entity nodes can be represented by the sum feature, or the correlation score between the two entities can be calculated by extracting features from the sum feature and using similarity metrics such as cosine similarity, dot product, and bilinear function; or, the sum feature can be compared with a specific feature representation (such as the original node feature of the head entity or the tail entity), and the correlation score between the two entity nodes can be obtained by calculating the similarity between the two features.

[0125] Among them, the head entity node feature and the edge relationship feature can also be combined to obtain a joint feature. Then, the attention coefficients can be calculated for the joint feature and the tail entity node feature respectively. For example, the dot product attention mechanism can be used to calculate the attention coefficients of the joint feature and the tail entity node feature respectively. First, the first weight vector and the second weight vector are obtained, and the first weight vector and the joint feature are dot-product calculated. The dot product result is input into the activation function for calculation to obtain the first attention coefficient. Similarly, the tail entity node feature and the second weight vector are dot-product calculated, and the dot product result is input into the activation function for calculation to obtain the second attention coefficient. Then, the first attention coefficient and the second attention coefficient are used to weight the joint feature and the tail entity node feature respectively. Then, the similarity between the weighted joint feature and the tail entity node feature is calculated as the correlation score.

[0126] It is worth noting that the correlation scoring function can also be constructed by nonlinear transformation. Specifically, the head entity node features, the tail entity node features and the edge relationship features can be fused by splicing, weighted summation or a more complex fusion mechanism to obtain fused features, and then the fused features are calculated using a nonlinear activation function (such as the LeakyRelu function) to obtain the correlation score between the two entity nodes. Alternatively, a multi-layer perceptron can be used to perform multi-layer nonlinear transformation, in which each layer has a nonlinear activation function. The fused features are input into the multi-layer perceptron for processing. The output layer in the multi-layer perceptron can also be provided with a linear transformation matrix to transform the nonlinear activation result output by the previous layer to obtain the correlation score between the two entity nodes.

[0127] Specifically, when constructing an attention mechanism based on the head entity node feature, the tail entity node feature, and the edge feature, the trainable first linear transformation matrix and the second linear transformation matrix can be first obtained, and then the query feature is constructed based on the inner product between the first linear transformation matrix and the head entity node feature, and the key feature is constructed based on the inner product between the second linear transformation matrix and the tail entity node feature. Then, the inner product between the query feature, the key feature, and the edge feature is calculated, and the inner product result is normalized, that is, the first correlation score between the head entity node and the tail entity node is obtained. Therefore, the correlation score function constructed using the attention mechanism constructed based on the head entity node feature, the tail entity node feature, and the edge feature can refer to the following formula (1):

[0128]

[0129] in, They represent the head entity node feature, edge relationship feature, and tail entity node feature respectively, and W Q , W K Represent the first linear transformation matrix and the second linear transformation matrix respectively, d represents the dimension of the feature, represents the inner product operation of the three features, f(h, r, t) represents the relevance score, the head entity node feature is used as the query vector, the first linear transformation matrix is ​​used as the weight matrix of the head entity node feature, the first linear transformation matrix is ​​multiplied by the head entity node feature, and the query feature is constructed, and the tail entity node feature is used as the key vector, the second linear transformation matrix is ​​used as the weight matrix of the tail entity node feature, and the second linear transformation matrix is ​​multiplied by the tail entity node feature to construct the key feature. By using different linear transformation matrices to multiply the head entity node feature and the tail entity node feature, the order of the triple can be maintained, and the inner product results of the three are normalized by using the feature dimension, so as to obtain the relevance score between the two entity nodes. Therefore, the attention mechanism constructed by taking the head entity node feature as the query vector and the tail entity node feature as the key vector can effectively capture the relationship between the head entity and the tail entity, and calculate the degree of association between the head entity and the tail entity in the edge relationship. At the same time, the edge relationship feature can be introduced to further enrich the calculation process of the attention mechanism.

[0130] Specifically, please refer to Figure 5 , the head entity node feature can be the word vector matrix X1, the tail entity node feature can be the word vector matrix X2, the word vector matrix X1 and the first linear transformation matrix W Q Perform matrix multiplication to obtain the query feature Q, and multiply the word vector matrix X2 with the second linear transformation matrix W KThe matrices are multiplied to obtain the key feature K, and then the inner product calculations can be performed on the query feature Q, the edge relationship feature R and the key feature K in sequence to obtain the inner product result. That is, the inner product calculations are first performed on the query feature Q and the key feature K to obtain the initial inner product result. The initial inner product result can then be normalized based on the feature dimension to obtain an inner product weight coefficient, and then this inner product weight coefficient is multiplied by the edge relationship feature R to calculate the relevance score.

[0131] Specifically, the inner products of the query features, edge relationship features and key features can be calculated respectively to obtain three inner product results, namely, the inner product result of the query feature and the edge relationship feature, the inner product result of the edge relationship feature and the key feature, and the inner product result of the query feature and the key feature. These three inner product results are then fused by concatenation, weighted addition, multiplication, etc. to obtain a fusion result, and the fusion result is normalized to obtain a correlation score.

[0132] Among them, the first linear transformation matrix and the second linear transformation matrix can be parameters of the knowledge graph embedding model. During the training process, the model can update and optimize the two matrices through the back-propagation algorithm. Specifically, the model will calculate the gradient according to the loss function, and adjust the two matrices through optimization algorithms such as gradient descent to minimize the loss. After multiple iterations of training, the first linear transformation matrix and the second linear transformation matrix will gradually converge to a set of optimal values, so that the model can accurately calculate the correlation score between the two entity nodes. It is worth noting that during the model training process, the trainable parameters include not only the first linear transformation matrix and the second linear transformation matrix, but also the synchronously trained embedding table, that is, the features of each entity and edge relationship.

[0133] In one possible implementation, when training the knowledge graph embedding model, you can first use the triples in the knowledge graph as positive samples, construct negative samples by replacing the head entity node or the tail entity node in the triplet, call the knowledge graph embedding model to determine the third relevance score corresponding to the negative sample, and then determine the target loss based on the first relevance score and the third relevance score, and train the knowledge graph embedding model based on the target loss.

[0134] Specifically, the training samples of the knowledge graph embedding model are composed of triplets in the knowledge graph. Positive samples refer to triplets that actually exist in the knowledge graph, while negative samples are triples that do not exist in the knowledge graph and are constructed by randomly replacing the head entity node or the tail entity node in the triple. During the training process, for each triple, whether it is a positive sample or a negative sample, a relevance score needs to be calculated. Therefore, after obtaining the first relevance score of the positive sample, the knowledge graph embedding model is called again to calculate the third relevance score corresponding to the negative sample. Then, the first relevance score of the positive sample is compared with the third relevance score of the negative sample through the loss function, and a difference is calculated as the target loss. Then, through optimization algorithms such as gradient descent, the parameters of the model (including the first linear transformation matrix, the second linear transformation matrix, and the embedding vectors of entity nodes and relationships) are updated according to the gradient information of the loss function, so that the target loss is as small as possible, thereby improving the accuracy of the model in predicting positive and negative samples. It is worth noting that negative samples can be constructed by replacing the head and tail entities in the positive samples. Therefore, t positive and negative sample pairs can be constructed from each positive sample, where t is a multiple of negative sampling, which can be a positive integer greater than or equal to 1. In other words, by constructing multiple negative samples for each positive sample, the positive and negative sample data sets of the training samples can be balanced to avoid the skewness of the data set, which also helps the model to better generalize to data that has not appeared and enhance the model's discrimination ability.

[0135] Specifically, refer to Figure 6 , Figure 6A schematic diagram of the training and updating of the knowledge graph embedding model provided in the embodiment of the present disclosure, assuming that there is a positive sample triple S1 in the knowledge graph (head entity: person A, edge relationship: birthplace, tail entity: place B), by randomly replacing the head entity node or the tail entity node of the positive sample, a triple S2 (head entity: person D, edge relationship: birthplace, tail entity: place B) and a triple S3 (head entity: person A, edge relationship: birthplace, tail entity: place C) that do not actually exist in the knowledge graph are obtained, wherein the entities and edge relationships in each triple are represented as an embedding vector; firstly, the first relevance score of the positive sample is calculated, assuming that the vector of the head entity "person A" is vector hA, the vector of the edge relationship "birthplace" is vector hb, and the vector of the tail entity "place B" is vector hB, and the knowledge graph embedding model is called to calculate the relevance score of vector hA, vector hb and vector hB. Specifically, the relevance score function used in the knowledge graph embedding model can be obtained by calculating the head entity vector plus The distance between the relationship vector and the tail entity vector is obtained, that is, the relevance score of triple S1 is the absolute value of (hA+hb-hB). Assume that the calculated relevance score of triple S1 is 0.9, which means that the triple S1 of the positive sample is very close in the vector space. Then calculate the third relevance score of the two negative samples. Assume that the vector of the head entity "person D" is vector hD, and the vector of the tail entity "place C" is vector hC. Similarly, call the knowledge graph embedding model to respectively calculate the vector hD and vector hb of triple S2. The correlation score of triple S2 is the absolute value of (hD+hb-hB), and the correlation score of triple S3 is the absolute value of (hA+hb-hC). Assuming that the correlation score of triple S2 is 0.2 and the correlation score of triple S3 is 0.1, it means that the triplets of the two negative samples are relatively far apart in the vector space. Then, the margin ranking loss function can be used as the loss function. The specific formula can refer to the following formula (2):

[0136]

[0137] Among them, margin is a hyperparameter used to control the difference between the first relevance score f(h, r, t) of the positive sample and the third relevance score f(h′, r, t′) of the negative sample. Assuming the value of margin is 0.5, the target loss of triple S1 and triple S2 is The target loss of triple S1 and triple S3 This is because the first relevance score of the positive sample is much higher than the third relevance score of the two negative samples, and the difference exceeds the margin, so the target loss is 0, indicating that the knowledge graph embedding model's prediction on triple S1 is accurate. Then, the back-propagation algorithm can be used to calculate the gradient of the target loss with respect to the model parameters (i.e., the embedding vectors of entities and edge relationships, and the first linear transformation matrix and the second linear transformation matrix), and use the optimization algorithm to update the model parameters according to the gradient. The training is continuously iterated until the loss function converges, and in each iterative training, the model parameters are updated according to the new target loss, so that the model gradually learns the structure and semantic information in the knowledge graph.

[0138] In a possible implementation, the target loss can be obtained by using multiple loss functions to calculate multiple losses for the first correlation score and the third correlation score respectively, and then combining the multiple losses. Specifically, the first loss, the second loss and the third loss are determined according to the first correlation score and the third correlation score respectively, wherein the first loss is used to maximize the difference between the first correlation score and the third correlation score, the second loss is used to control the difference between the first correlation score and the third correlation score, and the third loss is used to maximize the first correlation score while minimizing the third correlation score; then, the first loss, the second loss and the third loss are weightedly summed to obtain the target loss.

[0139] Reference Figure 7 , Figure 7 is a schematic diagram of target loss calculation provided by an embodiment of the present disclosure. The first loss may refer to a loss value calculated using a first loss function for the first correlation score and the third correlation score. The first loss function is used to maximize the difference between the first correlation score of the positive sample and the third correlation score of the negative sample. For example, the first loss function may be a Bayesian Personalized Ranking Loss function. Specifically, the following formula (3) may be referred to:

[0140]

[0141] The first loss is obtained by calculating the absolute difference between the first correlation score f(h,r,t) of the positive sample and the third correlation score f(h′,r,t′) of the negative sample, and then using the sigmoid function to map the absolute difference to the range (0,1), that is, normalizing it.

[0142] It should be noted that the second loss may refer to the loss value calculated using the second loss function for the first correlation score and the third correlation score. The second loss function is used to control the difference between the first correlation score of the positive sample and the third correlation score of the negative sample. For example, the second loss function may be a boundary ranking loss function. Specifically, refer to the above formula (2) to control the absolute difference between the first correlation score and the third correlation score within the set parameter margin.

[0143] It should be noted that the third loss may refer to a loss value calculated using a third loss function for the first correlation score and the third correlation score. The third loss function is used to make the first correlation score of the positive sample as large as possible and the third correlation score of the negative sample as small as possible. For example, the third loss function may be a cross entropy loss function. Specifically, the following formula (4) may be referred to:

[0144]

[0145] Therefore, in order to make the third loss of the cross entropy loss function To achieve minimum, the first correlation score f(h, r, t) of the positive sample needs to be as close to 1 as possible, that is, as large as possible, and the third correlation score f(h′, r, t′) of the negative sample needs to be as close to 0 as possible, that is, as small as possible.

[0146] like Figure 7 As shown, after obtaining the first loss, the second loss and the third loss, the first loss, the second loss and the third loss can be weighted and summed to obtain the target loss. For details, refer to the following formula (5):

[0147]

[0148] Among them, a represents the first loss The first loss weight, b represents the second loss The second loss weight, c represents the third loss The first loss weight, the second loss weight and the third loss weight can be equal or unequal. For example, the first loss weight, the second loss weight and the third loss weight can all be 1 / 3, that is, It is expressed as the target loss obtained by averaging the first loss, the second loss, and the third loss; or, different loss weights can be assigned to each loss according to the specific task. At the same time, the loss weight of each loss function can be dynamically adjusted according to the gradient size and change rate of each loss function. For example, if the gradient of the first loss function is large, it means that the performance of the model in this aspect still has a lot of room for improvement. A larger loss weight can be assigned to the first loss function. Specifically, the first loss weight assigned to the first loss is 0.5, the second loss weight assigned to the second loss is 0.3, and the third loss weight assigned to the third loss is 0.2. Then, the target loss The resulting value is Therefore, by combining multiple loss functions, the knowledge graph embedding model can be trained from multiple aspects. It is worth noting that in each training process, the target loss function constructed by multiple loss functions can be used to find the partial derivative of the trainable parameters of the model to obtain the gradient information of each parameter, and update each parameter in the direction of gradient descent, so as to reflect the relevance information of the knowledge graph in the trainable parameters. It is worth noting that the loss weights of each loss can be continuously adjusted with the training process to balance the influence of different loss functions.

[0149] In a possible implementation, by traversing the knowledge graph, the entity node currently traversed is called the central entity node, that is, the entity node whose neighbor nodes need to be sampled. For the central entity node, the first neighbor node set of the central entity node is sampled in the knowledge graph, wherein the first neighbor node set includes the first neighbor node subset of the k-th level of the central entity node, and the first neighbor node subset includes the neighbor nodes sampled by the central entity node at the k-th level, where k is an integer, k≥1.

[0150] Reference Figure 8 , Figure 8 A schematic diagram of a first neighbor node set provided by an embodiment of the present disclosure, such as Figure 8As shown, the current traversal reaches node 1, that is, node 1 is the central entity node, and node 1 is directly connected to nodes 2 and 3, node 2 is connected to nodes 4 and 5, and node 3 is connected to nodes 6 and 7. Therefore, for the central entity node 1, its neighbor nodes can be organized into first neighbor node subsets of different levels according to the distance between itself and the central entity node 1. Specifically, the first-level neighbor nodes are sampled for the central entity node 1. The first-level first neighbor nodes can refer to the neighbor nodes that have an edge relationship directly with the central entity node 1. Therefore, the first-level first neighbor node subset obtained by sampling includes nodes 2 and 3, and the second-level neighbor nodes are the neighbor nodes connected to the first-level neighbor nodes of the central entity node 1 (excluding the central entity node 1 itself), that is, the second-level first neighbor node subset obtained by sampling includes nodes 4, 5, 6 and 7, and so on. The k-th level neighbor nodes are the neighbor nodes connected to the (k-1)-th level neighbor nodes of the central entity node 1. For each class, neighbor nodes are sampled based on the central entity node to obtain a first neighbor node subset of the corresponding class. This subset contains the neighbor nodes sampled by the central entity node in the current class, and these neighbor node subsets are combined to form the first neighbor node set of the central entity node. Therefore, through continuous iterative sampling, each class subset will aggregate the information of more distant neighbor nodes and update the embedded representation of the node. Through multi-stage sampling iterations, the model can capture more complex structures and semantic information in the knowledge graph.

[0151] It is worth noting that due to the large number of requests in the fine ranking stage, even dozens to hundreds of times that of the graph recall stage, if the knowledge graph is accessed once for each request to perform real-time neighbor node sampling, the computational overhead and latency will be too large. Therefore, each entity node in the knowledge graph can be pre-traversed offline, and neighbor node sampling can be performed as the central entity node. Each central entity node is associated with the corresponding first neighbor node set and written into the cache. When the sample entity node and sample neighbor node set of the sample entity need to be determined, they can be quickly read from the cache. Moreover, since the graph convolution radiation diffusion iteration is performed with each entity node as the center, after sampling the neighbor nodes of each class, the first neighbor node subset of each class can be written into the cache. In other words, the first neighbor node subset of each class can be called directly and quickly, which greatly reduces the computational overhead of neighbor feature aggregation.

[0152] It should be noted that when the first neighbor node set of each central entity node is written into the cache, the node code corresponding to each entity node in the knowledge graph is written. Specifically, the node code of the central entity node is used as the keyword Key, and the node code of the central entity node and each neighbor node in the first neighbor node set is used as the value Value. A list consisting of key-value pairs is written into the cache, so that when the entity node and the corresponding first neighbor node set need to be called, the node code of the entity node can be used as the keyword Key for query, and the value Value corresponding to the entity node, that is, the node code of each neighbor node in the first neighbor node set, can be quickly determined. The corresponding node data can then be read from the knowledge graph through these node codes, without loading the full knowledge graph, thereby speeding up data acquisition.

[0153] It is worth noting that when writing the first neighbor node set into the cache, the writing order of the node codes of each node will be in ascending order according to the first neighbor node subsets of each class, such as giving priority to writing the first neighbor node subset of the first class, the first neighbor node subset of the second class, the first neighbor node subset of the third class, and so on. In addition, when writing the first neighbor node subsets of two adjacent classes, a subset mark can be added between the first neighbor node subsets of the two adjacent classes to distinguish the first neighbor node subsets of different classes; or, the first-order neighbor nodes of each entity node can be written in groups. Similarly, a grouping mark can be added between each group of first-order neighbor nodes for distinction. For example, the first-order neighbor nodes of node 1 include nodes 2 and 3, and node 2 has no first-order neighbor nodes (i.e., leaf nodes). The first-order neighbor nodes of node 3 include node 4. When writing nodes 1, 2, 3, and 4 into the cache, a grouping mark (such as blank space) can be added between nodes 2 and 3 for distinction, thereby avoiding mistakenly considering nodes 3 and 4 as first-order neighbor nodes of node 2 when reading the cache. Therefore, by writing the first neighbor node set in the corresponding order and adding marks to distinguish them during the process of writing the cache, it is possible to effectively avoid erroneous reading of node relationships, and thus ensure that the subgraph style of the first neighbor node set in the knowledge graph can be restored without any doubt through the data in the cache.

[0154] In one possible implementation, for all neighbor nodes of the kth class of the central entity node, the trained knowledge graph embedding model is called to determine the fourth correlation score between the central entity node and each neighbor node, all neighbor nodes of the kth class are sorted according to the size of the fourth correlation score, and the first neighbor node subset of the kth class is sampled in the sorting result according to the first ranking threshold; and then the first neighbor node subsets of the kth class are merged to obtain the first neighbor node set of the central entity node.

[0155] Among them, the sorting method for all neighbor nodes of each class can be that all neighbor nodes in each class are sorted in descending order from high to low according to the size of the fourth correlation score, or that all neighbor nodes in each class are sorted in ascending order from low to high according to the size of the fourth correlation score; for the sorting result, sampling is performed according to a pre-set first ranking threshold, and some neighbor nodes are screened out from multiple neighbor nodes of the same class in the sorting result to form a first neighbor node subset of the corresponding class; the first ranking threshold can be equal or unequal in each class. Specifically, the number of nodes required in the first neighbor node subset of each class needs to be equal, then the first ranking threshold is equal in each class. For example, the first ranking threshold of each class is 5. Therefore, the number of nodes in the first neighbor node subset of each class is 5, that is, the first 5 neighbor nodes in the sorting result constitute the first neighbor node subset of the class; or, the first ranking threshold can be determined according to the ratio of the number of neighbor nodes of the current class. It is determined that if the numbers of neighbor node subsets of two classes are different, the first ranking thresholds of the two classes are also unequal. For example, there are 5 neighbor nodes in the first class, and the first ranking threshold is 40% of the number of neighbor nodes, that is, the first 2 neighbor nodes in the sorting result constitute the first neighbor node subset of the first class, and the number of neighbor nodes in the second class is 10, and the first ranking threshold is 40% of the number of neighbor nodes, that is, the first 4 neighbor nodes in the sorting result constitute the first neighbor node subset of the second class, and the number of neighbor nodes in the third class is 20, and the first ranking threshold is 30% of the number of neighbor nodes, that is, the first 6 neighbor nodes in the sorting result constitute the first neighbor node subset of the third class; or, the first ranking threshold can increase or decrease continuously with the continuous increase of the class, for example, the first ranking threshold in the first stage is 10, the first ranking threshold in the second class is 8, and the first ranking threshold in the third class is 6.

[0156] Reference Fig. 9 , Fig. 9A schematic diagram of multi-level first neighbor node subset sampling provided by an embodiment of the present disclosure, specifically, node 1 is taken as the central entity node, wherein node 1 is connected to node 2, node 3, node 4, node 5, and node 6 respectively, node 2 is connected to node 7, node 8, and node 16 respectively, node 3 is connected to node 9 and node 15 respectively, node 4 is connected to node 10 and node 11 respectively, node 5 is connected to node 12 and node 13 respectively, and node 6 is connected to node 14; for all first-level neighbor nodes of the central entity node, they can be arranged in descending order from high to low according to the fourth correlation score, and the first first ranking threshold neighbor nodes in the sorting result are taken to form the first-level first neighbor node subset; for the central entity node, there are 5 neighbor nodes in the first level, assuming that the fourth correlation scores of these 5 neighbor nodes are arranged in descending order from high to low, respectively, node 3, node 4, node 2, node 5, and node 6, and the first ranking threshold is 3, therefore, node 3, node 4, and node 2 are taken to form the first-level first neighbor node subset;The sampling of the second-level neighbor nodes for the central entity node may refer to traversing all nodes in the first-level neighbor node subset of the central entity node, arranging the first-level neighbor node subsets of these nodes in descending order according to the fourth correlation score, and taking the first first ranking threshold neighbor nodes in the sorting result to form the first-level neighbor node subset of the second level. Therefore, traverse nodes 3, 4, and 2, and sort all neighbor nodes of the first-level neighbor node subsets of nodes 3, 4, and 2. The first-level neighbor node subset of node 3 includes node 9, the first-level neighbor node subset of node 4 includes nodes 10 and 11, and the first-level neighbor node subset of node 2 includes nodes 7 and 8. It is worth noting that node 15 belongs to the first-level neighbor node of node 3, but node 15 is not ranked in the first-level first neighbor node of node 3. In the sorting result, node 16 does not enter the first ranking threshold, so it does not belong to the first neighbor node subset of node 3 in the first class. Similarly, node 16 belongs to the first neighbor node of node 2 in the first class, but node 16 does not enter the first ranking threshold in the sorting result of the first neighbor node of node 2 in the first class, so it does not belong to the first neighbor node subset of node 2 in the first class. That is to say, for node 1 of the central entity node, there are 5 first neighbor nodes of the second class. According to the fourth correlation score of these 5 neighbor nodes, they are arranged in descending order from high to low, namely node 10, node 8, node 7, node 9, and node 11. The first ranking threshold is 4. Therefore, node 10, node 8, node 7, and node 9 are taken to form the first neighbor node subset of the second class. By analogy, the first neighbor node subsets of k classes of the central entity node can be obtained, and then the first neighbor node subsets of each class are merged to obtain the first neighbor node set of the central entity node. It should be noted that since the first ranking threshold can be adjusted and set according to the actual task and specific scenario, the size of the first neighbor node set of each central entity node can vary. The larger the size of the first neighbor node set, the larger the amount of data, which helps to improve the output accuracy of the knowledge graph embedding model. The smaller the size of the first neighbor node set, the smaller the amount of data, which helps to reduce the computing overhead, thereby achieving a flexible trade-off between model accuracy and computing cost. ;

[0157] In one possible implementation, for each online request, the central entity node and the corresponding first neighbor node set of the matched sample entity in the knowledge graph can be read from the cache, and then the first neighbor node subset of the kth level in the first neighbor node set is sampled again according to the second ranking threshold to obtain the second neighbor node subset of the kth level; the second neighbor node subsets of the kth level are merged to obtain the sample neighbor node set of the central entity node.

[0158] Among them, the second ranking threshold is smaller than the first ranking threshold, so the second neighbor node subset of each class is smaller than the first neighbor node subset of the corresponding class, that is, a small-scale dynamic random sampling is performed on the first neighbor node subset of each class to obtain a smaller neighbor node subset. Fig.10 , Fig.10 A schematic diagram of secondary sampling of a neighbor node set provided in an embodiment of the present disclosure, with Fig. 9 Taking the first neighbor node set of node 1 shown as an example, node 1 is the sample entity node corresponding to the sample entity, and the first neighbor node set of node 1 includes at least the first neighbor node subset of the first class and the first neighbor node subset of the second class, wherein the nodes of the first neighbor node subset of the first class are sequentially sorted as node 3, node 4, and node 2, the first ranking threshold of the first class is 3, and the second ranking threshold can be 2. Therefore, by performing secondary sampling on the first neighbor node subset of the first class, it is possible to obtain the second neighbor node subset of the first class consisting of node 3 and node 4; the nodes of the first neighbor node subset of the second class are sequentially sorted as node 10, node 8, node 7, node 9, and node 11, the first ranking threshold of the second class is 4, and the second ranking threshold can be 3. Therefore, by performing secondary sampling on the first neighbor node subset of the second class, it is possible to obtain the second neighbor node subset of the second class consisting of node 10, node 8, and node 7. By analogy, the second neighbor node subsets of each class of node 1 can be obtained.

[0159] In addition, when the first neighbor node subset of the kth class is resampled, when k is greater than 1, the first neighbor node subset of the kth class can be updated based on the second neighbor node subset of the k-1th class, and then the updated first neighbor node subset of the kth class is resampled. Specifically, refer to Fig.11 , Fig.11 is a schematic diagram of secondary sampling of a neighbor node set provided by another embodiment of the present disclosure. Fig.10 Taking the secondary sampling result shown as an example, the second neighbor node subset of the first level does not include node 2. Therefore, the first neighbor node subset of node 2 can be removed from the first neighbor node set of the subsequent level, that is, node 7 is moved out of the first neighbor node subset of the second level in the secondary sampling stage, so that when the first neighbor node subset of the second level is secondary sampled, the second neighbor node subset of the second level consisting of nodes 10 and 9 can be obtained.

[0160] Specifically, for each online request, the second ranking threshold may be different, so as to ensure that the neighbor node subset used for each request changes dynamically, thereby ensuring that the features of each training are diverse and avoiding overfitting.

[0161] It is worth noting that the first-order neighbor node set of the sample entity node can be the first neighbor node set or the second neighbor node set obtained through secondary sampling.

[0162] In a possible implementation, the target node features of the sample entity can be subjected to graph convolution radiation diffusion iteration. Specifically, at the first level, the first-order attention features can be fused with the sample node features to obtain the target node features of the sample entity at the first level, and the first-order neighbor node features are updated based on the second-order neighbor node features of the second-order neighbor nodes of the sample entity node, that is, the first-order neighbor node features of the first-level neighbor nodes are updated based on the second-order neighbor node features of the second-level neighbor nodes of the sample entity node; and when k>1, the first-order neighbor node features updated based on the k-1th level are combined with the k-1th level. The target node features obtained at the kth level are determined, the fifth correlation score between the sample entity node and each first-order neighbor node is determined, the first-order neighbor node features updated at the k-1th level are aggregated based on the attention mechanism constructed by the fifth correlation score to obtain the k-order attention features, the k-order attention features are fused with the target node features obtained at the k-1th level to obtain the target node features of the sample entity at the k-th level, and the n-order neighbor node features of the n-order neighbor nodes of the sample entity node are updated based on the n+1-order neighbor node features of the n+1-order neighbor nodes of the sample entity node, where n is an integer, n∈[1,k].

[0163] refer to Fig.12 , Fig.12 Schematic diagram of target node feature update iteration provided in the embodiment of the present disclosure. In the first stage, the sample entity node is node 1, the first-order neighbor nodes of node 1 are node 2 and node 3, the first-order neighbor nodes of node 2 are node 4 and node 5, the first-order neighbor nodes of node 3 are node 6 and node 7, and the second-order neighbor nodes of node 1 are node 4, node 5, node 6 and node 7; the first-order attention feature and H1 sample node feature are used (i.e. the initialized node features) are merged to update the target node features of the sample entity node Among them, the first-order attention feature H1 is based on the initial first-order neighbor node feature of the sample entity node Aggregation, such as Fig.12 As shown, the target node feature of node 1 It uses the first-order neighbor node features of node 2 and node 3 Updated, the target node features are updated Afterwards, the second-order neighbor node features of the second-order neighbor nodes can be used First-order neighbor node characteristics of first-order neighbor nodes Update to get new first-order neighbor node features Specifically, the second-order neighbor node features of node 4 and node 5 are The first-order neighbor node features of node 2 of the first-order neighbor node can be Update the second-order neighbor node features of node 6 and node 7 of the second-order neighbor node The first-order neighbor node features of node 3 can be to update.

[0164] In the second level, the target node features of the sample entity in the second level It is through the second-order attention feature H2 and the first-order target node feature The second-order attention feature H2 is obtained by aggregating the first-order neighbor node features updated in the first stage Obtained, such as Fig.12 As shown, that is, the target node feature of node 1 It uses the first-order neighbor node features updated by nodes 2 and 3 Updated, specifically, based on the first-order neighbor node features updated in the first stage The knowledge graph embedding model is called to determine the fifth correlation score between the sample entity node and each first-order neighbor node based on the target node features obtained in the first stage, and then the attention mechanism constructed based on the fifth correlation score aggregates the first-order neighbor node features updated in the first stage. Get the secondary attention feature H2 and update the target node feature Afterwards, the second-order neighbor node features of the second-order neighbor nodes can be used First-order neighbor node characteristics of first-order neighbor nodes Update to get new first-order neighbor node features Similarly, the third-order neighbor node features of the third-order neighbor node can be used Second-order neighbor node characteristics of second-order neighbor nodes Update to get new second-order neighbor node features And so on. The target node features can be calculated by referring to the following joint equations (6), (7), and (8):

[0165]

[0166] Among them, f(u,r,u1) represents the fifth correlation score between the sample entity node u and the current first-order neighbor node u1. The fifth correlation score f(u,r,u1) between the sample entity node u and the current first-order neighbor node u1 under the edge relationship r is normalized to obtain the attention coefficient π(u,r,u1), and then the attention coefficient π(u,r,u1) is used to analyze the first-order neighbor node features of each first-order neighbor node. Perform weighted summation to aggregate the first-order neighbor node features and obtain the k-order attention feature H k , and then use the k-order attention feature H k The target node features of the previous level of the sample entity node Fusion is performed to update the target node features of the current class Specifically, we first use the k-order attention feature H k The target node features of the previous level of the sample entity node The addition is performed, and the addition result is multiplied by the learnable first linear transformation parameter matrix W1 to obtain the first product result, and then the first product result is calculated using the nonlinear activation function to obtain the first activation result, and then the k-order attention feature H is used. k The target node features of the previous level of the sample entity node Multiply, multiply the product result with the learnable second linear transformation parameter matrix W2 to obtain the second product result, then use the nonlinear activation function to calculate the second product result to obtain the second activation result, and add the first activation result to the second activation result to obtain the target node feature of the current class Among them, the graph neural network can be used to analyze the first-order neighbor node features Aggregation is performed, and the learnable first linear transformation parameter matrix W1 and the second linear transformation parameter matrix W2 can be parameters in the graph neural network. Therefore, the node features of the central entity node and the node features of the neighboring nodes are synchronously iterated and updated in each level. After k levels of iteration, the set of target node features of each level of the central entity node can be obtained.

[0167] It is worth noting that when the first-order neighbor node features are updated using the second-order neighbor node features of the second-order neighbor nodes of the sample entity node, the sixth correlation score between the second-order neighbor nodes of the sample entity node and each first-order neighbor node is first determined; then, the second-order neighbor node features of the second-order neighbor nodes are aggregated based on the attention mechanism constructed by the sixth correlation score to obtain the second-order attention feature; then, the second-order attention feature is fused with the first-order neighbor node features to obtain the updated first-order neighbor node features.

[0168] It should be noted that when the node feature of a certain entity node is updated, the k-order neighbor nodes including the first-order neighbor nodes and second-order neighbor nodes of the sample entity node can use the entity node to be updated as the central entity node and use the first-order neighbor nodes of the entity node to be updated for updating; specifically, Fig.12 Taking the update of the first-order neighbor node node 2 shown in as an example, at this time, node 2 can be used as the new central entity node, and the first-order neighbor nodes node 4 and node 5 of node 2 can be used to update it, which is also equivalent to the first-order neighbor node node 2 of the sample entity node 1 being updated using the second-order neighbor nodes node 4 and node 5. First, the knowledge graph embedding model is called to determine the sixth correlation score between node 2 and nodes 4 and 5, and then the two sixth correlation scores are normalized to obtain the attention coefficients corresponding to nodes 4 and 5. The attention coefficients are then used to perform weighted summation on the second-order neighbor node features of nodes 4 and 5 to obtain the first-order attention feature (relative to the sample entity node, it is the second-order attention feature). The first-order attention feature is then fused with the node feature of node 2 (relative to the sample entity node, it is the first-order neighbor node feature) to obtain the updated target node feature of node 2 (relative to the sample entity node, it is the updated first-order neighbor node feature). The method of fusing the first-order attention feature with the node feature can refer to the fusion method provided in the above embodiment, which will not be repeated here.

[0169] In one possible implementation, after obtaining the target node features of the sample entity, when predicting the estimated click-through rate of the sample entity, the query semantic features associated with the sample entity can be obtained, and the query semantic features can be spliced ​​with the target node features to obtain the spliced ​​features; then the entity recommendation model is called to determine the estimated click-through rate of the sample entity based on the spliced ​​features.

[0170] Among them, the query semantic features associated with the sample entity may refer to the input data used in the related technology when estimating the click rate of the sample entity by using the entity recommendation model. The query semantic features may include query term semantic features, candidate entity recommendation item semantic features and cross-features between the two. The query term semantic features refer to the characteristics or attributes of the input query term at the semantic level, which are used to understand the query intent and needs; the candidate entity recommendation item semantic features refer to the characteristics or attributes of the candidate entity used for recommendation at the semantic level, which are used to evaluate the degree of match between the candidate entity and the query intent; the cross-features may refer to the new features obtained by combining or merging the query term semantic features with the candidate entity recommendation item semantic features, which are a combination of the query term and the candidate entity recommendation item semantic features. The semantic information of the recommended items can fully reflect the relationship between the user query and the candidate entity recommendation items. However, since the query semantic features do not contain much information, the node features of the candidate entity recommendation items on the knowledge graph are introduced. After multi-order neighbor node feature fusion, the target node features are updated, and then the target node features are spliced ​​with the query semantic features to obtain the spliced ​​features. The spliced ​​features are then input into the entity recommendation model to estimate the click rate of the sample entity. Therefore, by introducing the knowledge graph to enrich the amount of information obtained by the entity recommendation model and realizing two-stage training, the computational complexity and prediction accuracy of the entity recommendation model can be effectively balanced, thereby improving the relevance between the final recommended entity and the specific query request.

[0171] Specifically, after obtaining the estimated click-through rate of the sample entity, the cross-entropy loss can be calculated based on the actual click-through rate actually fed back by the browser, the gradients of each model parameter in the entity recommendation model can be calculated through back propagation, and stochastic gradient descent can be used to update the trainable parameters of the model, as well as the characteristics of each entity node and edge relationship in the knowledge graph.

[0172] In summary, the embodiments of the present disclosure provide a model training method, which introduces the features of the knowledge graph in the entity recommendation model in the fine ranking stage at a low cost and high efficiency to help solve the problem of feature sparsity faced in entity recommendation. This is different from the way of introducing the knowledge graph in the recall stage of the recommendation system. In the recall stage, only one request is needed for each user to generate a candidate entity recommendation set, and the request volume is at the user level. However, in the fine ranking stage, an estimated click-through rate calculation is required for each candidate entity in the candidate entity recommendation set of each user. As a result, the number of requests for introducing the knowledge graph in the fine ranking stage is usually tens to hundreds of times that of the knowledge graph introduced in the recall stage. In this case, it is difficult for the model in the fine ranking stage to efficiently extract semantic relevance features from large-scale knowledge graph data at a low cost. The related technology uses graph neural networks to directly extract knowledge graph features from the full knowledge graph in the recall stage, which has a high computational complexity. Therefore, it can only be limited to small-scale knowledge graphs or used in the recall stage with a low request volume. In order to achieve a trade-off between cost and performance, the disclosed embodiment constructs a full knowledge graph pre-training stage and a neighbor node sampling and adjustment stage, and uses the breadth and depth of the knowledge graph for training at different stages. Among them, the full knowledge graph pre-training stage refers to calling the knowledge graph embedding model to determine the first correlation score between any two entity nodes in the knowledge graph, and training the knowledge graph embedding model based on the first correlation score; and the neighbor node sampling and adjustment stage refers to first obtaining the sample entity node corresponding to the sample entity in the knowledge graph and the sample neighbor node set obtained by sampling the sample entity node in the knowledge graph, calling the trained knowledge graph embedding model to determine the sample node features of the sample entity node, the first-order neighbor node features of each first-order neighbor node in the sample neighbor node set, and the second correlation score between the sample entity node and each first-order neighbor node; then based on the attention mechanism constructed by the second correlation score, the first-order neighbor node features are aggregated to obtain the first-order attention features, the first-order attention features are fused with the sample node features to obtain the target node features of the sample entity, and then the entity recommendation model is called to determine the estimated click-through rate of the sample entity based on the target node features, and the entity recommendation model is trained based on the estimated click-through rate.

[0173] Reference Fig.13 , Fig.13 A schematic diagram of a model training architecture provided in an embodiment of the present disclosure, such as Fig.13As shown in the figure, the full knowledge graph pre-training stage and the neighbor node sampling and adjustment stage can be carried out independently, but both stages rely on the same knowledge graph and complement each other, thereby optimizing the entity recommendation model through continuous iteration. Among them, the full knowledge graph pre-training stage includes the triple sample construction process and the knowledge graph embedding model training process, while the neighbor node sampling and adjustment stage includes the neighbor node sampling process and the node feature training process. Specifically, in the pre-training stage of the full knowledge graph, the full knowledge graph data is split into triplets that are easy to train, and positive and negative sample pairs are constructed by sampling and replacement. A lightweight knowledge graph embedding model is used, and the correlation score of the triplet is used as the learning goal. The embedding vectors of all entities and edge relationships in the knowledge graph are trained in a self-supervised manner and saved in the embedding table. This stage focuses on improving the breadth of knowledge graph data training coverage. Therefore, a simple knowledge graph embedding model is used for training, which can reduce computational overhead while quickly learning the generalization features of the full knowledge graph data. Since the knowledge graph is large in scale and relatively stable in the short term, the update frequency of the full knowledge graph pre-training stage is set low to avoid the cost overhead caused by frequent updates. In the neighbor node sampling and adjustment stage, in order to ensure the accuracy of entity recommendation, the training frequency of the entity recommendation model is high. Therefore, a large range of neighbor nodes are first sampled offline with each entity node as the center of the entity node. The set (i.e., the first neighbor node set) is collected and written into the cache. Then, for each entity node, the corresponding neighbor node set is matched and read from the cache online, and a small range of neighbor node sets (i.e., the second neighbor node set) is further dynamically sampled. The attention mechanism based on the relevance score is used to aggregate the neighbor nodes. The aggregated neighbor node features are fused with the sample entity node features to update the target node features of the sample entity, thereby eliminating the need to use the full data of the knowledge graph. In addition, each iteration only updates the sample entity node features, the neighbor node features in the neighbor node set, and the corresponding edge relationship features, which can effectively reduce the computational overhead. The target node features are then concatenated with the original query semantic features and input into the entity recommendation model to obtain the estimated click-through rate of the sample entity. The estimated click-through rate is then used to train the entity recommendation model, and the embedding vectors of each entity and edge relationship (i.e., the head entity node features, the edge relationship features, and the tail entity node features) are adjusted. This stage focuses on improving the depth of knowledge graph feature learning. Therefore, a more complex graph neural model is required to aggregate the features of each neighbor node. However, the number of nodes can be controlled by two-step sampling of offline cache sampling of some neighbor nodes and online secondary sampling of some neighbor nodes, thereby reducing the computational complexity of the graph neural network.

[0174] Reference Fig.14 , Fig.15 and Fig.16 , Figures 14 to 16These are all schematic diagrams showing the effects of the application model training methods provided by multiple embodiments of the present disclosure. For example, Fig.14 taking the search keyword as "Commentator A's commentary on the game" as an example, Fig.14 the left sub-graph in Fig.14 shows a schematic diagram of the search results provided by the browser after entering the search keyword before applying the model training method provided by the embodiments of the present disclosure, that is, the control group before application. Fig.14 The three entity recommendation items "Person B", "Person C" and "Person D" shown in the left sub-graph are retired athletes of the "game" commented by "Commentator A", while Fig.14 the right sub-graph in Fig.14 shows a schematic diagram of the search results provided by the browser after entering the search keyword after applying the model training method provided by the embodiments of the present disclosure, that is, the experimental group after application.

[0175] For example, Fig.15 taking the search keyword as "Read the full text of Novel A" as an example, Fig.15 the left sub-graph in Fig.15 shows that the control group before application provides three entity recommendation items "Novel A", "Novel B" and "Novel C". Among the three entity recommendation items, the entity recommendation items "Novel A" and "Novel C" contain image data of the novel cover, while Fig.15 the right sub-graph in

[0176] For example, Fig.16 taking the search keyword as "The meaning of simplicity" as an example, Fig.16 the left sub-graph in Fig.15The right sub - figure on the right shows that the experimental group after application also provides three entity recommendation items for word explanations, namely "indifferent", "the highest good is like water", and "a person of virtue will reach far", obviously, the relevance of the entity recommendation item "a person of virtue will reach far" to the search keyword "the meaning of indifferent" is higher than the relevance of the entity recommendation item "God rewards the diligent" to the search keyword "the meaning of indifferent", that is, Fig.16 the recommendation effect provided by the control group before application shown in Fig.16 is lower than the recommendation effect provided by the experimental group after application.

[0177] The following uses a specific example to elaborate in detail on the model training method provided by the embodiments of the present disclosure.

[0178] Refer to Fig.17 as shown. Fig.17 is a specific flowchart of the model training method provided by a specific example. In Fig.17 this example, the model training method may include the following steps 1701 to step 1715.

[0179] Step 1701: Invoke the knowledge graph embedding model to determine the head - entity - node feature of the head - entity node, the tail - entity - node feature of the tail - entity node, and the edge feature of the connection relationship in any triple of the knowledge graph.

[0180] Step 1702: Determine the first correlation score between the head - entity node and the tail - entity node based on the attention mechanism constructed based on the head - entity - node feature, the tail - entity - node feature, and the edge feature.

[0181] Step 1703: Use the triple in the knowledge graph as a positive sample, construct a negative sample by replacing the head - entity node or the tail - entity node in the triple, and invoke the knowledge graph embedding model to determine the third correlation score corresponding to the negative sample.

[0182] Step 1704: Determine the first loss, the second loss, and the third loss according to the first correlation score and the third correlation score respectively, perform weighted summation on the first loss, the second loss, and the third loss to obtain the target loss, and train the knowledge graph embedding model based on the target loss.

[0183] In this step, the first loss is used to maximize the difference between the first correlation score and the third correlation score, the second loss is used to control the magnitude of the difference between the first correlation score and the third correlation score, and the third loss is used to maximize the first correlation score while minimizing the third correlation score.

[0184] Step 1705: Traverse the knowledge graph. For the currently traversed central - entity node, sample the first neighbor - node set of the central - entity node in the knowledge graph.

[0185] In this step, the first neighbor node set includes a first neighbor node subset of the kth level of the central entity node, and the first neighbor node subset includes neighbor nodes sampled from the central entity node at the kth level, where k is an integer and k≥1.

[0186] Step 1706: associate each central entity node with the corresponding first neighbor node set and write them into the cache.

[0187] Step 1707: Match the central entity node corresponding to the sample entity in the knowledge graph and the corresponding first neighbor node set from the cache.

[0188] Step 1708: for the first neighbor node subset of the kth level in the first neighbor node set, sample again to obtain a second neighbor node subset of the kth level.

[0189] Step 1709: Merge the second neighbor node subsets of the k levels to obtain a sample neighbor node set of the central entity node.

[0190] Step 1710: Call the trained knowledge graph embedding model to determine the sample node features of the sample entity node, the first-order neighbor node features of each first-order neighbor node in the sample neighbor node set, and the second correlation score between the sample entity node and each first-order neighbor node.

[0191] Step 1711: Normalize the second relevance score to obtain an attention weight.

[0192] Step 1712: Perform weighted summation on the first-order neighbor node features according to the attention weights to aggregate the first-order neighbor node features to obtain the first-order attention features.

[0193] Step 1713: Fuse the first-order attention features with the sample node features to obtain the target node features of the sample entity.

[0194] Step 1714: Obtain query semantic features associated with the sample entity, and concatenate the query semantic features with the target node features to obtain concatenated features.

[0195] Step 1715: Call the entity recommendation model to determine the estimated click rate of the sample entity based on the concatenated features.

[0196] Based on this, by calling the knowledge graph embedding model to determine the first correlation score between any two entity nodes in the knowledge graph, and training the knowledge graph embedding model based on the first correlation score, it is possible to more accurately capture the structural information of the knowledge graph and the semantic association information between entities by introducing the first correlation score. On this basis, by obtaining the sample entity nodes corresponding to the sample entities in the knowledge graph and the sample neighbor node set obtained by sampling the sample entity nodes in the knowledge graph, the sampling method can be used to reduce the computational complexity, so that when calling the trained knowledge graph embedding model to determine the sample node features of the sample entity nodes, the first-order neighbor node features of each first-order neighbor node in the sample neighbor node set, and the sample entity nodes The second correlation score between the point and each first-order neighbor node is obtained by aggregating the first-order neighbor node features based on the attention mechanism constructed by the second correlation score. The first-order attention feature is obtained. When the first-order attention feature is fused with the sample node feature, the target node feature of the sample entity can be efficiently obtained, and then the entity recommendation model is called to determine the estimated click-through rate of the sample entity based on the target node feature, and the entity recommendation model is trained based on the estimated click-through rate. The disclosed embodiment can introduce the knowledge graph when training the entity recommendation model to enrich the amount of information obtained by the entity recommendation model, and realize two-stage training, effectively balancing the computational complexity and the prediction accuracy of the entity recommendation model, thereby improving the correlation between the final recommended entity and the specific query request.

[0197] In one possible implementation, the knowledge graph embedding model and entity recommendation model trained using the model training method provided by the embodiments of the present disclosure can be applied in various search scenarios to improve the relevance between entity recommendation items and query requests. For example, when the server receives a query request from a terminal, it initially extracts multiple query entities from the query request, and then determines the query entity nodes corresponding to the query entities in the knowledge graph, and obtains a query neighbor node set by sampling the query entity nodes in the knowledge graph. Then, the trained knowledge graph embedding model is called to determine the query node features of the query entity node, the first-order neighbor node features of each first-order neighbor node in the query neighbor node set, and the correlation score between the query entity node and each first-order neighbor node. Then, the first-order neighbor node features are aggregated based on the attention mechanism constructed by the correlation score to obtain the first-order attention features, and the first-order attention features are fused with the query node features to obtain the target node features of each query entity. Then, the entity recommendation model is called to determine the estimated click-through rate of each query entity based on the target node features, and then the query entities are sorted according to the size of the estimated click-through rate, and the top-ranked query entities are returned to the terminal as the entity recommendation items for this query request for recommendation. In the actual search scenario, the processing process of the knowledge graph embedding model and the entity recommendation model is similar to the training process, which will not be repeated here.

[0198] It is to be understood that, although the steps in the above-mentioned various flow charts are shown in sequence according to the indication of the arrows, these steps are not necessarily performed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in the present embodiment, the execution of these steps does not have a strict order restriction, and these steps can be performed in other orders. Moreover, at least a portion of the steps in the above-mentioned flow charts can include a plurality of steps or a plurality of stages, and these steps or stages are not necessarily performed at the same time, but can be performed at different times, and the execution order of these steps or stages is not necessarily performed in sequence, but can be performed in turn or alternately with at least a portion of the steps or stages in other steps or other steps.

[0199] Reference Fig.18 , Fig.18 An optional structural diagram of a model training device provided in an embodiment of the present disclosure, the model training device 1800 includes:

[0200] A first training module 1810 is used to call the knowledge graph embedding model to determine a first correlation score between any two entity nodes in the knowledge graph, and train the knowledge graph embedding model based on the first correlation score;

[0201] Sampling module 1820, used to obtain the sample entity node corresponding to the sample entity in the knowledge graph and the sample neighbor node set obtained by sampling the sample entity node in the knowledge graph, and call the trained knowledge graph embedding model to determine the sample node features of the sample entity node, the first-order neighbor node features of each first-order neighbor node in the sample neighbor node set, and the second correlation score between the sample entity node and each first-order neighbor node;

[0202] A fusion module 1830 is used to aggregate first-order neighbor node features based on the attention mechanism constructed by the second relevance score to obtain first-order attention features, and fuse the first-order attention features with the sample node features to obtain target node features of the sample entity;

[0203] The second training module 1840 is used to call the entity recommendation model to determine the estimated click rate of the sample entity based on the target node characteristics, and train the entity recommendation model based on the estimated click rate.

[0204] In a possible implementation, the first training module 1810 is further used to:

[0205] Call the knowledge graph embedding model to determine the head entity node features of the head entity node, the tail entity node features of the tail entity node, and the edge features of the edge relationship in any triple of the knowledge graph;

[0206] An attention mechanism constructed based on the head entity node feature, the tail entity node feature and the edge feature determines the first correlation score between the head entity node and the tail entity node.

[0207] In a possible implementation, the first training module 1810 is further used to:

[0208] Obtain a trainable first linear transformation matrix and a second linear transformation matrix;

[0209] Constructing a query feature based on the inner product between the first linear transformation matrix and the head entity node feature, and constructing a key feature based on the inner product between the second linear transformation matrix and the tail entity node feature;

[0210] The inner products among the query features, key features, and edge features are normalized to obtain the first correlation score between the head entity node and the tail entity node.

[0211] In a possible implementation, the first training module 1810 is further used to:

[0212] Taking the triples in the knowledge graph as positive samples, construct negative samples by replacing the head entity node or the tail entity node in the triples, and call the knowledge graph embedding model to determine the third relevance score corresponding to the negative samples;

[0213] The target loss is determined according to the first relevance score and the third relevance score, and the knowledge graph embedding model is trained based on the target loss.

[0214] In a possible implementation, the first training module 1810 is further used to:

[0215] Determine a first loss, a second loss, and a third loss according to the first correlation score and the third correlation score, respectively, wherein the first loss is used to maximize the difference between the first correlation score and the third correlation score, the second loss is used to control the difference between the first correlation score and the third correlation score, and the third loss is used to maximize the first correlation score while minimizing the third correlation score;

[0216] The first loss, the second loss, and the third loss are weighted summed to obtain the target loss.

[0217] In a possible implementation, the sampling module 1820 is further configured to:

[0218] Traverse the knowledge graph, and for the currently traversed central entity node, sample the first neighbor node set of the central entity node in the knowledge graph, wherein the first neighbor node set includes the first neighbor node subset of the central entity node at the kth level, and the first neighbor node subset includes the neighbor nodes sampled by the central entity node at the kth level, where k is an integer, k≥1;

[0219] Associating each central entity node with the corresponding first neighbor node set and writing it into the cache;

[0220] The sample entity node and the sample neighbor node set corresponding to the sample entity in the knowledge graph are matched from the cache.

[0221] In a possible implementation, the sampling module 1820 is further configured to:

[0222] For all neighbor nodes of the kth level of the central entity node, the trained knowledge graph embedding model is called to determine the fourth correlation score between the central entity node and each neighbor node, all neighbor nodes of the kth level are sorted according to the size of the fourth correlation score, and the first neighbor node subset of the kth level is sampled from the sorting result according to the first ranking threshold;

[0223] The first neighbor node subsets of k levels are combined to obtain the first neighbor node set of the central entity node.

[0224] In a possible implementation, the sampling module 1820 is further configured to:

[0225] Match the central entity node and the corresponding first neighbor node set of the sample entity in the knowledge graph from the cache;

[0226] For the first neighbor node subset of the kth level in the first neighbor node set, sampling again according to the second ranking threshold value to obtain the second neighbor node subset of the kth level, wherein the second ranking threshold value is less than the first ranking threshold value;

[0227] The second neighbor node subsets of k levels are combined to obtain the sample neighbor node set of the central entity node.

[0228] In a possible implementation, the sampling module 1820 is further configured to:

[0229] When k=1, the first-order attention features are fused with the sample node features to obtain the target node features of the sample entity node at the first level, and the first-order neighbor node features are updated based on the second-order neighbor node features of the second-order neighbor nodes of the sample entity node;

[0230] When k>1, based on the first-order neighbor node features updated at the k-1th level and the target node features obtained at the k-1th level, the fifth correlation score between the sample entity node and each first-order neighbor node is determined, the first-order neighbor node features updated at the k-1th level are aggregated based on the attention mechanism constructed by the fifth correlation score to obtain the k-order attention feature, the k-order attention feature is fused with the target node features obtained at the k-1th level to obtain the target node features of the sample entity at the k-th level, and the n-order neighbor node features of the n-order neighbor nodes of the sample entity node are updated based on the n+1-order neighbor node features of the n+1-order neighbor nodes of the sample entity node, where n is an integer, n∈[1,k].

[0231] In a possible implementation, the sampling module 1820 is further configured to:

[0232] Determine a sixth correlation score between the second-order neighbor node of the sample entity node and each first-order neighbor node;

[0233] Aggregating the second-order neighbor node features of the second-order neighbor nodes based on the attention mechanism constructed by the sixth relevance score to obtain the second-order attention features;

[0234] The second-order attention features are fused with the first-order neighbor node features to obtain the updated first-order neighbor node features.

[0235] In a possible implementation, the fusion module 1830 is further used to:

[0236] Normalize the second relevance score to get the attention weight;

[0237] The first-order neighbor node features are weighted summed according to the attention weights to aggregate the first-order neighbor node features and obtain the first-order attention features.

[0238] In a possible implementation, the second training module 1840 is further used to:

[0239] Obtain query semantic features associated with sample entities, and concatenate the query semantic features with target node features to obtain concatenated features;

[0240] The entity recommendation model is called to determine the estimated click rate of the sample entity based on the concatenated features.

[0241] The electronic device for executing the above-mentioned model training method provided in the embodiment of the present disclosure may be a terminal. Fig.19 , Fig.19This is a partial structural block diagram of a terminal provided in an embodiment of the present disclosure, and the terminal includes: a camera assembly 1910, a first memory 1920, an input unit 1930, a display unit 1940, a sensor 1950, an audio circuit 1960, a wireless fidelity (WiFi) module 1970, a first processor 1980, and a first power supply 1990. Those skilled in the art can understand that Fig.19 The terminal structure shown in the figure does not constitute a limitation on the terminal, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.

[0242] The camera assembly 1910 can be used to capture images or videos. Optionally, the camera assembly 1910 includes a front camera and a rear camera. Typically, the front camera is disposed on the front panel of the terminal, and the rear camera is disposed on the back of the terminal. In some embodiments, there are at least two rear cameras, which are any one of a main camera, a depth of field camera, a wide-angle camera, and a telephoto camera, so as to realize the fusion of the main camera and the depth of field camera to realize the background blur function, the fusion of the main camera and the wide-angle camera to realize the panoramic shooting and VR (Virtual Reality) shooting function or other fusion shooting functions.

[0243] The first memory 1920 may be used to store software programs and modules. The first processor 1980 executes various functional applications and data processing of the terminal by running the software programs and modules stored in the first memory 1920 .

[0244] The input unit 1930 may be used to receive input digital or character information and generate key signal input related to the terminal's settings and function control. Specifically, the input unit 1930 may include a touch panel 1931 and other input devices 1932 .

[0245] The display unit 1940 may be used to display input information or provided information and various menus of the terminal. The display unit 1940 may include a display panel 1941 .

[0246] The audio circuit 1960, the speaker 1961, and the microphone 1962 may provide an audio interface.

[0247] The first power source 1990 may be alternating current, direct current, a disposable battery, or a rechargeable battery.

[0248] The number of sensors 1950 may be one or more, and the one or more sensors 1950 include but are not limited to: acceleration sensors, gyroscope sensors, pressure sensors, optical sensors, etc. Among them:

[0249] The acceleration sensor can detect the magnitude of acceleration on the three coordinate axes of the coordinate system established by the terminal. For example, the acceleration sensor can be used to detect the components of gravity acceleration on the three coordinate axes. The first processor 1980 can control the display unit 1940 to display the user interface in a horizontal view or a vertical view according to the gravity acceleration signal collected by the acceleration sensor. The acceleration sensor can also be used for collecting motion data of games or users.

[0250] The gyroscope sensor can detect the body direction and rotation angle of the terminal, and the gyroscope sensor can cooperate with the acceleration sensor to collect the user's 3D actions on the terminal. The first processor 1980 can implement the following functions based on the data collected by the gyroscope sensor: motion sensing (such as changing the UI according to the user's tilt operation), image stabilization during shooting, game control, and inertial navigation.

[0251] The pressure sensor can be set in the side frame of the terminal and / or the lower layer of the display unit 1940. When the pressure sensor is set in the side frame of the terminal, the user's holding signal of the terminal can be detected, and the first processor 1980 performs left and right hand recognition or shortcut operation according to the holding signal collected by the pressure sensor. When the pressure sensor is set in the lower layer of the display unit 1940, the first processor 1980 controls the operability controls on the UI interface according to the user's pressure operation on the display unit 1940. The operability control includes at least one of a button control, a scroll bar control, an icon control, and a menu control.

[0252] The optical sensor is used to collect the ambient light intensity. In one embodiment, the first processor 1980 can control the display brightness of the display unit 1940 according to the ambient light intensity collected by the optical sensor. Specifically, when the ambient light intensity is high, the display brightness of the display unit 1940 is increased; when the ambient light intensity is low, the display brightness of the display unit 1940 is decreased. In another embodiment, the first processor 1980 can also dynamically adjust the shooting parameters of the camera assembly 1910 according to the ambient light intensity collected by the optical sensor.

[0253] In this embodiment, the first processor 1980 included in the terminal can execute the model training method of the previous embodiment.

[0254] The electronic device for executing the above-mentioned model training method provided in the embodiment of the present disclosure may also be a server, referring to Fig. 20 , Fig. 20Partial structural block diagram of a server provided in an embodiment of the present disclosure. The server may have relatively large differences due to different configurations or performances, and may include one or more second processors 2010 and a second memory 2030, and one or more storage media 2040 (e.g., one or more mass storage devices) storing application programs 2043 or data 2042. Among them, the second memory 2030 and the storage medium 2040 may be short-term storage or persistent storage. The program stored in the storage medium 2040 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations on the server. Furthermore, the second processor 2010 may be configured to communicate with the storage medium 2040 to execute a series of instruction operations in the storage medium 2040 on the server.

[0255] The server may also include one or more second power supplies 2020, one or more wired or wireless network interfaces 2050, one or more input and output interfaces 2060, and / or one or more operating systems 2041, such as Windows ServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.

[0256] The second processor 2010 in the server can be used to execute the model training method.

[0257] The embodiments of the present disclosure also provide a computer-readable storage medium, which is used to store a computer program, and the computer program is used to execute the model training methods of the aforementioned embodiments.

[0258] The present disclosure also provides a computer program product, which includes a computer program stored in a computer-readable storage medium. A processor of a computer device reads the computer program from the computer-readable storage medium, and the processor executes the computer program, so that the computer device executes the above-mentioned model training method.

[0259] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate to describe the embodiments of the present disclosure, such as being able to be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0260] It should be understood that in the present disclosure, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.

[0261] It should be understood that in the description of the embodiments of the present disclosure, the meaning of multiple (or multiple items) is more than two, greater than, less than, exceed, etc. are understood to not include the number, and above, below, within, etc. are understood to include the number.

[0262] In the several embodiments provided in the present disclosure, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.

[0263] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0264] In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0265] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present disclosure is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the various embodiments of the present disclosure. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store program codes.

[0266] It should also be understood that the various implementations provided in the embodiments of the present disclosure can be combined arbitrarily to achieve different technical effects.

[0267] The above is a specific description of the preferred implementation of the present disclosure, but the present disclosure is not limited to the above-mentioned implementation mode. Technical personnel familiar with the field can also make various equivalent deformations or substitutions under the shared conditions without violating the spirit of the present disclosure. These equivalent deformations or substitutions are all included in the scope defined by the claims of the present disclosure.

Claims

1. A model training method, characterized in that: include: Calling the knowledge graph embedding model to determine a first correlation score between any two entity nodes in the knowledge graph, and training the knowledge graph embedding model based on the first correlation score; Obtain a sample entity node corresponding to the sample entity in the knowledge graph and a sample neighbor node set sampled from the sample entity node in the knowledge graph, and call the trained knowledge graph embedding model to determine the sample node features of the sample entity node, the first-order neighbor node features of each first-order neighbor node in the sample neighbor node set, and a second correlation score between the sample entity node and each of the first-order neighbor nodes; Aggregating the first-order neighbor node features based on the attention mechanism constructed by the second relevance score to obtain a first-order attention feature, and fusing the first-order attention feature with the sample node feature to obtain a target node feature of the sample entity; The entity recommendation model is called to determine the estimated click rate of the sample entity based on the target node feature, and the entity recommendation model is trained based on the estimated click rate.

2. The model training method according to claim 1, characterized in that: The calling of the knowledge graph embedding model to determine a first correlation score between any two entity nodes in the knowledge graph includes: Call the knowledge graph embedding model to determine the head entity node features of the head entity node, the tail entity node features of the tail entity node, and the edge features of the edge relationship in any triple of the knowledge graph; An attention mechanism constructed based on the head entity node feature, the tail entity node feature, and the edge feature determines a first correlation score between the head entity node and the tail entity node.

3. The model training method according to claim 2, characterized in that: The determining a first correlation score between the head entity node and the tail entity node by using an attention mechanism constructed based on the head entity node feature, the tail entity node feature, and the edge feature includes: Obtain a trainable first linear transformation matrix and a second linear transformation matrix; Constructing a query feature based on the inner product between the first linear transformation matrix and the head entity node feature, and constructing a key feature based on the inner product between the second linear transformation matrix and the tail entity node feature; The inner product between the query feature, the key feature and the edge feature is normalized to obtain a first correlation score between the head entity node and the tail entity node.

4. The model training method according to claim 1, characterized in that: The step of training the knowledge graph embedding model based on the first relevance score includes: Taking the triple in the knowledge graph as a positive sample, constructing a negative sample by replacing the head entity node or the tail entity node in the triple, and calling the knowledge graph embedding model to determine a third relevance score corresponding to the negative sample; A target loss is determined according to the first relevance score and the third relevance score, and the knowledge graph embedding model is trained based on the target loss.

5. The model training method according to claim 4, characterized in that: The determining the target loss according to the first correlation score and the third correlation score includes: Determine a first loss, a second loss, and a third loss respectively according to the first correlation score and the third correlation score, wherein the first loss is used to maximize the difference between the first correlation score and the third correlation score, the second loss is used to control the difference between the first correlation score and the third correlation score, and the third loss is used to maximize the first correlation score while minimizing the third correlation score; The first loss, the second loss and the third loss are weightedly summed to obtain a target loss.

6. The model training method according to claim 1, characterized in that: The obtaining of a sample entity node corresponding to the sample entity in the knowledge graph and a set of sample neighbor nodes sampled from the sample entity node in the knowledge graph includes: Traversing the knowledge graph, for the currently traversed central entity node, sampling the first neighbor node set of the central entity node in the knowledge graph, wherein the first neighbor node set includes the first neighbor node subset of the central entity node at the kth level, and the first neighbor node subset includes the neighbor nodes sampled by the central entity node at the kth level, where k is an integer, k≥1; Associating each of the central entity nodes with the corresponding first neighbor node set and writing them into a cache; The sample entity node and the sample neighbor node set corresponding to the sample entity in the knowledge graph are matched from the cache.

7. The model training method according to claim 6, characterized in that: The first neighbor node set of the central entity node is obtained by sampling in the knowledge graph, including: For all neighbor nodes of the kth class of the central entity node, the trained knowledge graph embedding model is called to determine a fourth correlation score between the central entity node and each of the neighbor nodes, all neighbor nodes of the kth class are sorted according to the size of the fourth correlation score, and a first neighbor node subset of the kth class is sampled from the sorting result according to the first ranking threshold; The first neighbor node subsets of k levels are combined to obtain the first neighbor node set of the central entity node.

8. The model training method according to claim 7, characterized in that: The matching from the cache to obtain the central entity node and the corresponding sample neighbor node set corresponding to the sample entity in the knowledge graph includes: Matching the central entity node and the first neighbor node set corresponding to the sample entity in the knowledge graph from the cache; For the first neighbor node subset of the kth level in the first neighbor node set, sampling again according to a second ranking threshold to obtain a second neighbor node subset of the kth level, wherein the second ranking threshold is less than the first ranking threshold; The second neighbor node subsets of k levels are combined to obtain a sample neighbor node set of the central entity node.

9. The model training method according to claim 6, characterized in that: The fusing the first-order attention feature with the sample node feature to obtain the target node feature of the sample entity includes: When k=1, the first-order attention feature is fused with the sample node feature to obtain the target node feature of the sample entity node at the first level, and the first-order neighbor node feature is updated based on the second-order neighbor node feature of the second-order neighbor node of the sample entity node; When k>1, based on the first-order neighbor node features updated at the k-1th level and the target node features obtained at the k-1th level, determine the fifth correlation score between the sample entity node and each of the first-order neighbor nodes, aggregate the first-order neighbor node features updated at the k-1th level based on the attention mechanism constructed by the fifth correlation score to obtain a k-order attention feature, fuse the k-order attention feature with the target node features obtained at the k-1th level to obtain the target node features of the sample entity at the k-th level, and update the n-order neighbor node features of the n-order neighbor nodes of the sample entity node based on the n+1-order neighbor node features of the n+1-order neighbor nodes of the sample entity node, where n is an integer, n∈[1,k].

10. The model training method according to claim 9, characterized in that: The updating of the first-order neighbor node features based on the second-order neighbor node features of the second-order neighbor nodes of the sample entity node includes: Determine a sixth correlation score between the second-order neighbor node of the sample entity node and each of the first-order neighbor nodes; Aggregating the second-order neighbor node features of the second-order neighbor node based on the attention mechanism constructed by the sixth relevance score to obtain a second-order attention feature; The second-order attention feature is fused with the first-order neighbor node feature to obtain an updated first-order neighbor node feature.

11. The model training method according to claim 1, characterized in that: The attention mechanism constructed based on the second relevance score aggregates the first-order neighbor node features to obtain the first-order attention features, including: Normalizing the second relevance score to obtain an attention weight; The first-order neighbor node features are weighted summed according to the attention weights to aggregate the first-order neighbor node features to obtain first-order attention features.

12. The model training method according to claim 1, characterized in that: The calling entity recommendation model determines the estimated click rate of the sample entity based on the target node feature, including: Acquire the query semantic feature associated with the sample entity, and concatenate the query semantic feature with the target node feature to obtain a concatenated feature; The entity recommendation model is called to determine the estimated click rate of the sample entity based on the concatenated features.

13. A model training device, characterized in that: include: A first training module, configured to call a knowledge graph embedding model to determine a first correlation score between any two entity nodes in the knowledge graph, and to train the knowledge graph embedding model based on the first correlation score; A sampling module, used to obtain a sample entity node corresponding to a sample entity in the knowledge graph and a sample neighbor node set sampled from the sample entity node in the knowledge graph, and call the trained knowledge graph embedding model to determine the sample node features of the sample entity node, the first-order neighbor node features of each first-order neighbor node in the sample neighbor node set, and a second correlation score between the sample entity node and each of the first-order neighbor nodes; a fusion module, configured to aggregate the first-order neighbor node features based on the attention mechanism constructed by the second relevance score to obtain a first-order attention feature, and fuse the first-order attention feature with the sample node feature to obtain a target node feature of the sample entity; The second training module is used to call the entity recommendation model to determine the estimated click rate of the sample entity based on the target node feature, and train the entity recommendation model based on the estimated click rate.

14. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the model training method described in any one of claims 1 to 12 is implemented.

15. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the model training method described in any one of claims 1 to 12 is implemented.

16. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the model training method described in any one of claims 1 to 12 is implemented.