A text analysis method and device based on causal relationships and multi-layered topic understanding

By combining global causal graphs and directional masked graph neural networks, fine-grained mapping and information transmission between abstract topics are achieved, solving the problem of insufficient identification of causal relationships and topic hierarchical structures in existing technologies, and improving the accuracy and logic of text analysis.

CN123070091APending Publication Date: 2026-11-10INST OF MEDICAL INFORMATION CHINESE ACAD OF MEDICAL SCI
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202512040366.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-30
Publication Date
2026-11-10

AI Technical Summary

Technical Problem

In the fields of topic modeling and causal discovery, existing technologies have several limitations. Traditional models cannot effectively distinguish between causal dependencies and simple associations, ignore topic hierarchical structures, supervised models rely on manually labeled data and have limited application scope, large language models have failed to integrate into a globally consistent causal structure, and graph neural network methods have not deeply integrated causal reasoning, resulting in text analysis results that lack logical rigor and interpretability.

Method used

This paper adopts a text analysis method based on causal relationships and multi-layer topic understanding. Through pre-trained global causal graph, directional mask graph neural network and cross-layer information fusion mechanism, it identifies topic nodes and aggregates causal information to realize the mapping and information transmission between fine-grained and abstract topics, and outputs multi-granular topic structure and directed causal inference results.

Benefits of technology

It enhances the depth of text theme mining and the accuracy of causal relationship revelation, provides hierarchical and logical analysis results, and offers comprehensive and reliable text understanding basis for professional fields.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123070091A_ABST
    Figure CN123070091A_ABST
Patent Text Reader

Abstract

This application discloses a text analysis method and device based on causal relationships and multi-layer topic understanding. The method first receives the target document to be analyzed and preprocesses it to obtain standardized target text. Then, it inputs a causal topic model containing a pre-trained global causal graph, a directional mask graph neural network, a cross-layer information fusion mechanism, and a mapping relationship between fine-grained and abstract topic layers. Based on the global causal graph, topic nodes are identified, and the parent node set is matched and causal information is aggregated through the directional mask graph neural network to obtain a target topic representation vector. Then, the vector is mapped to the corresponding fine-grained and abstract topics through the two-layer topic mapping relationship. Global context information is passed through the cross-layer information fusion mechanism to obtain the final target topic representation that integrates multi-granular information. Finally, based on the final target topic representation and the global causal graph, the multi-granular topic structure of the target document and the directed causal inference results between topics are output.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of text analysis technology, and in particular to a text analysis method and device based on causal relationships and multi-layered topic understanding. Background Technology

[0002] With the advent of the big data era, unstructured text data has experienced explosive growth, covering multiple fields such as academic literature, clinical medical records, policy documents, and financial reports. This type of text not only contains rich thematic concepts but also hides complex causal relationships between themes. Uncovering these causal relationships is crucial for revealing the laws governing the development of phenomena and supporting decision-making. For example, in the medical field, sorting out the causal logic between diseases, drugs, and efficacy from massive amounts of clinical literature can provide a scientific basis for clinical decision-making; in the field of policy analysis, clarifying the causal chain between policy implementation and changes in socio-economic indicators can provide support for policy optimization. Therefore, causal topic modeling techniques that automatically discover themes and infer their causal relationships from unstructured text have become a research hotspot in the fields of natural language processing and data mining.

[0003] Current technologies face core bottlenecks in topic modeling and causal discovery. Traditional topic models are limited to capturing statistical co-occurrence relationships between topics, failing to effectively distinguish between causal dependencies and simple associations, and neglecting the inherent hierarchical structure of topics. This results in outputs lacking sufficient logical rigor and interpretability, making them unsuitable for in-depth analysis in specialized fields. While supervised causal topic models can model causal relationships between topics, they heavily rely on manually labeled data. In fields such as medicine and social sciences, where text data is massive and labeling costs are extremely high, especially in emerging research areas lacking mature labeling systems, their practical application is severely limited, hindering efficient implementation in unsupervised scenarios. Summary of the Invention

[0004] To address the aforementioned issues, this application provides a text analysis method and apparatus based on causal relationships and multi-layered topic understanding.

[0005] The embodiments of this application disclose the following technical solutions:

[0006] In a first aspect, embodiments of this application provide a text analysis method based on causal relationships and multi-layered topic understanding, the method comprising:

[0007] Receive the target document to be analyzed, preprocess the target document to obtain standardized target text;

[0008] The standardized target text is input into a pre-trained causal topic model, which includes a pre-trained global causal graph, a directional mask graph neural network, a cross-layer information fusion mechanism, and a mapping relationship between fine-grained topic layers and abstract topic layers.

[0009] Based on the global causal graph, the topic nodes in the standardized target text are identified, and the parent node set of each topic node in the global causal graph is matched by the directional mask graph neural network. The causal information of the parent nodes is aggregated to obtain the target topic representation vector.

[0010] Based on the mapping relationship between the fine-grained topic layer and the abstract topic layer, the target topic representation vector is mapped to the corresponding fine-grained topic and abstract topic respectively. The cross-layer information fusion mechanism is invoked to pass the global context information of the abstract topic to the corresponding fine-grained topic, so as to obtain the target final topic representation that integrates multi-granular information.

[0011] Based on the final topic representation of the target and the global causal graph, the multi-granularity topic structure of the target document and the directed causal inference results between topics are output.

[0012] In one possible implementation, the training process of the causal topic model is as follows:

[0013] Acquire text corpus, and extract candidate sets of topic nodes and candidate causal relationship pairs from the text corpus based on a large language model;

[0014] The candidate set of topic nodes is standardized to obtain a global set of topic nodes;

[0015] A global causal graph is generated based on the NOTEARS algorithm and the candidate causal relationships. The global causal graph includes global topic nodes and directed causal edges between global topic nodes. The directed causal edges are used to mark the causal direction and causal strength between global topic nodes.

[0016] Based on the set of parent nodes of each topic node in the global causal graph, a nonlinear causal generation function for each topic node is constructed and the representation vector of each topic node is calculated.

[0017] A directional mask matrix is ​​introduced into the global causal graph. The parent node information is aggregated according to the directional mask matrix through a directional mask graph neural network, and the representation vector of each topic node is updated to obtain a topic node representation matrix that integrates causal information. The directional mask matrix is ​​used to restrict the propagation of information from the cause topic node to the result topic node.

[0018] Clustering is performed on the global topic nodes in the topic node representation matrix to obtain a fine-grained topic layer and an abstract topic layer; the fine-grained topic layer includes each topic node, and the abstract topic layer includes abstract topics formed by clustering semantically similar fine-grained topics;

[0019] Based on the global causal graph, directed causal edges are induced between the abstract topics, and an abstract layer causal graph is constructed.

[0020] Directional masked graph neural network propagation is performed on the abstract layer causal graph to update the representation vector of the abstract topic; the representation vector of the abstract topic is then passed back to the corresponding fine-grained topic through a gating mechanism to obtain a topic representation that integrates multi-granularity information.

[0021] Based on the global causal graph, the parameters of the directional mask graph neural network, the cross-layer information fusion mechanism, and the mapping relationship between the fine-grained topic layer and the abstract topic layer, the causal topic model is integrated to form the causal topic model.

[0022] In one possible implementation, the standardization process of the candidate topic nodes to obtain a global topic node set includes:

[0023] Load a pre-defined domain standard terminology library, which includes standard conceptual entities within the domain;

[0024] The semantic similarity between each topic node in the candidate topic node set and the terms in the standard terminology database is calculated using a text embedding model.

[0025] Topic nodes with semantic similarity higher than a preset threshold are mapped to corresponding standard terms, and multiple topic nodes mapped to the same standard term are merged and deduplicated to obtain the global topic node set.

[0026] In one possible implementation, constructing the nonlinear causal generation function for each topic node and calculating the representation vector for each topic node includes:

[0027] For the topic node, identify the set of parent nodes of the topic node from the global causal graph;

[0028] The input vector is obtained by concatenating the representation vectors of all parent nodes in the set of parent nodes along the feature dimension.

[0029] The input vector is input into the multilayer perceptron network corresponding to the topic node, and after nonlinear transformation, exogenous noise is superimposed to output the representation vector of the topic node; the multilayer perceptron network corresponds one-to-one with the topic in the global causal graph.

[0030] In one possible implementation, the process of constructing and applying the directional mask matrix includes:

[0031] Construct the directional mask matrix with the same dimension as the adjacency matrix. If there is a directed edge from node j to node i in the global causal graph, set the corresponding position (i,j) in the mask matrix to 1; otherwise, set it to 0.

[0032] When the graph neural network calculates the attention weights, the attention score corresponding to the position with a value of 0 in the directional mask matrix is ​​forcibly set to negative infinity or zero, so that when aggregating the information of the parent node, the weights of non-parent nodes are masked, and the information propagation flows from the parent node to the child node along the causal direction.

[0033] In one possible implementation, receiving the target document to be analyzed and preprocessing the target document includes:

[0034] The summary and title of the target text are merged into a unified text unit to obtain the merged target text;

[0035] The merged target text is cleaned by removing typesetting and citation marks, and the capitalization of academic proper nouns is standardized.

[0036] In one possible implementation, the candidate causal relationship pair includes the causal pair and the confidence level corresponding to the causal pair; the causal pair includes a cause topic and an effect topic;

[0037] The generation of a global causal graph based on the NOTEARS algorithm and the candidate causal relationship pairs includes:

[0038] The causal pairs are filtered based on the confidence level, and causal pairs with a confidence level greater than the confidence threshold are retained.

[0039] Calculate the frequency of occurrence of multiple causal pairs obtained from the screening and perform weight calculations to construct a candidate edge set;

[0040] Construct an initial adjacency matrix based on the candidate edge set;

[0041] The initial adjacency matrix is ​​optimized based on the NOTEARS algorithm, and the global causal graph is generated through differentiable acyclic constraints.

[0042] In one possible implementation, the training process of the causal topic model further includes:

[0043] Based on Pearl's Do-calculus theory, an intervention operation is performed on the target topic node, fixing the value of the target topic node to a preset intervention value, and severing the causal connection edges between the target topic node and all parent nodes in the global causal graph, while keeping the rest of the causal structure unchanged.

[0044] Based on the topological sorting of the global causal graph, the representation vectors of downstream descendant topic nodes affected by the intervention of the target topic node are recalculated to obtain the counterfactual representation vectors;

[0045] Input the counterfactual representation vector and Gaussian random noise into the generator to obtain the counterfactual text; input the real text or the generated counterfactual text into the discriminator to obtain the text authenticity score;

[0046] The scores of the real text and the counterfactual text are calculated separately, and the difference between the scores of the real text and the generated text is used as the Wasserstein distance estimate. Based on the linear interpolation samples of the real text and the counterfactual text, a gradient penalty term is calculated. The Wasserstein distance estimate is added to the gradient penalty term to obtain the total loss of the discriminator.

[0047] An optimizer is used to update the network parameters of the discriminator through backpropagation based on the total loss of the discriminator;

[0048] Calculate the adversarial loss of the discriminator; calculate the semantic similarity between the counterfactual text and the real text using the BERT model to obtain the semantic consistency constraint term; add the adversarial loss to the semantic consistency constraint term to obtain the generator's total loss;

[0049] An optimizer is used to update the generator's network parameters through backpropagation based on the generator's total loss.

[0050] In one possible implementation, the training process of the causal topic model further includes:

[0051] For the global causal graph, the adjacency matrix of the global causal graph is updated by augmented Lagrange optimization based on the structural scoring loss function and the acyclicity constraint function.

[0052] For the global causal graph and the directional mask graph neural network, the adjacency matrix of the global causal graph is fixed, and the parameters of the nonlinear causal generation function and the directional mask graph neural network are jointly optimized based on the reconstruction loss function;

[0053] With the global causal graph fixed, the parameters of the generator and discriminator are optimized using an adversarial training strategy.

[0054] Based on the global joint loss function, the parameters of each part in the causal topic model are adjusted.

[0055] In one possible implementation, the method further includes:

[0056] The topic nodes and their corresponding topic representation vectors in the target text are used as the baseline vector for counterfactual reasoning.

[0057] The baseline vector is adjusted according to the intervention description; if the intervention description is to delete the target topic node, the baseline vector of the target topic node is set to zero; if the intervention description is to enhance the target topic node, the baseline vector of the target topic node is multiplied by a coefficient greater than 1; if the intervention description is to replace the target topic node, the topic node representation vector of the target topic node sampled from other documents is used as the replacement vector.

[0058] According to the topological order of the global causal graph, the topic representation vectors of the downstream topic nodes affected by the intervention are recalculated, while the baseline vectors of the unaffected topics remain unchanged, resulting in a set of counterfactual topic vectors.

[0059] Input the set of counterfactual topic vectors into the generator, select zero noise to generate counterfactual text; calculate the change in the representation vector of each topic node before and after the intervention, identify topic nodes whose representation vector change is greater than a preset value and mark the degree of representation vector change;

[0060] Text alignment techniques are used to display the differences between the target document and the counterfactual text in the form of highlights or marks;

[0061] Generate a natural language causal explanation; the natural language causal explanation is used to explain the mechanism by which the intervention of the target topic leads to changes in the text content.

[0062] In one possible implementation, the method further includes:

[0063] Obtain the specified starting topic node, and from the pre-trained global causal graph, filter all descendant topic nodes that are rooted at the starting topic node and reachable by directed paths, as well as directed connection edges between topic nodes, to form a causal subgraph;

[0064] Perform a topological sort on the topic nodes in the causal subgraph to generate an ordered list of descendant topic nodes;

[0065] Using the starting topic node as the root node, add descendant topic nodes layer by layer according to the topological sorting in the ordered list, connect each descendant topic node to the parent node pointing to the descendant topic node in the causal subgraph, and mark the corresponding causal strength score on the connection edge;

[0066] Calculate the influence breadth of the starting topic node, and count the number of topic nodes that directly influence the topic node, the number of topic nodes that indirectly influence the topic node, and the total number of topic nodes that influence the topic node.

[0067] Identify intermediate topic nodes whose in-degree and out-degree are both greater than preset values; the intermediate topic nodes are topic nodes that connect multiple causal paths;

