User preference prediction method and system based on data causal graph and anti-factual reasoning, and storage medium
By constructing data causal graphs and counterfactual worlds, and optimizing the scoring calculation process, the problem of not fully considering the item text information and lack of debias operation in the existing technology is solved, and more accurate and fair recommendation results are achieved.
Patent Information
- Application Number
- CN202411979263.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-31
- Publication Date
- 2025-04-08
- Estimated Expiration
- 2044-12-31
AI Technical Summary
The existing scoring formulas do not fully consider the item text information, and the lack of targeted debias operation in the scoring generation process, which may pass the inherent deviations of the model into the final recommendation results.
By constructing a data causal graph, an intervention operation is carried out to build a counterfactual world, and scoring prediction is made. Calculate the degree of matching between sequences and objects in the real world and counterfactual world, combine the degree of matching between text information and sequences, and introduce super parameter λ2 to control the scale of impact of text information on the results, and generate the final prediction and scoring formula.
The joint influence between text features, the inherent characteristics of the item and the sequence characteristics is fully considered, the scoring calculation process is optimized, the fairness and accuracy of the recommendation results are improved, and unnecessary interference of text attributes to sequence attributes is eliminated.
Smart Images

Figure CN119782623A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of behavior sequence recommendation, and in particular to a method, system and storage medium for predicting user preferences based on data causal graph and counterfactual reasoning. Background Art
[0002] With the rapid development of personalized recommendation systems, how to efficiently combine user historical behavior and item features to make accurate rating predictions has become a research focus. In recent years, large language models have been widely used in sequence recommendation systems with their powerful text representation capabilities to extract text features of items and assist in sequence recommendation tasks. However, traditional rating calculation methods face two main problems in the text features of items generated by large models: first, text features may introduce interference that is irrelevant to the user's actual preferences, resulting in bias in rating predictions; second, existing rating formulas cannot fully model the interaction between text features and other features, thereby limiting the performance improvement of recommendation systems.
[0003] Causal inference provides a new perspective. By constructing a causal graph generated by data, we can clarify the causal relationship between text features, user behavior sequences, and rating results, and design new rating optimization methods based on this. However, the traditional rating formula does not fully consider the text information of the item, and lacks targeted debiasing operations in the rating generation process, which may pass the inherent bias of the model to the final recommendation results. Summary of the invention
[0004] The technical problems to be solved by the present invention are:
[0005] The existing scoring formula does not fully consider the item text information, and lacks targeted debiasing operations in the scoring generation process, which may pass the model's inherent bias to the final recommendation results.
[0006] The present invention adopts the following technical solutions to solve the above technical problems:
[0007] The present invention provides a user preference prediction method based on data causal graph and counterfactual reasoning, comprising the following steps:
[0008] Step 1: Collect user-item interaction information data, pre-process the user-item interaction information data to obtain a sequence set, collect item text information data, and pre-process the text information data to obtain a text information set;
[0009] Step 2: Build a large model. The score prediction process of the large model builds a data causal graph based on the sequence recommendation of the large model, performs intervention operations to build a counterfactual world and perform score prediction, calculates the matching degree between the sequence and the item in the real world and the counterfactual world, calculates the joint feature matching degree between the item text and the sequence in the real world and the counterfactual world, and calculates the matching degree between the text information and the sequence, and introduces the hyperparameter λ2 to control the impact scale of the text information on the result, and generates the final prediction score formula;
[0010] Step 3: Input the sequence set and the text information set into the large model to generate recommendation results.
[0011] Furthermore, step 1 includes the following steps:
[0012] Collect user-item interaction information data, determine whether items and users interact and score, filter out samples where users and items have been scored less than 5 times, sort items in chronological order, and then filter out user labels to form a sequence file; then filter out sequences with a sequence length of 1 in the sequence file, and cut the sequence into multiple subsequences, and take the last item in the sequence as the next interaction item result of the sequence, and take all the interaction items before the item as a sequence to obtain a sequence set;
[0013] Collecting the text information data of items and preprocessing the text information data, including text cleaning, splicing the text information of different labels, and generating a text information set;
[0014] Finally, the items in the sequence set that do not contain text information are filtered out.
[0015] Furthermore, the large model in step 2 includes an item text representation learning module based on the large model and a sequence representation learning module based on a graph neural network; the item text representation learning module based on the large model extracts high-quality semantic embedding of item text through a large language model, and combines linear layer mapping and multi-layer perceptron to generate item representations suitable for recommendation tasks; the sequence representation learning module based on the graph neural network uses session graphs and global graphs to capture local sequential relationships and cross-session co-occurrence relationships of items, and generates a comprehensive representation of user behavior sequences.
[0016] Furthermore, the functional implementation process of the sequence representation learning module based on graph neural network is as follows:
[0017] The session graph is constructed in the following way: Each session s is constructed as a directed session graph The point set The vertices in are the vertices in session s, and the edge set Any edge in Represents the order of items in the sequence. Indicates that item i is interacted before item j;
[0018] For node v i Representation Represented by the upper layer and neighbor nodes Features Weighted aggregation is obtained, namely:
[0019]
[0020] The weight α ij is the attention weight calculated based on the correlation between nodes, which is used to dynamically adjust the influence of neighbor nodes on the target node update. ij For node v i and v j The relevance score is combined with the feature representation of the item embedding representation and Through nonlinear changes of the learnable parameters W4 and the attention vector a, we get:
[0021]
[0022]
[0023] Global picture The construction method is as follows: each node v in the graph i Represents an item. If the item v i and v j co-occur in at least one user session, then in v i and v j Create an edge (v i , v j ), the weight of the edge is defined by the co-occurrence frequency between items, that is:
[0024]
[0025] where freq(v i , v j ) is v i and v j The number of co-occurrences, freq(v i ) and freq(v j ) are items v i and v j Number of occurrences;
[0026] Information propagation aggregates information of neighbor nodes through weighted sum based on attention mechanism; neighbor features The weighted aggregation formula is:
[0027]
[0028] The importance of neighbor nodes is determined by the conversation context-sensitive weight function π(v i , v j ) calculation, which is used to distinguish the importance of different neighbors to the current item, and the weight is:
[0029]
[0030] in is the feature vector obtained by averaging the items in the current session, that is:
[0031]
[0032] Among them, w ij is the weight between items, ⊙ represents element-by-element multiplication, || represents concatenation, W5 and q1 are learnable parameters;
[0033] The information aggregation step represents the feature of the current item h v and features propagated from neighbors Fusion is performed to generate new item representations through nonlinear transformation, namely:
[0034]
[0035] Where W6 is the linear transformation weight matrix and ReLU is the activation function;
[0036] The stacked multi-layer propagation mechanism captures high-order neighbor information. Each layer is generated by calculating the item representation and neighbor representation of the previous layer. The representation of the kth layer is defined as:
[0037]
[0038] First, we learn high-level feature representations of items through the global graph and generate comprehensive representations of items by combining session features. The final representation of each item is:
[0039]
[0040] Representing items and reverse position indicates p l-i+1 Splicing is performed and a new representation is generated through nonlinear changes, namely:
[0041]
[0042] Among them, W7 and b4 are learnable parameters;
[0043] Finally, the weighted representations of the items are combined into the final session representation, namely:
[0044]
[0045] Weight β i It is obtained by dynamic calculation of the soft attention mechanism:
[0046]
[0047] W8, W9, q2, b5 are learnable parameters;
[0048] The preliminary session feature s′ is calculated using the average representation of all items in the session, namely:
[0049]
[0050] Where l is the sequence length.
[0051] Furthermore, the score prediction process of the large model in step 2 specifically includes the following steps:
[0052] Calculate the matching degree between the sequence and the item in the real world and the counterfactual world, that is:
[0053]
[0054] Calculate the joint feature matching of item texts and sequences in the real world and the counterfactual world, that is:
[0055]
[0056] Calculate the matching degree between the text information and the sequence, that is:
[0057]
[0058] The hyperparameter λ2 is introduced to control the impact of text information on the results and generate the final prediction score formula:
[0059]
[0060] In the formula, s is a sequence representation, For item v i The item indicates that Q h,s is the matching degree between the inherent characteristics of the item and the sequence characteristics, P s,l is the influence of sequence and text features on the score, P h,l,s Modeling the influence of item inherent features, sequence features and text features, E is a transformation matrix, θ s is the text-aware factor of the sequence, ο is the Hadamard product of the vector, and σ is the Sigmod function.
[0061] Furthermore, the loss function of the large model is:
[0062] l=l rec (Y h,l,s )+l rec (Q h,s )+l rec (P s , P h,l,s )
[0063] Among them l rec Using binary cross loss entropy function:
[0064]
[0065] Where m is the size of the candidate item set, i.e. the number of all candidate items, and y i ∈{0, 1} is the true label.
[0066] Furthermore, the value range of the hyperparameter λ2 is 0 to 1.
[0067] Furthermore, the value of the hyperparameter λ2 is 0.8.
[0068] The present invention provides a user preference prediction system based on data causal graph and counterfactual reasoning. The system has a program module corresponding to the steps of the method described in any one of the above technical solutions, and executes the steps in the above-mentioned user preference prediction method based on data causal graph and counterfactual reasoning during operation.
[0069] The present invention provides a computer-readable storage medium, which stores a computer program. The computer program is configured to implement the steps of the user preference prediction method based on data causal graph and counterfactual reasoning described in any one of the above-mentioned technical solutions when called by a processor.
[0070] Compared with the prior art, the present invention has the following beneficial effects:
[0071] By constructing a causal graph generated by data, the present invention can clarify the causal relationship between text features, user behavior sequences and scoring results, fully consider the joint influence of text features, inherent features of items and sequence features, and optimize the scoring calculation process from the perspective of causality; for the main influencing factors of the score, the scoring results are further optimized based on the counterfactual principle, and the total indirect effect is introduced to replace the total effect, so as to more accurately quantify the impact of text features on the score, improve the fairness and rationality of the recommendation results, and eliminate unnecessary interference of text attributes on sequence attributes to improve the fairness and accuracy of the model's recommendations.
[0072] The method of the present invention was experimentally verified on multiple data sets, including score comparison experiments, ablation experiments, and parameter sensitivity analysis experiments, and the effectiveness and stability of the method of the present invention were comprehensively evaluated. BRIEF DESCRIPTION OF THE DRAWINGS
[0073] Figure 1 It is a causal graph of sequence recommendation model data based on a large model in an embodiment of the present invention;
[0074] Figure 2 is a flow chart of prediction score calculation in an embodiment of the present invention;
[0075] Figure 3 A causal graph of the real world and the counterfactual world in an embodiment of the present invention;
[0076] Figure 4 Figure 1 is a causal graph of the real world and the counterfactual world in an embodiment of the present invention, wherein Figure (a) is a causal graph of real world data, and Figure (b) is a causal graph of counterfactual world data after an intervention operation is performed;
[0077] Figure 5 1 is a graph showing the comparison of scores under different data sets in an embodiment of the present invention, wherein (a) is a graph showing the comparison of scores for Scientific, (b) is a graph showing the comparison of scores for Arts, (c) is a graph showing the comparison of scores for Office, and (d) is a graph showing the comparison of scores for Instruments;
[0078] Figure 6 2 is a graph of the λ2 sensitivity analysis results in an embodiment of the present invention, wherein FIG (a) is a Recall@50 curve graph, FIG (b) is a NDCG@50 curve graph, and FIG (c) is an MRR@50 curve graph. DETAILED DESCRIPTION
[0079] In order to enable those skilled in the art to better understand the scheme of the present invention, exemplary implementations or embodiments of the present invention will be described below in conjunction with the accompanying drawings. Obviously, the described implementations or embodiments are only implementations or embodiments of a part of the present invention, not all of them. Based on the implementations or embodiments of the present invention, all other implementations or embodiments obtained by ordinary technicians in the field without creative work should fall within the scope of protection of the present invention.
[0080] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, specific embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0081] Specific implementation scheme 1: The present invention provides a user preference prediction method based on data causal graph and counterfactual reasoning, comprising the following steps:
[0082] Step 1: Collect user-item interaction information data, pre-process the user-item interaction information data to obtain a sequence set, collect item text information data, and pre-process the text information data to obtain a text information set;
[0083] Step 2: Build a large model. The score prediction process of the large model builds a data causal graph based on the sequence recommendation of the large model, performs intervention operations to build a counterfactual world and perform score prediction, calculates the matching degree between the sequence and the item in the real world and the counterfactual world, calculates the joint feature matching degree between the item text and the sequence in the real world and the counterfactual world, and calculates the matching degree between the text information and the sequence, and introduces the hyperparameter λ2 to control the impact scale of the text information on the result, and generates the final prediction score formula;
[0084] Step 3: Input the sequence set and the text information set into the large model to generate recommendation results.
[0085] Specific implementation plan 2: Step 1 includes the following steps:
[0086] Collect user-item interaction information data, determine whether items and users interact and score, filter out samples where users and items have been scored less than 5 times, sort items in chronological order, and then filter out user labels to form a sequence file; then filter out sequences with a sequence length of 1 in the sequence file, and cut the sequence into multiple subsequences, and take the last item in the sequence as the next interaction item result of the sequence, and take all the interaction items before the item as a sequence to obtain a sequence set;
[0087] Collecting the text information data of items and preprocessing the text information data, including text cleaning, splicing the text information of different labels, and generating a text information set;
[0088] Finally, the items in the sequence set that do not contain text information are filtered out.
[0089] The rest of this embodiment is the same as the first embodiment.
[0090] Specific implementation plan three: The large model described in step 2 adopts a sequence recommendation model based on a large model and a graph neural network (Large Language Model-based Sequential Recommendation, LLM-SR), including an item text representation learning module based on a large model and a sequence representation learning module based on a graph neural network; the item text representation learning module based on a large model extracts high-quality semantic embedding of item text through a large language model, and combines linear layer mapping and multi-layer perceptron to generate item representations suitable for recommendation tasks; the sequence representation learning module based on a graph neural network uses session graphs and global graphs to capture the local sequential relationships and cross-session co-occurrence relationships of items, and generates a comprehensive representation of user behavior sequences.
[0091] The rest of this embodiment is the same as the first embodiment.
[0092] Specific implementation scheme 4: The functional implementation process of the sequence representation learning module based on graph neural network is as follows:
[0093] The session graph is constructed in the following way: Each session s is constructed as a directed session graph The point set The vertices in are the vertices in session s, and the edge set Any edge in Represents the order of items in the sequence. Indicates that item i is interacted before item j;
[0094] For node v i Representation Represented by the upper layer and neighbor nodes Features Weighted aggregation is obtained, namely:
[0095]
[0096] The weight α ij is the attention weight calculated based on the correlation between nodes, which is used to dynamically adjust the influence of neighbor nodes on the target node update. ij For node v i and v j The relevance score is combined with the feature representation of the item embedding representation and Through nonlinear changes of the learnable parameters W4 and the attention vector a, we get:
[0097]
[0098]
[0099] Global picture The construction method is as follows: each node v in the graph i Represents an item. If the item v i and v j co-occur in at least one user session, then in v i and v j Create an edge (v i , v j ), the weight of the edge is defined by the co-occurrence frequency between items, that is:
[0100]
[0101] where freq(v i , v j ) is v i and v j The number of co-occurrences, freq(v i ) and freq(v j ) are items v i and v j Number of occurrences;
[0102] Information propagation aggregates information of neighbor nodes through weighted sum based on attention mechanism; neighbor features The weighted aggregation formula is:
[0103]
[0104] The importance of neighbor nodes is determined by the conversation context-sensitive weight function π(v i , v j ) calculation, which is used to distinguish the importance of different neighbors to the current item, and the weight is:
[0105]
[0106] in is the feature vector obtained by averaging the items in the current session, that is:
[0107]
[0108] Among them, w ij is the weight between items, ⊙ represents element-by-element multiplication, || represents concatenation, W5 and q1 are learnable parameters;
[0109] The information aggregation step represents the feature of the current item h v and features propagated from neighbors Fusion is performed to generate new item representations through nonlinear transformation, namely:
[0110]
[0111] Where W6 is the linear transformation weight matrix and ReLU is the activation function;
[0112] The stacked multi-layer propagation mechanism captures high-order neighbor information. Each layer is generated by calculating the item representation and neighbor representation of the previous layer. The representation of the kth layer is defined as:
[0113]
[0114] First, we learn high-level feature representations of items through the global graph and generate comprehensive representations of items by combining session features. The final representation of each item is:
[0115]
[0116] Representing items and reverse position indicates p l-i+1 Splicing is performed and a new representation is generated through nonlinear changes, namely:
[0117]
[0118] Where W7 and b4 are learnable parameters.
[0119] Finally, the weighted representations of the items are combined into the final session representation, namely:
[0120]
[0121] Weight β i It is obtained by dynamic calculation of the soft attention mechanism:
[0122]
[0123] W8, W9, q2, b5 are learnable parameters;
[0124] The preliminary session feature s′ is calculated using the average representation of all items in the session, namely:
[0125]
[0126] Where l is the sequence length.
[0127] The rest of this implementation plan is the same as the specific implementation plan three.
[0128] Specific implementation plan 5: This implementation plan is designed for the data causal graph of the sequence recommendation framework based on the large language model. Figure 1As shown in the figure. The edge T→I in the figure indicates that the inherent attributes of the item are affected by the text attributes of the item. This is because in the model, the representation of the item is generated by the graph convolution operation through the text representation of the item. The edge T→L indicates that the text attributes of the item have an impact on the text feature representation generated by the large model. Since the text feature representation is generated by extracting the text information through the large model, the causal effect is obvious. The edges I→M, L→M and S→M represent the joint influence of the sequence-item matching pair to the inherent attributes of the item, the inherent attributes of the sequence, and the text feature representation generated by the large model. The edges L→N and S→N indicate that the user-text matching pair is affected by both the inherent attributes of the sequence and the text feature representation generated by the large model. Finally, the edges M→Y and N→Y indicate that the scoring result is jointly determined by the user-item matching pair and the user-text matching pair.
[0129] This implementation scheme adjusts the scoring calculation formula of the model and improves it to formula (4-2). Where E is a transformation matrix used to transform the text features L(T i ) is l i Mapped into the context-aware space. θ s represents the text perception factor of the sequence, which measures the degree to which the sequence is attracted by the text features of the items. It is worth noting that θ s and E(l i ) are located in the same perceptual space, and the inner product of the two reflects the correlation between the sequence and the item text features. In the score calculation, this implementation further decomposes the influence of the causal path M→Y into two parts. One is the influence of the item and sequence on the score, which is expressed as The second is the synergistic effect of items, text information, and sequence on the score, expressed as In addition, the influence of the causal path N→Y is determined by the degree to which the sequence is attracted by the item text features, which is expressed as
[0130]
[0131] Based on formula (4-2), the implementation details of each part of the prediction score are shown in formulas (4-3) to (4-5).
[0132]
[0133]
[0134]
[0135] Among them, s is a sequence representation, For item v i The items indicate that is the Hadamard product of the vector, and σ is the Sigmod function. The final prediction score is formula (4-6), where The function uses simple scalar multiplication.
[0136]
[0137] The specific calculation process is as follows Figure 2 As shown, P s,l Model the relationship between sequence features and text features, and output the joint impact of sequence and text features on the score, P h,l,s Modeling the joint influence of item inherent features, sequence features, and text features, indicating the contribution of the three together to the score, Q h,s Model the relationship between the inherent characteristics of the item and the sequence characteristics, output the matching degree between the item and the sequence characteristics, and finally score It is obtained by comprehensive calculation of the outputs of the above three modules.
[0138] The core of the score optimization in this implementation is based on the counterfactual hypothesis: "If a sequence has been matched with other items with the same large model-extracted text features as the current item, will the sequence still choose to match the current item?" By constructing a counterfactual world and comparing it with the real world, the actual effect of the text features extracted by the large model on the recommendation results can be effectively identified. The introduction of the counterfactual principle can not only quantify the positive or negative impact of text features on recommendations, but also provide theoretical support for eliminating potential biases and optimizing recommendation results.
[0139] In causal inference, intervention refers to setting the value of a certain node B = b (expressed as do(B = b), simplified as do(S)), cutting off the incoming edges of certain nodes in the causal graph, thereby controlling the causal relationship between variables. If node B is intervened, the causal path between variables A and B will be cut off, and the value of B will no longer be affected by A. This process can be achieved through Figure 3 (c) Intuitive expression, through do(A=a * ) intervention operation, the causal relationship between variables A and B is eliminated, and the change of B is completely independent of A. Figure 3 In the diagram, the color of the nodes is used to distinguish different intervention states: a blue node indicates that the node has been intervened, while a half-blue and half-white node indicates that the node is affected by both the intervention and other normal causal paths. This graphical representation clearly shows the impact of intervention on causal relationships, providing intuitive support for path separation and effect analysis in causal inference.
[0140] like Figure 3As shown, in this causal graph, nodes A, B, and C correspond to three random variables, A is the dependent variable, B is the mediating variable, and C is the outcome variable. The edge A-→B represents that B is affected by A, and A is the cause of B. The edge B-→C and the edge A-→C represent that C is affected by both A and B, and both A and B are causes of C. In the causal relationship graph, there are two paths, A-→C and A-→B-→C, that affect variable C at the same time. This implementation plan is based on intervention operations and uses the counterfactual principle to study the causal effects between random variables in the counterfactual world, and then infer how the dependent variable A in the real world affects the outcome variable C through the mediating variable B.
[0141] Based on the total effect TE (Total Effect) theory, the change in the outcome variable C is calculated when the dependent variable A and the mediating variable B change at the same time, that is, the common causal effect of the two paths A-→C and A-→B-→C is calculated. The calculation formula is formula (4-9).
[0142]
[0143] Based on the theory of natural direct effects, the change in the outcome variable C is calculated when the dependent variable A changes without changing the mediating variable B, that is, the causal effect of the path A-→C is calculated. The calculation formula is formula (4-10).
[0144]
[0145] Based on the total indirect effect TIE (Total Indirect Effect) theory, that is, the causal effect of the path A-→B-→C. It is obtained by subtracting the natural direct effect from the total effect. The calculation formula is formula (4-11).
[0146]
[0147] Constructing a causal diagram similar to the counterfactual world Figure 4 As shown, in this counterfactual world, intervention operations are performed on the object representation and the text representation, causing the object-sequence matching pair to become half blue and half white, while the text-sequence matching pair remains white because it is not affected by the intervention operation.
[0148] Introducing the intervention calculation method, assuming that the intervention I=i*, the score prediction result at this time is shown in formula (4-12).
[0149]
[0150] The total indirect effect can be obtained by subtracting the natural direct effect from the total effect. Based on this basic principle, the causal effect of the {L, S}→N→Y path is kept unchanged, and the causal effect of the {I, L, S}→M→Y path is calculated, so we have:
[0151]
[0152] Combined with the rating prediction formula (4-6) based on the data causal graph, in order to enhance the representation ability of the final result and retain the influence of a certain amount of text information on user selection, the hyperparameter λ2 is introduced to control the scale of the influence of text information on the result. The rating prediction formula of the final model is shown in formula (4-14).
[0153]
[0154] The rest of this implementation plan is the same as the specific implementation plan four.
[0155] Specific implementation plan 6: This implementation plan uses a multi-task learning framework to integrate the sequence to predict the rating of the item Y h,l,s , sequence and item-intrinsic attributes score prediction Q h,s And the sequence-to-item text feature joint score prediction P s, l P h,l,s For the three optimization subtasks, the loss function is calculated using formula (4-7).
[0156] l=l rec (Y h,l,s )+l rec (Q h,s )+l rec (P s,l P h,l,s ), #(4-7)
[0157] Where l uses the binary cross loss entropy function, as shown in formula (4-8):
[0158] rC
[0159]
[0160] Where m is the size of the candidate item set, i.e. the number of all candidate items, and y i ∈{0, 1} is the true label.
[0161] The rest of this implementation plan is the same as the specific implementation plan five.
[0162] The causal inference-based scoring optimization method (CISO) of the present invention solves the problem that the traditional scoring calculation formula fails to fully consider the inherent bias of the item text information and the large language model by constructing a data causal graph and introducing counterfactual inference. The core idea is to optimize the scoring prediction formula from the perspective of causality and counterfactual assumptions to improve the fairness and accuracy of the recommendation system. The pseudo code for implementing the scoring optimization method is:
[0163]
[0164] The input of the scoring optimization method based on causal inference is the candidate item set I = {i1, i2, ..., i |I|}, the set of item text representations H = {h1, h2, ..., h |H|}, parameter λ2 controls the weight of the text information on the rating prediction. The predicted rating of the items in the item set I by sequence S Algorithm 1-2 uses the method of calculating the average text representation and feature representation of the item to calculate the text representation and feature representation of the item in the counterfactual world, which is used for intervention operations to construct the counterfactual world. Algorithm 4-7 performs score prediction calculations. Line 4 calculates the matching degree between the sequence and the item in the real world and the counterfactual world respectively; Line 5 calculates the joint feature matching degree between the item text and sequence in the real world and the counterfactual world respectively; Line 6 calculates the matching degree between the text information and the sequence; Line 7 combines the above subtasks to perform prediction score calculation to obtain the final score.
[0165] The user preference prediction method (algorithm) based on data causal graph and counterfactual reasoning proposed in the present invention is the underlying technical core of the present invention, and various products can be derived based on the algorithm.
[0166] Based on the method proposed in the present invention, a user preference prediction system based on data causal graph and counterfactual reasoning is developed using a programming language. The system has program modules corresponding to the steps of the above-mentioned technical solution, and executes the steps in the above-mentioned user preference prediction method based on data causal graph and counterfactual reasoning during runtime.
[0167] The computer program of the developed system (software) is stored on a computer-readable storage medium, and the computer program is configured to implement the steps of the above-mentioned user preference prediction method based on data causal graph and counterfactual reasoning when called by a processor. That is, the present invention is materialized on a carrier to become a computer program product.
[0168] Various implementations of the systems and techniques described herein can be realized in digital electronic circuit systems, integrated circuit systems, dedicated ASICs (application specific integrated circuits), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0169] The computer programs (also referred to as programs, software, software applications, or codes) of the present invention include machine instructions for programmable processors, and these computer programs can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. As used herein, the terms "machine-readable medium" and "computer-readable medium" refer to any computer program product, device, and / or device (e.g., disk, optical disk, memory, programmable logic device PLD) for providing machine instructions and / or data to a programmable processor, including a machine-readable medium that receives machine instructions as machine-readable signals. The term "machine-readable signal" refers to any signal for providing machine instructions and / or data to a programmable processor.
[0170] The beneficial effects of the present invention are described in detail by the following examples.
[0171] Example 1
[0172] The embodiment selects four different datasets in Amazon Review Data 2018 for experiments, namely Industrial and Scientific (Scientific for short), Arts Crafts and Sewing (Arts for short), Office Products (Office for short), and Musical Instruments (Instruments for short).
[0173] The statistical information of the four selected data sets is shown in Table 1. Except for the Scientific data set, the number of interactions in the other data sets has reached the million level. The text information of the four data sets is also very rich, and the average length of the text exceeds 100. The number of users has also reached the tens of thousands level. Among them, the number of users in the Office data set is 87,436, the number of items is 25,986, and the number of interactions is 684,837, which is the largest number of value records among the four data sets.
[0174] Table 1 Statistics of the dataset
[0175]
[0176] All data are initially in two files, a rating only file and a metadata file. In the metadata file, each item consists of multiple data tags and corresponding information. The items in the five data sets have the labels "Title", "Brand" and "category" because the information of these three types of labels are all important text description information for the items. This embodiment first performs text cleaning, and then splices the text information of three different labels together to generate a new data file in the form of (item, text). Finally, the items in the sequence file that do not contain text information are filtered out.
[0177] For the rating only file, the data content is in the form of (user, item, rating, timestamp). The rating value is modified by using the rating as the interaction standard, and the samples with less than 5 appearances of users and items are filtered out. For the interaction behaviors of the same user, the data pairs of (user, item1, item2, item3) are generated by sorting according to the timestamp label, and then the user label is filtered out to form a sequence file. Then the sequences with a sequence length of 1 in the sequence file are filtered out, and the sequence is cut at the same time. A sequence is cut into multiple sequences by sliding the window, and the last item in the sequence is used as the next interaction item result of the sequence. All the interaction items before the item are used as a sequence, such as S = [v s,1 , v s,2 , …, v s,n ], and then cut into multiple subsequences according to the sliding window [(v s,1 ), v s,2 ],[(v s,1 , v s,2 ), v s,3 ],...[(v s,1 , v s,2 , v s,n-1 ), v s,n ].
[0178] The training set and test set are divided according to the session timestamp. First, the latest time of the session in the dataset is determined as the benchmark, and a 7-day time window is subtracted from it to determine the division time threshold. Sessions with timestamps earlier than the threshold are divided into the training set, and sessions later than the threshold are classified as the test set. During the processing, the items that appear in the training set are renumbered and a dictionary of uniquely identified items is constructed; only the items that appear in the training set are retained in the test set. Finally, the session data is converted into a sequence form.
[0179] Based on the above-mentioned LLM-SR model, this embodiment conducts experiments on four data sets: Scientific, Arts, Office, and Instruments. The effectiveness of the score optimization method is judged according to the changes in the evaluation index values before and after the improvement of the prediction score calculation formula (Formula 4-3 before improvement, Formula 4-14 after improvement). The experimental results are as follows: Figure 5 shown.
[0180] It can be seen that the scoring optimization method based on causal inference in this embodiment has significantly improved the model recommendation performance on the four data sets, among which the Recall evaluation index has the most significant improvement effect, the NDCG index has also improved, and the MRR index has a relatively small improvement, but it has an overall positive increase. It can be seen that the method of the present invention can effectively capture the joint impact of sequence features, text features, and item features on the score, which is more superior than the traditional scoring method that only considers sequence features and item features, and has significant advantages in the accuracy of model recommendation results and the ability to sort results.
[0181] Example 2
[0182] The scoring optimization method based on causal inference is mainly composed of P s,l , P h,l,s and Q h,s It consists of three parts. This embodiment uses ablation experiments to verify the rationality of the scoring formula of the present invention, and designs three variant scoring calculation methods Y1, Y2 and Y3, as shown in formulas (4-15), (4-16) and (4-17).
[0183] Y1=P s,l Q h,s , #(4-15)
[0184] Y2=P h,l,s Q h,s , #(4-16)
[0185] Y3=Q h,s , #(4-17)
[0186] Among them, Y1 ignores the joint influence of the inherent features of the item, the sequence features and the text features, Y2 ignores the joint influence of the sequence and text features on the score, and Y3 is the traditional scoring method, which only considers the matching degree between the item and the sequence features. Experiments were conducted on four data sets using four scoring formulas, and the experimental results are shown in Tables 2, 3 and 4.
[0187] It can be seen that the value of Recall@50 of the score optimization method of the present invention is significantly higher than that of the other three variant score methods, which verifies its effectiveness in improving the accuracy of recommendation results. The experimental results of Y1 on the four data sets are all lower than those of Y3, which shows that the score formula cannot be modified arbitrarily, which may lead to negative improvement. By comparing the scores Y2 and Y3, it can be found that the Recall@50 experimental results corresponding to the score Y2 do not change much, indicating that there are still unreasonable aspects in the design of the score Y2.
[0188] Table 2 Ablation experiment Recall@50 results (%)
[0189]
[0190] From the results in Tables 3 and 4, it can be seen that the NDCG@50 and MRR@50 indicators of the scoring optimization method of the present invention are better than the other three scoring methods on the four data sets. Although the improvement is not as significant as Recall@50, it still shows a certain improvement effect, indicating that the proposed optimization method has a positive effect on the ranking performance of the recommendation results. Further comparison of the experimental results of Y1, Y2 and Y3 shows that the performance of the Y1 scoring method is slightly weaker than that of Y2 and Y3. However, the overall difference in the experimental results of the three is small, indicating that these variant scoring methods do not have a significant impact on the ranking performance of the recommendation results, verifying the limitations of the three scoring designs.
[0191] In summary, the optimization method proposed in this paper not only performs outstandingly in terms of the coverage of recommendation results, but also has certain advantages in ranking performance, which further proves the effectiveness and rationality of the optimization method.
[0192] Table 3 Ablation experiment NDCG@50 results (%)
[0193]
[0194] Table 4 Ablation experiment MRR@50 results (%)
[0195]
[0196] Example 3
[0197] In this embodiment, sensitivity analysis is performed on the parameter λ on four datasets: Scientific, Arts, Office, and Instrumems. The values of λ2 are {0, 0.2, 0.4, 0.6, 0.8, 1.2}. Experiments are performed with different λ2 values within the range of the values. The experimental results are shown in Figure 2. Figure 6 shown.
[0198] exist Figure 6In the four data sets of (a), as λ2 increases, the value of Recall@50 also gradually increases, and reaches the maximum value when λ2=0.8. Subsequently, as the value of λ2 increases, the value of Recall@50 begins to decrease. When the value of λ2 is 1, Recall@50 only decreases slightly, but when λ reaches 1.2, Recall@50 drops sharply. This can be explained as the appropriate adoption of counterfactual scoring optimization strategies can increase the accuracy of recommendation results, but excessive adoption will lead to a decrease in results. This is also in line with the principle of the calculation formula of the total indirect effect. When the value of λ exceeds 1, the total effect minus the natural direct effect will result in the subtraction of additional effects. At this time, the total indirect effect obtained cannot reflect the situation where the dependent variable affects the outcome variable through the mediating variable. Figure 6 In (c), the MRR@50 curve shows the same rule as the Recall@50 change. As λ2 increases, the MRR@50 value increases continuously, reaches the maximum value when λ2=0.8, and then begins to decline. When λ, exceeds 1, there is a cliff-like drop.
[0199] exist Figure 6 In (b), the trend of NDCG@50 with λ2 is slightly different from that of Recall@50, and it does not show a consistent trend of first rising and then falling. The trend in the Office and Instruments datasets is exactly the same as Recall@50, rising first and then falling, but the rise is very small. The trend in the Arts dataset is to rise first, then fall, then rise again, and finally fall again. However, when λ2 is in the range of 0-1, the value of NDCG@50 is better than the value when λ2=0. In the Scientific dataset, although it also rises first and then falls, there is no cliff-like drop when λ2=1.2, but only a small drop. The explanation for this phenomenon is based on the NDCG evaluation index. The NDCG evaluation index focuses on the properties of the overall sequence of the candidate sequence, rather than the accuracy of the result. Therefore, as λ2 increases, the result may not necessarily become better. However, overall, when λ2 is in the range of 0-1, NDCG@50 in the four datasets is better than when λ2 is 0. After comprehensive consideration, this paper believes that the λ2 value of 0.8 is more appropriate. Although this is not the optimal solution sometimes, its performance is better overall.
[0200] Although the present invention is disclosed as above, the protection scope of the present invention is not limited thereto. Those skilled in the art may make various changes and modifications without departing from the spirit and scope of the present invention, and these changes and modifications will fall within the protection scope of the present invention.
Claims
1. A user preference prediction method based on data causal graph and counterfactual reasoning, characterized in that: The steps include: Step 1: Collect user-item interaction information data, pre-process the user-item interaction information data to obtain a sequence set, collect item text information data, and pre-process the text information data to obtain a text information set; Step 2: Build a large model. The score prediction process of the large model builds a data causal graph based on the sequence recommendation of the large model, performs intervention operations to build a counterfactual world and perform score prediction, calculates the matching degree between the sequence and the item in the real world and the counterfactual world, calculates the joint feature matching degree between the item text and the sequence in the real world and the counterfactual world, and calculates the matching degree between the text information and the sequence, and introduces hyperparameters to control the impact scale of the text information on the result, so as to generate the final prediction score formula; Step 3: Input the sequence set and the text information set into the large model to generate recommendation results.
2. The user preference prediction method based on data causal graph and counterfactual reasoning according to claim 1 is characterized in that: Step 1 includes the following steps: Collect user-item interaction information data, determine whether items and users interact and score, filter out samples where users and items have been scored less than 5 times, sort items in chronological order, and then filter out user labels to form a sequence file; then filter out sequences with a sequence length of 1 in the sequence file, and cut the sequence into multiple subsequences, and take the last item in the sequence as the next interaction item result of the sequence, and take all the interaction items before the item as a sequence to obtain a sequence set; Collecting the text information data of items and preprocessing the text information data, including text cleaning, splicing the text information of different labels, and generating a text information set; Finally, the items in the sequence set that do not contain text information are filtered out.
3. The user preference prediction method based on data causal graph and counterfactual reasoning according to claim 1 is characterized in that: The large model in step 2 includes an item text representation learning module based on the large model and a sequence representation learning module based on a graph neural network; the item text representation learning module based on the large model extracts high-quality semantic embedding of item text through a large language model, and combines linear layer mapping and multi-layer perceptron to generate item representations suitable for recommendation tasks; the sequence representation learning module based on a graph neural network uses session graphs and global graphs to capture local sequential relationships and cross-session co-occurrence relationships of items, and generates a comprehensive representation of user behavior sequences.
4. The user preference prediction method based on data causal graph and counterfactual reasoning according to claim 3 is characterized in that: The functional implementation process of the sequence representation learning module based on graph neural network is as follows: The session graph is constructed in the following way: Each session s is constructed as a directed session graph The point set The vertices in are the vertices in session s, and the edge set Any edge in Represents the order of items in the sequence. Indicates that item i is interacted before item j; For node v i Representation Represented by the upper layer and neighbor nodes Features Weighted aggregation is obtained, namely: The weight α ij is the attention weight calculated based on the correlation between nodes, which is used to dynamically adjust the influence of neighbor nodes on the target node update. ij For node v i and v j The relevance score is combined with the feature representation of the item embedding representation and Through nonlinear changes of the learnable parameters W4 and the attention vector a, we get: Global picture The construction method is as follows: each node v in the graph i Represents an item. If the item v i and v j co-occur in at least one user session, then in v i and v j Create an edge between i , v j ), the weight of the edge is defined by the co-occurrence frequency between items, that is: where freq(v i , v j ) is v i and v j The number of co-occurrences, freq(v i ) and freq(v j ) are items v i and v j Number of occurrences; Information propagation aggregates information from neighboring nodes through a weighted sum based on an attention mechanism; Neighborhood characteristics The weighted aggregation formula is: The importance of neighbor nodes is determined by the conversation context-sensitive weight function π(v i , v j ) calculation, which is used to distinguish the importance of different neighbors to the current item, and the weight is: in is the feature vector obtained by averaging the items in the current session, that is: Among them, w ij is the weight between items, ⊙ represents element-by-element multiplication, || represents concatenation, W5 and q1 are learnable parameters; The information aggregation step represents the feature of the current item h v and features propagated from neighbors Fusion is performed to generate new item representations through nonlinear transformation, namely: Where W6 is the linear transformation weight matrix and ReLU is the activation function; The stacked multi-layer propagation mechanism captures high-order neighbor information. Each layer is generated by calculating the item representation and neighbor representation of the previous layer. The representation of the kth layer is defined as: First, we learn high-level feature representations of items through the global graph and generate comprehensive representations of items by combining session features. The final representation of each item is: Representing items and reverse position indicates p l-i+1 Splicing is performed and a new representation is generated through nonlinear changes, namely: Among them, W7 and b4 are learnable parameters; Finally, the weighted representations of the items are combined into the final session representation, namely: Weight β i It is obtained by dynamic calculation of the soft attention mechanism: W8, W9, q2, b5 are learnable parameters; The preliminary session feature s′ is calculated using the average representation of all items in the session, namely: Where l is the sequence length.
5. The user preference prediction method based on data causal graph and counterfactual reasoning according to claim 4 is characterized in that: The score prediction process of the large model in step 2 specifically includes the following steps: Calculate the matching degree between the sequence and the item in the real world and the counterfactual world, that is: Calculate the joint feature matching of item texts and sequences in the real world and the counterfactual world, that is: Calculate the matching degree between the text information and the sequence, that is: The hyperparameter λ2 is introduced to control the impact of text information on the results and generate the final prediction score formula: In the formula, s is a sequence representation, For item v i The item indicates that Q h,s is the matching degree between the inherent characteristics of the item and the sequence characteristics, P s,l is the influence of sequence and text features on the score, P h,l,s Modeling the influence of item inherent features, sequence features and text features, E is a transformation matrix, θ s is the text-aware factor of the sequence, is the Hadamard product of the vectors, and σ is the Sigmod function.
6. The user preference prediction method based on data causal graph and counterfactual reasoning according to claim 5 is characterized in that: The loss function of the large model is: in Using binary cross loss entropy function: Where m is the size of the candidate item set, i.e. the number of all candidate items, and y i ∈{0, 1} is the true label.
7. The user preference prediction method based on data causal graph and counterfactual reasoning according to claim 6 is characterized in that: The value range of the hyperparameter λ2 is 0 to 1.
8. The user preference prediction method based on data causal graph and counterfactual reasoning according to claim 7 is characterized in that: The value of the hyperparameter λ2 is 0.
8.
9. A user preference prediction system based on data causal graph and counterfactual reasoning, characterized in that: The system has a program module corresponding to the steps of the method described in any one of claims 1 to 8 above, and executes the steps in the user preference prediction method based on data causal graph and counterfactual reasoning when running.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and the computer program is configured to implement the steps in the user preference prediction method based on data causal graph and counterfactual reasoning according to any one of claims 1 to 8 when called by a processor.
Citation Information
Patent Citations
Anti-fact generation method based on causal intervention
CN114897140A
Anti-fact fair recommendation method based on inverse tendency weighting method
CN114936890A
Sequence recommendation model modeling method and device
CN117743687A
De-biased cognitive recommendation method and system based on anti-fact learning
CN117972197A
Fraud detection method and system for anti-camouflage preference based on causal invariance
CN118170915A
Cited By
Knowledge tracking method and device based on anti-fact personalized enhancement
CN120471176A
An interview review scoring adjustment method and system based on causal inference
CN122509761A