Composition comment generation method, device, electronic device and storage medium incorporating meta-examples
By constructing a meta-example set and using a composition semantic encoder, combined with a pre-trained language model to generate comments, the problem of ambiguous evaluation criteria and low correlation between comments and composition content in the open composition review scenario is solved, and a more flexible and diverse Comment generation.
Patent Information
- Application Number
- CN202410851204.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-28
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2044-06-28
AI Technical Summary
In an open composition review scenario, the evaluation criteria are vague and the correlation between comments and composition content is low. It is difficult for existing technology to provide flexible and diverse comment generation methods.
By constructing a meta-example set, using the composition semantic encoder to retrieve relevant examples, and combining the pre-trained language model to generate comments, the relevance and diversity of comments and compositions are enhanced.
It improves the reliability and diversity of comments, provides a more targeted evaluation basis, and enhances the flexibility and accuracy of essay review.
Smart Images

Figure CN118395953B
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of natural language processing, and more specifically, relates to a composition comment generation method, device, electronic device and storage medium incorporating meta-examples. Background Art
[0002] The present invention involves the task of generating composition comments in an open review scenario for primary and secondary school students. It requires generating reasonable composition comments from multiple perspectives based on the understanding and analysis of composition content and combined with evaluation criteria, so as to assist students in improving their writing skills in a targeted manner, and has important application value.
[0003] In order to provide students with better guidance in the process of learning writing, the essay comments in this scenario need to give overall comments on the entire essay, and make targeted evaluations based on some excellent essay fragments, such as quoting excellent sentences in the essay and conducting fine-grained analysis of the expressions used. However, in open scenarios, there is little information available about the essay, such as the student's grade and essay style.
[0004] Considering that there are large differences in the evaluation standards for essays corresponding to different types of writing styles, grades and other constraints, the lack of essay-related information makes the evaluation standards that the model can refer to in the comment generation process relatively vague. Therefore, for the open essay review scenario in primary and secondary schools, the essence of essay comment generation is to generate comment content based on a full understanding of the essay and reasonable evaluation annotations. The difficulties include how to introduce evaluation criteria that are consistent with the essay to improve the rationality of the generated comments and how to enhance the relevance of the comments and the content of the essay, which has important theoretical significance.
[0005] The existing composition comment generation method mainly generates composition comments based on the input composition content and predefined paradigm sentences. For example, Chinese patent document CN202310158304.X discloses a composition comment generation method based on a knowledge graph fused with a multidimensional nested generalization pattern. First, a composition comment knowledge graph is constructed to associate composition types, comment dimensions, fine-grained dimensional analysis points, and analysis point grading intervals. Then, a multidimensional nested generalization pattern library is sorted out, which contains common comment paradigm sentences corresponding to each analysis point grading interval under all composition types. In the comment generation process, the composition analysis results and the dimensional analysis points in the composition comment knowledge graph are matched, and the comment path is constructed according to the dimension, and the corresponding generalization pattern is found from the generalization pattern library. The generalization pattern is concretized into a complete sentence based on the composition analysis results. Finally, the complete sentences are combined and polished by conjunctions to obtain the output comment.
[0006] However, the evaluation criteria given in different review scenarios may be different, which requires the knowledge graph and multi-dimensional nested generalized pattern library of the above methods to be adjusted accordingly according to specific application scenarios, which lacks flexibility. Moreover, the above methods are essentially based on template-based generation methods, so the generated comments lack diversity.
[0007] Considering the limitations of template-based methods, some studies have used pre-trained models to generate essay comments by mining the mapping relationship between input text features and comment vocabulary. For example, Chinese patent document CN202311137360.1 extracts semantics from historical comment data to obtain a bag-of-words model that contains semantic associations. In the comment generation process, the user's target label features are first extracted based on the user label information, and finally the user's target label features and semantic information are multimodally fused to obtain multimodal fusion parameters, and a large language model is used to generate comments based on the input multimodal fusion parameters.
[0008] This type of method solves the problem of lack of flexibility in the above template-based methods, but it still has shortcomings when applied to the task of generating essay comments. First, this type of method cannot clearly give the evaluation basis for the generated comments, so it cannot effectively improve the reliability of the generated comments. Second, the various constraints in the generation process will make the diversity of the generated comments poor.
[0009] Based on this, the present invention designs a composition review generation method that incorporates meta-examples to solve the problems of vague evaluation criteria and low correlation between comments and composition content in open composition review scenarios. Summary of the invention
[0010] The present invention aims to overcome at least one defect of the above-mentioned prior art and provide a composition comment generation method incorporating meta-examples to solve the problems of vague evaluation criteria and low correlation between comments and composition content in open composition review scenarios.
[0011] The invention also discloses a device loaded with a composition comment generation method incorporating meta-examples.
[0012] Technical term explanation:
[0013] Meta-example: in the present invention, it refers to a composition review example consisting of a composition fragment and the comments evaluating it, which shows a reasonable evaluation given by a professional reviewer to a certain composition fragment.
[0014] Meta-example set: A sample set containing all meta-examples.
[0015] Relevant example: in the present invention, it refers to the most relevant meta-example retrieved from the meta-example set by the composition semantic encoder for each new composition.
[0016] Real comments: in the present invention, it refers to the comment content corresponding to each composition in the composition comment data set.
[0017] The detailed technical scheme of the present invention is as follows:
[0018] A composition review generation method incorporating meta-examples, the method comprising:
[0019] S1. Obtain an original composition comment data set, wherein the data samples in the original composition comment data set include the original composition and its comment content, divide the original composition into a plurality of first text blocks, and annotate the mapping relationship between each first text block and the comment content, and use each annotated first text block and its corresponding comment content as a meta-example and construct a meta-example set;
[0020] S2, annotating the comment content of each meta-example in the meta-example set with the evaluation angle, using the annotated meta-examples as training samples to construct a training sample set, and using the training sample set to train the composition semantic encoder by contrastive learning;
[0021] S3, for a new composition, dividing the new composition into a plurality of second text blocks, and inputting the second text blocks and the first text block of the meta-example into a trained composition semantic encoder, respectively obtaining the encoding representation vector of the second text block and the encoding representation vector of the first text block, calculating the similarity between the encoding representation vector of the second text block and the encoding representation vector of the first text block, and taking the meta-example corresponding to the first text block with the greatest similarity as the relevant example of the corresponding second text block;
[0022] S4. Mask the comment contents of the relevant examples, and construct an example information set based on the masked comment contents. Input the new composition and the example information set into a composition comment generation model for encoding-decoding operations to generate a composition comment corresponding to the new composition.
[0023] Preferably, in step S1, marking the mapping relationship between each first text block and the comment content specifically includes:
[0024] Build an automatic tagger based on a pre-trained language model;
[0025] Selecting some data samples from the original composition comment data set, obtaining the comment content of the evaluation of each first text block in each original composition in the some data samples through manual annotation, and constructing a tagger training sample;
[0026] Using the tagger training samples to train the automatic tagger, and calculating and generating a loss function based on the output of the automatic tagger and the comment content in the tagger training samples to update the automatic tagger parameters;
[0027] The trained automatic annotator is used to annotate the remaining data samples in the original composition comment data set, and the comment content evaluating each first text block in each original composition in the remaining data samples is obtained.
[0028] According to a preferred embodiment of the present invention, in step S2, the comment content of each meta-example in the meta-example set is manually annotated with an evaluation angle. , Represents the first text block, Indicates the first text block The corresponding comment content, the comment content The evaluation angle label is , then the meta-example after the evaluation angle annotation is expressed as ,in, , Represents a set of evaluation angles.
[0029] Preferably, according to the present invention, in step S2, using the training sample set to train the composition semantic encoder by contrastive learning specifically includes:
[0030] Meta example based on the completed evaluation angle annotation Construct positive and negative samples for the meta-examples after the evaluation angle annotation is completed , from the first text block Belong to the same essay style and evaluation angle label Among the remaining consistent meta-examples, randomly sample a meta-example as a positive sample ; From the first text block Belong to different writing styles and evaluation angle labels Among the remaining inconsistent meta-examples, randomly sample a meta-example as a negative sample ;
[0031] The constructed positive and negative samples are used as training samples, and the contrast loss function is used Training the composition semantic encoder, the contrast loss function for:
[0032] (1);
[0033] In formula (1): represents the exponential function with the real number e as the base; Represents a function that measures the distance between two vectors, with a value range greater than 0, and Indicates the first text block The encoding representation vector of the first text block of the positive sample The encoding represents the distance between vectors, Indicates the first text block The encoded representation vector of the first text block with negative samples The encoding of represents the distance between vectors; Represents the temperature parameter.
[0034] Preferably, according to the present invention, in step S4, masking operation is performed on the comment content of the relevant example, specifically including:
[0035] Using the jieba tool to perform a word segmentation operation on the comment content of the relevant example and the first text block corresponding thereto, to obtain a comment content word segmentation set and a first text block word segmentation set respectively;
[0036] Marking the positions of the words in the comment content word set that appear in the first text block word set;
[0037] Replace the words corresponding to the marked positions in the comment content segmentation set with Word element.
[0038] According to a preferred embodiment of the present invention, in step S4, the example information set constructed based on the masked comment content is: , Indicates the masked comment content;
[0039] The composition review generation model includes an encoder and a decoder, and adopts a method of minimizing the generation loss function Training the composition review generation model, minimizing the generation loss function for:
[0040] (2);
[0041] In formula (2): Indicated in The word-units in the real comments corresponding to the time step, the real comments are from the composition comment data used to train the composition comment generation model; is the input of the encoder, and Indicates the identification text. Represents a collection of sample information, Indicates a new composition; Indicates in front All the tokens generated by the composition review generation model at time steps; Indicated in The decoder output of the composition review generation model for time steps is The probability distribution of It represents the time steps required by the composition review generation model to generate a complete composition review, corresponding to the length of the generated composition review.
[0042] Preferably, according to the present invention, step S4 further comprises: extracting the first K sentences in the original composition using the TextRank algorithm, and splicing them in the order in which they appear in the original composition as the composition summary. , and in the process of generating composition comments, the composition summary A is used to replace the new composition As the input of the encoder of the composition review generation model, .
[0043] In another aspect of the present invention, there is provided a device for implementing a composition review generation method incorporating meta-examples, the device comprising:
[0044] A meta-example set construction module is used to obtain an original composition comment data set, wherein the data samples in the original composition comment data set include the original composition and its comment content, divide the original composition into a plurality of first text blocks, and mark the mapping relationship between each first text block and the comment content, and use each first text block after marking and its corresponding comment content as a meta-example and construct a meta-example set;
[0045] A composition semantic encoder training module is used to annotate the comment content of each meta-example in the meta-example set according to the evaluation angle, use the annotated meta-examples as training samples to construct a training sample set, and use the training sample set to train the composition semantic encoder by contrastive learning;
[0046] A related example retrieval module is used to divide the new composition into a plurality of second text blocks, and input the second text blocks and the first text block of the meta-example into the trained composition semantic encoder, respectively obtain the encoding representation vector of the second text block and the encoding representation vector of the first text block, calculate the similarity between the encoding representation vector of the second text block and the encoding representation vector of the first text block, and use the meta-example corresponding to the first text block with the greatest similarity as the related example of the corresponding second text block;
[0047] The composition comment generation module is used to mask the comment content of the relevant examples, and construct an example information set based on the masked comment content, and input the new composition and the example information set into the composition comment generation model for encoding-decoding operations to generate a composition comment corresponding to the new composition.
[0048] In another aspect of the present invention, there is also provided an electronic device, comprising:
[0049] at least one processor; and
[0050] A memory storing instructions, which, when executed by the at least one processor, causes the at least one processor to execute the composition review generation method incorporating meta-examples as described above.
[0051] In another aspect of the present invention, a machine-readable storage medium is provided, which stores executable instructions, and when the instructions are executed, the machine executes the composition review generation method incorporating meta-examples as described above.
[0052] Compared with the prior art, the present invention has the following beneficial effects:
[0053] (1) The present invention proposes a method for constructing a meta-example set. By semantically segmenting the composition, a fine-grained mapping relationship between composition fragments and comment content is established. Compared with the conventional method of using the entire composition as an example, the meta-example constructed by the present invention can reflect the characteristics of different composition types and styles with specific words and sentences. This fine-grained composition evaluation basis can provide more meaningful reference evaluation examples for the composition comment generation process.
[0054] (2) The present invention uses relevant examples based on the retrieval of new composition content as reference evaluation basis, and uses contrastive learning to improve the adaptability of the encoder in the field of composition review. Compared with the prior art that selects prompt references based on text content, the present invention can search based on the feature differences of different paragraphs of the composition, improve the matching degree between the retrieval results and the new composition, and provide differentiated reference standards of different types and styles for composition review.
[0055] (3) The present invention generates comments based on examples and new composition content, which can provide more meaningful contextual information for the composition comment generation model. Compared with the prior art that generates comments based on templates or keywords, the present invention enables the model to learn the mapping relationship between different composition fragments and comment content, enhances the correlation between generated comments and compositions, and improves the diversity of generated comment content.
[0056] (4) The composition comment generation model in the present invention is based on the pre-trained language model, which can not only make full use of the linguistic knowledge and common sense knowledge learned from massive data by the pre-trained model, but also does not need to modify the structure of the basic model, and can adjust the basic model according to the computing power of the hardware device. Therefore, the present invention has the advantage of lightweight computing and can quickly adapt to a variety of application scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] Figure 1 It is an execution block diagram of the composition review generation method incorporating meta-examples described in the present invention.
[0058] Figure 2 This is a flowchart of constructing a meta-example set in Embodiment 1 of the present invention.
[0059] Figure 3 It is a schematic diagram of the structure of the apparatus for implementing the composition review generation method incorporating meta-examples in Embodiment 2 of the present invention.
[0060] Figure 4 This is a flow chart of using the apparatus of the present invention to realize the generation of composition comments incorporating meta-examples in Example 2 of the present invention.
[0061] Figure 5 It is a hardware structure diagram of an electronic device that incorporates the composition comment generation method of the meta-example in Embodiment 3 of the present invention. DETAILED DESCRIPTION
[0062] The present disclosure is further described below in conjunction with the accompanying drawings and embodiments.
[0063] It should be noted that the following detailed descriptions are exemplary and are intended to provide further explanation of the present disclosure. Unless otherwise specified, all technical and scientific terms used herein have the same meanings as those commonly understood by those skilled in the art to which the present disclosure belongs.
[0064] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit the exemplary embodiments according to the present disclosure. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should be understood that when the terms "comprising" and / or "including" are used in this specification, it indicates the presence of features, steps, operations, devices, components and / or combinations thereof.
[0065] In the absence of conflict, the embodiments in the present disclosure and the features in the embodiments may be combined with each other.
[0066] In view of the deficiencies in the prior art, the present invention provides a composition comment generation method incorporating meta-examples. The method uses a tagging method for associating composition fragments and comment content to construct a meta-example set, retrieves relevant examples of new compositions based on text encoding, and improves the composition semantic encoder's understanding of composition writing techniques through comparative learning. A cross-content detection method and masking mechanism for the original composition and comment are designed to eliminate the illusion problem caused by the original composition content contained in the relevant example comment content for the new composition comment. Finally, a new composition comment is generated using a pre-trained language model and relevant examples.
[0067] The advantage of the present invention is that the model can not only rely on real comments to learn the mapping relationship between essays and comments, but also use example information to learn diversified evaluation methods for similar fragments, thereby enhancing the correlation between generated comments and essay contents, improving the diversity of generated comment contents, and solving the problems of vague evaluation criteria and low correlation between comments and essay contents in open essay review scenarios.
[0068] The following is a further description of the composition review generation method and device incorporating meta-examples of the present invention in conjunction with specific embodiments.
[0069] Embodiment 1,
[0070] This embodiment provides a method for generating composition comments incorporating meta-examples, the method comprising:
[0071] S1. Obtain an original composition comment data set, wherein the data samples in the original composition comment data set include the original composition and its comment content, divide the original composition into a number of first text blocks, and annotate the mapping relationship between each first text block and the comment content, and use each first text block after annotation and its corresponding comment content as a meta-example and construct a meta-example set.
[0072] In this embodiment, the original composition comment data set includes original compositions of different genres and comment content for each genre. The purpose of this step is to construct a meta-example set based on the original compositions and corresponding comment content in the original composition comment data set.
[0073] Considering the close relationship between the review content and the original composition content, each sentence in the review content has a certain mapping relationship with part of the original composition content. Therefore, the original composition fragments and review sentences with a mapping relationship can be constructed as meta-examples.
[0074] In order to ensure that the number of meta-examples of each genre is balanced, this embodiment collects 60 pieces of composition comment data for each genre. Each composition comment data consists of composition serial number, composition title, score, grade, genre type, comment and composition content. The genre types involved in the data include narrative and argumentative essays, among which narrative mainly includes four types: narration, description of people, description of scenery and description of objects.
[0075] It should be noted here that there are no duplicate samples in the composition comment data used to construct the meta-example set and the composition comment data used to train the composition comment generation model. The composition comment data mentioned here are all composed of composition content, composition title, composition serial number, composition score, composition grade, composition genre, composition comment, etc. There are no duplicate samples in the composition comment data used to construct the meta-example set and the composition comment data used to train the composition comment generation model, which means that there will not be a single composition comment data that appears in both the meta-example set and the training data of the composition comment generation model, which can ensure that there is no data leakage and further avoid deviations in model performance.
[0076] The construction of the meta-example set specifically includes two steps: composition semantic segmentation and mapping relationship annotation. Composition semantic segmentation refers to segmenting the original composition into a number of first text blocks; mapping relationship annotation refers to annotating the mapping relationship between each first text block and the comment content.
[0077] Specifically, when writing an essay, in order to better express the viewpoint, the essay usually uses a variety of expression techniques in each paragraph. Since the expression techniques used in different sections of the essay vary greatly, in order to include more fine-grained evaluation information in the example, in this embodiment, the entire essay is first semantically segmented.
[0078] Semantic segmentation refers to dividing a composition into a sequence of multiple text blocks, where the content of each text block is relatively similar and the content of each text block is quite different. Since the paragraphs of a composition have the function of clearly dividing the semantics of the article, we can first perform preliminary semantic segmentation on the composition according to the paragraphs, and treat each paragraph as a text block.
[0079] However, if the composition is divided into paragraphs, some problems may occur, such as the resulting text blocks are shorter and a large number of text blocks are included in one article. Through observation of the data, we can find that the reasons for these problems are as follows: 1) Some compositions contain subtitles or inscriptions. After dividing into paragraphs, the subtitles or inscriptions will be treated as a separate text block; 2) Some authors' writing styles or prose-style writing requirements lead to more paragraphs in the composition. Adjacent paragraphs may describe the same thing, but are divided into multiple text blocks.
[0080] In order to solve the problem that the composition contains many subheadings, this embodiment manually checks all data. In order to solve the problem that the composition contains many paragraphs, this embodiment sets the minimum length of the text block to 300 words. If the length of the text block is less than this value, it is considered to be merged with the adjacent text block to ensure that each text block contains complete and sufficient semantic information.
[0081] Based on the above semantic segmentation method, the original composition can be segmented into several first text blocks.
[0082] The core of constructing a meta-example is to find the composition text blocks and comment contents with mapping relationships. However, there is currently no mature automatic annotation method specifically for this task, so an automatic annotator is designed in this embodiment, and a model is trained on the automatic annotator so that it can automatically annotate the mapping relationship between text blocks and comment contents.
[0083] Specifically, a pre-trained language model may be selected as the basic model of the automatic annotator, such as the BART model, the T5 model, etc., and then annotator training samples may be obtained from the original composition comment dataset to train the automatic annotator.
[0084] The method of obtaining the training samples of the annotator can be: select some data samples from the original composition comment data set, and obtain the comment content that evaluates each first text block in each original composition by manual annotation, that is, for each first text block, find the sentence that evaluates the first text block from the comment content corresponding to the original composition, and record this comment sentence as the comment content corresponding to the first text block. If a sentence that evaluates a first text block is not found in the comment content of the original composition, then the first text block is deleted.
[0085] Then, the first text block after manual annotation and its corresponding comment content are used as annotation training samples to train the automatic annotation machine. During the training process, the annotation training samples consisting of each first text block and its corresponding complete comment content are used as the input of the automatic annotation machine. According to the output of the automatic annotation machine and the comment content in the annotation machine training sample, a corresponding loss function is calculated and generated, such as a cross entropy loss function, to update the parameters of the automatic annotation machine. The model training process is a conventional technology and will not be repeated here.
[0086] After the automatic annotator is trained, during use, the remaining data samples (including the unannotated first text blocks and comment contents) in the original composition comment data set are used as inputs of the trained automatic annotator, and the trained automatic annotator is used to obtain comment contents evaluating the remaining first text blocks, thereby completing the mapping relationship annotation between each first text block and the comment content.
[0087] Finally, each first text block after annotation and its corresponding comment content are taken as a meta-example, which can be represented as a tuple , Represents the first text block, Indicates the first text block The corresponding comment content; then all meta-examples are constructed into a meta-example set.
[0088] In summary, the process of constructing the meta-example set in this embodiment is as follows: Figure 2 As shown, namely: 1) obtain the original composition comment data set, in which each data is composed of composition content, composition title, composition comment, composition type, author grade and composition score; 2) perform composition semantic segmentation on all original compositions in the original composition comment data set to obtain several first text blocks corresponding to the original composition; 3) select some data samples from the original composition comment data set, manually annotate the mapping relationship between the first text block and the comment content in each sample, and form the first text block and the comment content evaluating it into a meta-example sample; 4) train the automatic annotator through the existing meta-example samples, take the first text block and its complete comment content as the input of the automatic annotator, take the comment content corresponding to the first text block as the output, and train the automatic annotator; 5) annotate the remaining data samples in the original composition comment data set through the trained automatic annotator; 6) after processing all composition comment data according to the above process, obtain the meta-example set.
[0089] S2. Annotate the comment content of each meta-example in the meta-example set with the evaluation angle in combination with the evaluation angle, use the annotated meta-examples as training samples to construct a training sample set, and use the training sample set to train the composition semantic encoder by contrastive learning.
[0090] In this embodiment, the purpose of training the composition semantic encoder is to use the trained composition semantic encoder to obtain the encoding representation vector of the text block, and use it to retrieve the most relevant meta-example of the new composition.
[0091] In order to retrieve the most relevant meta-examples for the new composition, this embodiment uses contrastive learning to train the composition semantic encoder. During the retrieval process, if a pre-trained text encoder is used for retrieval, the relevant examples are only as close to the new composition as possible in semantics. However, different students may use different expression methods for similar topics, which may result in similar content. The comments on compositions may not be similar. Based on this understanding, in order to further improve the relevance of the retrieval results, the pre-trained text encoder is used as the basic model in this embodiment, and the composition semantic encoder (CompositionSemantic Encoder, Sem-Encoder) is trained through contrastive learning. The specific training process of Sem-Encoder is as follows:
[0092] First, the evaluation angles of the comments of each meta-example in the meta-example set are annotated to construct a training sample set. This embodiment organizes the evaluation angles involved in the comments. According to the evaluation angles specified in the evaluation standards for essays in various large-scale examinations, combined with the comments in the meta-example set, this embodiment refines the evaluation angles into 7 categories, and records the set of all evaluation angles as The specific evaluation perspective categories are described as follows:
[0093] Table 1 Definition of evaluation angle categories
[0094]
[0095] In order to allow the Sem-Encoder to integrate the features of the text in terms of expression techniques during the encoding process, this embodiment uses positive and negative samples to reflect the similarities and differences in the expression techniques between texts.
[0096] Essay comments are essentially evaluated according to given essay evaluation criteria, so each comment sentence can be classified into a certain evaluation criterion. The comments belonging to the same evaluation criterion are similar in evaluation angle, so the expression methods used in the essay fragments they evaluate are also similar.
[0097] Based on this background, this embodiment can classify and annotate the comment content of each meta-example in the meta-example set according to the evaluation angle, that is, clarify the evaluation angle to which the comment content of each meta-example belongs.
[0098] Due to the evaluation angle set The evaluation angle in the meta-example is summarized by combining the meta-example comment content and the evaluation criteria. The existing classification model cannot understand the mapping relationship between the evaluation angle and the comment content, so it cannot complete automatic annotation. Therefore, this embodiment adopts a manual annotation method to annotate the evaluation angle label of each meta-example comment content, that is, for the meta-example , the content of its comments The evaluation angle label is , The annotated meta-example is represented as .
[0099] Then, we construct positive and negative samples based on the annotated meta-examples as training samples to train the composition semantic encoder. Specifically, for each meta-example annotated with the evaluation angle, , from the first text block Belong to the same essay style and evaluation angle label From the remaining consistent meta-example samples, randomly sample a meta-example sample as a positive sample ; From the first text block Belong to different writing styles and evaluation angle labels From the rest of the inconsistent meta-example samples, randomly sample a meta-example sample as a negative sample , thereby completing the construction of positive and negative samples.
[0100] Finally, the constructed positive and negative samples are used as training samples to train the composition semantic encoder. In order to let the Sem-Encoder learn the expression techniques contained in the text block from the positive and negative samples, this embodiment designs a contrast loss function For each annotated meta-example , by minimizing the contrast loss , so that its first text block The encoding representation vector and the first text block in the positive sample The encoding representation vectors are closer to each other than the first text block in the negative sample. The distance between the encoding representation vectors is farther, so as to learn the similarities and differences in the expression methods between text blocks.
[0101] Among them, the contrast loss function The calculation process is expressed as:
[0102] (1);
[0103] In formula (1): represents the exponential function with the real number e as the base; Represents a function that measures the distance between two vectors, and the value range of this function is greater than 0; represents the temperature parameter, The smaller the value of is, the more attention will be paid to negative samples that are similar to the samples during the model optimization process, which can better help Sem-Encoder to have the desired encoding ability. In the specific implementation, Set to Euclidean distance, set the learning rate of Sem-Encoder to 1e-5, and set the temperature parameter Set to 0.05.
[0104] Based on the above process, by minimizing the contrast loss , complete the iterative training of the composition semantic encoder.
[0105] S3. For a new composition, divide the new composition into several second text blocks, and input the second text blocks and the first text block of the meta-example into the trained composition semantic encoder, obtain the encoding representation vector of the second text block and the encoding representation vector of the first text block respectively, calculate the similarity between the encoding representation vector of the second text block and the encoding representation vector of the first text block, and take the meta-example corresponding to the first text block with the greatest similarity as the relevant example of the corresponding second text block.
[0106] This step is to use the composition semantic encoder trained in the above steps to obtain the encoded representation vector of the text block, and use it to retrieve the most relevant meta-example of the new composition to obtain an evaluation basis for reference in the comment generation process.
[0107] Specific reference Figure 1 Because different passages in the composition use different techniques and play different roles in the whole composition, for new compositions In this embodiment, we first need to Perform semantic segmentation and divide it into several second text blocks, represented as ,in Indicates new composition No. The second text block, Indicates new composition The number of second text blocks contained in .
[0108] For new essays Every second text block , input it into the trained Sem-Encoder to obtain its encoding representation vector Meanwhile, for the first text block in the meta-example , and input it into the trained Sem-Encoder to obtain its encoding representation vector.
[0109] Since the second text block and the first block of text of the meta-example In the same semantic space, this embodiment calculates the second text block The encoding representation vector and the first text block of all meta examples The encoding represents the Euclidean distance between vectors. The closer the distance, the greater the similarity between the two text blocks, and vice versa.
[0110] Then the first text block with the largest similarity in the meta-example set is Corresponding meta example As the corresponding second text block The relevant example is the new essay retrieved Most relevant meta example.
[0111] S4. Mask the comment contents of the relevant examples, and construct an example information set based on the masked comment contents. Input the new composition and the example information set into a composition comment generation model for encoding-decoding operations to generate a composition comment corresponding to the new composition.
[0112] In the composition review generation stage, this embodiment uses a pre-trained language model as the basic model of the composition review generation model. The composition review generation model is composed of an encoder and a decoder. The encoder is a module for encoding the semantic information of the text, and the decoder needs to generate the target text in combination with the text semantic information output by the encoder.
[0113] Since the relevant examples and new essays retrieved , so that the comment content of the meta-example of the related example Can be used for new essays However, the comment content of this meta-example is directly introduced This may cause hallucination problems for the essay comment generation model. This is because the comment content of each meta-example is in conjunction with its first text block The evaluation is based on the content, so the review content May contain references to the first text block Summary information, which may also refer to the first text block Some sentences in .
[0114] Therefore, in order to avoid including new essays in the generated essay comments Irrelevant information, this embodiment is for each meta-example as a related example of the comment content Content masking is performed, such as Figure 1 Specifically, the jieba tool is used to mask the comment content of each meta-example that is a related example. and the first text block corresponding to it Perform word segmentation operations and obtain the comment content respectively The word set and the first text block The word set of the comment content, except for stop words The word set that appears in the first text block The word position in the word segmentation set is marked; when inputting the composition comment generation model, the comment content is The words corresponding to the marked positions in the word segmentation set are replaced by Word unit, thereby completing the masking operation of the relevant example comment content.
[0115] Then based on the masked review content Construct a sample information collection. Figure 1 As shown, the comment content after content masking Recorded as , and write the new composition All second text blocks in Corresponding to the masked comments in the relevant examples After splicing in sequence, they form a new composition Example information collection .
[0116] Finally, write the new composition and sample information collection As the input of the encoder, the corresponding composition comments are finally generated by the decoder.
[0117] Furthermore, during the encoding process, in order to allow the encoder to better distinguish new compositions and sample information collection The semantics of this embodiment is in the new composition and sample information collection Previously spliced a piece of identification text , the final encoder input is Then, it is fed into the encoder to analyze the new composition. and sample information collection Encode, and dynamically add new compositions to the decoder through the cross-attention mechanism and sample information collection The information is integrated into the decoding process to generate more realistic composition comments.
[0118] Furthermore, this embodiment generates a loss function by minimizing To optimize the composition review generation model, we have:
[0119] (2);
[0120] In formula (2): Indicated in The word-units in the real comments corresponding to the time step, the real comments are from the composition comment data used to train the composition comment generation model; is the input of the encoder, and Indicates the identification text. Represents a collection of sample information, Indicates a new composition; Indicates in front All the tokens generated by the composition review generation model at time steps; Indicated in The decoder output of the composition review generation model for time steps is The probability distribution of It represents the time step required by the composition comment generation model to generate a complete composition comment, corresponding to the length of the generated composition comment. In the specific implementation, the learning rate of the composition comment generation model is set to 4e-5, the batch size is set to 4, the generation process adopts beam search, and the beam size is set to 4.
[0121] Furthermore, in order to help the composition comment generation model better identify the core content of the original composition, this embodiment uses an unsupervised summary extraction algorithm to extract the summary of the input original composition, which also solves the problem that the length of some primary and secondary school students' compositions exceeds the input length range that most pre-trained language models can handle. This embodiment can use the TextRank algorithm to extract the top 20 (K=20) most important sentences in the original composition, and splice them in the order in which they appear in the original composition as the composition summary. , and use the essay summary A to replace the new essay in the essay comment generation model in the essay comment generation stage , that is, in the encoding process, the final encoder input is .
[0122] The effectiveness of the method of this embodiment is verified below in combination with a specific application example.
[0123] For the task of generating comments for primary and secondary school essays, the specific implementation process of this method is as follows:
[0124] 1. Construction of meta-example set.
[0125] In order to ensure a balanced number of meta-examples for each genre, this method collected 60 essay review data for each genre, and a total of 300 original essay review data were used to construct the meta-example set. Each essay review data consists of essay serial number, essay title, score, grade, genre type, comment, and essay content. The genre types involved in the data include narrative and argumentative essays, among which narrative mainly includes four types: narration, character description, scenery description, and object description.
[0126] The specific process of constructing the meta-example set includes two steps: composition semantic segmentation and mapping relationship annotation:
[0127] 1.1、Composition semantic segmentation:
[0128] Considering that there are large differences in the expression techniques used in different sections of the composition, this method first performs semantic segmentation on the content of each original composition in the 300 data. Since the composition paragraphs themselves have the function of clearly dividing the semantics of the article, this method first performs preliminary semantic segmentation on the original composition according to the paragraphs, and regards each paragraph as a text block.
[0129] However, if the original composition is divided into paragraphs, some problems may occur, such as the resulting text blocks are shorter and a large number of text blocks are included in one article. Through observation of the data, it can be found that the reasons for these problems are as follows: First, some compositions contain subtitles or inscriptions. After being divided into paragraphs, the subtitles or inscriptions will be treated as a separate text block. Second, the writing style or prose writing requirements of some authors lead to the inclusion of more paragraphs in the composition. Adjacent paragraphs may describe the same thing, but are divided into multiple text blocks.
[0130] In order to solve the problem that the original essay contains too many subheadings, this method manually checks all data. In order to solve the problem that the original essay contains too many paragraphs, this method sets the minimum length of the first text block to 300 words. If the length of the first text block is less than this value, it will be considered to be merged with the adjacent first text block to ensure that each first text block contains complete and sufficient semantic information.
[0131] 1.2. Mapping relationship annotation between composition text blocks and comment content:
[0132] The core of constructing meta-examples is to find the composition text blocks and comment content that have a mapping relationship. However, there is currently no mature automatic annotation method specifically for this task. Therefore, this method first selects some samples from the original composition comment data set through manual annotation, and annotates the comment content that evaluates each first text block in each original composition. Subsequently, the automatic annotator will be trained with the manually annotated meta-example data to annotate the remaining composition comment data.
[0133] In manual annotation, for the original composition comment data, this method first obtains the corresponding first text block sequence by composition semantic segmentation for each original composition. Then, for each first text block, find the sentence that evaluates the first text block from the comments corresponding to the original composition, and record this comment sentence as the comment content corresponding to the first text block. If a first text block does not find a sentence that evaluates it from the composition comments, then the first text block is deleted.
[0134] After obtaining the manually annotated meta-example data, select a pre-trained language model as the basic model of the automatic annotator, such as the BART model or the T5 model, train the automatic annotator with the annotated meta-example data, and use the automatic annotator to automatically annotate the mapping relationship between the remaining sample text blocks and the comment content.
[0135] During the training process, the tagger training sample consisting of each first text block and its corresponding complete comment content is used as the input of the automatic tagger. The corresponding loss function is calculated based on the output of the automatic tagger and the comment content in the tagger training sample to update the automatic tagger parameters.
[0136] During use, the remaining data samples in the original composition comment data set (including the unlabeled first text blocks and comment content) are used as the input of the trained automatic annotator, and the trained automatic annotator is used to obtain the comment content that evaluates the remaining first text blocks, thereby completing the mapping relationship annotation between each first text block and the comment content.
[0137] Finally, this method obtains a meta-example set by performing the above operations on the original composition comment data set, wherein each meta-example consists of the first text block and the comment content evaluating the first text block.
[0138] The following is an example of a sample meta-item:
[0139] Meta sample text block: If Zhangjiajie is an exquisite landscape painting, then Fenghuang Ancient Town is the finishing touch on the painting; if Zhangjiajie is a brocade bag embroidered with flowers, then Fenghuang Ancient Town is a bright pearl on it that shines dazzlingly. When I think of Fenghuang Ancient Town, I seem to be surrounded by an ancient and quaint atmosphere. I have experienced the majesty of Mount Tai and the wonders of Guilin's landscape, but none of them can compare to the impressive impression that Fenghuang Ancient Town has given me. The small bridges and flowing water, the low buildings with green tiles, and the fresh air make me feel refreshed. The red lanterns are hung under the eaves of every household, as if you are in thousands of years ago. On the small stools by the door, several old men in Miao costumes are chatting happily. On the wooden bridge, the beautiful Miao girl is humming a little song while walking lightly. Everything seems so harmonious and peaceful.
[0140] Content of Yuan example comment: The article mainly describes what the author sees and hears while visiting the Ancient Town of Fenghuang, presenting the beautiful scenery of the Ancient Town of Fenghuang to the readers. The language is natural and friendly. The article not only praises the beauty of the Ancient Town of Fenghuang, but also expresses the author's love for the Ancient Town of Fenghuang.
[0141] 2. Train the composition semantic encoder.
[0142] In order to retrieve the most relevant meta-examples for the new composition, this method uses contrastive learning to train the composition semantic encoder. During the retrieval process, if a pre-trained text encoder is used for retrieval, the relevant examples are only as close to the new composition as possible in semantics. However, different students' compositions may use different expressions for similar topics, which may result in that the comments on compositions with similar content may not be similar. Based on this understanding, in order to further improve the relevance of the retrieval results, this method uses the pre-trained text encoder Sentence-BERT as the basic model and trains the composition semantic encoder (Composition Semantic Encoder, Sem-Encoder) through contrastive learning. The specific training strategy of Sem-Encoder is as follows:
[0143] 2.1. Construct positive and negative samples:
[0144] In order to allow Sem-Encoder to integrate the features of text expression techniques during the encoding process, this method uses positive and negative samples to reflect the similarities and differences in the expression techniques between texts. Essay comments are essentially evaluated based on given essay evaluation criteria, so each comment sentence can be classified into a certain evaluation criterion. The comments belonging to the same evaluation criterion are similar in evaluation angle, so the expression techniques used in the essay fragments they evaluate are also similar. Based on this background, this method first classifies the comment content of each meta-example according to the evaluation angle, and then constructs positive and negative samples based on the meta-example data with the evaluation angle annotated.
[0145] First, this method sorts out the evaluation angles involved in the comments. According to the evaluation angles specified in the evaluation standards for various large-scale examination essays and combined with the content of the comments in the meta-example dataset, this method refines the evaluation angles into 7 categories and records the set of all evaluation angles as .
[0146] Next, the method annotates the evaluation perspective to which each meta-example comment belongs. Each meta-example is represented as a tuple , Represents the first text block, Indicates the first text block Corresponding review content. Due to the evaluation angle collection The evaluation angles in are summarized by combining the meta-example comment data and the evaluation criteria. The existing classification model cannot understand the mapping relationship between the evaluation angle and the comment content, so it cannot complete automatic labeling. Therefore, this method uses manual labeling to label the evaluation angle label of each meta-example comment content, that is, for the meta-example , the content of its comments The evaluation angle label is , The annotated meta-example is represented as .
[0147] For each meta-example after marking the evaluation angle , from the first text block Belong to the same essay style and evaluation angle label From the remaining consistent meta-example samples, randomly sample a meta-example sample as a positive sample ; From the first text block Belong to different writing styles and evaluation angle labels From the rest of the inconsistent meta-example samples, randomly sample a meta-example sample as a negative sample , thereby completing the construction of positive and negative samples.
[0148] 2.2、Training Sem-Encoder:
[0149] In order to allow Sem-Encoder to learn the expression techniques contained in the text block from positive and negative samples, this method designs a contrast loss function For each annotated meta-example , by minimizing the contrast loss , so that its first text block The encoding representation vector and the first text block in the positive sample The encoding representation vectors are closer to each other than the first text block in the negative sample. The distance between the encoding representation vectors is farther, so as to learn the similarities and differences in the expression methods between text blocks. The calculation process of is shown in formula (1) above.
[0150] 3. Extract the essay summary.
[0151] In order to help the composition comment generation model better identify the core content of the original composition, this method uses an unsupervised summary extraction algorithm to extract the summary of the input original composition, which also solves the problem that the length of some primary and secondary school students' compositions exceeds the input length range that most pre-trained language models can handle. This method can use the TextRank algorithm to extract the top 20 most important sentences in the original composition, and splice them in the order they appear in the original composition as the composition summary. .
[0152] 4. Retrieve relevant examples based on the content of the new composition.
[0153] In order to obtain a reference for evaluation in the process of comment generation, this method first uses Sem-Encoder to retrieve relevant examples of essays from the meta-example dataset, such as Figure 1The specific retrieval process is as follows:
[0154] 4.1. Semantic Segmentation
[0155] First, due to the different expression techniques used in different sections of the composition and their different roles in the whole composition, this method needs to input the new composition After semantic segmentation, a text block sequence consisting of three second text blocks is obtained. .
[0156] New essay input The content is as follows: I first knew about Taihu Lake when I was a child. The elders passed down a story: After the fall of the Wu Kingdom, Doctor Fan retired after achieving success and sailed on the five lakes with Xizi, and lived to a ripe old age. At that time, I thought, this must be a beautiful place, with reeds and a few wisps of breeze blowing leisurely; on the other side of the water, a few egrets danced elegantly. The clouds in the sky were gorgeous and crimson in the sunset; the boundless lake was sparkling in the morning sun...
[0157] 4.2. Retrieve relevant examples:
[0158] For new essays Every second text block , input it into the trained Sem-Encoder to obtain its encoding representation vector . Then, due to the second text block and the first block of text of the meta-example In the same semantic space, this method calculates the second text block The encoding representation vector and the first text block of all meta examples The encoding of represents the Euclidean distance between vectors. The closer the distance, the greater the similarity between the two text blocks, and vice versa. Corresponding meta example As the corresponding second text block The relevant example is the new essay retrieved Most relevant meta example.
[0159] For example, the second text block The retrieved relevant examples are as follows:
[0160] Related sample text block: Look, in this hazy morning, the town is like a girl sleeping peacefully. Wisps of green gauze are gently falling around. The sun is getting brighter and brighter, and thousands of beams of sunlight tiptoe and quietly lift the gauze. Every household has opened their doors, and women are pounding clothes on the big rocks by the stream, and farmers are hoeing the fields on the terraces over there.
[0161] Related example comment content: In this article, the author is good at using the rhetorical device of personification, vividly comparing the small town to a peacefully sleeping girl.
[0162] 5. Masking of irrelevant information about the content of the relevant example comments.
[0163] Since the relevant examples and new essays retrieved , so that the comment content of the meta-example of the related example Can be used for new essays However, the comment content of this meta-example is directly introduced This may cause hallucination problems for the essay comment generation model. This is because the comment content of each meta-example is in conjunction with its first text block The evaluation is based on the content, so the review content May contain references to the first text block Summary information, which may also refer to the first text block Some sentences in .
[0164] Therefore, in order to avoid including new essays in the generated essay comments Irrelevant information, this method treats the comment content of each meta-example as a related example Content masking is performed, such as Figure 1 Specifically, the jieba tool is used to mask the comment content of each meta-example that is a related example. and the first text block corresponding to it Perform word segmentation operations and obtain the comment content respectively The word set and the first text block The word set of the comment content, except for stop words The word set that appears in the first text block The word position in the word segmentation set is marked; when inputting the composition comment generation model, the comment content is The words corresponding to the marked positions in the word segmentation set are replaced by Word unit, thereby completing the masking operation of the relevant example comment content.
[0165] 6. Generate new composition comments based on the composition summary and the masked content of related example comments.
[0166] In the composition review generation stage, this method uses a pre-trained language model as the basic model of the composition review generation model. The composition review generation model consists of an encoder and a decoder. The encoder is a module for encoding the semantic information of the text, and the decoder needs to generate the target text based on the text semantic information output by the encoder.
[0167] like Figure 1 As shown, first, the content of the comments after content masking is Recorded as , and write the new composition All second text blocks in Corresponding to the masked comments in the relevant examples After splicing in sequence, they form a new composition Example information collection Next, write the new composition and sample information collection As the input of the encoder, the corresponding composition comments are finally generated by the decoder.
[0168] During the encoding process, in order to allow the encoder to better distinguish new compositions and sample information collection The semantics of this embodiment is in the new composition and sample information collection Previously spliced a piece of identification text , and extract the most important first 20 sentences from the original composition to form composition summary A, and use composition summary A to replace the new composition , the final encoder input is . Then, it is fed into the encoder to summarize the composition and sample information collection Encode and dynamically summarize the composition through the cross-attention mechanism in the decoder and sample information collection The information is integrated into the decoding process to generate more realistic composition comments.
[0169] During the training phase of the model, this method generates a loss function by minimizing To optimize the composition review generation model and minimize the generation loss function The calculation process of is shown in formula (2) above.
[0170] In the use phase of the model, you can As input, use the trained essay comment generation model to generate new essays The corresponding comment content.
[0171] For example, according to the composition content shown in the above example, after steps 3-6, the generated composition comments are as follows: This is a descriptive composition with vivid language, "The girl washing silk by the water has been praised countless times by poets, and those wind-like poems have also blown the ripples of a girl's heart under the sunset", "And the lotus-picking girl in the water, with her lotus leaf skirt cut in the same color, has also entered the dream of the passing boy. When he wakes up at midnight, he looks at her tenderness when he bows his head, and his love for his son is as clear as water. These poems, lyrics, songs and paintings, which are deposited in the water of Taihu Lake, have become precious spiritual wealth that flows with the history of Suzhou." Metaphors and personifications give life to the water of Taihu Lake, and the writing is fluent, the structure is well arranged, and the structure is complete. It expresses the author's love for the profound and splendid history and civilization of Taihu Lake. The whole text has a complete structure, clear ideas, distinct levels, and it integrates emotions with scenery, with emotions and scenes blending together. Between the lines, the young author reveals his love for Taihu Lake and highlights his sincere love for Taihu Lake. I hope the young author will continue his efforts!
[0172] In summary, the composition review generation method incorporating meta-examples of the present invention uses a tagging method for associating composition fragments and review contents to construct a meta-example set, retrieves relevant examples of new compositions based on text encoding, and improves the composition semantic encoder's understanding of composition writing techniques through comparative learning. A cross-content detection method and masking mechanism for original compositions and reviews is designed to eliminate the illusion problem caused by the original composition content contained in the relevant example review content for the new composition review. Finally, a new composition review is generated using a pre-trained language model and relevant examples.
[0173] Embodiment 2,
[0174] Ginseng Figure 3 This embodiment provides a device for implementing a composition review generation method integrating meta-examples, the device comprising:
[0175] A meta-example set construction module is used to obtain an original composition comment data set, wherein the data samples in the original composition comment data set include the original composition and its comment content, divide the original composition into a plurality of first text blocks, and mark the mapping relationship between each first text block and the comment content, and use each first text block after marking and its corresponding comment content as a meta-example and construct a meta-example set;
[0176] A composition semantic encoder training module is used to annotate the comment content of each meta-example in the meta-example set according to the evaluation angle, use the annotated meta-examples as training samples to construct a training sample set, and use the training sample set to train the composition semantic encoder by contrastive learning;
[0177] A related example retrieval module is used to divide the new composition into a plurality of second text blocks, and input the second text blocks and the first text block of the meta-example into the trained composition semantic encoder, respectively obtain the encoding representation vector of the second text block and the encoding representation vector of the first text block, calculate the similarity between the encoding representation vector of the second text block and the encoding representation vector of the first text block, and use the meta-example corresponding to the first text block with the greatest similarity as the related example of the corresponding second text block;
[0178] The composition comment generation module is used to mask the comment content of the relevant examples, and construct an example information set based on the masked comment content, and input the new composition and the example information set into the composition comment generation model for encoding-decoding operations to generate a composition comment corresponding to the new composition.
[0179] The process of generating composition comments by using the device of the present invention into a meta-example is as follows: Figure 4 The specific process is as follows: 1) construct a meta-example set based on the original composition comment data set; 2) use contrastive learning to train the composition semantic encoder on the meta-example set; 3) load the trained composition semantic encoder into the device; 4) train the composition comment generation model based on the composition comment data. The composition comment data used here and the original composition comment data used in 1) have no repeated samples; 5) load the trained composition comment generation model into the device; 6) finally, use the composition semantic encoder in the device to retrieve relevant examples of the input composition from the meta-example set, and input the composition and relevant examples into the composition comment generation model to generate reasonable comments corresponding to the composition.
[0180] Embodiment 3,
[0181] Ginseng Figure 5 This embodiment also provides an electronic device, which is mainly composed of five parts, namely, a readable storage medium, a processor, an internal memory, an input device, and an output device. The readable storage medium is composed of a database and an executable computer program, and the database stores a meta-example set, training data of a composition comment generation model, initialization parameters of a composition semantic encoder, and initialization parameters of a composition comment generation model.
[0182] In the electronic device provided by the present invention, the specific implementation process of the processor when executing the computer program is as follows:
[0183] Determine whether it is the model training phase or the usage phase;
[0184] If it is a training phase, the training data corresponding to the model is obtained; the model is trained according to the training data; after the training is completed, the model is loaded into the device;
[0185] If it is the usage stage, a composition comment generation model that incorporates meta-examples is obtained, and the composition to be processed is input into the model; the composition text is passed through the summary extraction module to obtain a composition summary; the composition text is retrieved from the meta-example set through a composition semantic encoder to obtain relevant examples; the relevant examples are passed through a content masking module to remove irrelevant information; finally, according to the content of the comments after content masking in the composition summary and relevant examples, the encoder is used to encode the composition and example information, and then the decoder is used to generate the corresponding comments for the composition to be processed.
[0186] In the embodiments of the present specification, electronic devices may include, but are not limited to: personal computers, server computers, workstations, desktop computers, laptop computers, notebook computers, mobile computing devices, smart phones, tablet computers, cellular phones, personal digital assistants (PDAs), handheld devices, messaging devices, wearable computing devices, consumer electronic devices, and the like.
[0187] Embodiment 4,
[0188] This embodiment also provides a machine-readable storage medium storing executable instructions, which, when executed, enable the machine to execute the composition review generation method incorporating meta-examples as described above.
[0189] Specifically, a system or device equipped with a readable storage medium can be provided, on which software program codes that implement the functions of any of the above-mentioned embodiments are stored, and a computer or processor of the system or device can read and execute instructions stored in the readable storage medium.
[0190] In this case, the program code itself read from the machine-readable medium can realize the function of any one of the above embodiments, and thus the machine-readable code and the machine-readable storage medium storing the machine-readable code constitute part of this specification.
[0191] Examples of readable storage media include floppy disks, hard disks, magneto-optical disks, optical disks (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD-RW), magnetic tapes, non-volatile memory cards, and ROMs. Optionally, the program code may be downloaded from a server computer or a cloud via a communication network.
[0192] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0193] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. 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.
[0194] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate 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 A function specified in one or more boxes.
[0195] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0196] Obviously, the above embodiments of the present invention are merely examples for clearly illustrating the technical solution of the present invention, and are not intended to limit the specific implementation methods of the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the claims of the present invention shall be included in the protection scope of the claims of the present invention.
Claims
1. A composition review generation method incorporating meta-examples, characterized in that: The method comprises: S1. Obtain an original composition comment data set, wherein the data samples in the original composition comment data set include the original composition and its comment content, divide the original composition into a plurality of first text blocks, and annotate the mapping relationship between each first text block and the comment content, and use each annotated first text block and its corresponding comment content as a meta-example and construct a meta-example set; S2, annotating the comment content of each meta-example in the meta-example set with the evaluation angle, using the annotated meta-examples as training samples to construct a training sample set, and using the training sample set to train the composition semantic encoder by contrastive learning; The step of using the training sample set to train the composition semantic encoder by contrastive learning specifically includes: The evaluation angle of the comment content of each meta-example in the meta-example set is annotated manually. , Represents the first text block, Indicates the first text block The corresponding comment content, the comment content The evaluation angle label is , then the meta-example after the evaluation angle annotation is expressed as , , represents the set of evaluation angles; Meta example based on the completed evaluation angle annotation Construct positive and negative samples for the meta-examples after the evaluation angle annotation is completed , from the first text block Belong to the same essay style and evaluation angle label Among the remaining consistent meta-examples, randomly sample a meta-example as a positive sample ; From the first text block Belong to different writing styles and evaluation angle labels Among the remaining inconsistent meta-examples, randomly sample a meta-example as a negative sample ; The constructed positive and negative samples are used as training samples, and the contrast loss function is used Training the composition semantic encoder, the contrast loss function for: (1); In formula (1): represents the exponential function with the real number e as the base; Represents a function that measures the distance between two vectors, with a value range greater than 0, and Indicates the first text block The encoding representation vector of the first text block of the positive sample The encoding represents the distance between vectors, Indicates the first text block The encoded representation vector of the first text block with negative samples The encoding of represents the distance between vectors; represents the temperature parameter; S3, for a new composition, dividing the new composition into a plurality of second text blocks, and inputting the second text blocks and the first text block of the meta-example into a trained composition semantic encoder, respectively obtaining the encoding representation vector of the second text block and the encoding representation vector of the first text block, calculating the similarity between the encoding representation vector of the second text block and the encoding representation vector of the first text block, and taking the meta-example corresponding to the first text block with the greatest similarity as the relevant example of the corresponding second text block; S4. Mask the comment contents of the relevant examples, and construct an example information set based on the masked comment contents. Input the new composition and the example information set into a composition comment generation model for encoding-decoding operations to generate a composition comment corresponding to the new composition.
2. The composition review generation method incorporating meta-examples according to claim 1, characterized in that: In step S1, marking the mapping relationship between each first text block and the comment content specifically includes: Build an automatic tagger based on a pre-trained language model; Selecting some data samples from the original composition comment data set, obtaining the comment content of the evaluation of each first text block in each original composition in the some data samples through manual annotation, and constructing a tagger training sample; Using the tagger training samples to train the automatic tagger, and calculating and generating a loss function based on the output of the automatic tagger and the comment content in the tagger training samples to update the automatic tagger parameters; The trained automatic annotator is used to annotate the remaining data samples in the original composition comment data set, and the comment content evaluating each first text block in each original composition in the remaining data samples is obtained.
3. The composition review generation method incorporating meta-examples according to claim 1, characterized in that: In step S4, masking operation is performed on the comment content of the relevant example, specifically including: Using the jieba tool to perform a word segmentation operation on the comment content of the relevant example and the first text block corresponding thereto, to obtain a comment content word segmentation set and a first text block word segmentation set respectively; Marking the positions of the words in the comment content word set that appear in the first text block word set; Replace the words corresponding to the marked positions in the comment content segmentation set with Word element.
4. The composition review generation method incorporating meta-examples according to claim 1, characterized in that: In step S4, the example information set constructed based on the masked comment content is , Indicates the masked comment content; The composition review generation model includes an encoder and a decoder, and adopts a method of minimizing the generation loss function Training the composition review generation model, minimizing the generation loss function for: (2); In formula (2): Indicated in The word-units in the real comments corresponding to the time step, the real comments are from the composition comment data used to train the composition comment generation model; is the input of the encoder, and Indicates the identification text. Represents a collection of sample information, Indicates a new composition; Indicates in front All the tokens generated by the composition review generation model at time steps; Indicated in The decoder output of the composition review generation model for time steps is The probability distribution of It represents the time steps required by the composition review generation model to generate a complete composition review, corresponding to the length of the generated composition review.
5. The composition review generation method incorporating meta-examples according to claim 4 is characterized in that: The step S4 also includes: using the TextRank algorithm to extract the first K sentences in the original composition, and splicing them in the order in which they appear in the original composition as the composition summary , and in the process of generating composition comments, the composition summary A is used to replace the new composition As the input of the encoder of the composition review generation model, .
6. A device for implementing a composition review generation method incorporating meta-examples, characterized in that: The device comprises: A meta-example set construction module is used to obtain an original composition comment data set, wherein the data samples in the original composition comment data set include the original composition and its comment content, divide the original composition into a plurality of first text blocks, and mark the mapping relationship between each first text block and the comment content, and use each first text block after marking and its corresponding comment content as a meta-example and construct a meta-example set; A composition semantic encoder training module is used to annotate the comment content of each meta-example in the meta-example set according to the evaluation angle, use the annotated meta-examples as training samples to construct a training sample set, and use the training sample set to train the composition semantic encoder by contrastive learning; The step of using the training sample set to train the composition semantic encoder by contrastive learning specifically includes: The evaluation angle of the comment content of each meta-example in the meta-example set is annotated manually. , Represents the first text block, Indicates the first text block The corresponding comment content, the comment content The evaluation angle label is , then the meta-example after the evaluation angle annotation is expressed as , , represents the set of evaluation angles; Meta example based on the completed evaluation angle annotation Construct positive and negative samples for the meta-examples after the evaluation angle annotation is completed , from the first text block Belong to the same essay style and evaluation angle label Among the remaining consistent meta-examples, randomly sample a meta-example as a positive sample ; From the first text block Belong to different writing styles and evaluation angle labels Among the remaining inconsistent meta-examples, randomly sample a meta-example as a negative sample ; The constructed positive and negative samples are used as training samples, and the contrast loss function is used Training the composition semantic encoder, the contrast loss function for: (1); In formula (1): represents the exponential function with the real number e as the base; Represents a function that measures the distance between two vectors, with a value range greater than 0, and Indicates the first text block The encoding representation vector of the first text block of the positive sample The encoding represents the distance between vectors, Indicates the first text block The encoded representation vector of the first text block with negative samples The encoding of represents the distance between vectors; represents the temperature parameter; A related example retrieval module is used to divide the new composition into a plurality of second text blocks, and input the second text blocks and the first text block of the meta-example into the trained composition semantic encoder, respectively obtain the encoding representation vector of the second text block and the encoding representation vector of the first text block, calculate the similarity between the encoding representation vector of the second text block and the encoding representation vector of the first text block, and use the meta-example corresponding to the first text block with the greatest similarity as the related example of the corresponding second text block; The composition comment generation module is used to mask the comment content of the relevant examples, and construct an example information set based on the masked comment content, and input the new composition and the example information set into the composition comment generation model for encoding-decoding operations to generate a composition comment corresponding to the new composition.
7. An electronic device, characterized in that: The electronic device comprises: at least one processor; and A memory storing instructions, which, when executed by the at least one processor, causes the at least one processor to execute the composition review generation method incorporating meta-examples according to any one of claims 1 to 5.
8. A machine-readable storage medium, characterized in that: The machine-readable storage medium stores executable instructions, which, when executed, cause the machine to perform the composition review generation method incorporating meta-examples according to any one of claims 1 to 5.
Citation Information
Patent Citations
Knowledge graph fusion multi-dimensional nested generalization mode-based composition comment generation method
CN116108204A
Automatic comment generation method based on large-scale language model and related device
CN116882414A
Coding and decoding-based comment generation method and device, equipment and storage medium
CN111897955A
Comment generation method and device, terminal equipment and storage medium
CN112069781A
Template sentence evaluation method based on multilevel comparative learning
CN115270752A
