An event relation explainability analysis method, system, device, medium and product based on a large language model
Patent Information
- Application Number
- CN202610815520.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-08
- Publication Date
- 2026-08-21
AI Technical Summary
[0005]本申请的目的是提供一种基于大语言模型的事件关系可解释性分析方法、系统、设备、介质及产品,以解决模型决策过程透明度低、可解释性不足的问题
本申请通过构建反事实文本对,有效控制了事件关系变量,将大语言模型中间层隐藏状态映射为稀疏激活向量并计算激活敏感性,精准筛选出与目标事件关系对应的关系敏感基向量,从而直观揭示大语言模型内部对事件关系的编码机制;进一步通过对关系敏感基向量对应激活值执行干预操作,将干预后的稀疏激活向量解码重构为干预后的隐藏状态并输入后续层分析大语言模型输出变化,提取关系敏感基向量索引集合在反事实文本对上的各基向量激活值,生成特征向量与对应标签,训练大语言模型,确定训练后的大语言模型,充分验证了关系敏感基向量对目标事件关系的表征能力,在不改变模型原有架构与性能的前提下,提升了大语言模型事件关系抽取过程的透明度与可解释性,为下游事件关系理解与抽取任务提供了可靠、可追溯且具有明确物理意义的内部表示依据。
Smart Images

