Irony detection method and system for rhetorical manipulation
By collecting and labeling satirical dialogues, building fine-grained data sets, and fine-tuning the language model for knowledge enhancement, the problems of narrow definition of satiricality and poor detection performance in the existing technology are solved, and a more accurate and robust satirical detection effect is achieved.
Patent Information
- Application Number
- CN202411930654.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-26
- Publication Date
- 2025-06-03
AI Technical Summary
The existing satirical detection methods have a narrow definition of satiricality, lack a fine-grained classification system, rely on simple emotional evaluation, and are difficult to achieve more accurate satirical detection by constructing fine-grained data sets and optimizing language models.
By collecting satirical dialogues for the first annotation, first counterfactual processing is performed to build a fine-grained satirical data set, fine-tuning the language model and enhancing knowledge, and optimizing the satirical detection performance of the language model. Specific steps include extracting satirical dialogues, labeling satirical fragments and rhetorical techniques, generating counterfactual dialogues, building fine-grained datasets, fine-tuning pre-trained language models Bert and RoBERTa, and optimizing model performance through dual counterfactual enhancement and competitive rationalization.
By building fine-grained data sets and optimizing language models, the accuracy and robustness of satire detection are improved, and the characteristics of satire and non-sarcastic can be distinguished more clearly, and the model's adaptability in the face of new and complex languages is improved.
Smart Images

