Causal discovery method based on large model and structure constraint and related device
By introducing large models and structural constraints into the causal discovery method, the causal graphs are generated and optimized, and the problem of insufficient efficiency and accuracy of causal relationship recognition in the existing technology is solved, and efficient and accurate causal relationship recognition and graph generation are achieved.
Patent Information
- Application Number
- CN202411951590.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-27
- Publication Date
- 2025-04-25
AI Technical Summary
When faced with high-dimensional data and complex causal relationships, the existing causal discovery methods have high computational complexity, strong model assumption dependence, and time-consuming optimization process, making it difficult to effectively identify causal relationships.
A causal discovery method based on large models and structural constraints is adopted. By obtaining the meta information of causal variables in text data, a large language model is used to generate initial potential causal graphs in combination with multiple rounds of dialogue, multi-role role-playing and auxiliary prompt words, and iterative optimization is carried out through a policy network and reinforcement learning algorithm to introduce structural constraints to ensure the rationality and confidence of the generated causal graph.
It significantly improves the efficiency and accuracy of causal relationship recognition, generates a high confidence causal relationship diagram in complex data environments, and improves the iteration speed of reinforcement learning algorithms, reducing the consumption of computing resources.
Smart Images

Figure CN119886341A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of artificial intelligence and data science technology, and relates to a causal discovery method based on a large model and structural constraints and a related device. Background Art
[0002] In the era of big data, how to discover causal relationships from massive data is one of the research areas in data science that is most likely to create commercial value and conduct research discoveries. Existing causal discovery methods mainly include constraint-based methods, model-based methods, and value score-based methods. However, these methods often show certain limitations when faced with high-dimensional data and complex causal relationships.
[0003] Constraint-based methods rely on testing the conditional independence between variables to identify the Markov equivalence class of the true causal graph. Such methods are prone to high computational complexity in high-dimensional data. Model-based methods impose additional assumptions on the distribution and function class of the causal model to identify the direction of all edges in the causal graph. However, this method is highly dependent on model assumptions and may lead to incorrect causal conclusions when the assumptions do not conform to the actual situation. Value-score-based methods use scoring functions and search strategies to find the causal graph with the optimal value score, but due to the huge search space, the optimization process is very time-consuming. Summary of the invention
[0004] The purpose of the present invention is to overcome the above-mentioned shortcomings of the prior art and provide a causal discovery method and related devices based on large models and structural constraints.
[0005] In order to achieve the above object, the present invention adopts the following technical solutions:
[0006] In a first aspect, the present invention provides a causal discovery method based on a large model and structural constraints, comprising: obtaining meta-information of each causal variable in a text data set; generating an initial potential causal graph of each causal variable based on the meta-information of each causal variable, using a large language model and combining multi-round dialogue, multi-role playing and auxiliary prompt words; repeating the following steps until preset conditions are met, and outputting a candidate causal graph with the highest value score: generating a candidate causal graph using a policy network based on an encoder-decoder architecture, and iteratively optimizing the candidate causal graph using a reinforcement learning algorithm based on an actor-critic framework; wherein, structural constraints generated based on the initial potential causal graph are introduced into the reward function of the reinforcement learning algorithm; calculating the value score of the iteratively optimized candidate causal graph based on the value network, and updating the parameters of the policy network based on the encoder-decoder architecture based on the value score.
[0007] Optionally, the text dataset is: a biological dataset, a sociological dataset, a climatological dataset or a complex system failure dataset.
[0008] Optionally, the meta-information of the causal variable includes the variable name and description information of the causal variable.
[0009] Optionally, the encoder of the policy network adopts a Transformer model with a multi-head attention mechanism; the generation of a candidate causal graph using a policy network based on an encoder-decoder architecture includes: establishing a relationship between two outputs of the encoder through the decoder, and sampling using a Bernoulli distribution after processing with a logistic-sigmoid function to obtain a 0-1 binary candidate graph adjacency matrix as a candidate causal graph.
[0010] Optionally, the structural constraints generated based on the initial potential causal graph include:
[0011] Edge constraints:
[0012] f(W,g(W c ))=||Wg(W c )||1,g(W c )=th*W c
[0013] Where W∈{0,1} n×n Represents the adjacency matrix of the candidate causal graph, W c ∈{0, 1} n×n represents the edge constraint matrix, X i and X j represents the causal variable, n is the total number of causal variables, [W c ] ij =1 means there is edge X i →X j ,[W c ] ij =0 means there is no edge f(.) is used to measure the current adjacency matrix W and the expected structure matrix g(W c ) is the deviation function of the deviation value, where g(W c ) is the generated expected structure matrix, th is the preset threshold constant, and ||·||1 represents the L1 norm of the matrix, which is used to measure the absolute deviation of each element of the matrix.
[0014] Path constraints:
[0015]
[0016] in, represents the constraint matrix of the kth path graph; Represents the threshold function of the kth path relationship, th k is the preset threshold constant of the kth path; ||·||1 represents the L1 norm; ⊙ represents the element-by-element multiplication operator; relu(·) is the activation function.
[0017] Order constraints:
[0018] |||W|⊙W O ||1=0
[0019] Among them, W O is the constraint matrix in triangular matrix form.
[0020] Optionally, the reward function of the reinforcement learning algorithm is designed using BIC score, cyclic penalty and correct path as penalty items, and allows the candidate causal graph to change multiple edges in each iterative optimization; the reward function is specifically:
[0021] reward(W)=S(W)+β||W||1+A
[0022]
[0023] C0(W)=tr(e W⊙W )=n1
[0024] C1(W)=||relu(g(W c )-|W|⊙W c )||1=0
[0025] C3(W)=||W⊙W c ||1=0
[0026]
[0027] Among them, S(W) is the BIC score calculation function, β||W||1 is the weighted regularization term, β is the regularization hyperparameter, and A is the additional penalty term used to penalize the circular dependencies and path constraints in the causal graph; λ x is the weight of the penalty term, represents the threshold function of the k path relationships; ⊙ represents the element-by-element multiplication of the matrix; C2(W) represents the weight function related to the path constraint; C0(W) represents the self-loop weight and acyclicity constraint through the matrix W, W is the adjacency matrix of the candidate causal graph, W ⊙ W represents the element-by-element square of the matrix elements, e W⊙W The matrix W⊙W is indexed element by element, tr(·) represents the trace of the calculation matrix; n1 is the total number of nodes in the candidate causal graph; C1(W) represents the guarantee that W is consistent with the prior edge constraint matrix W c Keep consistent constraints, W c is a binary constraint matrix, W c∈{0, 1} n×n , W c,ij =1 indicates that edge X in the candidate causal graph i →X j Existence, W c,ij = 0 means the edge does not exist; g(W c ) represents the desired structure matrix, relu(·) is the activation function, ||·||1 is the L1 norm; C3(W) represents the constraint of excluding invalid edges, |W| is the element-by-element absolute value matrix of W; C4(W) represents the local path constraint, I represents the identity matrix, represents the constraint relationship matrix on the qth and lth paths; C5(W) represents the topological sorting constraint, [W c ] ij Indicates whether the node i→j is allowed to exist in the constraint matrix.
[0028] Optionally, the value network adopts a graph attention network; and the value score of the candidate causal graph after iterative optimization is calculated according to the value network includes: calculating the value score V(G) of the candidate causal graph after iterative optimization by the following formula:
[0029]
[0030] Among them, h i represents the feature representation of the nodes in the candidate causal graph after iterative optimization, W i and b are learning parameters, σ is the activation function, and N is the total number of nodes in the candidate causal graph after iterative optimization.
[0031] In a second aspect, the present invention provides a causal discovery system based on a large model and structural constraints, comprising: a data acquisition module for acquiring meta-information of each causal variable in a text data set; a large model processing module for generating an initial potential causal graph of each causal variable based on the meta-information of each causal variable, using a large language model and combining multiple rounds of dialogue, multiple role-playing and auxiliary prompt words; a control module for iteratively triggering an optimization module and an update module until preset conditions are met, and outputting a candidate causal graph with the highest value score; an optimization module for generating a candidate causal graph using a policy network based on an encoder-decoder architecture, and iteratively optimizing the candidate causal graph using a reinforcement learning algorithm based on an actor-critic framework; wherein the structural constraint conditions generated based on the initial potential causal graph are introduced into the reward function of the reinforcement learning algorithm; an update module for calculating the value score of the iteratively optimized candidate causal graph based on the value network, and updating the parameters of the policy network based on the encoder-decoder architecture according to the value score.
[0032] According to a third aspect of the present invention, a computer device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above-mentioned causal discovery method based on large models and structural constraints when executing the computer program.
[0033] According to a fourth aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above-mentioned causal discovery method based on large models and structural constraints are implemented.
[0034] Compared with the prior art, the present invention has the following beneficial effects:
[0035] The causal discovery method based on large models and structural constraints of the present invention can efficiently understand and parse the causal variable meta-information in the text data set by adopting a large language model, and combining multiple rounds of dialogue, multiple role-playing and auxiliary prompt words, and quickly generate an initial potential causal graph. The large model significantly improves the initial efficiency and accuracy of causal relationship identification by virtue of its powerful natural language processing capabilities and rich prior knowledge. At the same time, a policy network based on an encoder-decoder architecture is used to generate candidate causal graphs, and iterative optimization is performed through a reinforcement learning algorithm based on an actor-critic framework. This combination enables the algorithm to automatically learn and adjust the structure of the candidate causal graph to maximize its value score, thereby generating a high-confidence causal relationship graph in a complex data environment. In addition, the structural constraints generated based on the initial potential causal graph are introduced in the reward function of the reinforcement learning algorithm to ensure that the candidate causal graph will not deviate from the topic or produce unreasonable structures during the iterative optimization process. This constraint not only improves the confidence of the causal relationship graph, but also makes the generated causal relationship graph more consistent with actual data and domain knowledge. In addition, by incorporating the structural constraints generated based on the initial potential causal graph, the reinforcement learning algorithm can converge to the optimal solution faster during the iterative optimization process. This design not only improves the iteration speed of the algorithm, but also reduces the consumption of computing resources. Finally, the introduction of the value network provides an effective evaluation mechanism for the candidate causal graph. By calculating the value score of the candidate causal graph after iterative optimization and updating the parameters of the policy network according to the score, an efficient feedback mechanism is implemented. This mechanism enables the algorithm to continuously learn and improve, gradually approaching the optimal solution, thereby further improving the iteration speed. In general, the causal discovery method based on large models and structural constraints of the present invention not only significantly improves the efficiency and accuracy of causal relationship identification, but also can generate high-confidence causal relationship graphs in complex data environments, and significantly improves the iteration speed of the reinforcement learning algorithm. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1This is a flow chart of a causal discovery method based on a large model and structural constraints according to an embodiment of the present invention.
[0037] Figure 2 Schematic diagram of the principle of a causal discovery method based on a large model and structural constraints according to an embodiment of the present invention.
[0038] Figure 3 This is a detailed flow chart of a causal discovery method based on a large model and structural constraints according to an embodiment of the present invention.
[0039] Figure 4 This is a structural block diagram of a causal discovery system based on a large model and structural constraints according to an embodiment of the present invention. DETAILED DESCRIPTION
[0040] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0041] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0042] The present invention is further described in detail below in conjunction with the accompanying drawings:
[0043] See also Figure 1 In one embodiment of the present invention, a causal discovery method based on a large model and structural constraints is provided, which effectively improves the result indicators on nonlinear text data sets and the convergence speed of reinforcement learning models, and provides a new solution for causal discovery in complex data scenarios.
[0044] Specifically, the causal discovery method based on large models and structural constraints of the present invention includes the following steps:
[0045] S1: Obtain the meta-information of each causal variable in the text dataset.
[0046] S2: Based on the meta-information of each causal variable, a large language model is used in combination with multi-round dialogues, multi-role playing, and auxiliary prompt words to generate the initial potential causal graph of each causal variable.
[0047] S3: Repeat S4 and S5 until the preset conditions are met, and output the candidate causal graph with the highest value score.
[0048] S4: A policy network based on an encoder-decoder architecture is used to generate a candidate causal graph, and a reinforcement learning algorithm based on an actor-critic framework is used to iteratively optimize the candidate causal graph; wherein a structural constraint condition generated based on the initial potential causal graph is introduced into the reward function of the reinforcement learning algorithm.
[0049] S5: Calculate the value score of the iteratively optimized candidate causal graph based on the value network, and update the parameters of the policy network based on the encoder-decoder architecture based on the value score.
[0050] Explanatory, the causal discovery method based on large models and structural constraints of the present invention utilizes large language models, such as GPT or other advanced natural language processing models, which are trained with a large amount of text data and can capture rich contextual information and semantic relationships. When applied to causal discovery tasks, the large model can quickly generate a preliminary but highly accurate potential causal graph based on the meta-information of each causal variable in the text data set. This avoids the cumbersome process of manually constructing or generating causal graphs based on simple rules in traditional methods, thereby significantly improving the efficiency of causal relationship identification.
[0051] At the same time, by combining multi-round dialogues and multi-role-playing strategies, the present invention can simulate the interaction between different roles (such as experts, patients, and researchers, etc.), and explore the potential relationships of causal variables from multiple angles and levels. This interactive generation method not only increases the richness of the causal diagram, but also further improves its accuracy, because the perspectives and professional knowledge of different roles can complement and verify each other. In addition, when generating the initial potential causal diagram, the present invention also cleverly introduces auxiliary prompt words. These prompt words can be keywords, phrases or questions in the field, which can guide the large model to generate potential relationships related to specific causal variables more focused, thereby further improving the accuracy and pertinence of the causal diagram.
[0052] Explanatory, the causal discovery method based on large models and structural constraints of the present invention uses a policy network based on an encoder-decoder architecture to generate candidate causal graphs, and performs iterative optimization through a reinforcement learning algorithm based on an actor-critic framework. This combination enables the algorithm to automatically learn and adjust the structure of the candidate causal graph to maximize its value score. In a complex data environment, this optimization capability is particularly important because it can handle nonlinear relationships, hidden dependencies, and noise interference between variables, thereby generating a more robust and reliable causal relationship graph. At the same time, introducing structural constraints based on the generation of the initial potential causal graph in the reward function of the reinforcement learning algorithm is an innovation of the present invention. This constraint can ensure that the candidate causal graph remains consistent with the initial potential causal graph during the iterative optimization process, avoiding deviation from the subject or the generation of unreasonable structures. This not only improves the confidence of the causal relationship graph, but also significantly reduces the blindness and uncertainty in the iterative process, thereby accelerating the convergence speed of the algorithm.
[0053] Finally, the present invention also uses the value network to evaluate the value of the candidate causal graph after iterative optimization, and updates the parameters of the policy network according to the evaluation results. This evaluation-update mechanism enables the algorithm to continuously learn and improve, gradually approaching the optimal solution. At the same time, the introduction of the value network also provides an effective stopping criterion, that is, when the value score of the candidate causal graph reaches a preset threshold or no longer significantly improves, the algorithm can stop iterating and output the optimal solution. This further improves the efficiency and practicality of the algorithm.
[0054] In general, the causal discovery method based on large models and structural constraints in the present invention not only significantly improves the efficiency and accuracy of causal relationship identification, but also can generate high-confidence causal relationship graphs in complex data environments and significantly improves the iteration speed of reinforcement learning algorithms.
[0055] In a possible implementation, the text dataset is: a biological dataset, a sociological dataset, a climatological dataset, or a complex system failure dataset.
[0056] For example, biological datasets such as the Sachs protein dataset, sociological datasets such as the Asia dataset, climatological datasets such as the Arctic sea ice dataset, and complex system failure datasets such as the RSF railway system monitoring dataset. In addition, text datasets can be observed based on specific causal discovery tasks. For example, causal variable data can also be preprocessed, including missing value filling and normalization steps to ensure data integrity and consistency.
[0057] In a possible implementation, the causal discovery method based on large models and structural constraints is applied to the fault detection dataset RSF of the railway brake system. The key factors leading to equipment failure are identified through causal discovery, thereby achieving fault prediction and maintenance optimization. The dataset contains 38 monitoring variables, which are divided into three categories: objective environmental variables (such as external temperature and operating time), human influence variables (such as braking mode and braking force level), and system physical property variables (such as current, voltage, vibration, etc.). The data is collected from the sensors of the railway brake system to monitor the operating status of the key components of the system.
[0058] Step 1: Data preprocessing, including missing value filling, constant screening and standardization. First, use interpolation or statistical methods (such as mean filling) to process missing values in sensor data, detect abnormal data through IQR (interquartile range) and remove variables that are always constant in the entire data set. Monitoring data contains continuous variables and discrete variables. Discrete variables are encoded through dummy variables. Finally, all variables are standardized using Z-score.
[0059] Step 2: Causal graph generation: Based on the meta-information of each sensor variable, a large language model is used in combination with multi-round dialogue, multi-role play and auxiliary prompt words to generate the initial potential causal graph of each causal variable; the following steps are repeated until the preset conditions are met, and the candidate causal graph with the highest value score is output: a policy network based on an encoder-decoder architecture is used to generate the candidate causal graph, and a reinforcement learning algorithm based on an actor-critic framework is used to iteratively optimize the candidate causal graph; wherein the structural constraints generated based on the initial potential causal graph are introduced into the reward function of the reinforcement learning algorithm; the value score of the iteratively optimized candidate causal graph is calculated based on the value network, and the parameters of the policy network based on the encoder-decoder architecture are updated according to the value score. Finally, a causal structure graph is output to identify the causal relationship between each sensor variable.
[0060] Step 3: Application and interpretation of causal graphs. First, the critical paths containing faults are screened. By removing redundant paths containing relationships and retaining high-contribution paths starting from leaf nodes, 13 critical paths are screened from the original causal path set for subsequent fault detection. Since the causal path reflects the causal influence mechanism of the fault, the identified path can also help analyze the cause of the fault in the positioning system, optimize the sensor monitoring and control strategy in a targeted manner, and support maintenance decisions of the detected object.
[0061] Exemplarily, the meta-information of the causal variable includes the variable name and description information of the causal variable.
[0062] See also Figure 2 and 3According to the meta-information of each causal variable, a large language model is used in combination with multi-round dialogue, multi-role playing and auxiliary prompt words to generate the initial potential causal graph of each causal variable, including:
[0063] Utilizing the semantic understanding and reasoning capabilities of the large language model, causal relationships are discovered using only meta-information such as the names and descriptions of causal variables. Then, structured conversations are conducted using the large language model to simulate different roles (such as sociologists and data analysts) to accurately capture causal assumptions in the context of the data. At the same time, conversation strategies are designed to iteratively refine causal relationships through role-playing, thereby enhancing the model’s ability to understand and express complex causal structures. Finally, the output results of the large model are processed, including deduplication and directed causal edges, and each causal relationship is integrated into a causal graph to generate an initial potential causal graph for each causal variable.
[0064] In one possible implementation, the encoder of the policy network adopts a Transformer model with a multi-head attention mechanism; the generation of a candidate causal graph using a policy network based on an encoder-decoder architecture includes: establishing a relationship between two outputs of the encoder through a decoder, and sampling using a Bernoulli distribution after processing with a logistic-sigmoid function to obtain a 0-1 binary candidate graph adjacency matrix as a candidate causal graph.
[0065] The Transformer structure encoder based on the multi-head attention mechanism is applicable to various types of data. The output of the encoder is represented as ennc i , i = 1, 2, ..., d, where the dimension is d e The decoder outputs two encoders enc i and enc j Establish the relationship, pass the logistic-sigmoid function, and then use the Bernoulli distribution for sampling to obtain a 0-1 binary candidate graph adjacency matrix.
[0066] The calculation formula of a single-layer decoder is expressed as:
[0067] g ij (W1, W2, u) = u T tanh(W1enc i +W2enc j )
[0068] Among them, g ij is used to calculate node x i and node x j The weight score of the causal edge between them (the larger the score, the stronger the causal relationship), through W1enc i and W2enc jThe final score is obtained by the weighted combination of the tanh activation function and the inner product of the vector u; W1 and W2 are two trainable weight matrices with dimensions W1, d h is the dimension of the hidden layer, indicating the characteristic dimension of the hidden layer of the neural network, and d e is the input encoding vector (enc i and enc j ) dimension; is a trainable parameter used to perform weighted summation on the results of the tanh activation function; tanh(·) represents a hyperbolic tangent activation function, which introduces a nonlinear transformation and maps the input value to the interval (-1,1); σ(·) represents the logistic-sigmoid function: G ij Mapped to the probability range (0, 1), indicating that from node x i To node x j The probability of a causal edge; Bernoulli distribution represents the probability of σ(g ij ) to perform Bernoulli distribution sampling, that is, according to the probability σ(g ij ) Generate entries of the binary adjacency matrix: If the sampling result is 1, it means that from x i to x j There is a causal edge; if the sampling result is 0, it means there is no causal edge.
[0069] Among them, W1, is a trainable parameter, and d h is the hidden dimension. To generate a binary adjacency matrix, each entry g ij Passed to the logistic-sigmoid function σ(·) and then sampled according to the Bernoulli distribution with probability σ(g ij ), indicating that from x i to x j The probability that a causal edge exists.
[0070] In a possible implementation, the structural constraints generated based on the initial potential causal graph include edge constraints, path constraints, and sequence constraints.
[0071] Among them, the edge constraints are:
[0072] f(W,g(W c ))=||Wg(W c )||1,g(W c )=th*W c
[0073] Where W∈{0,1} n×n Represents the adjacency matrix of the candidate causal graph, W c∈ {0, 1} n×n represents the edge constraint matrix, X i and X j represent causal variables, n is the total number of causal variables, [W c ij = 1 represents the existence of an edge X i → X j , [W c ij = 0 represents the non - existence of an edge f(.) is a deviation function used to measure the deviation value between the current adjacency matrix W and the expected structure matrix g(W c ), where g(W c ) is the generated expected structure matrix, th is a preset threshold constant, ||·||1 represents the L1 norm of the matrix, which is used to measure the absolute deviation of the matrix element by element.
[0074] Path constraint:
[0075]
[0076] Among them, represents the constraint matrix of the k - th path graph; represents the threshold function of the k - th path relationship, th k is the preset threshold constant of the k - th path; in |W| k represents the k - th power of the adjacency matrix W, representing the k - step path from node i to node j, ⊙ represents the element - by - element multiplication of the corresponding elements; relu(·) represents the activation function to ensure the non - negativity of the path constraint; ||·||1 is the L1 norm of the matrix, measuring the deviation degree of the path constraint.
[0077] Order constraint:
[0078] |||W|⊙W O ||1 = 0
[0079] Among them, W O is the constraint matrix in the form of a triangular matrix.
[0080] Explanatory, the edge constraint is non - parametric and represents a qualitative description of a directed acyclic graph. Its formula is:
[0081] f(W, g(W c )), g(W c ) = th * W c
[0082] Among them, W c ∈ {0, 1} n×n represents the edge constraint matrix, [W c ij =1 means there is edge X i →X j ; [W c ] ij = 0 means there is no edge, that is f(.) is used to measure the relationship between the current adjacency matrix W and the expected structure matrix g(W c )’s deviation value.
[0083] Regarding path constraints, the definition of the path graph in causal discovery is: Assume that graph G′ is an extension of graph G. For any edge X in G′ i →X j , there is always at least one path in G that satisfies X i →X1→…→X k-1 →X j The path where the intermediate nodes {X1, ..., X k-1} is k-1, then G′ is called the kth path graph of G. Similarly, the prior knowledge of the kth path graph is called the kth path constraint. Its equality constraint can be expressed as:
[0084]
[0085] in, represents the constraint matrix of the kth path graph, g k (W) = th k *W represents the threshold function of the kth path relationship, k is a constant.
[0086] The order constraint provides the confidence of the initial graph on the variable V sequence, which is essentially a collection of error paths and edge constraints. Its equality constraint is:
[0087] |||W|⊙W O ||1=0
[0088] Among them, the constraint matrix W O is a triangular matrix.
[0089] In a possible implementation, the reward function of the reinforcement learning algorithm is designed using BIC score, cyclic penalty and correct path as penalty items, and allows the candidate causal graph to change multiple edges in each iterative optimization; the reward function is specifically:
[0090] reward(W)=S(W)+β||W||1+A
[0091]
[0092] C0(W)=tr(e W⊙W )=n1
[0093] C1(W)=||relu(g(W c )-|W|⊙W c )||1=0
[0094] C3(W)=||W⊙W c ||1=0
[0095]
[0096] Among them, S(W) is a score function calculated using BIC (Bayesian Information Criterion), which is used to quantify the structural rationality and simplicity of the current graph W; β||W||1 is a weighted regularization term used to control the sparsity of the graph structure, and β is a regularization hyperparameter; A is an additional penalty term used to penalize cyclic dependencies and path constraints in the causal graph, which is defined as follows:
[0097]
[0098] Among them, λ x is the weight of the penalty term; Represents the threshold function of the k-path relationship; ⊙ represents the element-by-element multiplication of the matrix; C2(W): the weight function related to the path constraint.
[0099] The constraints given in the formula can be used to limit the learned adjacency matrix W to satisfy specific properties, including sparsity, acyclicity, and order. The following are the specific five constraint formulas and parameter explanations:
[0100] C0(W)=tr(e W⊙W )=n
[0101] It means that there are no self-loops in the graph structure through the self-loop weight and acyclic constraints of the matrix W. Where W is the adjacency matrix, which represents the structure of the candidate causal graph; W ⊙ W represents the element-by-element square of the matrix elements, which represents the square of the weight of each edge; e W⊙W : Take the exponentiation of the matrix W ⊙ W element by element to generate a new matrix; tr(·) represents the trace of the calculation matrix, that is, the sum of the elements on the diagonal; n is the total number of nodes in the causal graph.
[0102] C1(W)=||relu(g(W c )-W⊙W c )||1=0
[0103] Ensure that the graph structure W and the prior edge constraint matrix W c Keep consistent. Among them, W c is a binary constraint matrix, W c ∈{0, 1} n×n , where W c,ij =1 indicates that edge X in the candidate causal graph i→X j Existence, W c,ij = 0 means the edge does not exist; g(W c ) represents the desired structure matrix (generated by function g), which is the same as W c The associated constraint graph; W⊙W c is the adjacency matrix W and the constraint matrix W c The element-by-element product of represents the edges and their weights in the candidate causal graph; relu(·) is the activation function, which sets the negative values in the input to 0 and keeps the positive values unchanged; ||·||1 is the L1 norm.
[0104] C3(W)=||W⊙W c ||1=0
[0105] Excluding invalid edges specified in some constraints ensures that c The edges not marked as possible in W c The position of 0 in the adjacency matrix W does not exist either. Where |W| is the element-by-element absolute value matrix of W; W c is a binary constraint matrix that defines which edges can exist in the causal graph; ||·||1 is the L1 norm.
[0106]
[0107] A local path constraint is imposed on the weight matrix W in the graph to further ensure acyclicity. Here, e|W|-I means subtracting the identity matrix (self-loop constraint) from the absolute value of each element of the adjacency matrix and then taking the exponent; W q,l Represents the constraint relationship matrix on the q,lth path;
[0108]
[0109] To ensure the topological sorting of the graph, that is, to ensure that the directional signs of the edges in the causal graph satisfy the given constraints and prevent the generation of incorrect causal directions. c is the element-by-element product of the adjacency matrix and the constraint matrix, representing the valid edge weights in the candidate graph; [W c ] ij Indicates whether the node i→j in the constraint matrix is allowed to exist;
[0110] condition Restriction: Only causal edges with i < j are allowed (directional constraint).
[0111] Explanatory, traditional score-based methods explicitly check whether the graph has a cycle each time an edge is added. The present invention uses the Bayesian Information Criterion score (BIC score) and the cycle penalty and the correct path (Positive Path, PP) as penalty terms to design the reward function, while other constraints are used as constraints and allow the generated graph to change multiple edges in each iteration.
[0112] First, the Bayesian Information Criterion score (BIC) commonly used in score-based methods is calculated as the core penalty term. The calculation formula is:
[0113]
[0114] in, is the maximum likelihood estimator, and dθ represents the dimension of θ. If a linear model relationship is applied to each causal relationship, and Expressed as The corresponding estimate of , then the BIC score can be expressed as:
[0115]
[0116] in represents the residual sum of squares of the ith variable.
[0117] Then the Bayesian Information Criterion score (BIC), which is commonly used in score-based methods, is used as the core penalty term, and its calculation formula is:
[0118]
[0119] in, is the maximum likelihood estimator, and dθ represents the dimension of θ. If a linear model relationship is applied to each causal relationship, and Expressed as The corresponding estimate of , then the BIC score can be expressed as:
[0120]
[0121] in, represents the residual sum of squares of the ith variable.
[0122] The specific continuous optimization problem is as follows:
[0123] reward(W)=S(W)+β||W||1+A
[0124]
[0125] The constraints are:
[0126] C0(W)=tr(eW⊙W )=n
[0127] C1(W)=||relu(g(W c )-|W|⊙W c )||1=0
[0128] C3(W)||||W|⊙W c ||1=0
[0129] C4(W)||(e |W| -I)⊙W q ||1=0
[0130]
[0131] Among them, C0(W) is the acyclic constraint, that is, it needs to satisfy the properties of a directed acyclic graph; C1(W) and C3(W) are the correct edge and incorrect edge constraints; C4(W) is the incorrect path constraint; and C5(W) is the order constraint.
[0132] In a possible implementation, the value network adopts a graph attention network; the calculating the value score of the iteratively optimized candidate causal graph according to the value network includes: calculating the value score V(G) of the iteratively optimized candidate causal graph by the following formula:
[0133]
[0134] Among them, h i represents the feature representation of the nodes in the candidate causal graph after iterative optimization, W i and b are learning parameters, σ is the activation function, and N is the total number of nodes in the candidate causal graph after iterative optimization.
[0135] Explanatory, the value network uses a graph attention network (GAT) to evaluate the features of candidate causal graphs, updates the policy network through the value scores, and iterates continuously to finally generate a candidate causal graph with the optimal score.
[0136] In order to verify the performance of the method of the present invention, a number of experimental comparisons were carried out based on the Sachs protein dataset, including comparisons with traditional causal discovery algorithms (such as PC and GES, etc.), SOTA methods (such as NoTears and ICALiNGAM, etc.) and reinforcement learning-based methods (such as RL-BIC and CORL). The results were evaluated using five evaluation indicators: structural Hamming distance (SHD), F1 score (F1-score), precision (Precision), recall rate (Recall) and runtime (Runtime). The optimal value of the five experimental results was taken for each type of algorithm. The results are shown in Table 1.
[0137] Table 1
[0138]
[0139]
[0140] Experimental results show that the proposed method outperforms other comparison methods in terms of graph quality indicators on the Sachs dataset, while the running time is significantly reduced compared with other reinforcement learning comparison methods. The structural Hamming distance (SHD) and F1 score of the proposed method are 9 and 0.73, respectively, and the precision and recall are 0.93 and 0.60, respectively, which are significantly better than other comparison methods. Compared with the best control group LLMCSL algorithm, the structural Hamming distance is reduced by 4, and the F1 score is increased by 0.21. Compared with the benchmark algorithm based on reinforcement learning, the epoch required for convergence is reduced from 2000 to 500, and the running time is reduced from 4 minutes and 38 seconds to 54 seconds. The convergence speed is significantly improved, which verifies the effectiveness of the proposed method.
[0141] In order to further verify the robustness of the algorithm, the present invention also selected a number of representative public data sets covering continuous data and discrete data types, including the Lucas lung cancer data set in the field of biology, the Asia data set in the field of sociology, and the Arctic sea ice data set in the field of climatology, and the results are shown in Table 2. The above experimental results show that the method of the present invention performs well on different types of data sets in various fields, and has wide applicability and high practical value.
[0142] Table 2
[0143]
[0144] The following are device embodiments of the present invention, which can be used to implement the method embodiments of the present invention. For details not disclosed in the device embodiments, please refer to the method embodiments of the present invention.
[0145] See also Figure 4 In another embodiment of the present invention, a causal discovery system based on a large model and structural constraints is provided, which can be used to implement the above-mentioned causal discovery method based on a large model and structural constraints. Specifically, the causal discovery system based on a large model and structural constraints includes a data acquisition module, a large model processing module, a control module, an optimization module and an update module.
[0146] Among them, the data acquisition module is used to obtain the meta-information of each causal variable in the text data set; the large model processing module is used to generate the initial potential causal graph of each causal variable according to the meta-information of each causal variable, using a large language model and combining multi-round dialogue, multi-role playing and auxiliary prompt words; the control module iteratively triggers the optimization module and the update module until the preset conditions are met, and outputs the candidate causal graph with the highest value score; the optimization module is used to generate the candidate causal graph using a policy network based on the encoder-decoder architecture, and iteratively optimize the candidate causal graph using a reinforcement learning algorithm based on the actor-critic framework; wherein, the structural constraints generated based on the initial potential causal graph are introduced into the reward function of the reinforcement learning algorithm; the update module is used to calculate the value score of the iteratively optimized candidate causal graph according to the value network, and update the parameters of the policy network based on the encoder-decoder architecture according to the value score.
[0147] All relevant contents of each step involved in the aforementioned embodiment of the causal discovery method based on big models and structural constraints can be referred to the functional description of the functional modules corresponding to the causal discovery system based on big models and structural constraints in the embodiment of the present invention, and will not be repeated here.
[0148] The division of modules in the embodiments of the present invention is schematic and is only a logical function division. There may be other division methods in actual implementation. In addition, each functional module in each embodiment of the present invention may be integrated into one processor, or may exist physically separately, or two or more modules may be integrated into one module. The above-mentioned integrated modules may be implemented in the form of hardware or in the form of software functional modules.
[0149] In another embodiment of the present invention, a computer device is provided, the computer device comprising a processor and a memory, the memory being used to store a computer program, the computer program comprising program instructions, and the processor being used to execute the program instructions stored in the computer storage medium. The processor may be a central processing unit (CPU), or may be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc., which are the computing core and control core of the terminal, which are suitable for implementing one or more instructions, and are specifically suitable for loading and executing one or more instructions in a computer storage medium to implement a corresponding method flow or corresponding function; the processor described in the embodiment of the present invention can be used for the operation of a causal discovery method based on a large model and structural constraints.
[0150] In another embodiment of the present invention, the present invention also provides a storage medium, specifically a computer-readable storage medium (Memory), which is a memory device in a computer device for storing programs and data. It is understandable that the computer-readable storage medium here can include both built-in storage media in a computer device and, of course, an extended storage medium supported by the computer device. The computer-readable storage medium provides a storage space, which stores the operating system of the terminal. In addition, one or more instructions suitable for being loaded and executed by a processor are also stored in the storage space, and these instructions can be one or more computer programs (including program codes). It should be noted that the computer-readable storage medium here can be a high-speed RAM memory or a non-volatile memory, such as at least one disk memory. The processor can load and execute one or more instructions stored in the computer-readable storage medium to implement the corresponding steps of the causal discovery method based on large models and structural constraints in the above-mentioned embodiment.
[0151] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0152] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0153] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0154] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0155] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, ordinary technicians in the relevant field should understand that the specific implementation methods of the present invention can still be modified or replaced by equivalents. Any modification or equivalent replacement that does not depart from the spirit and scope of the present invention should be covered within the scope of protection of the claims of the present invention.
Claims
1. A causal discovery method based on large models and structural constraints, characterized in that: include: Obtain meta-information of each causal variable in the text dataset; Based on the meta-information of each causal variable, a large language model is used in combination with multi-round dialogue, multi-role playing and auxiliary prompt words to generate the initial potential causal graph of each causal variable; Repeat the following steps until the preset conditions are met and output the candidate causal graph with the highest value score: A policy network based on an encoder-decoder architecture is used to generate a candidate causal graph, and a reinforcement learning algorithm based on an actor-critic framework is used to iteratively optimize the candidate causal graph; wherein a structural constraint condition based on the generation of an initial potential causal graph is introduced into the reward function of the reinforcement learning algorithm; The value score of the iteratively optimized candidate causal graph is calculated according to the value network, and the parameters of the policy network based on the encoder-decoder architecture are updated according to the value score.
2. The causal discovery method based on large models and structural constraints according to claim 1 is characterized in that: The text dataset is: a biological dataset, a sociological dataset, a climatological dataset or a complex system failure dataset.
3. The causal discovery method based on large models and structural constraints according to claim 1 is characterized in that: The meta information of the causal variable includes the variable name and description information of the causal variable.
4. The causal discovery method based on large models and structural constraints according to claim 1 is characterized in that: The encoder of the strategy network adopts a Transformer model with a multi-head attention mechanism; The generation of a candidate causal graph using a strategy network based on an encoder-decoder architecture includes: establishing a relationship between two outputs of the encoder through the decoder, and sampling using a Bernoulli distribution after processing with a logistic-sigmoid function to obtain a 0-1 binary candidate graph adjacency matrix as a candidate causal graph.
5. The causal discovery method based on large models and structural constraints according to claim 1 is characterized in that: The structural constraints generated based on the initial potential causal graph include: Edge constraints: f(W,g(W c ))=||According to(In c )||1,g(W c )=th*W c Where W∈{0,1} n×n Represents the adjacency matrix of the candidate causal graph, W c ∈{0, 1} n×n represents the edge constraint matrix, X u and X j represents the causal variable, n is the total number of causal variables, [W c ] ij =1 means there is edge X i →X j ,[W c ] ij =0 means there is no edge f(.) is used to measure the current adjacency matrix W and the expected structure matrix g(W c ) is the deviation function of the deviation value, where g(W c ) is the generated expected structure matrix, th is the preset threshold constant, and ||·||1 represents the L1 norm of the matrix, which is used to measure the absolute deviation of each element of the matrix; Path constraints: in, represents the constraint matrix of the kth path graph; Represents the threshold function of the kth path relationship, th k is the preset threshold constant of the kth path; ‖·‖1 represents the L1 norm; ⊙ represents the element-wise multiplication operator; relu(·) is the activation function; Order constraints: |||W|⊙W o ||1=0 Among them, W o is the constraint matrix in triangular matrix form.
6. The causal discovery method based on large models and structural constraints according to claim 1 is characterized in that: The reward function of the reinforcement learning algorithm is designed using BIC score, cyclic penalty and correct path as penalty items, and allows the candidate causal graph to change multiple edges in each iterative optimization; The specific reward function is: reward(W)=S(W)+β||W||1+A C0(W)=tr(e W⊙W )=n1 C1(W)=||relu(g(W c )-|W|⊙W c )||1=0 C3(W)=||W⊙W c ||1=0 Among them, S(W) is the BIC score calculation function, β||W||1 is the weighted regularization term, β is the regularization hyperparameter, and A is the additional penalty term used to penalize the circular dependencies and path constraints in the causal graph; λ x is the weight of the penalty term, represents the threshold function of the k path relationships; ⊙ represents the element-by-element multiplication of the matrix; C2(W) represents the weight function related to the path constraint; C0(W) represents the self-loop weight and acyclicity constraint through the matrix W, W is the adjacency matrix of the candidate causal graph, W⊙W represents the element-by-element square of the matrix elements, e W⊙W The matrix W⊙W is indexed element by element, tr(·) represents the trace of the calculation matrix; n1 is the total number of nodes in the candidate causal graph; C1(W) represents the guarantee that W is consistent with the prior edge constraint matrix W c Keep consistent constraints, W c is a binary constraint matrix, W c ∈{0,1} n×n , W c,ij =1 indicates that edge X in the candidate causal graph i →X j Existence, W c,ij = 0 means the edge does not exist; g(W c ) represents the desired structure matrix, relu(·) is the activation function, ||·||1 is the L1 norm; C3(W) represents the constraint of excluding invalid edges, |W| is the element-by-element absolute value matrix of W; C4(W) represents the local path constraint, I represents the identity matrix, represents the constraint relationship matrix on the qth and lth paths; C5(W) represents the topological sorting constraint, [W c ] ij Indicates whether the node i→j is allowed to exist in the constraint matrix.
7. The causal discovery method based on large models and structural constraints according to claim 1 is characterized in that: The value network adopts a graph attention network; The value score of the candidate causal graph after iterative optimization according to the value network calculation includes: The value score V(G) of the iteratively optimized candidate causal graph is calculated by the following formula: Among them, j i represents the feature representation of the nodes in the candidate causal graph after iterative optimization, W i and b are learning parameters, σ is the activation function, and N is the total number of nodes in the candidate causal graph after iterative optimization.
8. A causal discovery system based on large models and structural constraints, characterized by: include: The data acquisition module is used to obtain the meta-information of each causal variable in the text dataset; The large model processing module is used to generate the initial potential causal graph of each causal variable based on the meta-information of each causal variable, using a large language model and combining multi-round dialogue, multi-role playing and auxiliary prompt words; The control module iteratively triggers the optimization module and the update module until the preset conditions are met, and outputs the candidate causal graph with the highest value score; An optimization module, for generating a candidate causal graph using a policy network based on an encoder-decoder architecture, and iteratively optimizing the candidate causal graph using a reinforcement learning algorithm based on an actor-critic framework; wherein a structural constraint condition generated based on an initial potential causal graph is introduced into a reward function of the reinforcement learning algorithm; An update module is used to calculate the value score of the iteratively optimized candidate causal graph according to the value network, and update the parameters of the policy network based on the encoder-decoder architecture according to the value score.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the causal discovery method based on large models and structural constraints as described in any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the causal discovery method based on large models and structural constraints as described in any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Heterogeneous graph-based multi-modal teaching video abstract generation method
CN120833575A
A Multimodal Teaching Video Summarization Method Based on Heterogeneous Graphs
CN120833575B
Causal structure discovery method based on evolutionary neural architecture search and reinforcement learning
CN121480606A
Multi-subgraph fusion reinforcement learning control method and system for multi-input multi-output system
CN121721968A
Industrial operation and maintenance text-driven causal graph construction and root cause analysis method and device
CN122221990A