Data distribution method and device, electronic equipment and storage medium
By using the combination of the first decoding model and the second decoding model in the big model, it is distributed according to the difficulty of understanding the data and the difficulty of processing, and the problem of high computing power requirements of the big model is solved, and the processing time and answer quality are achieved. Taking into account both, improving the user experience.
Patent Information
- Application Number
- CN202411022296.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-29
- Publication Date
- 2024-12-27
AI Technical Summary
In natural language generation tasks, large models have too high computing power demand due to the limitations of parameter scale, calculation quantity and autoregressive decoding methods, which reduces the accuracy of the reply.
By using a combination of the first decoding model and the second decoding model, problem data is distributed to the corresponding model for processing according to its computing resource requirements, and by training and adjusting the model weight, the data is ensured to be distributed to the appropriate model to take into account the processing time. with quality of answers.
A balance between processing speed and accuracy is achieved, and the user experience is improved, and the problem of waste of resources and inefficiency of a single model when processing complex data is avoided.
Smart Images

Figure CN119201422A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of artificial intelligence technology, and in particular to a data distribution method, device, electronic device and storage medium. Background Art
[0002] Large models are affected by parameter scale, computational complexity, and autoregressive decoding methods, and therefore require extremely high computing power.
[0003] To solve the problem of excessive computing power requirements, related technologies attempt to limit the model's parameter size and computational workload. Although this measure can improve the response speed of large models for natural language generation tasks to a certain extent, it inevitably reduces the accuracy of the response. Summary of the invention
[0004] The present disclosure provides a data distribution method, device, electronic device and storage medium to at least solve the above technical problems existing in the prior art.
[0005] According to a first aspect of the present disclosure, there is provided a data distribution method, comprising:
[0006] Inputting the problem data into the first distribution model to determine the distribution result;
[0007] In response to the distribution result being the first decoding model, the question data is input into the first decoding model, and the question data is processed by the first decoding model;
[0008] In response to the distribution result being the second decoding model, the question data is input into the second decoding model, and the question data is processed by the second decoding model;
[0009] The first decoding model and the second decoding model require different amounts of computing resources.
[0010] In the above solution, before inputting the problem data into the first distribution model and determining the distribution result, the method further includes:
[0011] Based on a first decoding result generated by the first decoding model for the first training data and a second decoding result generated by the second decoding model for the first training data, training the second distribution model, and determining that the trained second distribution model is the first distribution model;
[0012] The first distribution model is used to distribute the first training data; if the first decoding result is the same as the second decoding result, the second distribution model distributes the first training data to the second decoding model; if the first decoding result is different from the second decoding result, the second distribution model distributes the first training data to the first decoding model.
[0013] In the above solution, the second distribution model is trained based on the first decoding result generated by the first decoding model for the first training data and the second decoding result generated by the second decoding model for the first training data, including:
[0014] Determine a first training data set; the first training data set includes the first training data, a first decoding result obtained by inputting the first training data into a first decoding model and a probability distribution of the first decoding result, and a second decoding result obtained by inputting the first training data into a second decoding model and a probability distribution of the second decoding result;
[0015] Inputting the first training data into a second distribution model, determining a distribution result of a second decoding distribution module, and adjusting a weight of the second distribution model based on the distribution result, the first decoding result, and the second decoding result to obtain a first distribution model;
[0016] Inputting the first training data into the first distribution model, and determining feedback of the first distribution model based on a distribution result of the first distribution model, a first decoding result, a probability distribution of the first decoding result, a second decoding result, and a probability distribution of the second decoding result;
[0017] Adjusting a weight of the first distribution model based on feedback from the first distribution model;
[0018] Among them, the first decoding model requires more computing resources to run than the second decoding model.
[0019] In the above solution, the determining of the first training data set includes:
[0020] Inputting the second training data set into the first decoding model to obtain a first decoding data set;
[0021] Inputting the second training data set into the second decoding model to obtain a second decoded data set;
[0022] Determine the first training data set based on the second training data set, the first decoded data set and the second decoded data set;
[0023] The first training data set includes the correspondence between any training data in the second training data and the third decoding result output by the first decoding model based on the training data, and the correspondence between the training data and the fourth decoding result output by the second decoding model based on the training data.
[0024] In the above solution, the distribution result includes distributing the first training data to the first decoding model or the second decoding model for processing, and adjusting the weight of the second distribution model based on the distribution result, the first decoding result and the second decoding result to obtain the first distribution model, including:
[0025] Determining whether the first decoding result and the second decoding result satisfy a first condition;
[0026] In response to the first decoding result and the second decoding result satisfying the first condition, determining that the annotation label of the first training data is the second decoding model; or, in response to the first decoding result and the second decoding result not satisfying the first condition, determining that the annotation label of the first training data is the first decoding model;
[0027] Determine a loss function of the second distribution model based on the marked label and the distribution result, and adjust a weight of the second distribution model based on the loss function to obtain a first distribution model;
[0028] The first condition includes that the first decoding result and the second decoding result are the same, or the first decoding result and the second decoding result are semantically similar.
[0029] In the above solution, inputting the first training data into the first distribution model, and determining feedback of the first distribution model based on the distribution result of the first distribution model, the first decoding result, the probability distribution of the first decoding result, the second decoding result, and the second decoding result probability distribution, includes:
[0030] Determining semantic similarity between the first decoding result and the second decoding result;
[0031] Determining a difference measure between the first decoding result probability distribution and the second decoding result probability distribution;
[0032] Feedback of the first distribution model is determined based on the first decoding result, the second decoding result, the distribution result, the semantic similarity, and the difference.
[0033] In the above solution, the determining of the feedback of the first distribution model based on the first decoding result, the second decoding result, the distribution result, the semantic similarity and the difference includes one of the following:
[0034] In response to the first decoding result and the second decoding result satisfying a first condition, and the distribution result is a first decoding model, determining feedback of the first distribution model as first feedback;
[0035] In response to the first decoding result and the second decoding result satisfying a first condition, and the distribution result is a second decoding model, determining the sum of the semantic similarity and the difference as feedback of the first distribution model;
[0036] In response to the first decoding result and the second decoding result not satisfying a first condition, and the distribution result is a first decoding model, determining the sum of the semantic similarity and the difference as feedback of the first distribution model;
[0037] In response to the first decoding result and the second decoding result not satisfying the first condition, and the distribution result is the second decoding model, the feedback of the first distribution model is determined to be the first feedback.
[0038] According to a second aspect of the present disclosure, there is provided a data distribution device, comprising:
[0039] A distribution unit, configured to input the problem data into a first distribution model and determine a distribution result;
[0040] A first processing unit, in response to the distribution result being a first decoding model, is used to input the problem data into the first decoding model, and the problem data is processed by the first decoding model;
[0041] a second processing unit, in response to the distribution result being a second decoding model, for inputting the problem data into the second decoding model, so that the second decoding model processes the problem data;
[0042] The first decoding model and the second decoding model require different amounts of computing resources.
[0043] According to a third aspect of the present disclosure, there is provided an electronic device, including:
[0044] at least one processor; and
[0045] a memory communicatively connected to the at least one processor; wherein,
[0046] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method described in the present disclosure.
[0047] According to a fourth aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to cause the computer to execute the method described in the present disclosure.
[0048] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] The above and other objects, features and advantages of the exemplary embodiments of the present disclosure will become readily understood by reading the detailed description below with reference to the accompanying drawings. In the accompanying drawings, several embodiments of the present disclosure are shown in an exemplary and non-limiting manner, in which:
[0050] In the drawings, the same or corresponding reference numerals represent the same or corresponding parts.
[0051] Figure 1 A first optional flow chart of the data distribution method provided by the embodiment of the present disclosure is shown;
[0052] Figure 2 A second optional flow chart of the data distribution method provided by the embodiment of the present disclosure is shown;
[0053] Figure 3 A third optional flow chart of the data distribution method provided by the embodiment of the present disclosure is shown;
[0054] Figure 4 A fourth optional flow chart of the data distribution method provided by the embodiment of the present disclosure is shown;
[0055] Figure 5 An optional structural schematic diagram of a data distribution device provided by an embodiment of the present disclosure is shown;
[0056] Figure 6 A schematic diagram of the structure of an electronic device according to an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0057] In order to make the purpose, features, and advantages of the present disclosure more obvious and easy to understand, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present disclosure.
[0058] In the following description, reference is made to “some embodiments”, which describe a subset of all possible embodiments, but it can be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0059] In the following description, the terms "first\second" involved are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first\second" can be interchanged with a specific order or sequence where permitted, so that the embodiments of the present disclosure described herein can be implemented in an order other than that illustrated or described herein.
[0060] Unless otherwise defined, all technical and scientific terms used in this disclosure have the same meaning as those commonly understood by those skilled in the art to which this disclosure belongs. The terms used in this disclosure are only for the purpose of describing the embodiments of this disclosure and are not intended to limit this disclosure.
[0061] It should be understood that in the various embodiments of the present disclosure, the size of the serial number of each implementation process does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present disclosure.
[0062] Figure 1 A first optional flow chart of the data distribution method provided by the embodiment of the present disclosure is shown, and will be explained according to each step.
[0063] Step S101, inputting question data into the first distribution model.
[0064] In some embodiments, the data type of the question data may be image, text, audio or video; if the data type of the question data is image, the question data may represent a desired image processing method (such as local processing, global processing, regeneration, etc.); if the data type of the question data is text, the question data may represent a question that the first decoding model or the second decoding model is expected to answer; if the type of the question data is audio, the question data may represent a desired audio processing method (such as cropping, splicing, changing timbre, etc.); if the type of the question data is video, the question data may represent a video processing method.
[0065] In some embodiments, the first distribution model is used to distribute problem data to a first decoding model or a second decoding model; the first decoding model and the second decoding model require different amounts of computing resources. Assuming that the amount of computing resources required for the first decoding model is higher than that required for the second decoding model, the first decoding model takes longer to provide a response, but the quality of the response provided is higher; conversely, the second decoding model takes shorter time to provide a response, but the quality of the response provided is lower than that provided by the first decoding model.
[0066] In some optional embodiments, the first distribution model distributes the question data based on the question data and possible answers to the question data (i.e., decoding results) by the first decoding model and the second decoding model; if the question data is relatively easy to understand, or the answer corresponding to the question data is common sense; or the question data is relatively easy to process, then the first distribution model determines that the distribution result is the second decoding model; or, if the question data is relatively difficult to understand, or the answer corresponding to the question data requires a lot of retrieval and synthesis, or the question data is relatively difficult to process, then the first distribution model determines that the distribution result is the first decoding model.
[0067] Step S102: In response to the distribution result being the first decoding model, the problem data is input into the first decoding model, and the problem data is processed by the first decoding model.
[0068] In some embodiments, the first decoding model requires a higher amount of computing resources than the second decoding model, and may be a large model.
[0069] In some embodiments, the first decoding model processes the question data, obtains a decoding result (ie, an answer corresponding to the question data), and then returns the decoding result to the electronic device or module that issued the question data.
[0070] Step S103, in response to the distribution result being the second decoding model, inputting the problem data into the second decoding model, and the second decoding model processes the problem data.
[0071] In some embodiments, the second decoding model requires fewer computing resources than the first decoding model, and may be a lightweight model obtained by distillation of a large model, or other lightweight models.
[0072] In some embodiments, the second decoding model processes the problem data, obtains a decoding result, and then returns the decoding result to the electronic device or module that issued the problem data.
[0073] In this way, the data distribution method provided by the embodiment of the present disclosure distributes the data to models with different amounts of computing resources according to the difficulty of understanding and processing the question data. Accordingly, if the question data is difficult to understand or process, it will be processed by the first decoding model that requires more computing resources to ensure the quality of the answer; if the question data is easier to understand or process, it will be processed by the second decoding model that requires less computing resources to improve the processing time; in this way, both processing time and answer quality can be taken into account at the same time, thereby improving user experience.
[0074] Figure 2A second optional flow chart of the data distribution method provided in the embodiment of the present disclosure is shown and will be explained according to each step.
[0075] In some embodiments, the first distribution model involved in steps S101 to S103 is obtained based on training of the second distribution model, and the training of the second distribution model includes:
[0076] Step S201, determining a first decoding result generated by a first decoding model for first training data, and a second decoding result generated by a second decoding model for the first training data.
[0077] In some embodiments, a carrier implementing the data distribution method (hereinafter referred to as carrier) obtains the decoding results of the first decoding model and the second decoding model for the same training data. The carrier can be a computer program, an electronic circuit, a database, a mobile application, an electronic device, a cloud computing platform, a distributed system, an artificial intelligence framework, a mathematical model, an automation tool, and a microcontroller, etc., which can implement software or hardware of the algorithm and method flow.
[0078] Specifically, the first training data set includes several training data such as first training data and second training data; the carrier obtains the first decoding result and the second decoding result respectively obtained by the first decoding model and the second decoding model for the first training data; and so on, the carrier obtains the decoding results of the first decoding model and the second decoding model for all the training data in the first training data set.
[0079] In some embodiments, the first decoding result and the second decoding result may be the final result generated by the decoding model, or may be the next character (Token) generated by the decoding model; or may be all characters input to the decoding model at a certain moment.
[0080] Step S202: Train the second distribution model based on the first decoding result and the second decoding result, and determine that the trained second distribution model is the first distribution model.
[0081] In some embodiments, the first distribution model is used to distribute the first training data; if the first decoding result is the same as the second decoding result, the second distribution model distributes the first training data to the second decoding model; if the first decoding result is different from the second decoding result, the second distribution model distributes the first training data to the first decoding model.
[0082] The first decoding result and the second decoding result are the same, including that the first decoding result and the second decoding result are exactly the same (such as exactly the same text, exactly the same image, exactly the same video or audio), or the first decoding result and the second decoding result are semantically similar, or the first decoding result and the second decoding result have the same part exceeding a first threshold. The first threshold can be set according to actual needs.
[0083] Specifically, if the first decoding result is the same as the second decoding result, it means that the first decoding model and the second decoding model have the same processing capabilities for the first training data and achieve the same effect. In this case, in order to save computing resources and improve the reply speed, the second distribution model distributes the first training data to the second decoding model; if the first decoding result is different from the second decoding result, it means that the first decoding model and the second decoding model have inconsistent processing capabilities for the first training data. In order to ensure the quality of the reply, the second distribution model distributes the first training data to the first decoding model.
[0084] In some embodiments, the carrier labels the training data based on the decoding results of the first decoding model and the decoding results of the second decoding model corresponding to the training data; if the decoding results of the first decoding model and the decoding results of the second decoding model meet the first condition, the training data is labeled as the second decoding model; if the decoding results of the first decoding model and the decoding results of the second decoding model do not meet the first condition, the training data is labeled as the first decoding model; then the training data is input into the second distribution model to obtain the prediction results of the second distribution model for the training data, and the weight of the second distribution model is adjusted based on the prediction results and the labeling of the training data; the adjusted second distribution model is the first distribution model.
[0085] In this way, through the data distribution method provided by the embodiment of the present disclosure, the second distribution model is trained based on the decoding results of the first decoding model and the second decoding model on the same training data, so that the second distribution model can accurately distribute the training data that requires more computing resources to the first decoding model, and distribute the training data that does not require more computing resources to the second decoding model, thereby providing strong support for the subsequent distribution of problem data, taking into account both efficiency and accuracy.
[0086] Figure 3 A third optional flow chart of the data distribution method provided in the embodiment of the present disclosure is shown and will be explained according to each step.
[0087] Step S301, determining a first training data set.
[0088] In some embodiments, the carrier obtains decoding results of the first decoding model and the second decoding model for the same training data.
[0089] In some embodiments, the carrier inputs the second training data set into the first decoding model to obtain the first decoding data set; inputs the second training data set into the second decoding model to obtain the second decoding data set; the first training data set includes the correspondence between any training data in the second training data and the third decoding result output by the first decoding model based on the training data, and the correspondence between the training data and the fourth decoding result output by the second decoding model based on the training data.
[0090] Specifically, the second training data set includes several training data such as the first training data and the second training data; the carrier obtains the first decoding result of the first decoding model for the first training data and the probability distribution of the first decoding result, and obtains the second decoding result of the second decoding model for the first training data and the probability distribution of the second decoding result; and so on, the carrier obtains the decoding results of the first decoding model and the second decoding model for all the training data in the first training data set and the probability distribution of the decoding results. Determine the training data, the decoding results of the first decoding model and the second decoding model, and constitute the first training data set.
[0091] Step S302: training the second distribution model based on the first training data set to obtain the first distribution model.
[0092] In some embodiments, the carrier inputs the first training data into a second distribution model, determines a distribution result of a second decoding distribution module, adjusts the weight of the second distribution model based on the distribution result, the first decoding result and the second decoding result, and obtains a first distribution model.
[0093] Specifically, the carrier annotates the training data based on the decoding results of the first decoding model and the decoding results of the second decoding model corresponding to the training data; if the decoding results of the first decoding model and the decoding results of the second decoding model meet the first condition, the training data is annotated as the second decoding model; if the decoding results of the first decoding model and the decoding results of the second decoding model do not meet the first condition, the training data is annotated as the first decoding model; then the training data is input into the second distribution model to obtain the prediction results of the second distribution model for the training data, and the weight of the second distribution model is adjusted based on the prediction results and the annotation of the training data; the adjusted second distribution model is the first distribution model. The prediction results include distribution to the first decoding model and distribution to the second decoding model. Among them, the first condition includes that the first decoding result and the second decoding result are the same, or that the first decoding result and the second decoding result are semantically similar.
[0094] In some embodiments, the carrier can determine the loss function of the second distribution model based on the prediction results, the annotation of the training data and the cross entropy function, and adjust the weight of the second distribution model based on the loss function to obtain the first distribution model after adjustment.
[0095] Step S303: fine-tune the first distribution model based on the first training data set.
[0096] In some embodiments, the carrier inputs the first training data into the first distribution model, and determines feedback of the first distribution model based on the distribution result of the first distribution model, the first decoding result, the probability distribution of the first decoding result, the second decoding result, and the probability distribution of the second decoding result.
[0097] In some optional embodiments, the carrier determines the similarity between the first decoding result and the second decoding result; determines the difference measure between the probability distribution of the first decoding result and the probability distribution of the second decoding result; and determines the feedback of the first distribution model based on the first decoding result, the second decoding result, the distribution result, the semantic similarity and the difference. Wherein, the similarity includes one of semantic similarity, image similarity, video similarity and audio similarity, and the value range is [0,1]; the difference measure can be relative entropy, i.e., KL divergence (Kullback-LeiblerDivergence); a measure used to measure the difference between two probability distributions.
[0098] Specifically, in response to the first decoding result and the second decoding result satisfying the first condition, and the distribution result is the first decoding model, the feedback of the first distribution model is determined to be the first feedback; optionally, the first feedback is 0.
[0099] Alternatively, in response to the first decoding result and the second decoding result satisfying the first condition, and the distribution result is the second decoding model, the sum of the semantic similarity and the difference is determined as feedback of the first distribution model.
[0100] Alternatively, in response to the first decoding result and the second decoding result not satisfying the first condition, and the distribution result is the first decoding model, the sum of the semantic similarity and the difference is determined as feedback of the first distribution model.
[0101] Alternatively, in response to the first decoding result and the second decoding result not satisfying the first condition, and the distribution result is the second decoding model, the feedback of the first distribution model is determined to be the first feedback.
[0102] Furthermore, the carrier fine-tunes the first distribution model based on the feedback of the first distribution model and a proximal policy optimization algorithm (PPO).
[0103] In this way, through the data distribution method provided by the embodiment of the present disclosure, the second distribution model is trained based on the decoding results of the first decoding model and the second decoding model on the same training data, so that the second distribution model can accurately distribute the training data that requires more computing resources to the first decoding model, and distribute the training data that does not require more computing resources to the second decoding model, thereby providing strong support for the subsequent distribution of problem data, taking into account both efficiency and accuracy.
[0104] Figure 4 A fourth optional flow chart of the data distribution method provided in the embodiment of the present disclosure is shown and will be explained according to each step.
[0105] Step S401, obtaining a second decoding model based on the first decoding model.
[0106] In some embodiments, the carrier distills the first decoding model to obtain a second decoding model; the first decoding model may be a large model, and the second decoding model may be a lightweight model.
[0107] Step S402: pre-training the second distribution model based on a supervised learning method.
[0108] In some embodiments, the carrier constructs a training data set for the second distribution model based on the first decoding model and the second decoding model, that is, for the same context, the first decoding model and the second decoding model are used for processing at the same time. When the next characters generated by the two models are the same, the second distribution model needs to distribute the current training data to the second decoding model for processing. When the next characters generated by the two models are different, the second distribution model needs to distribute the current context to the first decoding model for processing. In this way, the training data set for the second distribution model (i.e., the second training data set) is constructed to pre-train the second distribution model.
[0109] For example, Figure 4 As shown, when the context is "Please introduce yourself", the decoding result of the first decoding model is "Hello, my name is Zhidian"; the result of the second decoding model is "Hello, my name is Zhijiao"; the decoding results of the two are different, so the second distribution model needs to distribute the current training data to the first decoding model for processing.
[0110] Furthermore, the carrier can train the second distribution model in combination with the context, the decoding results of the first decoding model and the decoding results of the second decoding model; the carrier can train the second distribution model based on the context and the characters and the next character already generated by the first decoding model, as well as the context and the characters and the next character already generated by the second decoding model.
[0111] Specifically, the carrier determines whether the next character generated by the first decoding model based on the latest context and the next character already generated by the second decoding model are the same; if the two are the same, the context and the character already generated by the second decoding model are sent to the second decoding model as a new context; if the two are different, the context and the character already generated by the first decoding model are sent to the first decoding model as a new context.
[0112] Still taking the case where the context is “Please introduce yourself”, the decoding result of the first decoding model is “Hello, my name is Zhidian”; the result of the second decoding model is “Hello, my name is Zhijiao”, and the context is “Q: Please introduce yourself”, when the context is just input into the first decoding model and the second decoding model, the next character generated by the first decoding model and the second decoding model is both “you”, so the current context “Please introduce yourself” is taken as the new context and input into the second decoding model; for the new context, the next character of the first decoding model and the second decoding model is both “good”, at this time the combination of the context of the two and the generated character (ie “you”) is “Q: Please introduce yourself; you”, so it is determined that “Q: Please introduce yourself; you” should be input into the second decoding model as the new context.
[0113] Then, "hello" becomes the generated character of the first decoding model and the second decoding model, and the next character of both is "," , at this time, the combination of the context of the two and the generated characters is "Q: Please introduce yourself; hello"; determine that "Q: Please introduce yourself; hello" should be input into the second decoding model as the new context; and so on, obtain the combination of the context of the two and the generated characters in turn: "Q: Please introduce yourself; hello," "Q: Please introduce yourself; hello, me", "Q: Please introduce yourself; hello, my", "Q: Please introduce yourself; hello, my name", "Q: Please introduce yourself; hello, my name", "Q: Please introduce yourself; hello, my name is", "Q: Please introduce yourself; hello, my name is Zhi".
[0114] Based on the decoding results of the first decoding model and the second decoding model, the next characters of the next two decoding models are different. That is, the next character of the first decoding model is "point", and the next character of the second decoding model is "teach". Therefore, "Question: Please introduce yourself; Hello, my name is Zhi" is used as the new context and input into the first decoding model. Further, the characters generated subsequently by the first decoding model and the second decoding model are the same, both being ".", so the subsequent processing is performed by the second decoding model.
[0115] In some embodiments, the second distribution model can be regarded as a classification task, and a classification model constructed by using conventional classification models such as BERT, Roberta and other PTMs can be used to complete it. According to actual needs, lightweight models of different magnitudes can be distilled from large models, and the training data set of the multi-class second distribution model can be constructed in the manner of step S402, so that the second distribution model supports distribution to multiple models.
[0116] Step S403, fine-tune the first distribution model based on the reinforcement learning method.
[0117] In some embodiments, as Figure 4 shown, the first distribution model decodes (or processes, that is, obtains the answer corresponding to the Context) for the same Context by using the first decoding model and the second decoding model at the same time, and can obtain the probability distribution p1 of the first decoding model at the next token and the corresponding first decoding result t1, as well as the probability distribution p2 of the second decoding model at the next token, and the corresponding second decoding result t2. The context and the first decoding result t1 (that is, Context + t1) are used as the new context and input into the first decoding model to obtain the first decoding result at the next moment (or the next one); the context and the second decoding result t2 (that is, Context + t2) are used as the new context and input into the second decoding model to obtain the second decoding result at the next moment.
[0118] In some embodiments, the carrier can calculate the semantic similarity sim_score of (Context + t1) and (Context + t2) through the semantic matching model, and the value range of the semantic similarity is [0, 1]. That is, the carrier determines the semantic similarity between the first training data and the first decoding result (Context + t1), and between the first training data and the second decoding result (Context + t2). The carrier determines the KL divergence of the probability distribution p1 and the probability distribution p2, that is, kl(p1, p2).
[0119] In some embodiments, if the first decoding result and the second decoding result satisfy the first condition, and the first distribution model distributes the first training data to the first decoding model, then the feedback (reward) of the first distribution model is determined to be 0; if the first decoding result and the second decoding result satisfy the first condition, and the first distribution model distributes the first training data to the second decoding model, then the feedback of the first distribution model is determined to be sim_score+kl(p1,p2).
[0120] like Figure 4 As shown, the carrier calculates the feedback of the first distribution model based on the probability distribution p1, the probability distribution p2, the semantic similarity sim_score, the first decoding result and the second decoding result, performs reinforcement learning update (Pro RL update) based on the feedback, obtains the updated weight of the first distribution model, and fine-tunes the first distribution model based on the updated weight. RL is the abbreviation of Reinforcement Learning.
[0121] In other embodiments, if the first decoding result and the second decoding result do not satisfy the first condition, and the first distribution model distributes the first training data to the first decoding model, then the feedback of the first distribution model is determined to be sim_score+kl(p1,p2); if the first decoding result and the second decoding result do not satisfy the first condition, and the first distribution model distributes the first training data to the second decoding model, then the feedback of the first distribution model is determined to be 0.
[0122] In some embodiments, the carrier fine-tunes the first distribution model based on the feedback of the first distribution model in combination with PPO. The semantic similarity calculation model adopts a conventional classification model such as a binary classification model constructed by PTM such as BERT and Roberta.
[0123] Step S404: perform inference prediction based on the first distribution model.
[0124] In some embodiments, during the inference stage, the problem data is input into a first distribution model to determine a distribution result; in response to the distribution result being a first decoding model, the problem data is input into the first decoding model, and the problem data is processed by the first decoding model; in response to the distribution result being a second decoding model, the problem data is input into the second decoding model, and the problem data is processed by the second decoding model.
[0125] In some embodiments, the first decoding model and the second decoding model are input into the corresponding decoding models based on the problem data and the generated decoding results as new contexts, and finally obtain the results of the problem data.
[0126] In this way, the data distribution method provided by the embodiment of the present disclosure is implemented by the first decoding model, the second decoding model and the first distribution model. The first distribution model understands the problem data and determines to distribute it to the first decoding model or the second decoding model. The first decoding model or the second decoding model determines the next character to be output based on the problem data, and then repeats the above process until the generation task is completed. Compared with using only the first decoding model or only the second decoding model, the data distribution method provided by the embodiment of the present disclosure can take into account both the response speed and the response quality. Compared with the speculative sampling method, it can avoid the problem of having to be evaluated by a large model after generating a certain number of characters, and can obtain a higher acceleration effect.
[0127] Figure 5 An optional structural schematic diagram of a data distribution device provided in an embodiment of the present disclosure is shown, and will be described according to each part.
[0128] In some embodiments, the data distribution device 500 includes a distribution unit 501 , a first processing unit 502 , and a second processing unit 503 .
[0129] The distribution unit 501 is used to input the question data into the first distribution model to determine the distribution result;
[0130] The first processing unit 502, in response to the distribution result being the first decoding model, is used to input the problem data into the first decoding model, so that the first decoding model processes the problem data;
[0131] The second processing unit 503, in response to the distribution result being the second decoding model, is used to input the problem data into the second decoding model, and the second decoding model processes the problem data;
[0132] The first decoding model and the second decoding model require different amounts of computing resources.
[0133] In some embodiments, the data distribution device 500 may further include a training unit 504 .
[0134] The training unit 504 is used to train the second distribution model based on the first decoding result generated by the first decoding model for the first training data and the second decoding result generated by the second decoding model for the first training data before the distribution unit 501 inputs the problem data into the first distribution model and determines the distribution result, and determines that the trained second distribution model is the first distribution model;
[0135] The first distribution model is used to distribute the first training data; if the first decoding result is the same as the second decoding result, the second distribution model distributes the first training data to the second decoding model; if the first decoding result is different from the second decoding result, the second distribution model distributes the first training data to the first decoding model.
[0136] The training unit 504 may be used to determine a first training data set; the first training data set includes the first training data, a first decoding result obtained by inputting the first training data into a first decoding model and a probability distribution of the first decoding result, and a second decoding result obtained by inputting the first training data into a second decoding model and a probability distribution of the second decoding result;
[0137] Inputting the first training data into a second distribution model, determining a distribution result of a second decoding distribution module, and adjusting a weight of the second distribution model based on the distribution result, the first decoding result, and the second decoding result to obtain a first distribution model;
[0138] Inputting the first training data into the first distribution model, and determining feedback of the first distribution model based on a distribution result of the first distribution model, a first decoding result, a probability distribution of the first decoding result, a second decoding result, and a probability distribution of the second decoding result;
[0139] Adjusting a weight of the first distribution model based on feedback from the first distribution model;
[0140] Among them, the first decoding model requires more computing resources to run than the second decoding model.
[0141] The training unit 504 may be used to input the second training data set into the first decoding model to obtain a first decoding data set;
[0142] Inputting the second training data set into the second decoding model to obtain a second decoded data set;
[0143] Determine the first training data set based on the second training data set, the first decoded data set and the second decoded data set;
[0144] The first training data set includes the correspondence between any training data in the second training data and the third decoding result output by the first decoding model based on the training data, and the correspondence between the training data and the fourth decoding result output by the second decoding model based on the training data.
[0145] The training unit 504 may be configured to determine whether the first decoding result and the second decoding result satisfy a first condition;
[0146] In response to the first decoding result and the second decoding result satisfying the first condition, determining that the annotation label of the first training data is the second decoding model; or, in response to the first decoding result and the second decoding result not satisfying the first condition, determining that the annotation label of the first training data is the first decoding model;
[0147] Determine a loss function of the second distribution model based on the marked label and the distribution result, and adjust a weight of the second distribution model based on the loss function to obtain a first distribution model;
[0148] The first condition includes that the first decoding result and the second decoding result are the same, or the first decoding result and the second decoding result are semantically similar.
[0149] The training unit 504 may be used to determine the semantic similarity between the first decoding result and the second decoding result;
[0150] Determining a difference measure between the first decoding result probability distribution and the second decoding result probability distribution;
[0151] Feedback of the first distribution model is determined based on the first decoding result, the second decoding result, the distribution result, the semantic similarity, and the difference.
[0152] The training unit 504 may be used for one of the following:
[0153] In response to the first decoding result and the second decoding result satisfying a first condition, and the distribution result is a first decoding model, determining feedback of the first distribution model as first feedback;
[0154] In response to the first decoding result and the second decoding result satisfying a first condition, and the distribution result is a second decoding model, determining the sum of the semantic similarity and the difference as feedback of the first distribution model;
[0155] In response to the first decoding result and the second decoding result not satisfying a first condition, and the distribution result is a first decoding model, determining the sum of the semantic similarity and the difference as feedback of the first distribution model;
[0156] In response to the first decoding result and the second decoding result not satisfying the first condition, and the distribution result is the second decoding model, the feedback of the first distribution model is determined to be the first feedback.
[0157] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device and a readable storage medium.
[0158] Figure 6 A schematic block diagram of an example electronic device 800 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0159] like Figure 6 As shown, the electronic device 800 includes a computing unit 801, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 802 or a computer program loaded from a storage unit 808 into a random access memory (RAM) 803. In the RAM 803, various programs and data required for the operation of the electronic device 800 can also be stored. The computing unit 801, the ROM 802, and the RAM 803 are connected to each other via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.
[0160] Multiple components in the electronic device 800 are connected to the I / O interface 805, including: an input unit 806, such as a keyboard, a mouse, etc.; an output unit 807, such as various types of displays, speakers, etc.; a storage unit 808, such as a disk, an optical disk, etc.; and a communication unit 809, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 809 allows the electronic device 800 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0161] The computing unit 801 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 801 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 801 performs the various methods and processes described above, such as the data distribution method. For example, in some embodiments, the data distribution method may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 808. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 800 via ROM 802 and / or communication unit 809. When the computer program is loaded into RAM 803 and executed by the computing unit 801, one or more steps of the data distribution method described above may be performed. Alternatively, in other embodiments, the computing unit 801 may be configured to perform the data distribution method in any other appropriate manner (e.g., by means of firmware).
[0162] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0163] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0164] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0165] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0166] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0167] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.
[0168] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.
[0169] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of the present disclosure, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.
[0170] The above is only a specific embodiment of the present disclosure, but the protection scope of the present disclosure is not limited thereto. Any person skilled in the art who is familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present disclosure, which should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.
Claims
1. A data distribution method, the method comprising: Inputting the problem data into the first distribution model to determine the distribution result; In response to the distribution result being the first decoding model, the question data is input into the first decoding model, and the question data is processed by the first decoding model; In response to the distribution result being the second decoding model, the question data is input into the second decoding model, and the question data is processed by the second decoding model; The first decoding model and the second decoding model require different amounts of computing resources.
2. The method according to claim 1, before inputting the problem data into the first distribution model and determining the distribution result, the method further comprises: Based on the first decoding result generated by the first decoding model for the first training data and the second decoding result generated by the second decoding model for the first training data, training the second distribution model, and determining that the trained second distribution model is the first distribution model; The first distribution model is used to distribute the first training data; if the first decoding result is the same as the second decoding result, the second distribution model distributes the first training data to the second decoding model; if the first decoding result is different from the second decoding result, the second distribution model distributes the first training data to the first decoding model.
3. The method according to claim 2, wherein the training of the second distribution model based on the first decoding result generated by the first decoding model for the first training data and the second decoding result generated by the second decoding model for the first training data comprises: Determining a first training data set; The first training data set includes first training data, a first decoding result obtained by inputting the first training data into a first decoding model and a probability distribution of the first decoding result, and a second decoding result obtained by inputting the first training data into a second decoding model and a probability distribution of the second decoding result; Inputting the first training data into a second distribution model, determining a distribution result of a second decoding distribution module, and adjusting a weight of the second distribution model based on the distribution result, the first decoding result, and the second decoding result to obtain a first distribution model; Inputting the first training data into the first distribution model, and determining feedback of the first distribution model based on a distribution result of the first distribution model, a first decoding result, a probability distribution of the first decoding result, a second decoding result, and a probability distribution of the second decoding result; Adjusting a weight of the first distribution model based on feedback from the first distribution model; Among them, the first decoding model requires more computing resources to run than the second decoding model.
4. The method according to claim 3, wherein determining the first training data set comprises: Inputting the second training data set into the first decoding model to obtain a first decoding data set; Inputting the second training data set into the second decoding model to obtain a second decoded data set; Determine the first training data set based on the second training data set, the first decoded data set and the second decoded data set; The first training data set includes the correspondence between any training data in the second training data and the third decoding result output by the first decoding model based on the training data, and the correspondence between the training data and the fourth decoding result output by the second decoding model based on the training data.
5. The method according to claim 3, wherein the distribution result comprises distributing the first training data to a first decoding model or a second decoding model for processing, and adjusting the weight of the second distribution model based on the distribution result, the first decoding result, and the second decoding result to obtain the first distribution model comprises: Determining whether the first decoding result and the second decoding result satisfy a first condition; In response to the first decoding result and the second decoding result satisfying the first condition, determining that the annotation label of the first training data is a second decoding model; Alternatively, in response to the first decoding result and the second decoding result not satisfying the first condition, determining that the annotation label of the first training data is a first decoding model; Determine a loss function of the second distribution model based on the marked label and the distribution result, and adjust a weight of the second distribution model based on the loss function to obtain a first distribution model; The first condition includes that the first decoding result and the second decoding result are the same, or the first decoding result and the second decoding result are semantically similar.
6. The method according to claim 3, wherein inputting the first training data into the first distribution model, and determining feedback of the first distribution model based on the distribution result of the first distribution model, the first decoding result, the probability distribution of the first decoding result, the second decoding result, and the second decoding result probability distribution, comprises: Determining semantic similarity between the first decoding result and the second decoding result; Determining a difference measure between the first decoding result probability distribution and the second decoding result probability distribution; Feedback of the first distribution model is determined based on the first decoding result, the second decoding result, the distribution result, the semantic similarity, and the difference.
7. The method according to claim 6, wherein the determining feedback of the first distribution model based on the first decoding result, the second decoding result, the distribution result, the semantic similarity and the difference comprises one of the following: In response to the first decoding result and the second decoding result satisfying a first condition, and the distribution result is a first decoding model, determining feedback of the first distribution model as first feedback; In response to the first decoding result and the second decoding result satisfying a first condition, and the distribution result is a second decoding model, determining the sum of the semantic similarity and the difference as feedback of the first distribution model; In response to the first decoding result and the second decoding result not satisfying a first condition, and the distribution result is a first decoding model, determining the sum of the semantic similarity and the difference as feedback of the first distribution model; In response to the first decoding result and the second decoding result not satisfying the first condition, and the distribution result is the second decoding model, the feedback of the first distribution model is determined to be the first feedback.
8. A data distribution device, comprising: A distribution unit, configured to input the problem data into a first distribution model and determine a distribution result; A first processing unit, in response to the distribution result being a first decoding model, is used to input the problem data into the first decoding model, and the problem data is processed by the first decoding model; a second processing unit, in response to the distribution result being a second decoding model, for inputting the problem data into the second decoding model, so that the second decoding model processes the problem data; The first decoding model and the second decoding model require different amounts of computing resources.
9. An electronic device, characterized in that: include: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor so that the at least one processor can execute: Inputting the problem data into the first distribution model to determine the distribution result; In response to the distribution result being the first decoding model, the question data is input into the first decoding model, and the question data is processed by the first decoding model; In response to the distribution result being the second decoding model, the question data is input into the second decoding model, and the question data is processed by the second decoding model; The first decoding model and the second decoding model require different amounts of computing resources.
10. A non-transitory computer-readable storage medium storing computer instructions, characterized in that: The computer instructions are used to cause the computer to execute: Inputting the problem data into the first distribution model to determine the distribution result; In response to the distribution result being the first decoding model, the question data is input into the first decoding model, and the question data is processed by the first decoding model; In response to the distribution result being the second decoding model, the question data is input into the second decoding model, and the question data is processed by the second decoding model; The first decoding model and the second decoding model require different amounts of computing resources.