[0068] Determine the longest causal chain from the starting topic node to the leaf node, record the path sequence and path length, and generate a visualization chart.

[0069] Secondly, embodiments of this application disclose a text analysis device based on causal relationships and multi-layered topic understanding, the device comprising:

[0070] The preprocessing module is used to receive the target document to be analyzed, preprocess the target document, and obtain standardized target text.

[0071] The input module is used to input the standardized target text into the pre-trained causal topic model. The causal topic model includes a pre-trained global causal graph, a directional mask graph neural network, a cross-layer information fusion mechanism, and a mapping relationship between fine-grained topic layers and abstract topic layers.

[0072] The first processing module is used to extract topic nodes in the standardized target text based on the global causal graph using the directional mask graph neural network, and to match the set of parent nodes of each topic node in the global causal graph, and to aggregate the causal information of the parent nodes to obtain the target topic representation vector.

[0073] The second processing module is used to map the target topic representation vector to the corresponding fine-grained topic and abstract topic respectively based on the mapping relationship between the fine-grained topic layer and the abstract topic layer, and call the cross-layer information fusion mechanism to pass the global context information of the abstract topic to the corresponding fine-grained topic to obtain the target final topic representation that integrates multi-granularity information.

[0074] The output module is used to output the multi-granularity topic structure of the target document and the directed causal inference results between topics based on the target final topic representation and the global causal graph.

[0075] In one possible implementation, the apparatus further includes a model training module, the model training module being used for:

[0076] Acquire text corpus, and extract candidate sets of topic nodes and candidate causal relationship pairs from the text corpus based on a large language model;

[0077] The candidate set of topic nodes is standardized to obtain a global set of topic nodes;

[0078] A global causal graph is generated based on the NOTEARS algorithm and the candidate causal relationships. The global causal graph includes global topic nodes and directed causal edges between global topic nodes. The directed causal edges are used to mark the causal direction and causal strength between global topic nodes.

[0079] Based on the set of parent nodes of each topic node in the global causal graph, a nonlinear causal generation function for each topic node is constructed and the representation vector of each topic node is calculated.

[0080] A directional mask matrix is ​​introduced into the global causal graph. The parent node information is aggregated according to the directional mask matrix through a directional mask graph neural network, and the representation vector of each topic node is updated to obtain a topic node representation matrix that integrates causal information. The directional mask matrix is ​​used to restrict the propagation of information from the cause topic node to the result topic node.

[0081] Clustering is performed on the global topic nodes in the topic node representation matrix to obtain a fine-grained topic layer and an abstract topic layer; the fine-grained topic layer includes each topic node, and the abstract topic layer includes abstract topics formed by clustering semantically similar fine-grained topics;

[0082] Based on the global causal graph, directed causal edges are induced between the abstract topics, and an abstract layer causal graph is constructed.

[0083] Directional masked graph neural network propagation is performed on the abstract layer causal graph to update the representation vector of the abstract topic; the representation vector of the abstract topic is then passed back to the corresponding fine-grained topic through a gating mechanism to obtain a topic representation that integrates multi-granularity information.

[0084] Based on the global causal graph, the parameters of the directional mask graph neural network, the cross-layer information fusion mechanism, and the mapping relationship between the fine-grained topic layer and the abstract topic layer, the causal topic model is integrated to form the causal topic model.

[0085] In one possible implementation, the model training module is specifically used for:

[0086] Load a pre-defined domain standard terminology library, which includes standard conceptual entities within the domain;

[0087] The semantic similarity between each topic node in the candidate topic node set and the terms in the standard terminology database is calculated using a text embedding model.

[0088] Topic nodes with semantic similarity higher than a preset threshold are mapped to corresponding standard terms, and multiple topic nodes mapped to the same standard term are merged and deduplicated to obtain the global topic node set.

[0089] In one possible implementation, the model training module is specifically used for:

[0090] For the topic node, identify the set of parent nodes of the topic node from the global causal graph;

[0091] The input vector is obtained by concatenating the representation vectors of all parent nodes in the set of parent nodes along the feature dimension.

[0092] The input vector is input into the multilayer perceptron network corresponding to the topic node, and after nonlinear transformation, exogenous noise is superimposed to output the representation vector of the topic node; the multilayer perceptron network corresponds one-to-one with the topic in the global causal graph.

[0093] In one possible implementation, the process of constructing and applying the directional mask matrix includes:

[0094] Construct the directional mask matrix with the same dimension as the adjacency matrix. If there is a directed edge from node j to node i in the global causal graph, set the corresponding position (i,j) in the mask matrix to 1; otherwise, set it to 0.

[0095] When the graph neural network calculates the attention weights, the attention score corresponding to the position with a value of 0 in the directional mask matrix is ​​forcibly set to negative infinity or zero, so that when aggregating the information of the parent node, the weights of non-parent nodes are masked, and the information propagation flows from the parent node to the child node along the causal direction.

[0096] In one possible implementation, the preprocessing module is specifically used for:

[0097] The summary and title of the target text are merged into a unified text unit to obtain the merged target text;

[0098] The merged target text is cleaned by removing typesetting and citation marks, and the capitalization of academic proper nouns is standardized.

[0099] In one possible implementation, the candidate causal relationship pair includes the causal pair and the confidence level corresponding to the causal pair; the causal pair includes a cause topic and an effect topic;

[0100] The model training module is specifically used for:

[0101] The causal pairs are filtered based on the confidence level, and causal pairs with a confidence level greater than the confidence threshold are retained.

[0102] Calculate the frequency of occurrence of multiple causal pairs obtained from the screening and perform weight calculations to construct a candidate edge set;

[0103] Construct an initial adjacency matrix based on the candidate edge set;

[0104] The initial adjacency matrix is ​​optimized based on the NOTEARS algorithm, and the global causal graph is generated through differentiable acyclic constraints.

[0105] In one possible implementation, the model training module is further used for:

[0106] Based on Pearl's Do-calculus theory, an intervention operation is performed on the target topic node, fixing the value of the target topic node to a preset intervention value, and severing the causal connection edges between the target topic node and all parent nodes in the global causal graph, while keeping the rest of the causal structure unchanged.

[0107] Based on the topological sorting of the global causal graph, the representation vectors of downstream descendant topic nodes affected by the intervention of the target topic node are recalculated to obtain the counterfactual representation vectors;

[0108] Input the counterfactual representation vector and Gaussian random noise into the generator to obtain the counterfactual text; input the real text or the generated counterfactual text into the discriminator to obtain the text authenticity score;

[0109] The scores of the real text and the counterfactual text are calculated separately, and the difference between the scores of the real text and the generated text is used as the Wasserstein distance estimate. Based on the linear interpolation samples of the real text and the counterfactual text, a gradient penalty term is calculated. The Wasserstein distance estimate is added to the gradient penalty term to obtain the total loss of the discriminator.

[0110] An optimizer is used to update the network parameters of the discriminator through backpropagation based on the total loss of the discriminator;

[0111] Calculate the adversarial loss of the discriminator; calculate the semantic similarity between the counterfactual text and the real text using the BERT model to obtain the semantic consistency constraint term; add the adversarial loss to the semantic consistency constraint term to obtain the generator's total loss;

[0112] An optimizer is used to update the generator's network parameters through backpropagation based on the generator's total loss.

[0113] In one possible implementation, the model training module is further used for:

[0114] For the global causal graph, the adjacency matrix of the global causal graph is updated by augmented Lagrange optimization based on the structural scoring loss function and the acyclicity constraint function.

[0115] For the global causal graph and the directional mask graph neural network, the adjacency matrix of the global causal graph is fixed, and the parameters of the nonlinear causal generation function and the directional mask graph neural network are jointly optimized based on the reconstruction loss function;

[0116] With the global causal graph fixed, the parameters of the generator and discriminator are optimized using an adversarial training strategy.

[0117] Based on the global joint loss function, the parameters of each part in the causal topic model are adjusted.

[0118] In one possible implementation, the device further includes a reverse reasoning module, the reverse reasoning module being used for:

[0119] The topic nodes and their corresponding topic representation vectors in the target text are used as the baseline vector for counterfactual reasoning.

[0120] The baseline vector is adjusted according to the intervention description; if the intervention description is to delete the target topic node, the baseline vector of the target topic node is set to zero; if the intervention description is to enhance the target topic node, the baseline vector of the target topic node is multiplied by a coefficient greater than 1; if the intervention description is to replace the target topic node, the topic node representation vector of the target topic node sampled from other documents is used as the replacement vector.

[0121] According to the topological order of the global causal graph, the topic representation vectors of the downstream topic nodes affected by the intervention are recalculated, while the baseline vectors of the unaffected topics remain unchanged, resulting in a set of counterfactual topic vectors.

[0122] Input the set of counterfactual topic vectors into the generator, select zero noise to generate counterfactual text; calculate the change in the representation vector of each topic node before and after the intervention, identify topic nodes whose representation vector change is greater than a preset value and mark the degree of representation vector change;

[0123] Text alignment techniques are used to display the differences between the target document and the counterfactual text in the form of highlights or marks;

[0124] Generate a natural language causal explanation; the natural language causal explanation is used to explain the mechanism by which the intervention of the target topic leads to changes in the text content.

[0125] In one possible implementation, the device further includes an intervention module, the intervention module being used for:

[0126] Obtain the specified starting topic node, and from the pre-trained global causal graph, filter all descendant topic nodes that are rooted at the starting topic node and reachable by directed paths, as well as directed connection edges between topic nodes, to form a causal subgraph;

[0127] Perform a topological sort on the topic nodes in the causal subgraph to generate an ordered list of descendant topic nodes;

[0128] Using the starting topic node as the root node, add descendant topic nodes layer by layer according to the topological sorting in the ordered list, connect each descendant topic node to the parent node pointing to the descendant topic node in the causal subgraph, and mark the corresponding causal strength score on the connection edge;

[0129] Calculate the influence breadth of the starting topic node, and count the number of topic nodes that directly influence the topic node, the number of topic nodes that indirectly influence the topic node, and the total number of topic nodes that influence the topic node.

[0130] Identify intermediate topic nodes whose in-degree and out-degree are both greater than preset values; the intermediate topic nodes are topic nodes that connect multiple causal paths;

[0131] Determine the longest causal chain from the starting topic node to the leaf node, record the path sequence and path length, and generate a visualization chart.

[0132] Thirdly, embodiments of this application disclose a control device, including a processor and a memory, wherein the memory is used to store programs, instructions or code, and the processor is used to execute the programs, instructions or code in the memory to perform the text analysis method based on causal relationships and multi-layered topic understanding as described in any of the first aspects.

[0133] Fourthly, embodiments of this application disclose a computer-readable storage medium, characterized in that it stores a computer program, which is loaded by a processor to execute the text analysis method based on causal relationships and multi-layered topic understanding as described in any of the first aspects.

[0134] This application provides a text analysis method and device based on causal relationships and multi-layer topic understanding. The method first receives the target document to be analyzed and preprocesses it to obtain standardized target text. Then, it inputs the target text into a causal topic model that includes a pre-trained global causal graph, a directional mask graph neural network, a cross-layer information fusion mechanism, and a mapping relationship between fine-grained and abstract topic layers. Based on the global causal graph, topic nodes are identified. The parent node set is matched and causal information is aggregated through the directional mask graph neural network to obtain a target topic representation vector. Then, the vector is mapped to the corresponding fine-grained and abstract topics through a two-layer topic mapping relationship. Global context information is transmitted through the cross-layer information fusion mechanism to obtain the final target topic representation that integrates multi-granular information. Finally, based on the final target topic representation and the global causal graph, the multi-granular topic structure of the target document and the directed causal inference results between topics are output.

[0135] This technical solution ensures the standardization of the target text through standardized preprocessing, laying the foundation for subsequent analysis. Utilizing a pre-trained global causal graph and directional masked graph neural network, it accurately aggregates causal information from parent nodes, effectively capturing directed causal relationships between topics and avoiding interference from irrelevant information. Through a two-layer mapping of fine-grained and abstract topics and cross-layer information fusion, it achieves multi-granular topic understanding, preserving specific topic details while providing a macro-level topic perspective. The final output multi-granular topic structure and directed causal inference results give the text analysis results both hierarchy and logic, significantly improving the depth of text topic mining and the accuracy of causal relationship revelation, providing users with a more comprehensive and reliable basis for text understanding. Attached Figure Description

[0136] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0137] Figure 1 A flowchart illustrating a text analysis method based on causal relationships and multi-layered topic understanding, provided for embodiments of this application;

[0138] Figure 2 A flowchart illustrating the training process of a causal topic model provided in this application embodiment;

[0139] Figure 3 This is a schematic diagram of the structure of a text analysis device based on causal relationships and multi-layered topic understanding, provided for an embodiment of this application. Detailed Implementation

[0140] As mentioned earlier, existing topic modeling and causal discovery techniques can be mainly divided into three implementation paths: The first is traditional topic models, represented by latent Dirichlet assignment and neural topic models, which mine frequently co-occurring topic concepts in text through probabilistic generation or neural network methods. The core goal is to fit the distribution pattern of words to achieve topic recognition. The second is supervised causal topic models, such as causal neural topic models, which model causal dependencies between topics by introducing manually labeled topic tags or causal priors. The third is a hybrid method based on large language models or graph neural networks, which uses the semantic understanding capabilities of large language models to extract candidate causal relationship pairs, or uses graph neural networks to process word co-occurrence graphs to improve the coherence of topic representation. Some methods attempt to combine the two to achieve joint mining of topics and causal relationships.

[0141] However, existing technologies face numerous intractable technical problems. First, traditional topic models can only capture statistical co-occurrence relationships between topics, failing to distinguish between causal dependencies and simple associations. Furthermore, they ignore the inherent hierarchical structure of topics, resulting in insufficient interpretability of the output and failing to meet the demands for logical rigor in specialized fields. Second, supervised causal topic models heavily rely on manually labeled data. In fields such as medicine and social sciences, the scale of text data is enormous, and labeling costs are extremely high. Emerging research directions even lack mature labeling systems, limiting the practical application of these models. Third, large language models, when extracting causal relationships independently, suffer from inconsistent conceptual expressions and disordered extraction results, failing to automatically integrate them into a globally consistent causal structure, making them unsuitable for direct use in structured modeling. Fourth, existing methods combining graph neural networks are not deeply integrated with causal reasoning. Their bidirectional information propagation mechanism violates the unidirectional nature of causal relationships, potentially leading to confusion in causal directions and an inability to correctly model true causal logic. These problems make it difficult for existing technologies to efficiently and reliably extract topic systems with both hierarchical organization and causal relationships from unstructured text, limiting their application value in specialized fields.

