Vector representation methods, devices and products
By constructing a heterogeneous graph of recommendation scenarios, identifying positive and negative sample pairs, and optimizing vector representations, the problem of inaccurate prediction of items that users will be interested in in the future is solved in existing technologies, thereby improving the recall rate and ranking accuracy of the recommendation system.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- BEIJING BAIDU NETCOM SCI & TECH CO LTD
- Filing Date
- 2026-03-31
- Publication Date
- 2026-06-30
AI Technical Summary
Existing recommendation systems struggle to accurately predict items that users may be interested in in the future, especially in resource recommendation scenarios. Current technologies cannot effectively utilize users' historical behavior to construct high-quality vector representations, resulting in insufficient recommendation accuracy.
By constructing a heterogeneous graph of recommendation scenarios, positive and negative sample pairs are determined. The original feature vector of a node and the feature vectors of its neighboring nodes are combined, and the representation vector is updated using a loss function to maximize the similarity of positive sample pairs and minimize the similarity of negative sample pairs, thereby optimizing the vector space.
It improves the recall and ranking accuracy of resource recommendations, enhances the accuracy and comprehensiveness of vector representations, and improves the recommendation performance of the recommendation system.
Smart Images

Figure CN122309846A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer technology, specifically to graph representation learning, intelligent recommendation, graph neural networks and other technical fields, and particularly to a vector representation method, device, electronic device, storage medium and computer program product that can be applied to resource recommendation scenarios. Background Technology
[0002] In recommender systems, the goal is to predict items a user might be interested in in the future based on their historical behavior. The historical behavior of a large number of users forms a massive graph network. Summary of the Invention
[0003] This disclosure provides a vector representation method, apparatus, electronic device, storage medium, and computer program product.
[0004] According to the first aspect, a vector representation method is provided, including: determining positive sample pairs and negative sample pairs based on the association relationships between nodes in a heterogeneous graph of a recommendation scenario, wherein the heterogeneous graph of a recommendation scenario represents the association relationships between object nodes, resource nodes, and topic nodes; obtaining the representation vector of a node by combining the original feature vector of the node and the original feature vector of the target neighbor node; and updating the representation vector using a loss function, wherein the loss function is used to maximize the similarity between the representation vectors of nodes in the positive sample pair and minimize the similarity between the representation vectors of nodes in the negative sample pair.
[0005] According to a second aspect, a vector representation apparatus is provided, comprising: a sample pair determination unit configured to determine positive sample pairs and negative sample pairs based on the association relationships between nodes in a heterogeneous graph of a recommendation scenario, wherein the heterogeneous graph of the recommendation scenario represents the association relationships between object nodes, resource nodes, and topic nodes; a vector combining unit configured to combine the original feature vector of a node and the original feature vector of a target neighbor node to obtain a representation vector of the node; and a vector updating unit configured to update the representation vector using a loss function, wherein the loss function is used to maximize the similarity between the representation vectors of nodes in a positive sample pair and minimize the similarity between the representation vectors of nodes in a negative sample pair.
[0006] According to a third aspect, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform a method as described in any implementation of the first aspect.
[0007] According to a fourth aspect, a non-transitory computer-readable storage medium is provided that stores computer instructions for causing a computer to perform the method described in any implementation of the first aspect.
[0008] According to a fifth aspect, a computer program product is provided, comprising: a computer program that, when executed by a processor, implements the method as described in any implementation of the first aspect.
[0009] According to the technology disclosed herein, a vector representation method and apparatus are provided. Positive and negative sample pairs are determined based on the relationships between nodes in a heterogeneous graph of a recommendation scenario. The heterogeneous graph represents the relationships between object nodes, resource nodes, and topic nodes. A node representation vector is obtained by combining the original feature vector of a node and the original feature vector of the target neighbor node. The representation vector is updated using a loss function, which maximizes the similarity between the representation vectors of nodes in positive sample pairs and minimizes the similarity between the representation vectors of nodes in negative sample pairs. By introducing topic nodes to construct a heterogeneous graph of the recommendation scenario and combining contrastive learning to optimize the vector space, the accuracy and comprehensiveness of the representation vectors are improved, which helps to enhance the accuracy of resource retrieval and ranking in the recommendation system.
[0010] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description
[0011] The accompanying drawings are provided to better understand this solution and do not constitute a limitation of this disclosure. Wherein: Figure 1 This is an exemplary system architecture diagram that can be applied to an embodiment of this disclosure; Figure 2 This is a flowchart of an embodiment of the vector representation method according to the present disclosure; Figure 3 This is a schematic diagram illustrating an application scenario of the vector representation method according to this embodiment; Figure 4 This is a flowchart of yet another embodiment of the vector representation method according to the present disclosure; Figure 5 This is a structural diagram of an embodiment of the vector representation apparatus according to the present disclosure; Figure 6 This is a schematic diagram of the structure of a computer system suitable for implementing the embodiments of the present disclosure. Detailed Implementation
[0012] The exemplary embodiments of this disclosure are described below with reference to the accompanying drawings, including various details of the embodiments to aid understanding, and should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of this disclosure. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.
[0013] The technical solutions disclosed herein involve the collection, storage, use, processing, transmission, provision, and disclosure of various types of information, such as user personal information, in accordance with relevant laws and regulations and do not violate public order and good morals.
[0014] Figure 1 An exemplary architecture 100 is shown that the vector representation methods and apparatus of this disclosure can be applied.
[0015] like Figure 1 As shown, the system architecture 100 may include terminal devices 101, 102, and 103, a network 104, and a server 105. The communication connections between terminal devices 101, 102, and 103 form a network topology. Network 104 serves as the medium for providing communication links between terminal devices 101, 102, and 103 and server 105. Network 104 may include various connection types, such as wired or wireless communication links or fiber optic cables, etc.
[0016] Terminal devices 101, 102, and 103 can be hardware or software that supports network connectivity for data acquisition, interaction, and processing. When terminal devices 101, 102, and 103 are hardware, they can be various electronic devices that support network connectivity, information acquisition, interaction, display, and processing functions, including but not limited to smartphones, tablets, e-book readers, laptops, and desktop computers. When terminal devices 101, 102, and 103 are software, they can be installed in the aforementioned electronic devices. They can be implemented as, for example, multiple software programs or software modules used to provide distributed services, or as a single software program or software module. No specific limitations are imposed here.
[0017] Server 105 can be a server that provides various services, such as a server that constructs a heterogeneous graph representing the relationships between object nodes, resource nodes, and topic nodes, and recommends resources to the users of terminal devices 101, 102, and 103 based on the heterogeneous graph. As an example, server 105 could be a cloud server.
[0018] It should be noted that a server can be either hardware or software. When the server is hardware, it can be implemented as a distributed server cluster consisting of multiple servers, or as a single server. When the server is software, it can be implemented as multiple software programs or software modules (such as software programs or software modules used to provide distributed services), or as a single software program or software module. No specific limitations are made here.
[0019] It should also be noted that the vector representation method provided in the embodiments of this disclosure is generally executed by a server, but the possibility of it being executed by a terminal device, or by a server and a terminal device cooperating with each other, is not excluded. Accordingly, all parts (e.g., units) of the vector representation device can be set entirely in the server, all in the terminal device, or separately in the server and the terminal device.
[0020] It should be understood that Figure 1 The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be included. When the electronic devices running the vector representation method do not require data transmission with other electronic devices, the system architecture may only include the electronic devices running the vector representation method (e.g., servers or terminal devices).
[0021] Please refer to Figure 2 , Figure 2 A flowchart illustrating a vector representation method provided in this embodiment of the disclosure. Flowchart 200 includes the following steps: Step 201: Determine positive sample pairs and negative sample pairs based on the relationships between nodes in the heterogeneous graph of the recommended scenarios.
[0022] In this embodiment, the execution body of the vector representation method (e.g., Figure 1 The server in the middle can be remotely accessed via wired or wireless network connection. It will obtain the heterogeneous graph of recommended scenarios from the local machine and determine positive and negative sample pairs based on the relationship between nodes in the heterogeneous graph of recommended scenarios.
[0023] Recommendation scenarios refer to personalized intelligent recommendation scenarios on internet content platforms, such as short videos, images and text, audio, news, e-commerce products, live streaming, and other content recommendation scenarios. Correspondingly, resources are the various object content / products that the platform pushes to the target audience (users) in the recommendation scenario. Specifically, these can be manifested as independent objects within the platform that can be interacted with by users, such as short videos, image and text news, audio programs, e-commerce products for sale, live streaming sessions, and course content.
[0024] The recommended scenario heterogeneous graph includes object node u, resource node i, topic node t, and the edge u2i between object node u and resource node i, the edge u2t between object node u and topic node t, and the edge i2t between resource node i and topic node t.
[0025] Object node u is the target subject node for personalized recommendation services in the recommendation scenario. It uniquely maps to a single independent user (such as a registered user or active visitor) in the recommendation platform and is the service recipient of the platform's recommendation behavior. Each object node u is associated with a unique subject identifier and carries basic attributes such as the user's age group, gender, and stage (activity level).
[0026] Resource node i is an independent object node pushed to the user by the platform in the recommendation scenario. It uniquely maps to a single interactive resource within the recommendation platform and is the object pushed by the platform's recommendation behavior. Each resource node i is associated with a unique resource identifier and carries characteristic information such as the resource's category, attributes, tags, and association information.
[0027] The topic node t is a media feature node in the recommendation scenario that describes the attributes of resource content and user interests. It uniquely maps to an independent content theme / category tag and is the core bridge connecting object node u and resource node i. Each topic node t is associated with a unique topic identifier and carries feature information such as topic classification, domain, relevance, and popularity.
[0028] Edge u2i is the interaction association edge between object node u and resource node i, used to quantitatively represent the direct interaction relationship between users and resources in the recommendation scenario. When a user performs any effective interaction behavior such as clicking, browsing, collecting, purchasing, or playing a resource, an edge u2i is established between the corresponding object node u and resource node i. The edge can be configured with weights, and the weight values are quantitatively set according to the type, frequency, depth, and other dimensions of the interaction behavior.
[0029] Edge u2t is an interest association edge between object node u and topic node t, used to quantitatively represent the interest matching relationship between users and topics in the recommendation scenario. When a user's interactive resource is associated with a topic node, an edge u2t is established between the corresponding object node u and topic node t. The edge can be configured with weights, and the weight values are quantitatively set according to the frequency, depth, preference and other dimensions of the user's interaction with the resource under the topic, directly reflecting the user's degree of interest in the topic.
[0030] Edge i2t is the attribute association edge between resource node i and topic node t, used to quantitatively represent the content matching relationship between resources and topics in the recommendation scenario. When the content attributes, category tags, and core themes of a resource match a topic node, i2t edge is established between the corresponding resource node i and topic node t. The edge can be configured with weights, and the weight values are quantitatively set according to the matching degree, relevance, and fit of the resource and topic, directly reflecting the content theme category to which the resource belongs.
[0031] As an example, positive and negative sample pairs are determined based on the existence and validity of the connecting edges between nodes in the heterogeneous graph of the recommendation scenario. Specifically, all nodes in the heterogeneous graph are traversed. If there is a connecting edge of any type u2i, u2t, or i2t between two nodes, and the weight value of the edge is greater than a preset effective weight threshold, the two nodes are determined to have a real and effective connection, and they are constructed as a positive sample pair. If there is no connecting edge of any type between two nodes, and they belong to the effective node type combination (ui, ut, it) in the recommendation scenario, the two nodes are determined to have no connection, and they are constructed as a negative sample pair.
[0032] As another example, positive and negative sample pairs are determined based on the correlation strength and attribute heterogeneity of nodes in the heterogeneous graph of the recommendation scenario. Specifically, for each target node in the heterogeneous graph, the correlation strength (correspondence edge weight × interaction frequency) of all its directly related nodes is calculated, and the top K (K is a preset threshold for the number of positive samples) related nodes are selected to construct positive sample pairs with the target node; for the target node, nodes with no direct / indirect correlation with the target node and no overlap in core attributes (such as resource category, topic domain, user tags) are randomly selected from the heterogeneous graph, and L (L is a preset threshold for the number of negative samples) nodes are selected to construct negative sample pairs with the target node.
[0033] In some implementations, the aforementioned execution entities can construct a heterogeneous graph of recommendation scenarios in the following ways: First, based on the full data from the user side, resource side, and topic side of the recommendation platform, three types of core nodes are constructed: object node u, resource node i, and topic node t. Each type of node adopts a standardized structure of "unique identifier + original feature vector" to ensure the uniqueness of the node and the quantifiability of the features.
[0034] For object node u, the unique account identifier of the platform user is used as the node ID (Identity Document). The user's basic attribute features and behavioral statistical features are integrated to generate the original feature vector of the node. Among them, the basic attribute features include age, gender, and user lifecycle stage (such as new user, active user, mature user), and the behavioral statistical features include the total number of platform interactions in the recent period (e.g., the last 30 days) and core category preference. Discrete features (such as gender and stage) are processed using one-hot encoding, and continuous features (such as age and number of interactions) are processed using normalization. After concatenation, a fixed-dimensional original feature vector of the object node is formed.
[0035] For resource node i, the unique content identifier of the independent resource within the platform is used as the node ID. Source tags are added according to the source attributes of "internal resource" and "external resource". The category features and publication features of the resource are integrated to generate the original feature vector of the node. Category features include the content category to which the resource belongs (such as news, short video, audio), and publication features include publication timestamp and author type (such as official, UGC (User Generated Content)). Similarly, discrete features are encoded and continuous features are normalized to form the original feature vector of the resource node with the same dimension as the object node.
[0036] For topic node t, the unique topic identifier of the platform's topic system is used as the node ID. Source tags are added according to the source attributes of "internal topic" and "external topic". The topic's domain features and popularity features are integrated to generate the original feature vector of the node. Domain features include the industry domain to which the topic belongs (such as technology, lifestyle, entertainment), and popularity features include the total amount of related resources and the total amount of user interactions in the recent period (e.g., the last 7 days). After feature encoding and normalization, the original feature vector of the topic node is formed with the same dimensions as the first two types of nodes.
[0037] Then, based on the user interaction logs and resource tagging system of the recommendation platform, three types of undirected association edges (u2i, i2t, u2t) are constructed between object nodes, resource nodes, and topic nodes. The construction of the edges is based on "real association as the core and weight quantification as a supplement" to accurately represent the association strength between nodes and provide an objective basis for the subsequent determination of positive and negative sample pairs.
[0038] For u2i edges, iterate through all user interaction logs on the platform and filter for valid interaction behaviors (such as clicks, browsing time exceeding thresholds, favorites, and likes). If object node u generates at least one valid interaction behavior with resource node i, then a u2i edge is established between the two nodes; the edge weight is calculated based on the importance of the interaction behavior, such as a favorite weight of 0.5, a like weight of 0.2, and a valid browsing weight of 0.1. The sum of the weights is the final association weight of the u2i edge.
[0039] For i2t edges, based on the platform's resource-topic tag matching system, for each resource node i, a topic node t (including internal and external topics) corresponding to its core content is matched. If the matching degree between the content topic of resource node i and topic node t exceeds a preset threshold (e.g., 80%), an i2t edge is established between the two nodes; the weight of the edge is directly taken as the actual matching degree between the resource and the topic. The higher the matching degree, the closer the attribute association between the resource and the topic.
[0040] For u2t edges, the user's interest in the topic is indirectly inferred based on the u2i edge association relationship of the object node u. For each object node u, the topic nodes t corresponding to all its associated resource nodes i are counted. If the proportion of resources under a certain topic t that object node u interacts with exceeds a preset threshold (e.g., 15%), then a u2t edge is established between u and t. The weight of the edge is the proportion of the number of times resources under that topic are interacted with to the total number of times the user interacts. The higher the proportion, the stronger the user's interest in that topic.
[0041] Finally, the three types of nodes and three types of associated edges that have been constructed are integrated to form a standardized heterogeneous graph of recommendation scenarios. This graph is then persistently stored using a graph database (such as Neo4j) and a graph data index is generated to ensure the efficient execution of subsequent operations such as node sequence sampling, neighbor node filtering, and sample pair determination.
[0042] Using node ID as the unique association key, the object node set, resource node set, topic node set, u2i edge set, i2t edge set, and u2t edge set are associated and integrated to form a triplet data structure of "node-edge-node", which constitutes a complete heterogeneous graph of recommendation scenario.
[0043] A secondary index is created for the "source tag" and "core category / domain" attributes of each type of node, and a numerical index is created for the "association weight" of each type of edge. The integrated heterogeneous graph data is written into the graph database, and the neighbor relationships of the nodes are recorded in the form of adjacency list storage, so as to realize fast node lookup and efficient reading of edge weight, providing stable and callable graph data support for subsequent processing.
[0044] It should be noted that in the entire process of data collection for building heterogeneous graphs for recommendation scenarios, data security and privacy protection standards are strictly followed. Data collection boundaries are clearly defined with user authorization, and privacy risks are eliminated by combining anonymization processing to ensure that all data used for graph construction, node feature generation, and model training are legal and compliant.
[0045] In some optional implementations of this embodiment, the execution entity performs step 201 as follows: First step, sample node sequences from the heterogeneous graph of the recommended scenario; Second step, determine positive sample pairs and negative sample pairs based on the association between nodes in the node sequence.
[0046] As an example, from the heterogeneous graph of the recommended scenario, starting with any randomly selected node, the system continuously walks along the natural edges between nodes until the walking length reaches a preset value. The nodes passed in sequence during the walk are then combined to form a node sequence. All generated node sequences are traversed, and the tightness of the association between nodes is determined based on the direct relationship and association frequency between nodes in the sequence. Based on the tightness of the association, node pairs with real and effective associations are selected as positive sample pairs, and node pairs with no actual associations are selected as negative sample pairs.
[0047] In this implementation, positive and negative sample pairs are determined by sampling the node sequence and their correlation, which provides high-quality samples that fit the graph topology for the vector optimization process, and helps to improve the accuracy and comprehensiveness of the final vector representation.
[0048] In some optional implementations of this embodiment, the execution entity performs the second step described above in the following manner to determine positive sample pairs and negative sample pairs: for nodes in the node sequence, positive sample pairs are constructed based on positive sample nodes in the node sequence whose hop count with the current node is within the first hop count threshold and the current node, and negative sample pairs are constructed based on negative sample nodes in the heterogeneous graph of the recommendation scenario whose hop count with the current node exceeds the first hop count threshold and the current node.
[0049] The threshold for the first hop count can be flexibly set according to actual needs, for example, 2.
[0050] For any current node in the node sequence, traverse all other nodes in the node sequence, calculate the hop count between each node and the current node in the sequence, and determine the nodes with a hop count ≤ 2 as positive sample nodes. Pair the current node with each positive sample node to construct a positive sample pair. At the same time, traverse all nodes in the heterogeneous graph of the recommendation scene, calculate the shortest path hop count between each node and the current node in the heterogeneous graph, determine the nodes with a hop count > 2 as negative sample nodes, and randomly select a preset number of negative sample nodes to pair with the current node to construct a negative sample pair.
[0051] The aforementioned execution entity can also identify nodes with a hop count greater than 2 in the node sequence as negative sample nodes, randomly select a preset number of negative sample nodes and combine them with the current node in pairs to construct negative sample pairs.
[0052] In this implementation, positive and negative samples are divided by a hop count threshold, which accurately defines the boundaries of node associations and improves the effectiveness and accuracy of sample pairs.
[0053] In some optional implementations of this embodiment, the execution entity performs the first step described above to determine the node sequence in the following manner: it samples the node sequence from the heterogeneous graph of the recommended scenario using preset meta-path rules.
[0054] Meta-path rules are directional rules that traverse the heterogeneous graph of recommendation scenarios according to the preset node type association order. They are composed of object, resource, topic nodes and u2i, i2t, u2t association edges, simulating the user's real behavior path on the platform and quantifying the semantic association relationship between nodes.
[0055] As an example, meta-path rules include: u2i-i2t-t2i-i2u indicates that users who like the same topics and resources are similar to each other; u2i-i2t indicates the resource that the user interacts with and belongs to the corresponding topic category; u2t-t2i represents a user's interest in a certain topic, and corresponds to matching resources under that topic; i2t-t2i means "resources belonging to the same topic and having similar content".
[0056] As an example, firstly, based on the user behavior logic of the recommendation scenario, several meta-path rules are preset. Each rule is composed of object node u, resource node i, topic node t, and u2i, i2t, u2t related edges in a specific semantic order.
[0057] Then, iterate through all nodes in the heterogeneous graph of the recommended scene, taking each node as an independent starting node for the walk, and execute the node walk operation in sequence according to all preset meta-path rules.
[0058] For each meta-path rule walk for each starting node, a directional walk is performed along the node type and associated edge direction specified by the rule. The number of walk steps is fixed as the specified number of jumps, such as 10 jumps, which means starting from the starting node, passing through 10 associated edges and connecting 10 subsequent nodes in sequence.
[0059] To ensure the richness of the node sequence sampling, for each starting node, the same meta-path rule is repeated 8 times, and a weighted sampling strategy is used for each walk. When selecting the next associated node at each hop, the weights of each associated edge of the current node are used as the basis. The higher the weight value of an edge, the greater the probability that its corresponding downstream node will be selected as the next hop node.
[0060] Each time a 10-hop directional walk starting from the starting node is completed, all nodes visited in the order of the walk are arranged sequentially to form a node sequence that conforms to the corresponding meta-path rule. After all starting nodes have completed repeated walks according to all preset meta-path rules, the resulting sequence of nodes is the sampling result.
[0061] In this implementation, node sequences are sampled according to meta-path rules, which aligns with the node association logic of the recommendation scenario and enhances the scenario adaptability of the sample pairs.
[0062] Step 202: Combine the original feature vector of the node with the original feature vector of the target neighbor node to obtain the node's representation vector.
[0063] In this embodiment, the aforementioned execution entity combines the original feature vector of the node and the original feature vector of the target neighbor node to obtain the node's representation vector. The original feature vector is the basic numerical vector constructed for each node in the heterogeneous graph. It is obtained by encoding, normalization, and other quantization processes based on the node's inherent attributes and associated features, and serves as the learning basis for the node's representation vector.
[0064] For each node in the heterogeneous graph of the recommendation scenario, the target neighbor nodes can be all or some nodes within a preset hop count threshold. Hop count refers to the number of edges along the shortest path between two nodes in the heterogeneous graph, and is a metric for measuring the topological association distance between nodes. One hop represents a directly connected node, and n hops represent nodes indirectly connected via n edges. For example, the preset hop count threshold is 2, meaning the target neighbor nodes are all or some nodes within one or two hops of the current node.
[0065] As an example, for each node in the heterogeneous graph of the recommendation scenario, a feature vector weighted fusion method is used to combine the node's original feature vector with the original feature vectors of the target neighbor nodes to obtain the node's representation vector. Specifically, firstly, a first preset weight is assigned to the node's own original feature vector, and a second preset weight is uniformly assigned to the original feature vectors of all target neighbor nodes (the first preset weight is greater than the second preset weight to ensure the dominance of the node's own features); then, the original feature vectors of all target neighbor nodes are averaged to obtain a neighbor feature fusion vector; finally, the node's original feature vector and the neighbor feature fusion vector are linearly weighted according to their corresponding weights, and the resulting fusion vector is the node's representation vector.
[0066] As another example, for each node in the heterogeneous graph of the recommendation scenario, a feature vector concatenation dimensionality reduction method is used to combine the original feature vector of the node with the original feature vectors of the target neighbor nodes to obtain the node representation vector. Specifically, firstly, the original feature vector of the node is concatenated with the original feature vectors of all target neighbor nodes in sequence to obtain a high-dimensional concatenated feature vector; then, a preset dimensionality reduction algorithm, such as PCA (Principal Component Analysis) or LDA (Linear Discriminant Analysis), is used to reduce the dimensionality of the high-dimensional concatenated feature vector, removing feature redundancy and retaining core feature information; finally, the dimensionality-reduced feature vector is normalized, and the resulting standardized vector is the representation vector of the node.
[0067] In some optional implementations of this embodiment, the execution entity performs step 202 as follows to obtain the node representation vector: The first step is to determine the target neighbor node from the candidate neighbor nodes whose hop count between the node and the node is within the second hop count threshold in the heterogeneous graph of the recommended scenario. The second step is to obtain the node's representation vector by combining the node's original feature vector and the target neighbor node's original feature vector.
[0068] The second hop threshold can be flexibly set according to actual needs, for example, to 2.
[0069] For each node to be processed in the node sequence, all nodes whose shortest path hop count to that node is within the second hop count threshold are retrieved from the heterogeneous graph of the recommended scene and selected as candidate neighbor nodes. Then, the nodes are filtered from high to low according to the weight of the edges between them to determine a specified number of target neighbor nodes. Finally, the original feature vector of the node to be processed is fused with the original feature vector of the target neighbor nodes through a feature fusion algorithm to obtain the representation vector of the node.
[0070] In this implementation, candidate neighbor nodes are filtered by the hop count threshold to accurately define the effective feature fusion range. By combining the original feature vector of the current node with the original feature vector of the neighbor nodes, the representation vector has both its own attributes and surrounding related features.
[0071] In some optional implementations of this embodiment, the execution entity performs the first step described above to determine the target neighbor node in the following manner: for each hop number within the second hop number threshold, a specified number of target neighbor nodes are selected from the candidate neighbor nodes associated with the target neighbor node that is a hop number away from the node and a hop number away from the node.
[0072] Among them, the target neighbor node that is one hop away from the node is selected from the candidate neighbor nodes associated with the node.
[0073] For each node in the node sequence, a hierarchical recursive method is used to filter a specified number of target neighbor nodes for each hop count within the second hop count threshold: For hop count n, first identify the selected target neighbor nodes that are n hops away from the current node, then filter out the candidate neighbor nodes that are n+1 hops away from the current node from its associated nodes, and select a specified number of them as target neighbor nodes for that hop count by sorting them according to their association weight; among them, the target neighbor nodes that are 1 hop away from the current node are obtained by directly filtering a specified number of candidate neighbor nodes directly connected to the node to be processed according to their weight.
[0074] Taking 2 hops as the threshold for the second hop count as an example, we specify that 3 target neighbor nodes are selected for each hop. First, from the candidate neighbor nodes directly connected to the node to be processed, 3 nodes are selected as 1-hop target neighbor nodes according to the weight of the associated edges from high to low. Then, from the associated nodes of these 3 1-hop nodes, nodes that are 2 hops away from the current node are selected, and 3 nodes are selected according to the weight of each node, for a total of 9 nodes as 2-hop target neighbor nodes.
[0075] In this implementation, a hierarchical recursive method is used to filter target neighbor nodes, which ensures the hierarchy and relevance of neighbor nodes. Specifying the number of nodes to filter makes the computational cost of feature fusion controllable and improves vector generation efficiency.
[0076] In some optional implementations of this embodiment, the execution entity performs the first step described above in the following manner to obtain the node representation vector: First, for each hop count within the second hop count threshold, the initial combination vector is obtained by combining the original feature vectors of the target neighbor nodes that are hops away from the node.
[0077] Then, following the order of hop count from smallest to largest, the following combination operation is performed iteratively, and the final vector to be combined is used as the representation vector of the node: Combining the initial combination vector corresponding to this combination operation with the vector to be combined, the vector to be combined for the next combination operation is obtained. Here, the vector to be combined for the first combination operation is the original feature vector of the node, and the hop count of the initial combination vector corresponding to this combination operation is the same as the round of this combination operation.
[0078] As an example, the original feature vectors of all target neighbor nodes within each hop count threshold are first aggregated by mean to obtain the initial combination vector corresponding to each hop count. Then, the fusion is iterated in ascending order of hop count. The vector to be combined in the first iteration is the original feature vector of the current node. The hop count of the initial combination vector in each iteration corresponds one-to-one with the iteration round. In each round, the current vector to be combined is fused with the corresponding initial combination vector. The final vector to be combined is the representation vector of the node.
[0079] Taking a second hop threshold of 2 as an example, the mean of the original feature vectors of the three 1-hop target neighbor nodes is first calculated to obtain the initial 1-hop combination vector; the mean of the original feature vectors of the nine 2-hop target neighbor nodes is then calculated to obtain the initial 2-hop combination vector. In the first iteration, the original feature vector of the current node is fused with the initial 1-hop combination vector to obtain a new vector to be combined; in the second iteration, the vector to be combined obtained in the first iteration is fused with the initial 2-hop combination vector, and the final result is the node representation vector.
[0080] In this implementation, the initial combined vector is iteratively fused according to the number of hops, allowing the node representation vector to absorb the feature information of neighboring nodes with different hop counts layer by layer. The feature fusion is more hierarchical and can accurately characterize the topological association features of nodes.
[0081] In some optional implementations of this embodiment, the execution entity obtains the vector to be combined for the next combination operation in the following way: according to the preset combination weight, the initial combination vector corresponding to the current combination operation and the vector to be combined are combined to obtain the vector to be combined for the next combination operation.
[0082] The preset combination weights can be flexibly set according to actual needs. For example, the weight of the initial combination vector corresponding to this combination operation is 40%, and the weight of the vector to be combined is 60%.
[0083] After assigning preset combination weights to the vector to be combined and the current initial combination vector during the iteration process (where the weight of the vector to be combined is higher than that of the initial combination vector, and the sum of the weights is 1), the vector to be combined and the initial combination vector are multiplied by their respective preset weights to obtain two weighted feature vectors; the two weighted feature vectors are linearly added dimension by dimension, and the resulting fused feature vector is the vector to be combined in the next combination operation.
[0084] By using preset weights for feature fusion, we can learn information from neighbors without losing the characteristics of the nodes themselves, making the generated representation vector more closely match the node's own attributes and core related features.
[0085] Step 203: Update the representation vector using the loss function.
[0086] In this embodiment, the execution entity updates the representation vector using a loss function. The loss function is used to maximize the similarity between the representation vectors of nodes in a positive sample pair and minimize the similarity between the representation vectors of nodes in a negative sample pair.
[0087] As an example, a joint loss gradient descent method is used to update the node representation vector. Specifically, firstly, based on the representation vectors of positive and negative sample pairs, the similarity loss values for positive and negative sample pairs are calculated separately. These are then weighted and summed according to a preset ratio to obtain the total loss function value. The loss calculation logic for positive sample pairs is designed with the goal of maximizing similarity, while the loss calculation logic for negative sample pairs is designed with the goal of minimizing similarity. Subsequently, the gradient descent algorithm is used to calculate the partial derivatives of the total loss function value with respect to the feature values of each dimension of the node representation vector, obtaining the vector update gradient. Finally, along the gradient descent direction, the feature values of each dimension of the representation vector are iteratively updated according to a preset learning rate to obtain the updated representation vector.
[0088] As another example, the sample pair error reverse correction method is used to update the node representation vector. Specifically, firstly, all positive and negative sample pairs are traversed, and the error value between the actual similarity and the target similarity (preset maximum value) of each positive sample pair is calculated, and the error value between the actual similarity and the target similarity (preset minimum value) of each negative sample pair is calculated. Then, all error values are normalized, and error weights are assigned to each sample pair according to the magnitude of the error value; the larger the error value, the higher the corresponding weight. Finally, based on the error weights, the representation vectors in each sample pair are corrected in a directional manner: the node vectors in positive sample pairs are corrected in the direction of increasing similarity, and the node vectors in negative sample pairs are corrected in the direction of decreasing similarity. The correction step size is adapted to the error weights according to a preset ratio, thus completing the update of the node representation vector.
[0089] In this embodiment, the execution entity can iteratively execute steps 201-203 until a preset termination condition is met, obtaining the final representation vector of the nodes in the heterogeneous graph of the recommended scenario. The preset termination condition may be, for example, that the number of iterations exceeds a preset threshold, the iteration time exceeds a preset time threshold, or the loss tends to converge.
[0090] In some optional implementations of this embodiment, the loss function includes a first loss function and a second loss function. The first loss function is used to maximize the similarity between the representation vectors of nodes in a positive sample pair and minimize the similarity between the representation vectors of nodes in a negative sample pair. The second loss function is used to maximize the similarity between the representation vector and the perturbation vector, which is obtained by adding random perturbation to the representation vector.
[0091] The first loss function is, for example, the NCE (Noise Contrastive Estimation) loss function, which serves as the main loss function. It quantifies the vector similarity loss between positive and negative sample pairs. By constructing a probability comparison between positive and negative (noise) sample pairs, it maximizes the cosine similarity of the node representation vectors of positive sample pairs while minimizing the cosine similarity of the node representation vectors of negative sample pairs, thus achieving accurate learning of the relationships between nodes. The second loss function is, for example, the SimGCL (Simple Graph Contrastive Learning) loss function, which serves as an auxiliary loss function. It adds a small Gaussian random perturbation to the node representation vector to generate a perturbation vector. By maximizing the similarity between the original representation vector and the perturbation vector, the model learns more robust and interference-resistant node feature representations, effectively alleviating the feature overfitting problem in graph data.
[0092] In this implementation, the aforementioned execution entity updates the representation vector in the following way: by using a first loss function and a second loss function to update the representation vector.
[0093] As an example, firstly, based on the constructed positive and negative sample pairs, the current representation vector of the nodes in all sample pairs is extracted. Following the calculation logic of NCE Loss, the similarity score of the positive sample pairs and the noise contrast score of the negative sample pairs are calculated. The NCE loss value, denoted as L1, is obtained by solving the log-likelihood function.
[0094] Then, for the current representation vector of all nodes, a Gaussian random perturbation with a preset variance is added to generate the perturbation vector corresponding to each node. The vector dimension before and after the perturbation is kept consistent. According to the calculation logic of SimGCL Loss, the cosine similarity between the original representation vector and the perturbation vector is calculated. The SimGCL loss value is obtained by solving the mutual information maximization criterion, which is denoted as L2.
[0095] Then, preset weights are assigned to the two loss functions. For example, the weight α of the main loss NCE Loss is set to 0.7, and the weight β of the auxiliary loss SimGCL Loss is set to 0.3 (α+β=1). The total loss value of this iteration is calculated by the formula total loss value L=α×L1+β×L2.
[0096] Then, the stochastic gradient descent (SGD) optimization algorithm is adopted, with the goal of minimizing the total loss value L. The partial derivatives of the total loss with respect to the feature values of each dimension of the representation vector of all nodes are calculated to obtain the gradient direction of vector update. The representation vector of all nodes is iteratively updated dimension by dimension along the gradient descent direction according to a preset learning rate (e.g., 0.01) to obtain the updated node representation vector.
[0097] In this implementation, the primary and secondary loss functions are optimized in tandem, which not only accurately learns the topological relationship features between nodes, but also improves the robustness of the representation vector, effectively avoiding overfitting and making the generated vectors more in line with the feature learning needs of the recommendation scenario.
[0098] See also Figure 3 , Figure 3 This is a schematic diagram of application scenario 300 of the vector representation method according to this embodiment. During the process of user 301 browsing a short video application through terminal device 302, server 303 recommends short videos based on a heterogeneous recommendation scene graph 304. First, the server determines positive and negative sample pairs based on the relationships between nodes in the heterogeneous recommendation scene graph, where the graph represents the relationships between object nodes, short video nodes, and topic nodes. Then, it combines the original feature vector of the node with the original feature vector of the target neighbor node to obtain the node's representation vector. Next, it updates the representation vector using a loss function, where the loss function maximizes the similarity between the representation vectors of nodes in positive sample pairs and minimizes the similarity between the representation vectors of nodes in negative sample pairs. Finally, it recommends short videos to user 301 based on the optimized representation vectors.
[0099] In this embodiment, positive and negative sample pairs are determined based on the relationships between nodes in the heterogeneous graph of the recommendation scenario. The heterogeneous graph of the recommendation scenario represents the relationships between object nodes, resource nodes, and topic nodes. The representation vector of a node is obtained by combining the original feature vector of the node and the original feature vector of the target neighbor node. The representation vector is updated using a loss function, which maximizes the similarity between the representation vectors of nodes in positive sample pairs and minimizes the similarity between the representation vectors of nodes in negative sample pairs. By introducing topic nodes to construct a heterogeneous graph of the recommendation scenario and combining contrastive learning to optimize the vector space, the accuracy and comprehensiveness of the representation vectors are improved, which helps to improve the accuracy of resource retrieval and ranking in the recommendation system.
[0100] In some optional implementations of this embodiment, the execution entity may also perform the following operations: using multiple recall methods, based on the representation vector, to determine the recommended resources for the target object.
[0101] Various recall methods include, but are not limited to, UCF (User-based Collaborative Filtering), ICF (Item-based Collaborative Filtering), and ANN (Approximate Nearest Neighbor).
[0102] After the node representation vectors are trained, based on the personalized recommendation requirements of the recommendation scenario, multiple retrieval methods for adaptive graph vector features are preset. Each retrieval method uses the similarity calculation of node representation vectors as its core logic. For the user representation vector of the target object, resource nodes in the heterogeneous graph of the recommendation scenario are independently retrieved through each retrieval method to obtain the candidate resource set corresponding to each retrieval method. All candidate resource sets are integrated, deduplicated, and preliminarily screened to finally determine the recommended resources for the target object.
[0103] This implementation combines multiple recall methods with representation vector retrieval to overcome the limitations of single-recall features, expand the coverage of resource retrieval, and improve the richness and accuracy of recommended resources.
[0104] In some optional implementations of this embodiment, the execution entity performs the resource recommendation operation in the following manner: The first step is to use a resource-based collaborative filtering recall method to determine the first recommended resource for the target object based on the representation vector.
[0105] The resource-based collaborative filtering (ICF) recall method is adopted. Based on the resource node representation vectors that the target object has interacted with, the similarity between the target object and the full set of resource node representation vectors is calculated, and the first recommended resource is obtained by filtering from high to low similarity.
[0106] The second step involves using an object-based collaborative filtering recall method to determine the second recommended resource for the target object based on its representation vector.
[0107] The object-based collaborative filtering (UCF) recall method is adopted. Based on the user representation vector of the target object, the similarity between the target object and the representation vector of all user nodes is calculated. Similar users are selected and their high-interaction resources are mined to obtain the second recommendation resources.
[0108] The third step involves using a topic-based filtering and recall method to determine the third recommended resource for the target object based on the representation vector.
[0109] A topic-based filtering (T2I) recall method is adopted. Based on the topic node representation vector associated with the target object, the similarity between the target object and the node representation vector of the entire resource is calculated, and the third recommended resource is obtained by filtering according to the similarity.
[0110] It should be noted that the first to third steps mentioned above can be executed in parallel or in a predetermined order, and no limitation is made here.
[0111] In some examples, the node representation vector is a high-dimensional representation vector, such as 4096-dimensional. It can be reduced to a low-dimensional vector, such as 64-dimensional, and the processing operations in the first to third steps above can be performed.
[0112] The fourth step is to combine the first, second, and third recommended resources to obtain the recommended resources.
[0113] The first, second, and third recommended resources are merged, and after deduplication and score fusion, the final recommended resources for the target object are obtained.
[0114] This implementation integrates three recall methods: ICF, UCF, and T2I. It mines recommended resources from multiple dimensions, including resources, users, and topics, to achieve feature complementarity. This makes the recommendation results more in line with the interests and preferences of the target audience, thereby improving the accuracy and comprehensiveness of resource recommendations.
[0115] In some optional implementations of this embodiment, the execution entity performs the third step described above to obtain the third recommended resource in the following manner: First, based on the heterogeneous graph of the recommendation scenario, the historical resources that the target object has interacted with are determined; then, based on the correspondence between resources and topics, the target topic to which the historical resources belong is determined; finally, based on the similarity between the representation vector corresponding to the target topic and the representation vector of the resource node in the heterogeneous graph of the recommendation scenario, the third recommended resource of the target object is determined.
[0116] As an example, firstly, from the heterogeneous graph of the recommendation scene, the u2i association edges of the target object nodes are extracted, and all historical resource nodes that have generated effective interaction behavior for the target object are selected to determine the historical resources; secondly, [the process continues]; then, based on the mapping dictionary representing the correspondence between resources and topics, the target topics required for each historical resource are determined; then, the representation vectors of all target topics are extracted, and cosine similarity is calculated with the representation vectors of all resource nodes in the heterogeneous graph of the recommendation scene to obtain the similarity value between each resource node and the target topic; finally, the resource nodes are sorted from high to low according to the similarity value, and a preset number of resource nodes are selected to determine the third recommended resource for the target object.
[0117] In this implementation, the similarity recall based on topic vectors and resource vectors, using topics as a medium to connect user history and candidate resources, can accurately capture the core of user interests and improve the matching degree between resources and user interests.
[0118] In some optional implementations of this embodiment, the execution entity may also perform the following operations: adjust the recommendation order of the recommended resources based on the similarity between the representation vector of the target object and the representation vector of the recommended resources, the similarity between the representation vector of the topics interacted with by the target object and the representation vector of the recommended resources, and the similarity between the representation vector of the resources interacted with by the target object and the representation vector of the recommended resources.
[0119] As an example, firstly, three types of core representation vectors are extracted to ensure that all vector dimensions are consistent and the format is standardized, providing a basis for similarity calculation: (1) the representation vector of the target object (denoted as V_u); (2) the representation vectors of all topics that the target object has interacted with (denoted as V_t1, V_t2, ..., V_tn, where n is the total number of topics that the target object has interacted with); (3) the representation vectors of all resources that the target object has interacted with (denoted as V_i1, V_i2, ..., V_im, where m is the total number of resources that the target object has interacted with); (4) the representation vectors of all candidate recommended resources (denoted as V_ir1, V_ir2, ..., V_irk, where k is the total number of candidate recommended resources).
[0120] Then, the cosine similarity algorithm is used to calculate the three types of similarity respectively, to ensure that the calculation results are accurate and quantifiable (the similarity value ranges from [0,1], and the larger the value, the higher the matching degree): (1) Calculate the similarity between the target object and the candidate recommendation resource (denoted as S1): For each candidate recommendation resource vector V_ir, calculate its cosine similarity with the target object vector V_u. The formula is S1=cos(V_u,V_ir), which directly represents the overall matching degree between the target object and the recommendation resource. (2) Calculate the similarity between the topics that the target object has interacted with and the candidate recommended resources (denoted as S2): For each candidate recommended resource vector V_ir, calculate the cosine similarity between it and all topic vectors (V_t1 to V_tn) that the target object has interacted with. Take the mean of all similarities as the S2 value of the candidate resource, that is, S2=(cos(V_t1,V_ir)+cos(V_t2,V_ir)+...+cos(V_tn,V_ir)) / n, which represents the degree of fit between the recommended resources and the target object's interest topics; (3) Calculate the similarity between the resources that the target object has interacted with and the candidate recommended resources (denoted as S3): For the vector V_ir of each candidate recommended resource, calculate the cosine similarity between it and all resource vectors (V_i1 to V_im) that the target object has interacted with. Take the mean of all similarities as the S3 value of the candidate resource, that is, S3=(cos(V_i1,V_ir)+cos(V_i2,V_ir)+...+cos(V_im,V_ir)) / m, which represents the degree of fit between the recommended resources and the historical interaction preferences of the target object.
[0121] Then, based on the actual needs of the recommendation scenario, preset weights are assigned to the three types of similarity (the total weight is 1, which can be dynamically adjusted according to actual needs). For example, the weight of S1 is set to 0.4 (emphasizing matching of user's own characteristics), the weight of S2 is set to 0.3 (emphasizing matching of topic interests), and the weight of S3 is set to 0.3 (emphasizing matching of historical behavior). For each candidate recommendation resource, its final score is calculated using the formula "total ranking score S = 0.4 × S1 + 0.3 × S2 + 0.3 × S3". The higher the score, the more closely the resource matches the target audience's interests.
[0122] Finally, all candidate recommended resources are sorted from highest to lowest according to their total ranking score, with the highest-scoring resource at the top of the recommendation list, and so on down. If there are candidate resources with the same score, resources with higher average similarity to topics that have been interacted with by the target object are given priority. The final adjusted recommendation order is then used to display recommended resources to the target object.
[0123] In this implementation, a weighted sorting method is used, which combines the vector similarity of three dimensions: user identity, interest topics, and historical interactions. This avoids the one-sidedness of sorting based on a single dimension, accurately captures the core of user interests, improves the rationality and relevance of the recommendation order, and optimizes the user recommendation experience.
[0124] Continue to refer to Figure 4 The illustration shows a schematic flow 400 of yet another embodiment of the vector representation method according to the present disclosure. Flow 400 includes the following steps: Step 401: Using preset meta-path rules, sample node sequences from the recommended scene heterogeneous graph.
[0125] The recommended scenario heterogeneous graph represents the relationships between object nodes, resource nodes, and topic nodes.
[0126] Step 402: For nodes in the node sequence, construct positive sample pairs based on positive sample nodes in the node sequence whose hop count with the current node is within the first hop count threshold and the current node, and construct negative sample pairs based on negative sample nodes in the heterogeneous graph of the recommendation scenario whose hop count with the current node exceeds the first hop count threshold and the current node.
[0127] Step 403: For each node in the node sequence, for each hop count within the second hop count threshold, select a specified number of target neighbor nodes from the candidate neighbor nodes associated with the target neighbor node that is hop away from the node and hop count away from the node.
[0128] Among them, the target neighbor node that is one hop away from the node is selected from the candidate neighbor nodes associated with the node.
[0129] Step 404: For each hop count within the second hop count threshold, combine the original feature vectors of the target neighbor nodes that are hops away from the node to obtain the initial combination vector.
[0130] Step 405: In order of increasing hop count, iteratively execute the following combination operation, and use the final vector to be combined as the representation vector of the node: Combine the initial combination vector corresponding to this combination operation with the vector to be combined to obtain the vector to be combined for the next combination operation.
[0131] In this case, the vector to be combined in the first combination operation is the original feature vector of the node, and the number of hops of the initial combination vector in this combination operation is the same as the round number of this combination operation.
[0132] Step 406: Update the representation vector using the first loss function and the second loss function.
[0133] The first loss function is used to maximize the similarity between the representation vectors of nodes in a positive sample pair and minimize the similarity between the representation vectors of nodes in a negative sample pair. The second loss function is used to maximize the similarity between the representation vector and the perturbation vector, which is obtained by adding random perturbation to the representation vector.
[0134] Step 407: Using a resource-based collaborative filtering recall method, the first recommended resource for the target object is determined based on the representation vector.
[0135] Step 408: Using an object-based collaborative filtering recall method, the second recommended resource for the target object is determined based on the representation vector.
[0136] Step 409: Using a topic-based filtering and recall method, the third recommended resource for the target object is determined based on the representation vector.
[0137] Step 410: Combine the first recommended resource, the second recommended resource, and the third recommended resource to obtain the recommended resources.
[0138] Step 411: Adjust the recommendation order of recommended resources based on the similarity between the representation vector of the target object and the representation vector of the recommended resources, the similarity between the representation vector of the topics interacted with by the target object and the representation vector of the recommended resources, and the similarity between the representation vector of the resources interacted with by the target object and the representation vector of the recommended resources.
[0139] The vector representation method in this embodiment, in process 400, compared to process 200 above, specifically describes the process of determining the representation vector and the recommendation process based on the representation vector, thereby improving the recommendation accuracy.
[0140] Continue to refer to Figure 5 As an implementation of the methods shown in the above figures, this disclosure provides an embodiment of a vector representation device, which is similar to... Figure 2 Corresponding to the method embodiments shown, the system can be specifically applied to various electronic devices.
[0141] like Figure 5 As shown, the vector representation device 500 includes: a sample pair determination unit 501, configured to determine positive sample pairs and negative sample pairs based on the association relationships between nodes in a heterogeneous graph of a recommendation scenario, wherein the heterogeneous graph of a recommendation scenario represents the association relationships between object nodes, resource nodes, and topic nodes; a vector combination unit 502, configured to combine the original feature vector of a node and the original feature vector of the target neighbor node to obtain the representation vector of the node; and a vector update unit 503, configured to update the representation vector using a loss function, wherein the loss function is used to maximize the similarity between the representation vectors of nodes in a positive sample pair and minimize the similarity between the representation vectors of nodes in a negative sample pair.
[0142] In some optional implementations of this embodiment, the sample pair determination unit 501 is further configured to: sample a node sequence from the heterogeneous graph of the recommended scenario; and determine positive sample pairs and negative sample pairs based on the association between nodes in the node sequence.
[0143] In some optional implementations of this embodiment, the sample pair determination unit 501 is further configured to: for nodes in the node sequence, construct positive sample pairs based on positive sample nodes in the node sequence whose hop count with the current node is within the first hop count threshold and the current node, and construct negative sample pairs based on negative sample nodes in the heterogeneous graph of the recommended scenario whose hop count with the current node exceeds the first hop count threshold and the current node.
[0144] In some optional implementations of this embodiment, the sample pair determination unit 501 is further configured to: sample node sequences from the recommended scene heterogeneous graph using preset meta-path rules.
[0145] In some optional implementations of this embodiment, the vector combining unit 502 is further configured to: for a node in the node sequence, determine the target neighbor node from the candidate neighbor nodes whose hop count between the node and the node is within the second hop count threshold in the heterogeneous graph of the recommended scenario; and combine the original feature vector of the node and the original feature vector of the target neighbor node to obtain the representation vector of the node.
[0146] In some optional implementations of this embodiment, the vector combining unit 502 is further configured to: for each hop number within the second hop number threshold, select a specified number of target neighbor nodes from the candidate neighbor nodes associated with the target neighbor node that is hop number away from the node and hop number away from the node, wherein the target neighbor node that is hop number away from the node is selected from the candidate neighbor nodes associated with the node.
[0147] In some optional implementations of this embodiment, the vector combining unit 502 is further configured to: for each hop count within the second hop count threshold, combine the original feature vectors of the target neighbor nodes that are hops away from the node to obtain an initial combining vector; iteratively execute the following combining operations in ascending order of hop count, and use the final vector to be combined as the representation vector of the node: combine the initial combining vector corresponding to this combining operation with the vector to be combined to obtain the vector to be combined for the next combining operation, wherein the vector to be combined for the first combining operation is the original feature vector of the node, and the hop count of the initial combining vector corresponding to this combining operation is the same as the round of this combining operation.
[0148] In some optional implementations of this embodiment, the vector combining unit 502 is further configured to: combine the initial combining vector corresponding to the current combining operation and the vector to be combined according to a preset combining weight to obtain the vector to be combined for the next combining operation.
[0149] In some optional implementations of this embodiment, the loss function includes a first loss function and a second loss function. The first loss function is used to maximize the similarity between the representation vectors of nodes in a positive sample pair and minimize the similarity between the representation vectors of nodes in a negative sample pair. The second loss function is used to maximize the similarity between the representation vector and the perturbation vector, which is obtained by adding random perturbation to the representation vector. The vector update unit 503 is further configured to update the representation vector using the first loss function and the second loss function.
[0150] In some optional implementations of this embodiment, the above apparatus further includes a resource determination unit (not shown in the figure), configured to determine recommended resources for the target object based on the representation vector using multiple recall methods.
[0151] In some optional implementations of this embodiment, the resource determination unit is further configured to: use a resource-based collaborative filtering recall method to determine a first recommended resource for the target object based on the representation vector; use an object-based collaborative filtering recall method to determine a second recommended resource for the target object based on the representation vector; use a topic-based filtering recall method to determine a third recommended resource for the target object based on the representation vector; and combine the first recommended resource, the second recommended resource, and the third recommended resource to obtain the recommended resource.
[0152] In some optional implementations of this embodiment, the resource determination unit is further configured to: determine the historical resources that the target object has interacted with based on the heterogeneous graph of the recommended scenario; determine the target topic to which the historical resources belong based on the correspondence between resources and topics; and determine the third recommended resource of the target object based on the similarity between the representation vector corresponding to the target topic and the representation vector of the resource node in the heterogeneous graph of the recommended scenario.
[0153] In some optional implementations of this embodiment, the above apparatus further includes: a resource sorting unit (not shown in the figure), configured to: adjust the recommendation order of the recommended resources based on the similarity between the representation vector of the target object and the representation vector of the recommended resources, the similarity between the representation vector of the topics interacted with by the target object and the representation vector of the recommended resources, and the similarity between the representation vector of the resources interacted with by the target object and the representation vector of the recommended resources.
[0154] In this embodiment, a vector representation device is provided. The sample pair determination unit in the vector representation device determines positive and negative sample pairs based on the association relationships between nodes in a heterogeneous graph of the recommendation scenario. The heterogeneous graph of the recommendation scenario represents the association relationships between object nodes, resource nodes, and topic nodes. The vector combination unit combines the original feature vector of a node with the original feature vector of the target neighbor node to obtain the node's representation vector. The vector update unit updates the representation vector using a loss function. The loss function maximizes the similarity between the representation vectors of nodes in positive sample pairs and minimizes the similarity between the representation vectors of nodes in negative sample pairs. By introducing topic nodes to construct a heterogeneous graph of the recommendation scenario and combining contrastive learning to optimize the vector space, the accuracy and comprehensiveness of the representation vectors are improved, which helps to enhance the accuracy of resource retrieval and ranking in the recommendation system.
[0155] According to embodiments of this disclosure, this disclosure also provides an electronic device, the electronic device comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to implement the vector representation method described in any of the above embodiments when executed.
[0156] According to embodiments of this disclosure, this disclosure also provides a readable storage medium storing computer instructions that enable a computer to implement the vector representation method described in any of the above embodiments when executed.
[0157] This disclosure provides a computer program product that, when executed by a processor, can implement the vector representation method described in any of the above embodiments.
[0158] Figure 6 A schematic block diagram of an example electronic device 600 that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0159] like Figure 6As shown, device 600 includes a computing unit 601, which can perform various appropriate actions and processes based on a computer program stored in read-only memory (ROM) 602 or a computer program loaded into random access memory (RAM) 603 from storage unit 608. RAM 603 may also store various programs and data required for the operation of device 600. The computing unit 601, ROM 602, and RAM 603 are interconnected via bus 604. Input / output (I / O) interface 605 is also connected to bus 604.
[0160] Multiple components in device 600 are connected to I / O interface 605, including: input unit 606, such as keyboard, mouse, etc.; output unit 607, such as various types of monitors, speakers, etc.; storage unit 608, such as disk, optical disk, etc.; and communication unit 609, such as network card, modem, wireless transceiver, etc. Communication unit 609 allows device 600 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0161] The computing unit 601 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 601 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 601 performs the various methods and processes described above, such as vector representation methods. For example, in some embodiments, the vector representation method may be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 608. In some embodiments, part or all of the computer program may be loaded and / or installed on device 600 via ROM 602 and / or communication unit 609. When the computer program is loaded into RAM 603 and executed by the computing unit 601, one or more steps of the vector representation method described above may be performed. Alternatively, in other embodiments, the computing unit 601 may be configured to perform vector representation methods by any other suitable means (e.g., by means of firmware).
[0162] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0163] The program code used to implement the methods of this disclosure may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable vector representation device, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0164] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0165] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor); and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0166] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as a data server), or computing systems that include middleware components (e.g., an application server), or computing systems that include frontend components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., a communication network). Examples of communication networks include local area networks (LANs), wide area networks (WANs), and the Internet.
[0167] Computer systems can include clients and servers. Clients and servers are generally geographically separated and typically interact via communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. Servers can be cloud servers, also known as cloud computing servers or cloud hosts, which are hosting products within the cloud computing service system to address the management difficulties and weak business scalability inherent in traditional physical hosts and Virtual Private Servers (VPS) services; they can also be servers for distributed systems or servers incorporating blockchain technology.
[0168] According to the technical solution of this disclosure, a vector representation method and apparatus are provided. Positive and negative sample pairs are determined based on the relationships between nodes in a heterogeneous graph of a recommendation scenario. The heterogeneous graph represents the relationships between object nodes, resource nodes, and topic nodes. A node representation vector is obtained by combining the original feature vector of a node and the original feature vector of its target neighbor nodes. A loss function is used to update the representation vector, maximizing the similarity between the representation vectors of nodes in positive sample pairs and minimizing the similarity between the representation vectors of nodes in negative sample pairs. By introducing topic nodes to construct a heterogeneous graph of the recommendation scenario and combining contrastive learning to optimize the vector space, the accuracy and comprehensiveness of the representation vectors are improved, which helps to enhance the accuracy of resource retrieval and ranking in the recommendation system.
[0169] It should be understood that the various forms of processes shown above can be used to reorder, add, or delete steps. For example, the steps described in this disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution provided in this disclosure can be achieved, and this is not limited herein.
[0170] The specific embodiments described above do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure should be included within the scope of protection of this disclosure.
Claims
1. A vector representation method, comprising: Based on the relationships between nodes in the heterogeneous graph of the recommended scenario, positive sample pairs and negative sample pairs are determined, wherein the heterogeneous graph of the recommended scenario represents the relationships between object nodes, resource nodes and topic nodes; By combining the original feature vector of the node and the original feature vector of the target neighbor node, the representation vector of the node is obtained; The representation vector is updated using a loss function, wherein the loss function is used to maximize the similarity between the representation vectors of nodes in the positive sample pair and minimize the similarity between the representation vectors of nodes in the negative sample pair.
2. The method according to claim 1, wherein, The step of determining positive and negative sample pairs based on the relationships between nodes in the heterogeneous graph of the recommended scenario includes: Node sequences are sampled from the heterogeneous graph of the recommended scenarios; Based on the association between nodes in the node sequence, the positive sample pairs and the negative sample pairs are determined.
3. The method according to claim 2, wherein, Determining the positive sample pairs and the negative sample pairs based on the association relationships between nodes in the node sequence includes: For each node in the node sequence, a positive sample pair is constructed based on the positive sample nodes in the node sequence whose hop count with the current node is within the first hop count threshold and the current node. A negative sample pair is constructed based on the negative sample nodes in the heterogeneous graph of the recommended scenario whose hop count with the current node exceeds the first hop count threshold and the current node.
4. The method according to claim 2, wherein, The step of sampling node sequences from the heterogeneous graph of the recommended scenarios includes: The node sequence is sampled from the heterogeneous graph of the recommended scene using preset meta-path rules.
5. The method according to claim 2, wherein, The step of combining the original feature vector of the node and the original feature vector of the target neighbor node to obtain the representation vector of the node includes: For a node in the node sequence, the target neighbor node is determined from the candidate neighbor nodes in the heterogeneous graph of the recommended scene whose hop count is within the second hop count threshold. The representation vector of the node is obtained by combining the original feature vector of the node and the original feature vector of the target neighbor node.
6. The method according to claim 5, wherein, The step of determining the target neighbor node from candidate neighbor nodes whose hop count with the node in the recommended scene heterogeneous graph is within the second hop count threshold includes: For each hop count within the second hop count threshold, a specified number of target neighbor nodes are selected from the candidate neighbor nodes associated with the target neighbor node that is a hop count away from the node and a hop count away from the node next to the node. Among them, the target neighbor nodes that are a hop count away from the node are selected from the candidate neighbor nodes associated with the node.
7. The method according to claim 5, wherein, The step of combining the original feature vector of the node and the original feature vector of the target neighbor node to obtain the representation vector of the node includes: For each hop count within the second hop count threshold, an initial combination vector is obtained by combining the original feature vectors of the target neighbor nodes that are hops away from the node. Following the order of hop count from smallest to largest, the following combination operation is performed iteratively, and the final vector to be combined is used as the representation vector of the node: By combining the initial combination vector and the vector to be combined corresponding to this combination operation, the vector to be combined corresponding to the next combination operation is obtained. The vector to be combined corresponding to the first combination operation is the original feature vector of the node, and the number of hops corresponding to the initial combination vector corresponding to this combination operation is the same as the round of this combination operation.
8. The method according to claim 7, wherein, The process of combining the initial combination vector and the vector to be combined corresponding to the current combination operation to obtain the vector to be combined for the next combination operation includes: According to the preset combination weights, the initial combination vector and the vector to be combined corresponding to the current combination operation are combined to obtain the vector to be combined for the next combination operation.
9. The method according to claim 1, wherein, The loss function includes a first loss function and a second loss function. The first loss function is used to maximize the similarity between the representation vectors of the nodes in the positive sample pair and minimize the similarity between the representation vectors of the nodes in the negative sample pair. The second loss function is used to maximize the similarity between the representation vector and the perturbation vector. The perturbation vector is obtained by adding random perturbation to the representation vector. as well as Updating the representation vector using a loss function includes: The representation vector is updated using the first loss function and the second loss function.
10. The method according to any one of claims 1-9, wherein, Also includes: Multiple recall methods are employed to determine recommended resources for the target object based on the representation vector.
11. The method according to claim 10, wherein, The method employs multiple recall techniques to determine recommended resources for the target object based on the representation vector, including: A resource-based collaborative filtering recall method is adopted to determine the first recommended resource of the target object based on the representation vector; An object-based collaborative filtering recall method is used to determine the second recommended resource for the target object based on the representation vector; A topic-based filtering and recall method is adopted to determine the third recommended resource of the target object based on the representation vector; The recommended resources are obtained by combining the first recommended resource, the second recommended resource, and the third recommended resource.
12. The method according to claim 11, wherein, The topic-based filtering and recall method, based on the representation vector, determines the third recommended resource for the target object, including: Based on the recommended scenario heterogeneity graph, determine the historical resources that the target object has interacted with; Based on the correspondence between resources and topics, determine the target topic to which the historical resources belong; The third recommended resource for the target object is determined based on the similarity between the representation vector corresponding to the target topic and the representation vector of the resource node in the heterogeneous graph of the recommendation scenario.
13. The method according to claim 10, wherein, Also includes: The recommendation order of the recommended resources is adjusted based on the similarity between the representation vector of the target object and the representation vector of the recommended resource, the similarity between the representation vector of the topics interacted with by the target object and the representation vector of the recommended resource, and the similarity between the representation vector of the resources interacted with by the target object and the representation vector of the recommended resource.
14. A vector representation device, comprising: The sample pair determination unit is configured to determine positive sample pairs and negative sample pairs based on the association relationships between nodes in the heterogeneous graph of the recommendation scenario, wherein the heterogeneous graph of the recommendation scenario represents the association relationships between object nodes, resource nodes and topic nodes; The vector combining unit is configured to combine the original feature vector of the node and the original feature vector of the target neighbor node to obtain the representation vector of the node; The vector update unit is configured to update the representation vector using a loss function, wherein the loss function is used to maximize the similarity between the representation vectors of nodes in the positive sample pair and minimize the similarity between the representation vectors of nodes in the negative sample pair.
15. An electronic device, characterized in that, include: At least one processor; as well as A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-13.
16. A non-transitory computer-readable storage medium storing computer instructions, characterized in that, The computer instructions are used to cause the computer to perform the method according to any one of claims 1-13.
17. A computer program product comprising: A computer program that, when executed by a processor, implements the method according to any one of claims 1-13.