Imbiy detection method and system based on common sense reasoning

Through a method based on common sense reasoning, using search enhancement and large language models to generate common sense content, construct and optimize syntax dependency graphs, and combined with adversarial contrast learning to optimize satirical classifiers, the problem of poor satirical detection accuracy in the existing technology is solved, and higher satirical detection accuracy and robustness are achieved.

CN120144735APending Publication Date: 2025-06-13SUN YAT SEN UNIV
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510071545.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-16
Publication Date
2025-06-13

AI Technical Summary

Technical Problem

The prior art has poor accuracy in satirical detection, is difficult to capture subtle inconsistencies in complex satirical expressions, and is susceptible to noise interference and false associations.

Method used

Using a common sense reasoning method, through retrieval enhancement and large language models, we generate common sense content related to the input text, build syntax dependency graphs and perform graph refinement, perform inconsistent reasoning skeleton processing, and optimize the satirical classifier in combination with adversarial contrast learning.

Benefits of technology

It improves the accuracy of satirical detection, enhances the generalization ability and robustness of the model, and can more accurately identify obscure satirical expressions, reducing the impact of false associations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120144735A_ABST
    Figure CN120144735A_ABST
Patent Text Reader

Abstract

The invention provides an irony detection method and system based on common sense reasoning, and relates to the technical field of natural language processing, and the method comprises the steps: obtaining an entity of an input text, searching background content related to the entity, and carrying out the mixed filtering processing of the background content; constructing a retrieval enhancement prompt based on the mixed filtering content, taking the input prompt as the input of a preset large language model, and outputting common sense content related to the input text; constructing a syntactic dependency graph based on the input text and the common sense content; optimizing the syntactic dependency graph by using a graph refining strategy to obtain a refined graph; the method comprises the following steps: carrying out inconsistent reasoning skeleton processing on a refined diagram, carrying out joint representation on obtained inconsistent sub-diagrams and the refined diagram, obtaining inconsistent fusion features as input of a preset irony classifier, optimizing the irony classifier by introducing confrontation contrast learning, and outputting an irony probability distribution result by using the optimized irony classifier. The irony detection accuracy is effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of natural language processing, and particularly relates to a sarcasm detection method and system based on commonsense reasoning. Background Art

[0002] The popularity of social media has prompted people to be more inclined to express their personal opinions through these platforms. In this context, sarcasm, as a common form of language expression, can indirectly convey emotions or positions contrary to the literal text. Therefore, sarcasm detection plays a key role in grasping the true intentions of users.

[0003] The task of sarcasm detection aims to enable machines to identify content with sarcastic emotions in text. This task is of great significance in multiple application scenarios such as product sentiment analysis, social network opinion analysis, and intention recognition. The key to accurately detecting sarcasm lies in capturing the subtle inconsistencies in the statements. Simple sarcasm usually only involves the literal meaning of the text. However, sarcastic expressions on social platforms are often more complex, with diverse and implicit emotional expressions. Relying solely on shallow text analysis is difficult to reveal the true sarcastic intentions of users. In recent years, identifying sarcasm using commonsense reasoning often relies on knowledge graphs and pre-trained language models. However, the knowledge scope of knowledge graphs is insufficient to cover various and constantly updated sarcastic content in reality; pre-trained language models have a larger knowledge coverage, but they have the phenomenon of hallucination and are easily interfered by noise, which damages the performance; to reason and capture the emotional inconsistencies between commonsense and text, existing methods usually construct a graph structure to capture long-distance dependencies and use graph neural networks to represent this relationship to discover emotional inconsistencies. These coarse-grained overall representations are difficult to depict details and cannot point out which specific parts reflect the emotional inconsistencies; in addition, existing technologies also rely on sarcasm detection models constructed by high-dimensional graph representations for sarcasm detection, but are easily interfered by false associations between keywords and labels. For example, since "praise" frequently appears in sarcastic data, the model may tend to misreport as sarcasm when encountering the word "praise", and this false association affects the generalization ability of the model and the accuracy of judgment. Summary of the Invention

[0004] To solve the problem of poor accuracy in sarcasm detection in the above-mentioned existing technologies, the present invention proposes a sarcasm detection method and system based on commonsense reasoning, effectively improving the accuracy of sarcasm detection.

[0005] To achieve the above technical effects, the technical solution of the present invention is as follows:

[0006] A sarcasm detection method based on commonsense reasoning, comprising the following steps:

[0007] S1. Obtain the entities in the input text, retrieve the background content related to the entities, perform a hybrid filtering process on the background content, and obtain the hybrid filtered content;

[0008] S2. Based on the hybrid filtered content, construct a retrieval enhanced prompt, preprocess the retrieval enhanced prompt to obtain an input prompt, use the input prompt as the input of a preset large language model, and output the common sense content related to the input text;

[0009] S3. Based on the input text and the common sense content, construct a syntactic dependency graph;

[0010] S4. Use the graph refinement strategy to optimize the syntactic dependency graph to obtain a refined graph;

[0011] S5. Perform inconsistent inference skeleton processing on the refined graph to obtain an inconsistent subgraph;

[0012] S6. Jointly represent the inconsistent subgraph and the refined graph to obtain an inconsistent fusion feature, use the inconsistent fusion feature as the input of a preset irony classifier, and optimize the irony classifier by introducing adversarial contrast learning. Use the optimized irony classifier to output the irony probability distribution result.

[0013] Preferably, the hybrid filtering process on the background content includes:

[0014] S11. Use a preset word matching model BM25 and a semantic matching model BERT to calculate the hybrid score f bebm of the articles in the background content, and the expression is as follows:

[0015]

[0016] where α represents a hyperparameter, f bm25 represents the word matching score output by the word matching model BM25, and f bert represents the semantic matching score output by the semantic matching model BERT;

[0017] S12. Determine whether the hybrid score f bebm is lower than a preset threshold ∈. If so, filter the articles in the background content corresponding to the hybrid score f bebm ; if not, execute S13;

[0018] S13. Use the BaRT encoder to perform feature embedding on the articles in the remaining background content after filtering, and generate high-quality representation features as the hybrid filtered content.