[0142] To address this technical problem, embodiments of this application provide a text analysis method and apparatus based on causal relationships and multi-layered topic understanding. The method first receives the target document to be analyzed and preprocesses it to obtain standardized target text. Then, it inputs this text into a causal topic model that includes a pre-trained global causal graph, a directional mask graph neural network, a cross-layer information fusion mechanism, and mapping relationships between fine-grained and abstract topic layers. Based on the global causal graph, topic nodes are identified; the directional mask graph neural network matches the set of parent nodes and aggregates causal information to obtain a target topic representation vector. This vector is then mapped to corresponding fine-grained and abstract topics using a two-layer topic mapping relationship. Global context information is transmitted through the cross-layer information fusion mechanism to obtain a final target topic representation that integrates multi-granularity information. Finally, based on the final target topic representation and the global causal graph, the multi-granularity topic structure of the target document and the directed causal inference results between topics are output.

[0143] This technical solution ensures the standardization of the target text through standardized preprocessing, laying the foundation for subsequent analysis. Utilizing a pre-trained global causal graph and directional masked graph neural network, it accurately aggregates causal information from parent nodes, effectively capturing directed causal relationships between topics and avoiding interference from irrelevant information. Through a two-layer mapping of fine-grained and abstract topics and cross-layer information fusion, it achieves multi-granular topic understanding, preserving specific topic details while providing a macro-level topic perspective. The final output multi-granular topic structure and directed causal inference results give the text analysis results both hierarchy and logic, significantly improving the depth of text topic mining and the accuracy of causal relationship revelation, providing users with a more comprehensive and reliable basis for text understanding.

[0144] This method can build a full-scenario application system relying on servers, edge computing devices, and terminal intelligent devices. Deploying a complete model in a hospital server cluster integrates massive amounts of medical literature, clinical guidelines, and anonymized medical record data. Model training is accelerated using GPUs, providing clinicians with personalized treatment recommendations, causal relationship queries, and counterfactual hypothesis verification for scenarios such as lung cancer targeted therapy, assisting in rapid diagnosis and treatment decisions. On workstations in research institutions, the model can be used to mine topic evolution paths and causal mechanisms in academic literature, supporting research on disease mechanisms and drug development. Simultaneously, the model can be lightweightly deployed on mobile terminals or portable medical devices, achieving localized inference through edge computing. This allows doctors to quickly query key information such as topic associations and causal paths in outpatient clinics and ward rounds, and also provides practitioners in policy analysis, financial research, and other fields with anytime, anywhere text causal analysis tools, significantly improving work efficiency and decision-making accuracy.

[0145] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present application.

[0146] See Figure 1 , Figure 1 This is a flowchart illustrating a text analysis method based on causal relationships and multi-layered topic understanding, provided as an embodiment of this application. The execution entity of this method can be a server, a desktop computer, or other electronic device capable of computation. The following description uses a server as the execution entity, and the method includes:

[0147] S101: The server receives the target document to be analyzed, preprocesses the target document, and obtains standardized target text.

[0148] Target documents refer to the original text uploaded by users to the server that requires topic analysis and causal relationship mining. They are typically unstructured texts such as academic literature, clinical medical records, and policy documents. Target documents include a title and an abstract.

[0149] Preprocessing refers to the standardized processing operations performed by the server on the original target document. The core purpose is to remove noise and unify the format, so as to provide high-quality input for subsequent model analysis.

[0150] The standardized target text preprocessing results in a uniformly formatted and semantically clear text that retains core information while eliminating formatting interference. It can be directly input into a causal topic model for further processing.

[0151] The server receives target documents uploaded by users via a network interface. Supported document formats include common text formats such as txt, docx, and pdf. In practical applications, target documents to be analyzed (such as academic literature and clinical medical records) typically contain a title and an abstract. The title concisely summarizes the core theme, while the abstract completes the semantics. However, separating these two parts can lead to incomplete topic identification. Furthermore, inconsistencies in formatting, citation, and academic terminology can interfere with the accuracy of subsequent topic extraction and causal relationship inference. Therefore, this application embodiment requires preprocessing to address the structural characteristics and data quality issues of the target documents, ensuring that the input text to the model is standardized and of high quality.

[0152] In one possible implementation, the target document to be analyzed is received, and preprocessing of the target document is performed, including:

[0153] The summary and title of the target text are merged into a unified text unit to obtain the merged target text;

[0154] The merged target text is cleaned, typesetting and citation marks are removed, and the capitalization of academic proper nouns is standardized.

[0155] First, the title and abstract of the target document are merged into a unified text unit in the format of "title + [SEP] + abstract". This preserves the thematic focus of the title and integrates the semantic integrity of the abstract, providing a complete semantic foundation for subsequent analysis.

[0156] Subsequently, the merged text was cleaned by using regular expressions to remove format noise that does not contribute semantics, such as LaTeX typesetting marks, mathematical formula symbols, and citation marks (e.g., "[1]" "(Smith et al.,2020)"). At the same time, special characters that are meaningful to technical terms, such as hyphens and underscores, were retained. General words were normalized to lowercase, while proper nouns and abbreviations such as BERT and COVID-19 were preserved in their original uppercase and lowercase forms. This achieved a unified expression of academic proper nouns, resulting in a standardized target text with a clear and consistent format, which laid the data foundation for the accurate analysis of subsequent causal topic models.

[0157] Optionally, the server can call a pre-trained language model optimized for academic text (such as SciBERT or PubMedBERT) to generate semantic embeddings on the cleaned text, extract the output vector of the [CLS] tag as the semantic representation of the document, and provide auxiliary information for subsequent topic recognition.

[0158] This application's embodiments employ a dedicated preprocessing strategy for unstructured text, effectively removing formatting noise and redundant information, avoiding interference from LaTeX tags and citation tags on subsequent topic extraction and causal relationship identification, and ensuring the purity of the input data. The structured merging of titles and abstracts, while utilizing the core topic focus of the title and the complete semantic context of the abstract, significantly improves the recall and accuracy of subsequent topic identification compared to using titles or abstracts alone. Selective case normalization and number standardization, while unifying the text format, preserve the standard expressions of professional terminology, ensuring the consistency of topic concepts and laying the foundation for subsequent global topic node aggregation.

[0159] S102: The server inputs the standardized target text into the pre-trained causal topic model.

[0160] Causal topic models refer to end-to-end models that, after data preprocessing, topic and causal relationship extraction, model training, and joint optimization, possess the capabilities of topic recognition, causal relationship inference, and multi-granularity topic fusion. Causal topic models include pre-trained global causal graphs, directional masked graph neural networks, cross-layer information fusion mechanisms, and mapping relationships between fine-grained topic layers and abstract topic layers.

[0161] The global causal graph is a directed acyclic graph (DAG) learned during the pre-training phase. It includes all topic nodes in the text and the directed causal dependencies between them, clearly defining the logical connection between causal topics and outcome topics.

[0162] The server first loads the pre-trained causal topic model and the parameters of all core components, including the adjacency matrix of the global causal graph, the weight parameters of the directional mask graph neural network, the fusion coefficients of the cross-layer information fusion mechanism, and the mapping table between fine-grained and abstract topics. During loading, the server verifies the integrity and consistency of the model parameters to ensure that all components can work together.

[0163] Subsequently, the server inputs the standardized target text into the causal topic model. The causal topic model first performs semantic encoding on the standardized target text, transforming it into a structured semantic feature vector through a pre-trained text encoding module. This vector serves as the foundational input for subsequent topic recognition and causal information extraction. During semantic encoding, the model retains the core semantic information of the text while filtering out redundant details, ensuring the accuracy and effectiveness of the data input to subsequent components.

[0164] The encoded semantic feature vectors are synchronously input into the various core components of the model. The global causal graph provides the causal topology of the topic nodes. The directional mask graph neural network is prepared to propagate information based on this topology. The cross-layer information fusion mechanism and the two-layer topic mapping relationship prepare for subsequent multi-granularity topic fusion. Each component starts the processing flow collaboratively based on the pre-trained parameters.

[0165] This application embodiment avoids the waste of computational resources caused by repeated training by loading a pre-trained model and parameters, significantly improving the efficiency of text analysis and enabling rapid initiation of subsequent topic identification and causal inference processes. Furthermore, the global causal graph provides a structured foundation for subsequent mining of causal relationships between topics, ensuring that causal inference has a clear topological basis and avoiding aimless association analysis. In addition, the synergy of directional masked graph neural networks, cross-layer information fusion mechanisms, and two-layer topic mapping relationships lays the technical foundation for accurate extraction of topic representations and multi-granularity topic fusion, ensuring that subsequent steps can efficiently output hierarchical topic structures and directed causal inference results. Finally, this application embodiment transforms standardized text into feature vectors that the model can process through semantic encoding, realizing the transformation of unstructured text into structured data and providing a unified data format for the collaborative processing of various components.

[0166] S103: The server identifies topic nodes in the standardized target text based on the global causal graph, and matches the set of parent nodes of each topic node in the global causal graph through a directional mask graph neural network, and aggregates the causal information of the parent nodes to obtain the target topic representation vector.

[0167] For each topic node, the set of all predecessor topic nodes pointing to that node in the global causal graph is the set of parent nodes. Predecessor nodes are topics that have a direct causal influence on the current node.

[0168] The server first invokes a topic matching algorithm to compare the semantic features of the standardized target text with the features of all topic nodes in the pre-trained global causal graph, filtering out topic nodes with similarity exceeding a preset threshold, thus completing topic node identification. For example, in a medical literature analysis scenario, if the text includes terms such as "EGFR T790M mutation" or "osimertinib," it will automatically match the corresponding topic nodes with the same names in the causal graph.

[0169] Subsequently, based on the adjacency matrix of the global causal graph, the server traverses each identified topic node, extracts the indices of all predecessor nodes pointing to that node in the adjacency matrix, and thus determines the set of parent nodes for each topic node. Simultaneously, it loads the parameters of a pre-trained directional mask graph neural network, which includes learned causal direction constraint rules to ensure that information propagation is only allowed to flow from parent nodes to child nodes.

[0170] During the causal information aggregation phase, the server calculates the attention weight of each parent node to the current topic node using a directional mask graph neural network. The weight is determined by the strength of the causal relationship and semantic relevance between the parent and current nodes. Subsequently, the feature information of all parent nodes is weighted and summed according to the attention weights, and combined with the initial features of the current topic node itself to generate the target topic representation vector. Throughout the aggregation process, the directional mask filters out information interference from child nodes and nodes without causal relationships, ensuring that the aggregation result only reflects the upstream causal influence.

[0171] This application's embodiments achieve precise correspondence between standardized target text and topic nodes in the global causal graph through a topic matching algorithm, ensuring the relevance and accuracy of subsequent causal analysis. Automatic extraction of the parent node set provides a structured basis for capturing direct causal relationships between topics, avoiding interference from irrelevant nodes. The directional mask graph neural network aggregates information according to the causal direction, preserving key causal information from parent nodes while eliminating logical confusion caused by reverse information propagation. This allows the generated target topic representation vector to accurately characterize the semantic features and causal dependencies of the topics, laying a solid foundation for subsequent multi-granularity topic fusion and causal inference output, significantly improving the logical rigor and reliability of the entire text analysis process.

[0172] S104: Based on the mapping relationship between the fine-grained topic layer and the abstract topic layer, the server maps the target topic representation vector to the corresponding fine-grained topic and abstract topic respectively, calls the cross-layer information fusion mechanism, and passes the global context information of the abstract topic to the corresponding fine-grained topic to obtain the final target topic representation that integrates multi-granular information.

[0173] The server first loads a pre-trained mapping table between fine-grained topic layers and abstract topic layers. This mapping table explicitly records the abstract topic category corresponding to each fine-grained topic. Then, the server associates the target topic representation vector with the corresponding fine-grained topic label and abstract topic label according to the mapping table, completing the initial matching of the two-level topics.

[0174] Next, the server invokes the cross-layer information fusion mechanism to initiate a top-down information transmission process. First, it extracts the global context information of the abstract topic, including its position in the causal graph, its causal relationships with other abstract topics, and the features of the covered fine-grained topic set. This macro-level information is encoded into an abstract layer feature vector. Then, through a gated fusion unit, the fusion ratio between the abstract layer feature vector and the corresponding fine-grained topic representation vector is dynamically adjusted. For feature dimensions in fine-grained topics that are strongly correlated with the core logic of the abstract topic, the weight of the abstract layer information is enhanced. For the unique semantic details of fine-grained topics, their original feature weights are preserved to prevent macro-level information from obscuring specific differences.

[0175] During the fusion process, the server also references the topology of the global causal graph to ensure that the information conveyed by the abstract topic conforms to causal semantic logic. For example, when the global information of the abstract topic "targeted therapy" is passed to the fine-grained topic "osimertinib treatment regimen," the causal features related to gene mutations and targeted drug responses are emphasized, making the fused representation more consistent with domain knowledge logic. Finally, through linear transformations and nonlinear activations, a final target topic representation that combines detailed accuracy with global relevance is generated.

[0176] This application's embodiments achieve precise association between the target topic representation vector and the two-level topic through pre-trained mapping relationships, laying a clear structural foundation for multi-granularity information fusion. A cross-layer information fusion mechanism cleverly injects macro-level information such as the global context and causal relationships of abstract topics into fine-grained topic representations, compensating for the lack of a global perspective in single-granularity topics. The dynamic adjustment strategy of the gating fusion unit, while preserving the specific semantic details of fine-grained topics, strengthens the logical connections between topics, avoiding information redundancy or loss of details. The final generated target topic representation possesses both the accuracy of fine-grained topics and the global perspective of abstract topics, providing high-quality data support for subsequent output of multi-granularity topic structures and directed causal inference results, significantly improving the completeness and logical rigor of the text analysis results.

