Verb metaphor identification method based on multi-verb extraction and thought chain prompts

By using the methods of multi-verb extraction and thought chain prompts, combined with MIP and SPV theories, we analyze verb collocation deviations and generate metaphorical interpretations, solving the problem of insufficient precision in Chinese verb metaphor recognition and achieving higher recognition accuracy and interpretability.

CN119646226BActive Publication Date: 2025-10-03DALIAN UNIV OF TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411861672.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-17
Publication Date
2025-10-03
Estimated Expiration
2044-12-17

AI Technical Summary

Technical Problem

Existing Chinese verb metaphor recognition methods have insufficient recognition accuracy when dealing with multi-verb scenarios and lack explanatory support for the reasons for metaphor generation, making it difficult to improve recognition accuracy.

Method used

A method based on multi-verb extraction and thought chain prompting is adopted. All verbs in the sentence are extracted through word segmentation tools. The MIP and SPV theories are combined to analyze verb collocation deviation. A large model is used for thought chain prompting, metaphorical interpretation is generated, and the verb and interpretation information are encoded into feature vectors for classification and judgment.

Benefits of technology

The accuracy and interpretability of Chinese verb metaphor recognition have been significantly improved, which enables a better understanding of the reasons for metaphor generation and improves the model's recognition accuracy and interpretation ability for metaphors.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119646226B_ABST
    Figure CN119646226B_ABST
Patent Text Reader

Abstract

A verb metaphor recognition method based on multi-verb extraction and thought chain prompting belongs to the field of natural language processing in deep learning and is used for metaphor recognition of Chinese sentences. The key points are: extracting verbs from texts in a data set; performing thought chain prompting on a large model to obtain a prompt result of whether the verb is a metaphor; splicing the sentence containing the verb in the text with the verb and encoding them to obtain a sentence feature vector; encoding the prompt result as a thought chain feature vector; splicing the sentence feature vector with the thought chain feature vector at a certain weight ratio to obtain a spliced ​​feature vector; inputting the spliced ​​feature vector into a classification model for metaphor judgment to obtain a judgment result of whether the sentence contains a metaphor. The present invention can significantly improve the accuracy and interpretability of metaphor recognition.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of natural language processing in deep learning, and specifically relates to a Chinese verb metaphor recognition method based on multi-verb extraction and thought chain prompts. This method can be applied to the metaphor recognition task of Chinese sentences, aiming to improve the accuracy and interpretability of metaphor recognition. Background Art

[0002] Metaphor is an important component of human language and thinking, playing a key role in daily communication, literary creation, and advertising design. The essence of metaphor is to map the characteristics of one specific thing onto another through unconventional semantic associations, thereby achieving a deeper expression of meaning. Metaphor recognition is one of the important research directions in the field of natural language processing. It helps to improve the model's ability to understand metaphorical language, thereby improving the performance of tasks such as machine translation and text generation. However, the complexity and diversity of metaphors make their identification and understanding extremely challenging. Especially in the Chinese context, because sentences often contain multiple verbs and have complex semantic and syntactic relationships, how to efficiently identify metaphors and explain their generation has become a pressing problem.

[0003] Current approaches to verb metaphor identification primarily focus on two technical approaches. The first is based on metaphor identification theory, such as MIP (Metaphor Identification Program) and SPV (Selection Preference Violation). These methods model the semantic encoding of the target verb and compare its contextual semantic representation with the verb's literal meaning to determine whether a metaphor exists. This approach eliminates the need to extract the subject and object of the verb and directly captures metaphorical features from the overall semantics of the sentence. However, its ability to parse complex sentences is limited. The second is based on abstraction ranking. These methods extract the subject and object of the core verb, analyze their abstractness compared to conventional subject-object collocations, and calculate semantic similarity using topic mapping. This approach relies on the accurate extraction of the core verb, but in long Chinese sentences, specifying the core verb often requires manual intervention, which is not only time-consuming and labor-intensive but may also be inconsistent with the model's semantic understanding criteria. Furthermore, most of these methods focus on outcome judgment and lack explanatory support for the reasons behind metaphor generation. This makes it difficult to provide a deep understanding of the metaphor generation mechanism and semantic mapping process, thus limiting further improvements in identification accuracy. Summary of the Invention

[0004] In order to improve the accuracy of verb metaphor recognition, in a first aspect, a verb metaphor recognition method based on multi-verb extraction and thought chain prompting according to some embodiments of the present application includes the following steps:

[0005] Extract verbs from texts in the dataset;

[0006] Conduct thought chain prompts on the large model to obtain prompt results on whether the verb is a metaphor;

[0007] Concatenate the sentence containing the verb in the text with the verb and encode the concatenated sentence to obtain a sentence feature vector;

[0008] encoding the prompt result into a thought chain feature vector;

[0009] splicing the sentence feature vector and the thought chain feature vector in a certain weight ratio to obtain a spliced ​​feature vector;

[0010] The concatenated feature vector is input into a classification model to perform metaphor judgment, thereby obtaining a judgment result of whether the sentence contains a metaphor.

[0011] According to some embodiments of the present application, a verb metaphor identification method based on multi-verb extraction and thought chain prompting, wherein the step of extracting verbs from text in a dataset includes the following steps:

[0012] Splitting the text in the data set into sentences by commas;

[0013] Using a word segmentation tool to mark the parts of speech of the sentences and perform dependency analysis to obtain the dependency relationships between words;

[0014] Relations containing a subject or an object in the clauses are extracted according to the dependency relationships, and the verbs are filtered from the relationships.

[0015] According to some embodiments of the present application, a verb metaphor identification method based on multi-verb extraction and thought chain prompting is described, wherein the text in the data set is divided into sentences by commas, as represented by the following formula:

[0016]

[0017] Where, Represents a text, Indicates the clauses separated by commas in each sentence, where ∈(1, ), t n Indicates the last clause in each sentence of text;

[0018] The step of using a word segmentation tool to mark the parts of speech of the sentence and analyze the semantic relationship includes the following steps:

[0019] Use the word segmentation tool to segment each of the clauses, as shown in the following formula:

[0020]

[0021] Where, It is a clause The word segmentation results, Expressive clause The words, is the total number of words in the clause;

[0022] In the step, the relationship containing the subject or object in the sentence is extracted according to the dependency relationship, and the verb is selected from the relationship, which is expressed by the following formula:

[0023]

[0024] Where, Indicates the type of dependency, Represents the position index of the central word in the dependency relationship, Represents the position index of the dependent word, represents a triple, Represents a set of dependency relationships;

[0025]

[0026] Where, A tuple indicating the presence of a subject or object in a dependency relation;

[0027]

[0028] Where, Represents the set of verb indexes that meet the subject and object conditions in the dependency relationship, Represents the position index in the dependency relationship, POS( ) indicates the index position The part of speech of the word;

[0029]

[0030] Where, The set of verbs representing all clauses, Indicates the specific verb that indexes the corresponding participle position.

[0031] According to some embodiments of the present application, the verb metaphor identification method based on multi-verb extraction and thought chain prompting, wherein the thought chain prompting in the step of performing thought chain prompting on the large model to obtain the prompt result of whether the verb is a metaphor includes:

[0032] Tip 1: Extract and analyze the basic meaning of the verb and its meaning in context;

[0033] Tip 2: Analyze the subject and object collocation of the verb to determine whether there is any collocation deviation;

[0034] Tip 3: Based on Tips 1 and 2, determine whether the verb is a metaphor and generate a metaphorical explanation.

[0035] According to some embodiments of the present application, a verb metaphor identification method based on multi-verb extraction and thought chain prompts, wherein the prompt 1 is represented by the following formula:

[0036]

[0037] Where, represents the target word, literal_meaning(w) represents the literal meaning of the target word, and contextual_meaning(w) represents the meaning of the target word in a specific context;

[0038] Wherein, the prompt 2 is represented by the following formula:

[0039]

[0040] Where, represents the target word, preference(w, context) represents the semantic preference of the target word in the context, expected_preference(w) represents the expected preference of the target word in the conventional context, when the semantic preference of the target word in a specific context does not match the conventional semantic preference, it is judged as a metaphor and output 1, otherwise it outputs 0;

[0041] Among them, the prompt 3 includes

[0042] According to Tip 1, when the literal meaning is not equal to the meaning in the context, it is judged as a metaphor. Output 1, otherwise Output 0;

[0043] According to Tip 2, when the semantic preference of the target word in a specific context does not match the conventional semantic preference, it is judged as a metaphor. Output 1, otherwise Output 0.

[0044] According to some embodiments of the present application, a verb metaphor identification method based on multi-verb extraction and thought chain prompting is described, wherein the sentence containing the verb in the text is concatenated with the verb code, as represented by the following formula:

[0045]

[0046] in:

[0047]

[0048] Where, Represents a text, Indicates the clauses separated by commas in each sentence, where ∈(1, ), t n Indicates the last clause in each sentence of text;

[0049] Where, In a text The set of verbs in all clauses of Indicates the verb, v Indicates the last verb;

[0050] Represents a splicing operation, Represents concatenated text.

[0051] Among them, the sentence feature vector encoded in the step is expressed by the following formula:

[0052]

[0053] Where, Represents the sentence feature vector;

[0054] In the step, the prompt result is encoded into a thought chain feature vector, which is represented by the following formula:

[0055]

[0056] Where, represents the thought chain feature vector, Indicates prompt results.

[0057] According to some embodiments of the present application, a method for identifying verb metaphors based on multi-verb extraction and thought chain prompting includes the following steps: concatenating the sentence feature vector and the thought chain feature vector at a certain weight ratio to obtain a concatenated feature vector.

[0058] Calculating an average length ratio of a sentence feature vector and a thought chain feature vector, and allocating space according to the average length ratio;

[0059] Concatenate the sentence feature vector and the thought chain feature vector in proportion;

[0060] In the step, the average length ratio of the sentence feature vector and the thought chain feature vector is calculated, and the space is allocated according to the average length ratio, which is expressed by the following formula:

[0061] ,

[0062] Where, The sentence feature vector representing the distribution ratio, represents the input ratio of the sentence feature vector, The thought chain eigenvector representing the distribution ratio, Represents the input ratio of the thought chain feature vector;

[0063] Among them, the sentence feature vector and the thought chain feature vector are spliced ​​in proportion in the step, which is expressed by the following formula:

[0064]

[0065] Where, Represents the concatenated feature vector.

[0066] According to some embodiments of the present application, a verb metaphor identification method based on multi-verb extraction and thought chain prompting is described. In the step, the concatenated feature vector is input into a classification model for metaphorical judgment, and a judgment result of whether the sentence contains a metaphor is obtained, which is represented by the following formula:

[0067]

[0068] is the prediction result, indicating whether the text belongs to the metaphorical or non-metaphorical category. W is the weight of the model, b is the bias term of the model, and the softmax function maps all output values ​​to the range of [0, 1] and selects the corresponding category based on the maximum probability value.

[0069] Among them, the cross-entropy loss function (Cross-EntropyLoss) of the model training is expressed by the following formula:

[0070]

[0071] Where, is the category distribution of the true label, It is the predicted probability calculated by the softmax function.

[0072] In a second aspect, an embodiment of the present application further provides an electronic device, comprising: one or more processors, a memory, and one or more programs; wherein the one or more programs are stored in the memory, and the one or more programs include instructions, which, when executed by the electronic device, enable the electronic device to execute the first aspect and any possible technical solution of the first aspect thereof.

[0073] In a third aspect, an embodiment of the present application further provides a computer-readable storage medium, which includes a computer program. When the computer program runs on an electronic device, the electronic device executes the first aspect and any possible technical solution of the first aspect.

[0074] Beneficial effects:

[0075] The present invention proposes a verb metaphor recognition method based on multi-verb extraction and thought chain prompts. First, a word segmentation tool is used to extract all verbs with practical meaning in a sentence, avoiding the subjectivity that may be caused by artificially specifying core verbs and ensuring that the model pays attention to all verbs; secondly, the MIP and SPV theories are combined and thought chain prompts are incorporated to help the model understand metaphors and generate contextual explanation information in which the metaphor occurs, and the explanation information is input into the model together with the extracted verbs for encoding. In this way, the model can not only pay attention to all verbs and their semantic features, but also deeply understand the reasons for the generation of metaphors, thereby significantly improving the accuracy and interpretability of verb metaphor recognition. Additional aspects and advantages of the present invention will be given in part in the description below, and in part will become apparent from the description below, or will be understood through the practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0076] Figure 1 Technology roadmap.

[0077] Figure 2 Architecture diagram of the verb metaphor recognition model based on multi-verb extraction and thought chain prompts.

[0078] Figure 3 Dependency parsing syntax tree diagram.

[0079] Figure 4 Specific thought chain prompt example diagram.

[0080] Figure 5 Large model test instruction format diagram. DETAILED DESCRIPTION

[0081] In order to more clearly demonstrate the purpose, technical solutions and features of the present invention, the present invention is now further described in detail in conjunction with specific embodiments and with reference to the accompanying drawings. The embodiments of the present application are described in detail below with reference to the accompanying drawings. Examples of the embodiments are shown in the accompanying drawings. The present application provides a method and an electronic device. Among them, the method and the device are based on the same technical concept. Since the principles of solving the problem by the method and the device are similar, the implementation of the device and the method can refer to each other, and the repeated parts will not be repeated.

[0082] Chinese texts often contain multiple verbs and have complex semantic structures. Different verbs may belong to different phrases or semantic units. Existing metaphor identification methods often assume that a sentence has only one core verb, ignoring the diversity of metaphors in multi-verb contexts and lacking an effective explanation for the metaphor generation process.

[0083] The verb metaphor recognition method based on multi-verb extraction and thought chain prompting in the present invention is a metaphor recognition method that combines word segmentation tools for multi-verb extraction and integrates MIP theory, SPV theory and thought chain prompting.

[0084] The method in this embodiment uses a word segmentation tool to efficiently and accurately extract all verbs in a sentence. It then uses a large model combined with MIP theory to extract the implicit meaning of the verbs, applies SPV theory to analyze deviations in verb collocations, and generates metaphorical interpretations through COT. This method effectively captures metaphorical features in multi-verb scenarios and significantly improves the accuracy and interpretability of metaphor recognition. This dual improvement provides a more comprehensive and efficient solution for Chinese verb metaphor recognition.

[0085] In a first embodiment of the present invention, a verb metaphor recognition method based on multi-verb extraction and thought chain prompting includes the following steps:

[0086] Step 1: This paper uses the corpus provided in the CCL2018 Chinese Metaphor Recognition and Sentiment Analysis Task, focusing on the classification subtask of metaphor recognition. By screening the training set and test set in this task, retaining sentences labeled "verb metaphor (1)" and "literal meaning (0)", a dataset suitable for the binary classification task was finally constructed. This dataset contains the initial text and the corresponding labels, of which the training set contains 2359 data items and the test set contains 593 data items;

[0087] Step 2: Extract multiple verbs: After splitting the text in the dataset by commas, use the CoreNLP tool to perform part-of-speech tagging and semantic relationship analysis on the segmented sentences. By analyzing the semantic relationships, valid relationships involving subjects and objects are extracted, and verbs with actual semantic functions are screened out. This process ensures that the extracted verbs are actual predicate verbs in the sentences, rather than isolated or meaningless motivators, thereby improving the accuracy of verb metaphor recognition.

[0088] Step 3: Thought chain prompts: By combining MIP (metaphor identification program) and SPV (selective preference violation) theory, the COT (thought chain) prompts of the large model are used to extract rich semantic information, thereby improving the accuracy of metaphor recognition. Prompt 1: Analyze the verbs in the text and extract the difference between their basic meaning and the actual meaning in the context; Prompt 2: Analyze the subject and object collocation of the verbs and check whether these collocations conform to common usage, especially whether there are any deviations from the norm; Prompt 3: Based on the analysis of the first two steps, determine whether the verb is metaphorical, especially when the collocation violates the norm, and give a detailed explanation. In this process, the COT framework of the large model helps the small model to understand the metaphors in the text more accurately, and provides strong support for the recognition of metaphors through the rich semantic information extracted;

[0089] Step 4: Feature concatenation: First, concatenate the verb features extracted in step 2 with the original text to form a new text, which is then fed into the pre-trained model for encoding to generate a sentence feature vector containing verb information. Next, the metaphor analysis results generated by the thought chain prompt in step 3 are fed into the pre-trained model to obtain the corresponding feature vector. Finally, according to the preset weight ratio, the sentence feature vector and the thought chain feature vector are concatenated to form a comprehensive feature vector representation for the next step of metaphor recognition.

[0090] Step 5: Metaphor Identification and Classification: The concatenated feature vectors are fed into a classification model to determine metaphoricality. Supervised training is performed on the concatenated features, and classification is performed using the softmax function. The final output is whether the sentence contains a metaphor. This result serves as the basis for the model's ability to identify metaphorical language in the text.

[0091] Specifically, in step 1, Chinese sentences are different from English sentences. They are usually composed of multiple clauses and verbs. Therefore, it is necessary to first divide the sentence into clauses, and then extract the verbs one by one based on the relationship between the various components in the sentence to ensure that the extracted verbs are accurate and have practical meaning;

[0092] For a text T=[t1,t2,…,t i ,…,t n ], where t i Represents the clauses separated by commas in each sentence, i∈(1,n), where n is the number of commas in the sentence plus one; first, remove irrelevant characters to ensure accurate division of sentence structure, and then use the word segmentation tool to segment each clause to obtain Wi=[w i1 ,w i2 ,…,w ij ,…,w im ], where Wi is the word segmentation result of clause ti, w ijrepresents the jth word in clause ti, and m is the total number of words in the clause. Subsequently, dependency parsing is performed on each clause after word segmentation to obtain the dependency relationships between words. By screening for valid dependencies containing subjects or objects, verbs are further extracted, and finally a verb set is constructed. The specific calculation process is shown in the following formula:

[0093]

[0094]

[0095]

[0096]

[0097] in, Indicates the type of dependency relationship (for example, subj represents the subject and obj represents the object), Represents the position index of the central word in the dependency relationship; Represents the position index of the dependent word; each tuple is in the form of ,The dependency parsing result uses a numerical index to indicate the position of the word in the sentence; A tuple indicating the presence of a subject or object in a dependency relation, Represents the position index in the dependency relationship, which may be or , POS( ) indicates the index position The part of speech of the word, The verb set representing all the final clauses.

[0098] In step three, we use the thought chain prompt method to provide additional reasoning information to the large model, thereby improving the accuracy of metaphor recognition. Thought chain prompt is a technique that helps the model understand and generate more complex semantic inferences through step-by-step reasoning. In this task, the thought chain method helps the model identify potential metaphors in the text by guiding it to think step by step. At the same time, the metaphor identification procedure (MIP: identifying metaphors by comparing the literal meaning of a word with the meaning of the word in this context) and the selection preference violation (SPV: identifying metaphors by paying attention to the semantic contrast between the target word and its context) theory are combined in the large model thought chain prompt to provide a reliable theoretical basis for the results of the large model, so that the pre-trained model can obtain more accurate and reliable results; the specific thought chain prompt is divided into three steps, as follows:

[0099] Tip 1: Understand the text and extract verbs, analyzing the basic meaning of each verb and its meaning in context (incorporating metaphor recognition process theory).

[0100] First, COT prompts the model to understand and extract verbs from the text, analyzing their basic meaning and contextual significance. This chain of thought guides the model's step-by-step reasoning, identifying the potential metaphorical nature of the verb in the current context. By analyzing the verb's literal meaning and its actual meaning in a specific context, the model can gradually determine whether the verb possesses metaphorical significance.

[0101]

[0102] Among them, w represents the target word, literal_meaning(w) represents the literal meaning of the word, and contextual_meaning(w) represents the meaning of the word in a specific context. When the literal meaning is not equal to the meaning in the context, it is judged as a metaphor (output 1), otherwise it outputs 0.

[0103] Tip 2: Determine the subject and object collocations for each verb in the text and analyze whether there are any inconsistencies between the actual collocations in the text and common usage.

[0104] SPV theory provides an important framework for metaphor identification, noting that metaphors often arise from semantic mismatches, or collocational deviations, between a target word and its context. By gradually examining the semantic relationships between a verb and its subject and object, the thought chain helps the model identify verbs with unusual collocations, which often have metaphorical potential.

[0105]

[0106] Among them, w represents the target word, preference(w,context) represents the semantic preference of the target word in the context, and expected_preference(w) represents the expected preference of the word in the regular context. When the semantic preference of the target word in a specific context does not match the regular semantic preference, the output is 1 to indicate metaphor; otherwise, the output is 0.

[0107] Hint 3: Based on the analysis in the first two steps, determine whether there is metaphorical meaning, especially when common collocations are violated, and give a detailed explanation.

[0108] Based on the analysis of prompts 1 and 2, the chaining method further guides the model to determine whether a verb is metaphorical, especially when there are deviations in collocation. Through step-by-step reasoning, the chaining method helps the model better understand which deviations in collocation indicate potential metaphoricality. The chaining method not only determines whether a verb is metaphorical but also generates a detailed metaphorical explanation, explaining why the verb is metaphorical in this context. The chaining prompts play a role in this process by guiding the model's reasoning step by step, clarifying the changes in the verb's meaning and the unusual nature of the collocation. Ultimately, based on this information, the model determines whether a metaphor exists and generates a detailed metaphorical explanation.

[0109] In step 4, we concatenate the features obtained in steps 2 and 3. The specific steps are as follows:

[0110] 1. The verb is spliced ​​into the original sentence

[0111] In step 2, we extracted all the verbs in the text. These verbs represent the core actions in the text. To combine these verbs with the original sentence, we first concatenate the extracted verbs directly into the original sentence. This gives us a new input sentence containing all the extracted verbs.

[0112] Our original sentence is represented as T=[t1,t2,…,t i ,…,t n ], and the extracted sentence verb is V=[v1,v2,…,v i ,…,v n ]. We concatenate these two parts to generate a new input sentence :

[0113]

[0114] here, Indicates concatenation operation to form new text .

[0115] 2. Input to the XML-RoBERTa pre-trained model for encoding

[0116] Next, we input the concatenated text T′ into the XML-RoBERTa model for encoding, generating a sentence vector T′′ containing verb information. This pre-trained model converts the input text into a feature vector:

[0117]

[0118] The purpose of this step is to capture the contextual information of the text containing verbs through the pre-trained model, providing a basis for subsequent analysis.

[0119] 3. Coding thinking chain analysis results

[0120] In step 3, we have conducted metaphorical analysis on the text through the thought chain prompt method and generated metaphorical analysis results. In step 4, we will analyze the results Directly input the XML-RoBERTa model for encoding to obtain the thought chain feature vector Specifically, input the results of the thought chain analysis to the model and generate the corresponding feature vector:

[0121]

[0122] 4. Feature vector weighting and concatenation

[0123] We then concatenate the sentence feature vector T′′ containing the verb and the thought chain feature vector A′′. To ensure effective model learning and avoid redundant information, we first calculate the average length ratio of the sentence and thought chain results, and then allocate space based on this ratio to ensure a reasonable input length:

[0124]

[0125]

[0126] , Represents the input ratio of sentences and thought chains.

[0127] Then, concatenate the scaled feature vectors:

[0128] The final feature vector F will be used as input for downstream metaphor recognition.

[0129] In step 5, we input the concatenated feature vector F obtained in step 4 into the XML-RoBERTa classification model for metaphorical classification. In XML-RoBERTa, the model uses the softmax function to output a probability distribution representing the probability of the text belonging to each category. F is the input concatenated feature vector, and the softmax function calculates the category probability using the following formula:

[0130]

