A generative model-based graph neural network recommendation system counterfactual explanation method
Patent Information
- Application Number
- CN202610081531.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-01-21
- Publication Date
- 2026-10-27
- Estimated Expiration
- 2046-01-21
AI Technical Summary
当反事实解释结果显著偏离上述行为分布特征时,其解释结论难以为系统优化或业务决策提供可靠参考
[0021]本申请实施例至少包括以下有益效果:本申请提供一种基于生成模型的图神经网络推荐系统反事实解释方法,该方案通过获取推荐系统对应的节点集合、用户与物品的历史交互关系矩阵以及节点特征矩阵后,根据节点集合、用户与物品的历史交互关系矩阵以及节点特征矩阵构建定义图,并基于定义图构建图神经网络模型,然后对定义图进行图分布推理得到用于表征用户的长期兴趣爱好和行为模式的语义隐变量,同时对定义图进行前向反事实扩散处理得到若干个噪声图后,将语义隐变量和噪声图输入去噪模型中进行反向去噪得到若干个候选反事实解释图以及候选反事实解释图对应的概率邻接矩阵,通过概率邻接矩阵从若干个候选反事实解释图确定干净图后,将定义图和干净图分别输入到图神经网络模型中进行用户偏好预测得到对应的原始预测得分和反事实预测得分,接着根据定义图、干净图、原始预测得分和反事实预测得分计算目标损失值后确定目标反事实解释图,本实施例通过对用户–物品交互图的潜在分布进行建模,可以在保持真实用户行为分布一致性的前提下生成有效的反事实解释,从而提升推荐解释结果的可信性和可用性,进而可以为推荐系统优化或业务决策提供可靠的参考信息。
Smart Images

