Business processing method and device based on knowledge graph
Through knowledge graph encoding and prototype clustering in the offline stage, anchor entities are determined and their data are stored, which solves the problem of high computing costs caused by the huge scale of knowledge graphs, and achieves fast processing speed and low-cost storage in the business processing stage.
Patent Information
- Application Number
- CN202411144340.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-19
- Publication Date
- 2024-11-08
AI Technical Summary
The existing knowledge graphs are huge and complex in processing downstream tasks, which lead to high computational costs and are difficult to process at low cost and quickly, and the amount of data needs to be reduced to improve processing speed.
Through the offline stage, the knowledge graph is encoded and prototyped clustered, the anchor entity is determined and its related data is stored. In the online stage, the entity representation is calculated in real time based on the anchor entity's characterization, reducing storage and calculation requirements.
Reduces the amount of data and calculation costs of knowledge graph representation learning, and increases the processing speed of downstream tasks (such as item recommendations).
Smart Images

Figure CN118917308A_ABST
Abstract
Description
Technical Field
[0001] One or more embodiments of the present specification relate to the field of knowledge graphs, and in particular, to business processing methods and devices based on knowledge graphs. Background Art
[0002] In recent years, knowledge graphs (KGs) have attracted widespread attention in many fields such as recommendation systems, large language model pre-training, and multimedia fusion. Knowledge graphs use a combination of topological structures and textual information to store human knowledge. In order to enhance the representation ability of knowledge graphs, knowledge graph representation learning (KGRL) has become a key task, which aims to embed entities into latent representations to facilitate various downstream tasks, including link prediction, relationship prediction, knowledge graph reasoning, and entity classification.
[0003] However, the knowledge graphs used in practical applications are usually large and complex. There are a large number of entities and relationships in these knowledge graphs, which leads to high computational costs and huge parameter requirements, making it difficult to process downstream tasks quickly and cheaply. Therefore, a method is needed to reduce the amount of data in knowledge graph representation learning, reduce storage costs and computational costs, and improve the processing speed of downstream tasks. Summary of the invention
[0004] One or more embodiments of this specification describe a business processing method and device based on a knowledge graph to reduce the amount of data in knowledge graph representation learning while improving the business processing speed.
[0005] In a first aspect, a business processing method based on a knowledge graph is provided, comprising:
[0006] In the offline stage, a target encoder is used to encode the knowledge graph to obtain a first entity representation of each entity therein; the knowledge graph includes entities representing users and items;
[0007] Prototype clustering is performed based on each first entity representation to obtain multiple cluster centers;
[0008] Determine several entities that are close to each cluster center as anchor entities, and store relevant data of the anchor entities as anchor data sets;
[0009] During the business processing stage, in response to a processing request containing a first target entity, a second entity representation of the first target entity is determined based on the first entity representation of at least some of the anchor entities in the anchor data set formed in the offline stage, and the relationship edges between the first target entity and at least some of the anchor entities; the second entity representation is used to recommend items to the user.
[0010] In a possible implementation, the processing request further includes a second target entity; the first target entity and the second target entity correspond to a first user and a first item, respectively; and the method further includes:
[0011] In a business processing stage, determining a second entity representation of the second target entity according to the anchor data set;
[0012] The second entity representations of the first target entity and the second target entity are respectively input into the recommendation model, and it is determined whether to recommend the first item to the first user according to the output result.
[0013] In one possible implementation, the target encoder is trained in the following manner:
[0014] For a sample entity pair in the knowledge graph, determine the current second entity representation of the sample entity pair according to the first entity representation of the current anchor entity;
[0015] Input the current second entity representation into the recommendation model to obtain the corresponding training loss;
[0016] Based on the training loss, parameter values in the target encoder are adjusted.
[0017] In a possible implementation, the recommendation model is used to complete a link prediction task; the link prediction task includes predicting whether there is a relationship edge between a user entity and an item entity that represents a specific interactive relationship.
[0018] In a possible implementation, the target encoder includes a text encoder and a structure encoder, and the encoding process includes:
[0019] Encode the text information of each entity in the knowledge graph using a text encoder to obtain a first original representation of each entity;
[0020] Using a structural encoder to encode each entity and relationship edge in the knowledge graph to obtain a second original representation of each entity and a first relationship representation of each relationship edge;
[0021] Based on the weighted sum of the first original representation and the second original representation of each entity, a first entity representation of each entity is determined.
[0022] In a possible implementation, prototype clustering is performed based on each first entity representation to obtain multiple cluster centers, including:
[0023] Using a prototype clustering algorithm, prototype clustering is performed on each entity based on each first entity representation to obtain a plurality of clusters;
[0024] The cluster center of each cluster is determined according to the first entity representation of each entity in each cluster.
[0025] In a possible implementation, the prototype clustering algorithm includes at least one of the following: a K-means clustering algorithm, a GMM algorithm, and a Spectral Clustering algorithm.
[0026] In a possible implementation, several entities close to each cluster center are determined as anchor entities, including:
[0027] For any first entity in the knowledge graph, calculate the distance between it and each cluster center, and determine the reciprocal of the minimum distance as the confidence score of the first entity;
[0028] Several entities with high confidence scores in each cluster are determined as anchor entities.
[0029] In a possible implementation manner, the encoding process further obtains a first relationship representation of each relationship edge; and determining a second entity representation of the first target entity includes:
[0030] Constructing a first representation matrix based on the first entity representations of at least part of the anchor entities and the first relationship representations of each relationship edge;
[0031] The first representation matrix is input into a representation encoding model to obtain a second entity representation.
[0032] In a possible implementation, before constructing the first characterization matrix, the method further includes:
[0033] In the business processing stage, determining the path distance between each anchor entity in the partial anchor entities and the first target entity in the knowledge graph;
[0034] Based on a preset mapping function, each path distance is mapped into a path distance representation;
[0035] Based on the sum of the first entity representation and the path distance representation of each anchor entity, the first entity representation of each anchor entity is updated.
[0036] In a possible implementation, the representation encoding model includes at least one of the following: a multi-layer perceptron model and a Transformer model.
[0037] In a second aspect, a business processing device based on a knowledge graph is provided, comprising:
[0038] A first encoding unit is configured to, in an offline stage, use a target encoder to encode the knowledge graph to obtain a first entity representation of each entity therein; the knowledge graph includes entities representing users and items;
[0039] The clustering unit is configured to, in an offline stage, perform prototype clustering based on each first entity representation to obtain a plurality of cluster centers;
[0040] An anchor point determination unit is configured to, in an offline stage, determine several entities that are close to each cluster center as anchor point entities, and store relevant data of the anchor point entities as anchor point data sets;
[0041] The second encoding unit is configured to, in a business processing phase, respond to a processing request containing a first target entity, determine a second entity representation of the first target entity based on a first entity representation of at least some of the anchor entities in the anchor data set formed in an offline phase, and a relationship edge between the first target entity and at least some of the anchor entities; the second entity representation is used to recommend items to a user.
[0042] In a possible implementation manner, the processing request further includes a second target entity; the first target entity and the second target entity correspond to a first user and a first item respectively; the device further includes:
[0043] A third encoding unit is configured to, during a business processing phase, determine a second entity representation of the second target entity according to the anchor data set;
[0044] The recommendation unit is configured to, during a business processing phase, input the second entity representations of the first target entity and the second target entity into a recommendation model, and determine whether to recommend the first item to the first user based on an output result.
[0045] In a possible implementation, it further includes:
[0046] A distance determination unit, configured to determine, in a business processing stage, a path distance between each anchor entity in the partial anchor entities and the first target entity in the knowledge graph;
[0047] A mapping unit configured to, during a business processing phase, map each path distance into a path distance representation based on a preset mapping function;
[0048] The representation updating unit is configured to update the first entity representation of each anchor point entity based on the sum of the first entity representation and the path distance representation of each anchor point entity during the service processing stage.
[0049] According to a third aspect, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed in a computer, the computer is caused to execute the method of the first aspect.
[0050] According to a fourth aspect, a computing device is provided, comprising a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, the method of the first aspect is implemented.
[0051] The business processing method and device based on the knowledge graph proposed in the embodiments of this specification divides the entities in the knowledge graph into multiple clusters through encoders and prototype clustering in the offline stage. Then, several entities near each cluster center are determined as anchor entities, and the relevant data of each anchor entity is stored as an anchor data set. The representations of other non-anchor entities in the knowledge graph are not stored, but are calculated in real time according to the representation of the anchor entity when responding to the corresponding processing request in the online business processing stage. In this way, by pre-calculating and storing a small number of representative entity representations, the entity representation of any entity in the knowledge graph can be quickly determined in real-time business according to the specific needs of downstream tasks to complete the calculation. While reducing storage costs and computing costs, it can also improve the processing speed of downstream tasks (such as item recommendations). BRIEF DESCRIPTION OF THE DRAWINGS
[0052] In order to more clearly illustrate the technical solutions of the multiple embodiments disclosed in this specification, the drawings required for the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only the multiple embodiments disclosed in this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0053] Figure 1 A schematic diagram showing an implementation scenario of a business processing method based on a knowledge graph according to an embodiment;
[0054] Figure 2 A flowchart showing a business processing method based on a knowledge graph according to an embodiment;
[0055] Figure 3 A schematic block diagram of a business processing device based on a knowledge graph according to one embodiment is shown. DETAILED DESCRIPTION
[0056] The solution provided in this specification is described below in conjunction with the accompanying drawings.
[0057] Figure 1 A schematic diagram of an implementation scenario of a business processing method based on a knowledge graph according to an embodiment is shown. Figure 1 In the example, it is divided into an offline phase and a business processing phase, wherein the steps of the offline phase can be executed and the corresponding data can be stored before the business processing, and then the processing results of the offline phase can be directly and repeatedly called for use in the business processing phase. The pre-formed knowledge graph contains multiple entities (entity) and relationship edges (relation). The knowledge graph can be a knowledge graph related to item recommendations, including entities related to users and items. The relationship edges between entities representing users and entities representing items can be the interactive relationship between users and items, such as browsing, liking, collecting, purchasing, etc.; the relationship between users can be, for example, friends, similar preferences, same generation, etc.; the relationship between items can be, for example, the same type, used together (such as toothpaste and toothbrush), similar usage scenarios, etc.
[0058] In the offline stage, first, each entity in the knowledge graph is encoded respectively to obtain the first entity representation (embedding) corresponding to each entity; optionally, each relationship edge in the knowledge graph is encoded respectively to obtain the first relationship representation corresponding to each relationship edge. Then, prototype clustering is performed based on each first entity representation to obtain multiple cluster centers. Optionally, when performing prototype clustering, the first relationship representation of each relationship edge can also be used to perform prototype clustering together with the first entity representation to improve the accuracy of the clustering results. Next, a preset number of entities that are close to each cluster center are determined as anchor entities. Finally, the relevant data of the anchor entity, including the first entity representation of the anchor entity, is stored as an anchor data set. At the end of the offline stage, only the relevant data of each anchor entity, that is, the anchor data set, will be saved, and the representations of other non-anchor entities will not be saved, but will be calculated in real time according to specific processing requirements in the subsequent online business processing stage.
[0059] In the business processing stage, in response to a processing request containing a target entity, the first t anchor entities that are close to the target entity are found from the anchor data set determined in the offline stage, including anchor entity 1 to anchor entity t. Then, based on the first entity representations of these t anchor entities, the second entity representation of the target entity is determined as the representation of the target entity calculated in real time during the online business processing stage. Optionally, multiple relationship edges between each anchor entity and the target entity can also be determined, and the relationship representations obtained by encoding these relationship edges are used together with the first entity representations of each anchor entity to determine the second entity representation of the target entity. The second entity representation of the target entity can be used to recommend items to users. For example, the second entity representations of the first user and the first item in the knowledge graph are determined respectively, and then input into the pre-trained recommendation model, and the output result of the recommendation model is used to determine whether to recommend the first item to the first user.
[0060] The following describes the specific implementation steps of the above-mentioned knowledge graph-based business processing method in conjunction with a specific embodiment.
[0061] Figure 2 A flowchart of a business processing method based on a knowledge graph according to an embodiment is shown. The execution subject of the method can be any platform or server or device cluster with computing and processing capabilities. Figure 2 As shown, the method at least includes: step 202, in the offline stage, using the target encoder to encode the knowledge graph to obtain the first entity representation of each entity therein; the knowledge graph includes entities representing users and items; step 204, based on each first entity representation, prototype clustering is performed to obtain multiple cluster centers; step 206, several entities that are close to each cluster center are determined as anchor entities, and the relevant data of the anchor entities are stored as an anchor data set; step 214, in the business processing stage, in response to a processing request containing a first target entity, according to the first entity representation of at least part of the anchor entities in the anchor data set formed in the offline stage, and the relationship edge between the first target entity and the at least part of the anchor entities, determine the second entity representation of the first target entity; the second entity representation is used to recommend items to users.
[0062] The specific execution process of each of the above steps is described below.
[0063] First, in step 202, in an offline stage, a target encoder is used to encode the knowledge graph to obtain a first entity representation of each entity therein; the knowledge graph includes entities representing users and items.
[0064] The knowledge graph G can be pre-formed based on previous theoretical knowledge and business practice accumulation, including multiple fact triples, denoted as G = {s1, s2, ..., sn}. Any fact triple s i It can be formally expressed as s i =(h,r,t), where h represents the head entity, r represents the relationship edge, and t represents the tail entity. h and t belong to the entity set E, i.e. h,t∈E; r belongs to the relationship edge set R, i.e. r∈R.
[0065] The target encoder is used to encode the elements in the knowledge graph and obtain a preliminary embedding representation.
[0066] In one embodiment, the target encoder comprises a text encoder F t and structure encoder F s The textual encoder is used to encode the text information contained in each entity in the knowledge graph; the structural encoder is used to encode the entities and relationship edges in the knowledge graph, as well as the structural information of the knowledge graph.
[0067] The encoding process in step 202 specifically includes steps 2022 to 2026.
[0068] In step 2022, using the text encoder F t Encode the text information of each entity in the knowledge graph to obtain the first original representation z of each entity c .
[0069] Here, the text information of the entity may include the entity name text, the description text of the entity attributes, etc. For example, for an item entity, its text information may include the name of the item, the attribute description, such as category, purpose, etc.
[0070] The first primitive representation of any entity z c It can be a 1×d-dimensional vector, where d is a preset hyperparameter representing the dimension of the embedding vector. When the number of entities in the knowledge graph is N, that is, the number of elements in the entity set E is N, the first original representation z of the N entities is c Can be arranged into an N×d dimensional matrix, denoted as Z c ∈R N×d At this time, step 2022 can be as shown in formula (1):
[0071] Z c =F t (E) (1)
[0072] Then, in step 2024, the structure encoder F is used. sEncode each entity and relationship edge in the knowledge graph to obtain the second original representation z of each entity s , and the first relation representation z of each relation edge r .
[0073] The second primitive representation z of any entity s It can be a 1×d dimensional vector, the second original representation z of N entities s Can be arranged into an N×d dimensional matrix, denoted as Z s ∈R N×d The first relational representation z of any relational edge r It can be a 1×d-dimensional vector. When the number of relationship edges in the knowledge graph is M, that is, the number of elements in the relationship edge set R is M, the first relationship representation z of the M relationship edges is r Can be arranged into an M×d dimensional matrix, denoted as Z r ∈R M×d At this time, step 2024 can be as shown in formula (2):
[0074] Z s ,Z r =F s (G) (2)
[0075] Next, in step 2026, based on the first original representation z of each entity c and the second primitive representation z s The weighted sum of the results is used to determine the first entity representation z of each entity.
[0076] The first entity representation z of any entity can be a 1×d-dimensional vector. The first entity representation z of N entities can be arranged into an N×d-dimensional matrix, denoted by Z∈R N×d The weight coefficient of the weighted summation can be recorded as α. At this time, step 2026 can be shown as formula (3):
[0077] Z=Z s +αZ c (3)
[0078] Each row vector in the matrix Z is the first entity representation z of each entity in the knowledge graph.
[0079] In another embodiment, the target encoder comprises only the text encoder F t In this embodiment, the text encoder F is used t Encode the text information of each entity in the knowledge graph, and use the encoding result as the first entity representation z of each entity. As shown in formula (4):
[0080] Z=Ft (E) (4)
[0081] In yet another embodiment, the target encoder comprises only the structure encoder F s In this embodiment, the structure encoder F is used s Encode each entity and relationship edge in the knowledge graph to obtain the first entity representation z of each entity and the first relationship representation z of each relationship edge r As shown in formula (5):
[0082] Z,Z r =F s (G) (5)
[0083] The above encoding operation can be completed using various types of text encoders and structural encoders. In one embodiment, the text encoder includes at least one of the following: BERT (Bidirectional Encoder Representations from Transformers) encoder, GPT (Generative Pre-trained Transformer) encoder, Llama encoder (Large Language Model MetaAI). The structural encoder includes at least one of the following: RotatE (RotateEntity) encoder, CompGCN (Composition-based Graph ConvolutionalNetworks) encoder, RGCN (Relational Graph ConvolutionalNetworks) encoder.
[0084] Then, return to Figure 2 In step 204, prototype clustering is performed based on each first entity representation z to obtain multiple cluster centers p.
[0085] In prototype clustering, prototype refers to a representative data point in a data set. Prototype clustering represents each cluster in a data set by selecting a set of prototypes (corresponding to cluster centers) from the data set, and then assigning each data point to the cluster represented by the prototype that is most similar or closest to it. The cluster center can be a representative user entity representation and / or item entity representation in each user cluster and item cluster.
[0086] Specifically, step 204 includes: using the prototype clustering algorithm C to prototype cluster each entity based on each first entity representation to obtain multiple clusters; and determining the cluster center p of each cluster according to the first entity representation of each entity in each cluster.
[0087] The number of clusters can be preset to K, and correspondingly, the number of cluster centers p is K. The matrix composed of K cluster centers p can be recorded as P∈R K×d Step 204 may be expressed as formula (6):
[0088] P=C(Z) (6)
[0089] In step 204, a variety of prototype clustering algorithms may be used. In one embodiment, the prototype clustering algorithm includes at least one of the following: K-means clustering algorithm, GMM (Gaussian Mixed Model) algorithm, Spectral Clustering algorithm.
[0090] Next, in step 206 , several entities that are close to each cluster center p are determined as anchor entities a, and relevant data of the anchor entity a is stored as anchor data set A.
[0091] For any cluster center p, calculate the distance between each entity in the entity set E and the cluster center, and select a number of entities (preset number) with the smallest distance as anchor entities a. The set of anchor entities near each cluster center is determined as the anchor set.
[0092] In one embodiment, the reciprocal of the aforementioned distance may be used as the confidence score of the entity, and then the entity with the highest confidence score is selected as the anchor entity. In this embodiment, step 206 specifically includes steps 2062 to 2064.
[0093] In step 2062, for any first entity in the knowledge graph, the distance between it and each cluster center is calculated, and the inverse of the minimum distance is determined as the confidence score of the first entity.
[0094] The first entity may be the i-th entity in the entity set E, and its confidence score c i It can be shown as formula (7):
[0095]
[0096] Among them, z i The first entity representation representing the first entity, p j∈P represents the representation of the jth cluster center, and D() is used to calculate the distance between two representations. The distance between two representations can be calculated in many ways, such as Euclidean distance, Manhattan distance, etc.
[0097] Then, in step 2064, several entities with higher confidence scores in each cluster are determined as anchor entities in the cluster.
[0098] Entities with higher confidence scores in each cluster may correspond to entities that are close to the cluster center.
[0099] Based on the determination of the above anchor entities, the relevant data of each anchor entity can be stored as an anchor data set A. The relevant data here may include the entity identifier of the anchor entity a, the first entity representation z a Optionally, other descriptive information (direct edges, triples, etc.) of the anchor entity in the knowledge graph may also be included.
[0100] Steps 202 to 206 describe the process of determining anchor entities and storing related information in the offline phase. The anchor data set A determined in the offline phase can be used to calculate (encode) representations of other non-anchor entities in the online business processing phase.
[0101] In step 214, in the business processing stage, in response to a processing request containing a first target entity, a second entity representation of the first target entity is determined based on the first entity representation of at least some of the anchor entities in the anchor data set formed in the offline stage, and the relationship edges between the first target entity and at least some of the anchor entities; the second entity representation is used to recommend items to the user.
[0102] At least some of the anchor entities in the anchor data set A may be a preset number of anchor entities that are closest to the first target entity. The preset number may be t, and the selected anchor entities may be anchor entity 1 to anchor entity t. The relationship edges between the first target entity and at least some of the anchor entities may be all the relationship edges that each anchor entity passes through to reach the first target entity in the knowledge graph, and the total number of these relationship edges may be m. The second entity representation of the first target entity may be denoted as h1, which is a 1×d-dimensional vector.
[0103] The distance used to determine at least some of the aforementioned anchor entities may be the path distance between the first target entity and each anchor entity, that is, the number of relationship edges required to reach the anchor entity from the first target entity in the knowledge graph. For example, when two entities are directly connected by a relationship edge, the path distance is 1; for another example, when entity 1 is connected to entity 3, and then entity 3 is connected to entity 2, the path distance between entity 1 and entity 2 is 2.
[0104] The distance used when determining at least part of the aforementioned anchor entities may also be the distance between the first target entity and each anchor entity determined based on the respective first entity representations.
[0105] In one embodiment, the encoding process in the offline stage also obtains the first relationship representation of each relationship edge. The second entity representation of the first target entity in step 214 includes: constructing a first representation matrix based on the first entity representation of at least part of the anchor entity and the first relationship representation of each relationship edge; inputting the first representation matrix into the representation encoding model to obtain the second entity representation h1.
[0106] The first entity representation of the partial anchor entity may be z1 to z t , the first relation representation of each relation edge can be z r1 To z rm The first characterization matrix M1 can be z1 to z t and z r1 To z rm The (t+m)×d-dimensional matrix formed by the arrangement, that is, M1∈R (t+m)×d .
[0107] The representation encoding model can be any pre-trained model that can implement R (t+m)×d →R d In one embodiment, the representation encoding model includes at least one of the following: a multi-layer perceptron model and a Transformer model.
[0108] When the representation encoding model is based on a multi-layer perceptron (MLP) model, it receives a 1×(t+m)d-dimensional vector formed after re-splicing the first representation matrix M1; when the representation encoding model is based on a Transformer model, it can directly receive the original first representation matrix M1.
[0109] Through step 214 of the business processing stage, the second entity representation of a specific entity can be calculated in real time based on the anchor data set according to the specific requirements of the downstream task, so as to be applied to the specific calculation of the downstream task.
[0110] In some possible implementations, during the business processing stage, the processing request further includes a second target entity; the first target entity and the second target entity correspond to a first user and a first item, respectively; and the method further includes steps 216 and 218.
[0111] In step 216, during the business processing phase, a second entity representation of the second target entity is determined based on the anchor data set.
[0112] The second entity representation of the second target entity can be denoted as h2. The process of determining the second entity representation of the second target entity can refer to the process of determining the second entity representation of the first target entity in step 214.
[0113] Then, in step 218, the second entity representations of the first target entity and the second target entity are respectively input into the recommendation model, and it is determined whether to recommend the first item to the first user based on the output result.
[0114] The recommendation model can accept the input of h1 and h2, and output a recommendation score with a continuous value, or output a binary value of 0-1 representing a recommendation / non-recommendation result. When the output is a recommendation score, a corresponding threshold can be set. When the recommendation score exceeds the threshold, the first item is recommended to the first user; otherwise, the first item is not recommended to the first user.
[0115] In some possible implementations, the recommendation model is used to complete a link prediction task; the link prediction task includes predicting whether there is a relationship edge between a user entity and an item entity that represents a specific interactive relationship.
[0116] The aforementioned steps of completing the link prediction task based on the recommendation model are conventional existing technologies and will not be repeated here.
[0117] In some possible implementations, during the business processing stage, the path distances between each anchor entity and the first target entity can also be added to the encoding process of the second entity standard to further improve the accuracy of the encoding. Before constructing the first characterization matrix M1, the method further includes steps 208 to 212.
[0118] In step 208, during the business processing stage, the path distance between each anchor entity in the partial anchor entities and the first target entity in the knowledge graph is determined.
[0119] The path distance between the anchor entity and the first target entity may be, in the knowledge graph, the number of relationship edges required to pass from the anchor entity to the first target entity.
[0120] In step 210, each path distance is mapped to a path distance representation based on a preset mapping function.
[0121] The mapping function can be able to achieve N → R d A mapping function, such as a function based on a relative distance encoding mechanism. Wherein, N represents a set of positive integers.
[0122] Then, in step 212, the first entity representation of each anchor entity is updated based on the sum of the first entity representation and the path distance representation of each anchor entity.
[0123] By incorporating the distance information into the encoding through steps 210 to 212, the structural information in the knowledge graph can be better used in the process of determining the second entity representation.
[0124] In some possible implementations, the target encoder may be trained according to the performance of the encoding result of the target encoder in the recommendation model to improve the accuracy and rationality of the encoding result. The target encoder is trained in the following manner:
[0125] First, for a sample entity pair in the knowledge graph, the current second entity representation of the sample entity pair is determined based on the first entity representation of the current anchor entity.
[0126] The process of determining the second entity representation may refer to the specific process of the aforementioned step 214 .
[0127] Then, the current second entity representation is input into the recommendation model to obtain the corresponding training loss.
[0128] Finally, based on the training loss, parameter values in the target encoder are adjusted.
[0129] The step of training the target encoder can be performed alternately with the step of generating the second entity representation of the entity in the offline phase and the business processing phase. Figure 2 The steps shown generate the second entity representations of multiple sample entity pairs, then train the target encoder based on the multiple sample entity pairs, and then use the target encoder to perform a new round of encoding of the second entity standard. After multiple rounds of alternating, a trained target encoder is obtained, which can further improve the accuracy of the second entity representation, thereby improving the accuracy and rationality of item recommendations.
[0130] The business processing method based on the knowledge graph described in the embodiment of this specification uses the prototype information in the knowledge graph to select representative anchor entities in the offline stage to form an anchor data set. The anchor data set has the characteristics of a small number of elements and high quality. Then, in the online business processing stage, other entities in the knowledge graph are encoded based on the anchor data set, which reduces the amount of data storage while improving the overall computational efficiency of the solution.
[0131] According to another embodiment, a business processing device based on a knowledge graph is also provided. Figure 3A schematic block diagram of a business processing device based on a knowledge graph according to an embodiment is shown, and the device can be deployed in any device, platform or device cluster with computing and processing capabilities. Figure 3 As shown, the device 300 includes:
[0132] A first encoding unit 302 is configured to, in an offline stage, use a target encoder to encode the knowledge graph to obtain a first entity representation of each entity therein; the knowledge graph includes entities representing users and items;
[0133] The clustering unit 304 is configured to perform prototype clustering based on each first entity representation in an offline stage to obtain a plurality of cluster centers;
[0134] An anchor point determination unit 306 is configured to, in an offline stage, determine several entities that are close to each cluster center as anchor point entities, and store relevant data of the anchor point entities as an anchor point data set;
[0135] The second encoding unit 314 is configured to, in a business processing phase, respond to a processing request containing a first target entity, determine a second entity representation of the first target entity based on a first entity representation of at least some of the anchor entities in the anchor data set formed in an offline phase, and a relationship edge between the first target entity and at least some of the anchor entities; the second entity representation is used to recommend items to the user.
[0136] In some possible implementations, the processing request further includes a second target entity; the first target entity and the second target entity correspond to a first user and a first item, respectively; the apparatus 300 further includes:
[0137] The third encoding unit 316 is configured to determine, during a business processing phase, a second entity representation of the second target entity according to the anchor data set;
[0138] The recommendation unit 318 is configured to, during the business processing stage, input the second entity representations of the first target entity and the second target entity into the recommendation model, and determine whether to recommend the first item to the first user based on the output result.
[0139] In some possible implementations, the device 300 further includes:
[0140] The distance determination unit 308 is configured to determine, in the business processing stage, the path distance between each anchor entity in the partial anchor entities and the first target entity in the knowledge graph;
[0141] The mapping unit 310 is configured to, during the service processing phase, map each path distance into a path distance representation based on a preset mapping function;
[0142] The representation updating unit 312 is configured to update the first entity representation of each anchor point entity based on the sum of the first entity representation and the path distance representation of each anchor point entity during the service processing stage.
[0143] According to another aspect of the embodiment, a computer-readable storage medium is further provided, on which a computer program is stored. When the computer program is executed in a computer, the computer is caused to execute the method described in any of the above embodiments.
[0144] According to yet another embodiment, a computing device is provided, including a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, the method described in any one of the above embodiments is implemented.
[0145] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0146] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0147] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0148] A person skilled in the art will understand that all or part of the steps to implement the above embodiments may be accomplished by hardware or by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a disk or an optical disk, etc.
[0149] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A business processing method based on knowledge graph, comprising: In the offline stage, a target encoder is used to encode the knowledge graph to obtain a first entity representation of each entity therein; the knowledge graph includes entities representing users and items; Prototype clustering is performed based on each first entity representation to obtain multiple cluster centers; Determine several entities that are close to each cluster center as anchor entities, and store relevant data of the anchor entities as anchor data sets; During the business processing stage, in response to a processing request containing a first target entity, a second entity representation of the first target entity is determined based on the first entity representation of at least some of the anchor entities in the anchor data set formed in the offline stage, and the relationship edges between the first target entity and at least some of the anchor entities; the second entity representation is used to recommend items to the user.
2. The method according to claim 1, wherein: The processing request further includes a second target entity; the first target entity and the second target entity correspond to a first user and a first item, respectively; the method further includes: In a business processing stage, determining a second entity representation of the second target entity according to the anchor data set; The second entity representations of the first target entity and the second target entity are respectively input into the recommendation model, and it is determined whether to recommend the first item to the first user according to the output result.
3. The method according to claim 1, wherein: The target encoder is trained in the following way: For a sample entity pair in the knowledge graph, determine the current second entity representation of the sample entity pair according to the first entity representation of the current anchor entity; Input the current second entity representation into the recommendation model to obtain the corresponding training loss; Based on the training loss, parameter values in the target encoder are adjusted.
4. The method according to claim 2 or 3, wherein: The recommendation model is used to complete the link prediction task; the link prediction task includes predicting whether there is a relationship edge representing a specific interactive relationship between a user entity and an item entity.
5. The method according to claim 1, wherein: The target encoder includes a text encoder and a structure encoder, and the encoding process includes: Encode the text information of each entity in the knowledge graph using a text encoder to obtain a first original representation of each entity; Using a structural encoder to encode each entity and relationship edge in the knowledge graph to obtain a second original representation of each entity and a first relationship representation of each relationship edge; Based on the weighted sum of the first original representation and the second original representation of each entity, a first entity representation of each entity is determined.
6. The method according to claim 1, wherein: Prototype clustering is performed based on each first entity representation to obtain multiple cluster centers, including: Using a prototype clustering algorithm, prototype clustering is performed on each entity based on each first entity representation to obtain a plurality of clusters; The cluster center of each cluster is determined according to the first entity representation of each entity in each cluster.
7. The method according to claim 6, wherein: The prototype clustering algorithm includes at least one of the following: K-means clustering algorithm, GMM algorithm, Spectral Clustering algorithm.
8. The method according to claim 1, determining several entities close to each cluster center as anchor entities, comprising: For any first entity in the knowledge graph, calculate the distance between it and each cluster center, and determine the reciprocal of the minimum distance as the confidence score of the first entity; Several entities with high confidence scores in each cluster are determined as anchor entities.
9. The method according to claim 1, wherein: The encoding process also obtains a first relation representation of each relation edge; Determining a second entity representation of the first target entity includes: Constructing a first representation matrix based on the first entity representations of at least part of the anchor entities and the first relationship representations of each relationship edge; The first representation matrix is input into a representation encoding model to obtain a second entity representation.
10. The method according to claim 9, before constructing the first characterization matrix, the method further comprises: In the business processing stage, determining the path distance between each anchor entity in the partial anchor entities and the first target entity in the knowledge graph; Based on a preset mapping function, each path distance is mapped into a path distance representation; Based on the sum of the first entity representation and the path distance representation of each anchor entity, the first entity representation of each anchor entity is updated.
11. The method according to claim 9, wherein: The representation encoding model includes at least one of the following: a multi-layer perceptron model and a Transformer model.
12. A business processing device based on knowledge graph, comprising: A first encoding unit is configured to, in an offline stage, use a target encoder to encode the knowledge graph to obtain a first entity representation of each entity therein; the knowledge graph includes entities representing users and items; The clustering unit is configured to, in an offline stage, perform prototype clustering based on each first entity representation to obtain a plurality of cluster centers; An anchor point determination unit is configured to, in an offline stage, determine several entities that are close to each cluster center as anchor point entities, and store relevant data of the anchor point entities as anchor point data sets; The second encoding unit is configured to, in a business processing phase, respond to a processing request containing a first target entity, determine a second entity representation of the first target entity based on a first entity representation of at least some of the anchor entities in the anchor data set formed in an offline phase, and a relationship edge between the first target entity and at least some of the anchor entities; the second entity representation is used to recommend items to a user.
13. The device according to claim 12, wherein: The processing request further includes a second target entity; the first target entity and the second target entity correspond to a first user and a first item respectively; the device further includes: A third encoding unit is configured to, during a business processing phase, determine a second entity representation of the second target entity according to the anchor data set; The recommendation unit is configured to, during a business processing phase, input the second entity representations of the first target entity and the second target entity into a recommendation model, and determine whether to recommend the first item to the first user based on an output result.
14. The apparatus according to claim 12, further comprising: A distance determination unit, configured to determine, in a business processing stage, a path distance between each anchor entity in the partial anchor entities and the first target entity in the knowledge graph; A mapping unit configured to, during a business processing phase, map each path distance into a path distance representation based on a preset mapping function; The representation updating unit is configured to update the first entity representation of each anchor point entity based on the sum of the first entity representation and the path distance representation of each anchor point entity during the service processing stage.
15. A computer-readable storage medium having a computer program stored thereon, which, when executed in a computer, causes the computer to execute the method according to any one of claims 1 to 11.
16. A computing device comprising a memory and a processor, wherein: The memory stores executable codes, and when the processor executes the executable codes, the method according to any one of claims 1 to 11 is implemented.