[0131] Here represents the prediction result, indicating whether the text belongs to the metaphor class (1) or the non-metaphor class (0), while W and b are the weights and bias terms of the model. The softmax function maps all output values ​​to the range of [0,1] and selects the corresponding category based on the maximum probability value.

[0132] To train the model, we use the cross-entropy loss function to calculate the predicted value The difference between the true label y. The cross entropy loss is calculated as follows:

[0133]

[0134] in, is the category distribution of the true label (metaphor category is 1, non-metaphor category is 0), It is the predicted probability calculated by the softmax function.

[0135] During training, we used two NVIDIA RTX4090 graphics cards for model training and the AdamW optimizer (Adam with weight decay) to update model parameters. The AdamW optimizer accelerates training while effectively preventing overfitting. Furthermore, we set the ReduceLROnPlateau strategy to automatically adjust the learning rate when the validation loss stops decreasing, thereby improving the model's convergence speed and stability.

[0136] In a second embodiment, the verb metaphor identification method based on multi-verb extraction and thought chain prompting of the present invention includes the following steps:

[0137] Step 1: Establishment of data set;

[0138] This paper uses the corpus provided in the CCL2018 Chinese metaphor recognition and sentiment analysis task, focusing on the classification subtask of metaphor recognition. Since this task covers verb metaphors and noun metaphors, in order to focus on the study of verb metaphors, a dataset suitable for the binary classification task was constructed by filtering and retaining only sentences labeled "verb metaphor (1)" and "literal meaning (0)". The composition of the dataset is as follows: Figure 3 As shown in the figure, this dataset contains the original text and its corresponding labels. The training set contains 2,359 data items, and the test set contains 593 data items. The training set is further divided into a training set and a validation set in a ratio of 8:2. The final dataset includes 1,887 training data items, 492 validation data items, and 593 test data items. The details are shown in Table 1. Take the sentence "Whoever can greet misfortune with courage and deal with misfortune with a smile can overcome all difficulties and obstacles" as an example. The words "to greet" and "to deal with" in this sentence are typical verb metaphors. Although "to greet" and "to deal with" usually refer to handling affairs or receiving guests, here, "to greet" is used to describe facing "misfortune" with courage, while "to deal with" refers to dealing with "misfortune" with a smile. These verbs deviate from their common collocations and are given positive and optimistic metaphorical meanings. Through this metaphor, the author conveys the importance of adopting a courageous and optimistic attitude when facing difficulties, emphasizing that this attitude can help people overcome difficulties and obstacles.

[0139] Step 2: Multi-verb extraction;

[0140] Table 1 Distribution of dataset data

[0141]

[0142] Since Chinese sentences generally contain multiple clauses, each of which has its own verb, for a given text T=[t1, t2, ..., ti ,…,t n ], where t i Indicates the clauses separated by commas in each sentence, i∈(1,n), where n is the number of commas in the sentence plus one. The specific steps for extracting verbs are as follows:

[0143] First, the text T is divided into clauses t by commas by removing irrelevant characters to ensure accurate division of sentence structure. i Then, use CoreNLP to analyze each sentence t i Perform word segmentation and obtain the word segmentation result Wi=[w i1 , w i2 ,…,w ij ,…,w im ], where Wi is the pair of clauses t i The word segmentation result, w ij Indicates clause t i is the jth word in the sentence, and m is the total number of words in the sentence.

[0144] Clause after the participle t i Perform dependency analysis to obtain the dependency set of the clause:

[0145]

[0146] in Indicates the dependency type, and They are the position indexes of the central word and dependent words respectively.

[0147] Filtering the Dependency Set The relationships related to the subject or object in the sentence constitute a set of valid dependency relations:

[0148]

[0149] According to the effective dependency set , extract the verb position index relative to the subject or object:

[0150]

[0151] Indexing a collection by position , get the corresponding verbs to form the final verb set:

[0152]

[0153] Finally, the verbs of each clause are combined The summary is used in the feature extraction stage of the subsequent metaphor recognition task.

[0154] CoreNLP is a powerful natural language processing toolkit that can perform comprehensive linguistic analysis on text, including word segmentation, part-of-speech tagging, named entity recognition, and dependency parsing. Its dependency parsing function can generate a dependency tree for a sentence, such as Figure 3 As shown in the figure, it shows the grammatical dependency relationships between words, such as subject (nsubj) and object (dobj). This dependency tree structure is particularly important in the task of extracting verb metaphors. It can help accurately identify the verbs and their collocations related to the subject, predicate, and object in a sentence, providing basic support for metaphor recognition.

[0155] Step 3: Thinking Chain Tips:

[0156] MIP theory and SPV theory are effective methods for metaphor detection, but when dealing with non-standardized multi-verb situations, it is often difficult to achieve accurate judgment. However, this does not affect its value as a metaphor detection theory. Therefore, the present invention combines the thinking chain prompts of the large model with the MIP theory and SPV theory, and realizes the specific application of these two theories through the method of prompt engineering, aiming to generate a detailed explanation of the reasons for the occurrence of metaphors. This not only provides additional information support for the pre-training model, but also maximizes the accuracy of metaphor recognition. The large model uses Llama3.1-70b, and the specific prompt content is as follows:

[0157] Tip 1: Understand the text and extract verbs, analyzing the basic meaning of each verb and its meaning in context (incorporating metaphor recognition process theory).

[0158] First, COT prompts the model to understand and extract verbs from the text, analyzing their basic meaning and contextual significance. This chain of thought guides the model's step-by-step reasoning, identifying the potential metaphorical nature of the verb in the current context. By analyzing the verb's literal meaning and its actual meaning in a specific context, the model can gradually determine whether the verb possesses metaphorical significance.

[0159]

[0160] Here, w represents the target word, literal_meaning(w) represents the literal meaning of the word, and contextual_meaning(w) represents the meaning of the word in a specific context. When the literal meaning is not equal to the meaning in the context, it is judged as a metaphor (output 1), otherwise it outputs 0.

[0161] Tip 2: Determine the subject and object collocations for each verb in the text and analyze whether there are any inconsistencies between the actual collocations in the text and common usage.