[0019] Preferably, constructing the retrieval enhancement prompt based on the hybrid filtered content includes: using the representation feature R of the articles in the hybrid filtered content p , to construct the expression of the retrieval enhancement prompt as follows:

[0020]

[0021] Wherein, represents the output result of the multi-head attention mechanism, MHA represents the head attention mechanism, represents a trainable length control vector, M q represents the first projection matrix, M k represents the second projection matrix, M v represents the third projection matrix, LN represents the layer normalization operation, and FFN represents the feed-forward neural network.

[0022] Preferably, preprocessing the retrieval enhancement prompt to obtain the input prompt has the following calculation expression:

[0023]

[0024] Wherein, represents the task-related generated prompt, represents the entity representation.

[0025] Preferably, constructing a syntactic dependency graph based on the input text and the common sense content includes:

[0026] S31. Converting the input text and the common sense content into an undirected graph where V i represents the conceptual nodes with practical meanings in the text, and E i represents the set of syntactic dependency edges between the nodes;

[0027] S32. Aggregating the undirected graph to obtain a common sense-enhanced syntactic dependency graph

[0028] Preferably, the graph refinement strategy includes a graph enhancement strategy and a graph pruning strategy. Optimizing the syntactic dependency graph using the graph refinement strategy to obtain a refined graph includes:

[0029] S41. Using the graph enhancement strategy to add semantic association edges between the nodes in the syntactic dependency graph;

[0030] S42. Using the graph pruning strategy, prune the semantic association edges between nodes in the syntactic dependency graph according to the meta-path for describing the relationships between different nodes, to obtain a refined graph

[0031] Preferably, the processing of the refined graph to obtain an inconsistent subgraph by inconsistent reasoning skeleton includes:

[0032] S51. Use special markers to split multiple paths between the same node pairs in the refined graph, and then splice the split results into a single input sequence;

[0033] S52. Use the input sequence as the condition and conclusion, input it into a preset entailment checker, and output the prediction result of each path. The prediction result includes a contradiction result indicating obvious inconsistency in the path, a neutral result indicating no obvious causal relationship between paths, and an entailment result indicating logical consistency between the condition and conclusion in the path;

[0034] S53. Select the contradiction results from the prediction results, and sample the node pairs and node pair paths with contradictions as the suspicious inconsistent subgraph

[0035] Preferably, the joint representation of the inconsistent subgraph and the refined graph includes:

[0036] S61. Input the refined graph and the inconsistent subgraph into a preset hierarchical graph attention network, and output the fine-grained inconsistency feature I e and the coarse-grained inconsistency feature I c respectively as follows:

[0037]

[0038] Among them, represents the max pooling operation, represents the semantic attention of the l-th layer in the hierarchical graph attention network, represents the node attention of the l-th layer in the hierarchical graph attention network, represents the fine-grained inconsistency feature output by the l-th layer in the hierarchical graph attention network, represents the coarse-grained inconsistency feature output by the l-th layer in the hierarchical graph attention network, represents the inconsistent subgraph in the meta-path neighbor node set, represents the refined graph in the meta-path neighbor node set;

[0039] S62. Combine the fine-grained inconsistency feature I e and the coarse-grained inconsistency feature I c into an inconsistency fusion feature I f The calculation expression is as follows:

[0040] I f = γI c +(1 - γ)I e

[0041] where γ represents a hyperparameter.

[0042] Preferably, by introducing adversarial contrast learning, the sarcasm classifier is optimized using the total loss function The calculation expression of the total loss function is as follows:

[0043]

[0044] where represents the classification loss function, represents the supervised contrast loss function;

[0045] The calculation expression of the supervised contrast loss function is as follows:

[0046]

[0047] where Λ s represents the sarcasm sample set, represents the feature of the sarcasm sample, Λ n represents the non-sarcasm sample set, represents the feature of the non-sarcasm sample, and τ represents the temperature parameter;

[0048] The calculation expression of the classification loss function is as follows:

[0049]

[0050] where represents the prediction probability distribution result of the sarcasm classifier, and y represents the true label.

[0051] The present invention also proposes a sarcasm detection system based on commonsense reasoning, including:

[0052] An acquisition module, configured to acquire entities of the input text;

[0053] A common sense generation module, which is used to retrieve background content related to the entity, perform hybrid filtering processing on the background content to obtain hybrid filtered content, construct a retrieval enhanced prompt based on the hybrid filtered content, preprocess the retrieval enhanced prompt to obtain an input prompt, use the input prompt as the input of a preset large language model, and output common sense content related to the input text;

[0054] An inconsistency reasoning module, which is used to construct a syntactic dependency graph according to the input text and the common sense content, optimize the syntactic dependency graph by using a graph refinement strategy to obtain a refined graph, perform inconsistency reasoning skeleton processing on the refined graph to obtain an inconsistent subgraph, and jointly represent the inconsistent subgraph and the refined graph to obtain an inconsistent fusion feature;

[0055] An adversarial contrast learning module, which is used to use the inconsistent fusion feature as the input of a preset irony classifier and optimize the irony classifier by introducing adversarial contrast learning;

[0056] An output module, which is used to use the optimized irony classifier to output an irony probability distribution result.

[0057] Compared with the prior art, the beneficial effects of the technical solution of the present invention are as follows:

[0058] The present invention provides an irony detection method and system based on common sense reasoning. First, a retrieval enhanced prompt is constructed by introducing a retrieval enhancement strategy, and the input prompt is obtained by preprocessing the retrieval enhanced prompt. The input prompt is input into a large language model. The purpose is to use the retrieval enhancement and the large language model to work together to obtain common sense content related to the input text from an external knowledge base and supplement the input text. By the retrieval enhancement strategy, not only the quality of the common sense content generated by the large language model is improved, but also the generated common sense content can cover the context information required for irony detection, improving the generalization ability and robustness of the large language model, and thus enhancing the accuracy of irony detection; Secondly, the syntactic dependency graph is optimized by using a graph refinement strategy, improving the expression accuracy of semantic relationships in the syntactic dependency graph, effectively reducing the influence of noise edges, and strengthening the expression of key information, so that the graph structure can more accurately reflect the emotional inconsistency in the text; Then, inconsistency reasoning skeleton processing is performed on the refined graph. The inconsistency reasoning skeleton clearly points out which parts have emotional inconsistency by analyzing the emotional contradictions in the text, so as to more accurately identify implicit ironic expressions; Finally, by introducing adversarial contrast learning, the irony classifier is optimized, optimizing the decision-making process of the irony classifier when dealing with irony detection tasks, reducing the possible false associations between the vocabulary and labels in the dataset, and further improving the accuracy of irony detection. Description of the Drawings