[0177] S105: Based on the final target topic representation and global causal graph, the server outputs the multi-granularity topic structure of the target document and the directed causal inference results between topics.

[0178] The server first calculates the activation strength of each topic node based on the final target topic representation, and then sorts and filters out the core fine-grained topics and their corresponding abstract topics in the target document according to the activation strength. Subsequently, based on the mapping relationship between the pre-trained fine-grained topic layer and the abstract topic layer, the core fine-grained topics are classified under the corresponding abstract topics, constructing a hierarchical structure of abstract topics and fine-grained topics, forming the basic framework of the multi-granularity topic structure.

[0179] Next, the server accesses the adjacency matrix and parent node set information of the global causal graph. For the selected core topics, it traverses the directed edges in the causal graph to identify the direct causal links for each topic. For topics with indirect causal relationships, a graph search algorithm is used to trace the complete causal path, recording all intermediate topic nodes in the path and calculating the weight product of each causal edge as the overall causal strength of the path. Simultaneously, following the logic of cause topics preceding effect topics, directed causal chains are formed to clarify the causal direction and influence strength between each topic.

[0180] Finally, the server outputs the multi-granularity topic structure and the directed causal inference results in a structured format. The multi-granularity topic structure is presented in the form of a hierarchical list or tree diagram, annotating the activation intensity of each topic; the directed causal inference results are presented in the form of a causal chain list, annotating the type, causal direction, and intensity score of each causal relationship, while also supporting visualization to intuitively present the causal network between topics.

[0181] This application's embodiments, based on a target final topic representation that integrates multi-granularity information, ensure the accuracy of core topic selection and the rationality of the multi-granularity topic structure. It provides users with a macro-level abstract topic perspective while retaining specific fine-grained topic details, meeting the topic understanding needs in different scenarios. By combining a global causal graph and graph search algorithms, it accurately mines the direct and indirect causal relationships between topics, clarifies the causal direction and strength, and elevates statistical associations to interpretable causal dependencies, overcoming the limitation of traditional topic models that can only identify topic co-occurrence. The structured and visualized output format makes the multi-granularity topic organization and causal inference results intuitive and easy to understand, significantly reducing the cost for users to understand the core logic and causal mechanisms of text, and providing reliable structured knowledge support for decision-making, scientific research, and other scenarios.

[0182] To further explore the causal relationships between topics in the target document and meet users' analytical needs for hypothetical scenarios, this application's embodiments, based on the output of multi-granularity topic structures and directed causal inference results, add counterfactual reasoning and hypothesis analysis processes. By performing targeted interventions on specified topic nodes, counterfactual text that conforms to causal logic is generated, and topic changes are quantified, text differences are visualized, and causal mechanisms are explained. This transforms abstract causal relationships into intuitive and perceptible analytical results, providing strong support for decision verification and scenario simulation.

[0183] Specifically, in one possible implementation, the method further includes:

[0184] Use all topic nodes in the target text and the topic representation vectors corresponding to all topic nodes as the baseline vector for counterfactual reasoning;

[0185] The baseline vector is adjusted according to the intervention description; some pre-descriptions are to delete the target topic node and set the baseline vector of the target topic node to zero; some pre-descriptions are to enhance the target topic node and multiply the baseline vector of the target topic node by a coefficient greater than 1; some pre-descriptions are to replace the target topic node and use the topic node representation vector of the target topic node sampled from other documents as the replacement vector.

[0186] Following the topological order of the global causal graph, the topic representation vectors of downstream topic nodes affected by the intervention are recalculated, while the baseline vectors of unaffected topics remain unchanged, resulting in a set of counterfactual topic vectors.

[0187] Input the set of counterfactual topic vectors into the generator, select zero noise to generate counterfactual text; calculate the change in representation vector of each topic node before and after the intervention, identify topic nodes whose representation vector change is greater than the preset value and mark the degree of representation vector change;

[0188] Text alignment techniques are used to highlight or mark up the differences between the target document and the counterfactual text.

[0189] Generate natural language causal explanations; natural language causal explanations are used to explain the mechanisms by which interventions in a target topic lead to changes in text content.

[0190] First, all topic nodes and their corresponding topic representation vectors in the target text are used as the baseline vectors for counterfactual reasoning. Then, the baseline vectors are adjusted based on the user intervention description: if the target topic node is deleted, its baseline vector is set to zero; if it is enhanced, the baseline vector is multiplied by a coefficient greater than 1; if it is replaced, the topic representation vector sampled from other documents is used as the replacement vector. Next, following the topological order of the global causal graph, the representation vectors of downstream topic nodes affected by the intervention are recalculated, while the baseline vectors of unaffected topics remain unchanged, resulting in a set of counterfactual topic vectors. This set is input into a generator, and zero-noise deterministic counterfactual text is generated. The change in representation vectors of each topic node before and after the intervention is then calculated, identifying topic nodes with changes greater than a preset value and marking the degree of change. Simultaneously, text alignment technology is used to highlight or mark the differences between the target document and the counterfactual text. Finally, a natural language causal explanation is generated, clarifying the internal mechanism by which the target topic intervention leads to changes in text content, thus fully realizing the entire counterfactual reasoning process from intervention setting to result analysis.

[0191] To help users fully grasp the propagation path and scope of influence of a specified topic within the global causal relationship, and to compensate for the lack of a global perspective in single-topic analysis, this application's embodiments add a topic evolution path tracking function to the core reasoning process. By extracting a dedicated causal subgraph, topologically sorting, constructing a propagation structure, and performing multi-dimensional impact analysis, the causal transmission logic of the initial topic is clearly presented, providing an intuitive and structured basis for scenarios such as event impact assessment and risk prevention.

[0192] Specifically, in one possible implementation, the method further includes:

[0193] Obtain the specified starting topic node, and from the pre-trained global causal graph, filter all descendant topic nodes that are rooted at the starting topic node and reachable by a directed path, as well as the directed connection edges between topic nodes, to form a causal subgraph;

[0194] Perform a topological sort on the topic nodes in the causal subgraph to generate an ordered list of descendant topic nodes;

[0195] Starting with the initial topic node as the root node, add descendant topic nodes layer by layer according to the topological sorting in the ordered list. Connect each descendant topic node to the parent node pointing to the descendant topic node in the causal subgraph, and mark the corresponding causal strength score on the connection edge.

[0196] Calculate the breadth of influence of the starting topic node, and count the number of topic nodes that directly affect the topic node, the number of topic nodes that indirectly affect the topic node, and the total number of topic nodes that affect the topic node.

[0197] Identify intermediate topic nodes whose in-degree and out-degree are both greater than preset values; intermediate topic nodes are topic nodes that connect multiple causal paths;

[0198] Determine the longest causal chain from the starting topic node to the leaf node, record the path sequence and path length, and generate a visual chart.

[0199] First, the user-specified starting topic node is obtained. From the pre-trained global causal graph, all descendant topic nodes rooted at the starting topic and reachable by directed paths, along with their corresponding directed edges, are selected to form a dedicated causal subgraph. Next, a topological sort is performed on the topic nodes in the causal subgraph, generating an ordered list of descendant topic nodes, ensuring that parent nodes are sorted before child nodes. Then, using the starting topic node as the root node, descendant topic nodes are added layer by layer according to the topological sort. Each descendant topic node is connected to its parent node in the causal subgraph, and a causal strength score is marked on the connection edge. Afterward, the influence breadth of the starting topic node is calculated, and the number of topic nodes with direct, indirect, and total influence is counted. Simultaneously, intermediate topic nodes (i.e., key nodes connecting multiple causal paths) with in-degree and out-degree both greater than preset values ​​are identified. Finally, the longest causal chain from the starting topic node to the leaf node is determined, the path sequence and path length are recorded, and a visualization chart is generated that includes node size mapping activation strength, edge thickness mapping causal strength, and color distinguishing abstract topic categories, fully presenting the causal propagation mechanism and influence scope of the starting topic.

[0200] This application also provides a training process for a causal topic model. By defining a global loss function, implementing a multi-stage training strategy, and configuring an optimizer, the collaborative optimization of each module is achieved, ultimately resulting in a pre-trained model with stable performance and reliable inference.

[0201] like Figure 2 As shown, Figure 2 This document provides a flowchart for training a causal topic model, as illustrated in an embodiment of this application. The training process for the causal topic model is as follows:

[0202] S201: The server acquires the text corpus and extracts the candidate set of topic nodes and candidate causal relationship pairs from the text corpus based on the large language model.

[0203] The server first acquires a large-scale text corpus through a data interface. The corpus supports common formats such as txt, docx, and pdf, covering core texts in the target field (e.g., medicine, policy, finance). For academic literature corpora, titles and abstracts are extracted first due to their high information density and strong thematic focus. For other types of text, core content fragments are extracted to ensure the relevance and effectiveness of the corpus.

[0204] Subsequently, based on the prompting engineering, two types of dedicated prompt templates were constructed, one for topic node extraction and the other for candidate causal relationship extraction. The topic extraction template sets the large language model as a domain expert, requiring it to extract multiple core academic terms or research topics from a single text and rank them by importance. The causal relationship extraction template specifies the causal judgment criteria, requiring the model to output causal pairs in the format of "cause-relationship-effect," along with confidence levels and supporting evidence. Preprocessed single texts were then populated into the templates, and the large language model API was called. A temperature of 0.1-0.3 was set to control output randomness. The returned results were then subjected to structured parsing, and the extraction results from all texts were aggregated to form a candidate set of topic nodes and candidate causal relationship pairs.

[0205] This application's embodiments provide ample data support for model training through large-scale text corpora, ensuring that the extracted topics and causal relationships are domain-representative. Leveraging the strong semantic understanding capabilities of large language models, it overcomes the limitations of traditional statistical methods that rely on word co-occurrence, accurately identifying core topics and causal clues implicit in the text. Dedicated prompt templates and structured output requirements guarantee the consistency and standardization of the extraction results, laying a high-quality foundation for subsequent standardization processing and causal graph construction, while significantly reducing the time cost of manual extraction and improving the efficiency of model training.

[0206] Text corpora serve as the foundational data for model training, and their quality directly determines the accuracy of subsequent topic extraction and causal relationship identification. While academic literature titles and abstracts possess high information density, they commonly suffer from formatting noise such as LaTeX typesetting marks and citation markers. Furthermore, academic terminology exhibits inconsistencies in capitalization and the mixing of abbreviations and full names. Existing general preprocessing techniques struggle to adapt to these unique characteristics, easily leading to biases in subsequent analysis. This application's embodiments provide a preprocessing method tailored to the format and semantic features of academic literature. Through a standardized process, interference is eliminated, providing high-quality input for model training.

[0207] Specifically, a collection of academic documents is obtained, each consisting of a title and an abstract. The collection draws from various academic texts, including peer-reviewed journal articles and conference papers. First, the titles and abstracts are merged using the format "title + [SEP] + abstract," preserving the thematic focus of the title and the semantic integrity of the abstract. Next, text cleaning and standardization are performed. Regular expressions are used to remove formatting noise such as LaTeX tags and citation marks. A dictionary of academic terminology is maintained, common terms are normalized to lowercase, proper nouns and abbreviations retain their original capitalization, and pure numeric sequences (excluding year and version numbers) are replaced with placeholders. <num>The cleaned text is then processed and consecutive whitespace characters are standardized. Finally, semantic embeddings are optionally generated. The cleaned text is input into a pre-trained model such as SciBERT, optimized for academic scenarios, and the output vectors marked with [CLS] are extracted as the document's semantic representation. This entire process effectively eliminates formatting interference and standardizes conceptual expressions while preserving complete academic information, laying a reliable foundation for subsequent large language models to extract topic nodes and candidate causal pairs.

[0208] S202: The server performs standardization processing on the candidate set of topic nodes to obtain the global set of topic nodes.

[0209] The server first selects an authoritative standard terminology database as a reference for concept standardization based on the domain of the text corpus. For each term in the candidate set of topic nodes, concept matching and unification operations are performed sequentially. Precise matching is prioritized for each term; if a term has a completely identical entry in the standard terminology database, it is directly mapped to the standard term. If no precise match exists, the string similarity and semantic similarity between the term and candidate entries in the standard terminology database are calculated, and candidate entries with similarity exceeding a preset threshold are filtered out.

[0210] For terms with multiple candidate entries or ambiguities, further confirmation is achieved through context disambiguation. The average embedding of the term in the surrounding words in the original text is extracted as a context vector, which is compared with the typical context vectors of each candidate standard term. The standard term with the highest semantic similarity is selected as the final mapping result. After standardizing all terms, deduplication is performed on the processed topic nodes, and topic nodes with the same concept are merged to form a global topic node set containing all standardized topic concepts.

[0211] This application's embodiments effectively solve the problem of inconsistent expressions of the same concept in the candidate set of topic nodes (such as abbreviations and full names, synonyms, and different expressions) through standardized processing that combines authoritative domain terminology databases with multi-dimensional similarity matching, ensuring the uniformity and accuracy of topic concepts. The application of a context disambiguation mechanism further improves the accuracy of mapping ambiguous terms and avoids concept confusion. The final global topic node set provides standardized and non-repeating basic nodes for the subsequent construction of the global causal graph, reducing noise interference and laying a solid foundation for accurate inference of causal relationships.

[0212] The candidate set of topic nodes often contains multiple expressions for the same concept. If these are directly used in subsequent causal graph construction, it will lead to topic redundancy and confusion of causal relationships, affecting the accuracy of the model. Existing standardization methods mostly rely on simple string matching, which is difficult to handle scenarios with similar semantics but different expressions. This application provides a precise topic node standardization scheme based on a domain standard terminology library and semantic similarity calculation, achieving concept unification and deduplication, and providing a standardized foundation for the construction of a global topic node set.

[0213] In one possible implementation, the candidate set of topic nodes is standardized to obtain a global set of topic nodes, including:

[0214] Load the pre-defined domain standard terminology library, which includes standard conceptual entities within the domain;

[0215] The semantic similarity between each topic node in the candidate topic node set and the terms in the standard terminology database is calculated using a text embedding model.