[0162] SPV theory provides an important framework for metaphor identification, noting that metaphors often arise from semantic mismatches, or collocational deviations, between a target word and its context. By gradually examining the semantic relationships between a verb and its subject and object, the thought chain helps the model identify verbs with unusual collocations, which often have metaphorical potential.

[0163]

[0164] Among them, w represents the target word, preference(w, context) represents the semantic preference of the target word in the context, and expected_preference(w) represents the expected preference of the word in the regular context. When the semantic preference of the target word in a specific context does not match the regular semantic preference, the output is 1 to indicate metaphor; otherwise, the output is 0.

[0165] Hint 3: Based on the analysis in the first two steps, determine whether there is metaphorical meaning, especially when common collocations are violated, and give a detailed explanation.

[0166] Based on the analysis in the first two steps, the chain of thought further guides the model to determine whether a verb is metaphorical, especially when there are deviations in collocation. Through step-by-step reasoning, the chain of thought method helps the model better understand which deviations in collocation indicate potential metaphoricality. The chain of thought method not only determines whether a verb is metaphorical but also generates a detailed metaphorical explanation, explaining why the verb is metaphorical in this context. The role of the chain of thought prompts in this process is to guide the model's reasoning step by step, clarifying the changes in the verb's meaning and the unusualness of the collocation. Ultimately, based on this information, the model determines whether a metaphor exists and generates a detailed metaphorical explanation.

[0167] All analysis results of the three prompts will be provided together as input to the pre-trained model to further support metaphor recognition.

[0168] In step 4, we encode and concatenate the results of steps 2 and 3. The specific steps are as follows:

[0169] In step 2, we extracted all the verbs in the text. These verbs represent the core actions in the text. To combine these verbs with the original sentence, we first concatenate the extracted verbs directly into the original sentence. This gives us a new input sentence containing all the extracted verbs.

[0170] Our original sentence is represented as T=[t1, t2, ..., t i ,…,t n ], and the extracted sentence verb is V={v1, v2, ..., v nWe concatenate these two parts to generate a new input sentence :

[0171]

[0172] here, Indicates concatenation operation to form new text .

[0173] Next, we input the concatenated text T′ into the XML-RoBERTa model for encoding to generate a sentence vector containing verb information XML-RoBERTa is a multilingual pre-trained model based on the RoBERTa architecture. It is specifically optimized for multilingual processing and is particularly suitable for processing text in multiple languages, including Chinese. Compared with traditional RoBERTa and BERT models, XML-RoBERTa performs better in cross-lingual tasks and can better capture the grammatical and semantic features of different languages, resulting in higher accuracy in tasks such as metaphor recognition. This pre-trained model converts the input text into a feature vector:

[0174]

[0175] The purpose of this step is to capture the contextual information of the text containing verbs through the pre-trained model, providing a basis for subsequent analysis.

[0176] In step 3, we have conducted metaphorical analysis on the text through the thought chain prompt method and generated metaphorical analysis results. In step 4, we will analyze the results Directly input the XML-RoBERTa model for encoding to obtain the thought chain feature vector Specifically, input the results of the thought chain analysis to the model and generate the corresponding feature vector:

[0177]

[0178] Next, we concatenate the sentence feature vector T′′ containing the verb and the thought chain feature vector A′′. To ensure effective model learning and avoid redundant information, we first calculated the average length of the sentence to be 20.29 and the average length of the thought chain result to be 470.13, with a ratio of approximately 1:24. The maximum input length was set to 512. However, in experiments, we found that the model performed best when the length ratio was 1:9. Therefore, we allocated space according to this ratio to ensure a reasonable input length:

[0179]

[0180]

[0181] , Represents the input ratio of sentences and thought chains.

[0182] Then, concatenate the scaled feature vectors:

[0183] The final feature vector F will be used as input for downstream metaphor recognition.

[0184] In step 5, we input the concatenated feature vector F from the previous step into the XML-RoBERTa classification model for metaphorical classification. In XML-RoBERTa, the model uses the softmax function to output a probability distribution representing the probability that the text belongs to each category. F is the input concatenated feature vector, and the softmax function calculates the category probability using the following formula:

[0185]

[0186] Here represents the prediction result, indicating whether the text belongs to the metaphor class (1) or the non-metaphor class (0), while W and b are the weights and bias terms of the model. The softmax function maps all output values ​​to the range of [0, 1] and selects the corresponding category based on the maximum probability value.

[0187] To train the model, we use the cross-entropy loss function to calculate the predicted value The difference between the true label y. The cross entropy loss is calculated as follows:

[0188]

[0189] in, is the category distribution of the true label (metaphor category is 1, non-metaphor category is 0), It is the predicted probability calculated by the softmax function.

[0190] During training, we used two NVIDIA RTX4090 graphics cards for model training. We used the AdamW optimizer (AdamwithWeightDecay) to update the model parameters, with an initial learning rate of 0.00001 and a number of epochs of 24. The AdamW optimizer helps accelerate training and prevent overfitting. We also set ReduceLROnPlateau to adjust the learning rate so that it decreases when the loss stops decreasing.

[0191] Experimental results and analysis: Based on the corpus provided by the CCL2018 Chinese metaphor recognition and sentiment analysis task, this paper focuses on the classification subtask of metaphor recognition and extracts a dataset of verb metaphors and non-metaphors from it for experimental comparison. The pre-trained model used in the experiment is :A model specifically optimized for the Chinese metaphor recognition task. Based on the RoBERTa architecture and pre-trained on a large-scale Chinese corpus, combined with dynamic masking and multi-head attention mechanisms, it significantly improves the model's performance and robustness on the Chinese metaphor recognition task. It demonstrates excellent recognition accuracy on multiple benchmark datasets and can effectively capture and understand metaphorical expressions in Chinese text. The experimental evaluation criteria use accuracy, precision, recall, and F1 value (F1score). Based on the actual labels of the data and the labels predicted by the algorithm, the prediction results can be divided into four categories: true positive (TP), true negative (TN), false positive (FP), and false negative (FN).

[0192] 1) Accuracy:

[0193] 2) Precision:

[0194] 3) Recall:

[0195] 4) F1 Score:

[0196] The first set of experiments compares the proposed model with commonly used metaphor recognition models. Commonly used Chinese metaphor recognition models are selected:

[0197] The HQU model, which took first place in the verb metaphor evaluation task at CCL 2018, employs a deep learning framework to address the problem of metaphor detection. The model combines a convolutional neural network (CNN) with a bidirectional long short-term memory (Bi-LSTM) network. The CNN extracts local features, while the Bi-LSTM captures long-range dependencies within a sentence. Furthermore, HQU employs an attention mechanism to focus on the contextual information most relevant to metaphor identification. This multi-layered model architecture enables HQU to accurately identify metaphorical verb usage in complex contexts.

[0198] MetaATT-Parser is a verb metaphor recognition model based on a synonym dictionary and an attention network. By combining the abstractness information from the synonym dictionary with Synonyms2Vec node representation learning, the model leverages LSTM and self-attention mechanisms to integrate the subject-verb-object structure in sentences, improving metaphor recognition.

[0199] MetaATT-Human uses the manually annotated subject-verb-object structure in the dataset instead of the extraction results of the syntactic analyzer. The rest of the parts are the same as MetaATT-Parser.

[0200] Compared with the verb metaphor recognition model based on multi-verb extraction and thought chain prompts, the experimental results are shown in Table 2. It can be seen from the experimental results that the present invention shows significant advantages in all indicators. Specifically, the F1 score of the present invention is 10.3% higher than the first-place HQU model in the initial evaluation task, and even compared with the manually screened MetaATT-Human model, the F1 score is 7.69% higher. In addition, except for Accuracy, all other indicators have increased by more than 7%. These results fully demonstrate the superiority of our algorithm and verify that the present invention can more effectively capture all verbs and explain the mechanism of metaphor occurrence when processing multi-verb Chinese texts, thereby significantly improving the pre-training model's ability to capture metaphor features and the accuracy and interpretability of metaphor recognition.

[0201] Table 2 Results of the first group of comparative experiments

[0202]

[0203] The second set of experiments compared the proposed model with a large model. As the large model develops, its performance in classification tasks gradually improves. Therefore, in order to more accurately evaluate the effectiveness of the proposed model, two large models were selected for direct testing: Llama3.1-8b and Qwen2.5-7b. Figure 5The test instruction format for large models is shown. Llama3.1-8b is a multilingual model released by Meta. Based on the Transformer architecture, it has 800 million parameters and is suitable for tasks such as metaphor recognition and sentiment analysis. Qwen2.5-7b is a Chinese-optimized model developed by Alibaba. Also based on the Transformer architecture, it has 700 million parameters and excels in Chinese processing, making it particularly suitable for sentiment analysis and metaphor recognition of Chinese text. The experimental results are shown in Table 3. Although the two large models achieve high precision, this metric may be affected by the high proportion of positive examples (resulting in 1) in the dataset, resulting in the model outputting more positive examples and thus higher precision. However, the model of our invention demonstrates more balanced and superior performance in terms of recall and F1 score. In particular, the F1 score of our model reaches 0.9357, an improvement of approximately 12.19% compared to Qwen2.5-7b's 0.8138. This result fully demonstrates the superior performance and efficiency of our model.

[0204] Table 3 Results of the second group of comparative experiments

[0205]

[0206] The present invention discloses a verb metaphor recognition method based on multi-verb extraction and thought chain prompts. First, a word segmentation tool is used to segment sentences according to punctuation marks, and all verbs in each sentence are extracted to ensure the accuracy of verb extraction while allowing the model to focus on key semantic information; secondly, a high-quality contextual explanation of metaphor occurrence is generated through thought chain prompts based on a large model. The generated explanation information is used as an additional feature and input into the model together with the extracted verbs to improve the metaphor recognition effect. The present invention combines the dual advantages of multi-verb extraction and thought chain prompts to make up for the shortcomings of existing verb metaphor recognition methods that fail to pay comprehensive attention to verbs and the causes of metaphor occurrence and lack interpretability. By generating explanatory information about the occurrence of metaphors, the model is helped to better understand the causes of metaphor generation, while increasing attention to key verbs, significantly improving the accuracy and interpretability of metaphor recognition.

[0207] Based on the above embodiments, an embodiment of the present application further provides a computer program, which, when executed on a computer, enables the computer to execute the method provided in the above embodiments.

[0208] Based on the above embodiments, an embodiment of the present application further provides a computer storage medium, in which a computer program is stored. When the computer program is executed by a computer, the computer executes the method provided in the above embodiments.

[0209] The storage medium may be any available medium that can be accessed by a computer. By way of example and not limitation, computer-readable media may include RAM, ROM, EEPROM, CD-ROM or other optical disk storage, magnetic disk storage media or other magnetic storage devices, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and can be accessed by a computer.

[0210] Based on the above embodiments, an embodiment of the present application further provides a chip, which is used to read a computer program stored in a memory to implement the method provided in the above embodiments.

[0211] Based on the above embodiments, an embodiment of the present application provides a computer program product, which implements the methods provided in the above embodiments when the computer program product is run on an electronic device.

[0212] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.

[0213] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present application. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0214] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.

[0215] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0216] Obviously, those skilled in the art may make various changes and modifications to this application without departing from the spirit and scope of this application. Thus, if these modifications and variations of this application fall within the scope of the claims of this application and their equivalents, this application is intended to include these modifications and variations.

Claims