[0059] Figure 1A flowchart showing a sarcasm detection method based on common sense reasoning proposed in an embodiment of the present invention;

[0060] Figure 2 Another flowchart showing a sarcasm detection method based on common sense reasoning proposed in an embodiment of the present invention;

[0061] Figure 3 A structural block diagram showing a sarcasm detection system based on common sense reasoning proposed in an embodiment of the present invention. Detailed implementation manners

[0062] The drawings are only for illustrative purposes and should not be construed as a limitation of this patent;

[0063] For those skilled in the art, it is understandable that some well-known content descriptions in the drawings may be omitted;

[0064] To facilitate the understanding of this embodiment, first, the prior art information of this embodiment is introduced as follows:

[0065] Implicit common sense knowledge refers to facts and emotional relationships that are generally understood by people but do not directly appear in the text. When these key information are lacking, it is difficult for us to discover the implicit emotional inconsistency in the text. Therefore, detecting such complex sarcastic content requires not only a comprehensive understanding of the text semantics but also reasoning with the help of external common sense. However, the current research on sarcasm detection in complex reasoning scenarios is still very weak. For this reason, we propose a new method aimed at filling the research gap in this field and significantly improving the accuracy and applicability of sarcasm detection by integrating semantic understanding and common sense reasoning capabilities.

[0066] In the academic field, sarcasm detection can be divided into two major development stages. The first stage is mainly based on rule-based and statistical machine learning sarcasm detection methods. For example, Riloff E et al. proposed that sarcastic speech usually uses positive verbs or adjectives to imply negative situations. By detecting the inconsistency between words and situations, sarcasm can be accurately detected and the performance of the model can be improved. However, this method relies too much on manually formulated rules and cannot adapt to the wide variety of sarcastic expressions on social networks, resulting in weak generalization ability. On this basis, Joshi A et al. proposed using user comments and sentiment dictionaries to construct explicit and implicit inconsistent features, and used LibSVM classifiers with RBF kernels to detect sarcasm, but this method is not efficient enough. They still rely on manual rules and cannot adaptively capture inconsistent features from text end-to-end. With the development of deep learning, the paradigm based on deep learning has become the mainstream method for sarcasm detection. For example, Hongliang Pan et al. introduced a common attention mechanism to focus on different parts of the text, effectively capturing the implicit negative emotions in a given text; Nastaran Babanejad et al. used the pre-trained language model BERT to enhance the model's ability to capture long-distance dependencies and improve the model's ability to model inconsistencies. However, such methods only studied the semantic information of a given text, ignoring the key role of external common sense in sarcasm detection, which resulted in their inability to identify more obscure sarcastic expressions. Based on this finding, Jiangnan Li et al. first proposed using the pre-trained language model Commonsense Transformer (COMET) to supplement the common sense knowledge directly associated with adjectives or nouns in the text; Yiyi Liu et al. used the sentiment knowledge graph SenticNet to score sentiment words in the text, thereby improving the model's ability to model sentiment inconsistencies; with the development of large language models, Ben Yao et al. used different prompting methods to allow large language models to make full use of the knowledge contained in the training parameters and adaptively match common sense for different sarcastic expressions. However, knowledge graphs are limited by the scope of knowledge, and methods based solely on large language models are susceptible to hallucinations, resulting in their limited sarcasm detection performance.

[0067] In the field of invention, sarcasm detection mostly focuses on deep learning research. In the field of sarcasm detection research based on text semantics, Tong Jian et al. proposed a method based on a dual-channel attention network, which combines the sentiment and syntax channels, and realizes the information flow and interaction between channels through the graph attention mechanism and the dynamic information interaction layer, improving the model's processing ability for complex language expressions, especially sarcastic language; Shi Wei et al. proposed an emotion-topic-sarcasm hybrid model, which uses the sentiment distribution of words in the text to construct an unsupervised probability relationship model to identify sarcastic subjects; Diao Yufeng et al. proposed a multi-hop attention network based on context representation, which recursively updates the context vectors of questions and answers, and inputs them into the classifier after weighted fusion in the integrated information layer, thus completing sarcasm detection. In the field of sarcasm detection by combining external knowledge, Ren Yafeng et al. proposed a knowledge-enhanced sarcasm detection method. After screening external knowledge and integrating it with the text, word embeddings are generated by RoBERTa, and long-distance dependencies and local semantics are captured through a BiLSTM network embedded with a multi-head self-attention mechanism, and finally the model is optimized to complete sarcasm detection; Du Yu et al. proposed a sarcasm detection method based on background knowledge, which constructs the background knowledge of the target text through an encyclopedia search engine, extracts sentence vectors, and combines a deep learning model to complete the binary classification task of sarcastic text, significantly improving the detection performance. However, these methods either only consider the semantics of the given text itself, or simply make common sense associations for adjectives and nouns in the text (for example: throwing a bottle - angry, irritated). When dealing with complex sarcastic posts on social networks, they lack strong common sense reasoning ability, resulting in unsatisfactory performance of these methods.

[0068] Different from the existing work, the present invention proposes a sarcasm detection method and system based on common sense reasoning, which can adaptively generate reliable common sense background knowledge according to the input text, and accurately infer the implicit emotional inconsistency in combination with this background knowledge.

[0069] The technical solution of the present invention will be further described below with reference to the accompanying drawings and embodiments.

[0070] Embodiment 1

[0071] As Figure 1 and Figure 2 shown, this embodiment proposes a sarcasm detection method based on common sense reasoning, including the following steps:

[0072] S1. Obtain the entities of the input text, retrieve the background content related to the entities, and perform mixed filtering processing on the background content to obtain mixed filtered content;