[0216] Topic nodes with semantic similarity higher than a preset threshold are mapped to corresponding standard terms, and multiple topic nodes mapped to the same standard term are merged and deduplicated to obtain a global topic node set.

[0217] First, a pre-defined domain-standard terminology library is loaded, containing authoritative and unified standard conceptual entities within the domain. Then, a text embedding model is used to encode each topic node in the candidate topic node set and each term in the standard terminology library, calculating the semantic similarity between each pair. Finally, a preset threshold is set, and topic nodes with semantic similarity higher than the threshold are mapped to their corresponding standard terms. Simultaneously, multiple topic nodes mapped to the same standard term are merged and deduplicated, ultimately resulting in a non-redundant, conceptually unified global set of topic nodes, ensuring the accuracy and standardization of subsequent causal graph construction.

[0218] S203: The server generates a global causal graph based on the NOTEARS algorithm and candidate causal relationships.

[0219] A global causal graph includes global topic nodes and directed causal edges between global topic nodes. Directed causal edges are used to mark the causal direction and causal strength between global topic nodes.

[0220] NOTEARS algorithm is a causal graph construction algorithm that transforms discrete graph structure learning into a continuous optimization problem. It ensures that the generated graph is a directed acyclic graph through a differentiable acyclic constraint function. The core of the algorithm is to solve for the optimal causal structure through matrix exponentiation and augmented Lagrange method.

[0221] The server first loads the global set of topic nodes, the set of candidate causal edges, and the initial adjacency matrix. The initial adjacency matrix is ​​used as the initial value for optimization in the NOTEARS algorithm, and the element values ​​in this matrix correspond to the initial weights of the candidate causal edges. Simultaneously, if a domain knowledge base exists, known causal relationships can be incorporated into the optimization process as prior constraints. A prior knowledge loss is defined to encourage the retention of known valid causal edges and penalize edges that violate domain common sense.

[0222] Subsequently, the optimization process of the NOTEARS algorithm is initiated. The server can define a differentiable acyclicity constraint function, implemented through matrix exponentiation and matrix trace calculation. The constraint function value is greater than 0 when the graph corresponding to the adjacency matrix contains cycles, and 0 when there are no cycles. The acyclicity constraint function can be denoted as:

[0223] ;

[0224] in, For a weighted adjacency matrix, This represents the Hadamard product (element-by-element product). Represents the trace of a matrix. For matrix exponents, This represents the number of nodes.

[0225] matrix The Each element corresponds to a node. Departure process The sum of the path weights that return to itself is taken as the first step. For a directed acyclic graph (DAG), there is no path weight of any length. The ring road, because If a cycle exists, then This constraint function is not only smooth and differentiable, but its gradient also explicitly indicates the direction for eliminating loops, thus allowing it to be solved using gradient-based optimization methods.

[0226] The server then constructs a structure scoring function, including a data fitting term and a sparsity regularization term. The structure scoring function can be expressed as:

[0227] ;

[0228] in, The least squares fitting loss is used. For the first The topic activation vector of each document. Least squares fitting loss is based on the assumption of a linear structural equation model, that is, the activation value of a node should be approximately predicted by a linear combination of its parent nodes, measuring the explanatory power of the causal graph for the observed data.

[0229] in, for Regularization term, This is a sparsity hyperparameter. This term penalizes the number of non-zero elements in the adjacency matrix, prompting the learned causal graph to maintain a sparse structure, avoiding overfitting, and eliminating spurious causal edges that have little impact on the results, thereby improving the interpretability of the model.

[0230] Next, the server employs the augmented Lagrange method to transform the constrained optimization into an unconstrained subproblem for iterative solution. In each iteration, the Lagrange multipliers and penalty coefficients are fixed, and the adjacency matrix is ​​updated using gradient descent. After the update, the elements are projected to the [0,1] interval, and the Lagrange multipliers and penalty coefficients are adaptively adjusted based on the constraint function value until the constraints are satisfied or the maximum number of iterations is reached. The augmented Lagrange objective function can be expressed as:

[0231] ;

[0232] This application employs the Augmented Lagrangian Method to transform the constrained optimization problem into a series of unconstrained subproblems. Among them, These are Lagrange multipliers used to penalize violations of linearity constraints; This is the penalty coefficient, used to control the secondary penalty term. The intensity.

[0233] In the optimization process, first fix and Minimize by gradient descent To update the adjacency matrix Then, based on the current degree of constraint violation... Size, dynamically increases And update This dual-update strategy effectively avoids the numerical instability caused by the simple penalty function method, ensuring that the final solution strictly satisfies... Acyclic constraints.

[0234] After optimization, the adjacency matrix is ​​sparsified, elements with weights less than a preset threshold are set to zero, weakly correlated noise edges are removed, and finally a global causal graph is constructed based on the optimized adjacency matrix, clarifying the parent node set, causal edge direction, and corresponding causal strength score of each topic node.

[0235] This application's embodiments transform the NP-hard discrete causal graph search problem into a continuous optimization problem using the NOTEARS algorithm, significantly reducing computational complexity and enabling efficient solutions even in scenarios with a large number of topic nodes. During optimization, a differentiable acyclic constraint function automatically ensures the directed acyclic property of the global causal graph, avoiding the tedious operations of repeatedly checking and eliminating loops in traditional methods. A structural scoring function, combined with data fitting and sparsity regularization, effectively filters noisy and redundant edges while ensuring consistency between the causal graph and the observed data, improving the interpretability of the causal graph. An optional domain prior knowledge incorporation mechanism further corrects the causal direction, improving the accuracy of causal edge identification in small-sample scenarios. The final generated global causal graph clearly depicts the directional causal dependencies and strengths between topics, providing a reliable structured foundation for subsequent nonlinear causal modeling and causal information propagation steps.

[0236] In practical applications, candidate causal pairs may contain noisy causal pairs with low confidence. Directly using these pairs for causal graph construction can lead to redundant graph structure and distorted causal relationships, affecting the accuracy of subsequent model training. Furthermore, different causal pairs appear at varying frequencies in text corpora; failing to consider this difference can result in unreasonable weight allocation of causal edges, failing to reflect the strength of causal relationships. To address this issue, this application's embodiments construct a candidate edge set through confidence screening and frequency weighting, and then optimize the initial adjacency matrix using the NOTEARS algorithm to generate an accurate and reliable global causal graph.

[0237] In one possible implementation, candidate causal pairs include the causal pair and the confidence level of the causal pair; the causal pair includes a cause topic and an effect topic.

[0238] A global causal graph is generated based on the NOTEARS algorithm and candidate causal relationships, including:

[0239] Causal pairs are filtered based on confidence level, and causal pairs with confidence levels greater than a confidence threshold are retained.

[0240] Calculate the frequency of occurrence of multiple causal pairs obtained from the screening and perform weight calculations to construct a candidate edge set;

[0241] Construct an initial adjacency matrix based on the candidate edge set;

[0242] The initial adjacency matrix is ​​optimized based on the NOTEARS algorithm, and a global causal graph is generated through differentiable acyclic constraints.

[0243] In this embodiment, candidate causal relationship pairs are first screened based on confidence levels. A confidence threshold is set, retaining causal pairs with confidence levels greater than the threshold and filtering out noisy causal relationships with low confidence. Then, the frequency of each filtered causal pair in the text corpus is statistically analyzed. The frequency is normalized and used as the initial weight of the corresponding causal edge, constructing a candidate edge set containing topic nodes, causal directions, and initial weights. Next, an initial adjacency matrix is ​​constructed based on the candidate edge set, with matrix elements corresponding to the initial weights of causal edges; weights between nodes without causal relationships are set to 0. Finally, the initial adjacency matrix is ​​optimized using the NOTEARS algorithm. A differentiable acyclic constraint function in matrix exponential form penalizes the loop structure, ensuring that the generated global causal graph is a directed acyclic graph. Simultaneously, data fitting and sparsity regularization are combined to improve the accuracy and interpretability of the causal graph, ultimately outputting a global causal graph containing global topic nodes, directed causal edges, and causal strength.

[0244] S204: The server constructs a nonlinear causal generation function for each topic node based on the set of parent nodes of each topic node in the global causal graph and calculates the representation vector of each topic node.

[0245] The server first determines the set of parent nodes for each topic node based on the adjacency matrix of the global causal graph, that is, the predecessor nodes that have a direct causal influence on the current node, and initializes the feature vector for each topic node. It can use pre-trained word embedding, contextualized embedding or hybrid initialization methods to balance prior knowledge and adaptive learning capabilities.

[0246] Subsequently, a dedicated nonlinear causal generation function is constructed for each topic node. This function can only use a 2-3 layer fully connected MLP structure. By concatenating the representation vectors of all parent nodes as input, and processing them through ReLU or ELU nonlinear activation functions, the initial representation of the current node is output. The structural causal equation can be expressed as:

[0247] ;

[0248] ;

[0249] in, Represents a node The latent representation vector of i, This refers to the set of parent nodes of the given node in the global cause-effect graph. This embodiment of the application uses a splicing operation... The feature vectors of all parent nodes are merged into a single input vector, which is then fed into the multilayer perceptron dedicated to that node. middle.

[0250] The deep nonlinear activation functions (such as ReLU or ELU) are used to fit the complex nonlinear effects of the parent node on the child node (such as threshold effect, saturation effect, etc.). The independent Gaussian exogenous noise represents the random disturbance of the system by unobserved potential factors. The structural causal model fully defines a structural causal model that supports intervention.

[0251] For a root node without a parent node, its representation consists of initial features and an exogenous noise term. The noise term is sampled from a standard normal distribution to simulate the random influence of unobserved factors. Finally, the representation vectors of all nodes are calculated sequentially according to the topological sorting of the global causal graph, ensuring that the representations of all its parent nodes have been completed when calculating each node, thus guaranteeing the correctness of the causal semantics.

[0252] This application's embodiments, through a nonlinear causal generation function, overcome the limitations of traditional linear causal assumptions and can accurately capture complex causal dependencies prevalent in professional fields. The directional input and topological sorting calculation of the parent node set ensure that the node representation depends only on upstream causal information, conforming to the unidirectionality of causal relationships. The diverse initialization strategies for initial features and the introduction of exogenous noise not only provide a high-quality starting point for the model but also enhance its robustness, laying a precise semantic and causal foundation for subsequent causal information aggregation and multi-granularity modeling.

[0253] Global causal graphs only clarify the causal topological relationships between topic nodes, but do not depict the specific mechanisms by which causal topics influence outcome topics. Traditional linear causal assumptions are also difficult to adapt to the complex nonlinear dependencies in specialized fields. Therefore, this application's embodiments design a dedicated nonlinear causal generation function for each topic node. By splicing parent node information and performing nonlinear transformation using a multilayer perceptron, the causal interaction patterns are accurately captured. At the same time, exogenous noise is introduced to simulate unobserved factors, ensuring the authenticity and robustness of the topic representation vector.

[0254] In one possible implementation, a nonlinear causal generation function is constructed for each topic node, and the representation vector of each topic node is computed, including:

[0255] For a topic node, identify the set of parent nodes of the topic node from the global cause-effect graph;

[0256] The input vector is obtained by concatenating the representation vectors of all parent nodes in the set of parent nodes along the feature dimension.

[0257] The input vector is fed into the multilayer perceptron network corresponding to the topic node. After nonlinear transformation, exogenous noise is superimposed to output the representation vector of the topic node. The multilayer perceptron network corresponds one-to-one with the topic in the global causal graph.

[0258] In this embodiment, for each topic node, all its direct parent nodes are accurately identified from the global causal graph, forming a set of parent nodes for that node. Then, the representation vectors of all parent nodes in the set are concatenated along the feature dimension, integrating all upstream causal information to obtain a unique input vector for that topic node. Finally, a one-to-one corresponding multilayer perceptron network is configured for each topic node. The input vector is fed into this network, processed through 2-3 fully connected layers and ReLU / ELU nonlinear activation functions, and then superimposed with exogenous noise sampled from a standard normal distribution. The final output is a representation vector that characterizes the semantic features of the topic and the nonlinear causal dependencies. The introduction of exogenous noise can simulate the random influence of unobserved factors, while the dedicated design of the multilayer perceptron ensures that the causal generation mechanism of each topic node independently adapts to its own causal relationship characteristics.

[0259] S205: The server introduces a directional mask matrix into the global causal graph, aggregates the parent node information according to the directional mask matrix through the directional mask graph neural network, updates the representation vector of each topic node, and obtains the topic node representation matrix that integrates causal information.

[0260] Directional masking matrices are used to restrict the propagation of information from cause topic nodes to result topic nodes.

[0261] The server first constructs a directional mask matrix based on the adjacency matrix of the global causal graph. It iterates through each topic node; if node j is the parent node of node i (there exists a causal edge j→i), the position (i,j) in the mask matrix is ​​set to 1; otherwise, it is set to 0, ensuring that only upstream causal nodes can pass information to the current node. Simultaneously, pre-trained graph neural network parameters, including attention weight matrices and feature transformation weights, are loaded to prepare for information aggregation.

[0262] Subsequently, the representation vectors of each topic node are used as initial input to the directional mask map neural network. The network first performs a linear transformation on the initial representation of each node to improve its feature representation capability. Then, combined with the directional mask matrix, only parent nodes with a mask value of 1 are selected, and the attention weight of each parent node to the current node is calculated. The expression for calculating the attention score is:

[0263] ;

[0264] Normalize the attention scores into a probability distribution:

[0265] ;

[0266] First calculate the nodes. Its potential parent node raw attention scores between The attention scores are then normalized. In the normalization formula, the summation of the denominator is limited to the set of parent nodes. (That is, the position in the mask matrix corresponding to a value of 1).

[0267] In actual calculations, this is equivalent to placing non-parent nodes... Attention score Forced to , making This mechanism mathematically guarantees that the weight of non-causal upstream nodes is zero, thereby ensuring that information propagation strictly follows the causal direction and preventing the leakage of "future information".

[0268] The weights are determined by the semantic similarity between the parent node and the current node, as well as the strength of the causal edges, highlighting the impact of key causal relationships.

