Data processing method and device, electronic equipment, computer readable storage medium and computer program product
Through hierarchical clustering and mapping processing, the problem of training entities and relationships in the same semantic space is solved, achieving more accurate entity relationship expression and improving model generalization capabilities.
Patent Information
- Application Number
- CN202510152945.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-11
- Publication Date
- 2025-09-23
AI Technical Summary
In existing technologies, entities and relationships are trained in the same semantic space, which limits the ability to model entities and relationships and makes it impossible to accurately express entity features and relationship features.
Through hierarchical clustering processing, hierarchical clustering is performed based on the entity relationship features of the positive sample pairs, mapping processing is performed using relationship mapping parameters, and the relationship and entity features are optimized and updated through the loss function to achieve hierarchical structure expression.
It improves the generalization ability of entity features and relationship features, enhances the adaptability and generalization ability of unknown data, and improves the expression ability of the model in complex relationships.
Smart Images

Figure CN120687845A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a data processing method, device, electronic device, computer-readable storage medium, and computer program product. Background Art
[0002] Related technologies improve the performance of knowledge graph representation learning by mapping entities and relationships to different spaces and using relationship mapping matrices to process complex knowledge graph structures. However, during the parameter training process of related technologies, entities and relationships are still in the same semantic space, which limits the ability to model entities and relationships, and therefore entity features and relationship features cannot be accurately expressed. Summary of the Invention
[0003] The embodiments of the present application provide a data processing method, device, electronic device, computer-readable storage medium, and computer program product, which can better express the hierarchical structure of relationships and enable the model to accurately capture the relationships between entities.
[0004] The technical solution of the embodiment of the present application is implemented as follows:
[0005] The present invention provides a data processing method, including:
[0006] Based on the entity relationship features corresponding to each positive sample pair in the positive sample pair set, hierarchical clustering is performed on the positive sample pair set to obtain clusters distributed at each clustering level;
[0007] Based on the relationship mapping parameters corresponding to the first cluster in the first clustering level, mapping processing is performed on the two entities included in the first positive sample pair in the first cluster to obtain a first entity feature and a second entity feature of the first positive sample pair;
[0008] Determining a loss function corresponding to the first positive sample pair in the first clustering level based on the entity relationship feature corresponding to the first cluster and the first entity feature and the second entity feature of the first positive sample pair;
[0009] Determining a loss function of the first clustering level based on the loss function corresponding to each of the positive sample pairs in the first clustering level;
[0010] Based on the loss function of the first clustering level, the relationship mapping parameters of each cluster in the first clustering level and the entity relationship features of each cluster in the first clustering level are updated to obtain the updated relationship mapping parameters of each cluster in the first clustering level and the updated entity relationship features of each cluster in the first clustering level.
[0011] The present application also provides a data processing method, including:
[0012] Determining the silhouette coefficient of the first sample pair at each clustering level, wherein each clustering level is obtained by the above-mentioned data processing method;
[0013] Taking the clustering level with the largest silhouette coefficient as the optimal clustering level for the first sample pair;
[0014] determining a second cluster to which the first sample pair belongs in the optimal clustering level;
[0015] determining, based on the updated relationship mapping parameters of the second cluster, a fifth entity feature of the first entity and a sixth entity feature of the second entity included in the first sample pair, wherein the updated relationship mapping parameters of the second cluster are obtained by the above-mentioned data processing method;
[0016] The updated entity relationship feature of the second cluster is used as the entity relationship feature between the first entity and the second entity, wherein the updated entity relationship feature of the second cluster is obtained by processing the data processing method described above.
[0017] The present application also provides a data processing method, including:
[0018] Based on the interactive entity relationship features of each positive sample pair in the positive sample pair set, hierarchical clustering is performed on the positive sample pair set to obtain clusters distributed at each clustering level, where the positive sample pair set involves T types of interactive relationships, and the T types of interactive relationships correspond to T interactive relationship mapping parameters and T interactive entity relationship features, where T is a positive integer;
[0019] Based on the T interaction relationship mapping parameters corresponding to the first cluster in the first clustering level, mapping processing is performed on the object entity and the information entity included in the first positive sample pair in the first cluster to obtain T first object features of the object entity and T first information features of the information entity of the first positive sample pair;
[0020] determining a loss function for the first clustering level based on the loss function corresponding to the first positive sample pair in the first clustering level;
[0021] Based on the loss function of the first clustering level, the T interactive relationship mapping parameters of each cluster in the first clustering level and the T interactive entity relationship features of each cluster in the first clustering level are updated to obtain T updated interactive relationship mapping parameters of each cluster in the first clustering level and T updated interactive entity relationship features of each cluster in the first clustering level.
[0022] The present application also provides a data processing method, including:
[0023] Determining the silhouette coefficient of the first sample pair at each clustering level, wherein each clustering level is obtained by the above-mentioned data processing method;
[0024] Taking the clustering level with the largest silhouette coefficient as the optimal clustering level for the first sample pair;
[0025] determining a second cluster to which the first sample pair belongs in the optimal clustering level;
[0026] Determining T second object features of the first object entity and T second information features of the first information entity included in the first sample pair based on the T updated interaction relationship mapping parameters of the second cluster, wherein the T updated interaction relationship mapping parameters of the second cluster are obtained by the above-mentioned data processing method;
[0027] The T updated interactive entity relationship features of the second cluster are used as the T interactive entity relationship features between the first object entity and the first information entity, wherein the T updated interactive entity relationship features of the second cluster are obtained by processing the above-mentioned data processing method.
[0028] Determining a matching degree between the T interactive relationships and the first sample pair based on the T second object features of the first object entity, the T second information features of the first information entity, and the T interactive entity relationship features between the first object entity and the first information entity;
[0029] Based on the matching degree between the T types of interactive relationships and the first sample pair, recommendation processing is performed on the first sample pair.
[0030] An embodiment of the present application provides a data processing device, including:
[0031] A first processing module is configured to perform hierarchical clustering processing on the positive sample pair set based on the entity relationship features corresponding to each positive sample pair in the positive sample pair set, to obtain clusters distributed at each clustering level;
[0032] A second processing module is configured to perform mapping processing on two entities included in a first positive sample pair in the first cluster based on the relationship mapping parameter corresponding to the first cluster in the first clustering hierarchy, to obtain a first entity feature and a second entity feature of the first positive sample pair;
[0033] A first determining module is configured to determine a loss function corresponding to the first positive sample pair in the first clustering level based on the entity relationship feature corresponding to the first cluster and the first entity feature and the second entity feature of the first positive sample pair;
[0034] The first determining module is further configured to determine a loss function of the first clustering level based on a loss function corresponding to each of the positive sample pairs in the first clustering level;
[0035] An updating module is used to update the relationship mapping parameters of each cluster in the first clustering level and the entity relationship features of each cluster in the first clustering level based on the loss function of the first clustering level, so as to obtain the updated relationship mapping parameters of each cluster in the first clustering level and the updated entity relationship features of each cluster in the first clustering level.
[0036] The present application also provides a data processing device, including:
[0037] A second determining module is configured to respectively determine the silhouette coefficient of the first sample pair at each clustering level, wherein each clustering level is obtained by the above-mentioned data processing method;
[0038] a third processing module, configured to use the clustering level with the largest silhouette coefficient as the optimal clustering level for the first sample pair;
[0039] a third determining module, configured to determine a second cluster to which the first sample pair belongs in the optimal clustering level;
[0040] a fourth determining module, configured to determine a fifth entity feature of the first entity and a sixth entity feature of the second entity included in the first sample pair based on the updated relationship mapping parameters of the second cluster, wherein the updated relationship mapping parameters of the second cluster are obtained by the above-mentioned data processing method;
[0041] The fourth processing module is configured to use the updated entity relationship feature of the second cluster as the entity relationship feature between the first entity and the second entity, wherein the updated entity relationship feature of the second cluster is obtained by the above-mentioned data processing method.
[0042] The present application also provides a data processing device, including:
[0043] The first processing module is further configured to perform hierarchical clustering processing on the positive sample pair set based on the interactive entity relationship features of each positive sample pair in the positive sample pair set to obtain clusters distributed at each clustering level, wherein the positive sample pair set involves T types of interactive relationships, and the T types of interactive relationships correspond to T interactive relationship mapping parameters and T interactive entity relationship features, where T is a positive integer;
[0044] The second processing module is further configured to perform mapping processing on the object entity and the information entity included in the first positive sample pair in the first cluster based on the T interaction relationship mapping parameters corresponding to the first cluster in the first clustering level, to obtain T first object features of the object entity and T first information features of the information entity of the first positive sample pair;
[0045] The first determining module is further configured to determine a loss function corresponding to the first positive sample pair in the first clustering level based on the T interactive entity relationship features corresponding to the first cluster, and the T first object features and T first information features of the first positive sample pair;
[0046] The first determining module is further configured to determine a loss function of the first clustering level based on a loss function corresponding to the first positive sample pair in the first clustering level;
[0047] The update module is also used to update the T interactive relationship mapping parameters of each cluster in the first clustering level and the T interactive entity relationship features of each cluster in the first clustering level based on the loss function of the first clustering level, to obtain T updated interactive relationship mapping parameters of each cluster in the first clustering level and T updated interactive entity relationship features of each cluster in the first clustering level.
[0048] The present application also provides a data processing device, including:
[0049] The second determining module is further configured to determine the silhouette coefficient of the first sample pair at each clustering level, wherein each clustering level is obtained by the above-mentioned data processing method;
[0050] The third processing module is further configured to use the clustering level with the largest silhouette coefficient as the optimal clustering level for the first sample pair;
[0051] The third determining module is further configured to determine the second cluster to which the first sample pair belongs in the optimal clustering level;
[0052] The fourth determining module is further configured to determine T second object features of the first object entity and T second information features of the first information entity included in the first sample pair based on the T updated interaction relationship mapping parameters of the second cluster, wherein the T updated interaction relationship mapping parameters of the second cluster are obtained by the above-mentioned data processing method;
[0053] The fourth processing module is further used to use the T updated interactive entity relationship features of the second cluster as the T interactive entity relationship features between the first object entity and the first information entity, wherein the T updated interactive entity relationship features of the second cluster are obtained by processing using the above-mentioned data processing method.
[0054] a fifth determining module, configured to determine a matching degree between the T interactive relationships and the first sample pair based on the T second object features of the first object entity, the T second information features of the first information entity, and the T interactive entity relationship features between the first object entity and the first information entity;
[0055] A recommendation module is used to perform recommendation processing on the first sample pair based on the matching degree between the T types of interactive relationships and the first sample pair.
[0056] An embodiment of the present application provides an electronic device, including:
[0057] a memory for storing computer-executable instructions or computer programs;
[0058] The processor is used to implement the data processing method provided in the embodiment of the present application when executing the computer-executable instructions or computer programs stored in the memory.
[0059] An embodiment of the present application provides a computer-readable storage medium storing a computer program or computer-executable instructions, which is used to implement the data processing method provided in the embodiment of the present application when executed by a processor.
[0060] An embodiment of the present application provides a computer program product, including a computer program or computer-executable instructions. When the computer program or computer-executable instructions are executed by a processor, the data processing method provided in the embodiment of the present application is implemented.
[0061] The embodiments of the present application have the following beneficial effects:
[0062] First, according to the entity relationship features corresponding to each positive sample pair in the positive sample pair set, the positive sample pair set is hierarchically clustered to obtain clusters distributed in each clustering level, which helps to discover the hierarchical structure and complex relationships in the data; then, in the first clustering level, according to the relationship mapping parameters corresponding to the first cluster, the two entities included in the first positive sample pair in the first cluster are mapped separately to obtain the first entity feature and the second entity feature of the first positive sample pair, and projected from the entity space to the relationship space through the relationship mapping parameters, that is, each entity has a representation in the relationship, and since the clustering here is hierarchical clustering, considering that the relationship also has a hierarchical structure, the extracted entity features can conform to the hierarchical structure of the relationship; then, according to the entity features of the positive sample pairs in the first clustering level and the entity relationship features of the corresponding clusters, a special loss function is constructed for hierarchical optimization, and then by iteratively updating the relationship mapping parameters of each cluster in the first clustering level and the entity relationship features of each cluster in the first clustering level, the generalization ability of the entity feature and relationship feature expression can be improved. In summary, hierarchical clustering processing is performed through this scheme to enhance the adaptability and generalization ability of unknown data. BRIEF DESCRIPTION OF THE DRAWINGS
[0063] Figure 1 This is an example diagram of the knowledge graph provided in the embodiment of the present application;
[0064] Figure 2 Schematic diagram of the vector representation of the TransH model provided in the embodiment of the present application;
[0065] Figure 3 Schematic diagram of the vector representation of the TransR model provided in the embodiment of the present application;
[0066] Figure 4 1 is a schematic diagram of the architecture of a data processing system 100 provided in an embodiment of the present application;
[0067] Figure 5A is a structural diagram of an electronic device 500 provided in an embodiment of the present application;
[0068] Figure 5B 6 is a schematic structural diagram of an electronic device 600 provided in an embodiment of the present application;
[0069] Figure 6 Schematic diagram of the data processing method provided in the embodiment of the present application;
[0070] Figure 7 Schematic diagram of the data processing method provided in the embodiment of the present application;
[0071] Figure 8 Schematic diagram of the data processing method provided in the embodiment of the present application;
[0072] Figure 9 Schematic diagram of the data processing method provided in the embodiment of the present application;
[0073] Figure 10 Schematic diagram of the data processing method provided in the embodiment of the present application;
[0074] Figure 11 This is a process diagram of the data processing method provided in an embodiment of the present application;
[0075] Figure 12 It is a clustering dendrogram provided in an embodiment of the present application;
[0076] Figure 13 It is a process diagram of the data processing method provided in an embodiment of the present application. DETAILED DESCRIPTION
[0077] In order to make the purpose, technical solutions and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings. The described embodiments should not be regarded as limiting this application. All other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0078] In the following description, reference is made to “some embodiments”, which describes a subset of all possible embodiments, but it will be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0079] It is understandable that in the embodiments of the present application, when user information and other related data are involved, when the embodiments of the present application are applied to specific products or technologies, user permission or consent must be obtained, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards.
[0080] In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program that has 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] In the following description, the terms "first\second\..." are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It is understandable that "first\second\..." can be interchanged with a specific order or sequence where permitted, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.
[0082] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art to which this application pertains. The terms used herein are for the purpose of describing the embodiments of this application only and are not intended to limit this application.
[0083] Before further describing the embodiments of the present application in detail, the nouns and terms involved in the embodiments of the present application are explained. The nouns and terms involved in the embodiments of the present application are subject to the following interpretations.
[0084] 1) Knowledge Graph: See Figure 1 , Figure 1 This is an example diagram of the knowledge graph provided by the embodiment of this application. Figure 1 As shown in Figure 1, a knowledge graph is a technical approach that uses a graph to describe knowledge and model the relationships between things in the world. A knowledge graph consists of nodes and edges. Nodes can be entities, such as a person or a book, or abstract concepts, such as artificial intelligence or knowledge graphs. Edges can be attributes of an entity, such as a name or book title, or relationships between entities, such as friends or spouses.
[0085] 2) Knowledge graph triples: In a knowledge graph, each piece of knowledge can be decomposed into the following form: <subject, predicate, object>, where the subject and object are nodes in the graph, and the predicate is the relationship in the graph.
[0086] 3) Translation-based Embedding (TransE): TransE is a knowledge graph embedding representation algorithm that uses distributed vector representations of entities and relations to embed each triple instance.<head,relation,tail> The relation in is regarded as the sum of the vectors from the head entity head to the tail entity tail. By continuously adjusting h (i.e. the vector of the head entity head), r (i.e. the vector of the relation) and t (i.e. the vector of the tail entity tail), (h+r) is made equal to t as much as possible, that is, h+r=t.
[0087] 4) Euclidean distance: Euclidean distance refers to the true distance between two points in m-dimensional space, or the natural length of a vector (that is, the distance from the point to the origin). The Euclidean distance in two-dimensional and three-dimensional space is the actual distance between two points.
[0088] 5) L1 operation: L1 operation is to sum the absolute values of each element of the vector.
[0089] 6) L2 operation: The L2 operation is to sum the squares of each element in the vector and then take the square root.
[0090] 7) Entity relationship features: In the knowledge graph triple <subject, predicate, object>, the subject and object refer to the two entities referred to by the two nodes in the knowledge graph respectively. The predicate is the relationship between the two entities corresponding to the two connected nodes, which is equivalent to the entity relationship. In machine learning technology, two feature vectors are learned to represent the two entities, namely entity features. The feature vectors are also used to represent the entity relationship between the two entities, namely entity relationship features. The entity relationship features are obtained by subtracting the two entity features.
[0091] In TransE's knowledge graph embedding representation method, the entities and relationships in the knowledge graph are regarded as two matrices. The entity matrix structure is n×d1, where n represents the number of entities and d1 represents the dimension of each entity vector. The relationship matrix structure is r×d2, where r represents the number of relationships and d2 represents the dimension of each relationship vector. The ideal state of the TransE model after training is to extract a vector from the entity matrix and the relationship matrix respectively to perform L1 or L2 operations, and the obtained operation result is approximately the vector of the other entity in the entity matrix, that is, h+r=t is satisfied, thereby achieving the representation of the relationship of the existing triples (h, r, t) in the knowledge graph through word vectors.
[0092] In related technologies, the knowledge graph embedding representation method TransE only considers one entity relationship and ignores long-distance implicit relationships. For efficiency reasons, the corresponding functions and representations are overly simplified, resulting in the inability to model complex entities and entity relationships in the knowledge graph. Therefore, the knowledge graph embedding representation method TransH was derived. TransH mainly solves the problems of 1-to-many, many-to-1, and many-to-many. Figure 2 , Figure 2 is a vector representation diagram of the TransH model provided in the embodiment of the present application, such as Figure 2 As shown, the TransH model gives an entity relationship face w for each entity relationship r r , define the entity relationship vector d on the hyperplane r , after mapping the original head entity h and tail entity t onto the hyperplane, the mapped head entity h is obtained r and the mapped tail entity t r , and the mapped vector satisfies formula (1).
[0093] h r +dr =t r (1)
[0094] Although TransH gives different vector representations to entities with multiple relationships by using hyperplanes, the entities and relationships are still in the same semantic space, which limits the ability to model entities and relationships; therefore, the TransR embedding vector representation method is derived, see Figure 3 , Figure 3 is a vector representation diagram of the TransR model provided in the embodiment of the present application, such as Figure 3 As shown, TransR assumes that entities and relations are in different semantic spaces and projects h and t from the entity space to the relation space, that is, each entity has a representation in the relation, h r , t r It is the representation of entity vectors h and t in the corresponding vector space of r. The mapped vectors satisfy formula (2) and formula (3).
[0095] h r =hM r (2)
[0096] t r =tM r (3)
[0097] However, in the embedding vector TransR representation method, the same relation projection matrix M is used for all relations. r ,In real situations, different relations should have different relation projection matrices. Therefore, a CTransR representation method based on relation clustering is derived.
[0098] First, the entity vectors h and t are obtained through TransE model training. For a specific relationship r, all entity pairs (h, t) in the training data will be clustered into several groups. The entity pairs (h, t) in each group are similar in r relationship. The feature used for clustering is th. After clustering is completed, a specific relationship vector r is learned for each cluster. c , and learn a specific relation projection matrix M for each relation r However, during the training process of the CTransR model, a flat clustering algorithm is used to cluster the entity pairs (h, t) in the training data, without considering the hierarchical structure of the relationship. Therefore, the hierarchical relationship cannot be expressed correctly.
[0099] Based on this, embodiments of the present application provide a data processing method, apparatus, electronic device, computer-readable storage medium, and computer program product that can better express the hierarchical structure of relationships, enabling the model to more accurately capture the relationships between entities. The electronic device provided in embodiments of the present application can be implemented as a server, or implemented collaboratively by a server and a terminal. The following description will be given using an example of a data processing method provided in embodiments of the present application being implemented collaboratively by a server and a terminal.
[0100] For example, see Figure 4 , Figure 4 This is a schematic diagram of the architecture of the data processing system 100 provided in an embodiment of the present application, which is used to support a data processing application, such as Figure 4 As shown, the data processing system 100 includes: a server 200, a network 300, a terminal 400 and a database 600. The terminal 400 is connected to the server 200 via the network 300, and the server 200 is connected to the database 600. The network 300 can be a local area network or a wide area network, or a combination of the two; the database 600 is used to store structured data (such as various data such as entities and relationships).
[0101] In some embodiments, the server 200 may first obtain a set of positive sample pairs from the database 600; then, the server 200 performs hierarchical clustering processing on the positive sample pair set based on the entity relationship features corresponding to each positive sample pair in the positive sample pair set, and obtains clusters distributed in each clustering level; then, the server 200 performs mapping processing on the two entities included in the first positive sample pair in the first cluster based on the relationship mapping parameters corresponding to the first cluster in the first clustering level, and obtains the first entity feature and the second entity feature of the first positive sample pair; subsequently, the server 200 determines the first clustering level based on the entity relationship features corresponding to the first cluster and the first entity feature and the second entity feature of the first positive sample pair. The server 200 determines the loss function of the first positive sample pair in the first clustering level based on the loss function corresponding to each positive sample pair in the first clustering level; the server 200 updates the relationship mapping parameters of each cluster in the first clustering level and the entity relationship features of each cluster in the first clustering level based on the loss function of the first clustering level, and obtains the updated relationship mapping parameters of each cluster in the first clustering level and the updated entity relationship features of each cluster in the first clustering level; finally, the server 200 can also send the updated relationship mapping parameters and the updated entity relationship features to the terminal 400 through the network 300, and display them on the terminal 400.
[0102] It should be noted that the technical solutions provided in the embodiments of this application can be applied to various scenarios such as social network analysis, recommendation systems, bioinformatics, natural language processing, and intelligent question-answering systems.
[0103] In some embodiments, taking the recommendation system scenario as an example, first, based on the interactive entity relationship features of each positive sample pair in the positive sample pair set, the positive sample pair set is hierarchically clustered to obtain clusters distributed at each clustering level. The positive sample pair set involves T kinds of interactive relationships, and the T kinds of interactive relationships correspond to T interactive relationship mapping parameters and T interactive entity relationship features. T is a positive integer. The interactive entity relationship feature is a type of entity relationship feature. Different application scenarios involve different entity relationships, so the entity relationship features involved are different. However, no matter which entity relationship feature, the entity relationship feature of the sample pair is obtained by subtracting the entity features corresponding to the two entities in the sample pair. The entity relationship features used in the recommendation scenario are different. The entity relationship feature is actually the interactive entity relationship feature. When the relationship between two entities is an interactive relationship, the entity relationship feature of the two entities is the interactive entity relationship feature. The interactive relationship refers to the interaction or connection between the object entity and the information entity, for example, like, general like, dislike, etc.; then, based on the T interactive relationship mapping parameters corresponding to the first cluster in the first clustering level, the object entity (such as user) and the information entity (such as advertising information) included in the first positive sample pair in the first cluster are mapped respectively to obtain the T first object features of the object entity of the first positive sample pair and the T first information features of the information entity. Usually, in the recommendation scenario, it is necessary to recommend information to the user. The object entity here is The entity represents the object in the recommendation scenario, that is, the user, and the information entity represents the information that needs to be recommended to the user, such as advertisements, products, news, etc.; then, based on the T interactive entity relationship features of the first cluster, and the T first object features and T first information features of the first positive sample pair, the loss function corresponding to the first positive sample pair in the first clustering level is determined; then, based on the loss function corresponding to the first positive sample pair in the first clustering level, the loss function of the first clustering level is determined; then, based on the loss function of the first clustering level, the T interactive relationship mapping parameters of each cluster in the first clustering level and the T interactive entity relationship features of each cluster in the first clustering level are updated to obtain each cluster in the first clustering level. The T updated interactive relationship mapping parameters and the T updated interactive entity relationship features of each cluster in the first clustering level are determined; then, the silhouette coefficient of the first sample pair in each clustering level is determined; then, the clustering level with the largest silhouette coefficient is used as the optimal clustering level for the first sample pair, and the second cluster to which the first sample pair belongs in the optimal clustering level is determined; then, based on the T updated interactive relationship mapping parameters of the second cluster, the T second object features of the first object entity and the T second information features of the first information entity included in the first sample pair are determined; then, the T updated interactive entity relationship features of the second cluster are used as the T interactive entity relationship features between the first object entity and the first information entity;Next, based on the T second object features of the first object entity, the T second information features of the first information entity, and the T interactive entity relationship features between the first object entity and the first information entity, the matching degree between the T interactive relationships and the first sample pair is determined. Finally, based on the matching degree between the T interactive relationships and the first sample pair, a recommendation process is performed on the first sample pair. This effectively improves the accuracy of information recommendations.
[0104] In some other embodiments, taking the natural language processing scenario as an example, first, based on the connection entity relationship features of each positive sample pair in the positive sample pair set, the positive sample pair set is hierarchically clustered to obtain clusters distributed at each clustering level, and the positive sample pair set involves T types of connection relationships, and the T types of connection relationships correspond to T connection relationship mapping parameters and T connection entity relationship features, where T is a positive integer; then, based on the T connection relationship mapping parameters corresponding to the first cluster in the first clustering level, the first information entity (for example, text 1) and the second information entity (for example, text 2) included in the first positive sample pair in the first cluster are clustered. 2) perform mapping processing respectively to obtain T first information features of the first information entity of the first positive sample pair and T second information features of the second information entity; then, based on the T connection relationship features of the first cluster, and the T first information features and T second information features of the first positive sample pair, determine the loss function corresponding to the first positive sample pair in the first clustering level; then, based on the loss function corresponding to the first positive sample pair in the first clustering level, determine the loss function of the first clustering level; then, based on the loss function of the first clustering level, the T connection relationship mapping parameters and The T connection relationship features of each cluster in the first clustering level are updated to obtain T updated connection relationship mapping parameters of each cluster in the first clustering level and T updated connection relationship features of each cluster in the first clustering level; then, the silhouette coefficient of the first sample pair in each clustering level is determined; then, the clustering level with the largest silhouette coefficient is used as the optimal clustering level of the first sample pair, and the second cluster to which the first sample pair belongs in the optimal clustering level is determined; then, based on the T updated connection relationship mapping parameters of the second cluster, the T third information entities of the third information entity included in the first sample pair are determined. The method uses the T updated connected entity relationship features of the second cluster as the T connection relationship features between the third information entity and the fourth information entity. The method then determines the matching degree between the T connection relationships and the first sample pair based on the T third information features of the third information entity, the T fourth information features of the fourth information entity, and the T connection relationship features between the third and fourth information entities. Finally, the method determines the optimal connection relationship between the third and fourth information entities based on the matching degree between the T connection relationships and the first sample pair. This helps the model better understand the relationship between contexts, thereby improving the model's text processing performance.
[0105] For example, Figure 4The server 200 in the example 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, content delivery networks (CDNs), and big data and artificial intelligence platforms. The terminal 400 can be a smart phone, tablet computer, laptop computer, desktop computer, smart speaker, smart watch, car terminal, etc., but is not limited to these. The terminal 400 and the server 200 can be directly or indirectly connected via wired or wireless communication, which is not limited in the embodiments of the present application.
[0106] In some embodiments, the server includes a hard disk, a memory, and a processor, and a plurality of positive sample pairs are stored in the hard disk. When the server receives a hierarchical clustering processing instruction, the plurality of positive sample pairs stored in the hard disk are read into the memory, and the processor executes the data processing method provided by the embodiment of the present application in the memory to obtain the updated relationship mapping parameters and updated entity relationship features of the clusters distributed at each clustering level, and then the updated relationship mapping parameters and updated entity relationship features of the clusters distributed at each clustering level are continued to be stored in the hard disk. In the related art, one relationship mapping parameter and one entity relationship feature are used for all positive sample pairs. Each time the parameters are updated, the same relationship mapping parameter and entity relationship feature are used for mapping processing, resulting in the hardware resources of the hard disk and memory not being effectively utilized. However, the present application uses different relationship mapping parameters and entity relationship features to map different sample pairs, which can better express the hierarchical structure of the relationship, thereby making full use of the hardware resources of the hard disk and memory and improving the utilization rate of hardware resources.
[0107] In practical applications, the two entities in the positive sample pair can be different servers in the field of network security, for example, 100 entities corresponding to 100 servers respectively. Based on the entity relationship features of each positive sample pair in the positive sample pair set constructed from the 100 entities, the positive sample pair set is hierarchically clustered to obtain clusters distributed in each clustering level; then, based on the relationship mapping parameters corresponding to the first cluster in the first clustering level, the two entities included in the first positive sample pair in the first cluster are mapped respectively to obtain the first entity feature and the second entity feature of the first positive sample pair; then, based on the entity relationship features of the first cluster and the first entity feature and the second entity feature of the first positive sample pair, the loss function corresponding to the first positive sample pair in the first clustering level is determined; then, based on the loss function corresponding to each positive sample pair in the first clustering level, the first positive sample pair is determined. The loss function of the clustering level is then calculated. Then, based on the loss function of the first clustering level, the relationship mapping parameters of each cluster in the first clustering level and the entity relationship features of each cluster in the first clustering level are updated to obtain the updated relationship mapping parameters and updated entity relationship features of each cluster in the first clustering level. Then, the silhouette coefficient of the first sample pair at each clustering level is determined. Subsequently, the clustering level with the largest silhouette coefficient is used as the optimal clustering level for the first sample pair. After that, the second cluster to which the first sample pair belongs in the optimal clustering level is determined. Finally, based on the updated relationship mapping parameters of the second cluster, the fifth entity feature of the first entity of the first sample pair and the sixth entity feature of the second entity are determined, and the updated entity relationship features of the second cluster are used as the entity relationship features between the first entity and the second entity. For example, if there is an unknown relationship between two servers, the relationship between the two unknown servers can be accurately predicted based on the relationship between the known positive sample pairs consisting of 100 servers, thereby clarifying the entity relationship between the two unknown servers, which can effectively improve business processing efficiency.
[0108] The following continues to describe the structure of the electronic device provided in the embodiment of the present application. Take the electronic device as an example, see Figure 5A , Figure 5A is a structural diagram of an electronic device 500 provided in an embodiment of the present application, Figure 5A The electronic device 500 shown includes: at least one processor 510, a memory 540, and at least one network interface 520. The various components in the electronic device 500 are coupled together via a bus system 530. It is understood that the bus system 530 is used to achieve connection and communication between these components. In addition to the data bus, the bus system 530 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clarity, the bus system 530 is not described in detail. Figure 5A Various buses are labeled as bus system 530 .
[0109] The processor 510 can be an integrated circuit chip with signal processing capabilities, such as a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc., where the general-purpose processor can be a microprocessor or any conventional processor, etc.
[0110] The memory 540 may be removable, non-removable, or a combination thereof. Exemplary hardware devices include solid-state memory, hard drives, optical drives, etc. The memory 540 may optionally include one or more storage devices that are physically remote from the processor 510.
[0111] The memory 540 includes volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. The non-volatile memory may be a read-only memory (ROM), and the volatile memory may be a random access memory (RAM). The memory 540 described in the embodiments of the present application is intended to include any suitable type of memory.
[0112] In some embodiments, the memory 540 can store data to support various operations, examples of which include programs, modules, and data structures, or a subset or superset thereof, as exemplified below.
[0113] Operating system 541, including system programs for processing various basic system services and performing hardware-related tasks, such as the framework layer, core library layer, and driver layer, which are used to implement various basic services and process hardware-based tasks;
[0114] A network communication module 542 for reaching other computing devices via one or more (wired or wireless) network interfaces 520 , exemplary network interfaces 520 including Bluetooth, Wireless LAN (WiFi), and Universal Serial Bus (USB);
[0115] In some embodiments, the apparatus provided in the embodiments of the present application may be implemented in software. Figure 5A A data processing device 543 stored in the memory 540 is shown, which can be software in the form of programs and plug-ins, etc., including the following software modules: a first processing module 5431, a second processing module 5432, a first determination module 5433 and an update module 5434. These modules are logical and can therefore be arbitrarily combined or further split according to the functions implemented.
[0116] The structure of the electronic device for implementing the data processing method provided in the embodiment of the present application is further described below. Taking the electronic device 600 as an example, see Figure 5B , Figure 5B is a structural diagram of an electronic device 600 provided in an embodiment of the present application, Figure 5B The electronic device 600 shown includes a data processing device 643, which can be software in the form of programs and plug-ins, including the following software modules: a second determination module 6431, a third processing module 6432, a third determination module 6433, a fourth determination module 6434 and a fourth processing module 6435. These modules are logical and can therefore be arbitrarily combined or further split according to the functions implemented.
[0117] It should be noted that Figure 5B The electronic device 600 shown includes a processor 610, a network interface 620, a bus system 630, an operating system 641, and a network communication module 642. Figure 5A The corresponding modules included in have the same structure and the same function, and the embodiments of the present application will not be repeated here.
[0118] The data processing method provided in the embodiment of the present application will be described in detail below in combination with the exemplary application and implementation of the server provided in the embodiment of the present application.
[0119] See also Figure 6 , Figure 6 This is a flow chart of the data processing method provided in the embodiment of the present application, which will be combined with Figure 6 The steps shown are explained.
[0120] In step 101, hierarchical clustering is performed on the positive sample pair set based on the entity relationship features corresponding to each positive sample pair in the positive sample pair set to obtain clusters distributed at each clustering level.
[0121] It should be noted that the positive sample pair includes two entities with a relationship. The positive sample pair can be obtained from two entities with an existence relationship obtained from a knowledge graph constructed based on historical data, or from two entities with an existence relationship obtained from a database storing historical data. No specific limitation is made here. During hierarchical clustering processing, each clustering can select an appropriate number (for example, 2, 3, 4, or other integers greater than 1) of positive sample pairs for clustering based on the entity relationship characteristics, or multiple positive sample pairs can be selected from the positive sample pair set at the same time for clustering separately based on the entity relationship characteristics (for example, there are 4 positive sample pairs A, B, C, and D in the positive sample pair set. When performing the first clustering, A and B can be selected for clustering, and C and D can be selected for clustering at the same time). The specific clustering method can be determined according to actual needs and is not specifically limited here.
[0122] In some embodiments, the two entities included in the positive sample pair can be two entities with the same attributes, for example, both entities are text, or they can be two entities with different attributes, for example, one entity is a user and the other entity is recommended product information. The specific attributes can be determined according to actual needs and are not specifically limited here.
[0123] As an example, suppose there are 5 positive sample pairs in the positive sample pair set, namely A, B, C, D, and E, and the corresponding entity relationship features are a, b, c, d, and e respectively. The 5 positive sample pairs in the positive sample pair set are hierarchically clustered according to the entity relationship features. In the first clustering level, the number of clusters is consistent with the number of positive sample pairs, that is, the number of clusters is 5 (including A, B, C, D, and E); in the second clustering level, the positive sample pair A and the positive sample pair B are clustered according to the entity relationship features to obtain cluster AB, that is, the number of clusters in the second clustering level is 4 (including AB, C, D, and E); similarly, in the third clustering level, In the class hierarchy, the positive sample pair C and the positive sample pair D are clustered to obtain cluster CD, that is, the number of clusters in the third clustering level is 3 (including AB, CD and E); similarly, in the fourth clustering level, cluster AB and cluster CD are clustered to obtain cluster ABCD, that is, the number of clusters in the fourth clustering level is 2 (including ABCD and E); finally, in the fifth clustering level, clusters ABCD and E are clustered to obtain cluster ABCDE, that is, the number of clusters in the fifth clustering level is 1, and clustering cannot be continued. The hierarchical clustering ends. Through hierarchical clustering processing, 15 clusters distributed in 5 clustering levels are obtained.
[0124] In another example, assuming that there are 5 positive sample pairs in the positive sample pair set, namely A, B, C, D, and E, and the corresponding entity relationship features are a, b, c, d, and e, respectively, hierarchical clustering is performed on the 5 positive sample pairs in the positive sample pair set according to the entity relationship features. In the first clustering level, the number of clusters is consistent with the number of positive sample pairs, that is, the number of clusters is 5 (including A, B, C, D, and E); in the second clustering level (i.e., the first clustering), the positive sample pair A and the positive sample pair B can be clustered according to the entity relationship features. Cluster AB is obtained, and the positive sample pair C and the positive sample pair D are clustered to obtain cluster CD, that is, the number of clusters in the second clustering level is 3 (including AB, CD and E); similarly, in the third clustering level (that is, the second clustering), cluster AB, cluster CD and the positive sample pair E are clustered to obtain cluster ABCDE, that is, the number of clusters in the third clustering level is 1 (including ABCDE), and clustering cannot be continued. The hierarchical clustering ends, and through hierarchical clustering processing, 8 clusters distributed in 3 clustering levels are obtained.
[0125] In some embodiments, see Figure 7 , Figure 7 is a flow chart of the data processing method provided in the embodiment of the present application, such as Figure 7 As shown, Figure 6 Step 101 shown can be performed by Figure 7 Steps 1011 to 1013 shown are implemented by combining Figure 7 The steps shown are explained.
[0126] In step 1011 , based on the entity relationship features corresponding to each positive sample pair, clustering processing is performed on the two target clusters in the cluster set belonging to the mth clustering level to obtain a cluster set belonging to the m+1th clustering level.
[0127] Here, the number of clusters included in the cluster set belonging to the mth clustering level is p, p is an integer greater than 1, m is an integer variable whose value increases from 1, and the value range of m is 1≤m.
[0128] As an example, suppose there are three positive sample pairs A, B, and C, and the corresponding entity relationship features are a, b, and c respectively. Assuming m is 1, the cluster set of the first clustering level is {A, B, C}, that is, the number of clusters p included in the cluster set of the first clustering level is 3, A and B are the target clusters for clustering in the cluster set, and cluster A and B are clustered to obtain cluster AB, and the cluster set of the second clustering level is {AB, C}, that is, the number of clusters p included in the cluster set of the second clustering level is 2.
[0129] In some embodiments, the above step 1011 can be implemented in the following manner: based on the entity relationship features corresponding to each positive sample pair, determine the cluster features of p clusters belonging to the mth clustering level; based on the cluster features of the p clusters belonging to the mth clustering level, determine the distance between any two clusters in the p clusters; select the two clusters corresponding to the minimum distance as the two target clusters, and merge the two target clusters to obtain a new cluster; combine the new cluster with the other clusters in the p clusters except the two target clusters to obtain a cluster set belonging to the m+1th clustering level. In this way, by processing data through layer-by-layer aggregation, the inherent relationships and hierarchical structure of the data can be better understood, providing richer reference information for further processing of subsequent data.
[0130] As an example, suppose there are three positive sample pairs A(A1, A2), B(B1, B2), and C(C1, C2). Here, A1, A2, B1, B2, C1, and C2 are two entities contained in the three positive sample pairs, and the entity relationship features corresponding to the three positive sample pairs are a, b, and c, respectively, where a=A1-A2, b=B1-B2, and c=C1-C2. The clustering features of the three clusters (i.e., A, B, and C) contained in the first clustering level are a, b, and c, respectively. Next, the distance between any two clusters in the three clusters is calculated. Here, the Euclidean distance between the two clusters can be calculated, or the Manhattan distance between the two clusters can be calculated. The specific distance can be determined according to specific needs and is not specifically limited here. The distance d between different clusters is finally obtained by calculation. AB d AC and d BC , and select the two clusters with the smallest distance as the target clusters to merge (assuming that A and B are merged) to obtain a new cluster AB; finally, the new cluster AB is combined with other cluster C to obtain the cluster set {AB, C} of the second clustering level.
[0131] In step 1012 , clustering is continued on the two target clusters in the cluster set belonging to the m+1th clustering level based on the entity relationship features of each positive sample pair.
[0132] Here, the number of clusters included in the cluster set belonging to the m+1th clustering level is p-1. When m is 1, the cluster set belonging to the mth clustering level is a cluster set composed of clusters corresponding to each positive sample pair, and the clusters corresponding to the positive sample pairs are initialized by the positive sample pairs.
[0133] It should be noted that the implementation of clustering the two target clusters in the cluster set belonging to the m+1th clustering level in step 1012 is similar to the implementation in step 1011. For details, please refer to the implementation of step 1011 and will not be repeated here.
[0134] In step 1013 , the cluster sets belonging to multiple clustering levels obtained when the clustering stop condition is met are disassembled to obtain clusters distributed at each clustering level.
[0135] As an example, suppose there are 3 positive sample pairs A, B, and C in the positive sample pair set. Through hierarchical clustering processing, the cluster set of the first clustering level is {A, B, C}, the cluster set of the second clustering level is {AB, C}, and the cluster set of the third clustering level is {ABC}. Then the cluster sets of the three clustering levels are disassembled to obtain 5 clusters distributed in the three clustering levels (including A, B, C, AB, ABC).
[0136] In summary, by adopting a hierarchical clustering scheme, we can better capture the hierarchical relationships between relationships, improve the accuracy and efficiency of clustering, and enhance the interpretability and flexibility of clustering, so that the processed data can be better applied to other data analysis scenarios.
[0137] In some embodiments, after executing step 1013, the following processing may be performed: if the number of clusters included in the cluster set at the m+1th cluster level is 1, then the clustering stopping condition is determined to be satisfied; or if the number of cluster levels reaches a first threshold, then the clustering stopping condition is determined to be satisfied. In this way, the risk of infinite loops or overfitting can be effectively avoided, ensuring the effectiveness of the algorithm and the reliability of the results.
[0138] In some embodiments, the above-mentioned step 101 can also be implemented in the following manner: based on the entity relationship features corresponding to each positive sample pair, the target cluster in the cluster set belonging to the m-th clustering level is split to obtain the cluster set belonging to the m+1-th clustering level; wherein, the number of clusters included in the cluster set belonging to the m-th clustering level is q, q is a positive integer, m is an integer variable whose value increases from 1, and the value range of m is 1≤m; continue to split the target cluster in the cluster set belonging to the m+1-th clustering level based on the entity relationship features of each positive sample pair; wherein, the number of clusters included in the cluster set belonging to the m+1-th clustering level is p+1, when m is 1, the cluster set belonging to the m-th clustering level is a cluster set composed of 1 cluster, and 1 cluster is obtained by initializing clustering of N positive sample pairs; the cluster sets belonging to multiple clustering levels obtained when the clustering stop condition is met are disassembled to obtain clusters distributed at each clustering level. In this way, by processing data in a layer-by-layer splitting manner, we can also better understand the internal relationships and hierarchical structure of the data, and provide richer reference information for subsequent data processing.
[0139] It should be noted that the method of determining the target cluster from the cluster set for splitting can be by calculating the distance and selecting the two clusters with the farthest distance in the cluster for splitting, or by selecting the two clusters that can maximize the variance for splitting. The specific splitting method can be determined according to actual needs and is not specifically limited here.
[0140] As an example, suppose there are 3 positive sample pairs A, B, and C, and the corresponding entity relationship features are a, b, and c respectively. Assuming m is 1, the cluster set of the first clustering level is {ABC}, that is, the number of clusters included in the cluster set of the first clustering level is 1, ABC is the target cluster for splitting in the cluster set, and ABC is split to obtain cluster AB and cluster C. The cluster set of the second clustering level is {AB, C}, that is, the number of clusters included in the cluster set of the second clustering level is 2; then, when m=2, assuming AB is the target cluster for splitting in the cluster set, AB is split to obtain cluster A and cluster B, the cluster set of the third clustering level is {A, B, C}, that is, the number of clusters included in the cluster set of the third clustering level is 3; finally, the cluster sets of the three clustering levels are disassembled to obtain 5 clusters distributed in 3 clustering levels (including A, B, C, AB, ABC).
[0141] In some embodiments, after splitting the cluster sets at multiple clustering levels obtained when the clustering stop condition is met to obtain clusters distributed at each clustering level, the following processing may be performed: if the number of clusters included in the cluster set at the m+1th clustering level is N, then the splitting stop condition is determined to be met; or if the number of cluster levels reaches a first number threshold, then the splitting stop condition is determined to be met. In this way, the risk of infinite loops or overfitting can be effectively avoided, ensuring the effectiveness of the algorithm and the reliability of the results.
[0142] In step 102, based on the relationship mapping parameters corresponding to the first cluster in the first clustering level, mapping processing is performed on the two entities included in the first positive sample pair in the first cluster to obtain the first entity feature and the second entity feature of the first positive sample pair.
[0143] Here, the first positive sample pair is any positive sample pair in the positive sample pair set, the first clustering level is any clustering level in multiple clustering levels, and the first cluster is the cluster to which the first positive sample pair belongs in the first clustering level.
[0144] As an example, assume that the first clustering level includes two clusters, one of which includes the positive sample pair A (h1, t1), and the corresponding relationship mapping parameter is M1, and the other cluster includes the positive sample pair B (h2, t2), and the corresponding relationship mapping parameter is M2. The two entities included in the positive sample pairs in each cluster are mapped separately, and the first entity feature corresponding to the positive sample pair A is h1M1, and the second entity feature is t1M1. The first entity feature corresponding to the positive sample pair B is h2M2, and the second entity feature is t2M2.
[0145] In some embodiments, after executing step 102, the following processing may also be performed: generating a negative sample pair corresponding one-to-one to each positive sample pair, wherein the negative sample pair includes two entities, the corresponding negative sample pair and the positive sample pair belong to the same cluster, and the entity relationship features of the negative sample pair are the same as the entity relationship features of the corresponding positive sample pair; based on the relationship mapping parameters corresponding to the first cluster in the first clustering level, the two entities included in the first negative sample pair are mapped separately to obtain the third entity feature and the fourth entity feature of the first negative sample pair, wherein the first negative sample pair is a negative sample pair having a corresponding relationship with the first positive sample pair. In this way, through the learning of positive and negative samples, the model can more clearly identify the differences between different entities and relationships, improve the discrimination of entities and relationships, and help the model more accurately capture the complex structure between entities and relationships, thereby improving the overall effect of knowledge graph representation learning.
[0146] It should be noted that the negative sample pair corresponding to the positive sample pair can be obtained by replacing any one entity included in the positive sample pair, or the negative sample pair corresponding to the positive sample pair can be obtained by replacing both entities included in the positive sample pair. The specific method can be determined according to actual needs and is not specifically limited here.
[0147] Continuing with the above example, construct a negative sample pair A0(h1, t3) corresponding to the positive sample pair A, and a negative sample pair B0(h2, t4) corresponding to the positive sample pair B, where there is no relationship between entity h1 and entity t3, and there is no relationship between entity h2 and entity t4. The relationship mapping parameter corresponding to the negative sample pair A0 is M1, and the relationship mapping parameter corresponding to the negative sample pair B0 is M2. Then the third entity feature corresponding to the negative sample pair A0 is h1M1, and the fourth entity feature is t3M1. The third entity feature corresponding to the negative sample pair B0 is h2M2, and the fourth entity feature is t4M2.
[0148] In step 103 , based on the entity relationship features corresponding to the first cluster and the first entity features and the second entity features of the first positive sample pair, a loss function corresponding to the first positive sample pair in the first clustering level is determined.
[0149] In some embodiments, step 103 described above can be implemented as follows: based on the entity relationship feature corresponding to the first cluster, mapping the first entity feature of the first positive sample pair to obtain the first mapping feature of the first positive sample pair; determining a first difference between the first mapping feature of the first positive sample pair and the second entity feature of the first positive sample pair, and determining a second difference between the entity relationship feature corresponding to the first cluster and the entity relationship feature corresponding to the first positive sample pair; fusing the first difference and the second difference to obtain a loss function corresponding to the first positive sample pair in the first clustering level. In this way, calculating the difference helps the model better understand the transformation of entity features and the relationship between entities, enhances feature representation, and provides feedback for model training by constructing a loss function, which helps optimize model parameters and improves the model's predictive ability.
[0150] As an example, assume that the first cluster includes a positive sample pair A, the corresponding first entity feature is h1M1, and the entity relationship feature of the corresponding cluster is r1. The first entity feature of the positive sample pair A is mapped, and the first mapping feature obtained is h1M1+r1; then, the first difference between the first mapping feature of the positive sample pair A and the second entity feature of the positive sample pair A is determined to be h1M1+r1-t1M1; then, the second difference r1-r between the entity relationship feature r1 of the cluster where the positive sample pair A is located and the entity relationship feature r of the positive sample pair A is determined; thereafter, the first difference h1M1+r1-t1M1 and the second difference r1-r of the positive sample pair A are fused, and the loss function f1 of the first positive sample pair can be obtained by referring to formula (4).
[0151]
[0152] Among them, h i and t i are the first entity feature and the second entity feature of the positive sample pair, respectively, h i +r j is the first mapping feature of the positive sample pair, r j is the entity relationship feature of the cluster where the positive sample pair is located, r i is the entity relationship feature of the positive sample pair, α is a hyperparameter, N is the number of positive sample pairs, It is the second norm of vector x, that is, the square root of the sum of the squares of the elements in vector x.
[0153] In step 104 , a loss function of the first clustering level is determined based on the loss function corresponding to each positive sample pair in the first clustering level.
[0154] As an example, assume that the first clustering level includes two positive sample pairs, the loss function of the first positive sample pair is f1, and the loss function of the second positive sample pair is f2. The loss functions of the two positive sample pairs are fused, and the loss function Loss of the first clustering level can be obtained by referring to formula (5).
[0155]
[0156] Among them, N is the number of positive sample pairs, f i is the loss function for the i-th positive sample pair.
[0157] In some embodiments, step 104 can also be implemented as follows: mapping the third entity feature of the first negative sample pair based on the entity relationship feature corresponding to the first cluster to which the first negative sample pair belongs to obtain a second mapping feature of the first negative sample pair; determining a third difference between the second mapping feature of the first negative sample pair and the fourth entity feature of the first negative sample pair, and determining a fourth difference between the entity relationship feature corresponding to the first cluster and the entity relationship feature of the first negative sample pair; fusing the third difference and the fourth difference to obtain a loss function corresponding to the first negative sample pair in the first clustering level; and determining a loss function for the first clustering level based on the loss function corresponding to each positive sample pair in the first clustering level and the loss function corresponding to each negative sample pair in the first clustering level. In this way, by processing the positive and negative sample pairs separately and calculating the difference between the two, the model can more accurately learn entity features and relationship features, providing a more robust method for clustering and relationship learning in the knowledge graph, and helping to improve model performance and the interpretability of clustering results.
[0158] It should be noted that the loss function calculation method of the first negative sample pair in the first clustering level is similar to the loss function calculation method of the first positive sample pair in the first clustering level mentioned above. For details, please refer to the calculation method of the loss function of the first positive sample pair in the first clustering level, which will not be repeated here.
[0159] As an example, the calculation method of the loss function of the positive sample pair in the above formula (3) can be referred to to calculate the loss function f of the positive sample pair and the loss function f' of the negative sample pair respectively. Referring to formula (6), the loss function corresponding to each positive sample pair in the first clustering level and the loss function corresponding to each negative sample pair in the first clustering level are fused to obtain the loss function Loss of the first clustering level.
[0160]
[0161] Among them, γ is a hyperparameter, f i is the first score corresponding to the positive sample pair, f′ i is the second score corresponding to the negative sample pair.
[0162] In step 105, based on the loss function of the first clustering level, the relationship mapping parameters of each cluster in the first clustering level and the entity relationship features of each cluster in the first clustering level are updated to obtain the updated relationship mapping parameters of each cluster in the first clustering level and the updated entity relationship features of each cluster in the first clustering level.
[0163] It should be noted that the loss function of each clustering level can be used to update the relationship mapping parameters and entity relationship features of the clusters in the clustering level. Based on the loss function of each clustering level, the relationship mapping parameters and entity relationship features of each cluster included in the current clustering level are updated to obtain the updated relationship mapping parameters and updated entity relationship features of each cluster included in the current clustering level.
[0164] In some embodiments, see Figure 8 , Figure 8 This is a flow chart of the data processing method provided in the embodiment of the present application, which will be combined with Figure 8 The steps shown are explained.
[0165] In step 201 , the silhouette coefficient of the first sample pair at each clustering level is determined.
[0166] Here, the first sample pair includes a first entity and a second entity, and each clustering level is obtained through the above step 101 .
[0167] In some embodiments, step 201 can be implemented by determining a first distance between the first sample pair and other positive sample pairs within the same cluster at the first clustering level; determining a second distance between the first sample pair and other clusters at the first clustering level; and determining a silhouette coefficient for the first sample pair at the first clustering level based on the first and second distances. In this way, the silhouette coefficient can provide a quantitative basis for interpreting clustering results, thereby better informing subsequent data selection and cluster analysis based on the silhouette coefficient.
[0168] As an example, when the cluster where the first sample pair is located includes itself and at least one other positive sample pair (that is, the cluster where the first sample pair is located includes at least two sample pairs), the first distance a(p) between the current first sample pair and other positive sample pairs in the same cluster in the first clustering level is calculated according to formula (7), and the second distance b(p) between the first sample pair and other clusters in the first clustering level is calculated according to formula (8). Finally, the silhouette coefficient s(p) of the first sample pair at the first clustering level is calculated based on the first distance and the second distance according to formula (9).
[0169]
[0170] Among them, p refers to the first sample pair, p′ refers to other positive sample pairs in the same cluster as the first sample pair, and C i refers to the cluster where the first sample pair is located, d(p,p′) refers to the distance between the first sample pair and other positive sample pairs in the same cluster, |C i | refers to the number of sample pairs in the cluster where the first sample pair is located. Both i and j are greater than or equal to 1 and less than or equal to the number of clusters contained in the current clustering level.
[0171] In another example, when the cluster where the first sample pair is located only includes itself (that is, the cluster where the first sample pair is located has only one sample pair), the first distance a(p) between the current first sample pair and other positive sample pairs in the same cluster in the first clustering level is 0. Then, the second distance b(p) between the first sample pair and other clusters in the first clustering level is calculated according to the above formula (8). Finally, the silhouette coefficient s(p) of the first sample pair in the first clustering level is calculated based on the first distance and the second distance according to the above formula (9).
[0172] In some embodiments, when the cluster to which the first sample pair belongs is unknown, the cluster center of each cluster contained in the current clustering hierarchy is first determined, and then, based on the entity relationship features in the first sample pair, the distance between the first sample pair and the cluster center of each cluster is determined, and the cluster with the closest corresponding distance is used as the cluster of the first sample pair.
[0173] Here, the cluster center refers to the mean of the entity relationship features of all sample pairs in the cluster.
[0174] As an example, assume that the i-th clustering level contains j clusters, and the cluster centers of each cluster are c1, c2, c3, ... cj. The distances between the first sample pair (h, t) and the cluster centers of each cluster are calculated as d1, d2, ... dj, respectively. The cluster corresponding to the cluster center with the smallest distance is selected as the cluster of the first sample pair to which the first sample pair belongs. In this way, clusters can be effectively assigned to sample pairs with unknown cluster affiliation, providing an effective strategy for cluster analysis.
[0175] In step 202, the clustering level with the largest silhouette coefficient is used as the optimal clustering level for the first sample pair.
[0176] As an example, assuming there are three clustering levels, the silhouette coefficient of the first sample pair at the first clustering level calculated through the above step 201 is 0.2, the silhouette coefficient at the second clustering level is 0.5, and the silhouette coefficient at the third clustering level is 0.9. By comparison, the third clustering level is taken as the optimal clustering level for the first sample pair.
[0177] In step 203 , the second cluster to which the first sample pair belongs in the optimal clustering hierarchy is determined.
[0178] It should be noted that the second cluster to which the first sample pair belongs in the optimal clustering hierarchy can be determined by the above step 101, or by determining the distance between the first sample pair and the cluster center of each cluster based on the entity relationship characteristics in the first sample pair, and determining the cluster with the closest distance as the second cluster to which the first sample pair belongs.
[0179] In step 204 , based on the updated relationship mapping parameters of the second cluster, a fifth entity feature of the first entity and a sixth entity feature of the second entity included in the first sample pair are determined.
[0180] Here, the updated relationship mapping parameters of the second cluster are obtained through the above-mentioned step 104 .
[0181] As an example, assuming that the updated relationship mapping parameter of the second cluster is M, the first sample pair A can be expressed as (h, t), then the fifth entity feature of the first entity of the first sample pair A is hM, and the sixth entity feature of the second entity is tM.
[0182] In step 205 , the updated entity relationship feature of the second cluster is used as the entity relationship feature between the first entity and the second entity.
[0183] Here, the updated entity relationship features of the second cluster are obtained through the above-mentioned step 104 .
[0184] In summary, by calculating the silhouette coefficient of each clustering level and taking the clustering level with the largest silhouette coefficient as the optimal clustering level, it can ensure that the features of subsequent analysis and processing are performed on the optimal clustering structure, thereby improving the accuracy of entity relationship feature determination; in addition, by dynamically adjusting and optimizing entity features to reflect the latest clustering information, it helps to improve the representativeness and relevance of entity features.
[0185] In some embodiments, see Figure 9 , Figure 9 This is a flow chart of the data processing method provided in the embodiment of the present application, which will be combined with Figure 9 The steps shown are explained.
[0186] In step 301 , hierarchical clustering is performed on the positive sample pair set based on the interactive entity relationship features of each positive sample pair in the positive sample pair set to obtain clusters distributed at each clustering level.
[0187] Here, the positive sample pair set involves T kinds of interaction relationships, and the T kinds of interaction relationships correspond to T interaction relationship mapping parameters and T interaction entity relationship features, where T is a positive integer.
[0188] It should be noted that the implementation of the above step 301 is similar to the implementation of the above step 101. For details, please refer to the implementation of step 101 and will not be repeated here.
[0189] Here, the object entity refers to one entity in a positive sample pair with an interactive relationship. For example, in a recommendation system, the object entity may be the user who needs to be recommended; the information entity refers to the other entity in a positive sample pair with an interactive relationship. Taking the recommendation system as an example, the information entity may be the product information recommended to the user; the interactive relationship refers to the interaction or connection between the object entity and the information entity. For example, it may be the degree of liking between the user and the recommended product information (for example, dislike, generally like, very like).
[0190] In step 302, based on the T interaction relationship mapping parameters corresponding to the first cluster in the first clustering level, the object entity and the information entity included in the first positive sample pair in the first cluster are mapped respectively to obtain T first object features of the object entity and T first information features of the information entity of the first positive sample pair.
[0191] Here, the first positive sample pair is any positive sample pair in the positive sample pair set, the first clustering level is any clustering level, and the first cluster is the cluster to which the first positive sample pair belongs at the first clustering level.
[0192] It should be noted that, for each interactive relationship mapping parameter, the implementation of the above step 302 is similar to the implementation of the above step 102. For details, please refer to the implementation of step 102, which will not be repeated here.
[0193] In step 303 , a loss function corresponding to the first positive sample pair in the first clustering level is determined based on the T interactive entity relationship features of the first cluster and the T first object features and T first information features of the first positive sample pair.
[0194] It should be noted that the implementation of the above step 303 is similar to the implementation of the above step 103. For details, please refer to the implementation of step 103, which will not be repeated here.
[0195] In step 304 , a loss function of the first clustering level is determined based on the loss function corresponding to the first positive sample pair in the first clustering level.
[0196] It should be noted that the implementation of the above step 304 is similar to the implementation of the above step 104. For details, please refer to the implementation of step 104 and will not be repeated here.
[0197] In step 305, based on the loss function of the first clustering level, the T interactive relationship mapping parameters of each cluster in the first clustering level and the T interactive entity relationship features of each cluster in the first clustering level are updated to obtain T updated interactive relationship mapping parameters of each cluster in the first clustering level and T updated interactive entity relationship features of each cluster in the first clustering level.
[0198] It should be noted that the implementation of the above step 305 is similar to the implementation of the above step 105. For details, please refer to the implementation of step 105 and will not be repeated here.
[0199] In summary, through hierarchical clustering and feature mapping, the interactive relationship characteristics between entities can be more accurately captured and represented, and by optimizing the loss function and updating the model parameters, the model's generalization ability for unknown data is improved. In addition, the scheme can handle complex data sets containing multiple interactive relationships and has high adaptability and flexibility.
[0200] In some embodiments, see Figure 10 , Figure 10 This is a flow chart of the data processing method provided in the embodiment of the present application, which will be combined with Figure 10 The steps shown are explained.
[0201] In step 401 , the silhouette coefficient of the first sample pair at each clustering level is determined.
[0202] Here, each clustering level is obtained by the above data processing method.
[0203] It should be noted that the implementation of the above step 401 is similar to the implementation of the above step 201. For details, please refer to the implementation of step 201 and will not be repeated here.
[0204] In step 402, the clustering level with the largest silhouette coefficient is used as the optimal clustering level for the first sample pair.
[0205] It should be noted that the implementation of the above step 402 is similar to the implementation of the above step 202. For details, please refer to the implementation of step 202 and will not be repeated here.
[0206] In step 403 , the second cluster to which the first sample pair belongs in the optimal clustering hierarchy is determined.
[0207] It should be noted that the implementation of the above step 403 is similar to the implementation of the above step 203. For details, please refer to the implementation of step 203, which will not be repeated here.
[0208] In step 404 , based on the T updated interaction relationship mapping parameters of the second cluster, T second object features of the first object entity and T second information features of the first information entity included in the first sample pair are determined.
[0209] Here, the T updated interaction relationship mapping parameters of the second cluster are obtained through the above step 304 .
[0210] It should be noted that the implementation of the above step 404 is similar to the implementation of the above step 204. For details, please refer to the implementation of step 204, which will not be repeated here.
[0211] In step 405 , the T updated interactive entity relationship features of the second cluster are used as the T interactive entity relationship features between the first object entity and the first information entity.
[0212] Here, the T updated interactive entity relationship features of the second cluster are obtained through the above step 304 .
[0213] It should be noted that the implementation of the above step 405 is similar to the implementation of the above step 205. For details, please refer to the implementation of step 205, which will not be repeated here.
[0214] In step 406, based on the T second object features of the first object entity, the T second information features of the first information entity, and the T interactive entity relationship features between the first object entity and the first information entity, the matching degree between the T interactive relationships and the first sample pair is determined.
[0215] In some embodiments, step 406 can be implemented as follows: for each of the T interactive relationships, the following processing is performed: mapping the second object feature of the first object entity based on the interactive entity relationship feature corresponding to the interactive relationship to obtain a third mapping feature; determining a fifth difference between the third mapping feature and the second information feature of the first information entity, and determining a matching degree for the corresponding interactive relationship that is negatively correlated with the fifth difference. In this way, the matching degree calculation can better determine the interactive relationships between different entities, thereby optimizing the decision-making process.
[0216] As an example, first, determine the second object feature h of the first object entity corresponding to the interactive relationship. r , the second information feature t of the first information entity r , and the interactive entity relationship feature r between the first object entity and the first information entity, then, referring to formula (10), determine the second object feature h of the first object entity r and the first mapping feature h of the interactive entity relationship feature r between the first object entity and the first information entity rr; Then, determine the first mapping feature h r r and the second information feature t of the first information entity r The difference between r rt r ; Finally, obtain the matching degree which is negatively correlated with the difference S. The smaller the difference, the greater the matching degree, which indicates the greater possibility that the corresponding interactive relationship is established.
[0217]
[0218] In step 407 , based on the matching degrees between the T types of interaction relationships and the first sample pair, a recommendation process is performed on the first sample pair.
[0219] As an example, suppose there are three interactive relationships: dislike r a 、Generally like r b 、I like r very much c , by calculating the scores between the three interactive relationships and the first sample pair, respectively S a =0.6, S b =0.5, S c =0.8, by comparison we can know the interactive relationship S b The matching degree with the first sample pair is higher, that is, the best interactive relationship between the first object entity and the first information entity in the first sample pair is generally liked. The first sample pair can be recommended based on the obtained best interactive relationship between the object entity and the information entity. For example, the recommended content can be filtered based on the obtained interactive relationship. If it is not liked, the corresponding content will be deleted from the recommended content. If it is very liked, the corresponding content will be added to the recommended content.
[0220] In summary, by selecting the optimal clustering hierarchy and feature mapping, the interactive relationships between entities can be more accurately identified and described, and recommendations can be made based on the matching degree of the interactive relationships, which helps to improve the accuracy of the recommendation system and user satisfaction. In addition, it can process data sets with unknown interactive relationships, has high adaptability and generalization capabilities, and can process complex data sets containing multiple interactive relationships, supporting the construction of complex relationship models.
[0221] The following describes an exemplary application of the embodiment of the present application in a practical application scenario, which describes the specific implementation process of the data processing method.
[0222] In some embodiments, see Figure 11 , Figure 11 This is a process diagram of the data processing method provided by the embodiment of the present application. Figure 11 Describe the specific implementation process.
[0223] In step 501, the TransE model trains the embedding vector to obtain a triplet vector (h, r, t).
[0224] Here, h and t are the head entity and tail entity respectively, and r is the relationship between h and t.
[0225] As an example, after the TransE model training is completed, the vectors of entities and relations are obtained and stored in the vector database.
[0226] In step 502 , a hierarchical clustering dendrogram is generated for the entity pair (h, t) using hierarchical clustering.
[0227] As an example, for all triples (h, r, t) in the knowledge graph, hierarchical clustering is performed on the entity pairs (h, t) in all triples. A bottom-up agglomerative strategy is used to calculate th to obtain the characteristics of an entity pair data point. Starting with each data point as a separate cluster, clusters are gradually merged until the specified number of clusters or a certain termination condition is reached. First, each data point is regarded as a separate cluster; then, the Euclidean distance between all clusters is calculated; then, among all clusters, the two clusters with the closest distance are selected for merging; then, after merging the selected clusters, the distance matrix is updated to reflect the new clustering structure, for example, using the mean distance, m i It is cluster C i The mean value, m j It is cluster C j The mean of , then the mean distance d=|m i -m j Finally, the above clustering process is repeated until the specified number of clusters is reached or all data points are merged into one cluster, and a cluster dendrogram can be generated by recording the clusters and distances of each merge (see Figure 12 , Figure 12 is a clustering dendrogram provided in an embodiment of the present application).
[0228] In step 503 , the CTransR model parameters are trained for each level.
[0229] As an example, data points belong to different clusters at each level, and the relationship vector r of the clusters c And the relational projection matrix M r Different, assuming that the data point in the layer layer belongs to the cluster r c For r c,layer , M r M r,layer The score function and loss function of the layer can be calculated by the above formula (4) and formula (6).
[0230] In step 504 , the optimal level of the entity pairs is calculated to obtain a clustering relationship vector and a projection matrix.
[0231] As an example, the feature data points of each entity pair (h, t) are at different levels and belong to different clusters. The silhouette coefficient is calculated for each layer of clustering where the data point is located. For a data set D with n data points, assume that D is divided into k clusters C1, C2...Ck at the layer level. For each object p∈D, the distance a(p) between p and other data points in the cluster is calculated (as shown in formula (7)). Similarly, b(p) (as shown in formula (8)) is the minimum average distance from p to all clusters that do not belong to p. Finally, the silhouette coefficient of the data point p is calculated according to formula (9), where the value of the silhouette coefficient is between -1 and 1. The value of a(p) reflects the compactness of the cluster to which p belongs. The smaller the value, the more compact the cluster. The value of b(p) reflects the degree of separation of p from other clusters. The larger the value, the more separated it is from other clusters. Therefore, when the silhouette coefficient value of data point p is close to 1, the cluster containing p is compact and p is far away from other clusters. The silhouette coefficient is calculated for all levels of data point p, and the layer with the largest silhouette system is selected. v As the optimal clustering level of p.
[0232] In some embodiments, if the entity pair (h, t) has a triple relationship (h, r, t) in the current knowledge graph, then the cluster to which the entity pair (h, t) belongs in each layer is already known after the hierarchical clustering in step 502 is completed, and the optimal layer layer can be calculated according to the above method. v .
[0233] If the entity pair (h, t) does not have a triple relationship (h, r, t) in the current knowledge graph, then the cluster to which the entity pair (h, t) belongs in each layer is unknown, so the cluster to which the entity pair belongs in each layer must first be calculated. After the clustering in step 502 is completed, the cluster center c of each cluster is obtained. Assume that there are k clusters in the layer layer, and the cluster centers are: c1, c2, c3...ck. The characteristic vector r=th of the entity pair (h, t) is calculated. The cluster center closest to r is the corresponding cluster to which the entity pair belongs in the layer layer. After the calculation of the belonging cluster of each layer is completed, the optimal layer layer of the entity pair is calculated according to the above method. v .
[0234] The essence of a recommendation system is to recommend items to users that they have not come into contact with but may be interested in or purchase, such as movies, books, music, commodities, credit products, etc. Users' preferences for items can be constructed into a knowledge graph triple (user, like, item). Entity pairs (user, item) in historical stock data are clustered into several groups. The entity pairs (user, item) in each group show similar "like" relationships. After clustering is completed, a specific "like" relationship vector is learned for each cluster, and a specific "like" relationship projection matrix is learned for each relationship. Finally, the entity vector is projected into the relationship space based on the projection vector to calculate the recommendation score.
[0235] In some embodiments, see Figure 13 , Figure 13 This is a process diagram of the data processing method provided by the embodiment of the present application. Figure 13 Describe the specific implementation process of data processing methods in the recommendation system.
[0236] In step 601, a knowledge graph TransE model is constructed based on historical data to train embedding vectors.
[0237] As an example, the historical user rating data for items are divided into three categories according to the rating level: very like, generally like, and dislike. A knowledge graph relationship is established for each category: very like (r a ), generally like (r b ), dislike (r c ), construct a knowledge graph for the stock data, where the knowledge graph triples of users’ preferences for items are as follows: (user A, like very much, item B), (user A, like very much, item C), (user B, generally like, item C), (user C, dislike, item F).
[0238] In step 602 , hierarchical clustering is used to generate a hierarchical clustering dendrogram for the entity pair (h, t).
[0239] As an example, the embedding representation vectors h and t of the entities "user" and "item" are obtained through TransE model training, and hierarchical clustering is performed using the feature th of the entity pair (h, t).
[0240] In step 603 , the CTransR model parameters are trained for each level.
[0241] It should be noted that during the training of the CTransR model, negative samples are constructed by randomly replacing the head entity or the tail entity. Because the triplets in the knowledge graph all exist and are positive samples, the construction of negative samples can only generate new triplets by replacing the head entity and the tail entity, and the generated triplets do not exist in the knowledge graph and are considered negative samples. This is why it is necessary to construct negative sample triplets during the training of the CTransR model. The CTransR model parameters of each layer are trained, and the relationship vectors of the three types of "like" at each layer are: very like (r a,layer ), generally like (r b,layer ), dislike (r c,layer ), the projection matrix of three types of like relationships: I like M very much a,layer , generally like M b,layer 、Don't like M c,layer .
[0242] As an example, for the training of each layer of CTransR model parameters, first, the data is initialized, then the entity is normalized by the L2 norm (i.e., the square root of the sum of the squares of each element of the vector), and a batch of samples is taken, S batch Represents the positive sample, that is, the correct triple, initialize the triple pair, that is, a list for storage, and construct a batch The non-existent samples are negative samples, and then the corresponding positive sample triples and negative sample triples are put together to form T batch After the extraction of positive and negative samples is completed, the loss function is calculated according to formula (4) and formula (6), and the model parameters are updated by gradient descent. Here, the entity in the positive sample triplet has a high preference for the data point, and the clusters in each layer belong to it (r a,layer ), generally like (r b,layer ), dislike (r c,layer ), I like M very much a,layer , generally like M b,layer 、Don't like M c,layer , including hyperparameters α and γ, which are randomly initialized to a value before starting training. They are continuously iterated and changed during the training process until the value after the model training is completed is used as the final value.
[0243] In step 604 , the optimal level of the entity pairs is calculated to obtain a clustering relationship vector and a projection matrix.
[0244] It should be noted that the implementation of step 604 is similar to the implementation of the above-mentioned step 504. For details, please refer to the specific implementation of step 504, which will not be repeated here.
[0245] In step 605, the scores of various like types are calculated to determine the type of likes the user has for the item.
[0246] Here, the score of each type of liking can be calculated using the above formula (10). The lowest score among the three liking levels represents the degree of liking of user X for item Y. This is because the lower the score, the more it satisfies the embedding vector representation of h + r = t. That is, the liking type corresponding to the lower score represents the more closely matched the liking type of user X for item Y.
[0247] After the user's preference for an item is quantified, other business recommendation rules can be combined to comprehensively calculate the items pushed to the user, thus completing the recommendation operation for the user.
[0248] The following continues to describe the exemplary structure of the data processing device 543 provided in the embodiment of the present application implemented as a software module. In some embodiments, such as Figure 5A As shown, the software modules stored in the data processing device 543 of the memory 540 may include: a first processing module 5431 , a second processing module 5432 , a first determination module 5433 and an update module 5434 .
[0249] The first processing module 5431 is used to perform hierarchical clustering processing on the positive sample pair set based on the entity relationship features corresponding to each positive sample pair in the positive sample pair set, and obtain clusters distributed at each clustering level; the second processing module 5432 is used to perform mapping processing on the two entities included in the first positive sample pair in the first cluster based on the relationship mapping parameters corresponding to the first cluster in the first clustering level, and obtain the first entity feature and the second entity feature of the first positive sample pair; the first determination module 5433 is used to determine the entity relationship features corresponding to the first cluster and the first entity feature of the first positive sample pair based on the relationship mapping parameters corresponding to the first cluster and the first entity feature of the first positive sample pair. Features and second entity features are used to determine the loss function corresponding to the first positive sample pair in the first clustering level; the first determination module 5433 is also used to determine the loss function of the first clustering level based on the loss function corresponding to each positive sample pair in the first clustering level; the updating module 5434 is used to update the relationship mapping parameters of each cluster in the first clustering level and the entity relationship features of each cluster in the first clustering level based on the loss function of the first clustering level, and obtain the updated relationship mapping parameters of each cluster in the first clustering level and the updated entity relationship features of each cluster in the first clustering level.
[0250] In some embodiments, the first processing module 5431 is further used to perform clustering processing on the two target clusters in the cluster set belonging to the mth clustering level based on the entity relationship features corresponding to each positive sample pair, and obtain the cluster set belonging to the m+1th clustering level; wherein the number of clusters included in the cluster set belonging to the mth clustering level is p, p is an integer greater than 1, m is an integer variable whose value increases from 1, and the value range of m is 1≤m; continue to perform clustering processing on the attribute based on the entity relationship features corresponding to each positive sample pair. Clustering is performed on two target clusters in the cluster set of the m+1th clustering level; the number of clusters included in the cluster set belonging to the m+1th clustering level is p-1, and when m is 1, the cluster set belonging to the mth clustering level is a cluster set composed of clusters corresponding to each positive sample pair, and the clusters corresponding to the positive sample pair are initialized by the positive sample pair; the cluster set belonging to multiple clustering levels obtained when the clustering stopping condition is met is disassembled to obtain clusters distributed at each clustering level.
[0251] In some embodiments, the first processing module 5431 is also used to determine the clustering features of p clusters belonging to the mth clustering level based on the entity relationship features corresponding to each positive sample pair; determine the distance between any two clusters in the p clusters based on the clustering features of the p clusters belonging to the mth clustering level; select the two clusters corresponding to the minimum distance as two target clusters, and merge the two target clusters to obtain a new cluster; combine the new cluster with other clusters in the p clusters except the two target clusters to obtain a cluster set belonging to the m+1th clustering level.
[0252] In some embodiments, the first processing module 5431 is further used to determine that the clustering stop condition is met if the number of clusters included in the cluster set of the m+1th clustering level is 1; or to determine that the clustering stop condition is met if the number of clustering levels reaches a first number threshold.
[0253] In some embodiments, the second processing module 5432 is also used to generate a negative sample pair corresponding one-to-one to each positive sample pair, wherein the negative sample pair includes two entities, the corresponding negative sample pair and the positive sample pair belong to the same cluster, and the entity relationship features of the negative sample pair are the same as the entity relationship features of the corresponding positive sample pair; based on the relationship mapping parameters corresponding to the first cluster in the first clustering level, the two entities included in the first negative sample pair are mapped separately to obtain the third entity feature and the fourth entity feature of the first negative sample pair, wherein the first negative sample pair is a negative sample pair having a corresponding relationship with the first positive sample pair.
[0254] In some embodiments, the first determination module 5433 is further used to perform mapping processing on the first entity feature of the first positive sample pair based on the entity relationship feature corresponding to the first cluster to obtain the first mapping feature of the first positive sample pair; determine the first difference between the first mapping feature of the first positive sample pair and the second entity feature of the first positive sample pair, and determine the second difference between the entity relationship feature corresponding to the first cluster and the entity relationship feature corresponding to the first positive sample pair; fuse the first difference and the second difference to obtain the loss function corresponding to the first positive sample pair in the first clustering level.
[0255] In some embodiments, the first determination module 5433 is further used to map the third entity feature of the first negative sample pair based on the entity relationship feature corresponding to the first cluster to which the first negative sample pair belongs, to obtain the second mapping feature of the first negative sample pair; determine the third difference between the second mapping feature of the first negative sample pair and the fourth entity feature of the first negative sample pair, and determine the fourth difference between the entity relationship feature corresponding to the first cluster and the entity relationship feature of the first negative sample pair; fuse the third difference and the fourth difference to obtain the loss function corresponding to the first negative sample pair in the first clustering level; determine the loss function of the first clustering level based on the loss function corresponding to each positive sample pair in the first clustering level and the loss function corresponding to each negative sample pair in the first clustering level.
[0256] The following continues to describe the exemplary structure of the data processing device 643 provided in the embodiment of the present application implemented as a software module. In some embodiments, such as Figure 5B As shown, the software modules stored in the data processing device 643 of the memory 640 may include: a second determination module 6431 , a third processing module 6432 , a third determination module 6433 , a fourth determination module 6434 and a fourth processing module 6435 .
[0257] The second determination module 6431 is used to determine the silhouette coefficient of the first sample pair at each clustering level, wherein each clustering level is obtained by the above-mentioned data processing method; the third processing module 6432 is used to take the clustering level with the largest silhouette coefficient as the optimal clustering level of the first sample pair; the third determination module 6433 is used to determine the second cluster to which the first sample pair belongs in the optimal clustering level; the fourth determination module 6434 is used to determine the fifth entity feature of the first entity and the sixth entity feature of the second entity included in the first sample pair based on the updated relationship mapping parameters of the second cluster, wherein the updated relationship mapping parameters of the second cluster are obtained by the above-mentioned data processing method; the fourth processing module 6435 is used to take the updated entity relationship feature of the second cluster as the entity relationship feature between the first entity and the second entity, wherein the updated entity relationship feature of the second cluster is obtained by the above-mentioned data processing method.
[0258] It should be noted that the description of the device in the embodiment of the present application is similar to the description of the method embodiment above, and has similar beneficial effects as the method embodiment, so it will not be repeated here. Figure 6 、 Figure 7 、 Figure 8 、 Figure 9 ,or Figure 10 The present invention should be understood by referring to the description of any one of the accompanying drawings.
[0259] An embodiment of the present application provides a computer program product, which includes a computer program or computer-executable instructions stored in a computer-readable storage medium. A processor of an electronic device reads the computer-executable instructions from the computer-readable storage medium and executes the computer-executable instructions, causing the electronic device to perform the data processing method described in the embodiment of the present application.
[0260] The embodiment of the present application provides a computer-readable storage medium in which computer-executable instructions or computer programs are stored. When the computer-executable instructions or computer programs are executed by a processor, the processor will execute the data processing method provided in the embodiment of the present application, for example, Figure 6 、 Figure 7 、 Figure 8 、 Figure 9 ,or Figure 10 The data processing method is shown.
[0261] In some embodiments, the computer-readable storage medium may be a ferroelectric random access memory (FRAM), ROM, programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), flash memory, magnetic surface memory, optical disk, or compact disc read-only memory (CD-ROM); or various devices including one or any combination of the above memories.
[0262] In some embodiments, computer-executable instructions may be in the form of a program, software, software module, script, or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as a stand-alone program or as a module, component, subroutine, or other unit suitable for use in a computing environment.
[0263] As an example, computer-executable instructions may, but need not, correspond to a file in a file system, may be stored as part of a file that stores other programs or data, such as in one or more scripts in a HyperText Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple coordinating files (e.g., files storing one or more modules, subroutines, or code portions).
[0264] By way of example, computer-executable instructions may be deployed to be executed on one electronic device, or on multiple electronic devices located at one site, or on multiple electronic devices distributed across multiple sites and interconnected by a communication network.
[0265] In summary, according to the embodiment of the present application, hierarchical clustering is performed on the positive sample pair set according to the entity relationship features corresponding to each positive sample pair in the positive sample pair set, and clusters distributed at each clustering level are obtained, which helps to discover the hierarchical structure and complex relationships in the data; then, in the first clustering level, according to the relationship mapping parameters corresponding to the first cluster, the two entities included in the first positive sample pair in the first cluster are mapped respectively to obtain the first entity feature and the second entity feature of the first positive sample pair, and projected from the entity space to the relationship space through the relationship mapping parameters, that is, each entity has a representation in the relationship, and since the clustering here is hierarchical clustering, considering that the relationship also has a hierarchical structure, the extracted entity features can conform to the hierarchical structure of the relationship; subsequently, according to the entity features of the positive sample pairs in the first clustering level and the entity relationship features of the corresponding clusters, a special loss function is constructed for hierarchical optimization, and then by iteratively updating the relationship mapping parameters of each cluster in the first clustering level and the entity relationship features of each cluster in the first clustering level, the generalization ability of the entity feature and relationship feature expression can be improved. In summary, hierarchical clustering processing is performed through this scheme to enhance the adaptability and generalization ability of unknown data.
[0266] The above description is merely an embodiment of the present application and is not intended to limit the scope of protection of the present application. Any modifications, equivalent replacements, and improvements made within the spirit and scope of the present application are included in the scope of protection of the present application.
Claims
1. A data processing method, characterized in that: The method comprises: Based on the entity relationship features corresponding to each positive sample pair in the positive sample pair set, hierarchical clustering is performed on the positive sample pair set to obtain clusters distributed at each clustering level; Based on the relationship mapping parameters corresponding to the first cluster in the first clustering level, mapping processing is performed on the two entities included in the first positive sample pair in the first cluster to obtain a first entity feature and a second entity feature of the first positive sample pair; Determining a loss function corresponding to the first positive sample pair in the first clustering level based on the entity relationship feature corresponding to the first cluster and the first entity feature and the second entity feature of the first positive sample pair; Determining a loss function of the first clustering level based on the loss function corresponding to each of the positive sample pairs in the first clustering level; Based on the loss function of the first clustering level, the relationship mapping parameters of each cluster in the first clustering level and the entity relationship features of each cluster in the first clustering level are updated to obtain the updated relationship mapping parameters of each cluster in the first clustering level and the updated entity relationship features of each cluster in the first clustering level.
2. The method according to claim 1, characterized in that The method of performing hierarchical clustering on the positive sample pair set based on the entity relationship features corresponding to each positive sample pair in the positive sample pair set to obtain clusters distributed at each clustering level includes: Based on the entity relationship features corresponding to each of the positive sample pairs, clustering is performed on the two target clusters in the cluster set belonging to the mth clustering level to obtain a cluster set belonging to the m+1th clustering level; Among them, the number of clusters included in the cluster set belonging to the mth clustering level is p, p is an integer greater than 1, m is an integer variable with a value starting from 1 and increasing, and the value range of m is 1≤m; Continuing to perform clustering processing on the two target clusters in the cluster set belonging to the m+1th clustering level based on the entity relationship feature of each of the positive sample pairs; The number of clusters included in the cluster set belonging to the m+1th clustering level is p-1. When m is 1, the cluster set belonging to the mth clustering level is a cluster set composed of clusters corresponding to each of the positive sample pairs, and the clusters corresponding to the positive sample pairs are initialized by the positive sample pairs. The cluster sets belonging to multiple clustering levels obtained when the clustering stopping condition is met are disassembled to obtain clusters distributed in each clustering level.
3. The method according to claim 2, characterized in that The clustering process is performed on the two target clusters in the cluster set belonging to the mth clustering level based on the entity relationship features corresponding to each of the positive sample pairs, to obtain the cluster set belonging to the m+1th clustering level, including: Determine the cluster features of the p clusters belonging to the m-th clustering level based on the entity relationship features corresponding to each positive sample pair; Determining the distance between any two clusters in the p clusters based on the cluster features of the p clusters belonging to the m-th clustering level; Selecting two clusters corresponding to the minimum distance as the two target clusters, and merging the two target clusters to obtain a new cluster; The new cluster is combined with the other clusters in the p clusters except the two target clusters to obtain a cluster set belonging to the m+1th clustering level.
4. The method according to claim 2, characterized in that The method further comprises: If the number of clusters included in the cluster set of the m+1th clustering level is 1, it is determined that the clustering stop condition is satisfied; or If the number of the clustering levels reaches a first number threshold, it is determined that the clustering stop condition is satisfied.
5. The method according to claim 1, wherein The determining, based on the entity relationship feature corresponding to the first cluster and the first entity feature and the second entity feature of the first positive sample pair, a loss function corresponding to the first positive sample pair in the first clustering level includes: Based on the entity relationship feature corresponding to the first cluster, mapping processing is performed on the first entity feature of the first positive sample pair to obtain a first mapping feature of the first positive sample pair; Determining a first difference between a first mapping feature of the first positive sample pair and a second entity feature of the first positive sample pair, and determining a second difference between an entity relationship feature corresponding to the first cluster and an entity relationship feature corresponding to the first positive sample pair; The first difference and the second difference are fused to obtain a loss function corresponding to the first positive sample pair in the first clustering level.
6. The method according to claim 1, characterized in that After performing hierarchical clustering on the positive sample pair set based on the entity relationship features corresponding to each positive sample pair in the positive sample pair set to obtain clusters distributed at each clustering level, the method further includes: Generate a negative sample pair corresponding to each positive sample pair, wherein the negative sample pair includes two entities, the corresponding negative sample pair and the positive sample pair belong to the same cluster, and the entity relationship feature of the negative sample pair is the same as the entity relationship feature of the corresponding positive sample pair; Based on the relationship mapping parameters corresponding to the first cluster in the first clustering hierarchy, mapping is performed on the two entities included in the first negative sample pair to obtain a third entity feature and a fourth entity feature of the first negative sample pair, wherein the first negative sample pair is a negative sample pair having a corresponding relationship with the first positive sample pair; The determining of the loss function of the first clustering level based on the loss function corresponding to each of the positive sample pairs in the first clustering level includes: Based on the entity relationship feature corresponding to the first cluster to which the first negative sample pair belongs, mapping the third entity feature of the first negative sample pair to obtain a second mapping feature of the first negative sample pair; Determining a third difference between the second mapped feature of the first negative sample pair and the fourth entity feature of the first negative sample pair, and determining a fourth difference between the entity relationship feature corresponding to the first cluster and the entity relationship feature of the first negative sample pair; fusing the third difference and the fourth difference to obtain a loss function corresponding to the first negative sample pair in the first clustering level; A loss function of the first clustering level is determined based on the loss function corresponding to each of the positive sample pairs in the first clustering level and the loss function corresponding to each of the negative sample pairs in the first clustering level.
7. A data processing method, characterized in that: The method comprises: determining a silhouette coefficient of the first sample pair at each clustering level, wherein each clustering level is obtained by processing the method according to any one of claims 1 to 6; Taking the clustering level with the largest silhouette coefficient as the optimal clustering level for the first sample pair; determining a second cluster to which the first sample pair belongs in the optimal clustering level; determining, based on the updated relationship mapping parameters of the second cluster, a fifth entity feature of the first entity and a sixth entity feature of the second entity included in the first sample pair, wherein the updated relationship mapping parameters of the second cluster are obtained by processing using the method of any one of claims 1 to 6; The updated entity relationship feature of the second cluster is used as the entity relationship feature between the first entity and the second entity, wherein the updated entity relationship feature of the second cluster is obtained by processing the method according to any one of claims 1 to 6.
8. A data processing method, characterized in that: The method comprises: Based on the interactive entity relationship features of each positive sample pair in the positive sample pair set, hierarchical clustering is performed on the positive sample pair set to obtain clusters distributed at each clustering level, where the positive sample pair set involves T types of interactive relationships, and the T types of interactive relationships correspond to T interactive relationship mapping parameters and T interactive entity relationship features, where T is a positive integer; Based on the T interaction relationship mapping parameters corresponding to the first cluster in the first clustering level, mapping processing is performed on the object entity and the information entity included in the first positive sample pair in the first cluster to obtain T first object features of the object entity and T first information features of the information entity of the first positive sample pair; Determining a loss function corresponding to the first positive sample pair in the first clustering level based on the T interactive entity relationship features corresponding to the first cluster, and the T first object features and T first information features of the first positive sample pair; determining a loss function for the first clustering level based on the loss function corresponding to the first positive sample pair in the first clustering level; Based on the loss function of the first clustering level, the T interactive relationship mapping parameters of each cluster in the first clustering level and the T interactive entity relationship features of each cluster in the first clustering level are updated to obtain T updated interactive relationship mapping parameters of each cluster in the first clustering level and T updated interactive entity relationship features of each cluster in the first clustering level.
9. A data processing method, characterized in that: The method comprises: determining a silhouette coefficient of the first sample pair at each clustering level, wherein each clustering level is obtained by processing the method according to claim 8; Taking the clustering level with the largest silhouette coefficient as the optimal clustering level for the first sample pair; determining a second cluster to which the first sample pair belongs in the optimal clustering level; Determining T second object features of the first object entity and T second information features of the first information entity included in the first sample pair based on the T updated interaction relationship mapping parameters of the second cluster, wherein the T updated interaction relationship mapping parameters of the second cluster are obtained by processing according to the method of claim 8; using the T updated interactive entity relationship features of the second cluster as the T interactive entity relationship features between the first object entity and the first information entity, wherein the T updated interactive entity relationship features of the second cluster are obtained by processing the method of claim 8; Determining a matching degree between the T interactive relationships and the first sample pair based on the T second object features of the first object entity, the T second information features of the first information entity, and the T interactive entity relationship features between the first object entity and the first information entity; Based on the matching degree between the T types of interactive relationships and the first sample pair, recommendation processing is performed on the first sample pair.
10. The method according to claim 9, characterized in that The determining, based on the T second object features of the first object entity, the T second information features of the first information entity, and the T interactive entity relationship features between the first object entity and the first information entity, of a matching degree between the T interactive relationships and the first sample pair includes: The following processing is performed for each of the T types of interactive relationships: Mapping the second object feature of the first object entity based on the interactive entity relationship feature corresponding to the interactive relationship to obtain a third mapping feature; A fifth difference between the third mapping feature and the second information feature of the first information entity is determined, and a matching degree corresponding to the interactive relationship that is negatively correlated with the fifth difference is determined.
11. A data processing device, characterized in that: The device comprises: A first processing module is configured to perform hierarchical clustering processing on the positive sample pair set based on the entity relationship features corresponding to each positive sample pair in the positive sample pair set, to obtain clusters distributed at each clustering level; A second processing module is configured to perform mapping processing on two entities included in a first positive sample pair in the first cluster based on the relationship mapping parameter corresponding to the first cluster in the first clustering hierarchy, to obtain a first entity feature and a second entity feature of the first positive sample pair; A first determining module is configured to determine a loss function corresponding to the first positive sample pair in the first clustering level based on the entity relationship feature corresponding to the first cluster and the first entity feature and the second entity feature of the first positive sample pair; The first determining module is further configured to determine a loss function of the first clustering level based on a loss function corresponding to each of the positive sample pairs in the first clustering level; An updating module is used to update the relationship mapping parameters of each cluster in the first clustering level and the entity relationship features of each cluster in the first clustering level based on the loss function of the first clustering level, so as to obtain the updated relationship mapping parameters of each cluster in the first clustering level and the updated entity relationship features of each cluster in the first clustering level.
12. A data processing device, characterized in that: The device comprises: a second determining module, configured to respectively determine the silhouette coefficient of the first sample pair at each clustering level, wherein each clustering level is obtained by processing the method according to any one of claims 1 to 6; a third processing module, configured to use the clustering level with the largest silhouette coefficient as the optimal clustering level for the first sample pair; a third determining module, configured to determine a second cluster to which the first sample pair belongs in the optimal clustering level; a fourth determining module, configured to determine a fifth entity feature of the first entity and a sixth entity feature of the second entity included in the first sample pair based on the updated relationship mapping parameters of the second cluster, wherein the updated relationship mapping parameters of the second cluster are obtained by processing using the method of any one of claims 1 to 6; A fourth processing module is used to use the updated entity relationship feature of the second cluster as the entity relationship feature between the first entity and the second entity, wherein the updated entity relationship feature of the second cluster is obtained by processing according to any one of claims 1 to 6.
13. An electronic device, characterized in that: include: a memory for storing computer-executable instructions or computer programs; The processor is configured to implement the data processing method according to any one of claims 1 to 10 when executing the computer-executable instructions or computer programs stored in the memory.
14. A computer-readable storage medium storing computer-executable instructions or a computer program, characterized in that: When the computer-executable instructions or computer programs are executed by a processor, the data processing method according to any one of claims 1 to 10 is implemented.
15. A computer program product comprising computer executable instructions or a computer program, characterized in that When the computer executable instructions or computer program are executed by a processor, the data processing method according to any one of claims 1 to 10 is implemented.