[0073] In S1, first, entities in the input text are extracted, and background content related to the entities is retrieved through the search engine Bing. The background content includes news and articles, and the N articles with the highest similarity are selected as candidate corpora. To reduce noise in the search content, a hybrid filtering strategy based on BERT-BM25 is designed in this step. This hybrid filtering strategy comprehensively considers word matching and semantic similarity. Specifically, BM25 provides high recall word matching ability, while BERT ensures the accuracy and reliability of the filtering process through its powerful semantic understanding ability.

[0074] The hybrid filtering process for the background content includes:

[0075] S11. Using the preset word matching model BM25 and semantic matching model BERT, calculate the hybrid score f of the articles in the background content bebm The expression of which is as follows:

[0076]

[0077] where α represents a hyperparameter, f bm25 represents the word matching score output by the word matching model BM25, and f bert represents the semantic matching score output by the semantic matching model BERT;

[0078] S12. Judge whether the hybrid score f bebm is lower than the preset threshold ∈. If so, filter the articles in the background content corresponding to the hybrid score f bebm ; if not, execute S13;

[0079] S13. Use the BaRT encoder to perform feature embedding on the articles in the remaining background content after filtering, and generate high-quality representation features as the hybrid filtering content; among them, the BaRT encoder can better generate high-quality representation features by introducing a denoising sequence-to-sequence pre-training mechanism.

[0080] S2. Based on the hybrid filtering content, construct a retrieval-enhanced prompt, preprocess the retrieval-enhanced prompt to obtain an input prompt, and use the input prompt as the input of a preset large language model to output common sense content related to the input text;

[0081] Step S2 supplements indispensable background common sense for the irony detection task with the help of a retrieval-enhanced large language model. The large language model is pre-trained with a large-scale corpus and can effectively capture context semantics and knowledge structures, generating common sense information relevant and reliable to the task. To improve training efficiency, this step adjusts the parameters of the large language model and uses prompt tuning to generate common sense content related to the input text. Specifically, this step designs a retrieval enhancement module composed of a cross-attention network and a feed-forward neural network (FFN). The retrieval enhancement module effectively utilizes the representation features R of the articles in the retrieved mixed filtered content to construct a high-quality retrieval-enhanced prompt. p Based on the mixed filtered content, a high-quality retrieval-enhanced prompt is constructed. Including: using the representation features R of the articles in the mixed filtered content p to construct the retrieval-enhanced prompt The expression is as follows:

[0082]

[0083] where represents the output result of the multi-head attention mechanism, MHA represents the multi-head attention mechanism, represents a trainable length control vector, M q represents the first projection matrix, M k represents the second projection matrix, M v represents the third projection matrix, LN represents the layer normalization operation, and FFN represents the feed-forward neural network;

[0084] Preprocess the retrieval-enhanced prompt concatenate the retrieval-enhanced prompt task-related generated prompt and the entity representation to obtain the input prompt The calculation expression is as follows:

[0085]

[0086] where represents the task-related generated prompt, represents the entity representation;

[0087] Among them, the task-related prompt is a preset instruction used to guide the large language model to generate common sense knowledge, specifically: "Please provide reliable common sense knowledge related to this text and its related paragraphs." This instruction ensures that the model can focus on the input text and the retrieved paragraph content, and avoid generating information irrelevant to the task as much as possible. Through the above design, not only the efficient fusion of retrieval information and task context is achieved, but also the large language model is ensured to have the ability to generate high-quality common sense knowledge at a low training cost. This design provides reliable knowledge support for the sarcasm detection task and significantly improves the large language model's ability to understand and reason about complex language phenomena.

[0088] S3. constructing a syntactic dependency graph based on the input text and the common sense content;

[0089] The step of constructing a syntactic dependency graph based on the input text and the common sense content includes:

[0090] S31. Convert the input text and the common sense content into an undirected graph Where V i Indicates the concept nodes with practical meaning in the text, E i Represents the set of syntactic dependency edges between nodes; the purpose is to capture the syntactic dependency relationship between text statements and common sense content;

[0091] S32. The undirected graph Aggregate to obtain a common sense enhanced syntactic dependency graph The purpose is to align the conceptual entities in the input text and enhance the overall representation ability of the graph;

[0092] To better learn syntactic dependency graphs The topological structure of S3 introduces the dependent adjacency matrix Specifically, when node v i and node v j When there is a syntactic dependency between them, the corresponding adjacency matrix elements are defined as In addition, to ensure the connectivity of the graph and avoid nodes being isolated during message propagation, self-connections are added to each node so that The dependency adjacency matrix defined in this way can not only reflect the syntactic association between nodes, but also ensure that all nodes have basic connectivity in the graph structure, which is conducive to subsequent graph structure modeling and feature propagation.

[0093] S4. Optimize the syntactic dependency graph using a graph refinement strategy to obtain a refined graph;

[0094] The graph refinement strategy includes a graph enhancement strategy and a graph pruning strategy. The graph refinement strategy is used to optimize the syntactic dependency graph to obtain a refined graph, including:

[0095] S41. Add semantic association edges between nodes in the syntactic dependency graph using the graph enhancement strategy;

[0096] To enhance the semantic association between nodes in the dependency graph, a graph enhancement strategy is designed. The graph enhancement strategy can establish effective semantic interactions between sparsely connected long-tail nodes, improving the model's ability to identify subtle sentiment inconsistencies in the graph structure. The graph enhancement strategy obtains the semantic matrix through metric learning shown in the following calculation formula The formula is as follows:

[0097]

[0098] where h i 、h j represent the node embedding vectors encoded by the bidirectional long short-term memory network; δ represents the threshold parameter for controlling the matrix sparsity; ψ se (·) represents the multi-head weighted cosine similarity based on node embeddings, which is calculated as follows:

[0099]

[0100] where β represents the number of heads in the multi-head attention mechanism, aiming to model the semantic relationships in different subspaces; ⊙ represents the Hadamard product, used for element-wise fusion of weight parameters; w se is the trainable weight parameter used to weight different dimensions of the node embeddings.

