A training sample generation method, device, electronic device and storage medium
By combining basic prompts and logically guided text to generate training samples adapted to the target business, the problem of time-consuming and labor-intensive training sample generation and unstable annotation results in existing technologies is solved, achieving efficient and accurate training sample construction and model recognition.
Patent Information
- Application Number
- CN202411147175.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-21
- Publication Date
- 2024-11-01
- Estimated Expiration
- 2044-08-21
AI Technical Summary
Existing technologies consume a lot of time and human resources when generating training samples, and the labeling effect depends on subjective judgment, which cannot guarantee the quality of training samples.
By acquiring reference comment text labeled with content tags and candidate comment text without tags, and combining basic prompts with a first language model, training samples adapted to the target business are generated. Logical guidance text is used to adjust the basic prompts to meet the target conditions, and a training sample set is constructed.
This improved the quality of training sample generation and the accuracy of recognition results, enabling rapid construction of training samples and ensuring the effectiveness of model recognition.
Smart Images

Figure CN118673334B_ABST
Abstract
Description
Background Art
[0002] Under the existing technology, the corresponding content tags are usually identified and determined based on the object review text of the relevant object in the specified business scenario, so that the usage experience of the relevant object in the specified business scenario can be analyzed based on the obtained content tags.
[0003] At present, in the process of analyzing the comment text of the object to obtain the content label, a text classification model is usually trained based on the constructed training samples, so that label classification within the specified label range can be achieved based on the text classification model, wherein a training sample includes: a sample comment text and a corresponding sample label.
[0004] However, when using the above method to classify content labels, it takes a lot of time and labeling costs to manually label each training sample. Moreover, since the labeled sample labels depend on the subjective judgment of the relevant labelers, the labeling effect of the training samples cannot be guaranteed. Summary of the invention
[0005] The embodiments of the present application provide a method, device, electronic device and storage medium for generating a training sample, so as to efficiently generate a suitable training sample.
[0006] In the first aspect, a method for generating training samples is proposed, comprising:
[0007] For the target business, obtain each reference review text annotated with content tags, and obtain each unannotated candidate review text;
[0008] Combining the reference comment texts with the basic prompt content determined for the target business to generate corresponding basic prompt texts, calling the first language model to output prediction tags corresponding to the basic prompt texts, and obtaining evaluation results of the first language model for the target business based on the prediction tags and the corresponding content tags;
[0009] When the evaluation result does not meet the standard condition, each preset logical guidance text is added to the basic prompt content to generate corresponding candidate prompt content, and from each candidate prompt content, a target prompt content is selected that makes the evaluation result of the first language model meet the standard condition;
[0010] Each candidate comment text is combined with the target prompt content to generate a corresponding sample prompt text, and the first language model is called to output a sample label corresponding to each sample prompt text, and a training sample set is constructed based on each sample prompt text and the corresponding sample label.
[0011] In a second aspect, a training sample generation device is proposed, comprising:
[0012] An acquisition unit, for acquiring reference review texts marked with content tags and unmarked candidate review texts for a target business;
[0013] A generating unit, configured to respectively combine the reference comment texts with the basic prompt content determined for the target business to generate corresponding basic prompt texts, and to call the first language model to respectively output prediction tags corresponding to the basic prompt texts, and to obtain an evaluation result of the first language model under the target business based on the prediction tags and the corresponding content tags;
[0014] a selection unit, configured to, when the evaluation result does not meet the standard condition, add each preset logical guidance text to the basic prompt content respectively, generate corresponding candidate prompt content, and select, from each candidate prompt content, a target prompt content that makes the evaluation result of the first language model meet the standard condition;
[0015] The construction unit is used to combine each candidate comment text with the target prompt content to generate a corresponding sample prompt text, and call the first language model to output a sample label corresponding to each sample prompt text, and construct a training sample set based on each sample prompt text and the corresponding sample label.
[0016] Optionally, when obtaining each unlabeled candidate comment text, the obtaining unit is used to:
[0017] Obtain unlabeled original comment texts;
[0018] According to the similarity between every two original comment texts, the original comment texts satisfying similarity conditions are clustered to obtain original comment text groups, and one original comment text is randomly selected from each original comment text group as a candidate comment text.
[0019] Optionally, after outputting the sample labels corresponding to the sample prompt texts respectively and before constructing the training sample set based on the sample prompt texts and the corresponding sample labels, the acquisition unit is further used to:
[0020] For each candidate review text, perform the following operations:
[0021] When there are other original comment texts except one candidate comment text in the determined original comment text group, the other original comment texts are respectively combined with the target prompt content to generate corresponding sample prompt texts, and the sample label determined corresponding to the one candidate comment text is used as the sample label of each sample prompt text generated corresponding to the original comment text group.
[0022] Optionally, when obtaining each unlabeled candidate comment text, the obtaining unit is used to:
[0023] Obtaining each unlabeled initial review text, and obtaining each keyword and the associated synonymous relationship of the word; the synonymous relationship of the word associated with a keyword is used to indicate the synonym corresponding to the keyword;
[0024] By replacing the corresponding keywords with synonyms, the initial review texts containing the keywords are adjusted to obtain processed extended review texts;
[0025] The initial review texts and the extended review texts are determined as candidate review texts.
[0026] Optionally, when the initial review texts containing the keywords are adjusted by replacing the corresponding keywords with synonyms to obtain the processed extended review texts, the acquisition unit is used to:
[0027] For each initial comment text, perform the following operations:
[0028] Performing hit detection in an initial review text according to the keywords;
[0029] When the target keyword is determined to be hit based on the detection result, the corresponding synonymous keywords are obtained based on the synonymous relationship associated with the target keyword, and the target keyword in the initial comment text is replaced by the synonymous keywords to obtain extended comment texts.
[0030] Optionally, when replacing the target keyword in the initial comment text with the synonymous keywords to obtain the extended comment texts, the acquisition unit is used to:
[0031] Replacing the target keyword in the initial review text with the synonymous keywords respectively to obtain pending review texts;
[0032] The text similarities between the pending comment texts and the one initial comment text are calculated respectively, and the pending comment texts whose text similarities meet the screening conditions are determined as extended comment texts.
[0033] Optionally, when selecting, from among the candidate prompt contents, the target prompt content that makes the evaluation result of the first language model meet the standard condition, the selection unit is configured to:
[0034] For each candidate prompt content, the following operations are performed respectively: each of the reference comment texts is combined with a candidate prompt content to generate a corresponding candidate prompt text, and the first language model is called to output a prediction label corresponding to each candidate prompt text, and based on each prediction label and the corresponding content label, an evaluation result of the first language model under the target business is obtained;
[0035] Among the evaluation results, a target evaluation result that meets the target-reaching condition is selected, and the candidate prompt content corresponding to the target evaluation result is determined as the target prompt content.
[0036] Optionally, when constructing a training sample set based on each sample prompt text and the corresponding sample label, the construction unit is used to:
[0037] For each sample prompt text, the following operations are performed respectively: a sample label corresponding to a sample prompt text is determined, and each synonymous label containing the sample label is obtained according to a preset label synonym relationship, and each synonymous label is combined with the sample prompt text to obtain each training sample; the label synonym relationship is used to indicate other labels with the same semantics as a label;
[0038] The obtained training samples are combined to obtain a training sample set.
[0039] Optionally, when obtaining the evaluation result of the first language model under the target business based on each predicted tag and the corresponding content tag, the generating unit is used to:
[0040] Based on each predicted label and the corresponding content label, the accuracy rate corresponding to the first language model is calculated, and the recall rate of the first language model under various content labels of the target business is calculated; the average recall rate determined based on each recall rate and the accuracy rate are determined as the evaluation result of the first language model under the target business.
[0041] Optionally, after constructing the training sample set, the apparatus further includes a training unit, wherein the training unit is used to:
[0042] Obtain training sample sets constructed respectively for each target business;
[0043] Adding the initial prefix network of the corresponding prefix tuning structure to the second language model to obtain an initial label recognition model; the parameter magnitude of the first language model is much higher than that of the second language model;
[0044] Using each training sample set, the initial prefix network in the initial label recognition model is trained for multiple rounds of iterations to obtain a target label recognition model consisting of a trained target prefix network and the second language model.
[0045] Optionally, after obtaining the target label recognition model composed of the trained target prefix network and the second language model, the device further includes an execution unit, wherein the execution unit is used to:
[0046] Obtain the review texts to be processed collected from each target business;
[0047] For each comment text to be processed, the following operations are performed respectively: after adjusting the matching target prompt content according to the label range corresponding to the target business to which it belongs, a text to be processed is combined with the adjusted target prompt content to generate a corresponding prompt text to be processed, and the target label recognition model is used to output the corresponding content label for the prompt text to be processed.
[0048] Optionally, after outputting the corresponding content label for each comment text to be processed, the execution unit is further configured to:
[0049] Clustering the to-be-processed comment texts according to the commented objects, and obtaining the to-be-processed comment sets corresponding to the commented objects;
[0050] For each set of pending comments, the following operations are performed respectively: according to the content labels corresponding to each pending comment text in a set of pending comments, different pending comment texts corresponding to the same content label are clustered to obtain the pending comment groups corresponding to each content label and the statistical results of the number of comments.
[0051] Optionally, after outputting the corresponding content label for each comment text to be processed, the execution unit is further configured to:
[0052] Clustering the review texts to be processed according to the targeted content tags to obtain the review sets of the same type corresponding to the content tags;
[0053] Among the content tags, target content tags expressing negative emotions are analyzed and determined, and improvement prompt information for the corresponding target business is generated based on a set of similar comments corresponding to the target content tags.
[0054] In a third aspect, an electronic device is proposed, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above method when executing the computer program.
[0055] In a fourth aspect, a computer-readable storage medium is proposed, on which a computer program is stored, and the computer program implements the above method when executed by a processor.
[0056] In a fifth aspect, a computer program product is proposed, comprising a computer program, wherein the computer program implements the above method when executed by a processor.
[0057] The beneficial effects of this application are as follows:
[0058] In the embodiment of the present application, a method, device, electronic device and storage medium for generating training samples are proposed, and the following steps are disclosed: obtaining reference comment texts annotated with content labels and obtaining unannotated candidate comment texts for a target business; then combining the reference comment texts with basic prompt contents determined for the target business to generate corresponding basic prompt texts, and calling a first language model to output prediction labels corresponding to the basic prompt texts, and obtaining evaluation results of the first language model under the target business based on the prediction labels and the corresponding content labels; this enables the evaluation results to be used to evaluate the comment reasoning effect of the first language model on the target business under the guidance of the basic prompt contents, thereby evaluating the availability and adaptability of the basic prompt contents to the target business;
[0059] Furthermore, when it is determined that the basic prompt content cannot play a guiding role in meeting the needs in the comment reasoning process of the first language model for the target business, the basic prompt content can be adjusted by adding logical guiding text to the basic prompt content to obtain various candidate prompt contents; and then, by selecting the target prompt content that makes the evaluation result of the first language model meet the standard condition from among the various candidate prompt contents, the target prompt content that meets the processing needs of the first language model under the target business can be screened out, so that the obtained target prompt content is adapted to the processing of the first language model under the target business;
[0060] Afterwards, each candidate comment text is combined with the target prompt content to generate a corresponding sample prompt text, and the first language model is called to output the sample label corresponding to each sample prompt text, and a training sample set is constructed based on the sample prompt text and the corresponding sample label; this enables the candidate comment text to be processed to be sorted according to the effective target prompt content when performing label recognition according to the first language model, thereby improving the accuracy of the model recognition result and providing a great guarantee for the label recognition effect of the first language model, thereby enabling the rapid construction of training samples on the one hand and ensuring the generation quality of training samples on the other hand. BRIEF DESCRIPTION OF THE DRAWINGS
[0061] Figure 1A schematic diagram of possible application scenarios in the embodiments of the present application;
[0062] Figure 2 A schematic diagram of a process of constructing a training sample in an embodiment of the present application;
[0063] Figure 3 A schematic diagram of the synonymous relationship between the keywords and the corresponding words constructed in the embodiments of the present application;
[0064] Figure 4 A schematic diagram of a process for constructing each extended comment text corresponding to an initial comment text in an embodiment of the present application;
[0065] Figure 5 A schematic diagram of the process of screening and determining the extended comment text in an embodiment of the present application;
[0066] Figure 6 This is a schematic diagram of the analysis of basic prompt content in an embodiment of the present application;
[0067] Figure 7 A schematic diagram of the process of generating basic prompt text in an embodiment of the present application;
[0068] Figure 8 This is another schematic diagram of a process for constructing training samples in an embodiment of the present application;
[0069] Fig. 9 This is a schematic diagram of the structure of the initial tag recognition model in the embodiment of the present application;
[0070] Fig.10 A schematic diagram of the process of sorting out each group of comments to be processed in the embodiment of the present application;
[0071] Fig.11 A schematic diagram of the process of arranging and obtaining similar review sets in the embodiment of the present application;
[0072] Fig.12 This is a schematic diagram of the knowledge extraction process in the embodiment of this application;
[0073] Fig.13 A schematic diagram of the logical structure of a training sample construction device in an embodiment of the present application;
[0074] Fig.14 A schematic diagram of the hardware structure of an electronic device to which the present invention is applied;
[0075] Fig.15 The present invention is a schematic diagram of the hardware structure of another electronic device to which the embodiments of the present application are applied. DETAILED DESCRIPTION
[0076] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the technical solution of the present application, rather than all of the embodiments. Based on the embodiments recorded in the application documents, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the technical solution of the present application.
[0077] The terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the terms used in this way can be interchanged where appropriate, so that the embodiments of the invention described herein can be implemented in sequences other than those illustrated or described herein.
[0078] In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program that has a predetermined function and works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories), or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be part of an overall module or unit that includes the function of the module or unit.
[0079] Some of the terms used in the embodiments of the present application are explained below to facilitate understanding by those skilled in the art.
[0080] Generative Pre-trained Transformer (GPT): is a large language model that is based on advanced natural language processing technology and is trained with a large amount of text data, thus having powerful language understanding and generation capabilities. For example, the GPT4 model in the GPT series can understand and respond to various types of text inputs, providing users with an intelligent and smooth conversation experience.
[0081] ChatGLM: refers to a natural language processing technology that is optimized for Chinese question-answering and dialogue, and is obtained after bilingual training in Chinese and English with about 1T identifiers, and supplemented by technologies such as supervised fine-tuning, feedback self-help, and human feedback reinforcement learning. At present, the 6 billion parameter ChatGLM-6B can already generate answers that are quite in line with human preferences. In the embodiment of this application, with the help of model quantization technology, it can be locally deployed on consumer-grade graphics cards (at the INT4 quantization level, only 6GB of video memory is required).
[0082] The following is a brief introduction to the design concept of the embodiment of the present application:
[0083] Under the existing technology, the corresponding content tags are usually identified and determined based on the object review text of the relevant object in the specified business scenario, so that the usage experience of the relevant object in the specified business scenario can be analyzed based on the obtained content tags.
[0084] Currently, when obtaining content tags for obtained object comment texts, the applicant has conceived that matching can be performed based on predefined rules (such as keyword matching), so that the matching content tags can be determined by matching the rules hit by the object comment texts.
[0085] However, although the rule-based matching scheme is relatively simple to implement, it lacks flexibility. The label recognition effect depends on the comprehensiveness of the customized rules, so it is difficult to process complex texts. Moreover, in order to obtain a good matching effect, the rules need to be adjusted frequently, which requires extremely high maintenance costs. In addition, the rule-based matching method can only handle known situations, which makes the scalability of label recognition very poor.
[0086] Furthermore, the applicant conceived that a text matching method based on machine learning could be used for processing, which is specifically reflected in the task definition as: multi-label classification with a fixed number of labels. In this classification method, a set of labels must first be defined, and then the comment texts are annotated manually to create an annotated data set. Next, a classification algorithm (such as logistic regression, support vector machine, random forest, neural network bert, etc.) is used to train the model to achieve automatic label matching in the comment text.
[0087] However, this approach requires manual annotation of datasets, which takes a lot of time and human resources and may have subjectivity and consistency issues.
[0088] In view of this, in the technical solution for which protection is sought in the present application, a method, device, electronic device and storage medium for generating training samples are proposed, and the method discloses obtaining reference comment texts annotated with content labels and obtaining unannotated candidate comment texts for a target business; then combining the reference comment texts with basic prompt contents determined for the target business to generate corresponding basic prompt texts, and calling a first language model to output prediction labels corresponding to the basic prompt texts, and obtaining evaluation results of the first language model under the target business based on the prediction labels and the corresponding content labels; this enables the evaluation results to be used to evaluate the comment reasoning effect of the first language model on the target business under the guidance of the basic prompt contents, thereby evaluating the availability and adaptability of the basic prompt contents to the target business;
[0089] Furthermore, when it is determined that the basic prompt content cannot play a guiding role in meeting the needs in the comment reasoning process of the first language model for the target business, the basic prompt content can be adjusted by adding logical guiding text to the basic prompt content to obtain various candidate prompt contents; and then, by selecting the target prompt content that makes the evaluation result of the first language model meet the standard condition from among the various candidate prompt contents, the target prompt content that meets the processing needs of the first language model under the target business can be screened out, so that the obtained target prompt content is adapted to the processing of the first language model under the target business;
[0090] Afterwards, each candidate comment text is combined with the target prompt content to generate a corresponding sample prompt text, and the first language model is called to output the sample label corresponding to each sample prompt text, and a training sample set is constructed based on the sample prompt text and the corresponding sample label; this enables the candidate comment text to be processed to be sorted according to the effective target prompt content when performing label recognition according to the first language model, thereby improving the accuracy of the model recognition result and providing a great guarantee for the label recognition effect of the first language model, thereby enabling the rapid construction of training samples on the one hand and ensuring the generation quality of training samples on the other hand.
[0091] The preferred embodiments of the present application are described below in conjunction with the drawings in the specification. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present application, and are not used to limit the present application. In addition, the embodiments of the present application and the features in the embodiments may be combined with each other if there is no conflict.
[0092] See also Figure 1 As shown, it is a schematic diagram of a possible application scenario in an embodiment of the present application. The schematic diagram of the application scenario includes a client device 110 and a processing device 120.
[0093] In some feasible embodiments of the present application, in order to realize label recognition for comment text, the processing device 120 needs to construct a training sample set that meets the recognition requirements of the comment text, and then train a target label recognition model that can realize comment text reasoning based on the training sample set, and then perform label recognition for the comment text based on the target label recognition model.
[0094] In other feasible embodiments of the present application, the processing device 120 can obtain the comment text posted by the relevant object on the client device 110 for the specified business or product category, and analyze the comment text to determine the relevant object's usage experience for the specified business or product category, wherein the comment operation triggered by the relevant object can be initiated on any of the mini-program applications, client applications, and web applications, and the present application does not impose any specific restrictions on this.
[0095] In some other feasible embodiments of the present application, the processing device 120 can analyze the review texts posted by each object, determine the usage experience of each object in various businesses or various product categories, and generate improvement prompt information for various businesses or various product categories based on the obtained analysis results.
[0096] The client device 110 includes but is not limited to mobile phones, tablet computers, notebooks, e-book readers, intelligent voice interaction devices, smart home appliances, vehicle-mounted terminals, aircraft, etc.
[0097] The processing device 120 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers. It can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), as well as big data and artificial intelligence platforms.
[0098] In the embodiment of the present application, the client device 110 and the processing device 120 may communicate via a wired network or a wireless network. The following description only describes the construction of training samples and related processing processes from the perspective of the processing device 120.
[0099] The following is a schematic description of the scenarios involving the construction of training samples in combination with possible application scenarios:
[0100] Application scenario 1: Analyze the user experience of each product category.
[0101] In the application scenario indicated by application scenario one, for each product category, the following operations are performed respectively: first, a target prompt text that can obtain a processing effect that meets the standard conditions under the product category by the first language model is selected; then, based on the target prompt text and each candidate review text for the product category, each sample prompt text is integrated to obtain each sample prompt text; and then, based on the first language model and each sample prompt text, corresponding sample labels are output respectively; then, based on each sample prompt text and the corresponding sample label, a training sample set is constructed.
[0102] Furthermore, based on the training sample sets constructed for various categories, the second language model with the initial prefix network added is subjected to multiple rounds of fine-tuning iterative training, and a target label recognition model is constructed based on the trained target prefix network and the untrained second language model; furthermore, based on the target label recognition model, the pending review texts published for various product categories can be analyzed.
[0103] Application scenario 2: Analyze the user experience of each application.
[0104] In the application scenario indicated by application scenario two, for each business application, the following operations are performed respectively: first, a target prompt text that can obtain a processing effect that meets the standard conditions under the business application by the first language model is selected, and then sample prompt texts are obtained by integrating the target prompt text and the candidate comment texts of the business application, and then, based on the first language model and each sample prompt text, corresponding sample labels are output respectively; then, a training sample set is constructed based on each sample prompt text and the corresponding sample label.
[0105] Furthermore, based on the training sample sets constructed for each business application, the second language model with the initial prefix network added is subjected to multiple rounds of fine-tuning iterative training, and a target label recognition model is constructed based on the trained target prefix network and the untrained second language model; furthermore, based on the target label recognition model, the pending comment texts published for each business application can be analyzed.
[0106] Application scenario three: Analyze the comment text associated with multimedia data.
[0107] In the application scenario indicated by application scenario three, the multimedia data may be specifically constructed in the form of any one or a combination of audio, video, and text.
[0108] For example, the targeted multimedia data may be any of the following: news content, songs, cartoons, and various types of videos (such as public videos, documentaries, movies, and TV series posted on self-media).
[0109] In some feasible implementations, the training sample construction method requested for protection in the present application can be first adopted to construct a training sample set for each target object, and then a target label recognition model is trained based on each training sample set. Then, based on the target label recognition model, the pending comment texts published for each target object are analyzed; wherein, the training sample set corresponding to each target object is constructed based on the comment texts published for each multimedia data after determining the multimedia data associated with the target object; when the multimedia data contains content related to the target object, it can be determined that the multimedia data is associated with the target object.
[0110] For example, each target object may be a virtual object, such as a game; or each target object may be a physical object, such as a car.
[0111] In some other feasible implementations, the training sample construction method requested for protection in this application can be adopted to construct a training sample set for each target multimedia data, and then train a target label recognition model based on each training sample set. Then, based on the target label recognition model, the newly released comment texts to be processed for each target multimedia data are analyzed.
[0112] For example, each target multimedia data may be a piece of music, or each target multimedia data may be a TV series, etc.
[0113] In addition, it should be understood that in the specific implementation of this application, it involves the construction of training samples and related processing processes. When the embodiments recorded in this application are applied to specific products or technologies, the collection, use and processing of relevant data need to comply with the relevant laws, regulations and standards of relevant countries and regions.
[0114] The following is an explanation of the construction process of training samples from the perspective of processing equipment in conjunction with the accompanying drawings:
[0115] See also Figure 2 As shown, it is a schematic diagram of a process of constructing a training sample in an embodiment of the present application. Figure 2 , the construction process of training samples is explained:
[0116] Step 201: The processing device obtains reference review texts marked with content tags and obtains unmarked candidate review texts for a target business.
[0117] Specifically, in the process of constructing a training sample set for the target business, the processing device needs to first obtain, for the target business, each reference comment text used as a basis for selecting appropriate prompt content, and each candidate comment text used as a basis for generating a training sample set, wherein each reference comment text obtained is respectively annotated with a corresponding content label; each candidate comment text obtained is not annotated; and the number of candidate comment texts is much larger than the number of reference comment texts.
[0118] It should be noted that in an embodiment of the present application, the processing device can select a specified number of historical comment texts from the historical comment texts collected for the target business as reference comment texts, and respectively obtain the content labels annotated for each reference comment text, wherein the annotated content labels may be temporarily annotated by the relevant annotated objects, or may be pre-annotated before being collected, and the present application does not impose any specific restrictions on this.
[0119] The sources of historical comment texts include, but are not limited to, collected online business data and open source data sets. According to actual processing needs, a specified number of reference comment texts may be randomly selected from the collected online business data and open source data sets.
[0120] In the embodiment of the present application, in some feasible processes of obtaining unlabeled candidate comment texts, the processing device may directly obtain the unlabeled candidate comment texts from the historical comment texts.
[0121] In other feasible processes of obtaining unlabeled candidate review texts, unlabeled initial review texts may be first obtained from historical review texts, and then synonymous text expansion may be performed on the initial review texts to obtain candidate review texts.
[0122] Specifically, the processing device obtains each unlabeled initial comment text, and obtains each keyword and the associated word synonym relationship; the word synonym relationship associated with a keyword is used to indicate a synonym corresponding to a keyword; then, the initial comment text containing the keyword is adjusted respectively by replacing the corresponding keyword with the synonym, and each processed extended comment text is obtained; then, each initial comment text and each extended comment text are determined as candidate comment texts.
[0123] In an embodiment of the present application, when the processing device obtains unlabeled initial comment texts, in some feasible implementation methods, it can determine, among the collected historical comment texts, the other historical comment texts except the reference comment texts as the initial comment texts. At this time, if some of the selected other historical comment texts are pre-labeled with content tags, the labeled content tags can be deleted to obtain the unlabeled initial comment texts; or, in other feasible implementation methods, among the collected historical comment texts, the unlabeled historical comment texts except the ones selected as the reference comment texts can be determined as the initial comment texts.
[0124] It should be noted that the preset keywords are used to match the content that can be replaced and adjusted in the initial comment text; each keyword has an associated word synonym relationship; a word synonym relationship associated with a keyword is used to indicate a synonym associated with a keyword; each keyword has at least one associated synonym; for a keyword, according to actual processing needs, its associated synonyms may exist in the preset keywords, or, its associated synonyms may partially exist in the preset keywords, or, its associated synonyms may not exist in the preset keywords, and this application does not make any specific restrictions on this.
[0125] In an embodiment of the present application, the initial comment texts containing keywords are adjusted respectively by replacing corresponding keywords with synonyms to obtain processed extended comment texts. For each initial comment text, the processing device, when detecting that a target keyword is hit among each keyword, replaces the corresponding target keyword with a synonymous keyword that is synonymous with the target keyword to obtain the adjusted extended comment text.
[0126] Specifically, the processing device can perform the following operations for each initial comment text: perform hit detection in an initial comment text based on each keyword; then, when determining the hit target keyword based on the detection result, obtain the corresponding synonymous keywords based on the synonymous relationship associated with the target keyword, and replace the target keyword in an initial comment text with each synonymous keyword to obtain each extended comment text.
[0127] It should be noted that in the embodiment of the present application, when multiple target keywords are hit in an initial comment text, the processing device can replace each target keyword with a synonymous keyword. Moreover, in the process of performing hit detection for each keyword, various feasible detection methods can be used for processing, including but not limited to accurate detection with the help of regular expressions.
[0128] For example, see Figure 3 As shown, it is a schematic diagram of the synonymous relationship between each keyword and the corresponding word constructed in the embodiment of the present application. Figure 3 As can be seen from the illustrated content, a corresponding synonymous relationship is configured for each constructed keyword, and the synonymous relationship of the associated words can be used to determine the synonym corresponding to a keyword.
[0129] For example, see Figure 4 As shown, it is a schematic diagram of the process of constructing each extended comment text corresponding to an initial comment text in the embodiment of the present application. Figure 4 As can be seen from the illustrated content, when the processing device processes an initial review text: initial review text Z, after determining that the initial review text Z contains the target keywords: fine workmanship and good quality and low price, three synonymous keywords corresponding to "fine workmanship" and one synonymous keyword corresponding to "good quality and low price" can be determined based on the keywords. After that, by replacing the corresponding target keywords in the initial review text Z with synonymous keywords, the following can be obtained: Figure 4 The 7 extended comment texts are shown.
[0130] In this way, by replacing the target keywords hit in the initial comment text with the corresponding synonymous keywords, the corresponding extended comment text is obtained, so that the number of comment texts serving as candidate comment texts can be increased; moreover, by replacing synonymous keywords, it is equivalent to realizing vocabulary and expression variants, which helps to enrich the diversity of textual expressions, so that when the model is subsequently trained based on the training samples generated by each candidate comment text, it helps the model to better understand the diversity of language and can improve the generalization ability of the model.
[0131] Optionally, in an embodiment of the present application, in order to avoid excessive semantic differences between a determined extended comment text and a corresponding initial comment text, the processing device may first replace the target keywords in an initial comment text with each synonymous keyword to obtain each pending comment text in the process of replacing each extended comment text with a target keyword in an initial comment text; then calculate the text similarity between each pending comment text and an initial comment text, and determine the pending comment text whose text similarity meets the screening conditions as the extended comment text.
[0132] It should be noted that when calculating the text similarity between the pending comment text and the initial comment text, you can first use an open source text vector model to extract text features for the pending comment text and the initial comment text respectively; then, calculate the similarity between the text features to obtain the text similarity, where the method of calculating text similarity includes but is not limited to any one of the following: calculating cosine similarity; calculating Euclidean distance; calculating Manhattan distance, etc.
[0133] For example, see Figure 5 As shown, it is a schematic diagram of the process of screening and determining the extended comment text in the embodiment of the present application. Figure 5 It can be seen from the illustrated content that after the processing device determines each pending comment text for an initial comment text, it calculates the text similarity between an initial comment text and each pending comment text respectively; then, assuming that the preset screening condition is: the text similarity is greater than the set threshold H, then the calculated text similarities a1-a7 can be compared with the set threshold H respectively, so as to determine each extended comment text in each pending comment text.
[0134] In this way, by calculating the text similarity between each pending comment text obtained after synonym replacement and the corresponding initial comment text, each pending comment text can be screened so that the determined extended comment text and the initial comment text meet the text similarity screening condition, thereby ensuring the semantic consistency between the extended comment text and the corresponding initial comment text.
[0135] Step 202: The processing device combines each reference comment text with the basic prompt content determined for the target business, generates a corresponding basic prompt text, and calls the first language model to output the prediction label corresponding to each basic prompt text, and obtains the evaluation result of the first language model under the target business based on each prediction label and the corresponding content label.
[0136] After the processing device obtains each reference comment text, in order to organize each reference comment text into a content form that meets the input requirements of the large prediction model, each reference comment text is combined with the basic prompt content preset for the target business to generate a corresponding basic prompt text.
[0137] The basic prompt content includes: the tag range determined for the target business, the indication information for indicating the filling position of the comment text, the description information of the implemented analysis task, and the description information of the output form. Optionally, according to the actual processing needs, the basic prompt content may also include: example information of the output form.
[0138] In addition, optionally, for the basic prompt content determined for the target business, the basic prompt content can be directly configured; or, the basic prompt content can be sorted out based on the initial prompt content. Specifically, when the initial prompt content is sorted out, the preset initial prompt content can be obtained first, and then the initial prompt content can be adjusted in combination with the processing needs of the target business to obtain the basic prompt content determined for the target business. Among them, for different businesses belonging to the same scenario, the corresponding basic prompt content can be constructed based on the same initial prompt content.
[0139] For example, see Figure 6 As shown, it is a schematic diagram of the analysis of the basic prompt content in the embodiment of the present application. Figure 6 As shown in the content, assuming that the target business specifically refers to the purchase of the product category "bowl", then in the process of determining the basic prompt content for the target business, after obtaining the constructed initial prompt content, the number of tags, tag range, and category information determined for the target business can be filled in the initial prompt content according to the processing needs of the target business to obtain the basic prompt content determined for the product category "bowl". Among them, for the purchase business of different categories of goods belonging to the product purchase scenario, the corresponding basic prompt content can be constructed based on the same initial prompt content.
[0140] For example, see Figure 7 As shown, it is a schematic diagram of the process of generating basic prompt text in the embodiment of the present application, according to Figure 7As shown in the content, for a reference comment text related to the target business, the reference comment text is filled into the basic prompt content of the target business, and the result can be obtained. Figure 7 The basic hint text indicated.
[0141] Furthermore, after generating corresponding basic prompt texts for each reference comment text, the processing device calls the first language model to output prediction labels corresponding to each basic prompt text, wherein the first language model may specifically be a model of the GTP series, such as GTP-4, or may be a large language model such as Baichuan 13B that can implement natural language processing, and the present application does not impose any specific restrictions on this.
[0142] Afterwards, the processing device obtains an evaluation result of the first language model under the target business based on the content label of each reference comment text and the predicted label determined for each reference comment text, wherein the evaluation result is used to evaluate the label matching effect of the first language model under the target business under the guidance of the current basic prompt content; in other words, the evaluation result is used to evaluate the current basic prompt content and its promoting effect on the label matching process of the first language model under the target business.
[0143] It should be noted that in the embodiment of the present application, when determining the evaluation result, the processing device can calculate the accuracy corresponding to the first language model based on each prediction label and the corresponding content label, and calculate the recall rate of the first language model under various content labels of the target business; then determine the average recall rate determined based on each recall rate, and the accuracy rate as the evaluation result of the first language model under the target business.
[0144] When calculating the accuracy, the following formula is used:
[0145]
[0146] Among them, accuracy represents the accuracy rate; s1 represents the total number of accurately predicted prediction labels; s2 represents the total number of inaccurately predicted prediction labels; s1+s2 represents the total number of predicted labels.
[0147] Taking the calculation of the recall rate under a type of content label (assuming it is content label p) as an example, the following formula is used for calculation:
[0148]
[0149] Among them, n11 represents the total number of accurately predicted labels for each reference comment text belonging to content label p; n12 represents the total number of inaccurately predicted labels for each reference comment text belonging to content label p; n11+n12 represents the total number of predicted labels belonging to content label p.
[0150] Furthermore, after calculating the corresponding recall rates for each type of content tag under the target business, the corresponding recall rate mean is calculated based on each recall rate, and the calculated recall rate mean and accuracy are determined as the evaluation result of the first language model under the target business.
[0151] In this way, the accuracy rate can reflect the reasoning accuracy of the first language model, and the recall rate can reflect the completeness of the first language model. Therefore, the average of the accuracy rate and the recall rate can comprehensively reflect the prediction effect of the first language model on various content labels under the target business under the guidance of the basic prompt text, thereby realizing the effectiveness evaluation of the basic prompt content.
[0152] Step 203: When the evaluation result does not meet the compliance condition, the processing device adds each preset logical guidance text to the basic prompt content, generates corresponding candidate prompt content, and selects the target prompt content that makes the evaluation result of the first language model meet the compliance condition from each candidate prompt content.
[0153] After the processing device obtains the evaluation results, it determines whether the preset compliance conditions are met based on the evaluation results. When the evaluation results include the average of the accuracy and the recall rate, the compliance conditions can specifically be: the accuracy reaches the preset accuracy threshold, and the average of the recall rate reaches the preset recall threshold; the values of the accuracy threshold and the recall threshold are set according to actual processing needs, and this application does not impose any specific restrictions on this.
[0154] Furthermore, when it is determined that the evaluation result meets the standard conditions, each candidate comment text can be directly combined with the basic prompt content to generate a corresponding sample prompt text.
[0155] Also, when it is determined that the evaluation result does not meet the standard conditions, it means that the basic prompt text generated with the help of the currently selected basic prompt content is not sufficient to guide the first language model to perform accurate label inference on the comment text under the target business. In this case, the processing device adds each preset logical guidance text to the basic prompt content, generates corresponding candidate prompt content, and then selects the target prompt content from each candidate prompt content that makes the evaluation result of the first language model meet the standard conditions.
[0156] It should be noted that, in the embodiment of the present application, the logic guidance text refers to the text content used for logical guidance, and each logic guidance text includes different logic guidance contents; in the process of selecting the target prompt content, after each logic guidance text is added to the basic prompt content respectively, each candidate prompt content can be obtained, and then the candidate prompt text generated according to each candidate prompt content is detected respectively, for the guidance effect of the first language model, so that the appropriate target prompt content can be selected from each candidate prompt content, wherein the method of adding the logic guidance text to the basic prompt content can be to directly splice the logic guidance text into the basic prompt content.
[0157] In addition, the constructed logical guidance text can be the text content of the Chain of Thought (CoT), so that the way of guiding the model processing with the help of the reconstructed candidate prompt content can be understood as a way to guide the model to show its step-by-step reasoning process. With the help of logical guidance text, the model can be required to explicitly output the reasoning of the intermediate steps before giving the final answer to enhance the reasoning ability of the model. According to the actual processing needs, the search collection and manual construction method can be used to construct 20 COT prompts (i.e. logical guidance texts) and summarize them into a COTPrompt library (i.e. logical guidance text library).
[0158] For example, a constructed logic guide text could be: "First, identify whether the main sentiment expressed in the review is positive or negative. Then, based on the sentiment analysis, list at least two labels that may match it and explain the reasons for your choice.".
[0159] For example, a logical guidance text can be: "Please describe the specific characteristics of the product or service mentioned in the review, such as quality, price or user experience. Then, compare these characteristics with the preset tags, find the best matching one or more tags, and explain your matching logic."
[0160] Specifically, in the process of selecting the target prompt content, the processing device performs the following operations for each candidate prompt content: each reference comment text is combined with a candidate content to generate a corresponding candidate prompt text, and the first language model is called to output the prediction label corresponding to each candidate prompt text, and based on each prediction label and the corresponding content label, an evaluation result of the first language model under the target business is obtained; then, among each evaluation result, a target evaluation result that meets the compliance conditions is selected, and the candidate prompt content corresponding to the target evaluation result is determined as the target prompt content.
[0161] Among them, the method of calculating the evaluation result is the same as the calculation method proposed in step 202; when the evaluation result includes the average of the accuracy rate and the recall rate, when selecting the target evaluation result that meets the standard conditions, the candidate evaluation result whose accuracy rate exceeds the preset accuracy threshold and the average of the recall rate exceeds the preset recall threshold can be determined as the target evaluation result.
[0162] In addition, considering that there may be many evaluation results that simultaneously meet the requirements of accuracy exceeding the preset accuracy threshold and the average recall rate exceeding the preset recall rate threshold; based on this, when finally determining a target evaluation result, you can arbitrarily select one of the multiple evaluation results that meet the standard conditions as the target evaluation result; or, you can select an evaluation result with the highest accuracy from the multiple evaluation results that meet the standard conditions as the target evaluation result; or, you can select an evaluation result with the highest average recall rate from the multiple evaluation results that meet the standard conditions as the target evaluation result.
[0163] In this way, by obtaining evaluation results for each candidate prompt content that are used to characterize the reasoning effect of the first language model under the target business, the candidate prompt content can be screened, thereby obtaining target prompt content that can guide the first language model to effectively complete label recognition reasoning under the target business, so that the determined target prompt content is adapted to the label matching of the first language model under the target business, thereby improving the reasoning effect of the first language model.
[0164] Step 204: The processing device combines each candidate comment text with the target prompt content to generate a corresponding sample prompt text, and calls the first language model to output a sample label corresponding to each sample prompt text, and constructs a training sample set based on each sample prompt text and the corresponding sample label.
[0165] After the processing device determines the target prompt content, it combines each candidate comment text with the target prompt content to generate a corresponding sample prompt text, wherein the method of combining the candidate comment text with the target prompt content is the same as the combination method involved in step 202, and specifically, the candidate comment text can be filled into the designated area in the target prompt content, which is not elaborated in this application.
[0166] Furthermore, after each sample prompt text is generated corresponding to each candidate comment text, the first language model is called to output a corresponding sample label for each sample prompt text; and then a training sample set is constructed based on each sample prompt text and the corresponding sample label.
[0167] In some feasible embodiments of the present application, training samples may be constructed directly based on each sample prompt text and the corresponding sample label.
[0168] It should be understood that in the embodiments of the present application, different contents are used to construct the training sample set in combination with different model training needs. When constructing the training sample set of the sample classification model, a training sample is constructed based on the candidate comment text included in each sample prompt text and the corresponding sample label; when constructing the training sample set of the language model, a corresponding training sample is constructed based on each sample prompt text and the corresponding sample label.
[0169] In some other feasible embodiments of the present application, the processing device can expand to obtain more training samples based on each sample prompt text and the corresponding sample label, so as to construct a training sample set.
[0170] Specifically, the processing device can perform the following operations for each sample prompt text: determine a sample label corresponding to a sample prompt text, obtain synonymous labels containing the sample label according to a preset label synonym relationship, and combine each synonymous label with a sample prompt text to obtain each training sample; the label synonym relationship is used to indicate other labels with the same semantics as a label. Afterwards, the obtained training samples are combined to obtain a training sample set.
[0171] It should be noted that in the training scenario of a large language model, after the sample labels are expanded with synonymous labels, the corresponding content in the sample prompt text needs to be adjusted for each synonymous label determined by the expansion; in the training scenario of a classification model, the sample label range can be selected based on the actual classification needs and the label synonym relationship.
[0172] For example, when the first language model is used for processing, it is assumed that the preset content labels for the target business are A1, B1, and C1, and according to the preset label synonym relationship, A2 can be determined to be synonymous with A1, B2 and B3 can be determined to be synonymous with B1, and C2 can be determined to be synonymous with C1. Then, based on the specific classification needs, the content labels based on which the labels are matched can be selected, and the training samples matching the content labels can be obtained respectively to construct the training sample set.
[0173] Moreover, it should be understood that there may be labels expressing similar content under different businesses. The reason for expanding the determination of synonymous labels in this application is to avoid the limitations caused by the fact that the comment text under a specified business is only matched with the labels under the specified business in actual matching tasks, avoid limiting the learning ability of the model, and help improve the generalization of the model.
[0174] For example, if a sample review text matches a sample label (such as "high cost performance"), then based on the label synonymy relationship, synonyms or near-synonyms of the label (such as "high quality and low price", "extremely high cost performance", etc.) can be found; then, these synonymous labels are also matched with the same sample review text, and the content corresponding to the label range in the sample review text is adaptively adjusted to obtain new training samples.
[0175] In this way, by introducing synonymous labels, the training data can be enriched, thereby improving the model's ability to understand and generalize different expressions, so that the original matching relationship between a single sample comment text and a sample label is changed to a matching relationship between a sample comment text and multiple synonymous labels, thereby improving the diversity of the data.
[0176] In the embodiment of the present application, the processing device may also use other processing processes to complete the processing during the process of constructing the training samples.
[0177] See also Figure 8 As shown, it is a schematic diagram of another process of constructing training samples in the embodiment of the present application. Figure 8 , explain the relevant construction process:
[0178] Step 801: The processing device obtains reference review texts marked with content tags for a target business.
[0179] In the embodiment of the present application, the processing device may adopt the same processing method as step 201 to obtain reference review texts marked with content tags for the target business, which will not be elaborated in this application.
[0180] Step 802: The processing device obtains each unlabeled original comment text, and clusters the original comment texts that meet similarity conditions according to the similarity between each two original comment texts to obtain each original comment text group, and randomly selects an original comment text from each original comment text group as a candidate comment text.
[0181] In an embodiment of the present application, in the process of the processing device obtaining each candidate comment text, the processing device first obtains each unlabeled original comment text, wherein each original comment text may be other historical comment texts among the collected historical comment texts except those selected as reference comment texts. At this time, if some other historical comment texts selected as original comment texts are pre-labeled with content tags, the labeled content tags can be deleted; or, each original comment text may be unlabeled comment texts among the collected historical comment texts except those selected as reference comment texts; or, each initial comment text and each extended comment text obtained by the processing method of step 201 may be used as each original comment text.
[0182] Furthermore, the original comment texts are clustered so that the original comment texts that meet the similarity conditions are divided into an original comment text group, and then one original comment text is selected from each group of original comment texts as a candidate comment text, wherein the similarity condition may specifically be that the text similarity reaches a preset similarity threshold; the value of the similarity threshold is set according to actual processing needs, such as being set to 0.95.
[0183] In this way, by clustering the original comment texts and selecting candidate comment texts from the obtained original comment text groups, the total number of candidate comment texts to be processed can be reduced, thereby reducing the number of subsequent calls to the first language model.
[0184] Step 803: The processing device combines each reference comment text with the basic prompt content determined for the target business, generates a corresponding basic prompt text, and calls the first language model to output the prediction label corresponding to each basic prompt text, and obtains the evaluation result of the first language model under the target business based on each prediction label and the corresponding content label.
[0185] Specifically, the processing of step 803 is the same as the processing method involved in step 202, and this application will not elaborate on it here.
[0186] Step 804: When the evaluation result does not meet the compliance condition, the processing device adds the preset logical guidance texts to the basic prompt content, generates corresponding candidate prompt content, and selects the target prompt content that makes the evaluation result of the first language model meet the compliance condition from among the candidate prompt contents.
[0187] Specifically, the processing process involved in step 804 is the same as the processing process described in step 203, and this application will not provide an expanded description here.
[0188] Step 805: The processing device combines each candidate comment text with the target prompt content to generate a corresponding sample prompt text, and calls the first language model to output a sample label corresponding to each sample prompt text.
[0189] Specifically, the processing involved in step 805 is the same as the process of outputting sample labels described in step 204, so this application will not provide an expanded description here.
[0190] Step 806: The processing device performs the following operations for each candidate comment text: When it is determined that there are other original comment texts except the candidate comment text in the original comment text group to which it belongs, each other original comment text is combined with the target prompt content to generate a corresponding sample prompt text, and the sample label determined for each candidate comment text is used as the sample label of each sample prompt text generated for the corresponding original comment text group.
[0191] Specifically, in an embodiment of the present application, when a candidate comment text is extracted from a corresponding original comment text group, a sample label corresponding to a candidate comment text can be regarded as a sample label corresponding to each original comment text in the original comment text group corresponding to the candidate comment text.
[0192] Based on this, taking the processing based on a candidate comment text (assuming it is candidate comment text 1) as an example, after the processing device determines the original comment text group (assuming it is original comment text group Z) to which the candidate comment text 1 belongs, when it is determined that the original comment text group includes other original comment texts except the candidate comment text 1, the other original comment texts are respectively combined with the selected target prompt content to generate corresponding sample prompt texts; then, the sample label corresponding to the candidate comment text 1 is used as the sample label of each sample prompt text generated for the corresponding original comment text group Z.
[0193] In this way, by means of the original comment text group obtained by pre-clustering and the attribution relationship between the candidate comment text and the original comment text group, the annotation efficiency can be significantly improved and the annotation cost can be greatly reduced.
[0194] Step 807: The processing device constructs a training sample set based on each sample prompt text and the corresponding sample label.
[0195] In the embodiment of the present application, when the processing device executes step 807, it can adopt the same processing method as in step 204, which is not elaborated in the present application.
[0196] Furthermore, in the embodiment of the present application, after the creation of the training sample set for the target business is completed, the corresponding training sample sets for other businesses can be constructed in the same way as the training sample set for the target business.
[0197] Furthermore, the processing device can use the training sample sets constructed for each target business to perform prefix tuning training on the second language model, and finally after completing the training of the initial prefix network, obtain a target label recognition model constructed by the trained target prefix network and the untrained second language model.
[0198] Specifically, in the process of training to obtain the target label recognition model, the processing device obtains the training sample sets constructed for each target business; then the initial prefix network of the corresponding prefix tuning structure is added to the second language model to obtain the initial label recognition model; the parameter magnitude of the first language model is much higher than that of the second language model; then, each training sample set is used to perform multiple rounds of iterative training on the initial prefix network in the initial label recognition model to obtain the target label recognition model composed of the trained target prefix network and the second language model. Among them, the model structure of the second language model can be any one of ChatGLM, Llama, and Vicuna. The following description only takes the model structure of ChatGLM as an example for schematic description.
[0199] It should be understood that in the embodiment of the present application, the training principle of prefix tuning is: by adding a learnable prefix before the input sequence of the second language model to adapt to a specific task. The main advantage of this fine-tuning method is that it can reduce the consumption of computing resources and avoid direct modification of the model parameters of the second language model, thereby reducing the risk of overfitting; the prefix can be generated from random noise through a small network (such as a multi-layer perceptron MLP); the length and dimension of the prefix need to match the input of the model, and the length is usually short, such as 10 to 50 virtual tokens, for example, it can be selected as 50.
[0200] See also Fig. 9 As shown, it is a schematic diagram of the structure of the initial tag recognition model in the embodiment of the present application. Fig. 9 As shown in the figure, for the autoregressive architecture model: add a prefix to the front of the sentence, and the input form of the second language model is [prefix; x]; according to the attached Fig. 9 The content shown in the figure corresponds to each layer of the second language model, and there is a corresponding MLP network to generate the corresponding prefix based on the random noise in the source, where the prefix generated by an MLP network has the same dimension as the content in the corresponding layer in the second language model; when there are m layers in the second language model, there are m MLP networks, collectively referred to as the initial prefix network. In addition, within the model, the prefix affects the output of the model by interacting with the content of other token positions in the model, which usually involves the model's attention mechanism.
[0201] Taking a round of prefix fine-tuning training as an example, after the processing device reads the training samples and inputs them into the second language model with the initial prefix network added, it can generate a predicted probability distribution for each output word position (token) based on the current context and model parameter θ, where this predicted probability distribution represents the probability that each word in the preset vocabulary becomes the content of an output token. Afterwards, the cross-entropy loss function is used to compare the generated predicted probability distribution with the actual probability distribution corresponding to each actual output token, and the difference between the two is calculated to obtain a loss value. The optimization goal of fine-tuning is to minimize the sum of the loss values on all output tokens to improve the quality and coherence of the generated text. The specific loss function is as follows:
[0202]
[0203] Among them, N represents the total number of training samples used in one round of training, V represents the total number of words included in the vocabulary, represents the true probability distribution constructed for the j-th output token determined for the i-th training sample, It represents the predicted probability distribution of the model for the jth output token in the i-th training sample, given the prefix and the generated output token.
[0204] In this way, with the help of the pre-trained first language model, after constructing training sample sets for the comment texts under each target business, the second language model with a small parameter magnitude is prefix tuned based on the training sample set obtained by the first language model in an unsupervised manner, which helps to improve the prefix tuning effect of the second language model and complete the training of the label recognition model, so that the trained target label recognition model can achieve accurate matching of content labels under each target business.
[0205] Furthermore, after the processing device constructs the target label recognition model, the processing device can perform label recognition on the collected comment text to be processed based on the target label recognition model.
[0206] Specifically, the processing device obtains the comment texts to be processed collected respectively for each target business; then for each comment text to be processed, the following operations are performed respectively: after adjusting the matching target prompt content according to the label range corresponding to the target business to which it belongs, a text to be processed is combined with the adjusted target prompt content to generate a corresponding prompt text to be processed, and a target label recognition model is used to output a corresponding content label for the prompt text to be processed.
[0207] It should be understood that in the embodiments of the present application, taking into account that the label range corresponding to a target business may change, in order to enable the model to adapt to changes in the label range, after determining the target business to which a comment text to be processed belongs, and determining the target prompt content for the attributed target business, the target prompt content can be adaptively adjusted according to the label range corresponding to the current target business.
[0208] In this way, with the help of the target label recognition model, it is possible to effectively analyze the comment texts to be processed under each target business and accurately match the content labels corresponding to the comment texts to be processed.
[0209] Optionally, in some feasible embodiments of the present application, considering that each comment text to be processed has a targeted commented object, and for a comment text to be processed, the targeted commented object is known, therefore, according to actual processing needs, the comment texts to be processed can be clustered according to the corresponding commented objects, and then the comments on each commented object can be analyzed.
[0210] Specifically, after outputting the corresponding content labels for each pending comment text obtained, the processing device can also cluster each pending comment text according to the commented object to obtain a pending comment set corresponding to each commented object; and then perform the following operations for each pending comment set: according to the content labels corresponding to each pending comment text in a pending comment set, cluster different pending comment texts corresponding to the same content label to obtain the pending comment groups corresponding to each content label and the statistical results of the number of comments.
[0211] It should be noted that the statistical results of the number of comments may include any one or combination of the following: the total number of comments, the proportion of the number of comments to the total number of comments in the corresponding set of comments to be processed.
[0212] For example, see Fig.10 As shown, it is a schematic diagram of the process of sorting out each review group to be processed in the embodiment of the present application. Fig.10 From the diagram, it can be seen that, assuming there are 11 unprocessed comment texts, and these 11 unprocessed comment texts are determined for 3 commented objects, then for each commented object, the corresponding unprocessed comment set can be clustered, and then for each unprocessed comment set, each unprocessed comment group can be clustered.
[0213] In this way, with the help of the content tags obtained by model recognition, it is possible to analyze and determine the comments under each content tag for each commented object.
[0214] Optionally, in some other feasible embodiments of the present application, the review texts to be processed may be clustered as a whole based on content tags, so as to analyze the improvement requirements of the target business based on the obtained set of similar reviews.
[0215] Specifically, the processing device clusters each comment text to be processed according to the targeted content label to obtain a set of similar comments corresponding to each content label; then, in each content label, the target content label expressing negative emotions is analyzed and determined, and based on the set of similar comments corresponding to the target content label, improvement prompt information for the corresponding target business is generated.
[0216] It should be noted that when analyzing target content tags that express negative emotions, a neural network model can be used to automatically identify the emotional tendencies in the content tags, wherein the present application does not describe the training process of the neural network model. In addition, after completing the clustering of the comment texts to be processed based on the content tags, when generating corresponding improvement prompt information for target content tags that express negative emotions, the generated prompt information to be improved may include any one or combination of the following: the target business; the total number of comment texts to be processed associated with the target content tags; the proportion of the total number of comment texts to be processed associated with the target content tags in all the comments to be processed under the corresponding target business.
[0217] For example, see Fig.11 As shown, it is a schematic diagram of the process of sorting out each similar review set in the embodiment of the present application. Fig.11 As can be seen from the illustrated content, assuming that there are 11 comment texts to be processed, after obtaining the content labels corresponding to the comment texts to be processed, the comment texts to be processed can be clustered according to the content labels to obtain 5 similar comment sets.
[0218] In this way, by clustering the pending comment texts corresponding to the same content tags, the pending comment texts expressing negative emotions can be integrated from the perspective of content tags, thereby achieving targeted evaluation of the corresponding target business, making it possible to timely detect the negative experience of the target business and provide improvement direction for the target business.
[0219] The following takes the commodity purchase scenario as an example, and takes the processing of commodities of various categories as an example, to illustrate the process of generating corresponding training sample sets for commodities of various categories:
[0220] It should be understood that in the technical solution proposed in the present application, with the help of the training sample sets corresponding to each category of goods, a target label recognition model can be trained, and then by using the target label recognition model, the review texts to be processed for each category of goods can be identified to obtain the corresponding content labels.
[0221] First, the historical review texts used to generate each training sample set are explained:
[0222] In the embodiment of the present application, the historical review texts related to each category of goods can be compiled based on self-operated e-commerce business data and open source e-commerce review data.
[0223] When processing the self-operated e-commerce business data, we collect and integrate the review data set from the self-operated e-commerce business, where the review data set usually includes: e-commerce reviews divided by category and the content tag range corresponding to each category. In addition, the review data set marks the correspondence between the historical review text and the content tag.
[0224] For example, for the "bowl" category, there are 2,500 historical review texts and nine predefined content tags: "suitable size, high cost-effectiveness, flawless, beautiful and practical, good workmanship, good thickness, tight packaging, high quality, and beautiful patterns."
[0225] For open source e-commerce review data, considering that the historical review text in the e-commerce scenario may not contain specific category information, it can be regarded as a general category according to actual processing needs, and the content tag range is determined according to the tags provided in the open source e-commerce review data. Therefore, the direct correspondence between the historical review text and the content tag can be obtained.
[0226] Furthermore, after summarizing and organizing the obtained data, a data set of all categories can be obtained, covering the historical review texts of each category.
[0227] For example, see Table 1, which is a statistical table of historical review texts of some categories in the embodiments of the present application:
[0228] Table 1:
[0229]
[0230] For further information, see Fig.12 As shown, it is a schematic diagram of the knowledge extraction process in the embodiment of the present application. Fig.12 , in the case of manual participation in adjusting the prompt content, the process of constructing training sample sets for each category (or product category) according to the first language model is explained:
[0231] It should be noted that when the first language model is used for processing in this application, the main information is extracted from the input prompt text and the matching intention is understood through dialogue. Finally, the corresponding label matching result is given according to the natural language understanding knowledge mastered in the model. The first language model in this application can be understood as a teacher model, specifically a GPT4 model, which has powerful language understanding and generation capabilities, so it can handle complex tasks of multiple categories at the same time and match content labels.
[0232] According to the attached Fig.12 As can be seen from the illustrated content, in the processing process illustrated by the solid line, each reference review text sampled from all categories is combined with the basic prompt content determined for the corresponding product category to obtain the corresponding basic prompt text, and then the first language model is used to output the content label corresponding to the basic prompt text; afterwards, in the manual detection process, for each category, the difference between the content label output by the detection model and the true label is detected to determine the precision and recall rates; further, after determining that the precision and recall rates of the first language model in a category are both over 80%, it can be determined that the basic prompt content meets the model processing needs, so the currently used basic prompt content can be used as the target prompt content to participate in the annotation of the candidate review text, and finally, for this category, the sample prompt text of each associated sample label is obtained.
[0233] Continue to combine Fig.12 To illustrate, in the processing process indicated by the dotted line, when manual detection determines that the accuracy or recall rate of the first language model in a category is lower than 80%, it is necessary to manually tune the corresponding basic prompt content, and based on the adjusted basic prompt content (or candidate prompt content), call the first language model for processing, and repeat manual detection until it is determined that the accuracy and recall rate of the first language model in this category are greater than 80%, and the target prompt content is obtained; then, based on the target prompt content, participate in the label matching of the candidate comment text, and finally obtain the sample prompt text of each associated sample label for this category.
[0234] For attachment Fig.12 A specific analysis of the contents shown in the figure shows that when determining the evaluation results of the first language model in different categories, 500 data can be randomly selected from each category as reference comment texts to form a corresponding evaluation set to evaluate the effect of the first language model in label matching under e-commerce comments in different categories.
[0235] Moreover, during the manual evaluation process, the label recognition accuracy of the first language model in different categories (or product categories) was evaluated, and for categories with accuracy or recall rates below 80%, semi-supervised prompt content tuning based on thought chains was used to improve the processing performance of the first language model.
[0236] In particular, when evaluating the accuracy and recall rate, for the reference comment text extracted from the self-operated e-commerce comment data, since the sorted self-operated e-commerce comment data does not contain the correspondence between the comment text and the content label, it is impossible to directly calculate the accuracy of the first language model matching the comment label. Therefore, it is necessary to combine manual annotation to annotate each reference comment text, and calculate the accuracy and recall of the first language model in label matching based on the annotation results and model output results. In addition, for the reference comment text selected from the open source data set, since each comment has a corresponding content label, it does not need to be verified by manual annotation, and the corresponding accuracy and recall can be calculated directly in combination with the corresponding content label.
[0237] It should be understood that for categories with accuracy or recall rates lower than 80%, it indicates that the relevant knowledge extracted by the current first language model is problematic, so the model cannot be trained directly based on the label results recognized by the first language model. For this type of data, we use a semi-supervised prompt content (prompt) tuning method based on thought chaining to automatically optimize the prompt.
[0238] When optimizing the prompt content, it is necessary to select the best logical guidance text for each category according to the different categories, and then adjust the basic prompt content according to the logical guidance text to obtain the best target prompt content for each category.
[0239] Taking the determination of the target prompt content for a category as an example, each logical guidance text is first concatenated with the basic prompt content of the category to construct the corresponding candidate prompt content; then each candidate prompt content is combined with each reference comment text under the category to obtain each candidate prompt text guided by each candidate prompt content, and then with the help of the first language model, the corresponding prediction label is output for each candidate prompt text; then, according to the changes in the accuracy and recall rate of the first language model under different candidate prompt contents, the candidate prompt content that can obtain the best accuracy and recall rate is selected as the target prompt content, and the sample data under the category is annotated and generated based on the target prompt content.
[0240] In particular, for categories with a precision and recall rate of more than 80% after optimization, full labeling can be performed directly based on the determined target prompt content to generate training samples. For some categories with a precision and recall rate still below 80%, manual review and optimization will be performed.
[0241] For example, see Table 2, which is a schematic table of accuracy and recall rates detected in an embodiment of the present application:
[0242] Table 2:
[0243]
[0244] Furthermore, when generating training sample sets for each category, a corresponding training sample is constructed based on the sample label output by the first language model for each sample prompt text, and similarly, a training sample set consisting of each training sample can be constructed corresponding to each category.
[0245] In addition, in the embodiments of the present application, label propagation and data enhancement methods can be used, which not only saves data annotation costs, but also significantly improves the diversity of data annotation, thereby ensuring the generalization of subsequent models.
[0246] In order to improve the efficiency of data annotation, this application adopts a comment clustering label propagation method based on the central text. Considering that GPT4 is currently called through an API, the corresponding cost is relatively high, this method can effectively save costs. First, the candidate comment texts to be annotated are clustered according to similarity, where the threshold is set to a relatively high 0.95 to ensure that the elements in each class can be regarded as texts with the same characteristics. After that, for each type of comment text, it is only necessary to match and determine the content label corresponding to a candidate comment text in that type of comment text, and other comment texts in that type of comment text can use the current annotation results. This method can significantly improve the annotation efficiency and save more than 60% of the annotation costs.
[0247] In addition, in order to improve the generalization of the model, data augmentation can be used to generate more training data by transforming and expanding the candidate comment texts. The main advantage is that it can improve the annotation efficiency and the generalization of the model. Related processing methods include synonym replacement of labels and synonym replacement of part of the comment text. When synonym replacement is performed on part of the comment text, the training set can be expanded by introducing synonyms or near synonyms of the vocabulary in the comment. Moreover, by increasing the variants of vocabulary and expression, the model can better understand the diversity of language and improve its generalization ability.
[0248] According to actual processing needs, in an embodiment of the present application, after performing synonym replacement on part of the content of the candidate comment text, the difference in text similarity before and after the replacement can be calculated through an open source text vector model to determine whether the semantics of the text has shifted, thereby retaining only comment texts with a semantic difference of less than 10% for data enhancement.
[0249] In this way, this application can use large models and human-computer collaboration to complete a large number of data labeling tasks efficiently and with high quality. Specifically, only a small amount of reference prompt text (usually in the order of a few hundred) needs to be manually labeled and tested to complete the labeling of the entire amount of e-commerce review data (usually in the order of tens of thousands). At the same time, with the help of label propagation and data enhancement, the efficiency of data labeling can be significantly improved while ensuring the integrity and diversity of the extracted knowledge, and the cost of knowledge extraction can be reduced. Ultimately, the self-operated e-commerce review data and open source e-commerce review data are transformed into a high-quality training sample set that contains e-commerce review-related knowledge in the first language model.
[0250] Furthermore, after training with the help of the training sample sets constructed in this application, the label recognition performance can be significantly improved.
[0251] See Table 3, which is a schematic diagram of the changes in model accuracy and recall rate in the embodiment of the present application:
[0252] Table 3
[0253]
[0254] In this way, the target label recognition model trained in this application has an overall recognition accuracy of more than 90% and a recall rate of more than 85%. Compared with the online model with an average accuracy of 52% and a recall rate of 61.25%, it has a very large processing performance improvement. Moreover, since the parameter magnitude of the target label recognition model is much smaller than that of the usual large prediction model, it can be directly used to replace the current online model for label recognition of comment texts.
[0255] In summary, in the technical solution proposed in the present application, by fine-tuning the prefix of the second language model to obtain the target label recognition model, the accuracy of label recognition can be effectively improved, the resources required for model processing can be reduced, and the difficulty of model deployment can be reduced; moreover, in the label recognition of reference review texts of all categories, the content tuning of the basic prompt content of each category, and the label recognition of each candidate prompt text, the powerful learning ability of the first language model with a very large parameter magnitude has played a huge role; using the first language model, through natural language processing, common sense reasoning and other capabilities to analyze and understand the text content of the review, it is possible to realize the automatic comment label matching function and improve the accuracy and efficiency of label matching. In the technical solution proposed in the present application, the first language model is used as a teacher model to verify the effectiveness of the first language model in the review label matching of various e-commerce categories, and by constructing training samples based on the recognition results of the first language model, it is equivalent to distilling and extracting the relevant knowledge it contains.
[0256] In addition, by using the content labels output by the first language model based on the sample comment text, the fine-tuning training of the second language model can better control the behavior of the model so that it can produce more stable output under the same or similar input. Moreover, the fine-tuning training process is equivalent to transferring the general knowledge related to e-commerce comments extracted by the first language model with a parameter level of trillions to a smaller and easier to deploy target label recognition model, so that the obtained target label recognition model can obtain very good processing effects in the label recognition process of all categories, thereby quickly producing relevant models that can be deployed online under low resource conditions; and, compared with the first language model, the target label recognition model has higher accuracy and lower resource consumption in the e-commerce comment recognition scenario, and can accurately identify content labels based on comment texts for all categories of goods, and can simultaneously process comment label matching tasks under multiple categories, so that the model has certain flexibility and scalability, and can efficiently and quickly adapt to the comment label matching tasks of new categories. Therefore, the technical solution proposed in this application can combine the knowledge of the first language model and the computational efficiency of the second language model, so that the final target label recognition model can achieve efficient, stable and high-performance matching and recognition of e-commerce comment labels.
[0257] Based on the same inventive concept, refer to Fig.13 As shown, it is a schematic diagram of the logical structure of the training sample construction device in the embodiment of the present application. The training sample construction device 1300 includes: an acquisition unit 1301, a generation unit 1302, a selection unit 1303, and a construction unit 1304, wherein:
[0258] The acquisition unit 1301 is used to acquire, for a target business, reference review texts marked with content tags, and to acquire unmarked candidate review texts;
[0259] The generating unit 1302 is used to combine the reference comment texts with the basic prompt content determined for the target business to generate corresponding basic prompt texts, and call the first language model to output the prediction tags corresponding to the basic prompt texts, and obtain the evaluation result of the first language model under the target business based on the prediction tags and the corresponding content tags;
[0260] A selection unit 1303 is used to add each preset logical guidance text to the basic prompt content respectively when the evaluation result does not meet the standard condition, generate corresponding candidate prompt content, and select a target prompt content that makes the evaluation result of the first language model meet the standard condition from each candidate prompt content;
[0261] The construction unit 1304 is used to combine each candidate comment text with the target prompt content to generate a corresponding sample prompt text, and call the first language model to output the sample label corresponding to each sample prompt text, and construct a training sample set based on the sample prompt text and the corresponding sample label.
[0262] Optionally, when obtaining each unlabeled candidate comment text, the obtaining unit 1301 is used to:
[0263] Obtain unlabeled original comment texts;
[0264] According to the similarity between every two original comment texts, the original comment texts satisfying similarity conditions are clustered to obtain original comment text groups, and one original comment text is randomly selected from each original comment text group as a candidate comment text.
[0265] Optionally, after outputting the sample labels corresponding to the sample prompt texts respectively and before constructing the training sample set based on the sample prompt texts and the corresponding sample labels, the acquiring unit 1301 is further used to:
[0266] For each candidate review text, perform the following operations:
[0267] When there are other original comment texts except one candidate comment text in the determined original comment text group, the other original comment texts are respectively combined with the target prompt content to generate corresponding sample prompt texts, and the sample label determined corresponding to the one candidate comment text is used as the sample label of each sample prompt text generated corresponding to the original comment text group.
[0268] Optionally, when obtaining each unlabeled candidate comment text, the obtaining unit 1301 is used to:
[0269] Obtaining each unlabeled initial review text, and obtaining each keyword and the associated synonymous relationship of the word; the synonymous relationship of the word associated with a keyword is used to indicate the synonym corresponding to the keyword;
[0270] By replacing the corresponding keywords with synonyms, the initial review texts containing the keywords are adjusted to obtain processed extended review texts;
[0271] The initial review texts and the extended review texts are determined as candidate review texts.
[0272] Optionally, when the initial review texts containing the keywords are adjusted by replacing the corresponding keywords with synonyms to obtain the processed extended review texts, the acquisition unit 1301 is used to:
[0273] For each initial comment text, perform the following operations:
[0274] Performing hit detection in an initial review text according to the keywords;
[0275] When the target keyword is determined to be hit based on the detection result, the corresponding synonymous keywords are obtained based on the synonymous relationship associated with the target keyword, and the target keyword in the initial comment text is replaced by the synonymous keywords to obtain extended comment texts.
[0276] Optionally, when replacing the target keyword in the initial comment text with the synonymous keywords to obtain the extended comment texts, the acquisition unit 1301 is used to:
[0277] Replacing the target keyword in the initial review text with the synonymous keywords respectively to obtain pending review texts;
[0278] The text similarities between the pending comment texts and the one initial comment text are calculated respectively, and the pending comment texts whose text similarities meet the screening conditions are determined as extended comment texts.
[0279] Optionally, when selecting, from among the candidate prompt contents, the target prompt content that makes the evaluation result of the first language model meet the standard condition, the selection unit 1303 is used to:
[0280] For each candidate prompt content, the following operations are performed respectively: each of the reference comment texts is combined with a candidate prompt content to generate a corresponding candidate prompt text, and the first language model is called to output a prediction label corresponding to each candidate prompt text, and based on each prediction label and the corresponding content label, an evaluation result of the first language model under the target business is obtained;
[0281] Among the evaluation results, a target evaluation result that meets the target-reaching condition is selected, and the candidate prompt content corresponding to the target evaluation result is determined as the target prompt content.
[0282] Optionally, when constructing a training sample set based on each sample prompt text and the corresponding sample label, the constructing unit 1304 is used to:
[0283] For each sample prompt text, the following operations are performed respectively: a sample label corresponding to a sample prompt text is determined, and each synonymous label containing the sample label is obtained according to a preset label synonym relationship, and each synonymous label is combined with the sample prompt text to obtain each training sample; the label synonym relationship is used to indicate other labels with the same semantics as a label;
[0284] The obtained training samples are combined to obtain a training sample set.
[0285] Optionally, when obtaining the evaluation result of the first language model under the target business based on each predicted tag and the corresponding content tag, the generating unit 1302 is used to:
[0286] Based on each predicted label and the corresponding content label, the accuracy rate corresponding to the first language model is calculated, and the recall rate of the first language model under various content labels of the target business is calculated; the average recall rate determined based on each recall rate and the accuracy rate are determined as the evaluation result of the first language model under the target business.
[0287] Optionally, after constructing the training sample set, the apparatus further includes a training unit 1305, wherein the training unit 1305 is configured to:
[0288] Obtain training sample sets constructed respectively for each target business;
[0289] Adding the initial prefix network of the corresponding prefix tuning structure to the second language model to obtain an initial label recognition model; the parameter magnitude of the first language model is much higher than that of the second language model;
[0290] Using each training sample set, the initial prefix network in the initial label recognition model is trained for multiple rounds of iterations to obtain a target label recognition model consisting of a trained target prefix network and the second language model.
[0291] Optionally, after obtaining the target label recognition model composed of the trained target prefix network and the second language model, the apparatus further includes an execution unit 1306, and the execution unit 1306 is used to:
[0292] Obtain the review texts to be processed collected from each target business;
[0293] For each comment text to be processed, the following operations are performed respectively: after adjusting the matching target prompt content according to the label range corresponding to the target business to which it belongs, a text to be processed is combined with the adjusted target prompt content to generate a corresponding prompt text to be processed, and the target label recognition model is used to output the corresponding content label for the prompt text to be processed.
[0294] Optionally, after outputting the corresponding content tag for each comment text to be processed, the execution unit 1306 is further configured to:
[0295] Clustering the to-be-processed comment texts according to the commented objects, and obtaining the to-be-processed comment sets corresponding to the commented objects;
[0296] For each set of pending comments, the following operations are performed respectively: according to the content labels corresponding to each pending comment text in a set of pending comments, different pending comment texts corresponding to the same content label are clustered to obtain the pending comment groups corresponding to each content label and the statistical results of the number of comments.
[0297] Optionally, after outputting the content labels corresponding to the prompt texts to be processed respectively, the execution unit 1306 is further configured to:
[0298] Clustering the review texts to be processed according to the targeted content tags to obtain the review sets of the same type corresponding to the content tags;
[0299] Among the content tags, target content tags expressing negative emotions are analyzed and determined, and improvement prompt information for the corresponding target business is generated based on a set of similar comments corresponding to the target content tags.
[0300] For the convenience of description, the above parts are divided into modules (or units) according to their functions and described separately. Of course, when implementing this application, the functions of each module (or unit) can be implemented in the same or multiple software or hardware.
[0301] After introducing the method and device for constructing training samples according to an exemplary embodiment of the present application, next, an electronic device according to another exemplary embodiment of the present application is introduced.
[0302] Those skilled in the art will appreciate that various aspects of the present application may be implemented as a system, method or program product. Therefore, various aspects of the present application may be specifically implemented in the following forms, namely: a complete hardware implementation, a complete software implementation (including firmware, microcode, etc.), or a combination of hardware and software, which may be collectively referred to as "circuit", "module" or "system" herein.
[0303] Based on the same inventive concept as the above method embodiment, an electronic device is also provided in the embodiment of the present application. Fig.14 As shown, it is a schematic diagram of the hardware structure of an electronic device using an embodiment of the present application. In one embodiment, the electronic device may be Figure 1 In this embodiment, the structure of the electronic device can be as follows: Fig.14 As shown, it includes a first memory 1401 , a communication module 1403 and one or more first processors 1402 .
[0304] The first memory 1401 is used to store computer programs executed by the first processor 1402. The first memory 1401 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system and programs required for running an instant messaging function, etc.; the data storage area may store various instant messaging information and an operating instruction set, etc.
[0305] The first memory 1401 may be a volatile memory, such as a random-access memory (RAM); the first memory 1401 may also be a non-volatile memory, such as a read-only memory, a flash memory, a hard disk drive (HDD) or a solid-state drive (SSD); or the first memory 1401 is any other medium that can be used to carry or store a desired computer program in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The first memory 1401 may be a combination of the above memories.
[0306] The first processor 1402 may include one or more central processing units (CPU) or a digital processing unit, etc. The first processor 1402 is configured to implement the above training sample construction method when calling the computer program stored in the first memory 1401 .
[0307] The communication module 1403 is used to communicate with client devices and other processing devices.
[0308] The specific connection medium between the first memory 1401, the communication module 1403 and the first processor 1402 is not limited in the embodiment of the present application. Fig.14 In the embodiment, the first memory 1401 and the first processor 1402 are connected via a bus 1404. The bus 1404 is Fig.14The connections between the other components are only for illustration and are not intended to be limiting. The bus 1404 can be divided into an address bus, a data bus, a control bus, etc. For ease of description, Fig.14 The diagram shows that only one thick line is used, but this does not mean that there is only one bus or only one type of bus.
[0309] The first memory 1401 stores a computer storage medium, and the computer storage medium stores computer executable instructions, which are used to implement the method for constructing training samples in the embodiment of the present application. The first processor 1402 is used to execute the above-mentioned method for constructing training samples, such as Figure 2 and 8 shown.
[0310] In another embodiment, the electronic device may also be other electronic devices, see Fig.15 FIG. 1 is a schematic diagram of the hardware structure of another electronic device using an embodiment of the present application. Specifically, the electronic device may be Figure 1 The client device 110 shown in FIG. 1 is a schematic diagram of a client device 110. In this embodiment, the structure of the electronic device can be as follows: Fig.15 As shown, it includes: a communication component 1510, a second memory 1520, a display unit 1530, a camera 1540, a sensor 1550, an audio circuit 1560, a Bluetooth module 1570, a second processor 1580 and other components.
[0311] The communication component 1510 is used to communicate with the processing device. In some embodiments, a wireless fidelity (WiFi) module may be included. The WiFi module belongs to a short-range wireless transmission technology. The electronic device can help the user send and receive information through the WiFi module.
[0312] The second memory 1520 can be used to store software programs and data. The second processor 1580 executes various functions and data processing of the client device 110 by running the software programs or data stored in the second memory 1520. In the present application, the second memory 1520 can store an operating system and various application programs, and can also store computer programs related to the method for constructing training samples in the embodiment of the present application.
[0313] The display unit 1530 may also be used to display information input by the user or information provided to the user and a graphical user interface (GUI) of various menus of the client device 110. Specifically, the display unit 1530 may include a display screen 1532 disposed on the front of the client device 110. The display unit 1530 may be used to display an input page for comment text in an embodiment of the present application, etc.
[0314] The display unit 1530 can also be used to receive input digital or character information and generate signal input related to user settings and function control of the client device 110. Specifically, the display unit 1530 may include a touch screen 1531 disposed on the front of the client device 110, which can collect user touch operations on or near it.
[0315] The touch screen 1531 may be covered on the display screen 1532, or the touch screen 1531 and the display screen 1532 may be integrated to realize the input and output functions of the client device 110, and the integrated touch screen may be referred to as a touch display screen. In the present application, the display unit 1530 may display the application and the corresponding operation steps.
[0316] The camera 1540 can be used to capture still images, and users can post comments on the images taken by the camera 1540 through the application. The object generates an optical image through the lens and projects it onto the photosensitive element. The photosensitive element can be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the optical signal into an electrical signal, and then transmits the electrical signal to the second processor 1580 to convert it into a digital image signal.
[0317] The client device may further include at least one sensor 1550, such as an acceleration sensor 1551, a distance sensor 1552, a fingerprint sensor 1553, and a temperature sensor 1554. The client device may also be configured with other sensors such as a gyroscope, a barometer, a hygrometer, a thermometer, an infrared sensor, a light sensor, and a motion sensor.
[0318] The audio circuit 1560, the speaker 1561, and the microphone 1562 can provide an audio interface between the user and the client device 110. The audio circuit 1560 can transmit the electrical signal converted from the received audio data to the speaker 1561, which is converted into a sound signal for output. On the other hand, the microphone 1562 converts the collected sound signal into an electrical signal, which is received by the audio circuit 1560 and converted into audio data, and then the audio data is output to the communication component 1510 to be sent to, for example, another client device 110, or the audio data is output to the second memory 1520 for further processing.
[0319] The Bluetooth module 1570 is used to exchange information with other Bluetooth devices having Bluetooth modules through the Bluetooth protocol.
[0320] The second processor 1580 is the control center of the client device, which uses various interfaces and lines to connect various parts of the entire terminal, and executes various functions of the client device and processes data by running or executing software programs stored in the second memory 1520, and calling data stored in the second memory 1520. In some embodiments, the second processor 1580 may include at least one processing unit; the second processor 1580 may also integrate an application processor and a baseband processor. In the present application, the second processor 1580 can run an operating system, an application program, a user interface display and a touch response, as well as processing related to the construction of training samples in the embodiments of the present application. In addition, the second processor 1580 is coupled to the display unit 1530.
[0321] In some possible implementations, various aspects of the method for constructing a training sample provided in the present application may also be implemented in the form of a program product, which includes a computer program. When the program product is run on an electronic device, the computer program is used to enable the electronic device to execute the steps of the method for constructing a training sample according to various exemplary implementations of the present application described above in this specification. For example, the electronic device may execute the following steps: Figure 2 and 8 Follow the steps shown in .
[0322] The program product may adopt any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination thereof. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof.
[0323] The program product of the embodiment of the present application may adopt a portable compact disk read-only memory (CD-ROM) and include a computer program, and can be run on an electronic device. However, the program product of the present application is not limited thereto, and in this document, a readable storage medium may be any tangible medium containing or storing a program, which can be used by or in combination with a command execution system, apparatus, or device.
[0324] A readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, wherein a readable computer program is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing. A readable signal medium may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with a command execution system, apparatus, or device.
[0325] The computer program embodied on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0326] The computer program for performing the operation of the present application can be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, etc., and also conventional procedural programming languages such as "C" language or similar programming languages. The computer program can be executed entirely on the user electronic device, partially on the user electronic device, as an independent software package, partially on the user electronic device and partially on the remote electronic device, or completely on the remote electronic device or server. In the case of involving a remote electronic device, the remote electronic device can be connected to the user electronic device through any type of network including a local area network (LAN) or a wide area network (WAN), or can be connected to an external electronic device (e.g., using an Internet service provider to connect through the Internet).
[0327] It should be noted that, although several units or subunits of the device are mentioned in the above detailed description, this division is merely exemplary and not mandatory. In fact, according to the embodiments of the present application, the features and functions of two or more units described above can be embodied in one unit. Conversely, the features and functions of one unit described above can be further divided into multiple units to be embodied.
[0328] In addition, although the operations of the method of the present application are described in a specific order in the drawings, this does not require or imply that the operations must be performed in this specific order, or that all the operations shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps.
[0329] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application 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.) that contain a computer-usable computer program.
[0330] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program commands. These computer program commands 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 generate a machine, so that the commands executed by the processor of the computer or other programmable data processing device generate commands 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.
[0331] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present application.
[0332] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. A method for generating training samples, characterized in that: include: For the target business, obtain each reference review text annotated with content tags, and obtain each unannotated candidate review text; Combining the reference comment texts with the basic prompt content determined for the target business to generate corresponding basic prompt texts, calling the first language model to output prediction tags corresponding to the basic prompt texts, and obtaining evaluation results of the first language model for the target business based on the prediction tags and the corresponding content tags; When the evaluation result does not meet the standard condition, each preset logical guidance text is added to the basic prompt content to generate corresponding candidate prompt content, and from each candidate prompt content, a target prompt content is selected that makes the evaluation result of the first language model meet the standard condition; Each candidate comment text is respectively combined with the target prompt content to generate a corresponding sample prompt text, and the first language model is called to output a sample label corresponding to each sample prompt text, and a training sample set is constructed based on each sample prompt text and the corresponding sample label.
2. The method according to claim 1, characterized in that The step of obtaining unlabeled candidate comment texts includes: Obtain unlabeled original comment texts; According to the similarity between every two original comment texts, the original comment texts satisfying similarity conditions are clustered to obtain original comment text groups, and one original comment text is randomly selected from each original comment text group as a candidate comment text.
3. The method according to claim 2, characterized in that After the sample labels corresponding to the sample prompt texts are output respectively, and before the training sample set is constructed based on the sample prompt texts and the corresponding sample labels, the method further includes: For each candidate review text, perform the following operations: When there are other original comment texts except one candidate comment text in the determined original comment text group, the other original comment texts are respectively combined with the target prompt content to generate corresponding sample prompt texts, and the sample label determined corresponding to the one candidate comment text is used as the sample label of each sample prompt text generated corresponding to the original comment text group.
4. The method according to claim 1, characterized in that The step of obtaining unlabeled candidate comment texts includes: Obtaining each unlabeled initial review text, and obtaining each keyword and the associated synonymous relationship of the word; the synonymous relationship of the word associated with a keyword is used to indicate the synonym corresponding to the keyword; By replacing the corresponding keywords with synonyms, the initial review texts containing the keywords are adjusted to obtain processed extended review texts; The initial review texts and the extended review texts are determined as candidate review texts.
5. The method according to claim 4, characterized in that The method of replacing the corresponding keywords with synonyms is adopted to adjust the initial comment texts containing the keywords respectively, and obtain the processed extended comment texts, including: For each initial comment text, perform the following operations: Performing hit detection in an initial review text according to the keywords; When the target keyword is determined to be hit based on the detection result, the corresponding synonymous keywords are obtained based on the synonymous relationship associated with the target keyword, and the target keyword in the initial comment text is replaced by the synonymous keywords to obtain extended comment texts.
6. The method according to claim 5, characterized in that The step of replacing the target keyword in the initial comment text with the synonymous keywords to obtain extended comment texts includes: Replacing the target keyword in the initial review text with the synonymous keywords respectively to obtain pending review texts; The text similarities between the pending comment texts and the one initial comment text are calculated respectively, and the pending comment texts whose text similarities meet the screening conditions are determined as extended comment texts.
7. The method according to claim 1, characterized in that The step of selecting, from among the candidate prompt contents, a target prompt content that enables the evaluation result of the first language model to meet the target condition comprises: For each candidate prompt content, the following operations are performed respectively: each of the reference comment texts is combined with a candidate prompt content to generate a corresponding candidate prompt text, and the first language model is called to output a prediction label corresponding to each candidate prompt text, and based on each prediction label and the corresponding content label, an evaluation result of the first language model under the target business is obtained; Among the evaluation results, a target evaluation result that meets the target-reaching condition is selected, and the candidate prompt content corresponding to the target evaluation result is determined as the target prompt content.
8. The method according to any one of claims 1 to 7, characterized in that: The step of constructing a training sample set based on each sample prompt text and the corresponding sample label includes: For each sample prompt text, the following operations are performed respectively: a sample label corresponding to a sample prompt text is determined, and each synonymous label containing the sample label is obtained according to a preset label synonym relationship, and each synonymous label is combined with the sample prompt text to obtain each training sample; the label synonym relationship is used to indicate other labels with the same semantics as a label; The obtained training samples are combined to obtain a training sample set.
9. The method according to any one of claims 1 to 7, characterized in that: The obtaining, based on each predicted tag and the corresponding content tag, an evaluation result of the first language model under the target business includes: Based on each predicted label and the corresponding content label, the accuracy rate corresponding to the first language model is calculated, and the recall rate of the first language model under various content labels of the target business is calculated; the average recall rate determined based on each recall rate and the accuracy rate are determined as the evaluation result of the first language model under the target business.
10. The method according to any one of claims 1 to 7, characterized in that: After constructing the training sample set, the method further includes: Obtain training sample sets constructed respectively for each target business; Adding the initial prefix network of the corresponding prefix tuning structure to the second language model to obtain an initial label recognition model; the parameter magnitude of the first language model is much higher than that of the second language model; Using each training sample set, the initial prefix network in the initial label recognition model is trained for multiple rounds of iterations to obtain a target label recognition model consisting of a trained target prefix network and the second language model.
11. The method according to claim 10, characterized in that After obtaining the target label recognition model composed of the trained target prefix network and the second language model, the method further includes: Obtain the review texts to be processed collected from each target business; For each comment text to be processed, the following operations are performed respectively: after adjusting the matching target prompt content according to the label range corresponding to the target business to which it belongs, a text to be processed is combined with the adjusted target prompt content to generate a corresponding prompt text to be processed, and the target label recognition model is used to output the corresponding content label for the prompt text to be processed.
12. The method according to claim 11, characterized in that After outputting the corresponding content label for each comment text to be processed, the method further includes: Clustering the to-be-processed comment texts according to the commented objects, and obtaining the to-be-processed comment sets corresponding to the commented objects; For each set of pending comments, the following operations are performed respectively: according to the content labels corresponding to each pending comment text in a set of pending comments, different pending comment texts corresponding to the same content label are clustered to obtain the pending comment groups corresponding to each content label and the statistical results of the number of comments.
13. The method according to claim 11, characterized in that After outputting the corresponding content label for each comment text to be processed, the method further includes: Clustering the review texts to be processed according to the targeted content tags to obtain the review sets of the same type corresponding to the content tags; Among the content tags, target content tags expressing negative emotions are analyzed and determined, and improvement prompt information for the corresponding target business is generated based on a set of similar comments corresponding to the target content tags.
14. A training sample generation device, characterized in that: include: An acquisition unit, for acquiring reference review texts marked with content tags and unmarked candidate review texts for a target business; A generating unit, configured to respectively combine the reference comment texts with the basic prompt content determined for the target business to generate corresponding basic prompt texts, and to call the first language model to respectively output prediction tags corresponding to the basic prompt texts, and to obtain an evaluation result of the first language model under the target business based on the prediction tags and the corresponding content tags; a selection unit, configured to, when the evaluation result does not meet the standard condition, add each preset logical guidance text to the basic prompt content respectively, generate corresponding candidate prompt content, and select, from each candidate prompt content, a target prompt content that makes the evaluation result of the first language model meet the standard condition; The construction unit is used to combine each candidate comment text with the target prompt content to generate a corresponding sample prompt text, and call the first language model to output a sample label corresponding to each sample prompt text, and construct a training sample set based on each sample prompt text and the corresponding sample label.
15. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 13 is implemented.
16. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 13 is implemented.
17. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 13 is implemented.