[0269] Finally, the transformed features of the parent nodes are weighted and summed according to their attention weights. Combined with the initial features of the current node, and processed by a non-linear activation function, the updated topic node representation vector is obtained. The l-th layer representation of node i is obtained by weighted aggregation of the transformed representations of all its parent nodes:

[0270] ;

[0271] This formula defines the node feature update rule for the l-th layer. The new representation of node i. It is the representation of the previous level of all its parent nodes. A weighted linear combination, after passing through a nonlinear activation function Obtained through transformation. Weights The dynamics reflect the differences in causal strength. This aggregation process ensures that the final representation of each node encodes only its own semantic information and its causal history information (Ancestral Information), which conforms to the causal Markov condition.

[0272] One round of propagation is completed by traversing all topic nodes. If it is necessary to aggregate multi-hop parent node information, multiple layers of network can be stacked and the above process can be repeated. Finally, the updated representations of all nodes are integrated to form a topic node representation matrix that integrates causal information.

[0273] This application's embodiments construct strict causal direction constraints through a directional mask matrix, architecturally avoiding causal logic confusion caused by backpropagation and ensuring that topic representations rely solely on upstream causal information. Dynamic calculation of attention weights allows the model to adaptively identify key parent nodes, highlighting the influence of core causal relationships and filtering out secondary information interference. Aggregating parent node causal information through a graph neural network ensures that topic node representations retain their own semantic features while incorporating causal dependencies, making them more interpretable than single-node representations. The resulting topic node representation matrix provides accurate and causal semantically rich foundational data for subsequent hierarchical clustering and cross-layer information fusion, significantly improving the processing efficiency of subsequent steps.

[0274] The core of directional masked graph neural networks is to ensure the unidirectional propagation of information through mask constraints. However, existing masking applications often rely on simple filtering logic, which can easily lead to problems such as leakage of non-parent node information or redundant attention weight calculations. Therefore, this application clarifies the standardized construction process and precise application logic of the directional mask matrix. It defines causal propagation permissions through a binary matrix and forcibly masks invalid associations in attention calculations, ensuring that information flows only in the causal direction from parent node to child node.

[0275] In one possible implementation, the process of constructing and applying the directional mask matrix includes:

[0276] Construct a directional mask matrix with the same dimensions as the adjacency matrix. If there is a directed edge from node j to node i in the global causal graph, set the corresponding position (i,j) in the mask matrix to 1; otherwise, set it to 0.

[0277] When calculating attention weights in a graph neural network, the attention score corresponding to the position with a value of 0 in the directional mask matrix is ​​forced to be negative infinity or zero. This makes the weights of non-parent nodes masked when aggregating information from parent nodes, and information propagation flows from parent nodes to child nodes along the causal direction.

[0278] In this embodiment, a binary directional mask matrix with dimensions identical to the adjacency matrix of the global causal graph is first constructed. All node pairs in the global causal graph are traversed. If a directed causal edge exists from node j to node i (i.e., node j is the parent node of node i), the value at position (i,j) in the mask matrix is ​​set to 1; otherwise, it is set to 0, clearly defining the effective causal propagation path. Subsequently, during the attention weight calculation stage of the graph neural network, the attention score corresponding to the position with a value of 0 in the directional mask matrix is ​​forcibly set to negative infinity (or zero). This ensures that after softmax normalization, the weights of non-parent nodes are compressed to near 0, allowing only the information of the parent node to participate in the feature aggregation of the current node. Ultimately, this achieves unidirectional propagation of information along the causal direction from the parent node to the child node, strictly conforming to the unidirectional requirement of causal semantics.

[0279] S206: The server clusters the global topic nodes in the topic node representation matrix to obtain a fine-grained topic layer and an abstract topic layer.

[0280] The fine-grained topic layer includes each topic node, while the abstract topic layer includes abstract topics formed by clustering semantically similar fine-grained topics.

[0281] The server first obtains a topic node representation matrix, which contains high-dimensional representation vectors of all global topic nodes. The vector dimensions have been optimized through causal information aggregation. Then, based on the scale of the number of topics in the target domain (e.g., the number of global topic nodes m is between 50 and 500), the number of clusters K for the abstract topic layer is preset (e.g., K = m / 5 to m / 10) to ensure that the abstract topics are both general and do not lose key semantics.

[0282] Next, a suitable clustering algorithm is selected for grouping. When m < 100, hierarchical clustering is used, constructing a cluster tree based on the cosine similarity of topic vectors. The most similar clusters are gradually merged using an agglomerative strategy, and the similarity between clusters is calculated using the average linking method. When m ≥ 100, K-Means++ clustering is used, which improves the convergence speed by intelligently initializing cluster centers. The similarity between topic vectors is measured using Euclidean distance, and the allocation and update process is executed iteratively. Each topic node is assigned to the nearest cluster center, and the mean of the topic vectors within the cluster is recalculated as the new center until the cluster centers are stable or the maximum number of iterations is reached. After clustering, the original global topic nodes constitute a fine-grained topic layer. Each cluster corresponds to an abstract topic, and all abstract topics together form the abstract topic layer.

[0283] This application's embodiments achieve hierarchical division of global topic nodes through clustering algorithms. This preserves the specific semantic details of fine-grained topics while summarizing and integrating core semantics through an abstract topic layer, aligning with the natural hierarchical structure of professional domain knowledge. Clustering based on topic representation vectors that integrate causal information ensures the semantic relevance and causal association of topics within clusters, avoiding the limitations of traditional clustering that relies solely on surface word similarity. The separate construction of fine-grained and abstract topic layers lays a structural foundation for subsequent cross-layer information fusion and multi-granularity topic output. This satisfies users' precise query needs for specific topics while providing a macro-level overview of topics, enhancing the interpretability and practicality of the topic system.

[0284] S207: The server constructs an abstract layer causal graph by inducing directed causal edges between abstract topics based on a global causal graph.

[0285] The server first clarifies the mapping relationship between fine-grained topics and abstract topics, that is, the category of abstract topic to which each fine-grained topic belongs. Then, it traverses all directed causal edges in the global causal graph. If an edge connects a fine-grained topic vi (belonging to abstract topic Ck) and vj (belonging to abstract topic Ck′), then it marks that there is a potential causal relationship between abstract topics Ck and Ck′.

[0286] Next, the frequency of occurrence of abstract topic pairs corresponding to all fine-grained causal edges is counted, and the frequency is normalized and used as the initial weight of the causal edges in the abstract layer. At the same time, weak associations with frequencies below a preset threshold are filtered out, and only core causal connections are retained. Finally, based on the filtered abstract topic nodes and directed causal edges, an abstract layer causal graph is constructed to clarify the causal direction and strength between abstract topics, ensuring that it is consistent with the core causal logic of the global causal graph.

[0287] This application's embodiments induce causal edges at the abstract layer through fine-grained causal relationships, ensuring logical consistency between the abstract layer causal graph and the underlying global causal graph, and preventing the top-level causal relationships from becoming disconnected from actual semantics. The construction of the abstract layer causal graph achieves hierarchical simplification of causal relationships, eliminating redundant associations at the fine-grained level and highlighting macroscopic causal logic. Simultaneously, it provides a structured foundation for the subsequent information dissemination at the abstract topic layer, enabling abstract topics to aggregate global contextual information based on causal relationships, further enhancing the hierarchy and interpretability of topic representation.

[0288] S208: The server performs directional masked graph neural network propagation on the causal graph of the abstract layer to update the representation vector of the abstract topic; through a gating mechanism, the representation vector of the abstract topic is passed back to the corresponding fine-grained topic to obtain the topic representation that integrates multi-granular information.

[0289] The server first loads the abstract layer causal graph, the initial representation of the abstract topic, and the directional mask matrix. This mask matrix strictly follows the direction of the causal edges in the abstract layer, allowing information to flow only from the parent abstract topic to the child abstract topic. Then, the directional mask graph neural network propagation process is initiated. Following the topological order of the abstract layer causal graph, the attention weight of each abstract topic is calculated, determined by the causal strength and semantic similarity between the parent topic and the current topic. The feature information of the parent topic is weighted and aggregated, and after non-linear activation, the representation vector of the abstract topic is updated, ensuring that the abstract topic captures the global causal context.

[0290] Next, for each fine-grained topic, its corresponding abstract topic is found based on the clustering mapping relationship, and the updated representation vector of that abstract topic is extracted. A gating mechanism is used to calculate the fusion weights. The representation vector of the fine-grained topic itself is concatenated with the representation vector of the corresponding abstract topic, input into a two-layer perceptron and activated by a sigmoid function, resulting in a weight vector in the 0-1 range. Higher weight values ​​indicate a greater contribution from the abstract layer information. In the gating mechanism, a gating unit dynamically adjusts the fusion ratio, which can be specifically represented as follows:

[0291] ;

[0292] ;

[0293] Gated vectors Represented by fine-grained topics and the corresponding abstract topic representation After concatenation, it is processed through a single-layer neural network and a sigmoid activation function. The calculation yields this gate vector, which dynamically determines the information source along the feature dimension. If... If it's close to 1, more detailed underlying information is retained; if... If the value is close to 0, a global context with more layers of abstraction is introduced. This mechanism solves the problem of incomplete information in a single-granularity representation.

[0294] Finally, the fine-grained topic representation and the abstract topic representation are weighted and fused according to the weight vector. This process preserves the specific semantic details of the fine-grained topic while incorporating the global perspective of the abstract topic, generating a topic representation that integrates multi-granular information.

[0295] This application's embodiments utilize directional propagation of the abstract layer causal graph to aggregate global causal context information into abstract topics, avoiding the semantic limitations of a single abstract topic. The application of a gating mechanism enables adaptive fusion of multi-granularity information, preventing abstract layer information from obscuring the unique features of fine-grained topics while strengthening the supplementation of local topics by global associations. The resulting fused representation vector possesses both specific details and a macroscopic perspective, solving the problem that single-granularity topic representations either lack global associations or lose detailed information, providing high-quality core data support for subsequent integration and inference applications of causal topic models.

[0296] S209: Based on the global causal graph, directional mask graph neural network parameters, cross-layer information fusion mechanism, and the mapping relationship between fine-grained topic layers and abstract topic layers, a causal topic model is integrated to form a causal topic model.

[0297] The server first summarizes the core results of all training phases, including the optimized global causal graph, the parameters of the trained nonlinear causal generation function, the weights and attention parameters of each layer of the directional masked graph neural network, the fine-grained-abstract topic clustering mapping table, the abstract layer causal graph, and the cross-layer fusion gating parameters.

[0298] Subsequently, the summarized structured data and parameters were standardized in format. The global causal graph and the abstract layer causal graph were uniformly stored as adjacency matrices and node attribute dictionaries. Model parameters were encapsulated according to network modules, such as GNN modules, fusion modules, or generator function modules. Cross-layer mapping relationships were converted into key-value pairs to ensure data format compatibility across components. Finally, a model call interface was constructed, defining standardized input and output formats, completing the encapsulation and storage of the complete causal topic model, supporting direct invocation in subsequent inference tasks.

[0299] This application's embodiments systematically integrate the core structures and parameters during the training process, forming a fully functional, independently runnable end-to-end model. This avoids the cumbersome calling and logical conflicts caused by the dispersion of various modules. Standardized data and parameter formats ensure the model's portability and scalability, adapting to deployment requirements in different scenarios. The deep binding of cross-layer mapping relationships with causal graphs and model parameters enables the model to quickly achieve multi-granularity information fusion and causal logic tracing during inference, providing a unified and efficient execution foundation for subsequent tasks such as topic discovery, causal query, and counterfactual reasoning, ensuring the consistency and reliability of the model's output.

[0300] Causal topic models involve multiple modules, including causal graph structures, nonlinear causal generation, directional graph neural networks, and counterfactual generation. Optimizing only a single module can easily lead to parameter conflicts and unstable training. Therefore, this application adopts a phased joint optimization strategy. By first fixing the structure and then optimizing the parameters, and by optimizing the independent modules first and then the joint modules, the adjacency matrix of the causal graph, the core model parameters, the generator, and the discriminator are optimized sequentially. Finally, the global loss function is uniformly tuned to ensure that each module is adapted to the other, thereby improving the overall performance of the model.

[0301] In one possible implementation, the training process for the causal topic model also includes:

[0302] For global causal graphs, the adjacency matrix of the global causal graph is updated by augmented Lagrange optimization based on the structural scoring loss function and the acyclicity constraint function.

[0303] For global causal graph and directional masked graph neural networks, the adjacency matrix of the global causal graph is fixed, and the parameters of the nonlinear causal generation function and the directional masked graph neural network are jointly optimized based on the reconstruction loss function;

[0304] By fixing the global causal graph, an adversarial training strategy is used to optimize the parameters of the generator and discriminator.

[0305] Based on the global joint loss function, the parameters of each part in the causal topic model are adjusted.

[0306] The joint optimization scheme provided in this application proceeds in four steps. The first step targets the global causal graph, using a structural scoring loss function (measuring the fit between the causal graph and the data) and an acyclicity constraint function (ensuring the graph is a directed acyclic graph) as optimization objectives. The adjacency matrix is ​​iteratively updated using augmented Lagrange optimization, dynamically adjusting the Lagrange multipliers and penalty coefficients until the constraints are satisfied or convergence occurs, resulting in a stable causal graph topology. The second step fixes the optimized adjacency matrix and, based on the reconstruction loss function (minimizing the prediction error of node representations and the difference between original features), jointly optimizes the MLP parameters of the nonlinear causal generation function and the attention weights and feature transformation matrix of the directional masked graph neural network, ensuring accurate adaptation between causal information transmission and nonlinear dependency modeling. The third step keeps the global causal graph unchanged and uses an adversarial training strategy to alternately update the generator and discriminator parameters. The discriminator learns to distinguish between real and counterfactual text through Wasserstein distance and gradient penalty, while the generator optimizes text generation quality in the adversarial process, while incorporating semantic consistency constraints to avoid deviating from the topic. The fourth step involves constructing a global joint loss function that includes structural loss, reconstruction loss, and adversarial loss. All parameters of the causal graph adjacency matrix (fine-tuned), the nonlinear causal generation function, the directional graph neural network, and the generator and discriminator are uniformly adjusted. Through differentiated learning rates and gradient pruning, the objectives of each module are coordinated, ultimately resulting in a stable causal topic model. The global joint loss function can be expressed as:

[0307] ;

[0308] in, Used to optimize cause-effect graph structures Used to force causal graphs to be acyclic. Used to optimize nonlinear causal generation mechanisms This is used to ensure that the node representations of the graph neural network can reconstruct the original features. Used to guide the generation of counterfactual text. By adjusting various losses The weighting coefficients enable the causal topic model to achieve a balance between structure learning, representation learning, and generation tasks, thus achieving end-to-end collaborative optimization.

[0309] Counterfactual reasoning is a core method for verifying the reliability of causal relationships. Existing generation methods are prone to problems such as inconsistent causal logic and low text quality. Therefore, this application's embodiments design a standardized intervention process based on Pearl's Do-calculus theory, combine the WGAN architecture with semantic consistency constraints, and optimize the generator and discriminator through adversarial training to ensure that the generated counterfactual text conforms to causal logic and possesses high-quality semantic expression.

[0310] In one possible implementation, the training process for the causal topic model also includes:

[0311] Based on Pearl's Do-calculus theory, intervention operations are performed on the target topic node, fixing the value of the target topic node to a preset intervention value, and severing the causal connection edges between the target topic node and all parent nodes in the global causal graph, while keeping the rest of the causal structure unchanged.

[0312] Based on the topological sorting of the global causal graph, the representation vectors of downstream descendant topic nodes affected by the intervention of the target topic node are recalculated to obtain the counterfactual representation vectors;

[0313] Input the counterfactual representation vector and Gaussian random noise into the generator to obtain the counterfactual text; input the real text or the generated counterfactual text into the discriminator to obtain the text authenticity score;

[0314] The scores for the real text and the counterfactual text are calculated separately. The difference between the scores of the real text and the generated text is used as the Wasserstein distance estimate. A gradient penalty term is calculated based on linear interpolated samples of the real and counterfactual texts. The Wasserstein distance estimate is then added to the gradient penalty term to obtain the total discriminator loss. The total discriminator loss can be expressed as:

[0315] Distance estimation gradient penalty term:

[0316] ;

[0317] The Wasserstein distance estimate is given. This is the gradient penalty term. The Wasserstein-1 distance (EM distance) between the real text distribution and the generated text distribution was approximated. Compared with the JS divergence of traditional GANs, it can provide effective gradients even when the two distributions do not overlap.

[0318] In the gradient penalty term, It is a linear interpolation between real samples and generated samples. This term forces the discriminator. The gradient norm is close to 1, thus satisfying the Lipschitz continuity constraint. This is a key technique to ensure stable WGAN training, avoid mode collapse, and generate high-quality counterfactual text.

[0319] An optimizer is used to update the discriminator's network parameters through backpropagation based on the discriminator's total loss;

[0320] Calculate the adversarial loss of the discriminator; calculate the semantic similarity between the counterfactual text and the real text using the BERT model to obtain the semantic consistency constraint term; add the adversarial loss and the semantic consistency constraint term to obtain the generator's total loss. The semantic consistency constraint term can be expressed as:

[0321] ;

[0322] Semantic consistency constraint term is calculated from the original text. Counterfactual texts The goal is to minimize the cosine similarity in the semantic space of a pre-trained BERT model. This means maximizing the semantic similarity between the two. While ensuring that the generator modifies causal content, it retains background information in the document that is irrelevant to the intervention (such as sentence style, irrelevant topics, etc.), which conforms to the "principle of least modification" of counterfactual reasoning.

[0323] An optimizer is used to update the generator's network parameters through backpropagation based on the generator's total loss.

[0324] In this embodiment, firstly, based on Pearl's Do-calculus theory, an intervention operation is performed on the target topic node. Its value is fixed to a preset intervention value, causal connections with all parent nodes are severed, while the remaining causal structure remains unchanged. Next, according to the topological sorting of the global causal graph, the representation vectors of the affected downstream descendant topic nodes are recalculated to obtain the counterfactual representation vector. Then, the counterfactual representation vector and Gaussian random noise are input into the generator to generate counterfactual text. Simultaneously, either real text or counterfactual text is input into the discriminator to obtain a text authenticity score. The difference between the scores of the real text and the counterfactual text is then calculated as the Wasserstein distance estimate. A gradient penalty term is calculated based on the linear interpolation samples of both, and the two are added together to obtain the total discriminator loss. The discriminator parameters are updated through backpropagation of the optimizer. Then, the adversarial loss of the discriminator is calculated, and the semantic consistency constraint term between the counterfactual text and the real text is obtained using the BERT model. The two are added together to form the total generator loss. Finally, the generator parameters are updated through backpropagation of the optimizer, completing one round of adversarial training. After iterative optimization, both causal logic and text quality are guaranteed.

[0325] The core theme of this application is unsupervised causal topic modeling, integrating technologies such as large language models and nonlinear causal graph neural networks to automatically construct a hierarchical topic system with causal relationships from unstructured text. This application's embodiments, through hierarchical topic discovery, form a multi-layered structure of macroscopic abstract topics and microscopic fine-grained topics, such as "lung cancer treatment → targeted therapy → EGFR inhibitor treatment → osimertinib treatment regimen" in the medical field. Furthermore, in this application's embodiments, directed causal relationships between topics are inferred, constructing a directed acyclic graph to clarify the logical chain of cause and effect, such as "EGFR T790M mutation → osimertinib resistance → treatment regimen adjustment". This topic model requires no manual annotation, relying solely on automatic learning from the original text, overcoming the limitations of traditional topic models that can only identify statistical co-occurrence and cannot explain causality. In multiple fields such as medicine, policy, and finance, it can help users quickly organize logical chains, reduce manual extraction costs, and provide support for decision-making.

[0326] This application also provides a text analysis device based on causal relationships and multi-layered topic understanding, such as... Figure 3 As shown, the device includes:

[0327] Preprocessing module 301 is used to receive the target document to be analyzed, preprocess the target document, and obtain standardized target text;

[0328] The input module 302 is used to input the standardized target text into a pre-trained causal topic model. The causal topic model includes a pre-trained global causal graph, a directional mask graph neural network, a cross-layer information fusion mechanism, and a mapping relationship between fine-grained topic layers and abstract topic layers.

[0329] The first processing module 303 is used to extract topic nodes in the standardized target text based on the global causal graph through the directional mask graph neural network, and match the set of parent nodes of each topic node in the global causal graph, and aggregate the causal information of the parent nodes to obtain the target topic representation vector.

[0330] The second processing module 304 is used to map the target topic representation vector to the corresponding fine-grained topic and abstract topic respectively based on the mapping relationship between the fine-grained topic layer and the abstract topic layer, call the cross-layer information fusion mechanism, and pass the global context information of the abstract topic to the corresponding fine-grained topic to obtain the target final topic representation that integrates multi-granular information.

[0331] The output module 305 is used to output the multi-granularity topic structure of the target document and the directed causal inference results between topics based on the target final topic representation and the global causal graph.

[0332] In one possible implementation, the apparatus further includes a model training module, the model training module being used for:

[0333] Acquire text corpus, and extract candidate sets of topic nodes and candidate causal relationship pairs from the text corpus based on a large language model;

[0334] The candidate set of topic nodes is standardized to obtain a global set of topic nodes;

[0335] A global causal graph is generated based on the NOTEARS algorithm and the candidate causal relationships. The global causal graph includes global topic nodes and directed causal edges between global topic nodes. The directed causal edges are used to mark the causal direction and causal strength between global topic nodes.

[0336] Based on the set of parent nodes of each topic node in the global causal graph, a nonlinear causal generation function for each topic node is constructed and the representation vector of each topic node is calculated.

[0337] A directional mask matrix is ​​introduced into the global causal graph. The parent node information is aggregated according to the directional mask matrix through a directional mask graph neural network, and the representation vector of each topic node is updated to obtain a topic node representation matrix that integrates causal information. The directional mask matrix is ​​used to restrict the propagation of information from the cause topic node to the result topic node.

[0338] Clustering is performed on the global topic nodes in the topic node representation matrix to obtain a fine-grained topic layer and an abstract topic layer; the fine-grained topic layer includes each topic node, and the abstract topic layer includes abstract topics formed by clustering semantically similar fine-grained topics;

[0339] Based on the global causal graph, directed causal edges are induced between the abstract topics, and an abstract layer causal graph is constructed.

[0340] Directional masked graph neural network propagation is performed on the abstract layer causal graph to update the representation vector of the abstract topic; the representation vector of the abstract topic is then passed back to the corresponding fine-grained topic through a gating mechanism to obtain a topic representation that integrates multi-granularity information.

[0341] Based on the global causal graph, the parameters of the directional mask graph neural network, the cross-layer information fusion mechanism, and the mapping relationship between the fine-grained topic layer and the abstract topic layer, the causal topic model is integrated to form the causal topic model.

[0342] In one possible implementation, the model training module is specifically used for:

[0343] Load a pre-defined domain standard terminology library, which includes standard conceptual entities within the domain;

[0344] The semantic similarity between each topic node in the candidate topic node set and the terms in the standard terminology database is calculated using a text embedding model.

[0345] Topic nodes with semantic similarity higher than a preset threshold are mapped to corresponding standard terms, and multiple topic nodes mapped to the same standard term are merged and deduplicated to obtain the global topic node set.

[0346] In one possible implementation, the model training module is specifically used for:

[0347] For the topic node, identify the set of parent nodes of the topic node from the global causal graph;

[0348] The input vector is obtained by concatenating the representation vectors of all parent nodes in the set of parent nodes along the feature dimension.

[0349] The input vector is input into the multilayer perceptron network corresponding to the topic node, and after nonlinear transformation, exogenous noise is superimposed to output the representation vector of the topic node; the multilayer perceptron network corresponds one-to-one with the topic in the global causal graph.

[0350] In one possible implementation, the process of constructing and applying the directional mask matrix includes:

[0351] Construct the directional mask matrix with the same dimension as the adjacency matrix. If there is a directed edge from node j to node i in the global causal graph, set the corresponding position (i,j) in the mask matrix to 1; otherwise, set it to 0.

[0352] When the graph neural network calculates the attention weights, the attention score corresponding to the position with a value of 0 in the directional mask matrix is ​​forcibly set to negative infinity or zero, so that when aggregating the information of the parent node, the weights of non-parent nodes are masked, and the information propagation flows from the parent node to the child node along the causal direction.

[0353] In one possible implementation, the preprocessing module 301 is specifically used for:

[0354] The summary and title of the target text are merged into a unified text unit to obtain the merged target text;

[0355] The merged target text is cleaned by removing typesetting and citation marks, and the capitalization of academic proper nouns is standardized.

[0356] In one possible implementation, the candidate causal relationship pair includes the causal pair and the confidence level corresponding to the causal pair; the causal pair includes a cause topic and an effect topic;

[0357] The model training module is specifically used for:

[0358] The causal pairs are filtered based on the confidence level, and causal pairs with a confidence level greater than the confidence threshold are retained.

[0359] Calculate the frequency of occurrence of multiple causal pairs obtained from the screening and perform weight calculations to construct a candidate edge set;

[0360] Construct an initial adjacency matrix based on the candidate edge set;

[0361] The initial adjacency matrix is ​​optimized based on the NOTEARS algorithm, and the global causal graph is generated through differentiable acyclic constraints.

[0362] In one possible implementation, the model training module is further used for:

[0363] Based on Pearl's Do-calculus theory, an intervention operation is performed on the target topic node, fixing the value of the target topic node to a preset intervention value, and severing the causal connection edges between the target topic node and all parent nodes in the global causal graph, while keeping the rest of the causal structure unchanged.

[0364] Based on the topological sorting of the global causal graph, the representation vectors of downstream descendant topic nodes affected by the intervention of the target topic node are recalculated to obtain the counterfactual representation vectors;

[0365] Input the counterfactual representation vector and Gaussian random noise into the generator to obtain the counterfactual text; input the real text or the generated counterfactual text into the discriminator to obtain the text authenticity score;

[0366] The scores of the real text and the counterfactual text are calculated separately, and the difference between the scores of the real text and the generated text is used as the Wasserstein distance estimate. Based on the linear interpolation samples of the real text and the counterfactual text, a gradient penalty term is calculated. The Wasserstein distance estimate is added to the gradient penalty term to obtain the total loss of the discriminator.

[0367] An optimizer is used to update the network parameters of the discriminator through backpropagation based on the total loss of the discriminator;

[0368] Calculate the adversarial loss of the discriminator; calculate the semantic similarity between the counterfactual text and the real text using the BERT model to obtain the semantic consistency constraint term; add the adversarial loss to the semantic consistency constraint term to obtain the generator's total loss;

[0369] An optimizer is used to update the generator's network parameters through backpropagation based on the generator's total loss.

[0370] In one possible implementation, the model training module is further used for:

[0371] For the global causal graph, the adjacency matrix of the global causal graph is updated by augmented Lagrange optimization based on the structural scoring loss function and the acyclicity constraint function.

[0372] For the global causal graph and the directional mask graph neural network, the adjacency matrix of the global causal graph is fixed, and the parameters of the nonlinear causal generation function and the directional mask graph neural network are jointly optimized based on the reconstruction loss function;

[0373] With the global causal graph fixed, the parameters of the generator and discriminator are optimized using an adversarial training strategy.

[0374] Based on the global joint loss function, the parameters of each part in the causal topic model are adjusted.

[0375] In one possible implementation, the device further includes a reverse reasoning module, the reverse reasoning module being used for:

[0376] The topic nodes and their corresponding topic representation vectors in the target text are used as the baseline vector for counterfactual reasoning.

[0377] The baseline vector is adjusted according to the intervention description; if the intervention description is to delete the target topic node, the baseline vector of the target topic node is set to zero; if the intervention description is to enhance the target topic node, the baseline vector of the target topic node is multiplied by a coefficient greater than 1; if the intervention description is to replace the target topic node, the topic node representation vector of the target topic node sampled from other documents is used as the replacement vector.