[0101] Based on the calculated semantic matrix further combine the original dependency adjacency matrix to generate the message propagation matrix This operation is denoted as Then, by combining and obtain the final semantic enhancement matrix where ⊕ represents the element-wise merging operation of matrices, realizing the effective combination of semantic information and dependency relationships.

[0102] S42. Use the graph pruning strategy to prune the semantic association edges between nodes in the syntactic dependency graph according to the meta-path for describing the relationships between different nodes, obtaining a refined graph

[0103] To learn the optimal graph topology for the learning task, S42 adopts a meta-path-based graph pruning strategy, which can efficiently remove the noisy edges in the graph. An ideal graph topology should retain the edges related to the task and contribute to efficient irony detection. Therefore, S42 focuses on sampling the Top-L meta-path neighbor edges of nodes based on certain constraints on the enhanced graph structure. First, the edge weight coefficient from the central node υ to the neighbor node j is defined as the following calculation expression:

[0104]

[0105] where represents the set of all neighbor nodes connected to the central node υ through the meta-path Φ; M ω is a learnable matrix parameter used to map the node feature vector to the target space; h υ and h j represent the feature representations of the central node υ and the neighbor node j respectively.

[0106] To improve the sampling efficiency, a linear programming strategy is introduced in S42 to efficiently screen and sample the edges on the meta-path. The objective function of the linear programming strategy is defined as Here represents the sampling pointer in the one-hot encoding form, indicating the selected node; represents the node weight matrix obtained through L calculation iterations, and the weight represents the degree of correlation between nodes. At the same time, to ensure that the sampling pointer satisfies the one-hot property and the rationality of the Top-L selection, the sampling constraint condition is defined as follows:

[0107]

[0108] where D represents the number of meta-path neighbors of the node. This constraint condition ensures that the sampling pointer selects only one valid node in each column and has a reasonable weight sorting, preferentially retaining the Top-L nodes with the highest weights.

[0109] Subsequently, the one-hot sampling pointers generated from each meta-path Φ are merged to form a pruning matrix This matrix only retains the edges with the highest weights and related to the task, completing the preliminary refinement of the graph. However, due to the one-hot encoding and the Top-L operation being non-differentiable in nature, the gradient backpropagation cannot be directly performed.

[0110] To solve this problem, a perturbation maximization strategy is introduced during the training phase, allowing gradient-based optimization by introducing controlled random noise. The specific calculation formula is as follows:

[0111]

[0112] where Controls the proportion of the injected Gaussian noise U, which is used to smooth the one-hot operation and alleviate the non-differentiable problem; Represents the expected value under the random noise U. By introducing the perturbation noise, this strategy allows the model to perform gradient optimization while ensuring the sampling effectiveness, solving the problem that traditional backpropagation fails in discrete sampling scenarios.

[0113] Finally, the optimized sampling pointer is fused into the pruning matrix to obtain the task-optimal graph topology matrix This matrix characterizes the task-optimal topology of the refined graph It retains the nodes and edges highly relevant to the task, significantly enhancing the expressive power and reasoning effect of the graph structure in the irony detection task.

[0114] S5. Perform inconsistent reasoning skeleton processing on the refined graph to obtain inconsistent subgraphs;

[0115] In S5, to capture fine-grained sentiment inconsistencies in the refined graph S5 proposes a novel inconsistent reasoning skeleton, which combines reasoning rules as prior knowledge. These reasoning rules come from multiple disciplinary fields such as psychology and sociology, and can help the model better understand diverse irony patterns. However, these reasoning rules have problems of poor scalability and difficulty in being directly integrated into the overall framework. To solve this problem, these reasoning rules are used to fine-tune the entailment checker based on the pre-trained RoBERTa-large model, enabling it to better perform entailment reasoning on the paths in the graph.

[0116] Specifically, the performing inconsistent reasoning skeleton processing on the refined graph to obtain inconsistent subgraphs includes:

[0117] S51. Use special markers for multiple paths between the same node pairs in the refined graph <s> <s>Perform segmentation, and then splice the segmentation results into a single input sequence;

[0118] S52. Use the input sequence as the condition and conclusion, input it into a preset entailment checker, and output the prediction result logits for each path. The prediction result logits include a contradiction result indicating an obvious inconsistency in the path, a neutral result indicating no obvious causal relationship between paths, and an entailment result indicating logical consistency between the condition and conclusion in the path;

[0119] S53. Select the contradiction results from the prediction results, and sample node pairs and node pair paths with contradictions as suspicious inconsistent subgraphs according to the contradiction results

[0120] S6. Jointly represent the inconsistent subgraph and the refined graph to obtain inconsistent fusion features. Use the inconsistent fusion features as the input of a preset irony classifier, and optimize the irony classifier by introducing adversarial contrast learning. Use the optimized irony classifier to output the irony probability distribution result.

[0121] The joint representation of the inconsistent subgraph and the refined graph includes:

[0122] S61. Since relying solely on the extracted inconsistent subgraph to infer inconsistencies may lose some global context information, therefore, to make up for this deficiency, the refined graph and the inconsistent subgraph are input into a preset hierarchical graph attention network to learn multi-granularity inconsistency features. The hierarchical graph attention network outputs fine-grained inconsistency feature I e and coarse-grained inconsistency feature I c respectively as follows:

[0123]

[0124] where represents the max pooling operation, represents the semantic attention of the l-th layer in the hierarchical graph attention network, represents the node attention of the l-th layer in the hierarchical graph attention network, represents the fine-grained inconsistency feature output by the l-th layer in the hierarchical graph attention network, represents the coarse-grained inconsistency feature output by the l-th layer in the hierarchical graph attention network, represents the inconsistent subgraph in the set of meta-path neighbor nodes, represents the refined graph The set of meta-path neighbor nodes in

[0125] S62. To balance the global context features and local inconsistent features, a gating strategy is introduced to fuse the fine-grained inconsistent feature I e and the coarse-grained inconsistent feature I c into the inconsistent fusion feature I f The calculation expression is as follows:

[0126] I f = γI c + (1 - γ)I e

