Data processing method and related equipment
By receiving the user's first prompt data in a large language model, generating multiple candidate results, and updating the prompt data when there is a large difference, the problem of users' difficulty in writing clear prompt words is solved, and the code that is more in line with expectations is generated.
Patent Information
- Application Number
- CN202311251097.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-26
- Publication Date
- 2025-03-28
AI Technical Summary
Without modifying the large language model, how to generate code that meets expectations based on prompt words entered by the user, especially when it is difficult for the user to write clear prompt words.
By receiving the first prompt data from the user, multiple candidate results are obtained based on the neural network. If the difference between the candidate results is greater than or equal to a certain threshold, the first prompt data is updated to generate the second prompt data, and the output result of the second prompt data is continued to be obtained based on the neural network.
Update the user's input prompts through the differences in multiple candidate results, making the updated prompts clearer, thus making the output results generated by the neural network more in line with expectations.
Smart Images

Figure CN119719262A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of artificial intelligence, and in particular, to a data processing method and related equipment. Background Art
[0002] Artificial intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a branch of computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Artificial intelligence is also the study of the design principles and implementation methods of various intelligent machines, so that machines have the functions of perception, reasoning and decision-making. Research in the field of artificial intelligence includes robotics, natural language processing, computer vision, decision-making and reasoning, human-computer interaction, recommendation and search, basic AI theory, etc.
[0003] Taking the code generation task applied to the large language model (LLM) as an example, the user provides a task described in natural language (also called a prompt word) and sends it to the large model. The LLM completes the code generation task based on the received prompt word and returns the generated code to the user. In many scenarios, users do not understand LLM and find it difficult to write appropriate and clear prompt words, which makes the quality of the code generated by LLM poor.
[0004] Therefore, how to generate expected code based on the prompt words input by the user without modifying the LLM is a technical problem that needs to be solved urgently. Summary of the invention
[0005] The embodiments of the present application provide a data processing method and related equipment, which can update the user's input prompt by the difference between multiple candidate results, so that the updated prompt is clearer, so that the neural network can generate output results that are more in line with expectations.
[0006] The first aspect of the embodiment of the present application provides a data processing method that can be applied to a large model reasoning scenario. The method can be executed by a data processing device, or by a component of the data processing device (such as a processor, a chip, or a chip system, etc.). In this method, a first prompt data input by a user is received; a candidate result collection of the first prompt data is obtained based on a neural network, and the candidate result collection includes multiple candidate results; if the difference between the multiple candidate results is greater than or equal to a first threshold, the first prompt data is updated based on the multiple candidate results to obtain the second prompt data; the output result of the second prompt data is obtained based on the neural network.
[0007] In the embodiment of the present application, multiple candidate results are determined according to the first prompt data input by the user, and when the difference between the multiple candidate results is greater than or equal to the first threshold, the first prompt data is updated based on the multiple candidate results, so that the output result is obtained using the updated prompt data (i.e., the second prompt data). That is, by updating the user's input prompt based on the difference between the multiple candidate results, the updated prompt can be made clearer, so that the neural network can generate an output result that is more in line with expectations.
[0008] Optionally, in a possible implementation of the first aspect, the above step: updating the first prompt data based on multiple candidate results to obtain the second prompt data, includes: determining a problem based on multiple candidate results, the problem being a problem that causes a difference greater than or equal to a first threshold; updating the first prompt data based on the problem to obtain the second prompt data.
[0009] This possible implementation method can help users quickly determine whether the big model can clearly understand the original prompt. The determination result is the input source for subsequent prompt clarification questions, thereby allowing the big model to ask clarification questions accurately.
[0010] Optionally, in a possible implementation of the first aspect, the above step: updating the first prompt data based on the question to obtain the second prompt data includes: obtaining an answer to the question, the answer being used to explain the reason why the question arises; updating the first prompt data based on the question and the answer to obtain the second prompt data.
[0011] In this possible implementation, in this case, the big model is used to generate a set of clarification questions (Clarifying Questions) and obtain answers to the clarification questions, which are integrated with the original prompt to obtain a clearer prompt, allowing the big model to generate higher quality code. For clarification questions, the big model can ask them accurately and answer them well.
[0012] Optionally, in a possible implementation manner of the first aspect, the above step of: obtaining an answer to the question includes: displaying the question to the user; and determining the answer in response to the user's operation.
[0013] In this possible implementation, the answer to the clarification question can be guaranteed to be as accurate as possible, that is, the part of the prompt to be clarified can be effectively clarified. In the case of manual feedback, the lack of understanding ability of the large model can be compensated to ensure the accuracy of the answer to the clarification question.
[0014] Optionally, in a possible implementation of the first aspect, the above step of: obtaining an answer to the question includes: generating third prompt data based on first prompt data, a first preset indication and the question, the first preset indication being used to instruct the neural network to generate an answer; obtaining an answer to the third prompt data based on the neural network.
[0015] In this possible implementation, the first prompt data is updated by a question that causes a difference greater than or equal to the first threshold, so that the third prompt data is compatible with the above-mentioned question, so that the neural network can refer to the question to obtain a solution (i.e., an answer), thereby improving the accuracy of the output result.
[0016] Optionally, in a possible implementation of the first aspect, the above step: updating the first prompt data based on the question and the answer to obtain the second prompt data includes: determining the second prompt data based on the first prompt data, the second preset indication, the question and the answer, and the second preset indication is used to instruct the neural network to generate an output result corresponding to the second prompt data.
[0017] In this possible implementation, the first prompt data is updated by the problem and solution that causes the difference to be greater than or equal to the first threshold, so that the second prompt data takes the above problem and answer into consideration, thereby improving the accuracy of the output result of the neural network.
[0018] Optionally, in a possible implementation of the first aspect, the above steps: determining the problem based on multiple candidate results, include: splitting the multiple candidate results into multiple subsets based on the multiple candidate results; generating fourth prompt data based on the multiple subsets, the first prompt data and the third preset indication, the third preset indication is used to instruct the neural network to generate the problem; obtaining the problem based on the neural network and the fourth prompt data.
[0019] In this possible implementation, the neural network can analyze the candidate results to identify problems where the difference is greater than or equal to the first threshold, so as to facilitate subsequent updating of clearer second prompt data.
[0020] Optionally, in a possible implementation manner of the first aspect, the above steps further include: if the difference is less than a first threshold, determining an output result from multiple candidate results.
[0021] In this possible implementation, when the difference between multiple candidate results is less than the first threshold, that is, when the multiple candidate results are similar, the output result can be directly determined from the multiple candidate results, thereby improving the efficiency of obtaining the output result.
[0022] Optionally, in a possible implementation of the first aspect, the above steps also include: generating test parameters based on the example input or code signature in the first prompt data, the test parameters are used as input parameters for any one of multiple candidate codes, and the code signature is used to generate test parameters in combination with multiple candidate codes; the difference is the difference between multiple execution results obtained after the test parameters are input into multiple candidate codes.
[0023] This possible implementation can be applied to code generation tasks, and the differences between candidate codes can be analyzed according to test parameters, so that prompt data updated according to the differences are clearer and the accuracy of the output code is improved.
[0024] Optionally, in a possible implementation manner of the first aspect, the above steps further include: presenting the output result to a user.
[0025] In this possible implementation, the output result can be presented to the user to meet the user's needs.
[0026] The second aspect of the embodiment of the present application provides a data processing device that can be applied to a large model reasoning scenario. The data processing device includes: a receiving unit for receiving first prompt data input by a user; an acquisition unit for acquiring a candidate result collection of the first prompt data based on a neural network, the candidate result collection including multiple candidate results; an updating unit for updating the first prompt data based on the multiple candidate results to obtain second prompt data if the difference between the multiple candidate results is greater than or equal to a first threshold; the acquisition unit is also used to acquire the output result of the second prompt data based on the neural network.
[0027] Optionally, in a possible implementation of the second aspect, the above-mentioned update unit is specifically used to determine a problem based on multiple candidate results, where the problem is a problem that causes a difference greater than or equal to a first threshold; the update unit is specifically used to update the first prompt data based on the problem to obtain the second prompt data.
[0028] Optionally, in a possible implementation of the second aspect, the above-mentioned updating unit is specifically used to obtain an answer to a question, and the answer is used to explain the reason why the question is raised; the updating unit is specifically used to update the first prompt data based on the question and the answer to obtain the second prompt data.
[0029] Optionally, in a possible implementation of the second aspect, the above-mentioned acquisition unit is specifically used to display questions to the user; the acquisition unit is specifically used to determine answers in response to user operations.
[0030] Optionally, in a possible implementation of the second aspect, the above-mentioned acquisition unit is specifically used to generate third prompt data based on the first prompt data, the first preset indication and the question, and the first preset indication is used to instruct the neural network to generate an answer; the acquisition unit is specifically used to obtain an answer to the third prompt data based on the neural network.
[0031] Optionally, in a possible implementation of the second aspect, the above-mentioned updating unit is specifically used to determine the second prompt data based on the first prompt data, the second preset indication, the question and the answer, and the second preset indication is used to instruct the neural network to generate an output result corresponding to the second prompt data.
[0032] Optionally, in a possible implementation of the second aspect, the above-mentioned update unit is specifically used to split the multiple candidate results into multiple subsets based on the multiple candidate results; the update unit is specifically used to generate fourth prompt data based on the multiple subsets, the first prompt data and the third preset indication, and the third preset indication is used to instruct the neural network to generate a problem; the update unit is specifically used to obtain the problem based on the neural network and the fourth prompt data.
[0033] Optionally, in a possible implementation manner of the second aspect, the acquisition unit is further configured to determine an output result from multiple candidate results if the difference is less than a first threshold.
[0034] Optionally, in a possible implementation of the second aspect, the above-mentioned acquisition unit is also used to generate test parameters based on the example input or code signature in the first prompt data, the test parameters are used as input parameters of any candidate code among multiple candidate codes, and the code signature is used to generate test parameters in combination with multiple candidate codes; the difference is the difference between multiple execution results obtained after the test parameters are input into multiple candidate codes.
[0035] Optionally, in a possible implementation manner of the second aspect, the data processing device further includes: a presentation unit, configured to present the output result to a user.
[0036] A third aspect of an embodiment of the present application provides a data processing device, including: a processor, the processor is coupled to a memory, the memory is used to store programs or instructions, when the program or instructions are executed by the processor, the data processing device implements the method in the above-mentioned first aspect or any possible implementation of the first aspect.
[0037] A fourth aspect of an embodiment of the present application provides a computer-readable medium on which a computer program or instruction is stored. When the computer program or instruction is executed on a computer, the computer executes the method in the aforementioned first aspect or any possible implementation of the first aspect.
[0038] A fifth aspect of an embodiment of the present application provides a computer program product. When the computer program product is executed on a computer, it enables the computer to execute the method in the aforementioned first aspect or any possible implementation manner of the first aspect.
[0039] A sixth aspect of an embodiment of the present application provides a chip system, which includes at least one processor for supporting a data processing device to implement the functions involved in the above-mentioned first aspect or any possible implementation method of the first aspect.
[0040] In one possible design, the chip system may also include a memory for storing program instructions and data necessary for the data processing device. The chip system may be composed of a chip, or may include a chip and other discrete devices. Optionally, the chip system also includes an interface circuit, which provides program instructions and / or data for at least one processor.
[0041] Among them, the technical effects brought about by the second, third, fourth, fifth, and sixth aspects or any possible implementation methods thereof can refer to the technical effects brought about by the first aspect or different possible implementation methods of the first aspect, and will not be repeated here.
[0042] It can be seen from the above technical solution that the embodiment of the present application has the following advantages: multiple candidate results are determined according to the first prompt data input by the user, and when the difference between the multiple candidate results is greater than or equal to the first threshold, the first prompt data is updated based on the multiple candidate results, so as to obtain the output result using the updated prompt data (i.e., the second prompt data). That is, by updating the user's input prompt through the difference between the multiple candidate results, the updated prompt can be made clearer, so that the neural network can generate an output result that is more in line with expectations. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 A schematic diagram of the structure of the system architecture provided in the embodiment of the present application;
[0044] Figure 2 Another structural diagram of the system architecture provided in the embodiment of the present application;
[0045] Figure 3 Another structural diagram of the system architecture provided in the embodiment of the present application;
[0046] Figure 4 A schematic diagram of a chip hardware structure provided in an embodiment of the present application;
[0047] Figure 5A A structural diagram of a data processing system provided in an embodiment of the present application;
[0048] Figure 5BAnother structural diagram of the data processing system provided in the embodiment of the present application;
[0049] Figure 6 A flowchart of a data processing method provided in an embodiment of the present application;
[0050] Figure 7 An example diagram of the first interface provided in an embodiment of the present application;
[0051] Figure 8 An example diagram of the fourth prompt data provided in an embodiment of the present application;
[0052] Fig. 9 An example diagram of the third prompt data provided in the embodiment of the present application;
[0053] Fig.10 An example diagram of the second prompt data provided in an embodiment of the present application;
[0054] Fig.11 An example diagram of the second interface provided in an embodiment of the present application;
[0055] Fig.12 Another flowchart of the data processing method provided in the embodiment of the present application;
[0056] Fig.13 A structural schematic diagram of a data processing device provided in an embodiment of the present application;
[0057] Fig.14 Another structural schematic diagram of a data processing device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0058] The embodiments of the present application provide a data processing method and related equipment, which can update the user's input prompt by the difference between multiple candidate results, so that the updated prompt is clearer, so that the neural network can generate output results that are more in line with expectations.
[0059] To facilitate understanding, the relevant terms and concepts mainly involved in the embodiments of the present application are first introduced below.
[0060] 1. Neural network (also called model)
[0061] A neural network can be composed of neural units. A neural unit can be a s is the weight, b is the bias operation unit, and the output of the operation unit can be:
[0062]
[0063] Where, s = 1, 2, ... n, n is a natural number greater than 1, W sFor X s The weight of the neural unit, b is the bias of the neural unit. f is the activation function of the neural unit, which is used to introduce nonlinear characteristics into the neural network to convert the input signal in the neural unit into the output signal. The output signal of the activation function can be used as the input of the next convolutional layer. The activation function can be a sigmoid function. A neural network is a network formed by connecting many of the above-mentioned single neural units together, that is, the output of one neural unit can be the input of another neural unit. The input of each neural unit can be connected to the local receptive field of the previous layer to extract the features of the local receptive field. The local receptive field can be an area composed of several neural units.
[0064] 2. Code Signing
[0065] Code signature refers to the type of input parameters and output parameters of a function.
[0066] When the model reasoning task is to generate code, code generation needs to understand the user's intention from the natural language description and generate executable code snippets that meet this intention. In recent years, this field has received great attention, especially the current pre-trained large language model (LLM) has achieved the most advanced results. Because the large language model contains a large amount of code corpus during training, it performs well in subsequent code generation tasks.
[0067] At present, the process of code generation based on the large model includes: the user provides a task described in natural language (also called a prompt word) and sends it to the large model. The large model completes the code generation task based on the received prompt word and returns the generated code to the user. In many scenarios, users do not understand LLM and it is difficult to write appropriate and clear prompt words, which makes the quality of the code generated by LLM poor.
[0068] Therefore, how to generate expected code based on the prompt words input by the user without modifying the LLM is a technical problem that needs to be solved urgently.
[0069] In order to solve the above technical problems, the embodiment of the present application provides a data processing method, which determines multiple candidate results according to the first prompt data input by the user, and updates the first prompt data based on the multiple candidate results when the difference between the multiple candidate results is greater than or equal to the first threshold, so as to obtain the output result using the updated prompt data (i.e., the second prompt data). That is, by updating the user's input prompt through the difference between the multiple candidate results, the updated prompt can be made clearer, so that the neural network can generate an output result that is more in line with expectations.
[0070] See also Figure 1 , a system architecture diagram provided in an embodiment of the present application, the system architecture includes: a code input generator, an IDE / editor, and a large model.
[0071] The code input generator is used to generate code input information and a code input value set according to a prompt, and send the code input value to an integrated development environment (IDE) / editor. The code input generator can be an existing method with heuristic test input generation, such as a metamorphosis method, which is not limited here.
[0072] The IDE / editor function includes at least one of the following: editing prompt, code testing, and code viewing, etc., sending prompts to the large model, and sending prompts or code input information about the generated code to the code input generator.
[0073] The functions of the large model include at least one of the following: generating code based on an input prompt, generating questions based on an input prompt, generating answers (or understanding them as answers to questions) based on an input prompt, and sending generated code content to an IDE / editor.
[0074] Optionally, the code input generator is located on the terminal side or the cloud side, the IDE / editor is located on the terminal side, and the large model is located on the cloud side. Of course, it is also possible that they are all on the cloud side, and the user communicates with the cloud side through a virtual machine or a cloud client (for example, inputting data, receiving data processing results, etc.).
[0075] In the code generation process of this architecture, if the prompt is accurate enough, that is, the output of the generated code set is consistent based on the test input set, then any code in the generated code set can be returned; if the test output is inconsistent, then it is divided according to the output type, and the big model identifies the relevant questions to be clarified and answers them. If necessary, humans intervene to answer questions that the big model cannot answer, and finally generate a clearer prompt to allow the big model to generate code.
[0076] In this system architecture, on the one hand, the clarity of prompts can be evaluated through code testing methods, and clarifying questions can be generated by the big model and answered to generate clearer prompts, ultimately allowing the big model to generate higher-quality code through a code generation capability enhancement framework. On the other hand, the original prompt is code generated, and the output of the generated code set is determined based on the test to determine whether it is consistent, that is, the prompt clarity determination method; if the output is inconsistent, the big model is used to generate clarifying questions (Clarifying Questions), and the big model is asked to answer the clarifying questions, and manual feedback is introduced to answer them, so as to avoid the big model from "talking nonsense" when it cannot answer questions.
[0077] In addition, the code input generator and the IDE / editor can be in the same device or in different devices. In practical applications, the code input generator can be used as a plug-in of the IDE / editor.
[0078] The system architecture diagram in this case can be as follows Figure 2 As shown, the IDE is used to edit prompts, view code, generate code input values, test code, send prompts to the big model, receive code content generated by the big model, etc. The big model is used to generate code based on the input prompt, generate questions based on the input prompt, generate answers (or understand them as answers to questions) based on the input prompt, and send the generated code content to the IDE.
[0079] It is understandable that the above Figure 1 and Figure 2 The IDE shown may also be replaced by a web page, other code generation tools, etc.
[0080] The following introduces the system architecture provided by the embodiments of the present application.
[0081] See attached Figure 3, an embodiment of the present invention provides a system architecture 300. As shown in the system architecture 300, the data acquisition device 360 is used to collect training data. In the embodiment of the present application, the training data includes: data of multiple different modalities. Among them, the modality may refer to text, image, video and audio. For example: the training data may include RGB image + depth image, or may include RGB image and point cloud data, etc. The training data is stored in the database 330, and the training device 320 obtains the target model / rule 301 based on the training data maintained in the database 330. The following will describe in more detail how the training device 320 obtains the target model / rule 301 based on the training data, and the target model / rule 301 can be used to implement the model reasoning task applied by the data processing method provided in the embodiment of the present application. The model reasoning task may include: classification task, segmentation task, detection task or image generation task, etc. The target model / rule 301 in the embodiment of the present application may specifically include self-attention network, multi-layer perceptron, pooling layer, etc. It should be noted that in actual applications, the training data maintained in the database 330 may not all come from the collection of the data acquisition device 360, but may also be received from other devices. It should also be noted that the training device 320 does not necessarily train the target model / rule 301 entirely based on the training data maintained by the database 330, and it is also possible to obtain training data from the cloud or other places for model training. The above description should not be regarded as a limitation on the embodiments of the present application.
[0082] The target model / rule 301 obtained by training the training device 320 can be applied to different systems or devices, such as Figure 3 The execution device 310 shown in the figure can be a terminal, such as a mobile phone terminal, a tablet computer, a laptop computer, an augmented reality (AR) device / virtual reality (VR) device, a vehicle terminal, etc. Of course, the execution device 310 can also be a server or a cloud. Figure 3 In the embodiment, the execution device 310 is configured with an I / O interface 312 for data interaction with an external device. The user can input data to the I / O interface 312 through the client device 340. The input data can include: an image to be detected in the embodiment of the present application. In addition, the input data can be input by the user, or uploaded by the user through a shooting device, or from a database, which is not limited here.
[0083] The preprocessing module 313 is used to preprocess the input data received by the I / O interface 312. In the embodiment of the present application, the preprocessing module 313 can be used to split the input data to obtain a sub-data set. For example, the input image is an image, and the preprocessing module 313 is used to split the image to obtain multiple image blocks.
[0084] When the execution device 310 preprocesses the input data, or when the computing module 311 of the execution device 310 performs calculations and other related processing, the execution device 310 can call the data, code, etc. in the data storage system 350 for corresponding processing, and can also store the data, instructions, etc. obtained from the corresponding processing into the data storage system 350.
[0085] Finally, the I / O interface 312 returns the processing result, such as the result corresponding to the above-mentioned target task, to the client device 340, thereby providing it to the user.
[0086] It is worth noting that the training device 320 can generate corresponding target models / rules 301 based on different training data for different goals or different tasks. The corresponding target models / rules 301 can be used to achieve the above goals or complete the above tasks, thereby providing users with the desired results.
[0087] In the attached Figure 3 In the case shown in the figure, the user can manually give input data, and the manual giving can be operated through the interface provided by the I / O interface 312. In another case, the client device 340 can automatically send input data to the I / O interface 312. If the client device 340 is required to automatically send input data and needs to obtain the user's authorization, the user can set the corresponding authority in the client device 340. The user can view the results output by the execution device 310 on the client device 340, and the specific presentation form can be a specific method such as display, sound, action, etc. The client device 340 can also be used as a data acquisition terminal to collect the input data of the input I / O interface 312 and the output results of the output I / O interface 312 as new sample data, and store them in the database 330. Of course, it is also possible not to collect through the client device 340, but the I / O interface 312 directly stores the input data of the input I / O interface 312 and the output results of the output I / O interface 312 as new sample data in the database 330.
[0088] It is worth noting that Figure 3 This is only a schematic diagram of a system architecture provided by an embodiment of the present invention. The positional relationship between the devices, components, modules, etc. shown in the figure does not constitute any limitation. Figure 3 In the embodiment, the data storage system 350 is an external memory relative to the execution device 310. In other cases, the data storage system 350 can also be placed in the execution device 310.
[0089] like Figure 3 As shown, the target model / rule 301 is obtained through training by the training device 320. The target model / rule 301 in the embodiment of the present application may specifically be LLM or the like.
[0090] The following introduces a chip hardware structure provided by an embodiment of the present application.
[0091] Figure 4 A chip hardware structure provided in an embodiment of the present invention includes a neural network processor 40. The chip can be arranged as follows: Figure 3 In the execution device 310 shown in FIG. 1 , the calculation module 311 is used to complete the calculation work. The chip can also be set in Figure 3 The training device 320 shown is used to complete the training work of the training device 320 and output the target model / rule 301.
[0092] The neural network processor 40 can be a neural network processing unit (NPU), a tensor processing unit (TPU), or a graphics processing unit (GPU) and any other processor suitable for large-scale XOR processing. Take NPU as an example: the neural network processor 40 is mounted on the main central processing unit (CPU) (host CPU) as a coprocessor, and the main CPU assigns tasks. The core part of the NPU is the operation circuit 403, and the controller 404 controls the operation circuit 403 to extract data from the memory (weight memory or input memory) and perform operations.
[0093] In some implementations, the operation circuit 403 includes multiple processing units (process engines, PEs) inside. In some implementations, the operation circuit 403 is a two-dimensional systolic array. The operation circuit 403 can also be a one-dimensional systolic array or other electronic circuits capable of performing mathematical operations such as multiplication and addition. In some implementations, the operation circuit 403 is a general-purpose matrix processor.
[0094] For example, assume there is an input matrix A, a weight matrix B, and an output matrix C. The operation circuit 403 takes the corresponding data of the matrix B from the weight memory 402 and caches it on each PE in the operation circuit. The operation circuit takes the matrix A data from the input memory 401 and performs a matrix operation with the matrix B, and the partial result or the final result of the matrix is stored in the accumulator 408.
[0095] The vector calculation unit 407 can further process the output of the operation circuit, such as vector multiplication, vector addition, exponential operation, logarithmic operation, size comparison, etc. For example, the vector calculation unit 407 can be used for network calculations of non-convolutional / non-FC layers in a neural network, such as pooling, batch normalization, local response normalization, etc.
[0096] In some implementations, the vector calculation unit 407 stores the vector of processed outputs to the unified buffer 406. For example, the vector calculation unit 407 can apply a nonlinear function to the output of the operation circuit 403, such as a vector of accumulated values, to generate an activation value. In some implementations, the vector calculation unit 407 generates a normalized value, a merged value, or both. In some implementations, the vector of processed outputs can be used as an activation input to the operation circuit 403, for example, for use in a subsequent layer in a neural network.
[0097] The unified memory 406 is used to store input data and output data.
[0098] The weight data is directly transferred from the external memory to the input memory 401 and / or the unified memory 406 through the direct memory access controller 405 (DMAC), the weight data in the external memory is stored in the weight memory 402, and the data in the unified memory 406 is stored in the external memory.
[0099] The bus interface unit (BIU) 410 is used to implement the interaction between the main CPU, DMAC and instruction fetch memory 409 through the bus.
[0100] An instruction fetch buffer 409 connected to the controller 404 is used to store instructions used by the controller 404 .
[0101] The controller 404 is used to call the instructions cached in the memory 409 to control the working process of the computing accelerator.
[0102] Generally, the unified memory 406, the input memory 401, the weight memory 402 and the instruction fetch memory 409 are all on-chip memories, and the external memory is a memory outside the NPU, which can be a double data rate synchronous dynamic random access memory (DDR SDRAM for short), a high bandwidth memory (HBM) or other readable and writable memory.
[0103] Next, several application scenarios of this application are introduced.
[0104] Figure 5A A structural diagram of a data processing system provided in an embodiment of the present application, the data processing system includes a terminal device ( Figure 5A In the figure, only the terminal device is a mobile phone as an example) and a data processing device. It is understandable that, in addition to a mobile phone, the terminal device can also be a tablet computer (pad), a portable game console, a personal digital assistant (PDA), a laptop computer, an ultra mobile personal computer (UMPC), a handheld computer, a netbook, a car media player, a wearable electronic device, a virtual reality (VR) terminal device, an augmented reality (AR), a vehicle, a vehicle terminal, an aircraft terminal, an intelligent robot and other terminal devices. The terminal device is the initiator of data processing. As the initiator of the data processing request, the request is usually initiated by the user through the terminal device.
[0105] The above-mentioned data processing device can be a device or server with data processing function such as a cloud server, a network server, an application server and a management server. The data processing device receives data processing requests from the terminal device through an interactive interface, and then performs data processing in the form of machine learning, deep learning, search, reasoning, decision-making, etc. through the memory that stores data and the processor link of data processing. The memory in the data processing device can be a general term, including local storage and databases that store historical data. The database can be on the data processing device or on other network servers.
[0106] exist Figure 5AIn the data processing system shown, the terminal device can receive the user's instructions. For example, the terminal device can obtain the data input / selected by the user (for example: images, text, audio, video, etc. collected by the terminal device through the terminal device), and then initiate a request to the data processing device, so that the data processing device performs a data processing application (for example, classification, segmentation, detection, image generation, code generation and other model reasoning tasks) for the data obtained by the terminal device, thereby obtaining a processing result corresponding to the data. Exemplarily, the terminal device can obtain the prompt data input by the user, and then initiate a code generation request to the data processing device, so that the data processing device updates the prompt data, generates code through the updated prompt data, and displays the code for the user to view and use.
[0107] exist Figure 5A In the embodiment of the present application, the data processing device can execute the data processing method of the embodiment of the present application.
[0108] Figure 5B Another structural diagram of the data processing system provided in the embodiment of the present application is shown in FIG. Figure 5B In the terminal device ( Figure 5B In this example, the terminal device is a mobile phone. The terminal device can directly obtain data (for example, the data is an image, text, audio, video, etc.) and process it directly by the hardware of the terminal device itself. The specific process is similar to Figure 5A Similarly, please refer to the above description and will not repeat them here.
[0109] Optionally, in Figure 5B In the data processing system shown, the terminal device can receive instructions from the user. For example, the terminal device can obtain multiple images selected by the user in the terminal device, and then the terminal device itself executes a data processing application (for example, model reasoning tasks such as classification, segmentation, detection, and image generation) for the image, thereby obtaining the corresponding processing result for the image, and displaying the processing result for the user to view and use.
[0110] Optionally, in Figure 5B In the data processing system shown, the terminal device can obtain input data in real time or periodically, and then the terminal device itself executes data processing applications (for example, classification, segmentation, detection, image generation, code generation and other model reasoning tasks) for the input data, thereby obtaining processing results corresponding to the input data, and implementing functions (classification function, segmentation function, detection function, image generation function, code generation function, etc.) based on the processing results.
[0111] exist Figure 5B In the embodiment of the present application, the terminal device itself can execute the data processing method.
[0112] Above Figure 5A and Figure 5B The terminal device in the example can be Figure 3 The client device 340 or the execution device 310 in Figure 5A The data processing device in the embodiment may be Figure 3 The execution device 310 in the embodiment, wherein the data storage system 350 can store the data to be processed by the execution device 310, and the data storage system 350 can be integrated on the execution device 310, or can be set on the cloud or other network servers.
[0113] Figure 5A and Figure 5B The processor in the system can perform data training / machine learning / deep learning through a neural network model, and use the model finally trained or learned by the data to execute data processing applications on the input data to obtain corresponding processing results.
[0114] The data processing method provided in the embodiment of the present application is described below. The method can be executed by a data processing device, or by a component of the data processing device (such as a processor, a chip, or a chip system, etc.). The data processing device can be a cloud device (such as the aforementioned Figure 5A as shown), or a terminal device (such as Figure 5B Of course, the method can also be executed by a system consisting of a cloud device and a terminal device (as described above). Figure 5A Optionally, the method may be processed by a CPU in a data processing device, or may be processed by a CPU and a GPU together, or may use other processors suitable for neural network calculations without using a GPU, and this application does not limit this.
[0115] The application scenarios to which the method provided in the embodiment of the present application is applicable may be model reasoning tasks such as classification scenarios, segmentation scenarios, detection scenarios, image generation scenarios, and code generation scenarios, or may be applied to semantic segmentation, indoor scene perception, outdoor driving, etc. In addition, the data involved in the embodiment of the present application may refer to text, images, audio, video, etc. For the convenience of description, this article only takes the task of prompting data to be text and generating code as an example for exemplary description.
[0116] See also Figure 6 , a flow chart of a data processing method provided by an embodiment of the present application, the method may include steps 601 to 604. Steps 601 to 604 are described in detail below.
[0117] Step 601: Acquire first prompt data input by the user.
[0118] In the embodiment of the present application, there are multiple ways for the data processing device to obtain the first prompt data, which may be through user input, collection / photography, receiving data sent by other devices, or selection from a database, etc., and the specifics are not limited here.
[0119] Optionally, the first prompt data includes a user requirement, or the first prompt data includes a user requirement and an example, and the example is used to guide the neural network to understand the user requirement. It is understandable that the example can be input by the user or generated by other neural networks according to the user requirement. The first prompt data can be called prompt.
[0120] In one possible implementation, the data processing device is a terminal device. The terminal device determines the first prompt data based on a user operation. The first operation may include at least one of the following: an operation of a user corresponding interface (such as selection, manual input, voice input, etc.), a voice operation, etc., which is not specifically limited here.
[0121] For example, the terminal device may display an input dialog box to the user, and the user may input the first prompt data through a peripheral device (eg, a mouse, a keyboard, etc.).
[0122] For example, Figure 7 As shown, the terminal device displays a first interface to the user, and the user can enter first prompt data in an input dialog box in the first interface.
[0123] In another possible implementation, the data processing device is a cloud device. After the terminal device determines the first prompt data based on the user operation, it sends the first prompt data to the cloud device.
[0124] Exemplarily, taking the model reasoning task as a code generation task, the first prompt data in the embodiment of the present application can be: def_separate_paren_groups(paren_string:str):... The input of this function is a string containing multiple sets of nested parentheses. Your goal is to separate these groups into separate strings and return a list of these groups..., ignoring any spaces in the string. Among them, "def_separate_paren_groups(paren_string:str):" is the signature of the function to be generated in the Python language, and "The input of this function is a string containing multiple sets of nested parentheses. Your goal is to separate these groups into separate strings and return a list of these groups..., ignoring any spaces in the string" is a description of the function's function.
[0125] It is understandable that the Python language in the above example is just an example. In actual applications, other languages can also be used, which is not limited here.
[0126] Exemplarily, in the case where the first prompt data includes a shot, the shot includes: "You will get a list of deposit and withdrawal operations for a bank account, which starts with a zero balance. Your task is to detect whether the account balance is lower than 0 at any time, and at that point the function should return True. Otherwise, it returns False." This shot will be described later and will not be expanded here.
[0127] Step 602: Obtain a candidate result set of the first prompt data based on the neural network.
[0128] After the data processing device obtains the first prompt data, it obtains a candidate result collection of the first prompt data based on the neural network, and the candidate result collection includes multiple candidate results.
[0129] It is understandable that the candidate results may be different depending on the user's needs. For example, if the user needs to generate a code, the candidate results are candidate codes. For another example, if the user needs to generate an image, the candidate results are images. For another example, if the user needs to generate a document, the candidate results are documents. For another example, if the user needs to generate a text explanation, the candidate results are text explanations.
[0130] In the embodiment of the present application, there are multiple ways for the data processing device to obtain the candidate result collection of the first prompt data based on the neural network. For example, when the data processing device stores the neural network, the first prompt data can be directly input into the neural network to obtain the candidate result collection. For another example, when the data processing device does not contain a neural network, the data processing device sends the first prompt data to other devices containing a neural network (such as a cloud device), and the cloud device obtains the candidate result collection based on the neural network and the first prompt data, and then returns the candidate result collection to the data processing device.
[0131] In addition, in the embodiment of the present application, the number of multiple candidate results can be 2 or a number greater than 2, which is not specifically limited here.
[0132] Exemplarily, the candidate result set includes 10 candidate codes, namely solution0, solution1, solution2, solution3, solution4, solution5, solution6, solution7, solution8, and solution9. The specific code content is not expanded in this example.
[0133] The neural network in the embodiments of the present application can be LLM (such as GPT-4, ChatGPT, etc.), convolutional neural network, transformer, etc., and the specific details are not limited here.
[0134] Step 603: if the difference between the multiple candidate results is greater than or equal to the first threshold, update the first prompt data based on the multiple candidate results to obtain second prompt data.
[0135] After the data processing device obtains multiple candidate results, if the difference between the multiple candidate results is greater than a first threshold, the first prompt data is updated based on the multiple execution results to obtain second prompt data.
[0136] In the embodiment of the present application, there are multiple ways for the data processing device to determine the difference between multiple candidate results. The input label can be found first, and then the difference between the multiple candidate results can be determined by the label. The test parameters can also be obtained first, and then the difference between the multiple candidate results can be tested according to the test parameters. The difference between the multiple candidate results can also be tested according to the test set. The difference can also be determined according to the parameters in the candidate results, etc., which are not limited here.
[0137] Exemplarily, continuing the above example, the difference between the above multiple candidate results can be specifically the difference between multiple execution results obtained by inputting multiple candidate codes respectively through test parameters. For another example, taking the generation of an image as an example, parameters such as sharpness value and pixel can be used as test criteria, which are not specifically limited here.
[0138] Optionally, after the data processing device obtains the first prompt data, it can generate a test parameter based on the example input or code signature in the first prompt data, and the test parameter is used as an input parameter for any candidate code among multiple candidate codes, and the code signature is used to generate the test parameter in combination with multiple candidate codes.
[0139] In one possible implementation, the data processing device generates a test parameter based on an example input. The example input may be in the first prompt data or may be another data, which is not specifically limited here. The example input may also be understood as a shot, which will be described later and will not be expanded here.
[0140] For example, the sample input is: You are given a list of deposit and withdrawal operations for a bank account, which starts with a zero balance. Your task is to detect whether the account balance is below 0 at any time, and at that point the function should return True. Otherwise, it returns False.
[0141] In another possible implementation manner, the data processing device generates a test parameter based on the code signature.
[0142] In this case, the data processing device may generate test parameters based on type-aware mutations or the like.
[0143] After the data processing device obtains the test parameters, it can use the generated test parameters to input multiple candidate codes respectively to obtain multiple execution results. If the multiple execution results are consistent, it means that the first prompt data is clear enough (that is, the neural network can understand the first prompt data), and directly output one of the multiple candidate codes as the output code. If the multiple execution results are inconsistent or the difference between the multiple execution results is greater than or equal to the first threshold, it means that the first prompt data is unclear (that is, the neural network does not understand the first prompt data), then the first prompt data is updated based on the multiple candidate results to obtain the second prompt data.
[0144] The following describes how the data processing device updates the first prompt data based on a plurality of candidate results to obtain the second prompt data.
[0145] The data processing device first determines a problem based on multiple candidate results, and then updates the first prompt data based on the problem to obtain the second prompt data, wherein the problem is a problem that causes the above difference to be greater than or equal to the first threshold.
[0146] Optionally, the multiple candidate results are first split into multiple subsets based on the differences among the multiple candidate results, and representative candidate results are found from the multiple subsets respectively. The fourth prompt data is then generated based on the multiple representative candidate results, the first prompt data and the third preset indication (for example, the fourth prompt data is obtained by directly concatenating the third preset indication, the first prompt data and the representative candidate results), and then the question of the fourth prompt data is obtained based on the neural network (for example, the fourth prompt data is input into the neural network to obtain a clarification question, and the clarification question can also be understood as a part of the subsequent third prompt data). The third preset indication is used to instruct the neural network to generate a question, or it can be understood that by adding the third preset indication, the neural network can be more clear about what to output.
[0147] Exemplarily, continuing the example of the above multiple candidate codes, solution0, solution1, solution2, solution3, solution4, solution5, solution6, solution7, solution8, solution9 are split into two subsets, and the representative codes selected from the two subsets are solution0 and solution1.
[0148] Exemplarily, continuing with the above example, based on the differences among multiple execution results, the multiple execution results are split into multiple subsets, and then representatives of each subset (also referred to as representative codes) are selected from the multiple subsets, and the representative codes are integrated into the original prompt data (i.e., the first prompt data). The reasoning ability of the neural network is used to analyze the reasons for the inconsistency (or large differences) of these multiple execution results, and the ambiguous expressions in the original prompt data are found out in combination with the reasons, and then targeted clarification questions are raised.
[0149] Exemplarily, continuing the example of the first prompt data and candidate code above, the analysis of solution0 is: this solution0 appends spaces to current_group and removes the spaces before appending it to the result. The analysis of solution1 is: this solution1 ignores spaces and only appends parentheses to current_group. The clarification questions obtained include: 1. Should the function remove spaces from the input string, or should it handle spaces in parentheses? 2. What does "no nesting" between groups mean? Should they be completely separated?
[0150] Optionally, the embodiments of the present application may also utilize in-context learning technology to design shots to enhance the ability of the neural network to ask clarifying questions.
[0151] Exemplarily, to improve the ability of the neural network to ask clarifying questions through one-shot examples, the fourth prompt data of zero-shot and one-shot examples can be as follows: Figure 8 As shown. The fourth prompt data includes: clarification questions, first prompt data (ie user requirements), and representative candidate results. The clarification questions can be understood as the aforementioned third preset instructions. Figure 8 The clarification instructions in the example shown are: You will get a user requirement and some solutions, and your task is to improve the clarity of the user requirement by asking clarifying questions. Specifically, you first need to analyze the user intent represented by each solution and understand their scenarios. By comparing the differences between these solutions, you can find out the unclear aspects of the requirements, and then ask clarifying questions to clarify these unclear aspects. The user requirement is: XXX (such as the example of the first prompt data mentioned above, which will not be expanded here), and multiple candidate results: YYY (such as the examples of solution0 and solution1 mentioned above). The user requirement entered in the example is: You will get a list of deposit and withdrawal operations for a bank account, and this account starts with a zero balance. Your task is to detect whether the account balance is lower than 0 at any time, and at that point the function should return True. Otherwise it returns False. Candidate result 0 in the example is:
[0152]
[0153] Candidate 1 in the example is:
[0154]
[0155]
[0156] It is understandable that the above zero-shot and one-shot are just examples. In actual applications, there may be more example inputs (ie, n-shot, where n is an integer greater than 1), which are not specifically limited here.
[0157] The analysis of candidate 0 in the example is: Candidate 0 calculates the total balance by adding all operations. Returns True if the total balance is less than 0, otherwise returns False. This candidate 0 detects that the balance is less than 0 at the last point, which seems to deviate from the requirement of detecting at any point. The analysis of candidate 1 is: Candidate 1 uses a variable balance to track the account balance. Each operation is added to the balance by iterating the operation. Returns True if the balance is less than 0 at any point. This candidate 1 complies with the requirement of detecting whether the balance is less than 0 at any point.
[0158] Clarification questions in the example include: 1. Can we assume that the initial balance is 0 and then start depositing and withdrawing money? 2. Is this requirement to check whether the balance is below 0 at any time? 3. If the balance happens to drop to 0, is it also considered "balance drops below 0"? Or is this condition only considered to be met when the balance is negative?
[0159] In the embodiment of the present application, there are multiple ways for the data processing device to update the first prompt data based on the question, which are described below respectively:
[0160] The first one is to update the first prompt data directly based on the question.
[0161] In this case, after obtaining the clarification question, the data processing device may directly update the first prompt data based on the clarification question.
[0162] Optionally, the data processing device may display a clarification question to the user, so that the user can clearly understand why the differences between the candidate results are too large, and the question is generated by the neural network. Thus, the user can clarify the problem of inaccurate neural network reasoning based on the question fed back by the neural network, and adjust the first prompt data based on the question to obtain the second prompt data.
[0163] In this case, it can help users quickly determine whether the big model can clearly understand the original prompt. The determination result is the input source for subsequent prompt clarification questions, so that the big model can ask clarification questions accurately.
[0164] The second method is to first obtain the answer based on the question, and then update the first prompt data based on the question and the answer.
[0165] In this case, after obtaining the clarification question, the data processing device may first obtain an answer based on the clarification question, and then update the first prompt data based on the question and the answer, wherein the answer is used to solve the cause of the problem.
[0166] In the embodiment of the present application, there are multiple ways for the data processing device to obtain answers based on the clarification questions, which are described below respectively:
[0167] In one possible implementation, the data processing device displays the clarification question to the user and determines the answer in response to the user's operation. It can also be understood that the user determines the answer by analyzing the clarification question and informs the data processing device through voice input or keyboard input.
[0168] In another possible implementation, the data processing device generates the third prompt data based on the clarification question, the first prompt data and the first preset instruction (for example, directly concatenating the first preset instruction, the first prompt data and the clarification question to obtain the third prompt data). The data processing device obtains an answer to the third prompt data based on the neural network (for example, inputting the third prompt data into the neural network to obtain the answer). The first preset instruction is used to instruct the neural network to generate a question, or it is understood that by adding the first preset instruction, the neural network can more clearly output what.
[0169] Exemplarily, continuing the example of the first prompt data, candidate code, and clarification question, the answers to the clarification questions include: 1. The function can directly delete spaces from the input string, or ignore spaces when processing the input string. 2. This means that a set of brackets should not be completely enclosed in another set of brackets.
[0170] For example, to improve the ability of the neural network to generate answers based on questions through one-shot examples, the third prompt data without zero-shot examples and one-shot examples can be as follows: Fig. 9 As shown. The third prompt data includes: answer instructions, first prompt data (ie user requirements), and clarification questions. The answer instructions can be understood as the aforementioned first preset instructions. Fig. 9The answer instructions in the example shown are: You will get a user requirement and some clarification questions. Your task is to answer the clarification questions based on the information provided in the user requirement. Just answer without repeating the requirement and question. The user requirement is: XXX (such as the example of the first prompt data mentioned above, which will not be expanded here), and the clarification question is: YYY (such as the example of the clarification question mentioned above, which will not be expanded here). The user requirement entered in the example is: You will get a list of deposit and withdrawal operations for a bank account, and this account starts with a zero balance. Your task is to check whether the account balance is lower than 0 at any time, and at that point the function should return True. Otherwise, it returns False. The clarification questions in the example are: 1. Can we assume that the initial balance is 0 and then start depositing and withdrawing money? 2. Is this requirement to check whether the balance is lower than 0 at any time? 3. If the balance just drops to 0, is it also considered as "the balance drops below 0"? Or is this condition only considered to be met when the balance is negative? The answers in the example are: 1. Yes, start with a zero balance. 2. Yes, the balance must be checked at any time. 3. The condition is only considered to be met when the balance is negative.
[0171] It is understandable that if the neural network cannot analyze the question and get an answer, that is, the output is wrong, the answer can be determined manually. That is, the above two ways of obtaining answers can be implemented separately or in combination. In this case, the answer to the clarification question can be guaranteed to be as accurate as possible, that is, the part to be clarified in the prompt can be effectively clarified. In the case of manual feedback, the lack of understanding ability of the large model can be compensated, the accuracy of the answer to the clarification question can be guaranteed, and the effective benefits of this framework can be maintained.
[0172] After the data processing device obtains the answer, it can determine the second prompt data based on the first prompt data, the second preset indication, the question and the answer (for example, directly concatenating the second preset indication and the first prompt data. Clarifying the question and the answer to obtain the second prompt data). The second preset indication is used to instruct the neural network to generate an output result corresponding to the second prompt data (for example, inputting the second prompt data into the neural network to obtain the output result), or it can be understood that by adding the second preset indication, the neural network can more clearly determine what to output.
[0173] Exemplarily, continuing the example of the first prompt data, candidate codes, clarification questions and answers, the output code obtained is solution X. It can be understood that solution X can be one of the 10 candidate code examples, or a code other than the 10 candidate codes, which is not limited here.
[0174] For example, to improve the ability of the neural network to generate output codes based on the second prompt data through one example (one-shot), the second prompt data without an example (zero-shot) and one-shot examples can be as follows: Fig.10 The second prompt data includes: code description, first prompt data (i.e. user requirements), clarifying questions and answers. The code description can be understood as the aforementioned second preset instruction. Fig.10 The code description in the example shown is: You will get a user requirement, clarification questions, and answers. These answers written by users are used to improve the clarity of user requirements and should be noted. Only a correct and efficient Python function that meets the requirements will be replied. The user requirement is: XXX (such as the example of the first prompt data mentioned above, which will not be expanded here), clarification questions and answers: CQ1, xxx_1, yyy_1, ..., CQn, xxx_n, yyy_n (such as the example mentioned above, which will not be expanded here). The user requirement entered in the example is: You will get a list of deposit and withdrawal operations for a bank account, and this account starts with a zero balance. Your task is to detect whether the account balance is lower than 0 at any time, and at that point the function should return True. Otherwise, it returns False. The clarification questions and answers in the example include: 1. Can we assume that the initial balance is 0 and then start depositing and withdrawing? Yes, start with a zero balance. 2. Is this requirement to check whether the balance is lower than 0 at any time? Yes, the balance must be checked at any time. 3. If the balance drops to 0, is it also considered as "the balance drops below 0"? Or is this condition only considered satisfied when the balance is negative? The condition is only considered satisfied when the balance is negative. The code output in the example is:
[0175]
[0176] In this case, the big model is used to generate a set of clarification questions and obtain answers to the clarification questions, which are then integrated with the original prompt to obtain a clearer prompt, allowing the big model to generate higher-quality code. For clarification questions, the big model can ask them accurately and give good answers.
[0177] Step 604: Obtain an output result of the second prompt data based on the neural network.
[0178] After the data processing device obtains the second prompt data, it obtains the output result of the second prompt data based on the neural network.
[0179] In the embodiment of the present application, there are multiple ways for the data processing device to obtain the output result of the second prompt data based on the neural network. For example, when the data processing device stores the neural network, the second prompt data can be directly input into the neural network to obtain the output result. For another example, when the data processing device does not contain a neural network, the data processing device sends the second prompt data to other devices containing a neural network (such as a cloud device), and the cloud device obtains the output result based on the neural network and the second prompt data, and then returns the output result to the data processing device.
[0180] It should be noted that in order to improve the understanding and reasoning ability of the neural network, the neural network for the aforementioned prompt data input is the same. Of course, in practical applications, it can also be a different but similar neural network (for example, similar parameters or similar structure, etc.), but the effect is poor, which is not limited here.
[0181] The output result may be a candidate result among the aforementioned multiple candidate results, or may be a newly generated result other than the aforementioned multiple candidate results.
[0182] Optionally, after obtaining the output result, the data processing device may present the output result to the user, and the presentation method may be display, voice playback, etc., which is not limited here.
[0183] For example, Fig.11 As shown, the terminal device displays a second interface to the user, and the second interface includes the first prompt data input by the user and the output result obtained by the data processing device ( Fig.11 Specific codes are omitted).
[0184] It is understandable that in the process of the user inputting the first prompt data and obtaining the output result, the user may not perceive the process of the data processing device updating the first prompt data. Alternatively, in addition to perceiving the first prompt data and the output result, the user may also perceive the question and manually provide an answer to the question to meet the scenario that the neural network cannot answer.
[0185] In an embodiment of the present application, on the one hand, multiple candidate results are determined based on the first prompt data input by the user, and when the difference between the multiple candidate results is greater than or equal to the first threshold, the first prompt data is updated based on the multiple candidate results, so that the updated prompt data (i.e., the second prompt data) is used to obtain the output result. That is, by updating the user's input prompt through the difference of multiple candidate results, the updated prompt can be made clearer, so that the neural network can generate an output result that is more in line with expectations. On the other hand, the questions and / or answers with large differences can be analyzed based on the neural network, so that the prompt data can be updated according to the questions and / or answers, so that the updated second prompt data is more compatible with the neural network. Or it can be understood that because it is a question and / or answer analyzed by the neural network, the neural network can better understand the problem in the first prompt data, so that the updated second prompt data is clearer. Or it can be understood that the reason why the multiple candidate results are large in difference is analyzed by the neural network, so that the original prompt data is calibrated according to the reason. On the other hand, the neural network can better understand the reasoning direction by providing examples (n-shot), so that the reasoning result that is more in line with the user's expectations can be obtained.
[0186] See also Fig.12 , another flow chart of the data processing method provided in the embodiment of the present application, the method can be executed by a data processing device, or by a component of the data processing device (such as a processor, a chip, or a chip system, etc.). The data processing device can be a cloud device (such as the aforementioned Figure 5A as shown), or a terminal device (such as Figure 5B Of course, the method can also be executed by a system consisting of a cloud device and a terminal device (as described above). Figure 5A shown).
[0187] Fig.12 The method flow shown includes: obtaining first prompt data, obtaining multiple candidate results through LLM, and comparing the differences between the multiple candidate results. If the difference is less than a threshold value (i.e., the difference is not large), determining an output result (e.g., random, preset rules, etc.) from multiple candidate results. If the difference is greater than or equal to the threshold value (i.e., the difference is too large), determining a fourth prompt data based on multiple candidate results, and obtaining a clarification question for the fourth prompt data through LLM. Determine the third prompt data based on the clarification question, and obtain an answer to the third prompt data through LLM. If there are unanswered questions, answer them manually. Then determine the second prompt data based on the answer of LLM, or based on LLM and the manual answer. Obtain the output result of the second prompt data through LLM.
[0188] Among them, the determination method of the above-mentioned prompt data is as mentioned above Figure 6 The description in the illustrated embodiment will not be repeated here.
[0189] How to accurately describe the intention of the prompt, how to further adjust the prompt to meet expectations when the output of the large model based on the prompt does not meet expectations, how to make a prompt obtain good results on one large model and obtain similar results on other large models, etc. For these problems that are inevitable and difficult to solve when using large models, the industry is still researching and exploring. In the existing prompt engineering research and practice, if you want to tune the prompt efficiently and accurately, then identifying and analyzing the shortcomings of the prompt through the large model itself and clarifying it is the best solution for prompt tuning at present, and it is an inevitable trend of prompt tuning in the era of large models.
[0190] The embodiment of the present application proposes a method for judging the clarity of the original prompt by the difference between the candidate results, and if the original prompt is not clear, allowing the large model to generate clarifying questions and answers, thereby obtaining a clearer prompt to generate the final output result. For example, taking the code generation task as an example, the advantage of this method is that the clarity of the generated code of the original prompt is judged using the test input, and the large model is allowed to generate the original prompt clarifying questions and answers based on the test result partition set, so that the large model is involved in the process of improving the clarity of the prompt, making the clarified prompt more accurate and easier to understand for the large model, and the generated code finally obtained is more in line with the user's intention.
[0191] In order to more intuitively see the beneficial effects of the data processing method (hereinafter referred to as Ours) provided in the embodiment of the present application, the performance results on different test sets and different neural networks are described below.
[0192] The test sets include HumanEval and MBPP, and the neural networks include GPT4 and ChatGPT. The test results are shown in Table 1:
[0193] Table 1
[0194] method HumanEval(Pass@1) MBPP(Pass@1) GPT-4 78.3% 70.2% GPT4+Ours(zero-shot) 82.3% 72.0% GPT4+Ours (one-shot) 83.9% 72.8% GPT4+Ours (two-shot) 85.2% 73.6% GPT4+Ours (three-shot) 87.6%(+9.3%) 74.4%(+4.2%) GPT-3.5 64.2% 63.5% GPT3.5+Ours(zero-shot) 70.7% 64.2% GPT3.5+Ours (one-shot) 72.8% 66.5% GPT3.5+Ours (two-shot) 73.9% 68.1% GPT3.5+Ours (three-shot) 74.5(+10.3%) 68.9%(+5.4%)
[0195] In the embodiments of the present application, zero-shot refers to only basic task description information without examples. n-shot refers to the number of examples carried in the input prompt data. Figures 6 to 11 The illustrated embodiment method adopts a one-shot method.
[0196] In the evaluation of the benefit effect, the test sets HumanEval and MBPP (Mostly Basic Python Programming) are used, as well as the Pass@1 indicator. Specifically, HumanEval is a popular Python benchmark consisting of 164 handwritten programming tasks proposed by OpenAI. Each task includes a function signature, NL description, function body, and several unit tests (7.7 tests per task on average). MBPP contains 427 manually verified Python programming tasks, covering programming basics, standard library functions, etc. Each task includes a natural language (NL) description, a code solution, and 3 automated test cases. When evaluating after code generation, the pass@k indicator is used to evaluate functional correctness. K code samples are generated for each problem. If any sample passes the unit test, the problem is considered to be solved, and the total proportion of problem solving is reported. Here k = 1, that is, the pass@1 indicator is used. From the data shown in Table 1, it can be seen that in the worst case (zero-shot) of this framework, on HumanEval, GPT-4 can improve by 4% (82.3%-78.3%), and GPT-3.5 can improve by 6.5% (70.7%-64.2%); on MBPP, GPT-4 can improve by 1.8% (72.0%-70.2%), and GPT-3.5 can improve by 0.7% (64.2%-63.5%). The scheme of the present invention can significantly improve the effect of code generation based on the existing large model.
[0197] The data processing method in the embodiment of the present application is described above. The data processing device in the embodiment of the present application is described below. Fig.13 , an embodiment of the data processing device in the embodiment of the present application includes:
[0198] The receiving unit 1301 is used to receive first prompt data input by a user;
[0199] An acquiring unit 1302 is used to acquire a candidate result collection of the first prompt data based on a neural network, where the candidate result collection includes multiple candidate results;
[0200] An updating unit 1303, configured to update the first prompt data based on the multiple candidate results to obtain second prompt data if the difference between the multiple candidate results is greater than or equal to the first threshold;
[0201] The acquisition unit 1302 is further used to acquire the output result of the second prompt data based on the neural network.
[0202] Optionally, the updating unit 1303 is specifically used to determine a problem based on multiple candidate results, where the problem is a problem that causes a difference greater than or equal to a first threshold; the updating unit 1303 is specifically used to update the first prompt data based on the problem to obtain the second prompt data.
[0203] Optionally, the updating unit 1303 is specifically used to obtain an answer to a question, where the answer is used to explain the reason why the question is raised; the updating unit 1303 is specifically used to update the first prompt data based on the question and the answer to obtain the second prompt data.
[0204] Optionally, the acquisition unit 1302 is specifically used to display questions to the user; the acquisition unit 1302 is specifically used to determine answers in response to user operations.
[0205] Optionally, the acquisition unit 1302 is specifically used to generate third prompt data based on the first prompt data, the first preset indication and the question, and the first preset indication is used to instruct the neural network to generate an answer; the acquisition unit 1302 is specifically used to obtain an answer to the third prompt data based on the neural network.
[0206] Optionally, the updating unit 1303 is specifically used to determine the second prompt data based on the first prompt data, the second preset indication, the question and the answer, and the second preset indication is used to instruct the neural network to generate an output result corresponding to the second prompt data.
[0207] Optionally, the update unit 1303 is specifically used to split the multiple candidate results into multiple subsets based on the multiple candidate results; the update unit 1303 is specifically used to generate fourth prompt data based on the multiple subsets, the first prompt data and the third preset indication, and the third preset indication is used to instruct the neural network to generate a problem; the update unit 1303 is specifically used to obtain the problem based on the neural network and the fourth prompt data.
[0208] Optionally, the acquisition unit 1302 is further configured to determine an output result from multiple candidate results if the difference is less than a first threshold.
[0209] Optionally, acquisition unit 1302 is also used to generate test parameters based on the example input or code signature in the first prompt data, the test parameters are used as input parameters of any candidate code among multiple candidate codes, and the code signature is used to generate test parameters in combination with multiple candidate codes; the difference is the difference between multiple execution results obtained after the test parameters are input into multiple candidate codes.
[0210] Optionally, the data processing device further includes: a presenting unit 1304, configured to present the output result to the user.
[0211] In this embodiment, the operations performed by each unit in the data processing device are the same as those described above. Figures 1 to 12The description in the illustrated embodiment is similar and will not be repeated here.
[0212] In this embodiment, on the one hand, the acquisition unit 1302 determines multiple candidate results according to the first prompt data input by the user, and the updating unit 1303 updates the first prompt data based on the multiple candidate results when the difference between the multiple candidate results is greater than or equal to the first threshold, so that the acquisition unit 1302 uses the updated prompt data (i.e., the second prompt data) to obtain the output result. That is, by updating the user's input prompt through the difference of multiple candidate results, the updated prompt can be made clearer, so that the neural network can generate an output result that is more in line with expectations. On the other hand, the questions and / or answers with large differences can be analyzed based on the neural network, so that the prompt data can be updated according to the questions and / or answers, so that the updated second prompt data is more compatible with the neural network. Or it can be understood that because it is a question and / or answer analyzed by the neural network, the neural network can better understand the question in the first prompt data, so that the updated second prompt data is clearer. Or it can be understood that the reason why the multiple candidate results are large in difference is analyzed by the neural network, so that the original prompt data is calibrated according to the reason. On the other hand, the neural network can better understand the reasoning direction by providing examples (n-shot), so that the reasoning result that is more in line with the user's expectations can be obtained.
[0213] See also Fig.14 , a schematic diagram of the structure of another data processing device provided by the present application. The data processing device may include a processor 1401, a memory 1402 and a communication port 1403. The processor 1401, the memory 1402 and the communication port 1403 are interconnected via a line. The memory 1402 stores program instructions and data.
[0214] The memory 1402 stores the aforementioned Figures 1 to 12 In the corresponding embodiment shown, the steps executed by the data processing device correspond to program instructions and data.
[0215] Processor 1401, used to execute the above Figures 1 to 12 The steps shown in any of the illustrated embodiments are performed by a data processing device.
[0216] Communication port 1403 can be used to receive and send data, and to perform the above Figures 1 to 12 The steps related to obtaining, sending and receiving in any of the embodiments shown.
[0217] In one implementation, the data processing device may include Fig.14 More or fewer components are merely illustrative in this application and are not limiting.
[0218] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0219] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0220] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0221] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, read-only memory), random access memory (RAM, random access memory), disk or optical disk and other media that can store program code.
Claims
1. A data processing method, characterized in that: The method comprises: receiving first prompt data input by a user; Acquire a candidate result collection of the first prompt data based on a neural network, wherein the candidate result collection includes a plurality of candidate results; If the difference between the multiple candidate results is greater than or equal to a first threshold, updating the first prompt data based on the multiple candidate results to obtain second prompt data; An output result of the second prompt data is obtained based on the neural network.
2. The method according to claim 1, characterized in that The updating the first prompt data based on the multiple candidate results to obtain second prompt data includes: determining a problem based on the plurality of candidate results, the problem being a problem that causes the difference to be greater than or equal to the first threshold; The first prompt data is updated based on the question to obtain the second prompt data.
3. The method according to claim 2, characterized in that The updating of the first prompt data based on the question to obtain the second prompt data includes: Obtaining an answer to the question, wherein the answer is used to explain the cause of the question; The first prompt data is updated based on the question and the answer to obtain the second prompt data.
4. The method according to claim 3, characterized in that The obtaining of the answer to the question comprises: displaying the question to the user; The answer is determined in response to the user's operation.
5. The method according to claim 3 or 4, characterized in that: The obtaining of the answer to the question comprises: generating third prompt data based on the first prompt data, a first preset instruction and the question, wherein the first preset instruction is used to instruct the neural network to generate the answer; The answer to the third prompt data is obtained based on the neural network.
6. The method according to claim 3 or 4, characterized in that: The updating the first prompt data based on the question and the answer to obtain the second prompt data includes: The second prompt data is determined based on the first prompt data, a second preset indication, the question and the answer, and the second preset indication is used to instruct the neural network to generate the output result corresponding to the second prompt data.
7. The method according to claim 2 or 3, characterized in that: The determining of the problem based on the multiple candidate results comprises: splitting the plurality of candidate results into a plurality of subsets based on the plurality of candidate results; generating fourth prompt data based on the plurality of subsets, the first prompt data, and a third preset instruction, wherein the third preset instruction is used to instruct the neural network to generate the question; The question is obtained based on the neural network and the fourth prompt data.
8. The method according to any one of claims 1 to 7, characterized in that The method further comprises: If the difference is less than the first threshold, the output result is determined from the multiple candidate results.
9. The method according to any one of claims 1 to 8, characterized in that The method further comprises: Generate a test parameter based on the example input or code signature in the first prompt data, the test parameter is used as an input parameter of any candidate code among the multiple candidate codes, and the code signature is used to generate the test parameter in combination with the multiple candidate codes; The difference is the difference between multiple execution results obtained after the test parameters are input into the multiple candidate codes.
10. The method according to any one of claims 1 to 9, characterized in that The method further comprises: The output result is presented to a user.
11. A data processing device, characterized in that: The data processing device comprises: A receiving unit, configured to receive first prompt data input by a user; An acquisition unit, configured to acquire a candidate result collection of the first prompt data based on a neural network, wherein the candidate result collection includes a plurality of candidate results; an updating unit, configured to update the first prompt data based on the multiple candidate results to obtain second prompt data if the difference between the multiple candidate results is greater than or equal to a first threshold; The acquisition unit is further used to acquire an output result of the second prompt data based on the neural network.
12. The data processing device according to claim 11, characterized in that The updating unit is specifically configured to determine a problem based on the multiple candidate results, the problem being a problem that causes the difference to be greater than or equal to the first threshold; The updating unit is specifically configured to update the first prompt data based on the question to obtain the second prompt data.
13. The data processing device according to claim 12, characterized in that The updating unit is specifically used to obtain an answer to the question, wherein the answer is used to explain the reason why the question occurs; The updating unit is specifically configured to update the first prompt data based on the question and the answer to obtain the second prompt data.
14. The data processing device according to claim 13, characterized in that The obtaining unit is specifically configured to display the question to the user; The acquisition unit is specifically configured to determine the answer in response to the user's operation.
15. The data processing device according to claim 13 or 14, characterized in that The acquisition unit is specifically used to generate third prompt data based on the first prompt data, a first preset instruction and the question, wherein the first preset instruction is used to instruct the neural network to generate the answer; The acquisition unit is specifically used to acquire the answer to the third prompt data based on the neural network.
16. The data processing device according to claim 13 or 14, characterized in that The updating unit is specifically used to determine the second prompt data based on the first prompt data, the second preset indication, the question and the answer, and the second preset indication is used to instruct the neural network to generate the output result corresponding to the second prompt data.
17. The data processing device according to claim 12 or 13, characterized in that: The updating unit is specifically configured to split the multiple candidate results into multiple subsets based on the multiple candidate results; The updating unit is specifically used to generate fourth prompt data based on the multiple subsets, the first prompt data and a third preset indication, wherein the third preset indication is used to instruct the neural network to generate the question; The updating unit is specifically used to obtain the question based on the neural network and the fourth prompt data.
18. The data processing device according to any one of claims 11 to 17, characterized in that: The acquisition unit is further configured to determine the output result from the multiple candidate results if the difference is less than the first threshold.
19. The data processing device according to any one of claims 11 to 18, characterized in that: The acquisition unit is further used to generate a test parameter based on the example input or code signature in the first prompt data, the test parameter is used as an input parameter of any candidate code among the multiple candidate codes, and the code signature is used to generate the test parameter in combination with the multiple candidate codes; The difference is the difference between multiple execution results obtained after the test parameters are input into the multiple candidate codes.
20. The data processing device according to any one of claims 11 to 19, characterized in that: The data processing device further comprises: A presenting unit is used to present the output result to the user.
21. A data processing device, characterized in that: include: A processor, the processor is coupled to a memory, the memory is used to store programs or instructions, when the program or instructions are executed by the processor, the data processing device executes the method according to any one of claims 1 to 10.
22. A computer storage medium, characterized in that The method comprises computer instructions, and when the computer instructions are executed on a terminal device, the terminal device executes the method according to any one of claims 1 to 10.
23. A computer program product, characterized in that When the computer program product is run on a computer, the computer is caused to perform the method according to any one of claims 1 to 10.