Task processing method and device, electronic equipment and computer readable storage medium
By using multiple prompts to template and jointly decode the input text, the problem of unstable model performance in natural language processing tasks is solved, and the accuracy and robustness of task processing are improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING BAIDU NETCOM SCI & TECH CO LTD
- Filing Date
- 2022-12-30
- Publication Date
- 2026-07-14
Smart Images

Figure CN116384360B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of artificial intelligence technology, and more particularly to the field of NLP (Natural Language Processing). Background Technology
[0002] Today, the field of natural language processing is moving towards the era of ultra-large-scale models. By using supercomputing power to train ultra-large parameter models on massive amounts of text data, the resulting language models can have general semantic understanding capabilities for multi-task and few-sample learning. In other words, the same language model can perform well for different NLP tasks.
[0003] In downstream applications, specifically when facing specific NLP tasks, prompts related to the NLP task can be constructed to guide the model in completing the task. To improve the accuracy and robustness of NLP task processing results, related technologies focus on how to construct better task prompts. Summary of the Invention
[0004] This disclosure provides a task processing method, apparatus, electronic device, and computer-readable storage medium.
[0005] According to one aspect of this disclosure, a task processing method is provided, comprising:
[0006] Obtain the input text for the target task;
[0007] Based on multiple preset prompts, the input text is templated to obtain multiple texts to be completed;
[0008] Based on a preset model, multiple texts to be completed are processed to obtain model output information for completing multiple texts to be completed;
[0009] Based on the model's output information, the processing results of the target task are obtained.
[0010] According to another aspect of this disclosure, a task processing apparatus is provided, comprising:
[0011] The task input module is used to obtain the input text of the target task;
[0012] The prompt processing module is used to template the input text based on multiple preset prompts to obtain multiple texts to be completed;
[0013] The model processing module is used to process multiple texts to be completed based on a preset model, and obtain model output information for completing multiple texts to be completed.
[0014] The task output module is used to obtain the processing results of the target task based on the model output information.
[0015] According to another aspect of this disclosure, an electronic device is provided, comprising:
[0016] At least one processor; and
[0017] The memory is communicatively connected to the at least one processor; wherein,
[0018] The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform any of the methods described in the present disclosure.
[0019] According to another aspect of this disclosure, a non-transitory computer-readable storage medium is provided storing computer instructions, wherein the computer instructions are used to cause the computer to perform any of the methods according to embodiments of this disclosure.
[0020] According to another aspect of this disclosure, a computer program product is provided, including a computer program that, when executed by a processor, implements any of the methods according to embodiments of this disclosure.
[0021] The technical solution of this disclosure uses prompts to template the input text, resulting in multiple texts to be completed. This transforms the processing of the target task into having a preset model output model output information that can be used to complete the texts to be completed, and the processing result of the target task is obtained based on the model output information. Because this technical solution uses multiple prompts to template the input text of the target task into multiple texts to be completed, the model can combine multiple texts to be completed for joint decoding, avoiding the instability of model performance caused by a single prompt, thereby improving the accuracy and robustness of the NLP task processing results.
[0022] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description
[0023] The accompanying drawings are provided to better understand this solution and do not constitute a limitation of this disclosure. Wherein:
[0024] Figure 1 This is a schematic diagram of a cluster processing scenario according to an embodiment of the present disclosure;
[0025] Figure 2 This is a schematic flowchart of a task processing method provided in an embodiment of this disclosure;
[0026] Figure 3This is a schematic diagram illustrating an application example of the task processing method according to an embodiment of the present disclosure;
[0027] Figure 4 This is a schematic block diagram of a task processing apparatus provided in an embodiment of the present disclosure;
[0028] Figure 5 This is a schematic block diagram of a task processing apparatus provided in another embodiment of the present disclosure;
[0029] Figure 6 This is a block diagram of an electronic device used to implement the task processing method of the embodiments of this disclosure. Detailed Implementation
[0030] The exemplary embodiments of this disclosure are described below with reference to the accompanying drawings, including various details of the embodiments to aid understanding, and should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope of this disclosure. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.
[0031] According to embodiments of this disclosure, a task processing method is provided. This method can be applied to a task processing device, which can be deployed in a terminal, server, or other processing device within a single-machine, multi-machine, or cluster system. For example, Figure 1 A schematic diagram of a cluster processing scenario according to an embodiment of this disclosure is shown. This disclosure is not limited to NLP task processing on a single machine or multiple machines; cluster processing can further improve the stability of NLP task processing. Figure 1 As shown, the cluster system includes multiple nodes (such as server 101, server 102, server 103, server 104, and server 105; server 105 can also connect to user devices, such as mobile phone 1051 and desktop computer 1052). Multiple nodes, as well as multiple nodes and connected user devices, can jointly execute one or more NLP tasks.
[0032] Figure 2 A flowchart illustrating a task processing method provided in an embodiment of this disclosure is shown. Figure 2 As shown, the method may include:
[0033] Step S210: Obtain the input text of the target task;
[0034] Step S220: Based on multiple preset prompts, the input text is templated to obtain multiple texts to be completed;
[0035] Step S230: Process multiple texts to be completed based on a preset model to obtain model output information for completing multiple texts to be completed;
[0036] Step S240: Based on the model output information, obtain the processing result of the target task.
[0037] For example, in this embodiment of the disclosure, the target task can be a natural language processing (NLP) task. For instance, the target task can be a text classification task, a sentiment analysis task, a translation task, a question answering task, etc.
[0038] The input text for a target task can take different forms depending on the task type. For example, if the target task is a text classification task, sentiment analysis task, or translation task, the input text may include a text description; if the target task is a question-and-answer task, the input text may include a text description and a question.
[0039] This disclosure embodiment processes the target task based on a prompt-based learning approach. Prompt-based learning refers to templatening the input text based on preset prompts to obtain the text to be completed, thereby transforming the target task into having a preset model complete the text to be completed, that is, transforming the target task into a task where the preset model performs cloze tests or text continuation to complete the text.
[0040] For example, in a sentiment analysis task, the input text may include a text description, and a pre-set prompt may include "I feel...". Using this prompt, the input text can be templated into the form "text description + I feel...". For instance, if the text description is "I missed the bus again today," then based on the prompt, this text description can be templated into the text to be completed: "I missed the bus again today, I feel..." where the ellipsis indicates the position to be completed. This text to be completed is input into a pre-set model, which processes it and outputs the text at the position to be completed, such as "frustrated" or "annoyed." In this way, the pre-set model completes the sentiment analysis task by continuing the text to be completed, and the model's output can be directly used as the processing result of the target task.
[0041] According to step S220 above, in this embodiment of the disclosure, multiple prompts can be preset, thereby templated into multiple texts to be completed for the target task. Based on this, according to step S230 above, a preset model processes the multiple texts to be completed, obtaining model output information that can be used to complete the multiple texts; according to step S240 above, the model output information is used as the processing result of the target task. Specifically, if the multiple texts to be completed include a first text to be completed and a second text to be completed, the model output information obtained by the preset model can complete both the first and second texts to be completed, that is, the preset model outputs uniform content for the multiple texts to be completed, which is used as the processing result of the target task.
[0042] For example, in the sentiment analysis task example above where the input text is "I missed the bus again today", multiple prompts can include "I feel" and "I feel very", etc., which will result in two texts to be completed: "I missed the bus again today, I feel..." and "I missed the bus again today, I feel very...". The preset model combines the two texts to be completed and outputs the same result, which can be used as the processing result of this sentiment analysis task.
[0043] Since the task processing method in this embodiment uses multiple prompts to template the input text of the target task into multiple texts to be completed, the model can combine multiple texts to be completed for joint decoding, avoiding the instability of the model effect caused by the bias of a single prompt, thereby improving the accuracy and robustness of the processing results of NLP tasks.
[0044] In an exemplary embodiment, step S230, processing the plurality of texts to be completed based on a preset model to obtain model output information for completing the plurality of texts to be completed, includes: inputting the plurality of texts to be completed into the preset model; and in the preset model, fusing the prediction results of a plurality of single prompts corresponding to the plurality of texts to be completed to obtain the model output information.
[0045] The single-hint prediction result refers to the prediction result for the text to be completed corresponding to a single hint. Specifically, for each text to be completed, the preset model can obtain a corresponding single-hint prediction result. Based on this, for multiple texts to be completed, the preset model can obtain multiple single-hint prediction results.
[0046] In this implementation method, the preset model predicts the text at each completion position for each text to be completed, obtaining a single-hint prediction result for each text to be completed. The model output information is obtained by fusing multiple single-hint prediction results. In this way, single-hint prediction results can be obtained by combining existing model processing methods, thereby effectively utilizing existing model processing methods to further improve model performance and enhance the accuracy and robustness of NLP task processing results.
[0047] In an exemplary implementation, the model output information may include the joint prediction result of each of the N characters, where N is an integer greater than or equal to 2. In the preset model, fusing the multiple single-hint prediction results corresponding to the multiple texts to be completed to obtain the model output information may include: in the preset model, for the t-th character among the N characters, based on the joint prediction results of each text to be completed and the first t-1 characters among the N characters, obtaining multiple single-hint prediction results for the t-th character; fusing the multiple single-hint prediction results for the t-th character to obtain the joint prediction result for the t-th character. Where t is a positive integer less than or equal to N.
[0048] It should be noted that N can be a pre-set value or not a fixed value. That is, depending on the actual situation of the target task, the model can output model output information with different numbers of words.
[0049] According to the above implementation method, the preset model predicts each character individually. For example, the preset model first predicts the first character based on the start character and each piece of text to be completed, obtaining individual prediction results for the first character, and then fusing them to obtain a joint prediction result for the first character. Then, for the second character, the preset model predicts the second character based on the first character and each piece of text to be completed, obtaining individual prediction results for the second character, and then fusing them to obtain a joint prediction result for the second character. This process continues, and joint prediction results for multiple characters can be obtained, which are then combined to form the model's output information.
[0050] According to this exemplary implementation, the preset model integrates multiple single-cue prediction results character by character. That is, when predicting a character, it combines other characters previously predicted based on multiple cues for prediction. Therefore, it can give full play to the role of multiple cues and further improve the accuracy and robustness of the processing results of NLP tasks.
[0051] In an exemplary embodiment, the multiple single - hint prediction results of the t - th character include the multiple single - hint prediction probabilities that the t - th character is the j - th character in a character set. That is, for the t - th character, the prediction model respectively obtains multiple single - hint prediction probabilities for each character in the character set. Correspondingly, fusing the multiple single - hint prediction results of the t - th character to obtain the joint prediction result of the t - th character includes: obtaining the joint prediction probability that the t - th character is the j - th character based on the average value or weighted average value of the multiple single - hint prediction probabilities; and obtaining the joint prediction result of the t - th character based on the joint prediction probability that the t - th character is the j - th character. Here, j is an integer greater than or equal to 1.
[0052] Among them, the j - th character in the character set can represent each character in the character set. That is, for each character in the character set, based on multiple texts to be completed, single - hint prediction probabilities are respectively predicted, and then averaged or weighted averaged to obtain the final probability (i.e., the joint prediction probability) of this character as the t - th character in the model output information. Combining the joint prediction probabilities that the t - th character is each character in the character set, the joint prediction result of the t - th character can be obtained. For example, the character with the highest joint prediction probability is taken as the joint prediction result of the t - th character.
[0053] For example, the character set includes the characters '今' and '天'. For the t - th character, the preset model will obtain the probability that the t - th character is '今' and the probability that the t - th character is '天'. Specifically, the preset model obtains multiple single - hint prediction probabilities that the t - th character is '今' for the t - th character and multiple texts to be completed, and obtains multiple single - hint prediction probabilities that the t - th character is '天'. Then, the preset model combines the multiple single - hint prediction probabilities that the t - th character is '今' to obtain the joint prediction probability that the t - th character is '今', and combines the multiple single - hint prediction probabilities that the t - th character is '天' to obtain the joint prediction probability that the t - th character is '天'. Then, the preset model selects the character with the largest joint prediction probability from the character set as the joint prediction result of the t - th character.
[0054] Exemplarily, define the input sample as x, and the multiple hints collected correspond to the hint set P = {P i (·)|i ∈ [1,M]}. Then, for the t - th character in the model output information, the probabilities of each character in the character set are:
[0055]
[0056] Among them, P i (x,u <t ) represents the prediction result y before the t - th character for the input x<t Using prompt P i (·) is used for template creation. That is, p(y) t │P i (x,y <t )) indicates that in the prompt P i Under the influence of (·), the prediction result y of the t-th character t The probability of a given character (the prediction probability of a single prompt) is used to average the probabilities of that character across multiple prompts to obtain the prediction result y. t This represents the final probability (joint prediction probability) of a given character. Alternatively, it can be a weighted average based on the accuracy on the validation set for each prompt.
[0057] According to the above implementation method, by calculating the prediction probability of each character in the character set, accurate model output information can be obtained, thereby further improving the accuracy and robustness of the processing results of NLP tasks.
[0058] Optionally, in some embodiments of this disclosure, the first prompt among a plurality of prompts includes a soft prompt for characterizing the task type of the target task, and / or a hard prompt for rewriting the input text according to a corresponding template.
[0059] The first cue can be any one of multiple cue options. In other words, a cue can consist of soft cues and hard cues. Soft cues indicate the task type, such as sentiment analysis or question-answering, while hard cues are used to rewrite the input text according to the objective.
[0060] For example, in a question-and-answer task, the input text can include a binary pair consisting of a text description and a question. A pre-defined hint can include a soft hint "QA (Question-and-Answer Task)" and hard hints "Please tell me" and "The answer is...". Using this hint, the input text can be templated into the form "QA: Text description + Please tell me + Question + Answer is...". For instance, if the input text includes the text description "The passport is in the wardrobe, and the property certificate is in the wardrobe" and the question "Where is the passport?", then based on the pre-defined hint, the input text can be templated into "QA: The passport is in the wardrobe, and the property certificate is in the wardrobe. Please tell me, where is the passport? The answer is...".
[0061] Furthermore, another preset prompt can consist of only hard prompts "Please ask" and "Answer:", which can be used to template the input text into the form of "text description + Please ask + Question + Answer: ...".
[0062] As can be seen, the above optional methods can enrich the implementation of multiple prompts. At the same time, soft prompts can be used to guide the preset model to take advantage of the commonalities and characteristics between different tasks, thereby further improving the processing effect of the model and correspondingly improving the accuracy and robustness of the processing results of NLP tasks.
[0063] To more clearly demonstrate the effects of the embodiments of this disclosure, a specific application example is provided below. Figure 3 A schematic diagram of an application example is shown. (For example...) Figure 3 As shown, taking the construction and output results of two different prompts as an example, two prompts are pre-set for the QA task. The first prompt includes a soft prompt 311 (QA, indicating a question-and-answer task) and a hard prompt 312 (question + answer); the second prompt includes a hard prompt 320 (ask + answer). The soft prompt contains task-related knowledge. The hard prompt connects the structured input (description text + question) pairs using natural language, which is more consistent with the pre-training paradigm and thus better guides the pre-set model 330 to complete the reading comprehension task. Block 340 represents the prediction result, with the prediction result of 3 characters as an example. The prediction result for each character includes two columns: the first column is the prediction result based on the first prompt, and the second column is the prediction result based on the second prompt. The higher the position of the character in block 340, the higher the probability of that character, i.e., the higher the confidence level. E represents the end-of-character marker.
[0064] Assuming a single prompt is used, if the first prompt is adopted, the model receives the text to be completed corresponding to the first prompt and will produce a redundant result "Wardrobe question: Where is the passport?" (The first three characters "Wardrobe asks" are used as an example in the figure). If the second prompt is adopted, the model receives the text to be completed corresponding to the second prompt and will produce an incorrect result "Property certificate". Using the embodiment of this disclosure, the probability of the prediction results of each step of the two texts to be completed constructed by the above two prompts is fused, the character with the highest confidence is selected, and the process is repeated until the end symbol E, which will produce a unique correct answer: Wardrobe.
[0065] As can be seen, since the technical solution of this disclosure uses multiple prompts to template the input text of the target task into multiple texts to be completed, the model can combine multiple texts to be completed for joint decoding, avoiding the instability of the model effect caused by a single prompt, thereby improving the accuracy and robustness of the processing results of the NLP task.
[0066] According to embodiments of this disclosure, a task processing apparatus is also provided. Figure 4 A schematic block diagram of a task processing apparatus provided according to an embodiment of the present disclosure is shown. Figure 4As shown, the device may include:
[0067] The task input module 410 is used to obtain the input text of the target task;
[0068] The prompt processing module 420 is used to template the input text based on multiple preset prompts to obtain multiple texts to be completed;
[0069] The model processing module 430 is used to process the multiple texts to be completed based on a preset model to obtain model output information for completing the multiple texts to be completed.
[0070] The task output module 440 is used to output information based on the model to obtain the processing result of the target task.
[0071] Figure 5 A schematic block diagram of a task processing apparatus provided in another embodiment of this disclosure is shown. Figure 5 As shown, in the task processing device, the model processing module may include:
[0072] Input unit 510 is used to input the plurality of texts to be completed into the preset model;
[0073] The fusion processing unit 520 is used to fuse multiple single prompt prediction results corresponding to the multiple texts to be completed in the preset model to obtain the model output information.
[0074] For example, the model output information includes the joint prediction result for each of the N characters. Accordingly, the fusion processing unit 520 is specifically used for:
[0075] In the preset model, for the t-th character among the N characters, based on the joint prediction results of each of the multiple texts to be completed and the first t-1 characters among the N characters, multiple single prompt prediction results for the t-th character are obtained;
[0076] The multiple single-hint prediction results of the t-th character are fused to obtain the joint prediction result of the t-th character.
[0077] For example, the multiple single-hint prediction results for the t-th character include multiple single-hint prediction probabilities that the t-th character is the j-th character in the character set. Accordingly, the fusion processing unit 520 is specifically used for:
[0078] Based on the average or weighted average of the multiple single-hint prediction probabilities, the joint prediction probability that the t-th character is the j-th character is obtained;
[0079] Based on the joint prediction probability that the t-th character is the j-th character, the joint prediction result of the t-th character is obtained.
[0080] Optionally, the first of the plurality of prompts includes a soft prompt for characterizing the task type of the target task, and / or a hard prompt for rewriting the input text according to a corresponding template.
[0081] The specific functions and examples of each module and submodule of the apparatus in this disclosure can be found in the relevant descriptions of the corresponding steps in the above method embodiments, and will not be repeated here.
[0082] The acquisition, storage, and application of user personal information involved in the technical solution disclosed herein comply with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0083] According to embodiments of this disclosure, this disclosure also provides an electronic device, a readable storage medium, and a computer program product.
[0084] Figure 6 A schematic block diagram of an example electronic device 600 that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0085] like Figure 6 As shown, device 600 includes a computing unit 601, which can perform various appropriate actions and processes based on a computer program stored in read-only memory (ROM) 602 or a computer program loaded from storage unit 608 into random access memory (RAM) 603. RAM 603 may also store various programs and data required for the operation of device 600. The computing unit 601, ROM 602, and RAM 603 are interconnected via bus 604. Input / output (I / O) interface 605 is also connected to bus 604.
[0086] Multiple components in device 600 are connected to I / O interface 605, including: input unit 606, such as keyboard, mouse, etc.; output unit 607, such as various types of monitors, speakers, etc.; storage unit 608, such as disk, optical disk, etc.; and communication unit 609, such as network card, modem, wireless transceiver, etc. Communication unit 609 allows device 600 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0087] The computing unit 601 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 601 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 601 performs the various methods and processes described above, such as task processing methods. For example, in some embodiments, the task processing method may be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 608. In some embodiments, part or all of the computer program may be loaded and / or installed on device 600 via ROM 602 and / or communication unit 609. When the computer program is loaded into RAM 603 and executed by the computing unit 601, one or more steps of the task processing method described above may be performed. Alternatively, in other embodiments, the computing unit 601 may be configured to perform task processing methods by any other suitable means (e.g., by means of firmware).
[0088] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0089] The program code used to implement the methods of this disclosure may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing apparatus, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0090] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0091] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor); and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0092] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as a data server), or computing systems that include middleware components (e.g., an application server), or computing systems that include frontend components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with embodiments of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., a communication network). Examples of communication networks include local area networks (LANs), wide area networks (WANs), and the Internet.
[0093] Computer systems can include clients and servers. Clients and servers are generally located far apart and typically interact via communication networks. Client-server relationships are created by computer programs running on the respective computers and having a client-server relationship with each other. Servers can be cloud servers, servers in distributed systems, or servers incorporating blockchain technology.
[0094] It should be understood that the various forms of processes shown above can be used to rearrange, add, or delete steps. For example, the steps described in this disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution disclosed in this disclosure can be achieved, and this is not limited herein.
[0095] The specific embodiments described above do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the principles of this disclosure should be included within the scope of protection of this disclosure.
Claims
1. A task processing method, comprising: Obtain the input text for the target task; The input text is templated based on multiple preset prompts to obtain multiple texts to be completed; The multiple texts to be completed are processed based on a preset model to obtain model output information for completing the multiple texts to be completed; Based on the model output information, the processing result of the target task is obtained; The step of processing the plurality of texts to be completed based on a preset model to obtain model output information for completing the plurality of texts to be completed includes: Input the multiple texts to be completed into the preset model; In the preset model, the prediction results of multiple single prompts corresponding to the multiple texts to be completed are fused to obtain the model output information.
2. The method according to claim 1, wherein, The model output information includes the joint prediction result of each of the N characters, where N is an integer greater than or equal to 2; In the preset model, the prediction results of multiple single prompts corresponding to the multiple texts to be completed are fused to obtain the model output information, including: In the preset model, for the t-th character among the N characters, based on the joint prediction results of each of the multiple texts to be completed and the first t-1 characters among the N characters, multiple single-hint prediction results for the t-th character are obtained; where t is a positive integer less than or equal to N; The multiple single-hint prediction results of the t-th character are fused to obtain the joint prediction result of the t-th character.
3. The method according to claim 2, wherein, The multiple single-hint prediction results for the t-th character include the multiple single-hint prediction probabilities for the t-th character being the j-th character in the character set, where j is an integer greater than or equal to 1; The process of fusing multiple single-hint prediction results for the t-th character to obtain a joint prediction result for the t-th character includes: Based on the average or weighted average of the multiple single-hint prediction probabilities, the joint prediction probability that the t-th character is the j-th character is obtained; Based on the joint prediction probability that the t-th character is the j-th character, the joint prediction result of the t-th character is obtained.
4. The method according to any one of claims 1-3, wherein, The first of the multiple prompts includes a soft prompt for characterizing the task type of the target task, and / or a hard prompt for rewriting the input text according to the corresponding template.
5. A task processing apparatus, comprising: The task input module is used to obtain the input text of the target task; The prompt processing module is used to template the input text based on multiple preset prompts to obtain multiple texts to be completed; The model processing module is used to process the multiple texts to be completed based on a preset model to obtain model output information for completing the multiple texts to be completed. The task output module is used to output information based on the model to obtain the processing result of the target task; The model processing module includes: The input unit is used to input the plurality of texts to be completed into the preset model; The fusion processing unit is used to fuse multiple single prompt prediction results corresponding to the multiple texts to be completed in the preset model to obtain the model output information.
6. The apparatus according to claim 5, wherein, The model output information includes the joint prediction result of each of the N characters, where N is an integer greater than or equal to 2; The fusion processing unit is used for: In the preset model, for the t-th character among the N characters, based on the joint prediction results of each of the multiple texts to be completed and the first t-1 characters among the N characters, multiple single-hint prediction results for the t-th character are obtained; where t is a positive integer less than or equal to N; The multiple single-hint prediction results of the t-th character are fused to obtain the joint prediction result of the t-th character.
7. The apparatus according to claim 6, wherein, The multiple single-hint prediction results for the t-th character include the multiple single-hint prediction probabilities for the t-th character being the j-th character in the character set; j is an integer greater than or equal to 1; The fusion processing unit is used for: Based on the average or weighted average of the multiple single-hint prediction probabilities, the joint prediction probability that the t-th character is the j-th character is obtained; Based on the joint prediction probability that the t-th character is the j-th character, the joint prediction result of the t-th character is obtained.
8. The apparatus according to any one of claims 5-7, wherein, The first of the multiple prompts includes a soft prompt for characterizing the task type of the target task, and / or a hard prompt for rewriting the input text according to the corresponding template.
9. An electronic device, comprising: At least one processor; as well as A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-4.
10. A non-transitory computer-readable storage medium storing computer instructions, wherein, The computer instructions are used to cause the computer to perform the method according to any one of claims 1-4.
11. A computer program product comprising a computer program that, when executed by a processor, implements the method according to any one of claims 1-4.