[0127] where γ represents a hyperparameter used to control the fusion ratio of global and local features. The inconsistent reasoning skeleton identifies and models the fine-grained inconsistencies in the graph structure by combining prior reasoning rules and an entailment checker. Through multi-granularity feature learning and the gating fusion strategy, the global context information and local conflict features are effectively balanced, thus enhancing the robustness and accuracy of the model in the irony detection task; then the fused feature representation I f is input into an irony classifier to generate a predicted probability distribution

[0128] It should be noted that, to effectively capture the complex correlation relationships between multiple texts, a graph structure modeling method is first adopted to construct a syntactic dependency graph, which can well represent the long-distance dependency relationships in the text. However, existing methods usually have difficulty in identifying the fine-grained sentiment inconsistencies in the text due to the incompleteness of the graph topology structure and the lack of reasoning ability. To address this problem, the present invention proposes a graph refinement strategy to enhance the robust association between nodes by optimizing the graph topology structure. Meanwhile, an inconsistent reasoning skeleton is designed to extract subgraphs containing sentiment conflicts from the graph structure to further improve the ability to capture inconsistencies. To prevent the irony classifier from overly relying on the inconsistent reasoning skeleton, the present invention also introduces a global context feature supplementation mechanism to ensure that the irony classifier can comprehensively consider the global semantic information and local conflict features, thereby improving the overall accuracy and robustness of sentiment inconsistency detection.

[0129] Due to the diversity of irony expression forms, irony features are often complex and implicit, and relying solely on the classification loss is not sufficient to fully learn the true irony features. The classification loss usually focuses on direct label prediction and fails to effectively capture the fine-grained inconsistencies and implicit semantic relationships in irony samples.

[0130] Therefore, in the classification loss function Based on the above, supervised contrastive learning is introduced to further improve the modeling ability of the sarcasm classifier model for sarcasm features by bringing the feature vectors of similar sarcasm samples closer and pushing the feature representations of sarcasm and non-sarcasm samples further apart. At the same time, in order to alleviate the problem of false associations during training and reduce the sensitivity of the sarcasm classifier model to local knowledge, adversarial gradient perturbations are introduced in the feature space to generate enhanced samples in the feature space.

[0131] Embedding vectors for common sense nodes The calculation process of applying gradient perturbation is as follows:

[0132]

[0133] in represents the gradient operator, μ represents a perturbation control hyperparameter used to adjust the amplitude of the perturbation; Represents the embedding vector of the common sense node after perturbation. Unlike the method of directly deleting or replacing words, gradient-based perturbation can introduce appropriate perturbations while maintaining the original common sense semantics, thereby generating more robust training samples.

[0134] According to the common sense node embedding after perturbation and the representation vector of the input text, and construct a syntactic dependency graph again; then, the syntactic dependency graph is optimized by using a graph refinement strategy through S4 to obtain a refined graph; and then, the refined graph is processed by inconsistent reasoning skeleton through S5 to obtain an inconsistent subgraph I after the disturbance is applied. f ′;

[0135] In this way, for the same batch of data, there is a set of sarcastic samples Λ s , satire sample set Λ s Contains original inconsistent features I f And the inconsistent subgraph I after the perturbation f ′; non-sarcasm sample set Λ n Based on this, the supervised contrast loss function can be calculated. The calculation expression is as follows:

[0136]

[0137] Among them, Λ s represents the set of sarcastic samples, represents the characteristics of sarcastic samples, Λ n represents the non-sarcasm sample set, represents the characteristics of non-sarcastic samples, and τ represents the temperature parameter, which is used to adjust the smoothness of the similarity distribution.

[0138] Finally, the learning objective of the sarcasm classifier is through the sarcasm detection loss and the supervised contrast loss function for joint optimization. Therefore, by introducing adversarial contrast learning, the total loss function is used to optimize the sarcasm classifier. The calculation expression of the total loss function is as follows:

[0139]

[0140] where represents the classification loss function, represents the supervised contrast loss function; is used to control the weight of the contrast learning loss in the total loss function.

[0141] The calculation expression of the classification loss function is as follows:

[0142]

[0143] where represents the prediction probability distribution result of the sarcasm classifier, y represents the true label, and by minimizing this loss function, the sarcasm classifier can effectively complete the classification task.

[0144] This embodiment proposes an irony detection method based on commonsense reasoning, aiming to determine whether a given text expresses criticism, ridicule, or other negative emotions contrary to its literal meaning. Existing irony detection methods mainly rely on the literal information in the text and judge emotional inconsistency through simple pattern matching to identify this ironic emotional expression. However, actual ironic content is often more complex, with diverse and implicit forms of emotional expression. Relying solely on literal matching is difficult to accurately identify the implicit ironic intent of people behind the text. To solve this problem, this embodiment proposes a new framework based on commonsense reasoning to capture ironic emotions. Specifically, this method first uses a retrieval-enhanced large language model to supplement missing but necessary commonsense content. Based on this commonsense content, a syntactic dependency graph is constructed to capture complex context associations. Since the initial syntactic dependency graph may have problems such as incomplete structure and noise interference, this embodiment proposes a graph refinement strategy to optimize the syntactic dependency graph to better capture the semantic relationships between texts. To infer fine-grained emotional inconsistency, this embodiment further introduces an adaptive inconsistency reasoning framework that integrates prior rules to extract potential emotional inconsistency subgraphs. These inconsistency subgraphs contain potential contradiction points in the text, which are beneficial for identifying irony. Subsequently, this method jointly represents the inconsistency subgraphs and the refined graph and inputs them into an irony classifier. To eliminate possible spurious associations between words and labels in the dataset, this method uses an adversarial contrast learning strategy to enhance the robustness of the detector. This method can effectively support applications such as intelligent customer service and public opinion analysis, help the system more accurately identify user emotions, and provide important value for improving user experience, information management, and decision support.