1. A verb metaphor recognition method based on multi-verb extraction and thought chain prompting, characterized in that: The following steps are involved: Extract verbs from texts in the dataset; Conduct thought chain prompts on the large model to obtain prompt results on whether the verb is a metaphor; Concatenate the sentence containing the verb in the text with the verb and encode the concatenated sentence to obtain a sentence feature vector; encoding the prompt result into a thought chain feature vector; splicing the sentence feature vector and the thought chain feature vector in a certain weight ratio to obtain a spliced ​​feature vector; Inputting the concatenated feature vector into a classification model to perform metaphor judgment, thereby obtaining a judgment result of whether the sentence contains a metaphor; The thought chain prompts in the step of performing thought chain prompts on the large model to obtain the prompt result of whether the verb is a metaphor include: Tip 1: Extract and analyze the basic meaning of the verb and its meaning in context; Tip 2: Analyze the subject and object collocation of the verb to determine whether there is any collocation deviation; Tip 3: Based on Tips 1 and 2, determine whether the verb is a metaphor and generate a metaphorical explanation; Wherein, the prompt 1 is represented by the following formula: Where, represents the target word, literal_meaning(w) represents the literal meaning of the target word, and contextual_meaning(w) represents the meaning of the target word in a specific context; Wherein, the prompt 2 is represented by the following formula: Where, represents the target word, preference(w, context) represents the semantic preference of the target word in the context, expected_preference(w) represents the expected preference of the target word in the conventional context, when the semantic preference of the target word in a specific context does not match the conventional semantic preference, it is judged as a metaphor and output 1, otherwise it outputs 0; Among them, the prompt 3 includes According to Tip 1, when the literal meaning is not equal to the meaning in the context, it is judged as a metaphor. Output 1, otherwise Output 0; According to Tip 2, when the semantic preference of the target word in a specific context does not match the conventional semantic preference, it is judged as a metaphor. Output 1, otherwise Output 0.

2. The verb metaphor identification method based on multi-verb extraction and thought chain prompting according to claim 1 is characterized in that: in, The steps to extract verbs from the text in the dataset include the following steps: Splitting the text in the data set into sentences by commas; Using a word segmentation tool to mark the parts of speech of the sentences and perform dependency analysis to obtain the dependency relationships between words; Relations containing a subject or an object in the clauses are extracted according to the dependency relationships, and the verbs are filtered from the relationships.

3. The verb metaphor identification method based on multi-verb extraction and thought chain prompting according to claim 2 is characterized in that: in, In the step, the text in the data set is divided into sentences by commas, which is represented by the following formula: Where, Represents a text, Indicates the clauses separated by commas in each sentence, where ∈(1, ), t n Indicates the last clause in each sentence of text; The step of using a word segmentation tool to mark the parts of speech of the sentence and analyze the semantic relationship includes the following steps: Use the word segmentation tool to segment each of the clauses, as shown in the following formula: Where, It is a clause The word segmentation results, Expressive clause The words, is the total number of words in the clause; In the step, the relationship containing the subject or object in the sentence is extracted according to the dependency relationship, and the verb is selected from the relationship, which is expressed by the following formula: Where, Indicates the type of dependency, Represents the position index of the central word in the dependency relationship, Represents the position index of the dependent word, represents a triple, Represents a set of dependency relationships; Where, A tuple indicating the presence of a subject or object in a dependency relation; Where, Represents the set of verb indexes that meet the subject and object conditions in the dependency relationship, Represents the position index in the dependency relationship, POS( ) indicates the index position The part of speech of the word; Where, The set of verbs representing all clauses, Indicates the specific verb that indexes the corresponding participle position.

4. The verb metaphor identification method based on multi-verb extraction and thought chain prompting according to claim 1 is characterized in that: in, In the step, the sentence containing the verb in the text is concatenated with the verb code, which is represented by the following formula: in: Where, Represents a text, Indicates the clauses separated by commas in each sentence, where ∈(1, ), t n Indicates the last clause in each sentence of text; Where, In a text The set of verbs in all clauses of Indicates the verb, v Indicates the last verb; Represents a splicing operation, Indicates concatenated text; Among them, the sentence feature vector encoded in the step is expressed by the following formula: Where, Represents the sentence feature vector; In the step, the prompt result is encoded into a thought chain feature vector, which is represented by the following formula: Where, represents the thought chain feature vector, Indicates prompt results.

5. The verb metaphor identification method based on multi-verb extraction and thought chain prompting according to claim 1 is characterized in that: in, The step of splicing the sentence feature vector and the thought chain feature vector with a certain weight ratio to obtain a spliced ​​feature vector includes the following steps: Calculating an average length ratio of a sentence feature vector and a thought chain feature vector, and allocating space according to the average length ratio; Concatenate the sentence feature vector and the thought chain feature vector in proportion; In the step, the average length ratio of the sentence feature vector and the thought chain feature vector is calculated, and the space is allocated according to the average length ratio, which is expressed by the following formula: , Where, The sentence feature vector representing the distribution ratio, represents the input ratio of the sentence feature vector, The thought chain eigenvector representing the distribution ratio, Represents the input ratio of the thought chain feature vector; Among them, the sentence feature vector and the thought chain feature vector are spliced ​​in proportion in the step, which is expressed by the following formula: Where, Represents the concatenated feature vector.

6. The verb metaphor identification method based on multi-verb extraction and thought chain prompting according to claim 1 is characterized in that: in, In the step, the concatenated feature vector is input into the classification model to perform metaphor judgment, and the judgment result of whether the sentence contains a metaphor is obtained, which is expressed by the following formula: is the prediction result, indicating whether the text belongs to the metaphorical or non-metaphorical category. W is the weight of the model, b is the bias term of the model, and the softmax function maps all output values ​​to the range of [0, 1] and selects the corresponding category based on the maximum probability value. Among them, the cross-entropy loss function (Cross-EntropyLoss) of the model training is expressed by the following formula: Where, is the category distribution of the true label, It is the predicted probability calculated by the softmax function.

7. An electronic device, comprising: One or more processors, a memory, and one or more programs; wherein the one or more programs are stored in the memory, and the one or more programs include instructions that, when executed by the electronic device, cause the electronic device to execute the method described in any one of claims 1 to 6.

8. A computer-readable storage medium comprising a computer program, wherein when the computer program is run on an electronic device, the electronic device is caused to execute the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Sensitive word auditing method based on large language model, storage medium and electronic equipment

    CN116720515A

  • Method for constructing sentiment classification model based on metaphor identification

    US20230289528A1