Task processing method and device, electronic equipment, storage medium and product
By selecting the target sample based on type and semantic similarity in the large model, the problem of inaccurate output in complex task processing is solved, and the accuracy of task processing results is improved.
Patent Information
- Application Number
- CN202410756050.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-12
- Publication Date
- 2024-12-20
AI Technical Summary
When large models deal with complex tasks, especially tasks that require multi-step inference to obtain results, the output is not always accurate, and existing methods cannot fully judge the similarity between samples and pending tasks, resulting in inaccurate output.
By determining the type similarity based on the prediction type of the pending task and the label type of the label sample, and combining the task semantics and sample semantics, the target sample is selected to improve the accuracy of the task processing results.
By accurately selecting target samples, the output accuracy of large models when processing complex tasks is improved, ensuring the accuracy of task processing results.
Smart Images

Figure CN119166806A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a task processing method and device, electronic equipment, storage medium, and product. Background Art
[0002] Chat Generative Pre-trained Transformer (ChatGPT) is a natural language processing technology driven by artificial intelligence technology. The large model based on ChatGPT demonstrates strong language capabilities and rich knowledge reserves. It can learn and understand human language, interact according to the context of the chat, chat like a human, and complete tasks such as writing emails, video scripts, copywriting, and translation. However, the skills required for large models to complete different tasks are different, resulting in the output of large models not always being accurate when processing complex tasks, especially when processing tasks that require multiple steps of reasoning to obtain results. Summary of the invention
[0003] The present disclosure provides a task processing method and device, electronic device, storage medium, and product, which can improve the accuracy of natural language processing.
[0004] In a first aspect, the present disclosure provides a task processing method, the task processing method comprising:
[0005] Based on the predicted type of the task to be processed and the labeled type of the labeled sample, determining the type similarity between the task to be processed and the labeled sample;
[0006] Determining candidate samples corresponding to the task to be processed from the labeled samples based on the type similarity;
[0007] Determining the semantic similarity between the task to be processed and the candidate sample according to the task semantics of the task to be processed and the sample semantics of the candidate sample;
[0008] Determining a target sample corresponding to the task to be processed from the candidate samples based on the type similarity and the semantic similarity;
[0009] Based on the task to be processed and the target sample, a task processing result of the task to be processed is obtained by using a first language model.
[0010] In a second aspect, the present disclosure provides a task processing device, the task processing device comprising:
[0011] A determination module, configured to determine the type similarity between the task to be processed and the labeled sample based on the predicted type of the task to be processed and the labeled sample;
[0012] The determination module is further configured to determine, based on the type similarity, candidate samples corresponding to the task to be processed from the labeled samples;
[0013] The determination module is further used to determine the semantic similarity between the task to be processed and the candidate sample according to the task semantics of the task to be processed and the sample semantics of the candidate sample;
[0014] The determination module is further used to determine the target sample corresponding to the task to be processed from the candidate samples based on the type similarity and the semantic similarity;
[0015] The obtaining module is used to obtain a task processing result of the task to be processed by using a first language model based on the task to be processed and the target sample.
[0016] In a third aspect, the present disclosure provides an electronic device comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores one or more computer programs executable by the at least one processor, and one or more of the computer programs are executed by the at least one processor so that the at least one processor can perform the above-mentioned task processing method.
[0017] In a fourth aspect, the present disclosure provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the above-mentioned task processing method when executed by a processor.
[0018] In a fifth aspect, the present disclosure provides a computer program product, characterized in that it includes a computer-readable code, or a non-volatile computer-readable storage medium carrying a computer-readable code, and when the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the above-mentioned task processing method.
[0019] The task processing method provided by the embodiment of the present disclosure determines the type similarity between the task to be processed and the labeled sample based on the predicted type of the task to be processed and the labeled type of the labeled sample, determines the candidate sample based on the type similarity, and determines the semantic similarity between the task to be processed and the candidate sample based on the task semantics of the task to be processed and the sample semantics of the candidate sample. Since the target sample is determined based on both the type similarity and the semantic similarity, the target sample determined in this way is more accurate, and the task processing result determined by the first language model based on the target sample is more accurate.
[0020] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The accompanying drawings are used to provide a further understanding of the present disclosure and constitute a part of the specification. Together with the embodiments of the present disclosure, they are used to explain the present disclosure and do not constitute a limitation of the present disclosure. The above and other features and advantages will become more apparent to those skilled in the art by describing detailed example embodiments with reference to the accompanying drawings, in which:
[0022] Figure 1 A schematic diagram of prompt words provided in an embodiment of the present disclosure;
[0023] Figure 2 A flowchart of a task processing method provided by an embodiment of the present disclosure;
[0024] Figure 3 A schematic diagram of a prompt word template provided in an embodiment of the present disclosure;
[0025] Figure 4 A block diagram of a task processing device provided by an embodiment of the present disclosure;
[0026] Figure 5 A block diagram of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0027] In order to enable those skilled in the art to better understand the technical solutions of the present disclosure, the exemplary embodiments of the present disclosure are described below in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, those of ordinary skill in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0028] In the absence of conflict, the various embodiments of the present disclosure and the various features therein may be combined with each other.
[0029] As used herein, the term "and / or" includes any and all combinations of one or more of the associated listed items.
[0030] The terms used herein are only used to describe specific embodiments and are not intended to limit the present disclosure. As used herein, the singular forms "a" and "the" are also intended to include plural forms, unless the context clearly indicates otherwise. It will also be understood that when the terms "including" and / or "made of" are used in this specification, the presence of the features, wholes, steps, operations, elements and / or components is specified, but the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or groups thereof is not excluded. "Connected" or "connected" and similar words are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect.
[0031] Unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by those of ordinary skill in the art. It will also be understood that terms such as those defined in commonly used dictionaries should be interpreted as having a meaning consistent with their meaning in the context of the relevant art and the present disclosure, and will not be interpreted as having an idealized or overly formal meaning unless explicitly defined as such herein.
[0032] In the technical solution disclosed in this disclosure, the collection, storage, use, processing, transmission, provision and disclosure of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals. The use of user data in this technical solution complies with relevant national laws and regulations (for example, the "Information Security Technology Personal Information Security Specification", etc.). For example: corresponding prescribed measures are taken for personal information access control; prescribed restrictions are imposed on the display of personal information; the purpose of using personal information does not exceed the scope of direct or reasonable association; when using personal information, clear identity orientation is eliminated to avoid precise positioning of specific individuals.
[0033] Large language model (LLM): For ease of description, this disclosure will refer to large language models as large models. Large models are a natural language processing technology based on neural networks that can learn and predict the rules and patterns of natural language texts. Large models extract and learn knowledge through a large amount of corpus or images, and then generate models with complex parameters, which can be applied to natural language processing tasks such as text summarization, machine translation, sentiment analysis, etc.
[0034] Prompt: Prompts are texts used by people to communicate with the big model, and are used to guide the big model to generate processing results according to the user's needs. Prompts can include a simple instruction, or a task background introduction, several task reference samples, or an introduction to the task. Generally, the more detailed the prompt, the more comprehensive the big model's understanding of the task, and the more accurate the output task processing results.
[0035] Chain of Thoughts (CoT): Chain of Thoughts is a technology used to improve the reasoning ability of large models. It can guide large models to generate a series of reasoning steps to solve problems. Chain of Thought prompts can be understood as a high-level prompt. The reference samples in the Chain of Thought prompts include not only tasks and processing results, but also the intermediate reasoning process to obtain the processing results. Chain of Thoughts can also guide large models to use the reasoning process as part of the output results when generating task processing results, effectively improving the accuracy of large model output.
[0036] Role playing: Generally speaking, a large model can simulate a specific object to complete a specified task. The large model playing the specific object should have background knowledge and personality as close as possible to the real person (or preset virtual person) corresponding to the specific object, so that it can think, speak and act in the style of the specific object. In the present disclosure, the large model is brought into a virtual environment through the role to guide the large model to pay attention to the information in the prompt words.
[0037] The disclosed embodiment mentions four types of prompts, namely, zero-shot prompt, zero-shot CoT prompt, few-shot prompt, and few-shot CoT prompt. The sample can stimulate the thinking ability of the large model, making the output of the large model more accurate. The higher the relevance of the sample to the task to be processed, the more accurate the output of the large model.
[0038] The thinking chain can guide the logical reasoning process of the large model, and can guide the large model to output a more specific and structured intermediate reasoning process, thereby outputting more accurate task processing results, which include conclusions or solutions.
[0039] Among them, zero-sample prompt words refer to the prompt words input into the large model only have tasks to be processed, and there are no reference samples. The large model solves the tasks to be processed based on its own knowledge reserves. Figure 1 Figure a in the middle.
[0040] Zero-sample thought chain prompts refer to the prompts input into the large model, including the task to be processed and the way to output the task processing results. The information output by the large model includes the task processing results and the reasoning process (thought chain) for obtaining the task processing results. Figure 1 Figure b.
[0041] The few-sample prompt words refer to the prompt words input into the large model, including the task to be processed and the reference sample. The reference sample does not include the thought chain, and the output of the large model does not include the thought chain. Figure 1Figure c.
[0042] The few-sample thinking chain prompts refer to the prompts input into the large model, including the task to be processed, the reference sample, and the way to output the task processing results. Moreover, the reference sample has a thinking chain. Figure 1 Middle d figure.
[0043] For a new task, choosing a suitable target sample as a reference has a great impact on the accuracy of the large model output. Therefore, the related technology trains the first model q w And the second model The first model is used to acquire the skills in the reference sample, and the second model is used to acquire the skills required for the new task.
[0044] When training the first model q w And the second model Before that, a sample database is first constructed, in which each sample includes a task Q and a thinking chain R corresponding to the task Q.
[0045] The first model q w The sample (Q, R) can be mapped to the first characterization vector q w (z|Q,R), where z represents a vector and the first representation vector implicitly represents the skills required to implement the thought chain R in sample Q.
[0046] Second Model The new task can be mapped to the second representation vector π φ (z|Q), the second representation vector implicitly represents the skills required to solve the thinking chain corresponding to the new task.
[0047] When selecting a target sample, the first model is used to obtain a first characterization vector of each sample in the sample database to obtain a first characterization vector set.
[0048] z post = argmax z [q w (z|Q,R)]
[0049] The second model is used to obtain a second representation vector of the new task, thereby obtaining a second representation vector set.
[0050] z test = argmax z [π φ (z|Q)]
[0051] Based on the first characterization vector and the second characterization vector, the cosine similarity is used to retrieve the sample vector z from the sample database. testThe most similar preset number of samples are used as target samples, such as the top K samples with the highest similarity as target samples.
[0052] This method of determining the target sample based on the representation vector can improve the accuracy of the large model output to a certain extent, but this method only considers the skills and has blind spots, and cannot fully judge the similarity between the sample and the task to be processed. When obtaining the second representation vector, the atomic skills of the sample are used, but the decomposition granularity of the atomic skills is small. In the later judgment, it is easy to use incompetent samples as target samples, resulting in inaccurate output of the large model.
[0053] The present disclosure provides a task processing method, which can select appropriate target samples for the task to be processed, thereby improving the accuracy of large model output.
[0054] Figure 2 A flowchart of a task processing method provided by an embodiment of the present disclosure. Figure 2 As shown, the task processing method includes:
[0055] Step S101, based on the predicted type of the task to be processed and the labeled type of the labeled sample, determine the type similarity between the task to be processed and the labeled sample.
[0056] The predicted type is the result of predicting the task type of the task to be processed. The predicted type includes but is not limited to physics questions, chemistry questions, and mathematics questions.
[0057] In the disclosed embodiment, the prediction may be performed manually or by a pre-trained task type prediction model.
[0058] In some embodiments, the predicted type of the task to be processed is determined by the following steps, including: inputting the task to be processed into a trained task type prediction model; the task type prediction model outputs the predicted label value of the task to be processed; and determining the predicted type of the task to be processed based on the predicted label value.
[0059] The task type prediction model can output the predicted type of the task to be processed, and can also output the predicted label value, that is, the probability value that the task to be processed belongs to the predicted type, and then determine the predicted type of the task to be processed based on the predicted label value.
[0060] For example, the task type prediction model outputs the predicted types of tasks to be processed, including physics questions, mathematics questions, and chemistry questions, and the corresponding prediction label values 0.6, 0.3, and 0.1, that is, the probability value of the task to be processed belonging to a physics question is 0.6, the probability value of the task to be processed belonging to a mathematics question is 0.3, and the probability value of the task to be processed belonging to a chemistry question is 0.1. The type with the largest prediction label value can be determined as the predicted type, that is, the predicted type of the task to be processed can be predicted to be a physics question.
[0061] In some embodiments, the prediction type of the task to be processed may be more than one, that is, the prediction type may be two or more. Therefore, the first preset threshold may be used for judgment, that is, the prediction label value is compared with the first preset threshold, and the prediction type of the task to be processed is judged according to the comparison result.
[0062] In some embodiments, the predicted type of the task to be processed is determined based on the predicted label value, including: when the predicted label value is greater than or equal to a first preset threshold, determining that the task type of the task to be processed is the task type corresponding to the predicted label value; when the predicted label value is less than the first preset threshold, determining that the task to be processed does not belong to the task type corresponding to the predicted label value.
[0063] For example, the task type prediction model outputs predicted types of tasks to be processed, including physics questions, mathematics questions, and chemistry questions, and corresponding predicted label values 0.5, 0.5, and 0.0. Assuming that the first preset threshold is 0.4, since the predicted label value of the physics question and the predicted label value of the mathematics question are both greater than the first preset threshold, and the predicted label value of the chemistry question is less than the first preset threshold, the predicted types of the tasks to be processed are physics questions and mathematics questions.
[0064] In some embodiments, the task type prediction model is trained using training samples in a training database.
[0065] In some embodiments, the training database is obtained by the following steps:
[0066] The original samples, the inspiration samples and the correction samples are labeled to obtain the original labeled sample database, the inspiration labeled sample database and the correction labeled sample database; the labeled samples in the original labeled sample database, the inspiration labeled sample database and the correction labeled sample database are mixed to obtain the mixed labeled samples; a preset number of labeled samples are extracted from the mixed labeled samples to obtain the training database.
[0067] Among them, the native sample is the first language model LLM use Samples obtained based on the correct chain of thought. The first language model is not limited to the large model. Input the task into the first language model LLM use , the first language model LLM useOutput the task processing result. The task and the task processing result constitute the native sample.
[0068] It should be noted that the first language model LLM use If the thought chain for the task is correct, the output task processing result is also correct; or, if the thought chain is wrong, the output task processing result is also wrong. In the embodiment of the present disclosure, the sample with the correct thought chain and correct output result is taken as the original sample.
[0069] The heuristic sample is a sample obtained by the second language model based on the correct chain of thought. The second language model includes but is not limited to a large model, and the second language model is a language model different from the first language model. In other words, the heuristic sample and the native sample are samples obtained based on different language models.
[0070] The present invention discloses a second language model LLM n ,n∈[0,N-1] The samples whose thinking chain for the task is correct and whose output task processing results are correct are used as inspiration samples; the samples whose thinking chain is wrong and whose output task processing results are wrong cannot be used as inspiration samples.
[0071] The correction sample is a sample after correcting the task processing result obtained based on the erroneous thinking chain output by the first language model.
[0072] Correction samples can also be obtained through experts in related fields, that is, experts in related fields process the tasks and obtain corresponding task processing results. For example, for physics questions, experts in the physics field are asked to answer the tasks and obtain answers and thinking chains (solution ideas).
[0073] It should be noted that the first language model and the second language model can be either open source models or application programming interface (API) services.
[0074] In some embodiments, the original sample, the inspiring sample, and the corrected sample include a thought chain, which is a thought path for solving a task.
[0075] The original samples, the inspiration samples and the correction samples are labeled to obtain the original labeled sample database, the inspiration labeled sample database and the correction labeled sample database, including: obtaining the original labeled samples based on the original samples and the thinking chain of the original samples, and constructing the original labeled sample database based on the original labeled samples; obtaining the inspiration labeled samples based on the inspiration samples and the thinking chain of the inspiration samples, and constructing the inspiration labeled sample database based on the inspiration labeled samples; obtaining the correction labeled samples based on the correction samples and the thinking chain of the labeled samples, and constructing the correction labeled database based on the correction labeled samples.
[0076] The disclosed embodiment annotates native samples, inspired samples, and corrected samples through manual or existing annotation models, and the annotated content includes but is not limited to task type, thought chain (task processing ideas), and task processing results.
[0077] When building a native annotated sample database, you can build a native annotated sample database for different target domains. The target domain is the first language model LLM. use For business scenarios, we collect tasks that have appeared in the target field in the past and perform deduplication and other screening processes on these tasks to ensure that the native labeled samples in the native labeled sample database are usable samples.
[0078] For example, we collect K tasks in the target domain to form a task library D Q , D Q = {Q K}, Q K Indicates the Kth task, which is not a repeated task. Input the K tasks into the first language model LLM with zero-sample thinking chain or few-sample thinking chain prompt words use , obtain the task processing results of each task, including the thought chain of the task processing results represents the Kth task Q k The thought chain obtained using the first language model can be recorded as the thought chain Each task and the corresponding thinking chain constitute a first original sample, and all the first original samples are used to build the first original sample library. The first original sample library can be recorded as
[0079] Select the first original sample in the first original sample library, pick out the first original sample with the correct thinking chain, and obtain the original sample database Then the original sample database The original samples in (the first original sample selected is called the original sample) are labeled to obtain the original labeled sample database
[0080] In the embodiment of the present disclosure, the task type label system can be used to label the native samples in the native sample database, wherein the task type label system can be a label system summarized by experts in the target field. Each native sample in Label according to the thought chain to obtain the original labeled samples. Each original labeled sample in the original labeled sample database is represented as in, Indicates the probability that the kth label belongs to the ith task type. The value of each label is between 0 and 1, where 1 means it definitely belongs and 0 means it definitely does not belong. Each original sample can correspond to one or more labels.
[0081] The present disclosure can annotate native samples from multiple dimensions. For example, it can annotate from the first dimension, annotate as physics questions, mathematics questions, and chemistry questions; and / or, annotate from the second dimension, annotate as questions for the first grade of high school, questions for the second grade of high school, and questions for the third grade of high school.
[0082] In the embodiment of the present disclosure, the task library D Q The task in the second language model LLM is combined with zero-sample thinking chain or few-sample thinking chain prompt words n , obtain the task processing results of each task, including the thought chain of the task processing results represents the Kth task Q k The thought chain obtained using the second language model is recorded as the thought chain Each task and the corresponding thought chain constitute a second original sample, and all the second original samples are used to build a second original sample library. The second original sample library can be recorded as Where n represents the number of second language models.
[0083] Select the second original samples in the second original sample library, pick out the second original samples with the correct thinking chain, and obtain the inspiration sample database The inspiration sample is represented as Then the heuristic sample database The heuristic samples in (the second original sample selected is called the heuristic sample) are labeled to obtain the heuristic labeled sample database
[0084] In the embodiment of the present disclosure, the task type label system can also be used to label the inspiration samples in the inspiration sample database, that is, the task type label system can be used to label the inspiration sample database. Each heuristic sample in Label according to the thought chain to obtain the heuristic annotation samples. Each heuristic annotation sample in the heuristic annotation sample database is represented as in, Indicates the probability that the kth label belongs to the ith task type. Each label value ranges from 0 to 1, where 1 means it definitely belongs and 0 means it definitely does not belong. Each heuristic sample can correspond to one or more labels.
[0085] The present disclosure can annotate inspiration samples from multiple dimensions. For example, it can annotate from the first dimension, annotate as physics questions, mathematics questions, and chemistry questions; and / or, annotate from the second dimension, annotate as questions for the first grade of high school, questions for the second grade of high school, and questions for the third grade of high school.
[0086] The first original sample with the wrong thinking chain in the first original sample library is selected, and the thinking chain is corrected, and the corrected first original sample is used as the correction sample Constructing a calibration sample database Using the task type label system to calibrate the sample database Each calibration sample in Label according to the thought chain to obtain the corrected labeled samples. Corrected labeled sample database Each corrected annotation sample is represented as in, Indicates the probability that the kth label belongs to the ith task type. Each label value ranges from 0 to 1, where 1 means it definitely belongs and 0 means it definitely does not belong. Each calibration sample can correspond to one or more labels.
[0087] In the embodiment of the present disclosure, the task library D Q Task Q K Submit it to the corresponding experts to obtain the task processing results of each task, including the thought chain of the task processing results represents the Kth task Q k Each task and the corresponding chain of thought constitute a third original sample, and all the third original samples are used to build a third original sample library. The third original sample library can be recorded as Wherein, m represents the number of experts, and each expert can correspond to a third original sample library.
[0088] Select original samples from the third original sample library that have a thinking chain corresponding to the same problem and are different from the thinking chains of the first original sample and the second original sample to construct an inspiration sample, that is, the inspiration sample includes not only the first original sample selected from the first original sample, but also the original samples in the second original sample library and the third original sample library.
[0089] In some embodiments, the original samples, heuristic samples and corrected samples can also be manually annotated by multiple experts, and the annotated label value is determined according to the proportion of expert votes. The higher the expert proportion, the greater the annotated label value. For example, 5 experts vote on the annotated label value of an original sample. If 3 people think it is a physics problem and 2 people think it is a math problem, then the annotated label value of the original sample belonging to the physics problem is 0.6, and the annotated label value of the math problem is 0.4. The way experts annotate the heuristic samples and corrected samples is the same as the original samples, which will not be repeated here.
[0090] The present disclosure determines the type similarity between the task to be processed and the labeled sample based on the predicted type of the task to be processed and the labeled sample, and then classifies the task to be processed based on the type similarity.
[0091] In some embodiments, the prediction type includes prediction label values of multiple dimensions, and the annotation type includes annotation label values of multiple dimensions. For example, the prediction type includes prediction label values of the first dimension and the second dimension, and the annotation type is the same as the prediction type, and the annotation type includes the annotation label values of the first dimension and the second dimension. The first dimension may be a subject type, and the second type may be a grade.
[0092] Based on the predicted type of the task to be processed and the labeled type of the labeled sample, determine the type similarity between the task to be processed and the labeled sample, including: calculating the difference between the predicted label value and the labeled label value of the same dimension; when the difference is less than a preset second threshold, determine that the task to be processed and the sample are similar in dimension; determine the type similarity between the task to be processed and the labeled sample based on the number of similar dimensions.
[0093] Among them, the predicted label value can be obtained using a trained model, for example, the predicted label value of the task to be processed can be obtained using the BERT model. The labeled label value is a pre-labeled label value, and the pre-labeled label value can be a label value output by the BERT model and manually verified. The difference between the predicted label value and the labeled label value is calculated. When the difference is less than a preset second threshold, it is determined that the task to be processed and the sample are similar. The difference between the predicted label value and the labeled label value of multiple dimensions is calculated to obtain the similarity of the corresponding dimensions, and then the type similarity is judged based on the number of identical labels.
[0094] In some embodiments, the similarity between the task to be processed and the labeled sample is determined from multiple dimensions to obtain whether the task to be processed and the labeled sample are similar in each dimension, and then the type similarity is obtained based on the number of similar dimensions.
[0095] Assume that the second threshold is t i , the number of similar dimensions is Among them, d labelrepresents the number of similar dimensions, d label (L1,L2) represents the number of similar dimensions between the task to be processed L1 and the labeled sample L2. represents the predicted label value of the i-th task to be processed, Represents the label value of the i-th labeled sample. For any dimension, calculate the difference between the predicted label value of the task to be processed and the label value of the labeled sample Then with the second threshold t i Compare, if the difference Greater than the second threshold value is t i , it is determined that the type of the task to be processed is similar to that of the labeled sample; otherwise, it is determined that the type of the task to be processed is not similar to that of the labeled sample. After obtaining the type similarity judgment results of multiple dimensions, the degree of similarity between the type of the task to be processed and the labeled sample is determined based on the number of similar dimensions. The greater the number of similar dimensions, the more similar the type of the task to be processed is to the labeled sample.
[0096] For example, judging the task to be processed and the labeled sample from three dimensions, if the judgment result of the first dimension is similar, the judgment result of the second dimension is similar, and the judgment result of the third dimension is dissimilar, then the similarity between the task to be processed and the labeled sample is more than 60%. If the judgment result of the first dimension is similar, the judgment result of the second dimension is dissimilar, and the judgment result of the third dimension is dissimilar, then the similarity between the task to be processed and the labeled sample is only 30%.
[0097] In some embodiments, a pre-trained model is used to determine the task type. test Types The task to be processed is input into the task type model. The model first encodes the task to be processed, obtains the predicted label value, and then retrieves the native labeled sample database Obtain the type similarity of each natively labeled sample in the natively labeled sample database of the task to be processed.
[0098] Step S102: Based on the type similarity, candidate samples corresponding to the task to be processed are determined from the labeled samples.
[0099] According to the similarity of the type, from the native annotation sample database Determine candidate samples with similar types to the task to be processed, and build a candidate sample set based on the candidate samples
[0100] Step S103 , determining the semantic similarity between the task to be processed and the candidate sample according to the task semantics of the task to be processed and the sample semantics of the candidate sample.
[0101] In some embodiments, the semantic similarity between the task to be processed and the candidate samples is determined based on the task semantics of the task to be processed and the sample semantics of the candidate samples, including: using a feature coding model to obtain the semantic coding of the task to be processed and the semantic coding of the candidate samples; calculating the similarity between the task to be processed and the candidate samples based on the semantic coding of the task to be processed and the semantic coding of the candidate samples, to obtain the semantic similarity between the task to be processed and the candidate samples.
[0102] The disclosed embodiments do not limit the method for obtaining the semantic coding. For example, the Deberta-v2-xlarge coding model may be used to obtain the semantic coding of the task to be processed and the semantic coding of the candidate samples.
[0103] For example, the Deberta-v2-xlarge encoding model is used to perform semantic encoding on the task to be processed and the candidate samples to obtain the semantic encoding of the task to be processed and the semantic encoding of the candidate samples.
[0104] The disclosed embodiments do not limit the method for calculating the similarity between the task to be processed and the candidate sample. In some embodiments, the similarity between the task to be processed and the candidate sample is obtained by calculating the cosine distance or the Euclidean distance.
[0105] For example, the cosine distance d between the task to be processed and the candidate sample is calculated based on the semantic coding of the task to be processed and the semantic coding of the candidate sample. semantic , the semantic similarity between the task to be processed and the candidate sample is determined based on the cosine distance. The smaller the cosine distance, the more similar the task to be processed and the candidate sample; conversely, the less similar the task to be processed and the candidate sample are.
[0106] Step S104: determining a target sample corresponding to the task to be processed from the candidate samples based on type similarity and semantic similarity.
[0107] In some embodiments, a target sample corresponding to the task to be processed is determined from candidate samples based on type similarity and semantic similarity, including: multiplying the type similarity and the first weight value to obtain type enhanced similarity; multiplying the semantic similarity and the second weight value to obtain semantic enhanced similarity; adding the type enhanced similarity and the semantic enhanced similarity to obtain a total similarity; sorting the candidate samples based on the total similarity to obtain a sorting result; and determining a preset number of candidate samples ranked first in the sorting result as target samples.
[0108] The present disclosure performs weighted calculation on type similarity and semantic similarity to obtain total similarity. The first weight value λ1 and the second weight value λ2 can be preset, and the values of λ1 and λ2 are 0-1.
[0109] For example, total similarity = λ1d label+λ2d semantic .
[0110] Among them, λ1 represents the first weight value, λ2 represents the second weight value, and d label Indicates type similarity, d semantic Indicates semantic similarity.
[0111] After obtaining the total similarity between the task to be processed and the candidate samples, the candidate samples are sorted in descending order based on the total similarity to obtain the sorting result, and then the target sample is determined according to the sorting result.
[0112] The preset number may be an integer greater than or equal to 1.
[0113] For example, the top three candidate samples in the sorting result are taken as target samples.
[0114] In some embodiments, the candidate samples are from one or more databases of a native labeled sample database, a heuristic labeled sample database, and a corrected labeled sample database.
[0115] In the disclosed embodiment, candidate samples can be selected not only from the native labeled sample database, but also from the heuristic labeled sample database and the corrected labeled sample database. When selecting candidate samples from the native labeled sample database, the task to be processed is compared with the labeled samples in the native labeled sample database to obtain the target sample. When selecting candidate samples from the heuristic labeled sample database, the task to be processed is compared with the labeled samples in the heuristic labeled sample database to obtain the target sample. When selecting candidate samples from the corrected labeled sample database, the task to be processed is compared with the labeled samples in the corrected labeled sample database to obtain the target sample.
[0116] In some embodiments, the number of target samples can be preset. If the preset number of target samples can be determined in the native labeled sample database, the target samples are no longer selected from the heuristic labeled sample database and the corrected labeled sample database. If the preset number of target samples cannot be obtained from the native labeled sample database, the target samples are selected from the heuristic labeled sample database, and the target samples are not selected from the corrected labeled sample database. If the preset number of target samples cannot be obtained from the native labeled sample database and the heuristic labeled sample database, the target samples are selected from the corrected labeled sample database.
[0117] It should be noted that the method of selecting target samples from the heuristic labeled sample database and the corrected labeled sample database is the same as the method of selecting target samples from the native labeled sample database, which will not be repeated here.
[0118] It should also be noted that when selecting target samples from the native labeled sample database and the heuristic labeled sample database, the candidate samples selected from the native labeled sample database and the heuristic labeled sample database can be sorted as a whole based on the total similarity, and then the target sample is selected from the overall sorting result. When selecting target samples from the native labeled sample database, the heuristic labeled sample database, and the corrected labeled sample database, the candidate samples selected from the native labeled sample database, the heuristic labeled sample database, and the corrected labeled sample database can be sorted as a whole based on the total similarity, and then the target sample is selected from the overall sorting result.
[0119] Step S105 , based on the task to be processed and the target sample, using the first language model to obtain a task processing result of the task to be processed.
[0120] The embodiment of the present disclosure does not limit the first language model. For example, the first language model may be a known large language model.
[0121] In some embodiments, based on the task to be processed and the target sample, obtaining a task processing result of the task to be processed using the first language model includes: determining role information based on the first language model.
[0122] When using the first language model to obtain the processing results of the task to be processed, the model can be assigned a role and let the model process the task to be processed according to the role. This can make the model closer to the role's knowledge level, tendency to analyze problems, etc., making the model's output more accurate.
[0123] In some embodiments, the first language model determines the role information by randomly specifying or based on a target sample.
[0124] The present disclosure can randomly specify the role of the first language model, and the randomly specified role can be any role, such as elementary school students, middle school students, college students, etc., to further determine the role information. The role determined based on the target sample is closer to the task to be processed. For example, if the target sample is a high school question, then the role is determined to be a high school student.
[0125] Make the first language model play a role, and when there is a knowledge conflict, the first language model can stand in the role and choose the knowledge with the tendency. For example, the first language model already has the knowledge that the largest city in the world is City A, but recently it has been re-determined that City B is the largest city in the world. Obviously, there is a knowledge conflict between the first language model's existing knowledge and the current real largest city. At this time, if the first language model outputs the result based on the existing knowledge, it is definitely City A, and it is obvious that there is an error in the processing result. However, the role can make the first language model believe in the tendency of contextual knowledge when there is a knowledge conflict. When the target sample input to the first language model includes that the largest city in the world is City B, then the first language model will choose to believe the contextual knowledge based on the role and output that City B is the largest city in the world.
[0126] In some embodiments, the target sample and role information are input into the first language model by means of prompt words.
[0127] In some embodiments, constructing a prompt word based on a target sample and role information includes: embedding the target sample and role information in a preset prompt word template to obtain a prompt word, wherein the prompt word template includes an embedding position of the target sample and an embedding position of the role information.
[0128] The prompt word may have a fixed template, and different contents are placed in different positions. The present disclosure does not limit the prompt word template. For example, the target sample is placed behind the task to be processed, and the role information is placed at the front of the prompt word. The target sample and the role information are embedded in a fixed position.
[0129] Figure 3 A schematic diagram of a prompt word template provided by an embodiment of the present disclosure. Figure 3 As shown, the role information is placed at the front of the prompt word template. There can be multiple target samples, which are arranged from top to bottom. The tasks to be processed are placed below the target samples, closer to the task processing results, and finally the display position of the task processing results. When there are multiple target samples, multiple target samples are spliced together. When splicing, the higher the order, the closer to the position of the task to be processed.
[0130] In some embodiments, the prompt words include thought chains, which are thought prompt information used to obtain task processing results.
[0131] When there is a chain of thought in the target sample, the task processing result output by the first language model may include the chain of thought or may not include the chain of thought. When the target sample does not include the chain of thought, the task processing result output by the first language model may include the chain of thought or may not include the chain of thought.
[0132] The target sample input to the first language model may be one or more. In some embodiments, the target sample input to the first language model may be determined based on the context length of the first language model and the length of each target sample. When the length of the context of the first language model is longer, the number of target samples input to the first language model is larger; otherwise, it is smaller. When the length of the target sample is shorter, the number of target samples input to the first language model is larger; otherwise, it is smaller.
[0133] It can be understood that the above-mentioned various method embodiments mentioned in the present disclosure can be combined with each other to form a combined embodiment without violating the principle logic. Due to space limitations, the present disclosure will not repeat them. It can be understood by those skilled in the art that in the above-mentioned method of the specific implementation method, the specific execution order of each step should be determined according to its function and possible internal logic.
[0134] The task processing method provided by the embodiment of the present disclosure determines the type similarity between the task to be processed and the labeled sample based on the predicted type of the task to be processed and the labeled type of the labeled sample, determines the candidate sample based on the type similarity, and determines the semantic similarity between the task to be processed and the candidate sample based on the task semantics of the task to be processed and the sample semantics of the candidate sample. Since the target sample is determined based on both the type similarity and the semantic similarity, the target sample determined in this way is more accurate, and the task processing result determined by the first language model based on the target sample is more accurate.
[0135] Figure 4 A block diagram of a task processing device provided in an embodiment of the present disclosure.
[0136] Reference Figure 4 , an embodiment of the present disclosure provides a task processing device, the task processing device comprising:
[0137] A determination module 401 is used to determine the type similarity between the task to be processed and the labeled sample based on the predicted type of the task to be processed and the labeled sample;
[0138] The determination module 401 is further used to determine candidate samples corresponding to the task to be processed from the labeled samples based on type similarity;
[0139] The determination module 401 is further used to determine the semantic similarity between the task to be processed and the candidate sample according to the task semantics of the task to be processed and the sample semantics of the candidate sample;
[0140] The determination module 401 is further used to determine the target sample corresponding to the task to be processed from the candidate samples based on the type similarity and the semantic similarity;
[0141] The obtaining module 402 is used to obtain a task processing result of the task to be processed by using the first language model based on the task to be processed and the target sample.
[0142] In some embodiments, the acquisition module 402 is further used to determine role information based on the first language model; construct prompt words based on the target sample and the role information; input the task to be processed and the prompt words into the first language model; the first language model analyzes the task to be processed based on the prompt words and the role information to obtain the task processing result.
[0143] In some embodiments, the first language model determines the role information by randomly specifying or based on a target sample.
[0144] In some embodiments, the obtaining module 402 is further used to embed the target sample and the role information into a preset prompt word template to obtain the prompt word, and the prompt word template includes the embedding position of the target sample and the embedding position of the role information.
[0145] In some embodiments, the prompt words include thought chains, which are thought prompt information used to obtain task processing results.
[0146] In some embodiments, the task processing device also includes: an acquisition module, used to input the task to be processed into a trained task type prediction model; the task type prediction model outputs the predicted label value of the task to be processed; and determines the predicted type of the task to be processed based on the predicted label value.
[0147] In some embodiments, the acquisition module is also used to determine that the task type of the task to be processed is the task type corresponding to the predicted label value when the predicted label value is greater than or equal to the first preset threshold; and to determine that the task to be processed does not belong to the task type corresponding to the predicted label value when the predicted label value is less than the first preset threshold.
[0148] In some embodiments, the task type prediction model is trained using training samples in a training database, and the task processing further includes a training module for labeling native samples, heuristic samples, and corrected samples to obtain a native labeled sample database, an heuristic labeled sample database, and a corrected labeled sample database; the native samples are samples obtained by the first language model based on the correct thinking chain, the heuristic samples are samples obtained by the second language model based on the correct thinking chain, and the corrected samples are samples after correcting the task processing results output by the first language model based on the incorrect thinking chain; the labeled samples in the native labeled sample database, the heuristic labeled sample database, and the corrected labeled sample database are mixed to obtain mixed labeled samples; a preset number of labeled samples are extracted from the mixed labeled samples to obtain a training database.
[0149] In some embodiments, the original sample, the inspired sample, and the corrected sample include chains of thought;
[0150] The original samples, the inspired samples and the corrected samples are labeled to obtain the original labeled sample database, the inspired labeled sample database and the corrected labeled sample database, including:
[0151] Based on native samples and the thinking chain of native samples, native labeled samples are obtained, and a native labeled sample database is built based on the native labeled samples;
[0152] Based on the inspiration samples and the thinking chain of the inspiration samples, inspiration annotation samples are obtained, and based on the inspiration annotation samples, an inspiration annotation sample database is constructed;
[0153] Based on the thinking chain of the corrected samples and the labeled samples, the corrected labeled samples are obtained, and the corrected labeled database is constructed based on the corrected labeled samples.
[0154] In some embodiments, the prediction type includes prediction label values of multiple dimensions, and the annotation type includes annotation label values of multiple dimensions; the determination module 402 is also used to calculate the difference between the prediction label value and the annotation label value of the same dimension; when the difference is less than a preset second threshold, it is determined that the task to be processed and the sample are similar in dimension; based on the number of similar dimensions, the type similarity of the task to be processed and the annotated sample is determined.
[0155] In some embodiments, the determination module 402 is also used to obtain the semantic coding of the task to be processed and the semantic coding of the candidate samples using the feature coding model; calculate the similarity between the task to be processed and the candidate samples based on the semantic coding of the task to be processed and the semantic coding of the candidate samples, and obtain the semantic similarity between the task to be processed and the candidate samples.
[0156] In some embodiments, the similarity between the task to be processed and the candidate sample is obtained by calculating the cosine distance or the Euclidean distance.
[0157] In some embodiments, the determination module 402 is further used to multiply the type similarity and the first weight value to obtain the type enhanced similarity; multiply the semantic similarity and the second weight value to obtain the semantic enhanced similarity; add the type enhanced similarity and the semantic enhanced similarity to obtain the total similarity; sort the candidate samples based on the total similarity to obtain the sorting result; and determine a preset number of candidate samples ranked first in the sorting result as target samples.
[0158] In some embodiments, the candidate samples are from one or more databases of a native labeled sample database, a heuristic labeled sample database, and a corrected labeled sample database.
[0159] Each module in the above task processing device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.
[0160] In the task processing device provided by the embodiment of the present disclosure, the determination module determines the type similarity between the task to be processed and the labeled sample based on the predicted type of the task to be processed and the labeled type of the labeled sample, determines the candidate sample based on the type similarity, and determines the semantic similarity between the task to be processed and the candidate sample based on the task semantics of the task to be processed and the sample semantics of the candidate sample. Since the target sample is determined based on the two aspects of type similarity and semantic similarity, the target sample determined in this way is more accurate, and the task processing result determined by the first language model based on the target sample is more accurate.
[0161] Figure 5 A block diagram of an electronic device provided in an embodiment of the present disclosure.
[0162] Reference Figure 5 , an embodiment of the present disclosure provides an electronic device, which includes: at least one processor 501; at least one memory 502, and one or more I / O interfaces 503, connected between the processor 501 and the memory 502; wherein the memory 502 stores one or more computer programs that can be executed by the at least one processor 501, and the one or more computer programs are executed by the at least one processor 501, so that the at least one processor 501 can perform the following steps: based on the predicted type of the task to be processed and the annotation type of the annotation sample, determine the type similarity between the task to be processed and the annotation sample; based on the type similarity, determine the candidate sample corresponding to the task to be processed from the annotation sample; determine the semantic similarity between the task to be processed and the candidate sample according to the task semantics of the task to be processed and the sample semantics of the candidate sample; determine the target sample corresponding to the task to be processed from the candidate sample based on the type similarity and the semantic similarity; based on the task to be processed and the target sample, use the first language model to obtain the task processing result of the task to be processed.
[0163] The processor 501 is also used to determine role information based on the first language model; construct prompt words based on the target sample and the role information; input the task to be processed and the prompt words into the first language model; the first language model analyzes the task to be processed based on the prompt words and the role information to obtain a task processing result.
[0164] In some embodiments, the processor 501 is used to embed the target sample and the role information into a preset prompt word template to obtain a prompt word, where the prompt word template includes an embedding position of the target sample and an embedding position of the role information.
[0165] In some embodiments, the processor 501 is further used to input the task to be processed into a trained task type prediction model; the task type prediction model outputs a predicted label value of the task to be processed; and the predicted type of the task to be processed is determined based on the predicted label value.
[0166] In some embodiments, the processor 501 is also used to determine that the task type of the task to be processed is the task type corresponding to the predicted label value when the predicted label value is greater than or equal to the first preset threshold; when the predicted label value is less than the first preset threshold, determine that the task to be processed does not belong to the task type corresponding to the predicted label value.
[0167] In some embodiments, the prediction type includes prediction label values of multiple dimensions, and the annotation type includes annotation label values of multiple dimensions; the processor 501 is also used to calculate the difference between the prediction label value and the annotation label value of the same dimension; when the difference is less than a preset second threshold, it is determined that the task to be processed and the sample are similar in dimension; based on the number of similar dimensions, the type similarity of the task to be processed and the annotated sample is determined.
[0168] In some embodiments, the processor 501 is also used to obtain the semantic coding of the task to be processed and the semantic coding of the candidate samples using the feature coding model; calculate the similarity between the task to be processed and the candidate samples based on the semantic coding of the task to be processed and the semantic coding of the candidate samples, and obtain the semantic similarity between the task to be processed and the candidate samples.
[0169] In some embodiments, the processor 501 is also used to multiply the type similarity and the first weight value to obtain the type enhanced similarity; multiply the semantic similarity and the second weight value to obtain the semantic enhanced similarity; add the type enhanced similarity and the semantic enhanced similarity to obtain the total similarity; sort the candidate samples based on the total similarity to obtain the sorting result; determine a preset number of candidate samples ranked first in the sorting result as target samples.
[0170] Each module in the above electronic device can be implemented in whole or in part by software, hardware, or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.
[0171] The present disclosure also provides a computer-readable storage medium on which a computer program is stored, wherein the computer program implements the above-mentioned task processing method when executed by a processor / processing core. The computer-readable storage medium may be a volatile or non-volatile computer-readable storage medium.
[0172] The embodiment of the present disclosure also provides a computer program product, including a computer-readable code, or a non-volatile computer-readable storage medium carrying the computer-readable code. When the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the above-mentioned task processing method.
[0173] It will be appreciated by those skilled in the art that all or some of the steps, systems, and functional modules / units in the methods disclosed above may be implemented as software, firmware, hardware, and appropriate combinations thereof. In a hardware implementation, the division between the functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed by several physical components in cooperation. Some or all physical components may be implemented as software executed by a processor, such as a central processing unit, a digital signal processor, or a microprocessor, or may be implemented as hardware, or may be implemented as an integrated circuit, such as an application-specific integrated circuit. Such software may be distributed on a computer-readable storage medium, which may include a computer storage medium (or a non-transitory medium) and a communication medium (or a temporary medium).
[0174] As is known to those of ordinary skill in the art, the term computer storage media includes volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable program instructions, data structures, program modules or other data). Computer storage media include, but are not limited to, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), static random access memory (SRAM), flash memory or other memory technology, portable compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and can be accessed by a computer. In addition, it is known to those of ordinary skill in the art that communication media typically contain computer-readable program instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transmission mechanism, and may include any information delivery medium.
[0175] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to each computing / processing device, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network can include copper transmission cables, optical fiber transmissions, wireless transmissions, routers, firewalls, switches, gateway computers, and / or edge servers. The network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in the computer-readable storage medium in each computing / processing device.
[0176] The computer program instructions for performing the operation of the present disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-related instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages, such as Smalltalk, C++, etc., and conventional procedural programming languages, such as "C" language or similar programming languages. Computer-readable program instructions may be executed completely on a user's computer, partially on a user's computer, as an independent software package, partially on a user's computer, partially on a remote computer, or completely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., using an Internet service provider to connect via the Internet). In some embodiments, an electronic circuit, such as a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA), may be customized by utilizing the state information of the computer-readable program instructions, and the electronic circuit may execute the computer-readable program instructions, thereby realizing various aspects of the present disclosure.
[0177] The computer program product described herein may be implemented in hardware, software, or a combination thereof. In one optional embodiment, the computer program product is embodied as a computer storage medium, and in another optional embodiment, the computer program product is embodied as a software product, such as a software development kit (SDK), etc.
[0178] Various aspects of the present disclosure are described herein 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 disclosure. It should be understood that each box in the flowchart and / or block diagram and the combination of each box in the flowchart and / or block diagram can be implemented by computer-readable program instructions.
[0179] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, thereby producing a machine, so that when these instructions are executed by the processor of the computer or other programmable data processing device, a device that implements the functions / actions specified in one or more boxes in the flowchart and / or block diagram is generated. These computer-readable program instructions can also be stored in a computer-readable storage medium, and these instructions cause the computer, programmable data processing device, and / or other equipment to work in a specific manner, so that the computer-readable medium storing the instructions includes a manufactured product, which includes instructions for implementing various aspects of the functions / actions specified in one or more boxes in the flowchart and / or block diagram.
[0180] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device so that a series of operating steps are performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to implement the functions / actions specified in one or more boxes in the flowchart and / or block diagram.
[0181] The flow chart and block diagram in the accompanying drawings show the possible architecture, function and operation of the system, method and computer program product according to multiple embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a part of a module, program segment or instruction, and a part of the module, program segment or instruction includes one or more executable instructions for realizing the specified logical function. In some alternative implementations, the function marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two continuous square boxes can actually be executed substantially in parallel, and they can sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or action, or can be implemented with a combination of special hardware and computer instructions.
[0182] Example embodiments have been disclosed herein, and although specific terms are employed, they are used and should be interpreted only in a general illustrative sense and not for limiting purposes. In some instances, it will be apparent to those skilled in the art that, unless otherwise expressly noted, features, characteristics, and / or elements described in conjunction with a particular embodiment may be used alone or in combination with features, characteristics, and / or elements described in conjunction with other embodiments. Therefore, those skilled in the art will appreciate that various changes in form and detail may be made without departing from the scope of the present disclosure as set forth in the appended claims.
Claims
1. A task processing method, characterized in that: include: Based on the predicted type of the task to be processed and the labeled type of the labeled sample, determining the type similarity between the task to be processed and the labeled sample; Determining candidate samples corresponding to the task to be processed from the labeled samples based on the type similarity; Determining the semantic similarity between the task to be processed and the candidate sample according to the task semantics of the task to be processed and the sample semantics of the candidate sample; Determining a target sample corresponding to the task to be processed from the candidate samples based on the type similarity and the semantic similarity; Based on the task to be processed and the target sample, a task processing result of the task to be processed is obtained by using a first language model.
2. The method according to claim 1, characterized in that The step of obtaining a task processing result of the task to be processed by using a first language model based on the task to be processed and the target sample includes: determining role information based on the first language model; Constructing a prompt word based on the target sample and the role information; Inputting the task to be processed and the prompt word into the first language model; The first language model analyzes the task to be processed based on the prompt word and the role information to obtain a task processing result.
3. The method according to claim 2, characterized in that The first language model determines the role information by randomly specifying or based on the target sample.
4. The method according to claim 2, characterized in that: The constructing of prompt words based on the target sample and the role information includes: The target sample and the role information are embedded in a preset prompt word template to obtain the prompt word, wherein the prompt word template includes an embedding position of the target sample and an embedding position of the role information.
5. The method according to claim 2, characterized in that: The prompt words include a thought chain, and the thought chain is thought prompt information used to obtain the task processing result.
6. The method according to claim 1, characterized in that The prediction type of the task to be processed is determined by the following steps, including: Inputting the task to be processed into a trained task type prediction model; The task type prediction model outputs a predicted label value of the task to be processed; The prediction type of the task to be processed is determined based on the prediction label value.
7. The method according to claim 6, characterized in that The determining the prediction type of the task to be processed based on the prediction label value includes: When the predicted label value is greater than or equal to a first preset threshold, determining that the task type of the task to be processed is the task type corresponding to the predicted label value; When the predicted label value is less than a first preset threshold, it is determined that the task to be processed does not belong to the task type corresponding to the predicted label value.
8. The method according to claim 6, characterized in that The task type prediction model is trained by training samples in a training database, and the training database is obtained by the following steps: Labeling the native samples, the inspired samples and the corrected samples to obtain a native labeled sample database, an inspired labeled sample database and a corrected labeled sample database; the native samples are samples obtained by the first language model based on the correct thinking chain, the inspired samples are samples obtained by the second language model based on the correct thinking chain, and the corrected samples are samples obtained by correcting the task processing results output by the first language model based on the wrong thinking chain; Mixing the labeled samples in the native labeled sample database, the heuristic labeled sample database and the corrected labeled sample database to obtain a mixed labeled sample; A preset number of labeled samples are extracted from the mixed labeled samples to obtain the training database.
9. The method according to claim 8, characterized in that The original sample, the inspiring sample and the corrected sample include a thought chain; The labeling of the original samples, the inspired samples and the corrected samples to obtain the original labeled sample database, the inspired labeled sample database and the corrected labeled sample database includes: Obtaining a native annotated sample based on the native sample and the thought chain of the native sample, and constructing the native annotated sample database based on the native annotated sample; Obtaining inspiring annotation samples based on the inspiring samples and the thought chain of the inspiring samples, and constructing the inspiring annotation sample database based on the inspiring annotation samples; A corrected and annotated sample is obtained based on the thought chain of the corrected sample and the annotated sample, and the corrected and annotated database is constructed based on the corrected and annotated sample.
10. The method according to claim 6, characterized in that The prediction type includes prediction label values of multiple dimensions, and the annotation type includes annotation label values of multiple dimensions; The determining, based on the predicted type of the task to be processed and the labeled type of the labeled sample, the type similarity between the task to be processed and the labeled sample includes: Calculate the difference between the predicted label value and the marked label value of the same dimension; When the difference is less than a preset second threshold, determining that the task to be processed and the sample are similar in the dimension; The type similarity between the task to be processed and the labeled sample is determined based on the number of similar dimensions.
11. The method according to claim 1, characterized in that: The determining the semantic similarity between the task to be processed and the candidate sample according to the task semantics of the task to be processed and the sample semantics of the candidate sample includes: Using a feature coding model to obtain a semantic coding of the task to be processed and a semantic coding of the candidate sample; The similarity between the task to be processed and the candidate sample is calculated based on the semantic coding of the task to be processed and the semantic coding of the candidate sample to obtain the semantic similarity between the task to be processed and the candidate sample.
12. The method according to claim 11, characterized in that The similarity between the task to be processed and the candidate sample is obtained by calculating the cosine distance or the Euclidean distance.
13. The method according to claim 1, characterized in that The determining, from the candidate samples, a target sample corresponding to the task to be processed based on the type similarity and the semantic similarity comprises: Performing a multiplication operation on the type similarity and the first weight value to obtain type enhanced similarity; Performing a multiplication operation on the semantic similarity and the second weight value to obtain semantic enhanced similarity; Adding the type enhanced similarity and the semantic enhanced similarity to obtain a total similarity; Sorting the candidate samples based on the total similarity to obtain a sorting result; A preset number of candidate samples ranked first in the sorting result are determined as the target samples.
14. The method according to claim 13, characterized in that The candidate samples come from one or more databases among a native labeled sample database, an inspired labeled sample database, and a corrected labeled sample database.
15. A task processing device, characterized in that: include: A determination module, configured to determine the type similarity between the task to be processed and the labeled sample based on the predicted type of the task to be processed and the labeled sample; The determination module is further configured to determine, based on the type similarity, candidate samples corresponding to the task to be processed from the labeled samples; The determination module is further used to determine the semantic similarity between the task to be processed and the candidate sample according to the task semantics of the task to be processed and the sample semantics of the candidate sample; The determination module is further used to determine the target sample corresponding to the task to be processed from the candidate samples based on the type similarity and the semantic similarity; The obtaining module is used to obtain a task processing result of the task to be processed by using a first language model based on the task to be processed and the target sample.
16. An electronic device, characterized in that: include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores one or more computer programs that can be executed by the at least one processor, and the one or more computer programs are executed by the at least one processor to enable the at least one processor to perform the task processing method according to any one of claims 1 to 14.
17. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the computer program implements the task processing method according to any one of claims 1 to 14.
18. A computer program product, characterized in that The invention comprises a computer-readable code or a non-volatile computer-readable storage medium carrying the computer-readable code. When the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the task processing method as described in any one of claims 1 to 4.
Citation Information
Patent Citations
Question and answer pair matching method and device, electronic equipment and storage medium
CN112417096A
Artificial intelligence-based task prediction method and device, equipment and medium
CN115828153A
Data processing method and device, electronic equipment and storage medium
CN117370373A
Class prediction method, device and equipment based on large language model
CN117390497A
Text processing method and device, electronic equipment and computer readable storage medium
CN118094240A
Cited By
Model task classification method and device, model selection method and electronic equipment
CN121093185A