[0145] This method can provide users with efficient and accurate sarcasm detection services, which can be applied to social media analysis, sentiment analysis, and intelligent customer service systems to help identify complex sarcastic expressions. In scenarios such as opinion analysis, sentiment recognition, user feedback interpretation, and public opinion monitoring in social networks, this patented technology can provide important support and enhance the ability to identify implicit sarcasm. For example, on social media platforms, a large number of users express various opinions. Sarcasm detection can help analyze the true attitudes of the public towards specific events, people, or policies. In addition, in the e-commerce field, the reputation of brands on social media is crucial. Consumers may use sarcasm to ridicule or criticize brand products or services. Enterprises can use sarcasm detection tools to monitor brand-related topics, promptly discover negative sarcastic comments, and take measures for crisis public relations to maintain the brand image. For instance, after a electronics company launches a new mobile phone, by monitoring social media, it can find sarcastic comments from users about the battery life of the new mobile phone and then improve the product or adjust the promotional strategy accordingly. On e-commerce websites, consumers' reviews are important references for other consumers' purchase decisions and also the basis for merchants to improve products and services. Some consumers will use sarcasm to express dissatisfaction with product quality, logistics speed, or customer service. Sarcasm detection can help e-commerce platforms more accurately screen out truly valuable negative feedback, prioritize displaying these comments to merchants, and prompt merchants to improve service quality. For example, for a clothing product, if it is detected that a customer comments "The size of this dress is really 'thoughtful', completely ignoring the normal body size of people", this is obviously a sarcastic negative comment, and the merchant can adjust the size standard in a timely manner according to this feedback.

[0146] In addition, to evaluate the effectiveness and superiority of a sarcasm detection method based on common sense reasoning proposed in this embodiment, a comparative experiment with traditional sarcasm detection methods is set up in this embodiment. At the model level, a sarcasm detection method based on common sense reasoning proposed in this embodiment selects sarcasm detection models based on graph structures (including ADGCN and DC-Net), sarcasm detection models enhanced by external knowledge (including SarDeCK and SD-APRR), and sarcasm detection models based on large language models (including SensoryT5 and SarcasmCue) for comparison; in terms of the dataset, a sarcasm detection method based on common sense reasoning proposed in this embodiment uses commonly used datasets (including Ghosh, Reddit, IAC-V2, iSarcasm, and SemEval2018) open-sourced in the field of sarcasm detection. This sarcasm detection method proposed in this embodiment uses two classic metrics to compare the performance of different methods, including accuracy and F1 score. The results of the comparative experiment show that the sarcasm detection method based on common sense reasoning proposed in this embodiment has higher sarcasm detection accuracy than traditional sarcasm detection methods.

[0147] Example 2

[0148] Refer to Figure 3 , this example proposes an irony detection system based on common sense reasoning, including:

[0149] An acquisition module, used to acquire entities of the input text;

[0150] A common sense generation module, used to retrieve background content related to the entity, perform hybrid filtering processing on the background content to obtain hybrid filtered content, construct a retrieval enhanced prompt based on the hybrid filtered content, preprocess the retrieval enhanced prompt to obtain an input prompt, use the input prompt as the input of a preset large language model, and output common sense content related to the input text;

[0151] An inconsistency reasoning module, used to construct a syntactic dependency graph according to the input text and the common sense content, optimize the syntactic dependency graph using a graph refinement strategy to obtain a refined graph, perform inconsistency reasoning skeleton processing on the refined graph to obtain an inconsistent subgraph, and jointly represent the inconsistent subgraph and the refined graph to obtain an inconsistent fusion feature;

[0152] An adversarial contrast learning module, used to use the inconsistent fusion feature as the input of a preset irony classifier, and optimize the irony classifier by introducing adversarial contrast learning;

[0153] An output module, used to use the optimized irony classifier to output an irony probability distribution result.

[0154] In this embodiment, first, a retrieval-enhanced prompt is constructed by introducing a retrieval-enhanced strategy. The input prompt is obtained by preprocessing the retrieval-enhanced prompt. The input prompt is input into the large language model. The purpose is to utilize the collaborative work of retrieval enhancement and the large language model to obtain common sense content related to the input text from an external knowledge base and supplement the input text. Through the retrieval-enhanced strategy, not only the quality of the common sense content generated by the large language model is improved, but also it can be ensured that the generated common sense content covers the context information required for irony detection, improving the generalization ability and robustness of the large language model, and thus enhancing the accuracy of irony detection. Secondly, the graph refinement strategy is used to optimize the syntactic dependency graph, improving the expression accuracy of semantic relationships in the syntactic dependency graph, effectively reducing the influence of noisy edges, and strengthening the expression of key information, so that the graph structure can more accurately reflect the emotional inconsistency in the text. Then, the refined graph is processed with an inconsistency reasoning skeleton. The inconsistency reasoning skeleton clearly points out which parts have emotional inconsistency by analyzing the emotional contradictions in the text, thus more accurately identifying implicit ironic expressions. Finally, by introducing adversarial contrast learning, the irony classifier is optimized, optimizing the decision-making process of the irony classifier when dealing with irony detection tasks, reducing the possible false associations between the vocabulary and labels in the dataset, and further improving the accuracy of irony detection.

[0155] Obviously, the above embodiments of the present invention are only examples for clearly illustrating the present invention, and are not limitations on the implementation manners of the present invention. For those of ordinary skill in the art, other different forms of changes or modifications can be made based on the above description. It is not necessary and impossible to enumerate all the implementation manners here. Any modifications, equivalent replacements, and improvements made within the spirit and principle of the present invention shall be included in the protection scope of the claims of the present invention.< / s> < / s>

Claims

1. A sarcasm detection method based on common sense reasoning, characterized in that: The following steps are involved: S1. Get the entity of the input text, retrieve the background content related to the entity, perform mixed filtering on the background content, and obtain mixed filtered content; S2. constructing a search enhancement prompt based on the mixed filtered content, preprocessing the search enhancement prompt to obtain an input prompt, using the input prompt as an input of a preset large language model, and outputting common sense content related to the input text; S3. constructing a syntactic dependency graph based on the input text and the common sense content; S4. Optimize the syntactic dependency graph using a graph refinement strategy to obtain a refined graph; S5. Perform inconsistent reasoning skeleton processing on the refined graph to obtain inconsistent subgraphs; S6. The inconsistent subgraph and the refined graph are jointly represented to obtain inconsistent fusion features, and the inconsistent fusion features are used as input of a preset irony classifier. The irony classifier is optimized by introducing adversarial contrast learning, and the irony classifier is used to output an irony probability distribution result.

