Specific field-oriented metaphor text generation method
By using the large language model GPT-4 and dataset construction scheme, a metaphor text data set for specific fields is constructed and the model is fine-tuned, which solves the problem of metaphor text generation for specific fields, realizes automated and personalized metaphor text generation, and improves the effect of information dissemination and cultural exchange.
Patent Information
- Application Number
- CN202411956954.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-29
- Publication Date
- 2025-05-06
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
It is difficult for the prior art to achieve automated and personalized metaphorical text generation for specific fields, and the research on dataset construction for metaphorical text generation tasks is in a blank.
The large language model GPT-4 and dataset construction scheme are adopted to generate multi-category metaphorical text data sets in specific fields through three steps: metaphorical scene construction, metaphorical strategy generation and metaphorical text generation, and fine-tune the general large language model to make the text content generated have more metaphorical characteristics.
It realizes automated and personalized metaphorical text generation for specific fields, and uses advanced natural language processing technology to automate custom metaphor strategies and generate personalized metaphorical texts, which enhances the effect of information dissemination and cultural exchange.
Smart Images

Figure CN119940534A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of cyberspace security and natural language processing, and specifically relates to a metaphor text generation method for a specific field. Background Art
[0002] As an indispensable form of expression in discourse, metaphor permeates the cultural connotation of discourse, reflects the ideology of discourse, and provides a basis for interpreting the deep structure of discourse. The reason why metaphor plays an important role in discourse is that metaphor can frame issues in a specific pattern and set the direction of issue resolution, thereby providing an interpretation framework to influence decision-making.
[0003] Metaphors can be found everywhere in our daily lives. As Lakoff said, metaphor is the norm of language, metaphorical expression is the external manifestation of human metaphorical thinking, and is an important part of the human conceptual system. Shu Dingfang also pointed out that metaphor is an indispensable means of language expression, and can even be said to be a common state of language. Through metaphor, human metaphorical thinking can be presented. In essence, metaphor is a way for people to understand abstract and unfamiliar concepts with concrete and familiar concepts.
[0004] Text is an information text, and its main function is to convey information and knowledge to the public. Metaphors can be found everywhere in texts and are widely used in propaganda. On the one hand, the concepts in texts are often abstract and difficult to explain in plain language; on the other hand, metaphors can help people rebuild their conceptual system, influence people's thinking and cognition, and then affect their actions.
[0005] The metaphorical text generation task for a specific field cannot be simply regarded as an end-to-end generation task. Metaphorical text generation is highly dependent on external cultural knowledge and often requires the help of external information such as common sense, culture, and Internet terms to complete the generation. Research on metaphorical text generation methods for specific fields requires the flexible use of metaphors according to different cultures and contexts, and the use of natural language processing technology to achieve automatic customization of metaphor strategies and personalized generation of metaphorical texts. At the same time, there is currently a gap in the research on the construction of datasets for metaphorical text generation tasks. Summary of the invention
[0006] 1. Technical issues to be resolved
[0007] The technical problem to be solved by the present invention is to design a metaphor text generation method for a specific field to realize automatic and personalized metaphor text generation for the specific field.
[0008] (II) Technical solution
[0009] In order to solve the above technical problems, the present invention provides a method for generating metaphorical text for a specific field, comprising the following steps:
[0010] Step 1: Generate a multi-category metaphor text dataset in a specific field using the large language model GPT-4 and the dataset construction scheme. The scheme includes three steps: metaphor scene construction, metaphor strategy generation, and metaphor text generation. Among them, metaphor scene construction is based on the large language model and the prompt project Prompt. According to the subject keywords, background, and target content elements of the specific field, learn to generate a text data set containing metaphor expressions in the specific field. The background includes scenes, and the metaphor scene is based on the text data expression containing metaphor expressions. Metaphor strategy generation is formulated in combination with the conceptual metaphor type and the metaphor expression statistics table. The metaphor expression statistics table is a list of expression statistics for metaphors, and metaphor expressions include metaphor expressions. The metaphor strategy set provides metaphor expressions and corresponding metaphor types from different channels. Based on the generated metaphor scene set, different scene metaphor strategies are generated in combination with the large language model and Prompt. Finally, based on the metaphor scene set and the metaphor strategy set, a text containing metaphorical expressions is generated based on the large language model and Prompt as a metaphor text data set.
[0011] Step 2: Based on the metaphor text data set generated in step 1, and with the preset general large language model as the base, fine-tune the model so that the content generated by the model has more metaphorical features.
[0012] Preferably, in step 1, construct a i ,F i ,T i Data collection: Among them, C i is a set of metaphorical scenes, including background and target content; F i is a set of metaphor strategies related to the metaphor scenario; T i is a metaphor text data set related to metaphor scenarios and strategy sets, N is the number of keywords, and i is the keyword sequence number.
[0013] Preferably, the three sub-steps of metaphor scene construction, metaphor strategy generation, and metaphor text generation in step 1 are specifically as follows:
[0014] 1) Use metaphor keywords to guide the generation of metaphor scenarios in specific fields: First, select some keywords with a frequency higher than the preset value from the metaphor keyword dataset of the specific field; second, combine any two metaphor keywords in the metaphor keyword dataset into a new compound metaphor keyword, and use the large language model GPT-4 to expand the dataset composed of compound metaphor keywords into a larger-scale keyword dataset with a dataset size of N; finally, provide contextual content containing metaphor keywords and corresponding scenario examples, give metaphor keywords through the keyword dataset, and prompt GPT-4 to generate metaphor scenarios based on the given metaphor keywords;
[0015] 2) Under the constraints of the conceptual metaphor type and metaphor expression statistics, a metaphor strategy generation mechanism is designed. The metaphor strategy generation mechanism provides information about metaphor types and metaphor expressions from multiple channels, as well as metaphor writing techniques from linguistics. This prompts GPT-4 to generate corresponding metaphor strategies with reference to the metaphor strategy generation mechanism. The metaphor strategy set reflects the metaphor type selection corresponding to metaphor expressions in different scenarios.
[0016] 3) Prompt GPT-4 to give a set of metaphorical scenarios C i and metaphor strategy set F i Create a metaphor text set T i , let the total number of iterations be L. In the jth iteration, in the given metaphor scene set C i and metaphor strategy set F i Metaphor text collection T created under i,j for:
[0017]
[0018] Among them, is the text content. This text content is the content that needs metaphor. The generated metaphor text is the generated content with metaphor characteristics. i,j It is the content that describes the reasoning process from summarizing metaphor content to choosing metaphor strategy. For The generated metaphorical text is influenced by r i,j Influence.
[0019] Preferably, in step 2, based on the metaphor text data set constructed in step 1, a general large language model is given, and the given large language model is trained, so that the model can generate text content with metaphor features for metaphor texts in different metaphor scenarios, wherein the method for fine-tuning the large language model is as follows:
[0020] First, we fine-tune the large language model so that it can learn to reason about metaphor strategies before generating text content. At the same time, we fine-tune the model using the collected metaphor text dataset:
[0021]
[0022] Among them, Θ is the parameter of the large language model base, which is the metaphor scene set C i As the initial input data of the model, optimize the first term r in the above formula i,j , which enables the model to construct a metaphor strategy set F i , and enables the model to adapt to unknown metaphor scenarios; then, given a set of metaphor scenarios C i The generated metaphor strategy data set F i , the historical metaphor text content T i,1:j-1 As the input data of the model, T i,1:j-1 is the metaphor text content generated from the first iteration to the j-1th iteration for the i-th keyword; through fine-tuning, the model learns to select the appropriate strategy reasoning content r i,j , and generate better metaphorical text
[0023] Preferably, when fine-tuning the model in step 2, the parameters of the pre-trained model GPT-4 need to be updated, and the formula is as follows:
[0024] h=W o x+ΔWx=W o x+BAx
[0025] Where W o represents the pre-trained weight matrix, ΔW represents the parameter update during fine-tuning, and LoRA fine-tuning limits the weight update so that ΔW = BA; W o x represents the original forward propagation process, that is, the model input x passes through the weight matrix W o Get the output; in the large language model, x is the word embedding vector, W o is the weight matrix from the word embedding layer to the hidden layer, BAx represents the correction term introduced by the fine-tuning process; A and B are two low-rank matrices, and their product BA represents the weight matrix W o Correction of (W o +BA)x represents the weight matrix W o Add it to the correction term BA to get the fine-tuned weight matrix, and then multiply it with the input x to get the final model output h.
[0026] The present invention also provides a system for implementing the method.
[0027] The invention also provides a network security assessment method implemented based on the method.
[0028] (III) Beneficial effects
[0029] The present invention utilizes advanced natural language processing technology to realize automatic customization of metaphor strategies and personalized generation of metaphor texts, wherein, firstly, metaphor keywords in different scenarios of specific fields are collected and expanded, and multi-category scenarios containing metaphor information are generated based on a large language model and corresponding prompts; secondly, in combination with multi-category scenarios, under the constraints of conceptual metaphor types and metaphor expression statistical tables, metaphor scenarios and metaphor strategies are inferred based on a large language model and corresponding prompts to form a metaphor strategy set; further, the generation of relevant metaphor text content is completed based on the scenario set and the metaphor strategy set; based on the generated domain-specific metaphor text data set, the general large language model is effectively fine-tuned so that the generated text content is easy to understand, thereby realizing automatic and personalized metaphor text generation for specific fields. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1 A principle block diagram of the method design of the present invention is provided. DETAILED DESCRIPTION
[0031] In order to make the purpose, content and advantages of the present invention more clear, the specific implementation methods of the present invention are further described in detail below in conjunction with the drawings and examples.
[0032] The present invention proposes a metaphor text generation method for a specific field. Metaphor has the characteristics of imagery, simplicity, uncertainty of meaning, etc. It not only has the beauty of words, but also has profound cultural connotations and philosophical thinking. Metaphors in texts play an important role in expressing positions. Therefore, the accurate use of metaphors in texts is particularly important. The method of the present invention mainly includes two steps. First, a metaphor text dataset for a specific field is constructed based on a large language model technology, which is mainly divided into three parts, namely, metaphor scene construction, metaphor strategy generation, and metaphor text generation, to generate a metaphor text dataset in a specific field; secondly, based on a general large model, combined with the generated metaphor text dataset, the general large model is fine-tuned to achieve metaphor text generation for a specific field. The metaphor text generation method for a specific field uses advanced natural language processing technology to realize the automatic customization of metaphor strategies and the personalized generation of metaphor texts. It can provide more obscure, humorous and easy-to-understand automated metaphor texts by highlighting culture and underlying connotations, making it easier for people to understand and spread certain views or information, effectively enhancing the degree of information dissemination and cultural communication.
[0033] refer to Figure 1 The invention provides a metaphor text generation for a specific field, comprising the following steps:
[0034] Step 1: Generate a multi-category metaphor text dataset in a specific field using the large language model GPT-4 and the dataset construction scheme. The scheme includes three modules: metaphor scene construction, metaphor strategy generation, and metaphor text generation. Among them, metaphor scene construction is mainly based on the large language model and prompt engineering Prompt. According to the theme keywords, background, target content and other elements of the specific field, learn to generate a text data set containing metaphor expressions in a specific field. The background includes scenes, and the metaphor scene is based on the text data expression containing metaphor expressions; metaphor strategy generation is formulated in combination with conceptual metaphor types and metaphor expression statistics. The metaphor expression statistics table is a list of expression statistics for metaphors by researchers, and metaphor expressions include metaphor expressions; the metaphor strategy set provides metaphor expressions from different channels and corresponding metaphor type selection methods. Based on the generated metaphor scene set, the large language model and Prompt are combined to complete the generation of metaphor strategies for different scenarios; finally, based on the metaphor scene set and the metaphor strategy set, the large language model and Prompt are used to generate text containing metaphorical expressions as a metaphor text data set.
[0035] Step 2: Based on the metaphorical text data set generated in step 1, and with the general large language model as the foundation, fine-tune the model to make the content generated by the model more culturally connotative and metaphorically distinctive, so as to better enable people to understand and spread certain information.
[0036] In step 1, in order to ensure the diversity and rationality of metaphor scenarios in a specific field, a i ,F i ,T i Data collection: Among them, C i is a set of metaphorical scenes, including background and target content; F i is a set of metaphor strategies related to the metaphor scenario; T i is a metaphor text data set related to metaphor scenarios and strategy sets, N is the number of keywords, and i is the keyword sequence number. Step 1 is implemented by three modules: metaphor scenario generation, metaphor strategy generation, and metaphor text data generation. The detailed introduction is as follows:
[0037] 1) Use metaphor keywords to guide the generation of metaphor scenarios in specific fields. First, manually select some keywords with high frequency, popularity and influence from the popular metaphor keyword dataset in the specific field. Second, in order to further improve the diversity of scenarios, any two metaphor keywords in the metaphor keyword dataset can be combined into a new compound metaphor keyword. With the help of the large language model GPT-4, the dataset composed of compound metaphor keywords is expanded into a larger-scale keyword dataset with a dataset size of N. Finally, provide contextual content containing metaphor keywords and corresponding scenario examples, give metaphor keywords through the keyword dataset, and prompt GPT-4 to generate metaphor scenarios based on the given metaphor keywords.
[0038] 2) Under the constraints of the conceptual metaphor type and metaphor expression statistics, a metaphor strategy generation mechanism is designed. The metaphor strategy generation mechanism provides information about metaphor types and metaphor expressions from multiple channels, as well as metaphor writing techniques from linguistics. This prompts GPT-4 to generate corresponding metaphor strategies with reference to the metaphor strategy generation mechanism. The metaphor strategy set reflects the metaphor type selection corresponding to metaphor expressions in different scenarios.
[0039] 3) Prompt GPT-4 to give a set of metaphorical scenarios C i and metaphor strategy set F i Create a metaphor text set T i , let the total number of iterations be L. In the jth iteration, in the given metaphor scene set C i and metaphor strategy set F i Metaphor text collection T created under i,j for:
[0040]
[0041] Among them, is the text content. This text content is the content that needs metaphor. The generated metaphor text is the generated content with metaphor characteristics. i,j It is the content that describes the reasoning process from summarizing metaphor content to choosing metaphor strategy. For The generated metaphorical text is influenced by r i,j The generation of metaphor scenarios is to generate a metaphor strategy set in combination with the designed strategy guide, which supports i,j Metaphorical content is the content that needs to be processed metaphorically. i,j It is to generate better content with metaphorical characteristics from the content that needs metaphor by choosing the correct metaphor strategy.
[0042] In step 2, based on the metaphor text dataset constructed in step 1, a general large language model (such as GPT-3, GPT-4, PaLM, Galactica, and LLaMA) is given, and the given large language model is trained to enable the model to generate text content with metaphorical features for metaphor texts in different metaphor scenarios. The main step is to fine-tune the large language model. The fine-tuning method is described in detail as follows:
[0043] First, fine-tune the large language model so that it can learn to effectively reason about metaphor strategies before generating text content. At the same time, fine-tune the collected metaphor text dataset to achieve the following:
[0044]
[0045] Among them, Θ is the parameter of the large language model base, which is the metaphor scene set C i As the initial input data of the model, optimize the first term r in the above formula i,j , which enables the model to construct a metaphor strategy set F i , and enables the model to adapt to unknown metaphor scenarios; then, given a set of metaphor scenarios C i The generated metaphor strategy data set F i , the historical metaphor text content T i,1:j-1 As the input data of the model, T i,1:j-1 is the metaphor text content generated for the i-th keyword from the first iteration to the j-1-th iteration (indicated by the subscript “1:j-1”); through fine-tuning, the model learns to select the appropriate strategy reasoning content r i,j , and generate better metaphorical text C i ,F i ,T i,1:j-1 ; Θ is the input, r i,j , is the output, that is, the output r i,j , maximum probability.
[0046] This embodiment provides a method for generating metaphorical texts for a specific field. The following is a specific example showing the specific steps and process of the method for generating metaphorical texts for a specific field.
[0047] 1. Create a multi-domain metaphor text data set
[0048] 1) Collect metaphor keywords, metaphor backgrounds, metaphor scenes, metaphor texts and other examples in specific fields. At the same time, manually extract new keyword datasets (scenario keyword sets) from the Metaphor Dataset with Emotion and Intention (MDEI), which can be a keyword or a combination of two keywords, to give new scenario keywords. Based on the large language model, combine the new scenario keywords and formulate corresponding prompts to generate a new scenario set. The prompt example is as follows:
[0049] [The research will provide you with metaphorical scene keywords. You need to give full play to your imagination and expand these keywords into detailed and specific generation settings with metaphorical characteristics.
[0050] You need to follow these requirements:
[0051] 1. The extended scenario needs to describe a very specific metaphorical scenario in no more than 2 sentences.
[0052] …
[0053] Scenario: Suppose you are Zhang San, and you want to express something metaphorically.
[0054] #Extended scenario example:
[0055] {{
[0056] "Keywords"
[0057] "background"
[0058] "content"
[0059] "Task"
[0060] }}
[0061] #Scene tags are extended:
[0062] election
[0063] Li Si & Winner
[0064] 2) Combined with the generated scene set, guided by the study of conceptual metaphor types and metaphor expression statistics, based on the large language model and the corresponding prompt, a metaphorical strategy set is generated. The prompt example is as follows:
[0065] [The research will provide a metaphorical scenario that you need to consider thoroughly and comprehensively.
[0066] Develop several metaphorical strategies that have metaphorical implications.
[0067] You need to follow these rules:
[0068] 1. Each strategy should contain a few words.
[0069] …
[0070] #Metaphors to be developed:
[0071] {……}
[0072] 3) Combine the generated scene set and metaphorical strategy set, generate a metaphor text dataset based on the large language model and the corresponding prompt. The prompt example is as follows:
[0073] [Given a metaphor scenario and a corresponding set of metaphor strategies, please be sure to follow the following rules and terms.
[0074] #Metaphor Rules:
[0075] 1. The metaphorist's words should have metaphorical meaning;
[0076] …
[0077] {Metaphorical Strategy Collection} 】
[0079] 2. Fine-tuning of general large models
[0080] In this embodiment, a general large language model (GPT-4, Llama3, ChatGLM, etc.) is used as the base, and the LoRA (Low-Rank Adaptation of LLMs) technology can be used to fine-tune it. Taking the fine-tuning of a large language model GPT-4 in the downstream task as an example, the parameters of the pre-trained model GPT-4 need to be updated, and the formula is expressed as follows:
[0081] h=W o x+ΔWx=W o x+BAx
[0082] Where W o represents the pre-trained weight matrix, ΔW represents the parameter update during fine-tuning, and LoRA fine-tuning limits the weight update so that ΔW = BA; W o x represents the original forward propagation process, that is, the model input x passes through the weight matrix W o Get the output. In a large language model, x can be a word embedding vector, W o is the weight matrix from the word embedding layer to the hidden layer. BAx represents the correction term introduced by the fine-tuning process. A and B are two low-rank matrices, and their product BA represents the weight matrix W. o For example, W o The dimension of is 1000×1000, the dimensions of A and B are 50×1000 and 1000×50 respectively, then the dimension of BA is 50×50. (Wo +BA)x represents the weight matrix W o Add it to the correction term BA to get the fine-tuned weight matrix, and then multiply it with the input x to get the final model output h.
[0083] Through this reparameterization, LoRA fine-tuning can adapt to new tasks by learning the low-rank matrix BA while keeping the pre-trained weights unchanged, which can greatly reduce the number of parameters that need to be trained and improve the efficiency of fine-tuning. o It is a pre-trained weight matrix and remains unchanged during the training process, which can further reduce the computation and storage costs. By introducing low-rank matrices A and B and adopting a re-parameterization method, LoRA fine-tuning can achieve rapid model adaptation by learning a small number of parameters while keeping the original model structure unchanged.
[0084] Working principle:
[0085] It can be seen that the technical solution of the present invention is divided into two parts: construction of a metaphor text dataset for a specific field and fine-tuning of a general large language model:
[0086] 1) Construction of domain-specific metaphor dataset
[0087] A high-quality domain-specific metaphor text dataset is an important foundation for the study of metaphor text generation methods. A dataset construction framework is designed to better fine-tune the text content generation method based on the large language model to generate more targeted text content. The metaphor keywords in different scenarios of the specific domain are collected and expanded, and multi-category scenes containing metaphor information are generated based on the large language model and the corresponding prompt; secondly, combined with multi-category scenes, under the constraints of the conceptual metaphor type and metaphor expression statistical table research, the metaphor scenes and metaphor irony strategies are inferred based on the large language model and the corresponding prompt to form a metaphor strategy set; then, the generation of relevant metaphor text content is completed based on the scene set and the metaphor strategy set.
[0088] 2) Fine-tuning the general large language model
[0089] Based on the generated domain-specific metaphor text dataset, the general large language model is effectively fine-tuned to make the generated text content easy to understand, highlight the expression of viewpoints, and have more cultural and metaphorical attributes, highlighting the vividness and attractiveness of the text, and realizing automated and personalized metaphor text generation for specific fields.
[0090] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the technical principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A method for generating metaphorical text for a specific field, characterized in that: The following steps are involved: Step 1: Generate a multi-category metaphor text dataset in a specific field using the large language model GPT-4 and the dataset construction scheme. The scheme includes three steps: metaphor scene construction, metaphor strategy generation, and metaphor text generation. Among them, metaphor scene construction is based on the large language model and the prompt project Prompt. According to the subject keywords, background, and target content elements of the specific field, learn to generate a text data set containing metaphor expressions in the specific field. The background includes scenes, and the metaphor scene is based on the text data expression containing metaphor expressions. Metaphor strategy generation is formulated in combination with the conceptual metaphor type and the metaphor expression statistics table. The metaphor expression statistics table is a list of expression statistics for metaphors, and metaphor expressions include metaphor expressions. The metaphor strategy set provides metaphor expressions and corresponding metaphor types from different channels. Based on the generated metaphor scene set, different scene metaphor strategies are generated in combination with the large language model and Prompt. Finally, based on the metaphor scene set and the metaphor strategy set, a text containing metaphorical expressions is generated based on the large language model and Prompt as a metaphor text data set. Step 2: Based on the metaphor text data set generated in step 1, and with the preset general large language model as the base, fine-tune the model so that the content generated by the model has more metaphorical features.
2. The method according to claim 1, characterized in that In step 1, build the i ,F i ,T i Data collection: Among them, C i is a set of metaphorical scenes, including background and target content; F i is a set of metaphor strategies related to the metaphor scenario; T i is a metaphor text data set related to metaphor scenarios and strategy sets, N is the number of keywords, and i is the keyword sequence number.
3. The method according to claim 1, characterized in that The three sub-steps of step 1, metaphor scene construction, metaphor strategy generation, and metaphor text generation, are as follows: 1) Use metaphor keywords to guide the generation of metaphor scenarios in specific fields: First, select some keywords with a frequency higher than the preset value from the metaphor keyword dataset of the specific field; second, combine any two metaphor keywords in the metaphor keyword dataset into a new compound metaphor keyword, and use the large language model GPT-4 to expand the dataset composed of compound metaphor keywords into a larger-scale keyword dataset with a dataset size of N; finally, provide contextual content containing metaphor keywords and corresponding scenario examples, give metaphor keywords through the keyword dataset, and prompt GPT-4 to generate metaphor scenarios based on the given metaphor keywords; 2) Under the constraints of the conceptual metaphor type and metaphor expression statistics, a metaphor strategy generation mechanism is designed. The metaphor strategy generation mechanism provides information about metaphor types and metaphor expressions from multiple channels, as well as metaphor writing techniques from linguistics. This prompts GPT-4 to generate corresponding metaphor strategies with reference to the metaphor strategy generation mechanism. The metaphor strategy set reflects the metaphor type selection corresponding to metaphor expressions in different scenarios. 3) Prompt GPT-4 to give a set of metaphorical scenarios C i and metaphor strategy set F i Create a metaphor text set T i , let the total number of iterations be L. In the jth iteration, in the given metaphor scene set C i and metaphor strategy set F i Metaphor text collection T created under i,j for: Among them, is the text content. This text content is the content that needs metaphor. The generated metaphor text is the generated content with metaphor characteristics. i,j It is the content that describes the reasoning process from summarizing metaphor content to choosing metaphor strategy. For The generated metaphorical text is influenced by r i,j Influence.
4. The method according to claim 3, characterized in that The purpose of generating metaphor scenarios is to generate a metaphor strategy set in combination with the designed strategy guidelines. The metaphor strategy set supports i,j of learning.
5. The method according to claim 3, characterized in that Metaphorical content is the content that needs to be processed metaphorically. i,j It is the content with metaphorical characteristics generated from the content that needs metaphor by selecting the correct metaphor strategy.
6. The method according to claim 3, characterized in that In step 2, based on the metaphor text dataset constructed in step 1, a general large language model is given, and the given large language model is trained to enable the model to generate text content with metaphor features for metaphor texts in different metaphor scenarios. The method for fine-tuning the large language model is as follows: First, we fine-tune the large language model so that it can learn to reason about metaphor strategies before generating text content. At the same time, we fine-tune the model using the collected metaphor text dataset: Among them, Θ is the parameter of the large language model base, which is the metaphor scene set C i As the initial input data of the model, optimize the first term r in the above formula i,j , which enables the model to construct a metaphor strategy set F i , and enables the model to adapt to unknown metaphor scenarios; then, given a set of metaphor scenarios C i The generated metaphor strategy data set F i , the historical metaphor text content T i,1:j-1 As the input data of the model, T i,1:j-1 is the metaphor text content generated from the first iteration to the j-1th iteration for the i-th keyword; through fine-tuning, the model learns to select the appropriate strategy reasoning content r i,j , and generate better metaphorical text 7. The method according to claim 3, characterized in that When fine-tuning the model in step 2, it is necessary to update the parameters of the pre-trained model GPT-4. The formula is as follows: h=W o x+ΔWx=W o x+BAx Where W o represents the pre-trained weight matrix, ΔW represents the parameter update during fine-tuning, and LoRA fine-tuning limits the weight update so that ΔW = BA; W o x represents the original forward propagation process, that is, the model input x passes through the weight matrix W o Get the output; in the large language model, x is the word embedding vector, W o is the weight matrix from the word embedding layer to the hidden layer, BAx represents the correction term introduced by the fine-tuning process; A and B are two low-rank matrices, and their product BA represents the weight matrix W o Correction of (W o +BA)x represents the weight matrix W o Add it to the correction term BA to get the fine-tuned weight matrix, and then multiply it with the input x to get the final model output h.
8. The method according to claim 6, characterized in that The general large language model given in step 2 is one of GPT-3, GPT-4, PaLM, Galactica and LLaMA.
9. A system for implementing the method according to any one of claims 1 to 8.
10. A network security assessment method implemented based on the method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Metaphor calculation and device based on knowledge graph representation learning
CN113157932A
Metaphor identification method, electronic equipment and computer readable storage medium
CN115758998A
Method for constructing sentiment classification model based on metaphor identification
US20230289528A1