[0378] According to the topological order of the global causal graph, the topic representation vectors of the downstream topic nodes affected by the intervention are recalculated, while the baseline vectors of the unaffected topics remain unchanged, resulting in a set of counterfactual topic vectors.

[0379] Input the set of counterfactual topic vectors into the generator, select zero noise to generate counterfactual text; calculate the change in the representation vector of each topic node before and after the intervention, identify topic nodes whose representation vector change is greater than a preset value and mark the degree of representation vector change;

[0380] Text alignment techniques are used to display the differences between the target document and the counterfactual text in the form of highlights or marks;

[0381] Generate a natural language causal explanation; the natural language causal explanation is used to explain the mechanism by which the intervention of the target topic leads to changes in the text content.

[0382] In one possible implementation, the device further includes an intervention module, the intervention module being used for:

[0383] Obtain the specified starting topic node, and from the pre-trained global causal graph, filter all descendant topic nodes that are rooted at the starting topic node and reachable by directed paths, as well as directed connection edges between topic nodes, to form a causal subgraph;

[0384] Perform a topological sort on the topic nodes in the causal subgraph to generate an ordered list of descendant topic nodes;

[0385] Using the starting topic node as the root node, add descendant topic nodes layer by layer according to the topological sorting in the ordered list, connect each descendant topic node to the parent node pointing to the descendant topic node in the causal subgraph, and mark the corresponding causal strength score on the connection edge;

[0386] Calculate the influence breadth of the starting topic node, and count the number of topic nodes that directly influence the topic node, the number of topic nodes that indirectly influence the topic node, and the total number of topic nodes that influence the topic node.

[0387] Identify intermediate topic nodes whose in-degree and out-degree are both greater than preset values; the intermediate topic nodes are topic nodes that connect multiple causal paths;

[0388] Determine the longest causal chain from the starting topic node to the leaf node, record the path sequence and path length, and generate a visualization chart.

[0389] This application also provides a control device. The control device may include a memory and a processor. The processor is used to execute the text analysis method based on causal relationships and multi-layer topic understanding described in any of the above embodiments. The memory may be random access memory (RAM), flash memory, read-only memory (ROM), non-volatile read-only memory (EPROM), registers, hard disk, removable disk, etc.

[0390] Memory can store computer instructions, which, when executed by a processor, can be used to perform text analysis methods based on causal relationships and multi-layered topic understanding. Memory can also store data.

[0391] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product. A computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the flow or function according to the embodiments of this application is generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape) or a semiconductor medium (e.g., solid-state disk (SSD)).

[0392] This application also provides a readable storage medium for storing the methods provided in the above embodiments. For example, RAM, flash memory, ROM, EPROM, registers, hard disk, removable disk, or any other form of storage medium in the art.

[0393] In the embodiments of this application, the terms "first" and "second" (if they exist) are used only as name identifiers and do not represent the order of first and second.

[0394] It should be noted that the various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. Regarding the methods disclosed in the embodiments, since they correspond to the product embodiments disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the description of the product embodiments.

[0395] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.< / num>

Claims

1. A text analysis method based on causal relationships and multi-layered topic understanding, characterized in that, The method includes: Receive the target document to be analyzed, preprocess the target document to obtain standardized target text; The standardized target text is input into a pre-trained causal topic model, which includes a pre-trained global causal graph, a directional mask graph neural network, a cross-layer information fusion mechanism, and a mapping relationship between fine-grained topic layers and abstract topic layers. Based on the global causal graph, the topic nodes in the standardized target text are identified, and the parent node set of each topic node in the global causal graph is matched by the directional mask graph neural network. The causal information of the parent nodes is aggregated to obtain the target topic representation vector. Based on the mapping relationship between the fine-grained topic layer and the abstract topic layer, the target topic representation vector is mapped to the corresponding fine-grained topic and abstract topic respectively. The cross-layer information fusion mechanism is invoked to pass the global context information of the abstract topic to the corresponding fine-grained topic, so as to obtain the target final topic representation that integrates multi-granular information. Based on the final topic representation of the target and the global causal graph, the multi-granularity topic structure of the target document and the directed causal inference results between topics are output.

2. The method according to claim 1, characterized in that, The training process for the causal topic model is as follows: Acquire text corpus, and extract candidate sets of topic nodes and candidate causal relationship pairs from the text corpus based on a large language model; The candidate set of topic nodes is standardized to obtain a global set of topic nodes; A global causal graph is generated based on the NOTEARS algorithm and the candidate causal relationships. The global causal graph includes global topic nodes and directed causal edges between global topic nodes. The directed causal edges are used to mark the causal direction and causal strength between global topic nodes. Based on the set of parent nodes of each topic node in the global causal graph, a nonlinear causal generation function for each topic node is constructed and the representation vector of each topic node is calculated. A directional mask matrix is ​​introduced into the global causal graph. The parent node information is aggregated according to the directional mask matrix through a directional mask graph neural network, and the representation vector of each topic node is updated to obtain a topic node representation matrix that integrates causal information. The directional mask matrix is ​​used to restrict the propagation of information from the cause topic node to the result topic node. Clustering is performed on the global topic nodes in the topic node representation matrix to obtain a fine-grained topic layer and an abstract topic layer; the fine-grained topic layer includes each topic node, and the abstract topic layer includes abstract topics formed by clustering semantically similar fine-grained topics; Based on the global causal graph, directed causal edges are induced between the abstract topics, and an abstract layer causal graph is constructed. Directional masked graph neural network propagation is performed on the abstract layer causal graph to update the representation vector of the abstract topic; the representation vector of the abstract topic is then passed back to the corresponding fine-grained topic through a gating mechanism to obtain a topic representation that integrates multi-granularity information. Based on the global causal graph, the parameters of the directional mask graph neural network, the cross-layer information fusion mechanism, and the mapping relationship between the fine-grained topic layer and the abstract topic layer, the causal topic model is integrated to form the causal topic model.

3. The method according to claim 2, characterized in that, The standardization process of the candidate topic nodes to obtain a global topic node set includes: Load a pre-defined domain standard terminology library, which includes standard conceptual entities within the domain; The semantic similarity between each topic node in the candidate topic node set and the terms in the standard terminology database is calculated using a text embedding model. Topic nodes with semantic similarity higher than a preset threshold are mapped to corresponding standard terms, and multiple topic nodes mapped to the same standard term are merged and deduplicated to obtain the global topic node set.

4. The method according to claim 2, characterized in that, The construction of the nonlinear causal generation function for each topic node and the calculation of the representation vector for each topic node include: For the topic node, identify the set of parent nodes of the topic node from the global causal graph; The input vector is obtained by concatenating the representation vectors of all parent nodes in the set of parent nodes along the feature dimension. The input vector is input into the multilayer perceptron network corresponding to the topic node, and after nonlinear transformation, exogenous noise is superimposed to output the representation vector of the topic node; the multilayer perceptron network corresponds one-to-one with the topic in the global causal graph.

5. The method according to claim 2, characterized in that, The process of constructing and applying the directional mask matrix includes: Construct the directional mask matrix with the same dimension as the adjacency matrix. If there is a directed edge from node j to node i in the global causal graph, set the corresponding position (i,j) in the mask matrix to 1; otherwise, set it to 0. When the graph neural network calculates the attention weights, the attention score corresponding to the position with a value of 0 in the directional mask matrix is ​​forcibly set to negative infinity or zero, so that when aggregating the information of the parent node, the weights of non-parent nodes are masked, and the information propagation flows from the parent node to the child node along the causal direction.

6. The method according to claim 1, characterized in that, The process of receiving the target document to be analyzed and preprocessing the target document includes: The summary and title of the target text are merged into a unified text unit to obtain the merged target text; The merged target text is cleaned by removing typesetting and citation marks, and the capitalization of academic proper nouns is standardized.

7. The method according to claim 2, characterized in that, The candidate causal relationship pairs include causal pairs and their corresponding confidence levels; the causal pairs include cause topics and effect topics. The generation of a global causal graph based on the NOTEARS algorithm and the candidate causal relationship pairs includes: The causal pairs are filtered based on the confidence level, and causal pairs with a confidence level greater than the confidence threshold are retained. Calculate the frequency of occurrence of multiple causal pairs obtained from the screening and perform weight calculations to construct a candidate edge set; Construct an initial adjacency matrix based on the candidate edge set; The initial adjacency matrix is ​​optimized based on the NOTEARS algorithm, and the global causal graph is generated through differentiable acyclic constraints.

8. The method according to claim 2, characterized in that, The training process of the causal topic model also includes: Based on Pearl's Do-calculus theory, an intervention operation is performed on the target topic node, fixing the value of the target topic node to a preset intervention value, and severing the causal connection edges between the target topic node and all parent nodes in the global causal graph, while keeping the rest of the causal structure unchanged. Based on the topological sorting of the global causal graph, the representation vectors of downstream descendant topic nodes affected by the intervention of the target topic node are recalculated to obtain the counterfactual representation vectors; Input the counterfactual representation vector and Gaussian random noise into the generator to obtain the counterfactual text; input the real text or the generated counterfactual text into the discriminator to obtain the text authenticity score; The scores of the real text and the counterfactual text are calculated separately, and the difference between the scores of the real text and the generated text is used as the Wasserstein distance estimate. Based on the linear interpolation samples of the real text and the counterfactual text, a gradient penalty term is calculated. The Wasserstein distance estimate is added to the gradient penalty term to obtain the total loss of the discriminator. An optimizer is used to update the network parameters of the discriminator through backpropagation based on the total loss of the discriminator; Calculate the adversarial loss of the discriminator; calculate the semantic similarity between the counterfactual text and the real text using the BERT model to obtain the semantic consistency constraint term; add the adversarial loss to the semantic consistency constraint term to obtain the generator's total loss; An optimizer is used to update the generator's network parameters through backpropagation based on the generator's total loss.

9. The method according to claim 2, characterized in that, The training process of the causal topic model also includes: For the global causal graph, the adjacency matrix of the global causal graph is updated by augmented Lagrange optimization based on the structural scoring loss function and the acyclicity constraint function. For the global causal graph and the directional mask graph neural network, the adjacency matrix of the global causal graph is fixed, and the parameters of the nonlinear causal generation function and the directional mask graph neural network are jointly optimized based on the reconstruction loss function; With the global causal graph fixed, the parameters of the generator and discriminator are optimized using an adversarial training strategy. Based on the global joint loss function, the parameters of each part in the causal topic model are adjusted.

10. The method according to claim 1, characterized in that, The method further includes: The topic nodes and their corresponding topic representation vectors in the target text are used as the baseline vector for counterfactual reasoning. The baseline vector is adjusted according to the intervention description; if the intervention description is to delete the target topic node, the baseline vector of the target topic node is set to zero; if the intervention description is to enhance the target topic node, the baseline vector of the target topic node is multiplied by a coefficient greater than 1; if the intervention description is to replace the target topic node, the topic node representation vector of the target topic node sampled from other documents is used as the replacement vector. According to the topological order of the global causal graph, the topic representation vectors of the downstream topic nodes affected by the intervention are recalculated, while the baseline vectors of the unaffected topics remain unchanged, resulting in a set of counterfactual topic vectors. Input the set of counterfactual topic vectors into the generator, select zero noise to generate counterfactual text; calculate the change in the representation vector of each topic node before and after the intervention, identify topic nodes whose representation vector change is greater than a preset value and mark the degree of representation vector change; Text alignment techniques are used to display the differences between the target document and the counterfactual text in the form of highlights or marks; Generate a natural language causal explanation; the natural language causal explanation is used to explain the mechanism by which the intervention of the target topic leads to changes in the text content.

11. The method according to claim 1, characterized in that, The method further includes: Obtain the specified starting topic node, and from the pre-trained global causal graph, filter all descendant topic nodes that are rooted at the starting topic node and reachable by directed paths, as well as directed connection edges between topic nodes, to form a causal subgraph; Perform a topological sort on the topic nodes in the causal subgraph to generate an ordered list of descendant topic nodes; Using the starting topic node as the root node, add descendant topic nodes layer by layer according to the topological sorting in the ordered list, connect each descendant topic node to the parent node pointing to the descendant topic node in the causal subgraph, and mark the corresponding causal strength score on the connection edge; Calculate the influence breadth of the starting topic node, and count the number of topic nodes that directly influence the topic node, the number of topic nodes that indirectly influence the topic node, and the total number of topic nodes that influence the topic node. Identify intermediate topic nodes whose in-degree and out-degree are both greater than preset values; the intermediate topic nodes are topic nodes that connect multiple causal paths; Determine the longest causal chain from the starting topic node to the leaf node, record the path sequence and path length, and generate a visualization chart.

12. A text analysis device based on causal relationships and multi-layered topic understanding, characterized in that, The device includes: The preprocessing module is used to receive the target document to be analyzed, preprocess the target document, and obtain standardized target text. The input module is used to input the standardized target text into the pre-trained causal topic model. The causal topic model includes a pre-trained global causal graph, a directional mask graph neural network, a cross-layer information fusion mechanism, and a mapping relationship between fine-grained topic layers and abstract topic layers. The first processing module is used to extract topic nodes in the standardized target text based on the global causal graph using the directional mask graph neural network, and to match the set of parent nodes of each topic node in the global causal graph, and to aggregate the causal information of the parent nodes to obtain the target topic representation vector. The second processing module is used to map the target topic representation vector to the corresponding fine-grained topic and abstract topic respectively based on the mapping relationship between the fine-grained topic layer and the abstract topic layer, and call the cross-layer information fusion mechanism to pass the global context information of the abstract topic to the corresponding fine-grained topic to obtain the target final topic representation that integrates multi-granularity information. The output module is used to output the multi-granularity topic structure of the target document and the directed causal inference results between topics based on the target final topic representation and the global causal graph.

13. A control device, characterized in that, It includes a processor and a memory, the memory being used to store programs, instructions, or code, and the processor being used to execute the programs, instructions, or code in the memory to perform the text analysis method based on causal relationships and multi-layered topic understanding as described in any one of claims 1-11.

14. A computer-readable storage medium, characterized in that, The system contains a computer program that is loaded by a processor to execute the text analysis method based on causality and multi-layered topic understanding as described in any one of claims 1-11.