2. The sarcasm detection method based on common sense reasoning according to claim 1, characterized in that: The hybrid filtering process on the background content includes: S11. Using the preset word matching model BM25 and semantic matching model BERT, calculate the mixed score f of the article in the background content bebm The expression is as follows: Among them, α represents the hyperparameter, f bm25 Represents the word matching score output by the word matching model BM25, f bert Represents the semantic matching score output by the semantic matching model BERT; S12. Determine the mixture fraction f bebm Is it lower than the preset threshold ∈? If so, the mixed fraction f bebm Filter the articles in the corresponding background content; if not, execute S13; S13. Use the BaRT encoder to embed features of the articles in the background content remaining after filtering, and generate high-quality representation features as the mixed filtered content.

3. The sarcasm detection method based on common sense reasoning according to claim 2, characterized in that: The step of constructing a search enhancement prompt based on the mixed filtering content includes: using the representation feature R of the article in the mixed filtering content p , construct the search enhancement prompt The expression is as follows: in, Represents the output of the multi-head attention mechanism, MHA represents the head attention mechanism, represents the trainable length control vector, M q represents the first projection matrix, M k represents the second projection matrix, M v represents the third projection matrix, LN represents the layer normalization operation, and FFN represents the feed-forward neural network.

4. The sarcasm detection method based on common sense reasoning according to claim 3, characterized in that: The search enhancement prompt Perform preprocessing and get input prompts The calculation expression is as follows: in, Indicates task-related generation prompts, Represents an entity representation.

5. The sarcasm detection method based on common sense reasoning according to claim 4, characterized in that: The step of constructing a syntactic dependency graph based on the input text and the common sense content includes: S31. Convert the input text and the common sense content into an undirected graph Where V i Indicates the concept nodes with practical meaning in the text, E i Represents the set of syntactic dependency edges between nodes; S32. The undirected graph Aggregate to obtain a common sense enhanced syntactic dependency graph 6. The sarcasm detection method based on common sense reasoning according to claim 5, characterized in that: The graph refinement strategy includes a graph enhancement strategy and a graph pruning strategy. The graph refinement strategy is used to optimize the syntactic dependency graph to obtain a refined graph, including: S41. Using the graph enhancement strategy to add semantically associated edges between nodes in the syntactic dependency graph; S42. Using the graph pruning strategy, prune the semantic association edges between nodes in the syntactic dependency graph according to the meta-path used to describe the relationship between different nodes to obtain a refined graph 7. The sarcasm detection method based on common sense reasoning according to claim 6, characterized in that: The performing inconsistent reasoning skeleton processing on the refined graph to obtain inconsistent subgraphs includes: S51. Segment multiple paths between the same node pair in the refined graph using special markers, and then concatenate the segmentation results into a single input sequence; S52. Input the input sequence as conditions and conclusions to a preset implication checker, and output the prediction results of each path, wherein the prediction results include contradictory results indicating that there is an obvious inconsistency in the path, neutral results indicating that there is no obvious causal relationship between the paths, and implication results indicating that there is logical consistency between the conditions and conclusions in the path; S53. Select the contradictory results from the prediction results, and sample the contradictory node pairs and node pair paths as suspicious inconsistent subgraphs according to the contradictory results.

8. The sarcasm detection method based on common sense reasoning according to claim 7, characterized in that: The jointly representing the inconsistent subgraph and the refined graph includes: S61. The refined graph and the inconsistent subgraph Input to the preset hierarchical graph attention network, and the hierarchical graph attention network outputs fine-grained inconsistency features I e and coarse-grained inconsistent feature I c They are as follows: in, represents the maximum pooling operation, represents the semantic attention of the lth layer in the hierarchical graph attention network, represents the node attention of the lth layer in the hierarchical graph attention network, represents the fine-grained inconsistent features of the l-th layer output in the hierarchical graph attention network, represents the coarse-grained inconsistent features of the output of layer l in the hierarchical graph attention network, Indicates the inconsistent subgraph The set of meta-path neighbor nodes in , Representing the refined graph The set of meta-path neighbor nodes in ; S62. The fine-grained inconsistent feature I e and coarse-grained inconsistent feature I c Fusion into inconsistent fusion features I f The calculation expression is as follows: I f =γI c +(1-γ)I e Among them, γ represents a hyperparameter.

9. The sarcasm detection method based on common sense reasoning according to claim 8, characterized in that: By introducing adversarial contrast learning, the total loss function is used The sarcasm classifier is optimized, and the total loss function The calculation expression is as follows: in, represents the classification loss function, represents the supervised contrast loss function; The supervised contrast loss function The calculation expression is as follows: Among them, Λ s represents the set of sarcastic samples, represents the characteristics of sarcastic samples, Λ n represents the non-sarcasm sample set, represents the characteristics of non-sarcastic samples, τ represents the temperature parameter; The classification loss function The calculation expression is as follows: in, represents the predicted probability distribution result of the sarcasm classifier, and y represents the true label.

10. A sarcasm detection system based on common sense reasoning, characterized in that: include: The acquisition module is used to obtain the entity of the input text; A common sense generation module, used to retrieve background content related to the entity, perform mixed filtering processing on the background content to obtain mixed filtered content, construct a search enhancement prompt based on the mixed filtered content, pre-process the search enhancement prompt to obtain an input prompt, use the input prompt as an input of a preset large language model, and output common sense content related to the input text; An inconsistent reasoning module is used to construct a syntactic dependency graph according to the input text and the common sense content, optimize the syntactic dependency graph using a graph refinement strategy to obtain a refined graph, perform inconsistent reasoning skeleton processing on the refined graph to obtain an inconsistent subgraph, and jointly represent the inconsistent subgraph and the refined graph to obtain an inconsistent fusion feature; An adversarial contrast learning module, used for taking the inconsistent fusion feature as an input of a preset irony classifier, and optimizing the irony classifier by introducing adversarial contrast learning; The output module is used to output the sarcasm probability distribution result using the optimized sarcasm classifier.

Citation Information

Cited By

  • Remote sensing image semantic segmentation optimization method

    CN120913208A