Task perception decoding method, device and equipment of large language model and storage medium
By using the initial and adjusted probability distributions to calculate the knowledge vector and merge the probability distribution in the fine-tuning process of large language model, the problems of strong dependence, high cost and insufficient adaptability in the existing technology are solved, and the more Efficient downstream tasks adaptation and wider application.
Patent Information
- Application Number
- CN202411552438.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-01
- Publication Date
- 2025-02-18
AI Technical Summary
Existing large language model fine-tuning methods rely on high-quality data, are expensive, do not fully utilize the model's inherent knowledge, and are insufficient to adapt to downstream tasks.
By determining the first and second conditional probability distributions of the output label of the initial large language model, the fine-tuning space vector is calculated, the knowledge vector is generated using the adjustment formula and activation function, and the probability distribution is merged to obtain the target probability distribution, thereby guiding the fine-tuning model Output.
Reliance on high-quality data is reduced, data costs are reduced, model adaptability and performance in downstream tasks are improved, and the wide applicability and practical application of the model are enhanced.
Smart Images

Figure CN119476441A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of large language models, and in particular to a task-aware decoding method, apparatus, device and storage medium for a large language model. Background Art
[0002] Large Language Models (LLMs) have achieved remarkable achievements in various natural language processing tasks. These achievements are mainly attributed to the enhancement of pre-trained LLMs in downstream tasks by various technical means. Among them, fine-tuning is a common and effective strategy that aims to improve model performance by optimizing algorithms and constructing efficient datasets.
[0003] The work of adapting pre-trained large models to downstream tasks mainly focuses on two aspects: fine-tuning methods and training dataset construction. In terms of fine-tuning methods, parameter-efficient fine-tuning methods are gaining more and more attention from researchers because they can fix most of the model parameters while still maintaining the model's effect. At the same time, in order to make the output of the large model more in line with human expectations, fine-tuning the large model often requires the introduction of more manually annotated training data, which results in higher labor costs. On the contrary, some studies automatically generate high-quality training data by maximizing the use of existing datasets. For example, some studies enriched the training instances by flipping the input-output pairs of existing instances using standardized task descriptions; or by using manually written task descriptions to augment the labeled dataset to guide the large model to better understand downstream tasks.
[0004] In addition to the above studies, researchers have also tried to improve the adaptation performance of large models in downstream tasks by focusing on the endogenous features of large models. For example, some studies use post-pre-training activation value editing to adjust the output of large models; some studies have proved that both neural network trained and manually selected steering vectors can effectively improve the style transfer of large models, and other studies have improved the performance of large models in downstream tasks by intervening during inference by discovering activation value vectors based on positive and negative examples. Compared with the improved methods for fine-tuning methods and training data sets, the above methods have lower training and data costs.
[0005] However, the related technologies have the following defects: (1) Dependence on high-quality data: The fine-tuning methods in the related technologies are highly dependent on high-quality manually annotated data. The construction and annotation costs of these datasets are high, which not only increases resource investment but also limits the widespread application of fine-tuning methods. (2) Inadequate use of the intrinsic knowledge of the model: Pre-trained LLMs have correct intrinsic knowledge in many cases, but the fine-tuning methods in the related technologies do not fully explore and utilize this knowledge. Specifically, even if the model generates incorrect outputs, its intermediate representation may still be correct. In addition, pre-trained LLMs can self-evaluate their correctness to a certain extent. If this intrinsic knowledge can be effectively utilized, it will greatly improve the performance of the model. (3) Insufficient ability to adapt to downstream tasks: The related technologies perform poorly in the process of transforming the common sense knowledge in the pre-training stage to the specific knowledge of downstream tasks. Specifically, the model does not fully utilize its changes in token prediction behavior to enhance its adaptability to specific tasks during the fine-tuning process. This lack of adaptive transformation limits the performance and stability of the model in downstream tasks.
[0006] In summary, the fine-tuning methods in related technologies usually ignore the utilization of the model's intrinsic knowledge, that is, they fail to fully explore and utilize the knowledge that the pre-trained model already has during the fine-tuning process. In view of this, there is an urgent need for a technology that can effectively utilize the model's intrinsic knowledge during the fine-tuning process to further improve the model's performance in various downstream tasks. Summary of the invention
[0007] The present application provides a task-aware decoding method, device, electronic device and storage medium for a large language model to solve the problems of related technologies being too dependent on high-quality data, too high data costs, poor model applicability and general practical application effects. The present application can better utilize the inherent knowledge of the large language model, enhance the adaptability and performance of the large language model in downstream tasks, reduce the dependence of the large language model on high-quality data, reduce data costs, and improve the wide applicability and practical application effects of the model.
[0008] The first aspect of the present application provides a task-aware decoding method for a large language model, comprising the following steps:
[0009] Determine a first conditional probability distribution of output labels of an initial large language model, adjust the initial large language model based on a preset algorithm, and determine a second conditional probability distribution of output labels of the adjusted initial large language model;
[0010] Determine a fine-tuning space vector according to the first conditional probability distribution and the second conditional probability distribution, adjust the fine-tuning space vector using a preset adjustment formula to obtain a knowledge vector, and convert the knowledge vector into a fine-tuning probability distribution using a preset activation function;
[0011] The fine-tuned probability distribution and the second conditional probability distribution are combined using a preset combination formula to obtain a target probability distribution, and the output result of the fine-tuned large language model is guided according to the target probability distribution.
[0012] Optionally, in some embodiments, the preset merging formula is:
[0013]
[0014] in, is the target probability distribution, μ is the weight coefficient, p φ (x t |x <t ) is the second conditional probability distribution, p K (x t |x <t ) is the fine-tuning probability distribution.
[0015] Optionally, in some embodiments, adjusting the fine-tuning space vector using a preset adjustment formula to obtain a knowledge vector includes:
[0016] According to the preset indicator function, the fine-tuning space vector is adjusted using the preset adjustment formula to obtain a knowledge vector, wherein the preset adjustment formula is:
[0017]
[0018] in, is the knowledge vector, is the preset indicator function, λ is the penalty coefficient, x t A token with a weight.
[0019] Optionally, in some embodiments, adjusting the fine-tuning space vector to obtain the knowledge vector using the preset adjustment formula according to the preset indicator function includes:
[0020] Based on a preset constraint function and according to a preset indicator function, the fine-tuning space vector is adjusted using the preset adjustment formula to obtain a knowledge vector, wherein the preset indicator function is:
[0021]
[0022] Among them, C t is the preset constraint function.
[0023] Optionally, in some embodiments, the preset constraint function is:
[0024]
[0025] in, is the vocabulary, a is the constraint range, x t ˊ is a token with a weight.
[0026] A second aspect of the present application provides a task-aware decoding device for a large language model, including:
[0027] A determination module, configured to determine a first conditional probability distribution of output labels of an initial large language model, adjust the initial large language model based on a preset algorithm, and determine a second conditional probability distribution of output labels of the adjusted initial large language model;
[0028] an adjustment module, configured to determine a fine-tuning space vector according to the first conditional probability distribution and the second conditional probability distribution, adjust the fine-tuning space vector using a preset adjustment formula to obtain a knowledge vector, and convert the knowledge vector into a fine-tuning probability distribution using a preset activation function;
[0029] The task-aware decoding module is used to combine the fine-tuned probability distribution and the second conditional probability distribution using a preset merging formula to obtain a target probability distribution, and guide the output result of the fine-tuned large language model according to the target probability distribution.
[0030] Optionally, in some embodiments, the preset merging formula is:
[0031]
[0032] in, is the target probability distribution, u is the weight coefficient, p φ (x t |x <t ) is the second conditional probability distribution, p K (x t |x <t ) is the fine-tuning probability distribution.
[0033] Optionally, in some embodiments, the adjustment module includes:
[0034] An adjustment unit is used to adjust the fine-tuning space vector according to a preset indicator function using the preset adjustment formula to obtain a knowledge vector, wherein the preset adjustment formula is:
[0035]
[0036] in, is the knowledge vector, is the preset indicator function, λ is the penalty coefficient, x t A token with a weight.
[0037] Optionally, in some embodiments, adjusting the fine-tuning space vector to obtain the knowledge vector using the preset adjustment formula according to the preset indicator function includes:
[0038] Based on a preset constraint function and according to a preset indicator function, the fine-tuning space vector is adjusted using the preset adjustment formula to obtain a knowledge vector, wherein the preset indicator function is:
[0039]
[0040] Among them, C t is the preset constraint function.
[0041] Optionally, in some embodiments, the preset constraint function is:
[0042]
[0043] Among them, v is the vocabulary, α is the constraint range, and x t ˊ is a token with a weight.
[0044] The third aspect of the present application provides an electronic device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the task-aware decoding method of the large language model as described in the above embodiment.
[0045] The fourth aspect of the present application provides a computer-readable storage medium having a computer program stored thereon, which is executed by a processor to implement the task-aware decoding method of a large language model as described in the above embodiments.
[0046] Therefore, this application has at least the following beneficial effects:
[0047] (1) Improving downstream task performance: The large language task-aware decoding method proposed in the embodiment of the present application improves the performance of large language models (LLMs) in downstream tasks by utilizing the difference in output probability distribution before and after fine-tuning. It also shows excellent results on various data sets and task categories by aligning the final output probability distribution to the direction of transition from general knowledge to specific downstream task knowledge.
[0048] (2) No need to modify the model structure: The large language task-aware decoding method proposed in the embodiment of the present application is a plug-and-play method that does not require any modification to the original large language model structure. It has wide applicability and can be used in combination with different LLMs and various fine-tuning methods to improve model performance.
[0049] (3) Improved performance in data-scarce scenarios: The large language task-aware decoding method proposed in the embodiment of the present application performs particularly well in data-scarce scenarios. Even when labeled data is limited, it can still significantly enhance the performance of the large language model and reduce the dependence of the large language model on high-quality data.
[0050] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:
[0052] Figure 1 A flowchart of a task-aware decoding method for a large language model provided according to an embodiment of the present application;
[0053] Figure 2 A schematic diagram of the principle of a task-aware decoding method for a large language model provided according to an embodiment of the present application;
[0054] Figure 3 A schematic diagram of an application of a task-aware decoding method for a large language model provided according to an embodiment of the present application;
[0055] Figure 4 This is an example diagram of a task-aware decoding device for a large language model provided according to an embodiment of the present application;
[0056] Figure 5 It is a schematic diagram of the structure of an electronic device provided according to an embodiment of the present application. DETAILED DESCRIPTION
[0057] Embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present application, and should not be construed as limiting the present application.
[0058] The following describes the task-aware decoding method, device, electronic device and storage medium of the large language model of the embodiment of the present application with reference to the accompanying drawings. In view of the problems that the related technologies mentioned in the above background technology are too dependent on high-quality data, the data cost is too high, the model applicability is poor and the actual application effect is general, the present application provides a task-aware decoding method for a large language model, in which the first conditional probability distribution of the output label of the initial large language model is determined, and the initial large language model is adjusted based on a preset algorithm, and the second conditional probability distribution of the output label of the adjusted initial large language model is determined; the fine-tuning space vector is determined according to the first conditional probability distribution and the second conditional probability distribution, the fine-tuning space vector is adjusted using a preset adjustment formula to obtain a knowledge vector, and the knowledge vector is converted into a fine-tuning probability distribution using a preset activation function; the fine-tuning probability distribution and the second conditional probability distribution are merged using a preset merging formula to obtain a target probability distribution, and the output result of the fine-tuned large language model is guided according to the target probability distribution. As a result, the problems of related technologies being too dependent on high-quality data, too high data costs, poor model applicability and general actual application effects are solved. This can better utilize the intrinsic knowledge of the large language model, enhance the adaptability and performance of the large language model in downstream tasks, reduce the dependence of the large language model on high-quality data, reduce data costs, and improve the wide applicability and practical application effects of the model.
[0059] Specifically, Figure 1 A flowchart of a task-aware decoding method for a large language model provided in an embodiment of the present application.
[0060] like Figure 1 As shown, the task-aware decoding method of the large language model includes the following steps:
[0061] In step S101, a first conditional probability distribution of output labels of an initial large language model is determined, and the initial large language model is adjusted based on a preset algorithm, and a second conditional probability distribution of output labels of the adjusted initial large language model is determined.
[0062] The preset algorithm may be any fine-tuning method, for example, LoRA, Adapter, etc.
[0063] Specifically, for a pre-trained initial large language model θ, the first conditional probability distribution of the output token is as follows:
[0064]
[0065] Among them, p θ (x t |x <t ) is the first conditional probability distribution, is the vocabulary, t represents the position of the token, and after applying the fine-tuning method Φ on the initial large language model θ, the adjusted initial large language model φ is obtained:
[0066] φ=Φ(θ,D)
[0067] Among them, D represents the training dataset of the downstream task. Similarly, for an adjusted initial large language model φ, the second conditional probability distribution of the token is as follows:
[0068]
[0069] Among them, p φ (x t |x <t ) is the second conditional probability distribution.
[0070] In step S102, a fine-tuning space vector is determined according to the first conditional probability distribution and the second conditional probability distribution, the fine-tuning space vector is adjusted using a preset adjustment formula to obtain a knowledge vector, and the knowledge vector is converted into a fine-tuning probability distribution using a preset activation function.
[0071] Among them, the preset activation function can be a softmax function.
[0072] Specifically, Figure 2 As shown, for a given vocabulary The size of p at each moment t θ (x t |x <t ) and p φ (x t |x <t ) can be regarded as dimensional space. From this, we can deduce the logarithmic meaning dimensional space vector V K . Let the vector point from the direction of the fine-tuning start to the direction of the fine-tuning end:
[0073] V K =log p φ (x t |x <t )-log p θ (x t |x <t );
[0074] Among them, V K is the fine-tuning space vector, which represents the change in conditional probability during the fine-tuning process and indicates the direction of movement from general knowledge to downstream task-specific knowledge. It should be noted that V KIt directly reflects the impact of fine-tuning on the probability distribution of model output and emphasizes the interpretability factor in the fine-tuning process.
[0075] It should be noted that V K May trigger a false positive situation, for example, for some p φ and p θ Very low tokens (e.g. 10 -5 and 10 -10 ), V calculated by the above formula K It may be very large, which will misleadingly indicate a wrong direction towards the corresponding dimension. Therefore, the embodiment of the present application introduces a preset constraint function C t To ensure that the probability of outputting a token is at least α times the probability of the maximum token.
[0076]
[0077] Optionally, in some embodiments, according to a preset indicator function, the fine-tuning space vector is adjusted using a preset adjustment formula to obtain the knowledge vector, including: based on a preset constraint function, according to a preset indicator function, the fine-tuning space vector is adjusted using a preset adjustment formula to obtain the knowledge vector, wherein the preset indicator function is:
[0078]
[0079] Among them, C t is the preset constraint function.
[0080] It is understandable that the preset indicator function points out tokenx t Whether the constraint function is satisfied, the embodiment of the present application can introduce a penalty coefficient λ to impose a penalty on the token that does not meet the constraint function, while keeping other tokens as the original V K The embodiment of the present application can adjust the fine-tuning space vector according to the preset indicator function and use the preset adjustment formula to obtain the knowledge vector, wherein the preset adjustment formula is:
[0081]
[0082] in, is the knowledge vector, is the preset indicator function, λ is the penalty coefficient, x t A token with a weight.
[0083] This gives us the final knowledge vector
[0084] After obtaining the final knowledge vector, the embodiment of the present application can optimize the probability output of the fine-tuned model based on the constructed knowledge vector, aiming to amplify the downstream task knowledge learned by the model during the fine-tuning process. It should be noted that It is not a probability distribution. Therefore, the embodiment of the present application needs to apply the softmax function on the basis of the knowledge vector to convert it into a fine-tuned probability distribution:
[0085]
[0086] Among them, p K (x t |x <t ) is the fine-tuning probability distribution, softmax is the preset activation function, is the knowledge vector.
[0087] In step S103, the fine-tuning probability distribution and the second conditional probability distribution are merged using a preset merging formula to obtain a target probability distribution, and the output result of the fine-tuned large language model is guided according to the target probability distribution.
[0088] Among them, the preset merging formula is:
[0089]
[0090] In this embodiment of the present application, a weight parameter μ can be used to combine p φ (x t |x <t ) and p K (x t |x <t ) to obtain the target probability distribution
[0091] exist Based on this, it can be applied in various basic decoding methods for text generation.
[0092] In order to enable relevant technical personnel in the field to further understand the task-aware decoding method of the large language model in the embodiment of the present application, it is elaborated in detail below in combination with specific embodiments.
[0093] Figure 3 A schematic diagram of the application of the task-aware decoding method of a large language model provided by an embodiment of the present application.
[0094] In an embodiment of the present application, the pre-trained model is fine-tuned on a biological field dataset.
[0095] When the user asked for a professional explanation of the word photosynthesis, both the pre-trained large language model (Pre-trained LLM) and the fine-tuned large language model (Fine-tuned LLM) output engage in the word plants instead of the more professional catalyst.
[0096] It can be noticed that the prediction probability of the word "catalyze" is significantly improved and the prediction probability of the word "engage" is significantly reduced compared to the pre-trained model and the fine-tuned model. However, since the fine-tuning dataset is smaller than the pre-training corpus, the model still has the highest prediction probability for the word "engage".
[0097] The knowledge vector proposed in the embodiment of the present application captures this probability change of the fine-tuning process, constructs a knowledge vector, and applies it to the output probability distribution after fine-tuning, amplifying the effect of the fine-tuning process. Ultimately, the prediction probability of the word "catalyze" is further improved to the highest level, and the model output after downstream task-aware decoding can better respond to user input (asking for professional explanations) and perform better on downstream tasks.
[0098] According to the task-aware decoding method of the large language model proposed in the embodiment of the present application, by determining the first conditional probability distribution of the output label of the initial large language model, adjusting the initial large language model based on a preset algorithm, and determining the second conditional probability distribution of the output label of the adjusted initial large language model, and determining the fine-tuning space vector according to the first conditional probability distribution and the second conditional probability distribution, adjusting the fine-tuning space vector using a preset adjustment formula to obtain a knowledge vector, and using a preset activation function to convert the knowledge vector into a fine-tuning probability distribution, and using a preset merging formula to merge the fine-tuning probability distribution and the second conditional probability distribution to obtain a target probability distribution, and guiding the output result of the fine-tuned large language model according to the target probability distribution. Thus, the problems of the related technology being too dependent on high-quality data, too high data cost, poor model applicability and general practical application effect are solved, and the inherent knowledge of the large language model can be better utilized to enhance the adaptability and performance of the large language model in downstream tasks, reduce the dependence of the large language model on high-quality data, and reduce data costs, and improve the wide applicability and practical application effect of the model.
[0099] Next, the task-aware decoding device for a large language model proposed in an embodiment of the present application is described with reference to the accompanying drawings.
[0100] Figure 4 It is a block diagram of a task-aware decoding device for a large language model according to an embodiment of the present application.
[0101] like Figure 4 As shown, the task-aware decoding device 10 of the large language model includes: a determination module 100, an adjustment module 200 and a task-aware decoding module 300.
[0102] The determination module 100 is used to determine a first conditional probability distribution of output labels of the initial large language model, adjust the initial large language model based on a preset algorithm, and determine a second conditional probability distribution of output labels of the adjusted initial large language model.
[0103] The adjustment module 200 is used to determine the fine-tuning space vector according to the first conditional probability distribution and the second conditional probability distribution, adjust the fine-tuning space vector using a preset adjustment formula to obtain a knowledge vector, and convert the knowledge vector into a fine-tuning probability distribution using a preset activation function.
[0104] The task-aware decoding module 300 is used to combine the fine-tuned probability distribution and the second conditional probability distribution using a preset merging formula to obtain a target probability distribution, and guide the output result of the fine-tuned large language model according to the target probability distribution.
[0105] Optionally, in some embodiments, the preset merging formula is:
[0106]
[0107] in, is the target probability distribution, μ is the weight coefficient, p φ (x t |x <t ) is the second conditional probability distribution, p K (x t |x <t ) is the fine-tuning probability distribution.
[0108] Optionally, in some embodiments, the adjustment module 200 includes: an adjustment unit.
[0109] The adjustment unit is used to adjust the fine-tuning space vector according to the preset indicator function using a preset adjustment formula to obtain the knowledge vector, wherein the preset adjustment formula is:
[0110]
[0111] in, is the knowledge vector, is the preset indicator function, λ is the penalty coefficient, x t A token with a weight.
[0112] Optionally, in some embodiments, according to a preset indicator function, a preset adjustment formula is used to adjust the fine-tuning space vector to obtain a knowledge vector, including:
[0113] Based on the preset constraint function and the preset indicator function, the knowledge vector is obtained by adjusting the fine-tuning space vector using the preset adjustment formula, wherein the preset indicator function is:
[0114]
[0115] Among them, C t is the preset constraint function.
[0116] Optionally, in some embodiments, the preset constraint function is:
[0117]
[0118] in, is the vocabulary, α is the constraint range, x t ˊ is a token with a weight.
[0119] It should be noted that the aforementioned explanation of the embodiment of the task-aware decoding method for a large language model is also applicable to the task-aware decoding device for a large language model of this embodiment, and will not be repeated here.
[0120] According to the task-aware decoding device of the large language model proposed in the embodiment of the present application, by determining the first conditional probability distribution of the output label of the initial large language model, adjusting the initial large language model based on a preset algorithm, and determining the second conditional probability distribution of the output label of the adjusted initial large language model, and determining the fine-tuning space vector according to the first conditional probability distribution and the second conditional probability distribution, the fine-tuning space vector is adjusted using a preset adjustment formula to obtain a knowledge vector, and the knowledge vector is converted into a fine-tuning probability distribution using a preset activation function, and the fine-tuning probability distribution and the second conditional probability distribution are merged using a preset merging formula to obtain a target probability distribution, and the output result of the fine-tuned large language model is guided according to the target probability distribution. Thus, the problems of the related technology being too dependent on high-quality data, too high data cost, poor model applicability and general practical application effect are solved, and the inherent knowledge of the large language model can be better utilized to enhance the adaptability and performance of the large language model in downstream tasks, reduce the dependence of the large language model on high-quality data, and reduce data cost, and improve the wide applicability and practical application effect of the model.
[0121] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. The electronic device may include:
[0122] A memory 501 , a processor 502 , and a computer program stored in the memory 501 and executable on the processor 502 .
[0123] When the processor 502 executes the program, the task-aware decoding method of the large language model provided in the above embodiment is implemented.
[0124] Furthermore, the electronic device further comprises:
[0125] The communication interface 503 is used for communication between the memory 501 and the processor 502 .
[0126] The memory 501 is used to store computer programs that can be executed on the processor 502 .
[0127] The memory 501 may include a high-speed RAM (Random Access Memory) memory, and may also include a non-volatile memory, such as at least one disk memory.
[0128] If the memory 501, the processor 502 and the communication interface 503 are implemented independently, the communication interface 503, the memory 501 and the processor 502 can be connected to each other through a bus and communicate with each other. The bus can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 5 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0129] Optionally, in a specific implementation, if the memory 501, the processor 502 and the communication interface 503 are integrated on a chip, the memory 501, the processor 502 and the communication interface 503 can communicate with each other through an internal interface.
[0130] The processor 502 may be a CPU (Central Processing Unit), or an ASIC (Application Specific Integrated Circuit), or one or more integrated circuits configured to implement the embodiments of the present application.
[0131] An embodiment of the present application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the task-aware decoding method for a large language model as described above.
[0132] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms are not necessarily directed to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or N embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.
[0133] 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. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of this application, "N" means at least two, such as two, three, etc., unless otherwise clearly and specifically defined.
[0134] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, fragment or portion of code comprising one or more executable instructions for implementing the steps of a custom logical function or process, and the scope of the preferred embodiments of the present application includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present application belong.
[0135] It should be understood that the various parts of the present application can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiment, the N steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array, a field programmable gate array, etc.
[0136] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.
[0137] Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limitations on the present application. Ordinary technicians in this field can change, modify, replace and modify the above embodiments within the scope of the present application.
Claims
1. A task-aware decoding method for a large language model, characterized in that: The following steps are involved: Determine a first conditional probability distribution of output labels of an initial large language model, adjust the initial large language model based on a preset algorithm, and determine a second conditional probability distribution of output labels of the adjusted initial large language model; Determine a fine-tuning space vector according to the first conditional probability distribution and the second conditional probability distribution, adjust the fine-tuning space vector using a preset adjustment formula to obtain a knowledge vector, and convert the knowledge vector into a fine-tuning probability distribution using a preset activation function; The fine-tuned probability distribution and the second conditional probability distribution are combined using a preset combination formula to obtain a target probability distribution, and the output result of the fine-tuned large language model is guided according to the target probability distribution.
2. According to the method of claim 1, the preset merging formula is: in, is the target probability distribution, μ is the weight coefficient, p φ (x t |x <t ) is the second conditional probability distribution, p K (x t |x <t ) is the fine-tuning probability distribution.
3. The method according to claim 1, characterized in that The step of adjusting the fine-tuning space vector using a preset adjustment formula to obtain a knowledge vector includes: According to the preset indicator function, the fine-tuning space vector is adjusted using the preset adjustment formula to obtain a knowledge vector, wherein the preset adjustment formula is: in, is the knowledge vector, is the preset indicator function, λ is the penalty coefficient, x t A token with a weight.
4. The method according to claim 3, characterized in that The step of adjusting the fine-tuning space vector to obtain the knowledge vector by using the preset adjustment formula according to the preset indicator function includes: Based on a preset constraint function and according to a preset indicator function, the fine-tuning space vector is adjusted using the preset adjustment formula to obtain a knowledge vector, wherein the preset indicator function is: Among them, C t is the preset constraint function.
5. The method according to claim 3, characterized in that: The preset constraint function is: in, is the vocabulary, α is the constraint range, x t ˊ is a token with a weight.
6. A task-aware decoding device for a large language model, characterized in that: include: A determination module, configured to determine a first conditional probability distribution of output labels of an initial large language model, adjust the initial large language model based on a preset algorithm, and determine a second conditional probability distribution of output labels of the adjusted initial large language model; an adjustment module, configured to determine a fine-tuning space vector according to the first conditional probability distribution and the second conditional probability distribution, adjust the fine-tuning space vector using a preset adjustment formula to obtain a knowledge vector, and convert the knowledge vector into a fine-tuning probability distribution using a preset activation function; The task-aware decoding module is used to combine the fine-tuned probability distribution and the second conditional probability distribution using a preset merging formula to obtain a target probability distribution, and guide the output result of the fine-tuned large language model according to the target probability distribution.
7. The device according to claim 6, wherein the preset merging formula is: in, is the target probability distribution, μ is the weight coefficient, p φ (x t |x <t ) is the second conditional probability distribution, p K (x t |x <t ) is the fine-tuning probability distribution.
8. The device according to claim 6, characterized in that The adjustment module comprises: An adjustment unit is used to adjust the fine-tuning space vector according to a preset indicator function using the preset adjustment formula to obtain a knowledge vector, wherein the preset adjustment formula is: in, is the knowledge vector, is the preset indicator function, λ is the penalty coefficient, x t A token with a weight.
9. An electronic device, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the task-aware decoding method for a large language model as described in any one of claims 1 to 5.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: The program is executed by a processor to implement the task-aware decoding method of a large language model as described in any one of claims 1-5.
Citation Information
Cited By
Large language model output distribution-oriented data processing method, apparatus and device, and medium
CN122528965A