Figure CN122198163B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence technology, and in particular to a counterfactual explanation method for a graph neural network recommendation system based on a generative model. Background Technology
[0002] In related technologies, with the rapid development of internet platforms, recommender systems have been widely applied in e-commerce, content distribution, social media, and online advertising to recommend potentially interesting items to users based on their historical behavior and interests. Currently, recommendation models based on graph neural networks (GNNs) are gradually becoming an important technical approach in the field of recommender systems because they can effectively model user-item interaction relationships and high-order collaborative information.
[0003] However, similar to other deep learning models, GNN recommendation models typically exhibit strong black-box characteristics, lacking intuitive and understandable explanations for their recommendation results. To improve the transparency and credibility of recommendation systems, existing technologies have proposed various recommendation explanation methods. Among them, counterfactual explanations provide an intuitive causal explanation for recommendation results by answering the question "How should user behavior change to change the recommendation results?" This approach can also be used to filter out items that users are not interested in, thereby enhancing recommendation effectiveness.
[0004] Existing counterfactual explanations for recommender systems typically alter the model's output by directly deleting historical user interactions, modifying user characteristics, or artificially constructing fake interactions. However, these methods are prone to generating anomalous interaction patterns that are unlikely to occur in real-world recommender scenarios, leading to out-of-distribution (OOD) problems. OOD weakens the credibility of counterfactual explanations, making it difficult to distinguish whether changes in recommendation results are due to alterations in key interest factors or unreasonable behavioral perturbations. Furthermore, user behavior in recommender systems often exhibits significant structural and long-term stability, such as interest clusters, behavioral sequence patterns, and user group similarities. When counterfactual explanations significantly deviate from these behavioral distribution characteristics, their conclusions are unreliable for system optimization or business decision-making.
[0005] In summary, the technical problems existing in the relevant technologies need to be improved. Summary of the Invention
[0006] The main objective of this application is to propose a counterfactual explanation method for graph neural network recommendation systems based on generative models. This method can generate effective counterfactual explanations while maintaining the consistency of the distribution of real user behavior, thereby improving the credibility and usability of the recommendation explanation results and providing reliable reference information for recommendation system optimization or business decisions.
[0007] To achieve the above objectives, one aspect of this application proposes a counterfactual explanation method for a graph neural network recommendation system based on a generative model, the method comprising the following steps: Obtain the node set, the historical interaction matrix between users and items, and the node feature matrix corresponding to the recommendation system. The node set includes user nodes and item nodes, and the node feature matrix is used to represent user profile features or item attribute features. A definition graph is constructed based on the node set, the historical interaction matrix between users and items, and the node feature matrix. A graph neural network model is constructed based on the defined graph, and the graph neural network model is used to predict the user's preference score for the target item; Graph distribution reasoning is performed on the defined graph to obtain semantic latent variables, which are used to represent users' long-term interests and behavioral patterns. The definition graph is subjected to forward counterfactual diffusion processing to obtain several noise graphs; The semantic latent variables and the noise graph are input into the denoising model for inverse denoising to obtain several candidate counterfactual interpretation graphs and the probability adjacency matrix corresponding to the candidate counterfactual interpretation graphs. The probability adjacency matrix is used to characterize the probability of each edge in the candidate counterfactual interpretation graph. A clean graph is determined from several candidate counterfactual interpretation graphs using the probabilistic adjacency matrix; The definition graph and the clean graph are respectively input into the graph neural network model to predict user preferences, and the corresponding original prediction score and counterfactual prediction score are obtained. After calculating the target loss value based on the defined graph, the clean graph, the original prediction score, and the counterfactual prediction score, the target counterfactual interpretation graph is determined.
[0008] In some embodiments, the graph neural network model learns the node representations of the defined graph through a message passing mechanism, and each node representation in the defined graph is updated by its own node representation and the representations of its neighboring nodes.
[0009] In some embodiments, the update process represented by each node in the definition graph is as follows: ; In the formula, Represents a node Representation at layer l; Represents a node Representation at layer l-1; Represents a node Representation at layer l-1; Represents a node The set of neighbors; This indicates a summation operation, a mean operation, or a concatenation operation.
[0010] In some embodiments, the step of performing graph distribution reasoning on the defined graph to obtain semantic latent variables includes: A graph distribution reasoning mechanism based on variational reasoning is used to perform graph distribution reasoning on the defined graph to obtain semantic latent variables.
[0011] In some embodiments, the forward counterfactual diffusion process on the definition graph to obtain several noise graphs includes: The defined graph is transformed into several noise graphs by discrete structure diffusion processing.
[0012] In some embodiments, determining a clean graph from a plurality of candidate counterfactual interpretation graphs using the probabilistic adjacency matrix includes: The discrete adjacency matrix is obtained by sampling the probability adjacency matrix using the Bernoulli distribution; Based on the discrete adjacency matrix, the candidate counterfactual interpretation graph with the minimum perturbation is determined from the candidate counterfactual interpretation graph as the clean graph.
[0013] In some embodiments, the Bernoulli variables of the Bernoulli distribution The following formula: ; In the formula, ; Indicates the activation function; Indicates temperature parameter; This represents the probability value output by the model.
[0014] In some embodiments, determining the target counterfactual interpretation map after calculating the target loss value based on the definition map, the clean map, the original prediction score, and the counterfactual prediction score includes: Calculate the distribution loss based on the defined graph and the clean graph; Calculate the prediction loss based on the original prediction score and the counterfactual prediction score; Calculate the target loss based on the distributed loss and the predicted loss; Based on the target loss, a target counterfactual interpretation map is determined from several clean maps.
[0015] In some embodiments, the distribution loss The calculation formula is as follows: ; In the formula, Represents the definition diagram; Z represents the noise graph; T represents the total number of noise graphs; Indicates the noise in the sampling; This indicates the expectation value; This indicates sampling from the original distribution; Forward noise addition process.
[0016] In some embodiments, the predicted loss The calculation formula is as follows: ; In the formula, Represents a clean image; This represents a graph neural network model; This represents the prediction result of a clean graph in a graph neural network model; Indicates the distribution of the original data; Indicates the continuous time step; This indicates sampling from the original distribution; This indicates the encoding process for implicit variables; This indicates the reverse denoising process.
[0017] To achieve the above objectives, another aspect of this application proposes a counterfactual explanation device for a graph neural network recommendation system based on a generative model, the device comprising: The first module is used to obtain the node set, the historical interaction matrix between users and items, and the node feature matrix corresponding to the recommendation system. The node set includes user nodes and item nodes, and the node feature matrix is used to represent user profile features or item attribute features. The second module is used to construct a definition graph based on the node set, the historical interaction matrix between users and items, and the node feature matrix. The third module is used to construct a graph neural network model based on the defined graph, and the graph neural network model is used to predict the user's preference score for the target item; The fourth module is used to perform graph distribution reasoning on the defined graph to obtain semantic latent variables, which are used to represent the user's long-term interests and behavioral patterns. The fifth module is used to perform forward counterfactual diffusion processing on the definition graph to obtain several noise graphs; The sixth module is used to input the semantic latent variables and the noise graph into the denoising model for inverse denoising, to obtain several candidate counterfactual interpretation graphs and the probability adjacency matrix corresponding to the candidate counterfactual interpretation graphs. The probability adjacency matrix is used to characterize the probability of each edge in the candidate counterfactual interpretation graph. The seventh module is used to determine a clean graph from a plurality of candidate counterfactual interpretation graphs using the probabilistic adjacency matrix; The eighth module is used to input the definition graph and the clean graph into the graph neural network model to predict user preferences, and obtain the corresponding original prediction score and counterfactual prediction score. The ninth module is used to calculate the target counterfactual interpretation map after calculating the target loss value based on the definition map, the clean map, the original prediction score and the counterfactual prediction score.
[0018] To achieve the above objectives, another aspect of this application provides an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the method described above.
[0019] To achieve the above objectives, another aspect of the embodiments of this application proposes a computer-readable storage medium storing a computer program that, when executed by a processor, implements the methods described above.
[0020] To achieve the above objectives, another aspect of the embodiments of this application proposes a computer program product, including a computer program that, when executed by a processor, implements the aforementioned method.
[0021] The embodiments of this application include at least the following beneficial effects: This application provides a counterfactual explanation method for a graph neural network recommendation system based on a generative model. This method obtains the node set corresponding to the recommendation system, the historical interaction matrix between users and items, and the node feature matrix. Then, it constructs a definition graph based on the node set, the historical interaction matrix between users and items, and the node feature matrix. A graph neural network model is then constructed based on the definition graph. Graph distribution reasoning is then performed on the definition graph to obtain semantic latent variables that characterize users' long-term interests and behavioral patterns. Simultaneously, forward counterfactual diffusion processing is performed on the definition graph to obtain several noisy graphs. Finally, the semantic latent variables and the noisy graphs are input into a denoising model for inverse denoising to obtain several candidate counterfactual solutions. The definition graph and the probabilistic adjacency matrix corresponding to the candidate counterfactual explanation graph are used to determine the clean graph from several candidate counterfactual explanation graphs. Then, the definition graph and the clean graph are respectively input into the graph neural network model to predict user preferences and obtain the corresponding original prediction score and counterfactual prediction score. Then, the target counterfactual explanation graph is determined by calculating the target loss value based on the definition graph, the clean graph, the original prediction score and the counterfactual prediction score. This embodiment can generate effective counterfactual explanations while maintaining the consistency of the actual user behavior distribution by modeling the potential distribution of the user-item interaction graph, thereby improving the credibility and usability of the recommendation explanation results, and thus providing reliable reference information for recommendation system optimization or business decisions. Attached Figure Description
[0022] Figure 1 This is a flowchart of the counterfactual explanation method for a graph neural network recommendation system based on a generative model provided in this application embodiment; Figure 2 This is a schematic diagram of the overall architecture of the counterfactual explanation method for a graph neural network recommendation system based on a generative model provided in this application embodiment. Detailed Implementation
[0023] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of this application and are not intended to limit it. In the following description, when referring to the accompanying drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with those of this application; they are merely examples of apparatuses and methods consistent with some aspects of the embodiments of this application as detailed in the appended claims.
[0024] It is understood that the terms “first,” “second,” etc., used in this application may be used herein to describe various concepts, but unless otherwise stated, these concepts are not limited by these terms. These terms are only used to distinguish one concept from another. For example, without departing from the scope of the embodiments of this application, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the words “if,” “when,” or “in response to a determination” as used herein may be interpreted as “when…” or “when…” or “in response to a determination.”
[0025] As used in this application, the terms "at least one", "multiple", "each", "any", etc., "at least one" includes one, two or more, "multiple" includes two or more, "each" refers to each of the corresponding multiples, and "any" refers to any one of the multiples.
[0026] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.
[0027] Before providing a detailed description of the embodiments of this application, some of the nouns and terms used in the embodiments of this application will be explained first. The nouns and terms used in the embodiments of this application shall be interpreted as follows: Counterfactual explanations are a method used in artificial intelligence and machine learning to enhance model interpretability. They aim to answer the question, "How would the model's output change if certain features of the input data were altered?" by constructing hypothetical scenarios. The core idea is to reveal the key influencing factors of model decisions by comparing real-world and hypothetical situations, thereby providing users with actionable improvement suggestions.
[0028] To address the out-of-distribution problem in existing counterfactual explanation methods for recommendation systems, this application provides a graph neural network-based counterfactual explanation method for recommendation systems based on generative models. This method models the potential distribution of user-item interaction graphs and generates effective counterfactual explanations while maintaining consistency with the distribution of real user behavior, thereby improving the credibility and usability of recommendation explanation results and providing reliable reference information for recommendation system optimization or business decisions.
[0029] The counterfactual explanation method for a generative model-based graph neural network recommender system provided in this application relates to the field of artificial intelligence technology. This method can be applied to a terminal, a server, or software running on either a terminal or a server. In some embodiments, the terminal can be a smartphone, tablet, laptop, desktop computer, smart speaker, smartwatch, or in-vehicle terminal, but is not limited to these. The server can be configured as an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. The server can also be a node server in a blockchain network. The software can be an application implementing the counterfactual explanation method for a generative model-based graph neural network recommender system, but is not limited to the above forms.
[0030] This application can be used in a wide variety of general-purpose or special-purpose computer system environments or configurations. Examples include: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, programmable consumer electronics, network PCs, minicomputers, mainframe computers, and distributed computing environments including any of the above systems or devices. This application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform specific tasks or implement specific abstract data types. This application can also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communication network. In distributed computing environments, program modules can reside in local and remote computer storage media, including storage devices.
[0031] It should be noted that in all specific embodiments of this application, when processing data related to user identity or characteristics, such as user information, user behavior data, user historical data, and user location information, user permission or consent is obtained first. Furthermore, the collection, use, and processing of this data comply with relevant laws, regulations, and standards. In addition, when embodiments of this application require access to sensitive personal information of users, separate permission or consent from the user is obtained through pop-ups or redirection to confirmation pages. Only after obtaining the user's separate permission or consent is the necessary user-related data required for the proper functioning of these embodiments acquired.
[0032] The embodiments of this application will be described in detail below with reference to the accompanying drawings: Figure 1 This is an optional flowchart of the counterfactual explanation method for a graph neural network recommendation system based on a generative model provided in this application embodiment. Figure 1 The method may include, but is not limited to, steps S110 to S190: Step S110: Obtain the node set, the historical interaction matrix between users and items, and the node feature matrix corresponding to the recommendation system. The node set includes user nodes and item nodes, and the node feature matrix is used to represent user profile features or item attribute features. Step S120: Construct a definition graph based on the node set, the historical interaction matrix between users and items, and the node feature matrix; Step S130: Construct a graph neural network model based on the defined graph, wherein the graph neural network model is used to predict the user's preference score for the target item; Step S140: Perform graph distribution reasoning on the definition graph to obtain semantic latent variables, where semantic latent variables are used to represent users' long-term interests and behavioral patterns. Step S150: Perform forward counterfactual diffusion on the definition graph to obtain several noise graphs; Step S160: Input the semantic latent variables and the noise graph into the denoising model for reverse denoising to obtain several candidate counterfactual interpretation graphs and the probability adjacency matrix corresponding to the candidate counterfactual interpretation graphs. The probability adjacency matrix is used to characterize the probability of each edge in the candidate counterfactual interpretation graph. Step S170: Determine a clean graph from several candidate counterfactual interpretation graphs using the probability adjacency matrix; Step S180: Input the definition graph and the clean graph into the graph neural network model respectively to predict user preferences and obtain the corresponding original prediction score and counterfactual prediction score. Step S190: After calculating the target loss value based on the definition map, clean map, original prediction score and counterfactual prediction score, determine the target counterfactual interpretation map.
[0033] It is understood that the definition diagram in this embodiment can be represented by triples. It means that, among them, This indicates a combination of nodes, which includes user nodes and item nodes; A matrix representing the historical interaction relationships between users and items; This represents the node feature matrix, which indicates the user profile or item attribute features. d represents the node feature dimension, and the i-th row represents the node. eigenvectors.
[0034] In this embodiment, the graph neural network model learns the node representations of the defined graph through a message passing mechanism. Each node representation in the defined graph is updated by aggregating its own node representation with the representations of its neighbors. The update process for each node representation in the defined graph is as follows: ; In the formula, Represents a node Representation at layer l; Represents a node Representation at layer l-1; Represents a node Representation at layer l-1; Represents a node The set of neighbors; This indicates a summation operation, a mean operation, or a concatenation operation.
[0035] In this embodiment of the application, after obtaining the definition graph and the graph neural network model, a counterfactual explanation instance is also constructed. Specifically, the definition graph... Given an interaction graph, This represents the trained graph neural network model. Representation of graph neural network model In the definition diagram The prediction above. A counterfactual explanation example is introducing a minimum perturbation into the definition graph. A new diagram was obtained from the middle. , making This process can be defined as the following optimization problem: ; In the formula, Used for measurement and The similarity between them can be defined, for example, by the number of edges that have been changed.
[0036] Understandably, after obtaining the definition graph, this embodiment introduces a graph distribution reasoning mechanism based on variational reasoning to capture the diverse and complex distributions of the interaction graph for items. This mechanism performs graph distribution reasoning on the definition graph to obtain semantic latent variables. The core idea is to use variational reasoning to approximate the latent distribution representation of the interaction graph. Specifically, for each input graph... Assume that its generation process contains an invisible, continuous, random latent variable. This process can be divided into two steps: 1) From the prior distribution sampling 2) From the conditional probability distribution sampling However, in most cases, the posterior distribution... It is complex and unknown; therefore, variational reasoning introduces a variational distribution. To approximate This embodiment assumes... It follows a Gaussian distribution, and its encoding process is defined by the following formula: ; In the formula, and They represent respectively by and The mean and standard deviation of the Gaussian distribution are calculated. This is achieved by applying reparameterization techniques. It can be calculated using the following formula: ; In the formula, ; This represents element-wise multiplication. To optimize... The easily tractable lower bound of evidence (ELBO) shown in the following formula can be used as the optimization objective: ; In the formula, Represent the prior distribution and variational distribution The Kullback-Leibler (KL) divergence between the learning distributions. The network acts as an encoder, mapping the input graph to the distribution corresponding to the latent variable Z. Similarly, As a decoder, it is used to reconstruct the graph from Z. .
[0037] The semantic latent variable Z obtained by variational inference captures the semantic latent variables of user behavior patterns. Therefore, this embodiment uses Z as a semantic prior to guide the reverse process. By injecting this high-fidelity prior knowledge, it ensures that the user-item interaction graph generated by the model is consistent with the real user behavior distribution, preserving key in-distribution characteristics.
[0038] Understandably, in order to ensure the generation of a valid counterfactual explanation, this embodiment first uses discrete structure diffusion processing to process the user-item interaction graph. (i.e., definition diagram) Transformed into an approximate noise state The random graph is used as a noisy graph. This controlled noise-addition process gradually destroys the structure of the defined graph, thereby constructing a search space from which the graph neural network model can reconstruct the corresponding counterfactual explanatory graph. Specifically, this embodiment lets Representing the adjacency matrix The two-dimensional one-hot encoding of the ij-th element is then defined as follows: The forward transition process for each edge can be defined by the following class distribution: ; In the formula, Denotes the transition matrix, where the elements are... This is used to capture the transition probabilities of edge states. The transition probability at step t. It can be calculated using an approximate solution, where This embodiment models the diffusion process of each edge independently; therefore, the graph-level transition distribution can be decomposed into the following formula: ; The forward diffusion process generates a series of noisy maps, known as noise maps. In the reverse process, these noisy graphs are denoised using the learned semantic prior Z to generate candidate counterfactual explanatory graphs that are both effective and uniformly distributed.
[0039] Understandably, the reverse processing in this embodiment trains a denoising model to approximate the distribution of the clean graph (counterfactual explanation graph). To stabilize the training process of the denoising model, this embodiment uses a network. Predict the distribution on the clean map This parameterization process can be expressed as the following formula: ; To effectively learn the counterfactual explanation graph distribution, this embodiment builds a denoising model based on PPGN (Provably Powerful Graph Network). The input to the denoising model is as follows: ; In the formula, Represents a noise graph; Represents semantic implicit vectors; This represents the transition probability of an edge state. (Diagonal matrix) The current noise level is represented by a multilayer perceptron (MLP) that integrates time information. It will pass through multiple layers of PPGN networks with residual connections and layer regularization. The cascaded output of L-layer PPGNs can be expressed as follows: ; Ultimately, additional Will be used to reduce The dimensions are determined and the final output is obtained: .
[0040] It is understandable that in this embodiment, the probability adjacency matrix is obtained through the output of the denoising model. The probability matrix represents the distribution predicted by the model on the clean graph. The elements in the probability adjacency matrix are between [0,1], representing the probability that each edge in the definition graph exists in the counterfactual interpretation graph. However, the adjacency matrix is typically discrete and is assumed to contain only binary values (if...). and If there is an edge, then Otherwise, it is 0). Therefore, based on The probability in this embodiment is obtained through Bernoulli distribution. The probabilistic adjacency matrix is sampled to obtain a binary discrete matrix, which serves as the discrete adjacency matrix. To enable gradient optimization, this embodiment modifies the Bernoulli variable. The class weights are parameterized. The continuous relaxation of the Bernoulli distribution can be expressed by the following formula: ; In the formula, ; Indicates the activation function; This represents a temperature parameter used to control the similarity between the relaxation distribution and the Bernoulli distribution; This represents the probability value output by the model.
[0041] This embodiment obtains a discrete adjacency matrix through the above sampling process. Then, based on the discrete adjacency matrix, the candidate counterfactual interpretation graph with the minimum perturbation is determined as the clean graph from the candidate counterfactual interpretation graph. (Right now ).
[0042] Understandably, to optimize the generated explanatory graph, it is necessary to consider both its in-distribution properties and counterfactual properties. For example... Figure 2 As shown, this embodiment alleviates the training instability problem in the graph neural network model by extending a specific parameterization method and readjusting the weights of the KL divergence. Combined with the learned prior Z, the following distribution loss can be constructed: ; In the formula, Represents the definition diagram; Z represents the noise graph; T represents the total number of noise graphs; Indicates the noise in the sampling; This indicates the expectation value; This indicates sampling from the original distribution; Forward noise addition process.
[0043] in, In the early stages, samples with less noise are given greater weight.
[0044] To ensure that the generated explanatory graphs effectively alter the model's predictions, this embodiment employs the following prediction loss function. : ; In the formula, Represents a clean image; This represents a graph neural network model; This represents the prediction result of a clean image in a graph neural network model, i.e., the ideal classification label. ; Indicates the distribution of the original data; Indicates the continuous time step; This indicates sampling from the original distribution; This indicates the encoding process for implicit variables; This indicates the reverse denoising process.
[0045] This embodiment reduces the prediction probability of the generated explanatory graph under the original label using the aforementioned prediction function, thus satisfying the counterfactual property. Finally, the target loss function of this embodiment is as follows: ; In the formula, Used for control The weight, This represents the optimization loss based on semantic priors.
[0046] In the field of recommender systems, counterfactual explanation explores how to explain the recommendation mechanism by minimizing perturbations to the interaction relationships between users or items. Simultaneously, counterfactual explanation can also enhance recommendation performance by filtering out negative items through perturbation results. The following describes in detail the specific implementation of the counterfactual explanation method for graph neural networks based on generative models proposed in this application, using the user preference prediction task of a recommender system as an example. Specifically, the application process of this embodiment includes, but is not limited to, the following steps: Step 1: Definition graph modeling and graph neural network model construction of the user-item interaction process. Specifically, in this embodiment, the recommendation system is represented as a definition graph of the user-item interaction process, wherein the graph structure of the definition graph is a triple. It includes 14 nodes and 11 edges. The node set is... Including user nodes and item nodes , A matrix representing the historical interaction relationships between users and items: ; In the formula, This indicates an interaction between user u and item i, and represents the node's characteristics. User profile or item attribute features, with feature values initialized to 1, and each row of the matrix corresponding to the feature vector of each node: ; Based on the defined graph of user-item interactions, a graph neural network recommendation model is constructed and trained to predict user preference scores for target items. Node representations can be learned through a message-passing mechanism. Each node's representation is updated by aggregating its own and its neighbors' representations. The update process can be represented by the following formula: ; For a given definition graph of user-item interaction The graph neural network model outputs the user's recommendation results for the target item.
[0047] Step 2: Constructing Counterfactual Explanation Examples. When a graph neural network model recommends a target item to a specific user, the counterfactual explanation objective in this embodiment is: in the definition graph of the user's historical interaction behavior... Generate a new interaction graph of user history interactions with minimal modifications. , making The target item is no longer recommended. At the same time, satisfying Minimum value, It can be defined as the following formula: ; Step 3: User-Item Interaction Distribution Inference. Specifically, this embodiment introduces a graph distribution modeling mechanism based on variational inference to learn the potential distribution of user-item interaction behavior. First, a graph encoder network is constructed, utilizing a variational distribution... To approximate the posterior distribution Assuming It is a Gaussian distribution, and the user-item interaction graph is encoded as follows: ; We can obtain the mean and standard deviation of the Gaussian distribution, and then use the following reparameterization technique: ; And combine the following easily handled lower bound of evidence (ELBO) as the objective optimization : ; Finally, we can obtain the corresponding semantic latent variable Z: ; The semantic latent variable Z, obtained through variational inference, captures key structural and semantic information in the interaction graph, representing users' long-term interests, preferences, and behavioral patterns. Therefore, Z is used as a semantic prior to guide the reverse process of learning the counterfactual interpretation graph distribution.
[0048] Step 4: Counterfactual Interaction Graph Diffusion. Discrete structure diffusion is performed on the original user-item interaction graph, progressively introducing noise to construct the interaction structure search space. Specifically, the forward processing uses discrete structure diffusion to transform the input graph... It gradually transforms into a state approximating noise. Randomized graphs, and generate a series of noisy graphs. . The corresponding adjacency matrix is: ; make Representing the adjacency matrix The two-dimensional one-hot encoding of the ij-th element is then defined as follows: The forward transition process for each edge can be defined by the following class distribution: ; By independently modeling the diffusion process of each edge, the graph-level transition distribution can be decomposed into: ; Step 5: Reverse processing of parameterization and denoising model design. First, a network is used... Predict the distribution on the clean map To stabilize the training process, this parameterization can be expressed as the following formula: ; Then the noise map Semantic latent variable Z and noise level indicator The input to the model is obtained by concatenating the data: ; Then, it is input into a multi-layer PPGN network with residual connections and layer regularization: ; The reverse denoising process reconstructs the counterfactual interaction graph under the constraints of the semantic latent variables, so that the generated interaction behavior conforms to the distribution of real user behavior.
[0049] Step 6: Counterfactual interactive sampling and discretization. Specifically, the denoising model outputs a fully connected probability adjacency matrix. This probability matrix represents the distribution predicted by the model on the clean graph. The elements in the probability adjacency matrix are between [0,1], representing the probability that each edge in the defined graph exists in the counterfactual interpretation graph. ; Since adjacency matrices are typically discrete and assumed to contain only binary values, therefore based on The probability in the formula uses the Bernoulli distribution. The probabilistic adjacency matrix is sampled to obtain a binary discrete matrix as the discrete adjacency matrix, and the following class reparameterization is used to ensure gradient optimization: ; Through the above sampling process, a discrete interaction matrix can be obtained. Then, based on the discrete adjacency matrix, the candidate counterfactual interpretation graph with the minimum perturbation is determined as the clean graph from the candidate counterfactual interpretation graph. : ; Step 7: Loss Function Optimization. Specifically, in this embodiment, by extending a specific parameterization method and readjusting the weights of the KL divergence, and combining it with the learned prior Z, the following distribution loss can be constructed: ; To ensure that the generated interpretation graph can effectively change the model's prediction results, the following prediction loss function can be used: ; Finally, the following optimization objective function can be obtained: ; This embodiment generates a counterfactual interaction graph by jointly optimizing the distribution consistency loss and the recommendation prediction loss. While maintaining the characteristics of real user behavior, it effectively changes the recommendation results, thereby providing a practically meaningful counterfactual explanation for the recommendation system. Furthermore, it can enhance the recommendation effect by filtering out items that users are not interested in through the corresponding counterfactual explanation results.
[0050] This application also provides a counterfactual explanation device for a graph neural network recommendation system based on a generative model, the device comprising: The first module is used to obtain the node set, the historical interaction matrix between users and items, and the node feature matrix corresponding to the recommendation system. The node set includes user nodes and item nodes, and the node feature matrix is used to represent user profile features or item attribute features. The second module is used to construct a definition graph based on the node set, the historical interaction matrix between users and items, and the node feature matrix. The third module is used to construct a graph neural network model based on the defined graph, and the graph neural network model is used to predict the user's preference score for the target item; The fourth module is used to perform graph distribution reasoning on the defined graph to obtain semantic latent variables, which are used to represent the user's long-term interests and behavioral patterns. The fifth module is used to perform forward counterfactual diffusion processing on the definition graph to obtain several noise graphs; The sixth module is used to input the semantic latent variables and the noise graph into the denoising model for inverse denoising, to obtain several candidate counterfactual interpretation graphs and the probability adjacency matrix corresponding to the candidate counterfactual interpretation graphs. The probability adjacency matrix is used to characterize the probability of each edge in the candidate counterfactual interpretation graph. The seventh module is used to determine a clean graph from a plurality of candidate counterfactual interpretation graphs using the probabilistic adjacency matrix; The eighth module is used to input the definition graph and the clean graph into the graph neural network model to predict user preferences, and obtain the corresponding original prediction score and counterfactual prediction score. The ninth module is used to calculate the target counterfactual interpretation map after calculating the target loss value based on the definition map, the clean map, the original prediction score and the counterfactual prediction score.
[0051] It is understood that the content of the above method embodiments is applicable to the present device embodiments. The specific functions implemented by the present device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0052] This application also provides an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the above-described method. This electronic device can be any smart terminal, including tablet computers, in-vehicle computers, etc.
[0053] It is understood that the content of the above method embodiments is applicable to this device embodiment. The specific functions implemented by this device embodiment are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0054] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described method.
[0055] It is understood that the content of the above method embodiments is applicable to this storage medium embodiment. The specific functions implemented in this storage medium embodiment are the same as those in the above method embodiments, and the beneficial effects achieved are also the same as those achieved in the above method embodiments.
[0056] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the above-described method.
[0057] It is understood that the content of the above method embodiments is applicable to the embodiments of this program product. The specific functions implemented by the embodiments of this program product are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0058] This application provides a counterfactual explanation method for a graph neural network recommendation system based on a generative model. By modeling the potential distribution of the user-item interaction graph, it can generate effective counterfactual explanations while maintaining consistency with the distribution of real user behavior, thereby improving the credibility and usability of the recommendation explanation results and providing reliable reference information for recommendation system optimization or business decisions.
[0059] The embodiments described in this application are for the purpose of more clearly illustrating the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions provided by the embodiments of this application. As those skilled in the art will know, with the evolution of technology and the emergence of new application scenarios, the technical solutions provided by the embodiments of this application are also applicable to similar technical problems.
[0060] Those skilled in the art will understand that the technical solutions shown in the figures do not constitute a limitation on the embodiments of this application, and may include more or fewer steps than shown, or combine certain steps, or different steps.
[0061] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0062] Those skilled in the art will understand that all or some of the steps in the methods disclosed above, as well as the functional modules / units in the systems and devices, can be implemented as software, firmware, hardware, or suitable combinations thereof.
[0063] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms “comprising” and “having,” and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0064] It should be understood that in this application, "at least one (item)" means one or more, and "more than" means two or more. "And / or" is used to describe the relationship between related objects, indicating that three relationships can exist. For example, "A and / or B" can represent three cases: only A exists, only B exists, and both A and B exist simultaneously, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one (item) of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one (item) of a, b, or c can represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple.
[0065] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of the units described above is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0066] The units described above as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0067] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0068] The preferred embodiments of the present application have been described above with reference to the accompanying drawings, but this does not limit the scope of the claims of the present application. Any modifications, equivalent substitutions, and improvements made by those skilled in the art without departing from the scope and substance of the embodiments of the present application shall be within the scope of the claims of the present application.
Claims
1. A counterfactual explanation method for a graph neural network-based recommender system using a generative model, characterized in that, The method includes the following steps: Obtain the node set, the historical interaction matrix between users and items, and the node feature matrix corresponding to the recommendation system. The node set includes user nodes and item nodes, and the node feature matrix is used to represent user profile features or item attribute features. A definition graph is constructed based on the node set, the historical interaction matrix between users and items, and the node feature matrix; wherein, the update process represented by each node in the definition graph is as follows: ;In the formula, Represents a node Representation at layer l; Represents a node Representation at layer l-1; Represents a node Representation at layer l-1; Represents a node The set of neighbors; This indicates summation, mean calculation, or concatenation operations; A graph neural network model is constructed based on the defined graph, and the graph neural network model is used to predict the user's preference score for the target item; Graph distribution reasoning is performed on the defined graph to obtain semantic latent variables, which are used to represent users' long-term interests and behavioral patterns. The definition graph is subjected to forward counterfactual diffusion processing to obtain several noise graphs; The semantic latent variables and the noise graph are input into the denoising model for inverse denoising to obtain several candidate counterfactual interpretation graphs and the probability adjacency matrix corresponding to the candidate counterfactual interpretation graphs. The probability adjacency matrix is used to characterize the probability of each edge in the candidate counterfactual interpretation graph. A clean graph is determined from several candidate counterfactual interpretation graphs using the probabilistic adjacency matrix; The definition graph and the clean graph are respectively input into the graph neural network model to predict user preferences, and the corresponding original prediction score and counterfactual prediction score are obtained. After calculating the target loss value based on the definition map, the clean map, the original prediction score and the counterfactual prediction score, the target counterfactual interpretation map is determined. The step of determining the target counterfactual interpretation map after calculating the target loss value based on the definition map, the clean map, the original prediction score, and the counterfactual prediction score includes: Calculate the distribution loss based on the defined graph and the clean graph; Calculate the prediction loss based on the original prediction score and the counterfactual prediction score; Calculate the target loss based on the distributed loss and the predicted loss; Based on the target loss, a target counterfactual interpretation map is determined from several of the clean maps; The distribution loss The calculation formula is as follows: ; In the formula, Represents the definition diagram; Z represents the noise graph; T represents the total number of noise graphs; Indicates the noise in the sampling; This indicates the expectation value; This indicates sampling from the original distribution; Forward noise addition process; The predicted loss The calculation formula is as follows: ; In the formula, Represents a clean image; This represents a graph neural network model; This represents the prediction result of a clean graph in a graph neural network model. Indicates the distribution of the original data; Indicates the continuous time step; This indicates sampling from the original distribution; This indicates the encoding and processing of implicit variables; This indicates the reverse denoising process.
2. The method according to claim 1, characterized in that, The graph neural network model learns the node representations of the defined graph through a message passing mechanism. Each node representation in the defined graph is updated by comparing its own node representation with the representations of its neighboring nodes.
3. The method according to claim 1, characterized in that, The step of performing graph distribution reasoning on the defined graph to obtain semantic latent variables includes: A graph distribution reasoning mechanism based on variational reasoning is used to perform graph distribution reasoning on the defined graph to obtain semantic latent variables.
4. The method according to claim 1, characterized in that, The forward counterfactual diffusion process applied to the defined graph yields several noise graphs, including: The defined graph is transformed into several noise graphs by discrete structure diffusion processing.
5. The method according to claim 1, characterized in that, The step of determining a clean graph from a plurality of candidate counterfactual interpretation graphs using the probabilistic adjacency matrix includes: The discrete adjacency matrix is obtained by sampling the probability adjacency matrix using the Bernoulli distribution; Based on the discrete adjacency matrix, the candidate counterfactual interpretation graph with the minimum perturbation is determined from the candidate counterfactual interpretation graph as the clean graph.
6. The method according to claim 5, characterized in that, The Bernoulli variable of the Bernoulli distribution The following formula: ; In the formula, ; Indicates the activation function; Indicates temperature parameter; This represents the probability value output by the model.