Figure CN120087361A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of text irony detection, and specifically provides an irony detection method and system for rhetorical devices. Background Art
[0002] As a complex language phenomenon, irony widely exists in various fields such as daily communication, literary works, and film and television works. Traditional irony usually uses rhetorical devices such as irony, metaphor, hyperbole, and contrast to expose, criticize, or ridicule people or things. Most of the time, this phenomenon is expressed indirectly, that is, there is an obvious difference between the literal meaning and the actual intention of the words. Although irony can also be expressed through direct statements, such as detailed and exaggerated descriptions to highlight the absurdity or contradiction of the ironic object. However, the existing automatic irony detection tasks face many challenges in the field of natural language processing.
[0003] Currently, most of the existing technologies adopt a narrow definition of irony. Usually, irony is regarded as a form of verbal irony, and the detection mainly relies on evaluating the inconsistency between positive emotions and negative situations or the actual intention and the literal content. This single definition and detection method are somewhat superficial and difficult to cope with the diversity and complexity of ironic expressions. In addition, the early methods mainly relied on machine learning techniques (such as Support Vector Machine, SVM) and manually designed feature engineering, and failed to effectively mine the deep information behind the language. With the rise of neural networks, although some studies have begun to design more complex model structures to compare ironic-related words or phrases, there is still a lack of fine-grained analysis of ironic emotions and corresponding data support.
[0004] In addition, the existing irony detection methods based on pre-trained language models (PLMs), although introducing sentiment lexicons and common sense reasoning tools to enhance external knowledge, still tend to focus on ironic types of irony and fail to accurately identify and classify various other forms of ironic expressions. This makes the current detection systems perform unsatisfactorily when dealing with diverse ironic situations. Summary of the Invention
[0005] In view of the above problems, the present invention is proposed.
[0006] Therefore, the technical problem solved by the present invention is that the existing irony detection methods have a narrow definition of irony, lack a fine-grained classification system, rely on simple emotion evaluation, and how to achieve more accurate irony detection by constructing a fine-grained dataset and optimizing the language model.
[0007] To solve the above technical problems, the present invention provides the following technical solutions: A sarcasm detection method for rhetorical devices, including collecting sarcastic dialogues and performing the first annotation; performing the first counterfactual processing to construct a fine-grained sarcasm dataset; fine-tuning the language model and performing knowledge enhancement to optimize the sarcasm detection performance of the language model.
[0008] As a preferred solution of the sarcasm detection method for rhetorical devices according to the present invention, wherein: the collecting of sarcastic dialogues includes extracting sarcastic dialogues.
[0009] As a preferred solution of the sarcasm detection method for rhetorical devices according to the present invention, wherein: the performing of the first annotation includes annotating sarcastic segments and rhetorical devices.
[0010] As a preferred solution of the sarcasm detection method for rhetorical devices according to the present invention, wherein: the performing of the first counterfactual processing includes generating counterfactual dialogues.
[0011] As a preferred solution of the sarcasm detection method for rhetorical devices according to the present invention, wherein: the constructing of the fine-grained sarcasm dataset includes sarcastic and non-sarcastic dialogues.
[0012] As a preferred solution of the sarcasm detection method for rhetorical devices according to the present invention, wherein: the fine-tuning of the language model includes, based on the fine-grained sarcasm dataset, classifying the data through the pre-trained language models Bert and RoBERTa, calculating the F1 scores of the sarcastic category and the non-sarcastic category, and calculating the classification model performance metric MacroF1 of the language model to evaluate the sarcasm detection performance of the dataset on the language model.
[0013] As a preferred solution of the sarcasm detection method for rhetorical devices according to the present invention, wherein: the knowledge enhancement includes optimizing the sarcasm detection performance of the language model through double counterfactual enhancement and competitive rationalization; the double counterfactual enhancement includes, based on the fine-grained sarcasm dataset, the large model generating new sarcastic-non-sarcastic pairs and automatically filtering out unwanted and highly similar dialogues; the competitive rationalization includes applying the internal knowledge and reasoning ability of the large model to the sarcasm detection model, the large model generating competitive reasons, and using potential sarcastic labels to respectively clarify the reasoning processes of sarcasm and non-sarcasm.
[0014] Another object of the present invention is to provide a sarcasm detection system for rhetorical devices, which can solve the problem that the current sarcasm detection technology lacks a fine-grained classification system by performing the first counterfactual processing and constructing a fine-grained sarcasm dataset.
[0015] As a preferred solution of the irony detection system for rhetorical devices according to the present invention, it includes a fine-grained data collection module, a counterfactual generation module, and a model fine-tuning and knowledge enhancement module; the fine-grained data collection module is used to collect ironic conversations and perform the first annotation; the counterfactual generation module is used to perform the first counterfactual processing to construct a fine-grained ironic data set; the model fine-tuning and knowledge enhancement module is used to fine-tune the language model and perform knowledge enhancement to optimize the irony detection performance of the language model.
[0016] A computer device includes a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, the steps of the irony detection method for rhetorical devices are implemented.
[0017] A computer-readable storage medium stores a computer program thereon. When the computer program is executed by a processor, the steps of the irony detection method for rhetorical devices are implemented.
[0018] The beneficial effects of the present invention: The irony detection method for rhetorical devices provided by the present invention realizes the construction of basic data for ironic language phenomena by collecting ironic conversations and performing the first annotation. By performing the first counterfactual processing, a fine-grained ironic data set for model training is constructed. The counterfactual processing rewrites the ironic conversation into a non-ironic version, ensuring the integrity of the context and structure. This rewriting method retains the original intention of the speaker but removes the irony, which enables a clearer distinction between ironic and non-ironic features in subsequent analysis and model training. By fine-tuning the language model and performing knowledge enhancement, the overall performance of the irony detection model is improved. The combination of double counterfactual enhancement and competition rationalization not only increases the richness of data samples but also improves the reasoning ability of the model. By enabling the model to understand the relationship between irony and non-irony from multiple perspectives, competition rationalization enhances the performance of the model in real scenarios, making it more adaptable to new and complex languages. The present invention achieves better results in terms of accuracy, robustness, and reliability. Description of the Drawings
[0019] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for the description of the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0020] Figure 1 It is the overall flowchart of an irony detection method for rhetorical devices provided by the first embodiment of the present invention.
[0021] Figure 2Process diagram of an irony detection method for rhetorical devices provided by the first embodiment of the present invention.
[0022] Figure 3 Fine-grained data collection and counterfactual data augmentation process diagram of an irony detection method for rhetorical devices provided by the first embodiment of the present invention.
[0023] Figure 4 Distribution diagram of the number of words in the irony dataset of an irony detection method for rhetorical devices provided by the first embodiment of the present invention.
[0024] Figure 5 Knowledge enhancement schematic diagram of an irony detection method for rhetorical devices provided by the first embodiment of the present invention.
[0025] Figure 6 Experimental result diagram of an irony detection method for rhetorical devices provided by the second embodiment of the present invention based on the constructed irony dataset.
[0026] Figure 7 Generalization experiment diagram of the constructed irony dataset and other irony datasets of an irony detection method for rhetorical devices provided by the second embodiment of the present invention.
[0027] Figure 8 Irony dialogue and corresponding counterfactual example diagram of an irony detection method for rhetorical devices provided by the second embodiment of the present invention.
[0028] Figure 9 Module schematic diagram of an irony detection system for rhetorical devices provided by the third embodiment of the present invention. Detailed implementation manners
[0029] To make the above objects, features, and advantages of the present invention more obvious and understandable, the following detailed description of the specific implementation manners of the present invention will be given in conjunction with the accompanying drawings of the specification. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all of them. All other embodiments obtained by those of ordinary skill in the art without creative efforts based on the embodiments of the present invention shall fall within the scope of protection of the present invention.
[0030] Embodiment 1, referring to Figures 1-5 , which is an embodiment of the present invention, provides an irony detection method for rhetorical devices, including:
[0031] As Figure 2As shown in the figure, it is a process diagram of an irony detection method for rhetorical devices. The framework includes three parts: fine-grained data collection, counterfactual data augmentation, and additional knowledge augmentation. First, ironic conversations are extracted, and on this basis, ironic segments and rhetorical devices are annotated to create fine-grained ironic data. Then, non-ironic conversations are generated through counterfactual data augmentation to construct an ironic dataset. Finally, additional knowledge augmentation strategies, including double counterfactual augmentation and competitive rationalization, are introduced to help the model improve the detection performance.
[0032] S1: Collect ironic conversations and perform the first annotation.
[0033] Furthermore, collecting ironic conversations includes extracting ironic conversations.
[0034] Among them, extracting ironic conversations includes, but is not limited to, extracting ironic conversations from corpora such as social media, sitcom scripts, and news comments.
[0035] Such as Figure 3 As shown on the left, the conversations in the corpus need to vividly depict human behaviors and interactions and contain rich and detailed background information, so that the annotation can accurately infer the author's intention and ensure that the reader's interpretation is consistent with the author's intention, thereby reducing inconsistencies in the labels. In addition, the extracted ironic conversations include various rhetorical devices in different scenarios, which can lay a research foundation for fine-grained irony detection. Figure 1 In the embodiments of the present application, ironic conversations are collected from seasons 1-12 of the sitcom "The Big Bang Theory", which contain various rhetorical devices expressing irony in different scenarios. Ten representative rhetorical devices are summarized as shown in Table 1; for each ironic conversation, ironic segments (the reasons for irony, that is, the segments initiating irony) and the corresponding rhetorical devices are annotated.
[0036] Table 1 Representative rhetorical devices
[0037] Table 1 Representative rhetorical devices
[0038]
[0039] As can be seen from Table 1, hyperbole and clever use of presupposition are the two most frequently used rhetorical devices in ironic conversations, while echo mention and self-deprecation are the two least used. Note that each ironic conversation may use multiple rhetorical devices. For example, innuendo is usually combined with the clever use of presupposition, while metaphor usually produces an exaggerated effect.
[0040] It should be noted that performing the first annotation includes annotating ironic segments and rhetorical devices.
[0041] Among them, the ironic segment refers to the cause of irony, that is, the segment where a person starts or initiates irony. In a conversation, the cause or span of irony can vary. It can be a sentence, a phrase, or even a single word, and can also extend to multiple sentences or the entire conversation context. By analyzing the ironic segment, one can gain insights into the speaker's perspective and the intended target of the irony, which helps the model understand the dynamics of irony in the conversation and avoid problems where the model fails to accurately identify the ironic segment in subsequent steps.
[0042] Rhetorical devices refer to various techniques or strategies adopted to improve the expression effect. Irony can be manifested through various rhetorical devices, such as echo mention, exaggeration, rhetorical question, metaphor, etc. By introducing rhetorical devices, the complex expressions of irony can be fully captured, further revealing the deep meaning carried by irony in the text.
[0043] For complex tasks such as irony detection that require a large amount of common sense, world knowledge, and logical reasoning, in order to better utilize large models to generate counterfactuals, for the 10 representative rhetorical devices collected, 2 samples are respectively labeled as context examples. Each example takes an ironic conversation, an ironic segment, and the rhetorical device used as input, and intention, explanation, and counterfactual as output.
[0044] The first annotation can be carried out manually by humans, or through an automated annotation tool, or other methods that can annotate ironic segments and rhetorical devices.
[0045] It should be noted that in the embodiments of this application, the first annotation is carried out manually by humans. The specific steps are as follows:
[0046] First, select the corpus, manually extract the conversation segments related to irony from seasons 1 - 12 of the sitcom "The Big Bang Theory" one by one. Secondly, annotate the ironic segments, identify and annotate the ironic segments and their rhetorical devices for each extracted conversation paragraph to ensure the integrity and consistency of the annotation. Then, record the rhetorical devices, mark the rhetorical devices related to each ironic paragraph, and record the background context for subsequent analysis. Finally, integrate the data, organize and summarize the annotated ironic segments and rhetorical devices to form a standard ironic dataset for subsequent model training and verification.
[0047] It should be noted that in an alternative embodiment, the first annotation is carried out through an automated annotation tool. The specific steps are as follows:
[0048] The automated annotation tool utilizes advanced natural language processing algorithms and focuses on extracting sarcastic dialogue segments from a corpus (such as sitcom texts). By analyzing the language patterns, syntactic structures, and semantic features of the dialogue, the tool can efficiently identify sarcastic features. Specifically, the tool is first trained to recognize common language features of sarcasm, such as irony, exaggeration, and subtle implications. During the processing, the tool tokenizes the dialogue, performs part-of-speech tagging, and syntactic analysis to ensure that the context information of the dialogue can be captured. By combining machine learning algorithms, the tool learns annotation samples from a large amount of text so that it can subsequently perform automated annotation on new, unannotated dialogues.
[0049] S2: Perform the first counterfactual processing to construct a fine-grained sarcasm dataset.
[0050] Furthermore, performing the first counterfactual processing includes generating counterfactual dialogues.
[0051] Among them, generating counterfactual dialogues means rewriting the fine-grained sarcasm data generated in step S1 into a non-sarcastic version.
[0052] Constructing a fine-grained sarcasm dataset includes sarcastic and non-sarcastic dialogues; according to the generated counterfactuals, automatic screening and manual revision are performed to construct a fine-grained sarcasm dataset enhanced with counterfactual data.
[0053] It should be noted that the first counterfactual processing can be performed through a language generation model, or through a structured template generation, or other methods that can rewrite sarcastic data into non-sarcastic data.
[0054] It should also be noted that in the embodiments of this application, the first counterfactual processing is performed through a language generation model, and the specific steps are as follows:
[0055] As Figure 3 As shown on the right, utilize the powerful internal knowledge and reasoning ability of a large model (such as the GPT series) to generate counterfactuals, taking sarcastic dialogues, sarcastic segments, rhetorical devices, and their corresponding context examples as inputs. In order to fully capture the subtle differences between sarcasm and non-sarcasm, it is required that the large model makes minimal modifications during the rewriting process, retaining the speaker's original intention while removing the sarcastic meaning. In addition, as a way of Chain of Thought (CoT), guide the large model to first analyze the speaker's intention and then provide a concise explanation to guide the generation of high-quality counterfactuals.
[0056] Subsequently, first, the large model is applied to automatically filter out unnecessary conversations, delete problem counterfactuals with unnatural expressions, illogical coherence, being too simple or general, and still containing sarcasm. Then, the problem counterfactuals are passed to human annotators for further verification and revised into non-sarcastic conversations that meet the requirements. This process is iterated three times to ensure the quality of the counterfactuals. Finally, a new fine-grained sarcasm dataset is constructed, containing the same number of sarcastic and non-sarcastic conversations, with the average conversation lengths being approximately 35 and 33 words respectively, and the word count distribution is as Figure 4 shown.
[0057] It should also be noted that in an optional embodiment, the first counterfactual processing is generated through a structured template. The specific steps are as follows:
[0058] First, a set of general and flexible conversation templates are designed, and each template contains necessary structural elements, such as characters, situation descriptions, and counterfactual conditions. These templates can handle different types of sarcastic conversations. Next, the sarcastic conversations, related rhetorical devices, and context information are processed into specific variables and filled into the predefined templates to generate counterfactual conversations.
[0059] To ensure the quality of the generated conversations, basic conditional judgments can be introduced in this process to make the generated conversations meet the non-sarcastic expression standards. For example, during the filling process of characters and situations, check whether the variable content conforms to the sarcastic features to ensure the logical and fluency of the counterfactual conversations are reasonable. After generation, the automated tool will conduct a preliminary screening of the generated conversations and eliminate conversation fragments with illogical coherence, rigid expressions, or still having a sarcastic meaning.
[0060] Then, the counterfactual conversations that have passed the preliminary screening will be submitted to human annotators for further review and revision to ensure that the final output meets the requirements of non-sarcastic conversations. In this iterative process, the annotators will make adjustments and optimizations based on the naturalness, logical relevance, and richness of the expression of the conversation content. Through such iteration, it is ensured that a new dataset containing sarcastic and non-sarcastic conversations is finally constructed. The dataset will contain the same number of conversations with higher quality, improving the standardization and practicality of conversation generation. Finally, a new dataset containing the same number of sarcastic and non-sarcastic conversations is constructed to make the generation of counterfactual conversations more standardized and efficient, maintaining an expression scale similar to the original sarcastic conversations to achieve effective counterfactual rewriting.
[0061] S3: Fine-tune the language model and perform knowledge enhancement to optimize the sarcasm detection performance of the language model.
[0062] Further, the fine-tuned language model includes classifying data through pre-trained language models Bert and RoBERTa based on a fine-grained irony dataset, calculating the F1 scores of the ironic category and the non-ironic category, and calculating the classification model performance metric Macro F1 of the language model to evaluate the irony detection performance of the dataset on the language model.
[0063] It should be noted that knowledge enhancement includes optimizing the irony detection performance of the language model through double counterfactual enhancement and competitive rationalization; double counterfactual enhancement includes generating new ironic-non-ironic pairs based on a fine-grained irony dataset by a large model and automatically filtering out unwanted and highly similar conversations; competitive rationalization includes applying the internal knowledge and reasoning ability of the large model to the irony detection model, and the large model generates competitive reasons to clarify the reasoning processes of irony and non-irony respectively using potential irony labels.
[0064] It should also be noted that double counterfactual enhancement, as Figure 5 shown above, uses the ironic-non-ironic conversation pairs in the existing irony dataset as input to prompt the large model to generate new ironic-non-ironic conversation pairs. This process is divided into the following sub-steps:
[0065] a) Rewrite the conversation: Analyze the given conversation pair to understand the nuances between irony and non-irony, convert the ironic conversation into a direct, non-ironic version; select a suitable ironic target (which can be a person, thing or event), specify the rhetorical device to be used and provide corresponding context examples, and perform precise operations on the generated ironic conversation.
[0066] b) Automatic filtering: Apply the large model to automatically filter out unwanted conversations. For non-ironic conversations, delete unnatural or incoherent conversations and those still containing irony, and then calculate the Jaccard similarity to remove conversations with high similarity. For ironic conversations, design rules to delete highly similar conversations and reduce the frequency of frequently occurring ironic cue words (such as of course, because, absolutely, yes, etc.).
[0067] Competitive rationalization, as Figure 5 shown below, the competitive reasons of the large model generally refer to describing the reasoning process from multiple perspectives based on prior knowledge, which helps in a more comprehensive and balanced decision-making process and makes more robust predictions. To apply the internal knowledge and reasoning ability of the large model to the irony detection model, prompt it to generate competitive reasons to elaborate the reasoning processes from the ironic and non-ironic perspectives respectively.
[0068] Example 2, referring to Figures 6-8 , is an embodiment of the present invention, which provides an irony detection method for rhetorical devices. To verify the beneficial effects of the present invention, scientific demonstration is carried out through economic benefit calculation and simulation experiments.
[0069] To verify the effectiveness of the present invention, a comparative experiment was conducted on the rhetorical device-oriented irony detection method of the present invention and the zero-shot learning model. The Macro F1 and the F1 scores of the ironic category and the non-ironic category were used to evaluate the effects of each method, and the precision P and recall rate R were given for reference, as Figure 6 shown, Figure 6 In the table, Model is the model, Ace is the accuracy rate, Sarc is the ironic category, Non-Sarc is the non-ironic category, Zero-shot is the zero-shot learning model, Fine-tuning is the fine-tuning model, w / CR is competition rationalization, and w / DCA is double counterfactual augmentation.
[0070] From Figure 6 the comparative experiment results, it can be found that the performance of the zero-shot models varies greatly. GPT-4-turbo shows excellent and balanced performance on most metrics, but the recall rate of non-ironic conversations is slightly lower than that of the fine-tuning model, highlighting a common challenge in irony detection, that is, large models are good at detecting irony but perform poorly in identifying non-ironic samples. Similarly, the GPT-3.5 and LLaMA3 models perform extremely well in the recall rate of irony and the precision of non-irony, but perform poorly in the precision of irony and the recall rate of non-irony, indicating that they tend to predict irony, limiting their effectiveness in practical applications because accurately distinguishing between irony and non-irony is equally important.
[0071] In contrast, the fine-tuning model has obvious advantages and shows more balanced and consistent performance on all evaluation metrics. Among them, the best-performing fine-tuning model is better than the zero-shot models GPT-3.5 and LLaMA3 with different parameter scales. Thus, although large models have powerful zero-shot learning capabilities, task-specific fine-tuning can better handle different types of irony in complex and diverse scenarios, while bringing more balanced and reliable performance. In addition, models using additional knowledge enhancement strategies are mostly better than their basic versions. Introducing double counterfactual augmentation has obvious effects on BERT base 、BERT large and RoBERTa, with Macro F1 increasing by 1.5 / 5.8 / 5.7 (%) respectively. Among them, the RoBERTa model performs the best among the fine-tuning models, with an accuracy rate of 72.3% and a Macro F1 of 72.2%, highlighting the effectiveness of rhetorical device-aware counterfactual data augmentation in improving the performance and robustness of irony detection models; introducing competition rationalization also has certain improvements on BERT large and RoBERTa, by 4.8% and 2.9% respectively, indicating that using the competitive reasons generated by large models helps the fine-tuning model better understand and distinguish between irony and non-irony.
[0072] To test the generalization of sarcasm detection across different datasets, sarcasm detection is performed in two ways: in-dataset detection and cross-dataset detection. As Figure 7 shown,[[]] Figure 7 in the figure, Intra-dataset represents the results within the dataset, and Predicted represents the results of the predicted dataset. All results are Macro F1. Among all datasets, compared with the CSC dataset with 5000 training data and the MUStARD dataset with 500 training data, the fine-grained sarcasm dataset (Ours) with 1400 training data proposed by the present invention has the best performance. This may be because although the CSC dataset has a large amount of data, it lacks scene diversity and there are many samples with high similarity or even duplicates. The MUStARD dataset has a small amount of data and loses multimodal clues in the pure text setting. However, the dataset (Ours) proposed by the present invention better balances the dataset size and data quality and can handle different types of sarcasm. In terms of cross-dataset generalization performance, the dataset (Ours) proposed by the present invention shows obvious advantages. Taking BERT base as an example, when fine-tuned on Ours, it achieves performances of 54.4% and 49.2% on the CSC and MUSTARD datasets respectively. In contrast, the model fine-tuned on CSC only reaches a performance of 42.2% on MUSTARD, while the model fine-tuned on MUSTARD shows a performance of 51.3% on CSC. The generalization experiment results on the other two models also show consistent performances, indicating that the dataset proposed by the present invention helps to construct a robust model that can effectively identify sarcasm in different scenarios.
[0073] To more intuitively demonstrate the role of the sarcasm classification method for rhetorical devices proposed by the present invention, several types of sarcastic conversations and corresponding counterfactuals are selected, such as Figure 8 shown. In the example of innuendo, the sarcastic segment does not appear in the last response but in the second response. However, the last response provides important contextual clues for detecting the sarcasm in the segment. In response to this situation, the corresponding counterfactual accurately modifies the sarcastic segment, removing the sarcasm while retaining the speaker's original intention and not changing the last response. In the example of exploiting presupposition, the speaker presupposes that bringing someone a Cylon toast will be laughed at. The corresponding counterfactual removes the mocking meaning while retaining the presupposition that a Cylon toast is not a gift in the traditional sense. In the example of metaphor, the speaker uses both metaphor and hyperbole to criticize extremely uncomfortable pants. The corresponding counterfactual directly expresses that the pants are very uncomfortable, also removing the sarcasm while retaining the speaker's original intention. Examples of the remaining rhetorical devices will not be elaborated.
[0074] In summary, the irony detection method for rhetorical devices proposed by the present invention has great advantages in fully capturing the complexity of irony compared with the existing commonly used irony detection methods. In addition, the counterfactual data augmentation for rhetorical device perception in ironic conversations designed by the present invention can make full use of the internal knowledge and reasoning ability of large models, thereby improving the quality of the generated counterfactuals.
[0075] Example 3. Refer to Figure 9 This is an embodiment of the present invention, which provides an irony detection system for rhetorical devices, including a fine-grained data collection module, a counterfactual generation module, and a model fine-tuning and knowledge enhancement module.
[0076] Among them, the fine-grained data collection module is used to collect ironic conversations and perform the first annotation; the counterfactual generation module is used to perform the first counterfactual processing and construct a fine-grained irony dataset; the model fine-tuning and knowledge enhancement module is used to fine-tune the language model and perform knowledge enhancement to optimize the irony detection performance of the language model.
[0077] If the functions are implemented in the form of software function units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods in various embodiments of the present invention. The foregoing storage medium includes: USB flash drives, mobile hard disks, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), magnetic disks, or optical disks, etc., which can store program codes.
[0078] The logic and / or steps represented in the flowchart or described in other ways herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be specifically implemented in any computer-readable medium for use by an instruction execution system, apparatus, or device (such as a computer-based system, a system including a processor, or other systems that can fetch and execute instructions from the instruction execution system, apparatus, or device), or in combination with these instruction execution systems, apparatus, or devices. For the purposes of this specification, a "computer-readable medium" can be any device that can contain, store, communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
[0079] More specific examples (a non-exhaustive list) of computer-readable media include the following: an electrical connection (electronic device) having one or more wirings, a portable computer diskette (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disc read-only memory (CDROM). Additionally, the computer-readable media can even be paper or other suitable media on which a program can be printed, because the program can be obtained electronically, for example, by optically scanning the paper or other media, followed by editing, interpretation, or otherwise processing it in a suitable manner if necessary, and then storing it in a computer memory.
[0080] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, any one or a combination of the following techniques well known in the art can be used: discrete logic circuits having logic gate circuits for implementing logical functions on data signals, application specific integrated circuits having appropriate combinational logic gate circuits, programmable gate arrays (PGAs), field programmable gate arrays (FPGAs), etc. It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit them. Although the present invention has been described in detail with reference to the preferred embodiments, those of ordinary skill in the art should understand that the technical solutions of the present invention can be modified or equivalently replaced without departing from the spirit and scope of the technical solutions of the present invention, and they should all be covered by the scope of the claims of the present invention.
[0081] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit them. Although the present invention has been described in detail with reference to the preferred embodiments, those of ordinary skill in the art should understand that the technical solutions of the present invention can be modified or equivalently replaced without departing from the spirit and scope of the technical solutions of the present invention, and they should all be covered by the scope of the claims of the present invention.
Claims
1. A method for detecting sarcasm based on rhetoric, characterized in that: include: Collect sarcastic dialogues and make the first annotation; Conduct the first counterfactual processing and construct a fine-grained sarcasm dataset; Fine-tune the language model and perform knowledge enhancement to optimize the language model's sarcasm detection performance.
2. The method for detecting sarcasm based on rhetoric as claimed in claim 1, characterized in that: The collecting of sarcastic dialogues includes extracting sarcastic dialogues.
3. The method for detecting sarcasm based on rhetoric as claimed in claim 2, characterized in that: The first marking includes marking satirical fragments and rhetoric.
4. The method for detecting sarcasm based on rhetoric as claimed in claim 3, characterized in that: The performing the first counterfactual processing includes generating a counterfactual dialogue.
5. The method for detecting sarcasm based on rhetoric as claimed in claim 4, characterized in that: The construction of a fine-grained sarcasm dataset includes sarcastic and non-sarcastic dialogues.
6. The method for detecting sarcasm based on rhetoric as claimed in claim 5, characterized in that: The fine-tuning language model includes classifying data based on a fine-grained sarcasm dataset using pre-trained language models Bert and RoBERTa, calculating the F1 scores of sarcasm categories and non-sarcasm categories, and calculating the classification model performance indicator Macro F1 of the language model, and evaluating the sarcasm detection performance of the dataset on the language model.
7. The method for detecting sarcasm based on rhetoric as claimed in claim 6, characterized in that: The knowledge enhancement includes optimizing the language model sarcasm detection performance through double counterfactual enhancement and competitive rationalization; Double counterfactual enhancement includes generating new sarcasm-non-sarcasm pairs based on a fine-grained sarcasm dataset, and automatically filtering out unwanted and highly similar conversations; Competitive justification involves applying the internal knowledge and reasoning capabilities of the big model to the sarcasm detection model. The big model generates competing justifications, using potential sarcasm labels to illustrate the reasoning process of sarcasm and non-sarcasm respectively.
8. A system using the method for detecting sarcasm in rhetoric as claimed in any one of claims 1 to 7, characterized in that: It includes fine-grained data collection module, counterfactual generation module, model fine-tuning and knowledge enhancement module; The fine-grained data collection module is used to collect sarcastic dialogues and perform a first annotation; The counterfactual generation module is used to perform a first counterfactual processing and construct a fine-grained satire dataset; The model fine-tuning and knowledge enhancement module is used to fine-tune the language model and perform knowledge enhancement to optimize the sarcasm detection performance of the language model.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the sarcasm detection method for rhetorical devices according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the sarcasm detection method for rhetorical devices according to any one of claims 1 to 7 are implemented.