Figure CN122616640A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of natural language processing technology, and in particular to a method, system, device, medium and product for interpretability analysis of event relationships based on a large language model. Background Technology
[0002] Event relation extraction is an important task in the field of natural language processing, aiming to identify structural relationships such as causality, temporal sequence, and sub-events between events in text. With the rapid development of Large Language Models (LLMs), LLM-based event relation extraction methods have made significant progress in various tasks.
[0003] Existing methods for extracting event relationships can be broadly categorized into two types: one is based on fine-tuning, which involves adding a classification layer to a pre-trained model and then conducting supervised training; the other is based on cue-based learning, which guides the language model to output relationship types by designing specific cue templates. These methods have achieved good performance on standard evaluation datasets.
[0004] However, existing research has paid relatively little attention to the interpretability of event relationships themselves, especially at the level of internal model representation. Current interpretability analysis methods mostly focus on the interpretation of event detection or the generation of interpretive analysis using event knowledge. The two key questions—whether large language models encode event relationships with identifiable, relation-sensitive internal features, and whether these features functionally support the understanding of event relationships and model performance—remain unexplored. This results in low transparency and insufficient interpretability in the model decision-making process, becoming a pressing technical problem that needs to be addressed. Summary of the Invention
[0005] The purpose of this application is to provide a method, system, device, medium, and product for interpretability analysis of event relationships based on a large language model, in order to solve the problems of low transparency and insufficient interpretability in the model decision-making process.
[0006] To achieve the above objectives, this application provides the following solution: Firstly, this application provides a method for interpretability analysis of event relationships based on a large language model, including: S1, construct a set of counterfactual text pairs for the target event relationship type; the set of counterfactual text pairs includes positive samples and negative samples; S2, based on the counterfactual text pair set, extract the hidden states of the intermediate layer of the large language model and map them into sparse activation vectors, calculate the activation sensitivity of each basis vector in the sparse activation vector to the target event relationship, and filter the set of relationship-sensitive basis vector indices corresponding to the target event relationship; S3, according to the relation-sensitive basis vector index set, perform intervention operations on the corresponding basis vector activation values, reconstruct the sparse activation vectors after intervention into the hidden state after intervention, and input them into the subsequent layers of the large language model to analyze the output changes of the large language model; S4. Based on the analysis results of the changes in the output of the large language model, extract the activation values of each basis vector in the counterfactual text pair of the relation-sensitive basis vector index set, generate feature vectors and corresponding labels, train the large language model, and determine the trained large language model; the trained large language model is used to analyze the representation ability of the relation-sensitive basis vectors on the relationship of the target event.
[0007] Secondly, this application provides an event relation interpretability analysis system based on a large language model, including: A counterfactual text pair set construction module is used to construct a counterfactual text pair set for a target event relationship type; the counterfactual text pair set includes positive samples and negative samples. The relation-sensitive basis vector index set determination module is used to extract the hidden states of the intermediate layer of the large language model and map them into sparse activation vectors based on the counterfactual text pair set, calculate the activation sensitivity of each basis vector in the sparse activation vector to the target event relation, and filter the relation-sensitive basis vector index set corresponding to the target event relation. The large language model output change analysis module is used to perform intervention operations on the activation values of each corresponding basis vector according to the relation-sensitive basis vector index set, reconstruct the sparse activation vectors after intervention into the hidden state after intervention, and input them into the subsequent layers of the large language model to analyze the output changes of the large language model. The large language model training module is used to extract the activation values of each basis vector in the counterfactual text pairs based on the analysis results of the changes in the output of the large language model, generate feature vectors and corresponding labels, train the large language model, and determine the trained large language model; the trained large language model is used to analyze the representation ability of the relation-sensitive basis vectors on the relationship of the target event.
[0008] Thirdly, this application provides a computer device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the above-described event relation interpretability analysis method based on a large language model.
[0009] Fourthly, this application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the above-described event relation interpretability analysis method based on a large language model.
[0010] Fifthly, this application provides a computer program product, including a computer program that, when executed by a processor, implements the above-described event relation interpretability analysis method based on a large language model.
[0011] According to the specific embodiments provided in this application, this application has the following technical effects: This application effectively controls event relationship variables by constructing counterfactual text pairs, maps the hidden states of the intermediate layers of a large language model to sparse activation vectors, and calculates activation sensitivity. It accurately selects the relationship-sensitive basis vectors corresponding to the target event relationship, thus intuitively revealing the encoding mechanism of event relationships within the large language model. Furthermore, by intervening in the activation values corresponding to the relationship-sensitive basis vectors, the application decodes and reconstructs the intervened sparse activation vectors into the intervened hidden states, which are then input into subsequent layers to analyze changes in the output of the large language model. It extracts the activation values of each basis vector in the relationship-sensitive basis vector index set on the counterfactual text pairs, generates feature vectors and corresponding labels, trains the large language model, and determines the trained large language model. This fully verifies the representational ability of the relationship-sensitive basis vectors for the target event relationship. Without changing the original model architecture and performance, it improves the transparency and interpretability of the event relationship extraction process of the large language model, providing a reliable, traceable, and physically meaningful internal representation basis for downstream event relationship understanding and extraction tasks. Attached Figure Description
[0012] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the embodiments 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.
[0013] Figure 1 A flowchart illustrating an event relationship interpretability analysis method based on a large language model, provided in an embodiment of this application; Figure 2 A schematic diagram illustrating the overall logic of data construction, hidden state extraction, sparse coding, relation-sensitive basis vector identification, and subsequent intervention verification and model training provided in an embodiment of this application; Figure 3 A schematic diagram illustrating the counterfactual text pair construction and basis vector selection process provided in an embodiment of this application; Figure 4 This is a schematic diagram illustrating the basis vector functionality verification and event relationship extraction process based on activation features provided in an embodiment of this application. Detailed Implementation
[0014] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0015] To make the objectives, features and advantages of this application more apparent and understandable, the application will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0016] like Figure 1 As shown, this application provides a method for interpretability analysis of event relationships based on a large language model, including: S1, construct a set of counterfactual text pairs for the target event relationship type; the set of counterfactual text pairs includes positive samples and negative samples.
[0017] S2, based on the counterfactual text pair set, extract the hidden states of the intermediate layer of the large language model and map them into sparse activation vectors, calculate the activation sensitivity of each basis vector in the sparse activation vectors to the target event relationship, and filter the set of relation-sensitive basis vector indices corresponding to the target event relationship.
[0018] S3, based on the set of relation-sensitive basis vector indices, perform intervention operations on the corresponding basis vector activation values, reconstruct the sparse activation vectors after intervention into the hidden state after intervention, and input them into the subsequent layers of the large language model to analyze the changes in the output of the large language model.
[0019] S4. Based on the analysis results of the changes in the output of the large language model, extract the activation values of each basis vector in the counterfactual text pair of the relation-sensitive basis vector index set, generate feature vectors and corresponding labels, train the large language model, and determine the trained large language model; the trained large language model is used to analyze the representation ability of the relation-sensitive basis vectors on the relationship of the target event.
[0020] This application first constructs counterfactual text pairs covering three relation types: causal, temporal, and sub-event, and modifies the relation expression through minimal editing. Then, a sparse autoencoder is used to map the activations of the intermediate layers of a large language model into sparse activation vectors. The sensitivity of each basis vector is calculated through counterfactual comparison, and relation-sensitive basis vectors corresponding to the target event relation are selected. Further intervention is applied to these relation-sensitive basis vectors, suppressing or enhancing their activation values, and their impact on the model output is analyzed. Finally, the model is trained based on the selected relation-sensitive basis vectors for the event relation extraction task. This method reveals the encoding mechanism of event relations within the large language model, improving the transparency and interpretability of model decisions.
[0021] In one exemplary embodiment, counterfactual text pairs are constructed for a target event relationship type, the counterfactual text pairs including positive samples. and negative samples .in, For sample index, , The number of counterfactual text pairs; the positive samples The negative sample contains the target event relationship. While maintaining basic consistency in event entities, event trigger words, and event content, the expression of target event relationships is removed, replaced, or weakened through minimal editing operations. S1 specifically includes: S11, Obtain the event relationship dataset and generate the raw corpus.
[0022] S12, based on the original corpus, perform minimal editing operations on each event relationship instance, removing, replacing, or weakening relationship expression words to generate the negative sample, and maintain consistency with the positive sample in terms of event entities, event trigger words, and event content, thus constructing a counterfactual text pair set. ;in, This represents a set of counterfactual text pairs. Indicates the first A positive sample containing the relationship of the target event. Indicates the first A negative sample obtained through minimal edit operations. Indicates the number of counterfactual text pairs.
[0023] Furthermore, an event relationship dataset is obtained, wherein the event relationship types include one or more of causal relationships, temporal relationships, and sub-event relationships; for each event relationship instance, a counterfactual text pair is constructed, wherein the counterfactual text pair includes positive samples and negative samples.
[0024] Positive samples contain the target event relationship, while negative samples, while maintaining the basic consistency of event entities, event trigger words, event content and contextual semantics, remove, replace or weaken the original target event relationship by removing, replacing or weakening relation expression words, relation trigger words or relation connection methods.
[0025] Minimal editing operations include removing relational expressions, replacing relational connectors, weakening relational triggers, or adjusting relational connections. For example, for causal relationships, causal expressions such as "cause," "lead to," and "therefore" can be removed or replaced; for temporal relationships, temporal expressions such as "after," "before," and "subsequently" can be removed or replaced; and for sub-event relationships, expressions indicating composition, inclusion, or step relationships can be removed or replaced.
[0026] By using the aforementioned counterfactual text pairs, the event relationship variables can be controlled while maintaining basic consistency in the event content.
[0027] This application constructs counterfactual text pairs containing positive and negative samples, and removes, replaces, or weakens the expression of target event relationships while maintaining the basic consistency of event entities, event trigger words, and event content, thereby achieving effective control over event relationship variables.
[0028] In an exemplary embodiment, the positive and negative samples are input into a large language model, the hidden states of a specified intermediate layer of the large language model are extracted, and the hidden states are mapped to sparse activation vectors using a sparse autoencoder. By comparing the differences in the activation values of each basis vector in the sparse activation vectors corresponding to the positive and negative samples, the activation sensitivity of each basis vector to the target event relationship is calculated, and the relationship-sensitive basis vectors corresponding to the target event relationship are selected. Specifically, S2 includes: S21, the set of counterfactual text pairs is input into a large language model to extract the specified intermediate layer hidden states, and sparse activation vectors are generated using a sparse autoencoder mapping. ,in, This represents the total number of basis vectors in the sparse autoencoder. Indicates the first basis vectors activation value, k∈[1, K] , Represents the first in the sparse autoencoder decoder basis vectors This is the index of the basis vector.
[0029] S22, based on the sparse activation vector, for the... A counterfactual text Calculate the first basis vectors activation sensitivity Generate sensitivity sequences; where, Indicates the first The basis vectors in the positive samples The activation value on Indicates the first basis vectors in negative samples The activation value on.
[0030] S23, based on the sensitivity sequence pair N The average of the counterfactual text pairs is obtained to get the first... k Average activation sensitivity of basis vectors And based on the average activation sensitivity, filter the set of relation-sensitive basis vector indices corresponding to the relationship with the target event.
[0031] Furthermore, for a specified intermediate layer of the large language model, hidden states are extracted, and the hidden states are mapped to sparse activation vectors using a sparse autoencoder.
[0032] For the A counterfactual text Calculate the first basis vectors The activation sensitivity can be measured by using methods that do not distinguish between directions of activation changes. As a sensitivity measure.
[0033] right The average of the counterfactual text pairs is obtained to get the first... The average activation sensitivity of the basis vectors.
[0034] In an exemplary embodiment, the activation values corresponding to the selected relation-sensitive basis vectors are intervened; during suppression intervention, the corresponding activation values are set to zero; during enhancement intervention, the corresponding activation values are amplified according to a preset amplification factor; the sparse activation vectors after intervention are decoded and reconstructed into hidden states by a sparse autoencoder, and then input into subsequent layers of the large language model for further forward propagation to analyze the impact of the intervention on the model output. Step S23, followed by: S24, calculate the... activation sufficiency index of basis vectors Activation exclusionary indicators Features represent confidence levels ;in, ; ; .
[0035] Furthermore, set an activation threshold. Calculate the first activation sufficiency index of basis vectors Activation exclusionary indicators Features represent confidence levels .in, Used to characterize the first positive sample text containing the target event relationship. The proportion of basis vector activation values exceeding the threshold; Used to characterize negative sample text that does not contain the target event relationship or whose target event relationship has been changed, the first The proportion of basis vector activation values that do not exceed the threshold.
[0036] in, This indicates an indicator function that takes the value 1 when the condition inside the parentheses is true, and 0 otherwise. Indicates the preset activation threshold; Indicates the first The feature representation of each basis vector is the confidence level.
[0037] Based on average sensitivity Features represent confidence levels Sort the basis vectors and select the top-ranked ones as relation-sensitive basis vectors. Specifically, prioritize those that simultaneously satisfy... Larger higher higher and Higher-order basis vectors form a set of relation-sensitive basis vector indices: in, This represents the set of indexes of relation-sensitive basis vectors selected from the filtering. This represents the number of relation-sensitive basis vectors selected. For any... Its corresponding relation-sensitive basis vector is .
[0038] Through the above steps, relation-sensitive basis vectors that have a stable correspondence with the target event relationship can be selected from the basis vectors learned by the sparse autoencoder, thereby revealing the encoding mechanism of event relationships within the large language model.
[0039] This application reveals the way the model encodes event relationships by mapping the hidden states of the intermediate layers of a large language model to sparse activation vectors and comparing the activation differences between positive and negative samples in counterfactual text pairs to select relation-sensitive basis vectors that correspond to the target event relationship.
[0040] In an exemplary embodiment, S3 specifically includes: S31, based on the set of relation-sensitive basis vector indices, locate the target basis vectors and perform suppression intervention on any target basis vector. or implement enhanced intervention Generate the sparse activation vector after intervention; where, , This is the preset magnification factor. The sparse activation vector after intervention. For the first basis vectors The activation value.
[0041] S32, input the intervened sparse activation vector into the sparse autoencoder decoding function to generate the intervened hidden state. ;in, This is the decoding function for a sparse autoencoder.
[0042] S33, the hidden state after the intervention is input into the subsequent layers of the large language model to continue forward propagation, generating the output of the model after the intervention.
[0043] S34. Analyze the changes in the output of the large language model based on the differences between the model output before and after the intervention; the changes in the output of the large language model are used to characterize the functional role of the relation-sensitive basis vector in the model's event relation judgment results.
[0044] Furthermore, during the forward propagation of the model, a sparse autoencoder is used to map the hidden states of the specified intermediate layers of the large language model into sparse activation vectors, and intervention is performed on the activation values corresponding to the selected relation-sensitive basis vectors.
[0045] Let the set of indexes of the relation-sensitive basis vectors selected be: For any , No. The relation sensitivity basis vectors are denoted as follows: The corresponding activation value is denoted as .
[0046] Let the sparse activation vector before intervention be: Let the sparse activation vector after intervention be: in, This represents the total number of basis vectors in the sparse autoencoder.
[0047] During inhibitory intervention, for any Set its corresponding activation value to zero: When enhancing intervention, for any Multiply its corresponding activation value by a preset amplification factor. : In one specific implementation, Option 2 is acceptable.
[0048] In the control experiment, for any , keep the first The activation values corresponding to the relation-sensitive basis vectors remain unchanged: For other basis vectors that do not belong to the set of relation-sensitive basis vector indices, i.e. Its corresponding activation value remains unchanged: The sparse activation vector after intervention Reconstructing the hidden state through decoding with a sparse autoencoder: in, This represents the decoding function of the sparse autoencoder. It reconstructs the hidden state. The input large language model continues to propagate forward to the subsequent layers, obtaining the model output after intervention. By comparing the changes in the model output before and after intervention, the functional role of the relation-sensitive basis vector in the model's event relation judgment results is analyzed.
[0049] If suppressing the activation value corresponding to the relation-sensitive basis vector reduces the model's ability to judge the relationship of the target event, it indicates that the relation-sensitive basis vector plays a necessary role in judging the relationship of the target event; if increasing the activation value corresponding to the relation-sensitive basis vector enhances the model's response to the relationship of the target event, it indicates that the relation-sensitive basis vector has a promoting effect on judging the relationship of the target event.
[0050] This application verifies the functional role of the activation values corresponding to the relationship-sensitive basis vectors in the model's event relationship judgment results by suppressing or enhancing them; at the same time, it uses their activation values as explicit features to train the classification model to verify its ability to represent the target event relationship.
[0051] In an exemplary embodiment, based on the selected relation-sensitive basis vectors, their activation values on counterfactual text pairs are extracted as features. A large language model is trained for the event relation extraction task, and the representation ability of the relation-sensitive basis vectors for the target event relations is verified. Specifically, S4 includes: S41, based on the aforementioned set of relation-sensitive basis vector indices, for the... A counterfactual text Construct positive sample feature vectors and negative sample feature vectors respectively.
[0052] S42, assign positive sample labels to the positive sample feature vectors and negative sample labels to the negative sample feature vectors to generate a training dataset.
[0053] S43, Perform supervised learning based on the training dataset to generate a trained large language model.
[0054] S44. Calculate the classification accuracy, precision, recall, or F1 score of the trained large language model based on the test dataset, and analyze the representation ability of the relation-sensitive basis vectors to the target event relations; the representation ability of the relation-sensitive basis vectors to the target event relations is used to confirm the effectiveness of the representation of the target event relations by the relation-sensitive basis vectors.
[0055] Furthermore, based on the selected relation-sensitive basis vectors, their activation values on counterfactual text pairs are extracted as features, and a large language model is trained for the event relation extraction task. The large language model can also be replaced by any one of support vector machines, neural networks, or traditional machine learning methods to verify the representation ability of the relation-sensitive basis vectors for the target event relations.
[0056] Let the set of indexes of the relation-sensitive basis vectors selected be: in, Represents the set of relation-sensitive basis vector indices. This represents the number of relation-sensitive basis vectors selected. For any... , No. The basis vectors are denoted as . In the text The activation value on is denoted as .
[0057] For the A counterfactual text Construct feature vectors for positive samples and feature vectors for negative samples respectively: in, Indicates the first The basis vectors in the positive samples The activation value on Indicates the first basis vectors in negative samples The activation value on.
[0058] With positive sample feature vectors and negative sample feature vectors As input, the text contains the target event relationship as a label to train a large language model; positive samples are labeled as 1, indicating that the target event relationship is contained, and negative samples are labeled as 0, indicating that the original target event relationship has been removed, replaced or weakened.
[0059] After training, the ability of the relation-sensitive basis vectors to represent the relationship of the target event is verified by classification accuracy, precision, recall or F1 score.
[0060] Training samples are constructed using feature vectors as input and whether the text contains a target event relationship as a label. For positive samples... Its label is recorded as: This indicates that the text contains a target event relationship; for negative samples Its label is recorded as: This indicates that the text does not contain the original target event relationship, or that the original target event relationship has been removed, replaced, or changed. This yields the training dataset: A classification model is trained based on the training dataset. After training, the selected relationship-sensitive basis vectors are verified to effectively represent the relationships of the target events by measuring the model's classification accuracy, precision, recall, or F1 score on the test set.
[0061] Through the above steps, the sparse activation features related to the target event relationship within the large language model can be transformed into explicit features that can be used for classification tasks. This verifies the ability of relation-sensitive basis vectors to represent event relationships and provides an interpretable internal representation basis for the event relationship extraction task.
[0062] To address the problems of insufficient model interpretability, lack of structured event relationship analysis capabilities, and insufficient utilization of internal model knowledge in existing event relationship extraction methods, this application achieves interpretability analysis of event relationships by constructing counterfactual text pairs, identifying relationship-sensitive basis vectors, performing basis vector intervention, and training a large language model, and verifies the ability of the identified basis vectors to represent the target event relationships.
[0063] This application not only focuses on the results of event relationship extraction, but also further analyzes the representation features related to event relationships within the large language model, which can improve the transparency and interpretability of the model's event relationship judgment process.
[0064] Furthermore, this application, through counterfactual comparison and basis vector intervention, can both identify sensitive basis vectors related to the target event and verify their functional role in the model output.
[0065] Furthermore, this application transforms the activation values of relation-sensitive basis vectors into explicit features that can be used for classification tasks, providing an interpretable internal representation basis for event relation extraction.
[0066] To gain a clearer understanding of the technical features, objectives, and effects of this application, the following will be combined with... Figures 2 to 4 The specific implementation methods of this application will be described. Figures 2 to 4 The technical solution of this application is presented from three aspects: overall process, relation-sensitive basis vector identification, and basis vector intervention verification and application. Figure 2 The overall logic of data construction, hidden state extraction, sparse coding, relation-sensitive basis vector identification, and subsequent intervention verification and model training is presented. Figure 3 Further, we will explore the process of constructing counterfactual text pairs and selecting basis vectors. Figure 4 The functional verification of basis vectors and the extraction of event relationships based on activation features are further elaborated. The three figures form a continuous technical chain from data control, internal representation recognition, functional verification to downstream task applications.
[0067] In one specific implementation, this application first obtains an event relationship dataset, wherein the event relationship types include one or more of causal relationships, temporal relationships, and sub-event relationships. For each event relationship instance, minimal editing operations are performed to construct counterfactual text pairs. The counterfactual text pairs include positive samples containing the target event relationship and negative samples that remove, replace, or weaken the target event relationship. The positive and negative samples maintain basic consistency in event entities, event trigger words, event content, and contextual semantics, differing only in relation expression words, relation trigger phrases, or relation connection methods, thus keeping the event content factors basically stable while the target event relationship variables change.
[0068] Let the set of counterfactual text pairs be: in, Indicates the sample index. Indicates the number of counterfactual text pairs. Indicates the first A positive sample containing the relationship of the target event. Indicates the first These are negative samples obtained by removing, replacing, or weakening the target event relationships through minimal editing. Using these counterfactual text pairs, the event relationship variables can be controlled while maintaining basic consistency in event content, providing controllable comparison samples for the subsequent analysis of the encoding mechanism of event relationships within the model.
[0069] After constructing the counterfactual text pairs, positive and negative samples are input into a large language model, and the hidden states of a specified layer are extracted during the model's forward propagation. Subsequently, a sparse autoencoder is used to encode these hidden states, mapping them to sparse activation vectors for the specified intermediate layers of the large language model. Each dimension of the sparse activation vector corresponds to the activation value of a basis vector. For the same counterfactual text pair, separate sparse activation vectors are obtained for positive and negative samples.
[0070] The identification of relation-sensitive basis vectors is based on the difference between the sparse activation vectors of positive and negative samples. For the th A counterfactual text Calculate the first basis vectors Activation sensitivity on this counterfactual text pair: in, Indicates the first basis vectors In positive samples The activation value on Indicates the first basis vectors In negative samples The activation value on the surface. If it is necessary to measure activation changes regardless of direction, then... As a sensitivity measure.
[0071] Furthermore, on The average of the counterfactual text pairs is obtained to get the first... The average activation sensitivity of each basis vector to the target event relation: Based on the average activation sensitivity calculation, the third... activation sufficiency index of basis vectors Activation exclusionary indicators and feature representation confidence .in, This indicates the proportion of basis vector activation values exceeding a threshold in positive sample text containing the target event relationship. This indicates the proportion of basis vector activation values that do not exceed a threshold in negative sample text that does not contain the target event relationship or whose target event relationship has been altered. for and Harmonic average: in, Indicates the activation threshold. Indicates an indicator function. According to... Value or average activation sensitivity The basis vectors are sorted and filtered, and the top-ranked basis vectors are selected as relation-sensitive basis vectors, forming a relation-sensitive basis vector index set.
[0072] After completing the relation-sensitive basis vector screening, this application follows Figure 1 and Figure 3 The two branches shown undergo further processing: on the one hand, basis vector intervention is performed to verify its functional role in the model output; on the other hand, its activation values are extracted as features to train a classification model to verify its ability to represent the event relationship extraction task. Both branches are based on the selected relationship-sensitive basis vectors, but they have different verification perspectives: the former focuses on their impact on the model output, while the latter focuses on their ability to represent the target event relationships.
[0073] In the basis vector intervention branch, during the model forward propagation, a sparse autoencoder is used to map the hidden states of a specified layer into sparse activation vectors. Suppression, enhancement, or control experiments are then performed on the activation values corresponding to the selected relation-sensitive basis vectors. During suppression, the corresponding activation value is set to zero; during enhancement, the corresponding activation value is multiplied by a preset amplification factor. ,in In one specific implementation, A value of 2 can be selected; in the control experiment, the corresponding activation value should remain unchanged.
[0074] After intervention, the sparse activation vectors after intervention are decoded and reconstructed into hidden states using a sparse autoencoder, and then input into subsequent layers of the large language model for further forward propagation to obtain the model output. By comparing the changes in the model output before and after intervention, the functional role of the relation-sensitive basis vectors in the model's event relationship judgment results is analyzed. If suppressing the activation values corresponding to the relation-sensitive basis vectors reduces the model's ability to judge target event relationships, it indicates that the basis vectors play a necessary role in event relationship recognition; if enhancing the activation values corresponding to the relation-sensitive basis vectors enhances the model's response to target event relationships, it indicates that the basis vectors have a promoting effect on event relationship recognition.
[0075] In the model training branch, based on the selected relation-sensitive basis vectors, their activation values on counterfactual text pairs are extracted as features to form feature vectors for event relation extraction. These feature vectors can be input into a classification model for training. The classification model is not limited to a specific model and can be any of support vector machines, neural networks, large language models, or traditional machine learning methods. After training, the selected relation-sensitive basis vectors are validated using metrics such as classification accuracy, precision, recall, or F1 score on the test set to determine whether they effectively represent the target event relations.
[0076] Therefore, this application controls event relation variables through counterfactual text pairs, locates relation-sensitive basis vectors in the intermediate layer representation space of a large language model using a sparse autoencoder, and verifies its functional role and representational ability through basis vector intervention and classification model training, respectively. The above process can reveal the encoding mechanism of event relations within the large language model, improve the transparency and interpretability of the event relation judgment process, and provide usable internal representation features for event relation extraction tasks.
[0077] In a specific application example, taking causal relationship identification as an example, the target event relationship type is causal relationship. To illustrate the execution process of the method in this application, a set of counterfactual text pairs is selected for explanation. The positive sample is: <event type="Motion"> flash flooding< / event> in Kentucky caused <event type="Damaging"> 5million in damage< / event> The negative sample is:<event type="Motion"> flash flooding< / event> occurred in Kentucky alongside <event type="Damaging"> 5 million damage< / event> ".in, <event type="Motion"> ...< / event> and <event type="Damaging"> ...< / event> This is used to annotate event fragments and their event types in text. Other event annotation formats can also be used in practical applications.
[0078] In the above positive samples, "caused" refers to both "flash flooding" and " There is a causal relationship between “5 million in damage”; in the above negative sample, “caused” is replaced with “occurred alongside” to weaken or remove the explicit causal relationship between the two events, while keeping the event fragments, event types and event content basically consistent.
[0079] The positive and negative samples are input into the large language model, and the hidden states of the eighth intermediate layer are extracted. After mapping the hidden states to sparse activation vectors using a sparse autoencoder, the activation values of the corresponding basis vectors in the positive and negative samples are compared to obtain the activation sensitivity of each basis vector to the target causal relationship. In this specific application example, the activation sensitivities of some basis vectors are shown in Table 1.
[0080] Table 1
[0081] In this specific application example, since the number of counterfactual text pairs is 1, the average activation sensitivity is equal to the activation difference between the positive and negative samples. Based on the above activation sensitivity sorted from high to low, a set of relation-sensitive basis vector indices can be obtained, for example, {61726, 173481, 163833, 21018, 91151}. These relation-sensitive basis vectors exhibit a large activation difference between positive and negative samples, indicating that they are highly sensitive to the expression of causal relationships.
[0082] Furthermore, intervention operations were performed on the five relation-sensitive basis vectors obtained from the above screening, and the large language model was instructed to determine whether a causal relationship existed between two events in the positive samples. Specifically, in the enhancement intervention, the activation values of the above relation-sensitive basis vectors were enhanced, and the inference was repeated 10 times. In all 10 instances, the model determined that "flash flooding" and " There is a causal relationship between “5 million in damage”; in the suppression intervention, after the activation values of the above relationship sensitive basis vectors are ablated or set to zero, the inference is repeated 10 times. The model judges that there is a causal relationship between the two 7 times and fails to judge that there is a causal relationship 3 times.
[0083] The above results indicate that enhancing the activation values of the relation-sensitive basis vectors improves the stability of the model's judgment of the target causal relationship; suppressing the activation values of the relation-sensitive basis vectors weakens the model's tendency to judge the target causal relationship. Therefore, the relation-sensitive basis vectors play a functional role in the model's identification of causal relationships.
[0084] In the model training branch, the actual activation values of the aforementioned relation-sensitive basis vectors on positive and negative samples can be used to construct positive and negative sample feature vectors, respectively, and assigned labels 1 and 0, where label 1 indicates that the text contains the target causal relationship, and label 0 indicates that the target causal relationship has been removed, replaced, or weakened. By repeatedly performing the above process on multiple counterfactual text pairs, a training dataset can be generated, and a classification model or event relationship recognition model can be trained to verify the representation ability of the relation-sensitive basis vectors for the target event relationship.
[0085] It should be noted that the aforementioned set of counterfactual text pairs, the eighth-layer intermediate representation, the five relation-sensitive basis vectors, and the results of ten repeated inferences are only used to illustrate the execution process of the method in a specific application example and do not constitute a limitation on the number of input texts, the specified layer position, the number of basis vectors, the number of repeated inferences, the model type, the judgment threshold, or the intervention method. In practical applications, the above steps can be repeated for multiple counterfactual text pairs and one or more specified intermediate layers, and relation-sensitive basis vectors can be selected based on average activation sensitivity, activation sufficiency, activation exclusion, or feature representation confidence.
[0086] This application provides an event relation interpretability analysis system based on a large language model, including: The counterfactual text pair set construction module is used to construct a counterfactual text pair set for a target event relationship type; the counterfactual text pair set includes positive samples and negative samples.
[0087] The relation-sensitive basis vector index set determination module is used to extract the hidden states of the intermediate layer of the large language model and map them into sparse activation vectors based on the counterfactual text pair set, calculate the activation sensitivity of each basis vector in the sparse activation vector to the target event relation, and filter the relation-sensitive basis vector index set corresponding to the target event relation.
[0088] The large language model output change analysis module is used to perform intervention operations on the activation values of each corresponding basis vector according to the relation-sensitive basis vector index set, reconstruct the sparse activation vectors after intervention into the hidden state after intervention, and input them into the subsequent layers of the large language model to analyze the output changes of the large language model.
[0089] The large language model training module is used to extract the activation values of each basis vector in the counterfactual text pairs based on the analysis results of the changes in the output of the large language model, generate feature vectors and corresponding labels, train the large language model, and determine the trained large language model; the trained large language model is used to analyze the representation ability of the relation-sensitive basis vectors on the relationship of the target event.
[0090] The overall approach of this application is as follows: First, counterfactual text pairs are constructed. While maintaining the basic consistency of event entities, event trigger words, and event content, the expression of target event relationships is removed, replaced, or weakened through minimal editing operations to achieve effective control over event relationship variables. Then, a sparse autoencoder is used to map the hidden states of the intermediate layers of the large language model into sparse activation vectors. Relation-sensitive basis vectors corresponding to the target event relationships are selected through counterfactual comparison. Furthermore, the activation values corresponding to the relation-sensitive basis vectors are suppressed or enhanced, and their impact on the model output is analyzed. Finally, the large language model is trained based on the selected relation-sensitive basis vector activation values for the event relationship extraction task.
[0091] In an exemplary embodiment, a computer device is provided, including a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the steps in the above-described method embodiments. The computer device can be a server or a terminal. The computer device includes a processor, a memory, an input / output interface (I / O), and a communication interface. The processor, memory, and I / O interface are connected via a system bus, and the communication interface is connected to the system bus via the I / O interface. The processor of the computer device provides computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and computer program in the non-volatile storage medium. The database of the computer device stores data to be processed. The I / O interface of the computer device is used for exchanging information between the processor and external devices. The communication interface of the computer device is used for communicating with an external terminal via a network connection. When the computer program is executed by the processor, it implements the above-described methods.
[0092] In one exemplary embodiment, a computer-readable storage medium is provided storing a computer program that, when executed by a processor, implements the steps in the above-described method embodiments.
[0093] In one exemplary embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above-described method embodiments.
[0094] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.
[0095] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by hardware related to computer program instructions. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments described above. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM).
[0096] The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0097] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0098] This document uses specific examples to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. Furthermore, those skilled in the art will recognize that, based on the ideas of this application, there will be changes in the specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A method for interpretability analysis of event relationships based on a large language model, characterized in that, include: S1, construct a set of counterfactual text pairs for the target event relationship type; The set of counterfactual text pairs includes positive and negative samples; S2, based on the counterfactual text pair set, extract the hidden states of the intermediate layer of the large language model and map them into sparse activation vectors, calculate the activation sensitivity of each basis vector in the sparse activation vector to the target event relationship, and filter the set of relationship-sensitive basis vector indices corresponding to the target event relationship; S3, according to the relation-sensitive basis vector index set, perform intervention operations on the corresponding basis vector activation values, reconstruct the sparse activation vectors after intervention into the hidden state after intervention, and input them into the subsequent layers of the large language model to analyze the output changes of the large language model; S4. Based on the analysis results of the changes in the output of the large language model, extract the activation values of each basis vector in the counterfactual text pair of the relation-sensitive basis vector index set, generate feature vectors and corresponding labels, train the large language model, and determine the trained large language model; the trained large language model is used to analyze the representation ability of the relation-sensitive basis vectors on the relationship of the target event.
2. The event relationship interpretability analysis method based on a large language model according to claim 1, characterized in that, S1 specifically includes: S11, Obtain the event relationship dataset and generate the raw corpus; S12, based on the original corpus, perform minimal editing operations on each event relationship instance, removing, replacing, or weakening relationship expression words to generate the negative sample, and maintain consistency with the positive sample in terms of event entities, event trigger words, and event content, thus constructing a counterfactual text pair set. ;in, This represents a set of counterfactual text pairs. Indicates the first A positive sample containing the relationship of the target event. Indicates the first A negative sample obtained through minimal edit operations. Indicates the number of counterfactual text pairs.
3. The event relationship interpretability analysis method based on a large language model according to claim 2, characterized in that, S2 specifically includes: S21, the set of counterfactual text pairs is input into a large language model to extract the specified intermediate layer hidden states, and sparse activation vectors are generated using a sparse autoencoder mapping. ,in, This represents the total number of basis vectors in the sparse autoencoder. Indicates the first basis vectors The activation value, k∈[1,K]; S22, based on the sparse activation vector, for the... A counterfactual text Calculate the first basis vectors activation sensitivity Generate sensitivity sequences; where, For the first basis vectors activation sensitivity, Indicates the first The basis vectors in the positive samples The activation value on Indicates the first basis vectors in negative samples The activation value on; S23, averaging the N counterfactual text pairs according to the sensitivity sequence, to obtain the average activation sensitivity of the k-th basis vector. And based on the average activation sensitivity, filter the set of relation sensitivity basis vector indices corresponding to the relationship with the target event; wherein, Let be the average activation sensitivity of the k-th basis vector.
4. The event relationship interpretability analysis method based on a large language model according to claim 3, characterized in that, S23, followed by: S24, calculate the... activation sufficiency index of basis vectors Activation exclusionary indicators Features represent confidence levels ;in , ; ; ;in, As the activation threshold, This is an indicator function.
5. The event relationship interpretability analysis method based on a large language model according to claim 1, characterized in that, S3 specifically includes: S31, based on the set of relation-sensitive basis vector indices, locate the target basis vectors and perform suppression intervention on any target basis vector. or implement enhanced intervention Generate the sparse activation vector after intervention; where, , This is the preset magnification factor. The sparse activation vector after intervention. For the first basis vectors The activation value; S32, input the intervened sparse activation vector into the sparse autoencoder decoding function to generate the intervened hidden state. ;in, This is the decoding function for a sparse autoencoder; The hidden state after intervention; S33, The hidden state after the intervention is input into the subsequent layers of the large language model to continue forward propagation, generating the model output after the intervention; S34. Analyze the changes in the output of the large language model based on the differences between the model output before and after the intervention; the changes in the output of the large language model are used to characterize the functional role of the relation-sensitive basis vector in the model's event relation judgment results.
6. The event relationship interpretability analysis method based on a large language model according to claim 1, characterized in that, S4 specifically includes: S41, based on the aforementioned set of relation-sensitive basis vector indices, for the... A counterfactual text Construct positive sample feature vectors and negative sample feature vectors respectively; where, Indicates the first A positive sample containing the relationship of the target event. Indicates the first One negative sample obtained through minimal edit operations; S42, assign positive sample labels to the positive sample feature vectors and negative sample labels to the negative sample feature vectors to generate a training dataset; S43, Perform supervised learning based on the training dataset to generate a trained large language model; S44. Calculate the classification accuracy, precision, recall, or F1 score of the trained large language model based on the test dataset, and analyze the representation ability of the relation-sensitive basis vectors to the target event relations; the representation ability of the relation-sensitive basis vectors to the target event relations is used to confirm the effectiveness of the representation of the target event relations by the relation-sensitive basis vectors.
7. An event relation interpretability analysis system based on a large language model, characterized in that, The event relation interpretability analysis method based on a large language model as described in any one of claims 1-6 includes: A counterfactual text pair set construction module is used to construct a counterfactual text pair set for a target event relationship type; the counterfactual text pair set includes positive samples and negative samples. The relation-sensitive basis vector index set determination module is used to extract the hidden states of the intermediate layer of the large language model and map them into sparse activation vectors based on the counterfactual text pair set, calculate the activation sensitivity of each basis vector in the sparse activation vector to the target event relation, and filter the relation-sensitive basis vector index set corresponding to the target event relation. The large language model output change analysis module is used to perform intervention operations on the activation values of each corresponding basis vector according to the relation-sensitive basis vector index set, reconstruct the sparse activation vectors after intervention into the hidden state after intervention, and input them into the subsequent layers of the large language model to analyze the output changes of the large language model. The large language model training module is used to extract the activation values of each basis vector in the counterfactual text pairs based on the analysis results of the changes in the output of the large language model, generate feature vectors and corresponding labels, train the large language model, and determine the trained large language model; the trained large language model is used to analyze the representation ability of the relation-sensitive basis vectors on the relationship of the target event.
8. A computer device, comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that the processor executes the computer program to implement the event relation interpretability analysis method based on a large language model according to any one of claims 1-6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the event relation interpretability analysis method based on a large language model as described in any one of claims 1-6.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the event relation interpretability analysis method based on a large language model as described in any one of claims 1-6.