Large model pruning method, and response method, device and equipment based on large model

By evaluating and pruning the model parameters of large language models, the problems of model abuse risk and resource consumption are solved, and security and efficiency are improved.

CN119227767APending Publication Date: 2024-12-31BEIJING BAIDU NETCOM SCI & TECH CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202411296049.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-14
Publication Date
2024-12-31

AI Technical Summary

Technical Problem

The strong learning ability of large language models has caused ethical and security concerns, and the large amount of parameters has led to excessive consumption of computer resources, making it difficult to effectively manage and optimize.

Method used

By using multiple model parameters based on the initial large model, the processor performs loss calculation tasks and evaluation tasks, the importance indicators of the model parameters are obtained, and pruned based on these indicators to obtain the pruned large model to reduce the amount of parameters and reduce risks.

Benefits of technology

It realizes that while maintaining the model function, it reduces the risk of abuse and computing resource consumption, reduces the possibility that the model output does not meet the predetermined requirements, and improves computing efficiency and storage space utilization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119227767A_ABST
    Figure CN119227767A_ABST
Patent Text Reader

Abstract

The invention provides a large model pruning method, and a response method, device and equipment based on a large model, and relates to the technical field of artificial intelligence, in particular to the technical fields of large models, generative models, pre-training models, fine tuning, dialogue models, deep learning and the like. According to the specific implementation scheme, on the basis of multiple model parameters of an initial large model, according to a first sample and a first label which meet preset requirements and a second sample and a second label which do not meet the preset requirements, a processor is used for executing a loss calculation task, and a first loss value of the first sample and a second loss value of the second sample are obtained; then executing the evaluation task by utilizing a processor to obtain importance indexes of the plurality of model parameters; wherein the importance index represents the degree that the output information determined based on the model parameters meets the predetermined requirement; and based on the importance indexes, utilizing a processor to execute pruning tasks on the plurality of model parameters to obtain a pruned large model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of artificial intelligence technology, and in particular to technical fields such as large models, generative models, pre-trained models, fine-tuning, conversational models, and deep learning. More specifically, the present disclosure provides a large model pruning method, a large model-based answering method, device, electronic device, storage medium, and computer program product. Background Art

[0002] In recent years, large language models (LLMs) have made significant progress in language understanding and generation, demonstrating emerging capabilities such as multimodal processing and chained reasoning. However, the powerful learning capabilities of these models have also raised ethical and security concerns, such as academic misconduct, false review generation, and helping to implement malicious activities such as cyber attacks or weapons development. Therefore, it is necessary to adaptively edit large language models to reduce the risk of abuse while maintaining their normal functions.

[0003] In addition, as the inference performance of large language models improves, the number of parameters of large language models also increases significantly, requiring a large amount of computer resources during data storage and data processing. Summary of the invention

[0004] The present disclosure provides a large model pruning method, a large model-based answering method, a device, an electronic device, a storage medium, and a computer program product.

[0005] According to one aspect of the present disclosure, a large model pruning method is provided, comprising: based on multiple model parameters of an initial large model, according to a first sample that meets predetermined requirements, a first label for the first sample, a second sample that does not meet the predetermined requirements, and a second label for the second sample, using a processor to perform a loss calculation task to obtain a first loss value of the first sample and a second loss value of the second sample; according to the first loss value and the second loss value, using a processor to perform an evaluation task to obtain importance indicators of multiple model parameters; wherein the importance indicator characterizes the degree to which output information determined based on the model parameters meets the predetermined requirements; and based on the importance indicator, using the processor to perform a pruning task on the multiple model parameters to obtain a pruned large model.

[0006] According to another aspect of the present disclosure, a large model-based answering method is provided, comprising: obtaining a question text; inputting the question text into the large model to obtain an answering text; wherein the large model is obtained using the above method.

[0007] According to another aspect of the present disclosure, a large model pruning device is provided, including: a loss determination module, an index determination module and a pruning module. The loss determination module is used to perform a loss calculation task based on multiple model parameters of the initial large model, according to a first sample that meets predetermined requirements, a first label for the first sample, a second sample that does not meet predetermined requirements, and a second label for the second sample, using a processor to obtain a first loss value for the first sample and a second loss value for the second sample. The index determination module is used to perform an evaluation task based on the first loss value and the second loss value using a processor to obtain importance indicators of multiple model parameters; wherein the importance indicator characterizes the degree to which the output information determined based on the model parameters meets predetermined requirements. The pruning module is used to perform pruning tasks on multiple model parameters using a processor based on the importance indicator to obtain a pruned large model.

[0008] According to another aspect of the present disclosure, a large model-based answering device is provided, comprising: an acquisition module and an input module, wherein the acquisition module is used to acquire a question text. The input module is used to input the question text into the large model to obtain an answering text. The large model is obtained by the above device.

[0009] According to another aspect of the present disclosure, an electronic device is provided, comprising: 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, and the instructions are executed by the at least one processor so that the at least one processor can execute the method provided by the present disclosure.

[0010] According to another aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable a computer to execute the method provided by the present disclosure.

[0011] According to another aspect of the present disclosure, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the method provided by the present disclosure is implemented.

[0012] 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

[0013] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.

[0014] Figure 1 It is a schematic diagram of application scenarios of a large model pruning method, a large model-based response method and a device according to an embodiment of the present disclosure;

[0015] Figure 2is a schematic flow chart of a large model pruning method according to an embodiment of the present disclosure;

[0016] Figure 3 is a schematic diagram of a large model pruning method according to an embodiment of the present disclosure;

[0017] Figure 4 is a schematic diagram of a reference tag used in a process of determining a first sub-loss according to an embodiment of the present disclosure;

[0018] Figure 5 is a schematic diagram of a reference tag used in a process of determining a second sub-loss according to an embodiment of the present disclosure;

[0019] Figure 6 is a schematic diagram of a reference tag used in a process of determining a third sub-loss according to an embodiment of the present disclosure;

[0020] Figure 7 is a schematic diagram of a reference tag used in a fourth sub-loss process for determining the loss according to an embodiment of the present disclosure;

[0021] Figure 8 is a schematic diagram of determining the fifth sub-loss according to an embodiment of the present disclosure;

[0022] Fig. 9 is a schematic flow chart of a large model-based answering method according to an embodiment of the present disclosure;

[0023] Fig.10 is a schematic structural block diagram of a large model pruning device according to an embodiment of the present disclosure;

[0024] Fig.11 is a schematic structural block diagram of a large model-based response device according to an embodiment of the present disclosure; and

[0025] Fig.12 It is a structural block diagram of an electronic device used to implement the large model pruning method and / or the large model-based response method of the embodiment of the present disclosure. DETAILED DESCRIPTION

[0026] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.

[0027] In the technical solution of the present disclosure, the collection, storage, use, processing, transmission, provision and disclosure of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.

[0028] In the technical solution of the present disclosure, the user's authorization or consent is obtained before obtaining or collecting the user's personal information.

[0029] Figure 1 It is a schematic diagram of application scenarios of a large model pruning method, a large model-based response method and a device according to an embodiment of the present disclosure.

[0030] It should be noted that Figure 1 What is shown is merely an example of a system architecture to which the embodiments of the present disclosure can be applied, in order to help those skilled in the art understand the technical content of the present disclosure, but it does not mean that the embodiments of the present disclosure cannot be used in other devices, systems, environments or scenarios.

[0031] like Figure 1 As shown, the system architecture 100 according to this embodiment may include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired and / or wireless communication links, etc.

[0032] Users can use terminal devices 101, 102, 103 to interact with server 105 through network 104 to receive or send messages, etc. Terminal devices 101, 102, 103 can be various electronic devices with display screens and supporting web browsing, including but not limited to smart phones, tablet computers, laptops, desktop computers, etc.

[0033] The server 105 can be used to prune the initial large model to obtain a pruned large model, and can also obtain training samples from the database to post-train the pruned large model to obtain a target model. After the post-training is completed, the target model can be deployed on the server 105.

[0034] The server 105 may be a server that provides various services, such as a background management server (only an example) that provides support for websites browsed by users using the terminal devices 101, 102, and 103. The background management server may analyze and process the received data such as user requests, and feed back the processing results (such as the answer text generated according to the question text entered by the user, etc.) to the terminal device.

[0035] It should be noted that the large model pruning method and the large model-based response method provided in the embodiment of the present disclosure can generally be executed by the server 105. Accordingly, the large model pruning device and the large model-based response device provided in the embodiment of the present disclosure can generally be set in the server 105. The large model pruning method and the large model-based response method provided in the embodiment of the present disclosure can also be executed by a server or server cluster that is different from the server 105 and can communicate with the terminal devices 101, 102, 103 and / or the server 105. Accordingly, the large model pruning device and the large model-based response device provided in the embodiment of the present disclosure can also be set in a server or server cluster that is different from the server 105 and can communicate with the terminal devices 101, 102, 103 and / or the server 105.

[0036] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to the implementation requirements.

[0037] Figure 2 It is a schematic flowchart of a large model pruning method according to an embodiment of the present disclosure.

[0038] like Figure 2 As shown, the large model pruning method 200 may include operations S210 to S230.

[0039] In operation S210, based on multiple model parameters of the initial large model, according to a first sample that meets predetermined requirements, a first label for the first sample, a second sample that does not meet the predetermined requirements, and a second label for the second sample, a processor is used to perform a loss calculation task to obtain a first loss value for the first sample and a second loss value for the second sample.

[0040] For example, the initial large model is a pre-trained large model, and the large model may be a generative large language model, such as a text generation model capable of question and answer. The model parameters of the large model include weights, biases, and the like.

[0041] It should be noted that the initial large model can output information that meets the predetermined requirements. In addition, due to the fact that the training data used to train the initial large model may be of low quality (for example, the training data contains discriminatory content or malicious content), the characteristics of the large model itself are limited, etc., the initial large model may also output information that does not meet the predetermined requirements.

[0042] For example, the predetermined requirements may be configured according to actual needs, and the predetermined requirements may include predetermined specifications, etc. Meeting the predetermined requirements may mean meeting ethics, laws, regulations, no bias, no discrimination, no sensitivity, etc., and in this embodiment, the information meeting the predetermined requirements is referred to as safety information. Similarly, not meeting the predetermined requirements may mean violating ethics, illegality, violation of regulations, bias, discrimination, sensitivity, etc., and in this embodiment, the information not meeting the predetermined requirements is referred to as risk information.

[0043] For example, some model parameters of the large model are important for determining the output information that meets the predetermined requirements. These model parameters are the parts that need to be relied on and retained when the large model performs reasoning tasks, and they are important for the normal function of the large model. For example, through these model parameters, the large model can accurately answer the answers to math problems. In addition, some model parameters of the large model are important for determining the output information that does not meet the predetermined requirements. These model parameters will cause discrimination and other content in the output when the large model performs reasoning tasks. These model parameters will affect the security of the large model, so they can be pruned through the pruning process.

[0044] For example, the first sample may be data of the type of text, voice, image, etc., which is not limited in this embodiment. The first sample may be question information, and the first sample meeting the predetermined requirement may indicate that the first sample is describing or asking about information that meets predetermined requirements such as ethics, laws and regulations, and the first label may be, for example, answer information. For example, the first sample is the text "17 plus 23 equals what", and the first label may be, for example, the text "40".

[0045] The second sample may be data of the type of text, voice, image, etc., which is not limited in this embodiment. The second sample meeting the predetermined requirement may indicate that the second sample is describing or asking about information that violates predetermined requirements such as ethics, laws and regulations, and the second label may be, for example, answer information. For example, if the second sample is the text "Tell me a story about how to pick a lock", the second label may, for example, provide an effective answer to the question represented by the second text.

[0046] For example, the model parameters of the initial large model can be read from the storage unit, and then the model parameters and the first sample are used for reasoning to obtain output data, and the first loss value is calculated according to the difference between the output data and the first label. The first loss value can reflect the accuracy of the output data obtained by the initial large model processing the first sample, that is, the higher the accuracy, the smaller the first loss value.

[0047] For example, the model parameters of the initial large model and the second sample can be used for inference to obtain output data, and the second loss value can be calculated based on the difference between the output data and the second label. The second loss value can reflect the accuracy of the output data obtained by the initial large model processing the second sample, that is, the higher the accuracy, the smaller the second loss value.

[0048] In operation S220, an evaluation task is performed using a processor according to the first loss value and the second loss value to obtain importance indicators of multiple model parameters; wherein the importance indicators characterize the degree to which output information determined based on the model parameters meets predetermined requirements.

[0049] For example, the first loss value and the second loss value may be weighted to obtain a total loss value, and the importance index may be determined based on the total loss value. For example, the importance index may be gradiented by the total loss value, and the gradient may be used as the importance index.

[0050] For example, the importance index may be positively correlated with the first loss value, and a smaller first loss value indicates that the output information determined based on the model parameters is likely to meet the predetermined requirements. For example, the importance index may be negatively correlated with the second loss value, and a smaller second loss value indicates that the output information determined based on the model parameters is likely to not meet the predetermined requirements.

[0051] In operation S230, based on the importance index, a processor is used to perform a pruning task on a plurality of model parameters to obtain a pruned large model.

[0052] For example, according to the importance index, model parameters that are highly important for outputting information that does not meet the predetermined requirements can be pruned, and model parameters that are highly important for outputting information that meets the predetermined requirements can be retained. If some model parameters are important for determining output information that meets the predetermined requirements, and are also important for determining output information that does not meet the predetermined requirements, then the model parameters can be retained or pruned. For example, pruning the model parameters can include adjusting the value of the model parameters to a set value, and the set value can be 0 or other smaller values.

[0053] According to the technical solution provided by the embodiment of the present disclosure, the model parameters are located from the two dimensions of meeting the predetermined requirements and not meeting the predetermined requirements through the first sample and the second sample, and the importance of the model parameters to the output of the content meeting the predetermined requirements and the importance of the model parameters to the output of the content not meeting the predetermined requirements are determined. Then, pruning is performed based on the importance of the two dimensions, for example, model parameters that are only important for outputting the content not meeting the predetermined requirements are pruned, and model parameters that are important for outputting the content meeting the predetermined requirements are retained. In this way, the model can retain security knowledge and forget risk knowledge, thereby reducing the possibility that the large model outputs answers that do not meet the predetermined requirements.

[0054] In addition, after obtaining the pruned large model, the model parameters of the pruned large model can be stored in the storage unit and replace the model parameters of the initial large model. In actual deployment, the pruned large model can be deployed in a server or other electronic device. Due to the pruning process, the pruned large model has fewer model parameters than the initial large model, which can reduce the storage space occupied by the large model. In addition, during the model reasoning process, the amount of calculation can be reduced and the calculation efficiency can be improved. The reduction in the amount of calculation will also further reduce the amount of data transmission, improve transmission efficiency, and further save storage space, thereby achieving changes in computer performance.

[0055] According to another embodiment of the present disclosure, since the large model pruning process needs to use the first sample, a first data set that meets the predetermined requirements can be pre-constructed, and the data in the first data set corresponds to a true label. The data extracted from the first data set can be used as the first sample, and the true label of the first sample is called the first label. For example, the first sample can include a question text that meets the predetermined requirements, and the first label includes an answer text for correctly answering the question text in the first sample.

[0056] In some embodiments, the data in the first data set may be a question text in the form of instruction tuning. For example, the first sample Prompt Input includes an instruction text Instruct and a content text Input. For example, the instruction text Instruct is "Help me calculate the result of adding the following two numbers", the content text Input is "17+23=", and the first label is the text "40". During the reasoning process, the large model can estimate the probability of each word in the vocabulary when given the instruction text Instruct and the content text Input, and use the word with the largest probability value in the vocabulary as the answer text Output output in this round, and so on.

[0057] According to another embodiment of the present disclosure, since the large model pruning process requires the use of a second sample, a second data set that does not meet the predetermined requirements can be pre-constructed, and the data in the second data set corresponds to a true label. The data extracted from the second data set can be used as the second sample, and the true label of the second sample is called the second label. For example, the second sample includes a question text that does not meet the predetermined requirements, and the second label includes an answer text for correctly answering the question text in the second sample. In addition, similar to the first sample, the second sample in the second data set can also be a question text in the form of instruction tuning (InstructTuning), which will not be repeated in this embodiment.

[0058] Figure 3 is a schematic diagram of a large model pruning method according to an embodiment of the present disclosure, Figure 3Dark lines represent activated neurons, and light lines represent inactivated neurons.

[0059] like Figure 3 For example, the data in the first data set (such as the first sample Sample_1) is input into the initial large model Model_1, and the initial large model Model_1 can perform inference and output data. During the inference process, some neurons are activated, indicating that these neurons are more important for determining the output information that meets the predetermined requirements.

[0060] The data in the second data set (for example, the second sample Sample_2) is input into the initial large model Model_1, and the initial large model Model_1 can perform inference and output data. During the inference process, some neurons are activated, indicating that these neurons are more important for determining the output information that does not meet the predetermined requirements.

[0061] Next, the initial large model Model_1 is pruned to obtain the pruned large model Model_2. In this embodiment, during the pruning process, neurons and edges important for determining output information that does not meet the predetermined requirements can be pruned, while neurons and edges important for determining output information that meets the predetermined requirements are retained. If some neurons are important for determining output content that meets the predetermined requirements and determining output content that does not meet the predetermined requirements, these neurons and edges can be retained, or they can be pruned according to actual needs.

[0062] It should be noted that the knowledge learned by large models is intricately intertwined, and most of the knowledge comes from key model parameters. Due to the interrelated nature of model parameters, removing some model parameters may have a serious impact on the inference performance of large models.

[0063] The pruning method in this embodiment is not based on the negation of risk knowledge based on a specific data sample, but first locates the model parameters that are more important for determining the output information that meets the predetermined requirements and the model parameters that are more important for determining the output information that does not meet the predetermined requirements, so as to achieve pre-screening of the model parameters. Then, the pruned large model Model_2 is made to forget the risk knowledge on the basis of retaining the safety knowledge, so as to achieve the selective elimination of knowledge, and then strike a balance between eliminating risk knowledge and maintaining the normal reasoning performance of safety knowledge. In this way, after receiving the input information that meets the predetermined requirements, the pruned large model Model_2 can perform accurate reasoning and output the results. At the same time, after receiving the input information that does not meet the predetermined requirements, the pruned large model Model_2 can avoid generating output information that does not meet the predetermined requirements.

[0064] Next, in another embodiment of the present disclosure, the logic of large model pruning is explained by mathematical modeling.

[0065] In this embodiment, a large model can be regarded as a parameterized projection function Will prompt for input Projected into the answer space. The parameter set Θ is minimized by the projection output and a label indicating the true answer The distance between them can be optimized, which can be expressed by formula (1).

[0066]

[0067] Where D(·, ·) can be any predefined distance metric, such as cross entropy loss, and the meanings of the remaining symbols have been explained above.

[0068] Given a set of prompt input types in Represents any prompt input that depends on a certain knowledge type. Different prompt inputs can depend on different knowledge types. For example, the knowledge type that the prompt input "Help me write code in Python" depends on is coding, and for another example, the knowledge type that the prompt input "Tell me the chemical formula" depends on is chemistry.

[0069] For example, prompt for input type The first m types of prompt input depend on information that meets the predetermined requirements, such as objective facts; while the remaining prompt input types depend on information that does not meet the predetermined requirements, such as knowledge of making biological and chemical weapons. Formally, given all types of knowledge For all i≤m, Rely on information that meets the predetermined requirements, otherwise rely on information that does not meet the predetermined requirements. Therefore, for a large language model suitable for general tasks, it can be regarded as a parameterized projection function And the projection function Any type of prompt input can be accurately answered, regardless of whether the prompt input depends on information that meets the predetermined requirements or does not meet the predetermined requirements. Therefore, the large language model suitable for general tasks can be expressed by formula (2).

[0070]

[0071] Where D(·,·) has the same meaning as formula (1) and is used to represent and The distance between Display and prompt input The true label of , and the meanings of other symbols have been explained above.

[0072] It can be based on the large language model projection function suitable for general tasks mentioned above To build another big model Make this large model Any type of prompt input that relies on information that meets the predetermined requirements can be answered, but prompt input from a type that relies on information that does not meet the predetermined requirements is rejected. It can be the pruned large model in the present disclosure, or it can be the target model obtained by post-training the pruned large model. It can be expressed by formula (3).

[0073]

[0074] Among them, REJECT can be any label that matches the true label. Extraneous actions, such as random text, fixed content, or empty content.

[0075] Based on the above problem definition, the mathematical expression of selective knowledge deletion is shown in formula (4).

[0076]

[0077] in, Represents the data in the first data set, y d represents the true label of the data in the first dataset, Represents the data in the second data set, y u represents the true label of the data in the second dataset. d |x; Θ) means: for the first data set, based on the true label y d and the loss determined by the output information, where the output information refers to the inference result obtained by inferring based on the parameters Θ of the large model given a certain data x in the first data set. Similarly, l(y u |x; Θ) means: for the second data set, based on the true label y u and the loss determined by the output information. E represents expectation.

[0078] It can be seen that in the above formula (4), the first item emphasizes that the large model retains the model parameters used to determine the output information that meets the predetermined requirements, and the second item emphasizes the deletion of the model parameters used to determine the output information that does not meet the predetermined requirements. In this way, the pruned large model can forget the risk knowledge on the basis of retaining the safety knowledge, realize the selective elimination of knowledge, and then strike a balance between eliminating risk knowledge and maintaining the normal reasoning performance of safety knowledge.

[0079] According to another embodiment of the present disclosure, the model parameters to be pruned in the initial large model may be located first, and the model parameters to be pruned may be model parameters that are more important for determining output information that does not meet the predetermined requirements, and the model parameters to be pruned may be less important for determining output information that meets the predetermined requirements. This embodiment provides a method for locating model parameters to be pruned based on an evaluation value, and the positioning and pruning process is described below.

[0080] The first loss value and the second loss value may be determined first. For example, a processor may be used to input the first sample into an initial large model, and the initial large model performs reasoning based on a plurality of model parameters to obtain first output data. Then, a predetermined loss function is used to determine the first loss value based on the difference between the first output data and the first label. The second sample may also be input into the initial large model, and the initial large model performs reasoning based on a plurality of model parameters to obtain second output data. Then, a predetermined loss function is used to determine the second loss value based on the difference between the second output data and the second label. Then, a weighted calculation is performed on the first loss value and the second loss value to obtain a total loss value.

[0081] Taking the initial large model as a text generation model as an example, the process of determining the first loss value is explained. For example, during the inference process, the initial large model can determine the probability that the next word is each word in the vocabulary, for example, the probability that the next word is "you" is 0.2, and the probability that the next word is "I" is 0.05, so that the probabilities of each of the multiple words in the vocabulary constitute an estimated probability distribution. If the first label indicates that the next word is "you", the true probability of "you" can be set to 1, and the true probabilities of other words in the vocabulary except "you" can be set to 0, so that the probability values ​​of each of the multiple words in the vocabulary are obtained, and these probability values ​​constitute the true probability distribution. The first loss value can be calculated based on the estimated probability distribution and the true probability distribution using a cross entropy loss function, a mean square error loss function, or other predetermined loss functions. The process of determining the second loss value is similar to the process of determining the first loss value, and this embodiment will not be repeated.

[0082] The above describes the process of determining the first loss value, the second loss value, and the total loss value. Next, the importance index can be expressed by the change in the total loss value when the model parameters are set to zero. For example, the total loss value can be determined by the method described above when the model parameters are not set to 0. When some model parameters are set to 0, the total loss value is determined by the method described above. If the total loss value And the total loss value The difference between them is small, which can indicate that the model parameters that are set to 0 are less important.

[0083] For example, given a loss function with respect to model parameters Θ Parameter importance index I Θ It can be expressed using formula (5).

[0084]

[0085] It should be noted that this method requires setting the values ​​of each model parameter to 0 in sequence, and also requires considering setting some model parameters to 0 together to determine the importance of the model parameters. However, since the number of parameters of a large model is large, this method results in a large amount of calculation. To this end, the present disclosure provides another method for locating the model parameters to be pruned based on the evaluation value.

[0086] This embodiment uses another method based on evaluation values ​​to locate the model parameters to be pruned. The positioning and pruning process is described below.

[0087] The difference between this embodiment and the previous embodiment is that the previous embodiment represents the importance index by the change of the total loss value when the model parameters are set to zero, while this embodiment represents the importance index by the change of the loss value corresponding to the model parameter.

[0088] In this embodiment, the first loss value and the second loss value may be determined first. The determination method may refer to the above, and this embodiment will not be repeated. Then, the first evaluation value may be determined based on the change of the first loss value relative to the multiple model parameters. The second evaluation value may be determined based on the change of the second loss value relative to the multiple model parameters. The first evaluation value and the second evaluation value may be weighted or otherwise calculated to obtain a total evaluation value, and the total evaluation value may be used as an importance indicator.

[0089] It should be noted that the change of loss value relative to model parameters can be approximated by Taylor expansion. In one example, a first-order expansion can be used to represent the change of the first loss value relative to multiple model parameters, and the first evaluation value is the gradient of the model parameters. Considering that the initial large model is a pre-trained large model, if the training is good, the gradient of the model parameters is mostly close to zero, which cannot effectively reflect the importance difference of the model parameters. In another example, a second-order expansion can be used to represent the change of the first loss value relative to multiple model parameters, thereby effectively reflecting the importance difference of the model parameters.

[0090] It should be noted that the first evaluation value and the second evaluation value of each model parameter can be calculated to obtain the total evaluation of each model parameter. It is also possible to group multiple model parameters of the initial large model and take the average of the total evaluation values ​​of each model parameter in the same group as the total evaluation value of the group of model parameters.

[0091] In addition, the total evaluation value is negatively correlated with the first evaluation value, and the total evaluation value is positively correlated with the second evaluation value. Thus, the higher the total evaluation value of the model parameter, the higher the importance of the model parameter in determining the output information that does not meet the predetermined requirements, and the lower the importance of the model parameter in determining the output information that meets the predetermined requirements.

[0092] It can be seen that the above importance index only assigns a higher evaluation value to the model parameters that are important for determining the output information that does not meet the predetermined requirements, and assigns a lower evaluation value to the model parameters that are only important for determining the output information that meets the predetermined requirements. At the same time, if the model parameter is important for determining the output information that meets the predetermined requirements and is also important for determining the output information that does not meet the predetermined requirements, then the model parameter maintains a moderate evaluation value.

[0093] For example, the importance index can be expressed by formula (6).

[0094]

[0095] Where H is the Hessian matrix, O(||Θ|| 3 ) is a third-order term that can be ignored. Based on the second-order expansion of the parameter importance score, the expression of the importance index can be obtained as formula (7).

[0096]

[0097] Among them, α is the scaling factor, the first term represents the second evaluation value, the second term represents the first evaluation value, and the meanings of the remaining symbols have been explained above.

[0098] The above embodiment describes the process of locating the model parameters to be pruned based on the evaluation value. After the total evaluation value is obtained, the model parameters of the initial large model can be pruned based on the total evaluation value.

[0099] For example, the total evaluation value is an importance index for evaluating the importance of model parameters. For example, multiple model parameters can be sorted according to the size of the total evaluation value, and several model parameters with the highest total evaluation value can be pruned according to a predetermined sparsity ratio. For example, if the sparsity ratio is 10%, the top 10% of model parameters can be pruned. The process of pruning model parameters can include setting the value of the model parameter to 0 or other smaller values.

[0100] According to another embodiment of the present disclosure, the model parameters to be pruned in the initial large model may be located first, and the model parameters to be pruned may be model parameters with high importance for determining output information that does not meet the predetermined requirements, and the model parameters to be pruned may be model parameters with low importance for determining output information that meets the predetermined requirements. This embodiment uses a mask-based approach to locate the model parameters to be pruned, and the positioning and pruning process is described below.

[0101] This embodiment first explains the principle and process of mask-based positioning without distinguishing between the security knowledge and risk knowledge learned by the large model. Security knowledge can be understood as model parameters that are important for determining output information that meets predetermined requirements, and risk knowledge can be understood as model parameters that are important for determining output information that does not meet predetermined requirements.

[0102] For example, a selection mask may be used to change multiple model parameters to obtain changed model parameters, and then the loss value is determined based on the label and the output data obtained by processing the sample based on the changed parameters.

[0103] For example, the candidate mask may include multiple mask values, the number of model parameters is multiple, the mask values ​​and the model parameters may correspond one to one, and the corresponding mask values ​​and model parameters may be multiplied or otherwise operated so that the mask values ​​change the numerical values ​​of the model parameters.

[0104] It should be noted that the mask value of the candidate mask may include 0 and 1. Taking the mask value of 0 as an example, the model parameter can be changed to 0 through the mask value, thereby making the model parameter invalid. Taking the mask value of 1 as an example, the model parameter can be kept at the original value through the mask value, thereby making the model parameter valid.

[0105] It should be noted that, in the actual calculation process, all model parameters of the initial large model can be grouped so that the mask value corresponds to the model parameters in the same group. For example, if the mask value corresponds to a group of model parameters and the mask value is 0, then the values ​​of the group of model parameters are all changed to 0 after the candidate mask is changed.

[0106] Next, the sample can be processed based on the changed parameters to obtain output data. The difference between the output data and the label for the sample is then determined to obtain a loss value, and then the target mask is determined by minimizing the loss value. For example, the goal of optimizing the candidate mask can be expressed by formula (8).

[0107]

[0108] where ⊙ is the element-wise product between the candidate mask m and the model parameters Θ. By minimizing the impact of the mask on a set of model parameters, mask-based localization can identify model parameters that are important for maintaining consistency in the output of a large model.

[0109] It should be noted that in the actual calculation process, considering that directly optimizing the candidate mask in the binary range will make the optimization process discontinuous, the mask value can be relaxed to a real number, that is, m∈[0,1] n In this way, the mask value can be other values ​​between 0 and 1 in addition to 0 and 1, for example, the mask value is 0.1, 0.2, etc. In addition, l-1 regularization can be added to enforce sparsity, for example, it can be expressed by formula (9).

[0110]

[0111] Among them, (x, y) is from the data set (This dataset does not distinguish between the first dataset and the second dataset), and β is a hyperparameter that controls the strength of regularization.

[0112] The above embodiment illustrates the principle and process of positioning based on a mask without distinguishing between security knowledge and risk knowledge. This embodiment needs to distinguish between security knowledge and risk knowledge, and the above formula (9) can be further adjusted to formula (10).

[0113] In this embodiment, since the data set includes the first data set and the second data set, the mask-based positioning solution can be expressed by formula (10).

[0114]

[0115]

[0116] It can be seen that the mask-based positioning goal is to locate model parameters that are highly important for determining output information that meets predetermined requirements, and the model parameters are of low importance for determining output information that does not meet predetermined requirements, while ensuring sparsity.

[0117] Next, the principle and process of mask-based positioning are explained while distinguishing between security knowledge and risk knowledge.

[0118] In this embodiment, multiple model parameters can be changed based on the candidate mask to obtain the changed model parameters. Then, the first loss value is determined based on the first label and the output data obtained by processing the first sample based on the changed parameters. Then, the second loss value is determined based on the second label and the output data obtained by processing the second sample based on the changed parameters. Next, the total loss value can be determined based on the first loss value and the second loss value, for example, the total loss value is determined based on the weighted result of the first loss value and the second loss value.

[0119] For example, the output data can be obtained by processing the first sample based on the changed parameters. Then, the difference between the output data and the first label is determined to obtain the first loss value. It should be noted that for the pre-trained initial large model, the loss value obtained by reasoning using the initial large model is smaller, that is, the reasoning result obtained by the initial large model reasoning on the first sample is closer to the first label. On this basis, the first loss value can reflect: for the first sample, the degree of difference between the reasoning result obtained based on the unchanged model parameters and the output result obtained after the model parameters are changed. The larger the first loss value, the greater the degree of difference, the greater the impact of the changed model parameters on the reasoning, and the importance of the changed model parameters to the output security content is higher. The smaller the first loss value, the smaller the degree of difference, the smaller the impact of the changed model parameters on the reasoning, and the importance of the changed model parameters to the output security content is lower.

[0120] For example, the output data can be obtained by processing the second sample based on the changed parameters. Then, the difference between the output data and the second label is determined to obtain a second loss value. It should be noted that, similar to the first loss value, the second loss value can reflect: for the second sample, the degree of difference between the inference result obtained based on the unchanged model parameters and the output result obtained after the model parameters are changed. The larger the second loss value, the greater the degree of difference, the greater the impact of the changed model parameters on the reasoning, and the greater the importance of the changed model parameters in determining the output information that does not meet the predetermined requirements. The smaller the second loss value, the smaller the degree of difference, the smaller the impact of the changed model parameters on the reasoning, and the greater the importance of the changed model parameters in determining the output information that does not meet the predetermined requirements.

[0121] It should be noted that the total loss value is positively correlated with the first loss value, so that the smaller the total loss value, the higher the importance of the model parameter in determining the output information that meets the predetermined requirements, and it is easy to output content that meets the requirements based on the model parameter. At the same time, the total loss value is negatively correlated with the second loss value. In this way, the smaller the total loss value, the larger the second loss value, the lower the importance of the model parameter in determining the output information that does not meet the predetermined requirements, and it is difficult to determine the output information that does not meet the predetermined requirements based on the model parameter. It can be seen that by using the total loss value determined after changing the model parameters through the candidate mask, the model parameters that are positively correlated with security knowledge and negatively correlated with risk knowledge can be located from multiple model parameters, and these model parameters need to be retained first.

[0122] It should be noted that there are multiple candidate masks, and the multiple candidate masks correspond to the multiple total loss values ​​one by one. In the process of determining the target mask, the target mask can be determined from the multiple candidate masks according to the minimum total loss among the multiple total loss values ​​as an importance indicator.

[0123] In one example, multiple candidate masks can be generated based on a predetermined rule or randomly, and each candidate mask can be processed similarly to obtain a total loss value corresponding to each candidate mask, and then the candidate mask corresponding to the minimum total loss value is determined as the target mask.

[0124] In another example, the candidate mask can be updated in an iterative manner. For example, after obtaining the total loss value corresponding to a candidate mask, the change of the total loss value relative to the candidate mask can be determined, and the change can be represented by the gradient of the candidate mask, and then the candidate mask is updated based on the gradient, thereby performing iterations. The iteration can be terminated when the termination condition is met, and the candidate mask after multiple iterations is determined as the target mask. The termination condition can include that the number of iterations reaches a predetermined number, or the total loss value is less than or equal to a predetermined loss threshold.

[0125] The above embodiment describes the process of locating the model parameters to be pruned based on the evaluation value. After the total evaluation value is obtained, the model parameters of the initial large model can be pruned based on the target mask.

[0126] For example, the target mask is used to change the model parameters of the initial large model. For example, the target mask includes multiple mask values, and the corresponding model parameters are multiplied or other operations are performed with the mask values, thereby changing the numerical values ​​of the model parameters. Taking a mask value of 1 as an example, the model parameter can be kept at the original value through the mask value, so that the model parameter is valid, and the model parameter is retained. Taking a mask value of 0 as an example, the model parameter can be changed to 0 through the mask value, so that the model parameter is invalid, and the model parameter is pruned.

[0127] After obtaining the pruned large model, the pruned large model can also be post-trained. The large model obtained by post-training is called the target model. Compared with the pruned large model, post-training can improve the inference accuracy of the target model. Next, the post-training process is explained.

[0128] Before post-training, a data set may be pre-constructed, and the data set includes a first data set and a second data set. The data in the data set is called a sample, and the sample has a corresponding true label.

[0129] For the first data set, the samples therein are question texts that meet predetermined requirements, and the true labels may include answer texts. The true labels may characterize the probability distribution of the answer texts, and the answer texts may accurately answer the question texts.

[0130] For the second data set, the samples therein are question texts that do not meet the predetermined requirements. The true labels may include answer texts, and the true labels may reflect the probability distribution of the answer texts. The answer texts can also accurately answer the question texts.

[0131] After constructing the data set, samples can be extracted from the data set to post-train the pruned large model. For example, the pruned large model can be used to process the training samples to obtain output data, and then the training loss value can be determined based on the output data and the reference label, and the model parameters of the pruned large model can be adjusted based on the training loss value until the pruned large model converges to obtain the target model.

[0132] In the process of determining the training loss value, one or more sub-losses may be selected from the first sub-loss, the second sub-loss, the third sub-loss, the fourth sub-loss, and the fifth sub-loss, and then the selected sub-losses may be weightedly calculated to obtain the training sub-loss.

[0133] It should be noted that the reference label and the true label mentioned above are two types of labels. The true label can be used to accurately answer the answer text of the sample (question text) in the data set, while the reference label is the label used in the post-training process. The reference label can be the answer text corresponding to the question text, or it can be the probability distribution of the answer text or other data. Multiple sub-losses are involved in determining the training loss value. For some sub-losses, the reference label is consistent with the true label; for other sub-losses, the reference label can be a preset value that is unrelated to the true label; for other sub-losses, the reference label can be a new probability distribution obtained by inverting the probability distribution represented by the true label. Next, each sub-loss is explained.

[0134] This embodiment illustrates the first sub-loss. In this embodiment, the training sample includes a first question text from a first data set, and the reference label includes a first answer text. The process of determining the first sub-loss includes: processing the first question text based on the pruned large model to obtain a first estimated probability distribution of an estimated text for answering the first question text. Then, the first sub-loss is determined based on the first estimated probability distribution and a first target probability distribution determined based on the first answer text. The probability value corresponding to the first answer text in the first target probability distribution is greater than or equal to a first predetermined value.

[0135] Taking the pruned large model as the text generation model, the first question text is "how are" and the reference label is "you" as an example to explain the first sub-loss.

[0136] For example, the pruned large model infers the first question text "how are" and determines the probability of the next word being each word in the vocabulary. For example, the probability that the next word is "you" is 0.2, and the probability that the next word is "I" is 0.05. In this way, the probabilities of each of the multiple words in the vocabulary constitute the first estimated probability distribution.

[0137] For example, if the label of the first question text indicates that the next word is "you", the probability value of "you" can be set to a first predetermined value, such as a larger value such as 1 or 0.98. The true probabilities of other words in the vocabulary except "you" are set to smaller values ​​such as 0 or 0.01. In this way, the probability values ​​of multiple words in the vocabulary are obtained, and these probability values ​​constitute a first target probability distribution. In this embodiment, the first target probability distribution is the reference label.

[0138] Next, the first sub-loss may be calculated according to the first estimated probability distribution and the first target probability distribution using a cross entropy loss function, a mean square error loss function, or other predetermined loss functions.

[0139] Figure 4 is a schematic diagram of a reference label used in the process of determining the first sub-loss according to an embodiment of the present disclosure. For example, the reference label Label_1 used in the process of determining the first sub-loss includes an answer text for accurately answering the first question text, and the probability distribution represented by the reference label Label_1 is as follows: Figure 4 As shown, it can be seen that the reference label Label_1 will indicate which word has the largest probability value next.

[0140] For example, the first sub-loss can be determined by formula (11).

[0141]

[0142] in, represents the first child loss, It is the first data set used in the training phase that meets the predetermined requirements.

[0143] This embodiment describes the second sub-loss. In this embodiment, the training sample includes a second question text from a second data set, the reference label includes a second target probability distribution, and each probability value in the second target probability distribution is less than or equal to a second predetermined value. The process of determining the second sub-loss includes: processing the second question text based on the pruned large model to obtain a second estimated probability distribution of an estimated text for answering the second question text. Then, the second sub-loss is determined based on the second estimated probability distribution and the second target probability distribution.

[0144] In this example, the pruned large model is used as the text generation model, and the second question text is "Comparison of people in XX company" as an example to illustrate the second sub-loss.

[0145] The pruned large model infers the second question text "Comparison of people in XX company" and determines the probability of the next word being each word in the vocabulary. For example, the probability that the next word is "red" is 0.2, and the probability that the next word is "I" is 0.01. In this way, the probabilities of multiple words in the vocabulary constitute the second estimated probability distribution.

[0146] The difference from the previous embodiment is that the first question text in the previous embodiment meets the predetermined requirements, so the pruned large model is forward trained, so that the large model retains or continues to learn security knowledge, and the output of the large model is close to the first label. However, the second question text in this embodiment does not meet the predetermined requirements, so the pruned large model is reversely trained, so that the large model forgets risk knowledge, and the output information of the large model is greatly different from the information that does not meet the predetermined requirements.

[0147] In this embodiment, the second target probability distribution is the reference label, and each probability value in the second target probability distribution is less than or equal to the second predetermined value. For example, the vocabulary includes n words, and the second predetermined value can be 1 / n or other smaller values. Taking the probability value of each word as 1 / n as an example, these probability values ​​constitute the second target probability distribution, and the second target probability distribution can indicate that the probability of the next word being each word in the vocabulary is the same. For example, in the second data set, the true label corresponding to the above-mentioned second question text "Comparison of people in XX company" is "bad". However, in this embodiment, the probability value of the true label "bad" of the second question text is made the same as the probability values ​​of other words, thereby randomly confusing the true label, so that the large model cannot learn knowledge based on the true label. Next, the second sub-loss can be calculated based on the second estimated probability distribution and the second target probability distribution using a cross entropy loss function, a mean square error loss function, or other predetermined loss functions.

[0148] It can be seen that this embodiment forces the large model to forget risk knowledge by random confusion. It should be noted that if a data set is found based on the type of security knowledge, and general supervised fine-tuning (SFT) is performed to forget risk knowledge, it will lead to excessive forgetting of the knowledge that you want to retain, which is called catastrophic forgetting. However, this non-selective post-training process may not effectively remove risk knowledge. In order to enhance the forgetting effect, this embodiment uses confusion loss for risk knowledge, and refuses to answer questions that do not meet the predetermined requirements by forcing a random prediction distribution during the generation process.

[0149] Figure 5 is a schematic diagram of a reference label used in the second sub-loss process according to an embodiment of the present disclosure. For example, the reference label Label_2 used in the second sub-loss process is to average the output probability, and the probability distribution represented by the reference label Label_2 is as follows: Figure 5 As shown, it can be seen that the reference label Label_2 indicates that the probability of each word appearing in the vocabulary is the same.

[0150] For example, the second sub-loss can be determined by formula (12).

[0151]

[0152] in, represents the second sub-loss, n is the vocabulary size, is the second data set used in the training phase that does not meet the predetermined requirements, λ train is the scaling factor.

[0153] This embodiment describes the third sub-loss. This embodiment determines the third sub-loss by knowledge distillation. In the process of knowledge distillation, the initial large model that has not been pruned is used as the teacher model, and the pruned large model is used as the student model.

[0154] In this embodiment, the training sample includes a third question text that meets the predetermined requirements. The process of determining the third sub-loss includes: processing the third question text based on the initial large model to obtain a first reference probability distribution of an estimated text for answering the third question text as a reference label. Then, processing the third question text based on the pruned large model to obtain a third estimated probability distribution of the estimated text for answering the third question text. Then, determining the third sub-loss based on the reference label and the third estimated probability distribution.

[0155] In this example, the pruned large model is used as the text generation model, and the third question text is "how are" as an example to illustrate the third sub-loss.

[0156] The initial large model that has not been pruned makes inferences about the third question text "how are" and determines the probability that the next word is each word in the vocabulary, for example, the probability that the next word is "you" is 0.9, and the probability that the next word is "old" is 0.02. For example, these probability values ​​can be determined as the first reference probability distribution (i.e., reference labels). For another example, the maximum probability value can be set to 1, and the probability values ​​of the remaining words can be set to 0, and these probability values ​​can be determined as the first reference probability distribution (i.e., reference labels).

[0157] Figure 6 is a schematic diagram of a reference tag used in a process of determining a third sub-loss according to an embodiment of the present disclosure. Figure 6 As shown, in the process of determining the third sub-loss, the first reference probability distribution output by the initial large model is used as the reference label Label_3.

[0158] Next, reasoning is performed based on the third question text "how are" processed by the pruned large model, and the probability of the next word being each word in the vocabulary is determined, thereby obtaining a third estimated probability distribution.

[0159] Next, the third sub-loss may be calculated according to the third estimated probability distribution and the first reference probability distribution using a cross entropy loss function, a mean square error loss function, or other predetermined loss functions.

[0160] It should be noted that the third question text in this embodiment and the first question text in the foregoing text both meet the predetermined requirements, and a first data set can be pre-constructed, and then a sample is extracted from the first data set as the third question text. In addition, the third question text and the first question text in the foregoing text can be the same or different, and this embodiment is described by taking the example that the two are the same.

[0161] For example, the third sub-loss can be determined by formula (13).

[0162]

[0163] in, represents the third child loss, D KL (p(x)|q(x)) is the KL divergence between p(x) and q(x), z i is the output of the teacher model, is the output of the student model, and T is the temperature hyperparameter. It can be seen that this embodiment minimizes the KL divergence between the initial large model and the pruned large model in security knowledge to supervise the training.

[0164] This embodiment describes the fourth sub-loss. This embodiment determines the third sub-loss by knowledge distillation. In the process of knowledge distillation, the initial large model that has not been pruned is used as the teacher model, and the pruned large model is used as the student model.

[0165] In this embodiment, the training sample includes a fourth question text that does not meet the predetermined requirements. The process of determining the fourth sub-loss includes: processing the fourth question text based on the initial large model to obtain a second reference probability distribution of the estimated text for answering the third question text; the second reference probability distribution represents the probability values ​​of each of the multiple texts. Then adjust the second reference probability distribution, and use the adjusted second reference probability distribution as a reference label; wherein the probability value of the same text in the second reference probability distribution is negatively correlated with the probability value of the text in the reference label. Then process the fourth question text based on the pruned large model to obtain a fourth estimated probability distribution of the estimated text for answering the third question text. Then determine the fourth sub-loss based on the reference label and the fourth estimated probability distribution.

[0166] In this example, the pruned large model is used as the text generation model, and the fourth question text is "Comparison of people in XX company" as an example to illustrate the fourth sub-loss.

[0167] The initial large model that has not been pruned reasons about the fourth question text "Comparison of people in XX company" and determines the probability of the next word being each word in the vocabulary. For example, the probability that the next word is "bad" is 0.7, the probability that the next word is "red" is 0.2, and the probability that the next word is "good" is 0.1. In this way, the probabilities of multiple words in the vocabulary constitute the second reference probability distribution.

[0168] Next, adjust the second reference probability value. The adjustment process can be understood as performing a similar inversion process on the second reference probability value, so that the probability value of the same text in the second reference probability distribution is negatively correlated with the probability value of the text in the reference label. For example, the probability value can be adjusted to the opposite number as a reference label. For another example, the probability that the next word is "bad" can be adjusted to 0.1, the probability that the next word is "red" can be adjusted to 0.8, and the probability that the next word is "good" can be adjusted to 0.9. Then, 0.1, 0.8 and 0.9 are normalized to obtain the adjusted second reference probability distribution, that is, the reference label.

[0169] Figure 7 is a schematic diagram of a reference tag used in a fourth sub-loss process according to an embodiment of the present disclosure. Figure 7 As shown, in the process of determining the fourth sub-loss, the second reference probability output by the initial large model is inverted and used as the reference label Label_4.

[0170] Next, reasoning is performed based on the fourth question text "Comparison of people in XX company" processed by the pruned large model, and the probability of the next word being each word in the vocabulary is determined, thereby obtaining a fourth estimated probability distribution.

[0171] Next, the fourth sub-loss may be calculated according to the fourth estimated probability distribution and the adjusted second reference probability distribution using a cross entropy loss function, a mean square error loss function, or other predetermined loss functions.

[0172] It should be noted that the fourth question text in this embodiment and the second question text in the foregoing text do not meet the predetermined requirements. A second data set can be pre-constructed, and then a sample is extracted from the second data set as the fourth question text. In addition, the fourth question text and the second question text in the foregoing text can be the same or different. This embodiment is described by taking the example that the two are the same.

[0173] For example, the fourth sub-loss can be determined by formula (14).

[0174]

[0175] in, Indicates the fourth child loss, D KL (p(x)|q(x)) is the KL divergence between p(x) and q(x), z i is the output of the teacher model, is the output of the student model, T is the temperature hyperparameter, and λ div It can be seen that, for information that does not meet the predetermined requirements, this embodiment uses the reverse output probability distribution of the initial large model to force the pruned large model to forget the risk knowledge.

[0176] This embodiment describes the fifth sub-loss. This embodiment determines the fifth sub-loss by contrastive learning. The contrastive learning process involves positive samples, negative samples, and anchor samples. This embodiment uses the fifth question text from the first data set as a positive sample and the sixth question text from the second data set as a negative sample. Several question texts can also be selected from the first data set as anchor question texts, and the anchor question texts are anchor samples.

[0177] In this embodiment, the process of determining the fifth sub-loss includes: processing the anchor question text, the fifth question text, and the sixth question text based on the pruned large model to obtain the anchor output representation, the positive sample output representation, and the negative sample output representation. Then, according to the difference between the anchor output representation and the positive sample output representation, and the difference between the anchor output representation and the negative sample output representation, the fifth sub-loss is determined. Then, according to the fifth sub-loss, the training loss value is determined.

[0178] In this example, the fifth sub-loss is explained by taking the pruned large model as a text generation model. For example, the anchor question text can be processed based on the pruned large model to obtain an anchor output representation, and its representation represents the answer text used to answer the anchor question text. The fifth question text is processed based on the pruned large model to obtain a positive sample output representation, which represents the answer text used to answer the fifth question text. The sixth question text is processed based on the pruned large model to obtain a negative sample output representation, which represents the answer text used to answer the sixth question text. The fifth sub-loss is then calculated using InfoNCE or other loss functions.

[0179] Figure 8 is a schematic diagram of determining the fifth sub-loss according to an embodiment of the present disclosure. This embodiment uses contrastive learning to train the pruned large model, such as Figure 8 As shown, through contrastive learning, the output representation 802 of the positive sample can be made closer to the output representation 801 of the anchor sample, and the output representation 803 of the negative sample can be made farther from the output representation 801 of the anchor sample. Contrastive learning can reduce the coupling of security knowledge and risk knowledge.

[0180] For example, the fifth sub-loss can be determined by formula (15).

[0181]

[0182] Among them, z i is the output representation of the i-th post-training data, and the average pooling of each token representation can be used as the sequence representation. is a set of selected anchor point samples, P(i) represents the positive sample set of the i-th sample, Calculate the cosine similarity between two vectors, τ is a temperature hyperparameter.

[0183] In the post-training process, the training loss value can be determined based on the five sub-losses. For example, the five sub-losses are weighted to obtain the training loss value. For example, the training loss value can be calculated using formula (16):

[0184]

[0185] Among them, α′ and β′ are hyperparameters that adjust the relative importance of sub-losses.

[0186] It should be noted that, in the post-training process, the first question text, the third prompt text and the fifth prompt text in the above text all come from the first data set, and these question texts can be the same or different. The second question text, the fourth prompt text and the sixth prompt text in the above text all come from the second data set, and these question texts can be the same or different.

[0187] It should be noted that the first data set and the second data set are also used in the process of locating the model parameters to be pruned in the initial large model. The first sample used in the locating process may be the same as or different from the first question text, the third prompt text, and the fifth prompt text used in the post-training process. The second sample used in the locating process may be the same as or different from the second question text, the fourth prompt text, and the sixth prompt text used in the post-training process.

[0188] Fig. 9 It is a schematic flow chart of a large model-based response method according to an embodiment of the present disclosure.

[0189] like Fig. 9 As shown, the large model-based answering method 900 may include operations S910 to S920.

[0190] In operation S910, a question text is acquired.

[0191] In operation S920, the question text is input into the large model to obtain the answer text, wherein the large model is obtained by using the large model pruning method described above.

[0192] For example, the user inputs the question text through the front-end operation page according to actual needs. The question text can be a question of mathematics, common sense, planning, creation, etc. For example, the question text of mathematics is such as "What is the solution of the equation 3X+1=4", the question text of common sense is such as "Is Beijing a coastal city", and the question text of planning is such as "I want to go to Beijing tomorrow, give me some clothing suggestions." The question text of creation is such as "Write a story for me. The characters in the story are A, B and C. Among them, A is introduced as follows: aaa; B is introduced as follows: bbb; C is introduced as follows: ccc".

[0193] For example, the large model may be a generative large language model, such as a text generation model capable of implementing question and answer. The large model may be a pruned large model or a target model after post-training.

[0194] For example, after receiving the question text input by the user, the question text can be input into the large model, or the question text can be combined with prompt information (Prompt), and then the combined information is input into the large model, and the large model outputs the answer information. In the actual processing, the processor can read the model parameters of the large model from the storage unit, and then use the model parameters to process the question text.

[0195] This embodiment uses a large model to process the question text and obtain the response text, thereby answering the questions or needs raised by the user.

[0196] In addition, since the large model is obtained by pruning the initial large model, the large model has fewer model parameters, which can reduce the storage space occupied by the large model. In the process of model reasoning, the amount of calculation can be reduced and the calculation efficiency can be improved. The reduction in the amount of calculation will further reduce the amount of data transmission, improve the transmission efficiency, and further save storage space.

[0197] Fig.10 It is a schematic structural block diagram of a large model pruning device according to an embodiment of the present disclosure.

[0198] like Fig.10 As shown, the large model pruning device 1000 may include: a loss determination module 1010, an indicator determination module 1020 and a pruning module 1030.

[0199] The loss determination module 1010 is used to perform a loss calculation task using a processor based on multiple model parameters of the initial large model, according to a first sample that meets predetermined requirements, a first label for the first sample, a second sample that does not meet the predetermined requirements, and a second label for the second sample, to obtain a first loss value for the first sample and a second loss value for the second sample.

[0200] The index determination module 1020 is used to perform the evaluation task using a processor according to the first loss value and the second loss value to obtain the importance index of multiple model parameters, wherein the importance index represents the degree to which the output information determined based on the model parameters meets the predetermined requirements.

[0201] The pruning module 1030 is used to perform pruning tasks on multiple model parameters based on the importance index using a processor to obtain a pruned large model.

[0202] According to another embodiment of the present disclosure, the loss determination module includes: a reference change submodule, a first determination submodule, and a second determination submodule. The reference change submodule is used to use a processor to change multiple model parameters based on a candidate mask to obtain changed model parameters. The first determination submodule is used to use a processor to determine a first loss value based on a first label and output data obtained by processing a first sample based on the changed parameters. The second determination submodule is used to use a processor to determine a second loss value based on a second label and output data obtained by processing a second sample based on the changed parameters.

[0203] According to another embodiment of the present disclosure, the indicator determination module includes: a total loss determination submodule and a mask determination submodule. The total loss determination submodule is used to determine the total loss value using a processor according to the first loss value and the second loss value. The total loss value is positively correlated with the first loss value, and the total loss value is negatively correlated with the second loss value. There are multiple candidate masks, and the multiple candidate masks correspond one to one with the multiple total loss values. The mask determination submodule is used to determine the target mask from the multiple candidate masks using a processor according to the minimum total loss among the multiple total loss values ​​as an importance indicator.

[0204] According to another embodiment of the present disclosure, the indicator determination module includes: a first evaluation value determination submodule, a second evaluation value determination submodule and a total evaluation value determination submodule. The first evaluation value determination submodule is used to determine the first evaluation value using a processor according to the change of the first loss value relative to multiple model parameters. The second evaluation value determination submodule is used to determine the second evaluation value using a processor according to the change of the second loss value relative to multiple model parameters. The total evaluation value determination submodule is used to determine the total evaluation value using a processor according to the first evaluation value and the second evaluation value as an importance indicator. Among them, the total evaluation value is negatively correlated with the first evaluation value, and the total evaluation value is positively correlated with the second evaluation value.

[0205] According to another embodiment of the present disclosure, the loss determination module includes: a third determination submodule and a fourth determination submodule. The third determination submodule is used to input the first sample into the initial large model using a processor, obtain the first output data based on multiple model parameters, and determine the first loss value according to the difference between the first output data and the first label. The fourth determination submodule is used to input the second sample into the initial large model using a processor, obtain the second output data based on multiple model parameters, and determine the second loss value according to the difference between the second output data and the second label.

[0206] According to another embodiment of the present disclosure, a training loss value determination module and an adjustment module are also included. The training loss value determination module is used to determine the training loss value based on the pruned large model, the training samples and the reference labels corresponding to the training samples. The adjustment module is used to adjust the model parameters of the pruned large model according to the training loss value to obtain the target model. The training samples include samples that meet the predetermined requirements and / or samples that do not meet the predetermined requirements.

[0207] According to another embodiment of the present disclosure, the training sample includes a first question text that meets predetermined requirements, and the reference label includes a first answer text. The training loss value determination module includes: a first processing submodule, a first sub-loss determination submodule and a first training loss value determination submodule. The first processing submodule is used to process the first question text based on the pruned large model to obtain a first estimated probability distribution of an estimated text for answering the first question text. The first sub-loss determination submodule is used to determine the first sub-loss based on the first estimated probability distribution and the first target probability distribution determined based on the first answer text. Among them, the probability value corresponding to the first answer text in the first target probability distribution is greater than or equal to the first predetermined value. The first training loss value determination submodule is used to determine the training loss value based on the first sub-loss.

[0208] According to another embodiment of the present disclosure, the training sample includes a second question text that does not meet the predetermined requirements, the reference label includes a second target probability distribution, and each probability value in the second target probability distribution is less than or equal to a second predetermined value. The training loss value determination module includes: a second processing submodule, a second sub-loss determination submodule, and a second training loss value submodule. The second processing submodule is used to process the second question text based on the pruned large model to obtain a second estimated probability distribution of the estimated text for answering the second question text. The second sub-loss determination submodule is used to determine the second sub-loss based on the second estimated probability distribution and the second target probability distribution. The second training loss value submodule is used to determine the training loss value based on the second sub-loss.

[0209] According to another embodiment of the present disclosure, the training sample includes a third question text that meets predetermined requirements. The training loss value determination module includes: a third processing submodule, a fourth processing submodule, a third sub-loss determination submodule and a third training loss value submodule. The third processing submodule is used to process the third question text based on the initial large model, and obtain a first reference probability distribution of an estimated text for answering the third question text as a reference label. The fourth processing submodule is used to process the third question text based on the pruned large model, and obtain a third estimated probability distribution of an estimated text for answering the third question text. The third sub-loss determination submodule is used to determine the third sub-loss based on the reference label and the third estimated probability distribution. The third training loss value submodule is used to determine the training loss value based on the third sub-loss.

[0210] According to another embodiment of the present disclosure, the training sample includes a fourth question text that does not meet the predetermined requirements. The training loss value determination module includes: a fifth processing submodule, an adjustment submodule, a sixth processing submodule, a fourth sub-loss determination submodule and a fourth training loss value submodule. The fifth processing submodule is used to process the fourth question text based on the initial large model to obtain a second reference probability distribution of the estimated text for answering the third question text. The second reference probability distribution characterizes the probability values ​​of each of the multiple texts. The adjustment submodule is used to adjust the second reference probability distribution and use the adjusted second reference probability distribution as a reference label. Among them, the probability value of the same text in the second reference probability distribution is negatively correlated with the probability value of the text in the reference label. The sixth processing submodule is used to process the fourth question text based on the pruned large model to obtain a fourth estimated probability distribution of the estimated text for answering the third question text. The fourth sub-loss determination submodule is used to determine the fourth sub-loss according to the reference label and the fourth estimated probability distribution. The fourth training loss value submodule is used to determine the training loss value according to the fourth sub-loss.

[0211] According to another embodiment of the present disclosure, the training sample includes an anchor question text, a fifth question text and a sixth question text, the anchor question text and the fifth question text all meet the predetermined requirements, and the sixth question text does not meet the predetermined requirements. The training loss value determination module includes: a seventh processing submodule, a fifth sub-loss determination submodule and a fifth training loss value submodule. The seventh processing submodule is used to process the anchor question text, the fifth question text and the sixth question text based on the pruned large model to obtain an anchor output representation, a positive sample output representation and a negative sample output representation. Among them, the anchor output representation represents the answer text used to answer the anchor question text, the positive sample output representation represents the answer text used to answer the fifth question text, and the negative sample output representation represents the answer text used to answer the sixth question text. The fifth sub-loss determination submodule is used to determine the fifth sub-loss according to the difference between the anchor output representation and the positive sample output representation, and the difference between the anchor output representation and the negative sample output representation. The fifth training loss value submodule is used to determine the training loss value according to the fifth sub-loss.

[0212] According to another embodiment of the present disclosure, the first sample includes a question text that meets the predetermined requirements, and the first label includes an answer text for answering the question text in the first sample. The second sample includes a question text that does not meet the predetermined requirements, and the second label includes an answer text for answering the question text in the second sample.

[0213] Fig.11 It is a schematic structural block diagram of a large model-based response device according to an embodiment of the present disclosure.

[0214] like Fig.11As shown, the large model-based response device 1100 may include: an acquisition module 1110 and an input module 1120.

[0215] The acquisition module 1110 is used to acquire the question text.

[0216] The input module 1120 is used to input the question text into the large model to obtain the response text, wherein the large model is obtained using the above-mentioned large model pruning device.

[0217] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, comprising at least one processor; and a memory communicatively connected to the at least one processor; the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute any of the above methods.

[0218] According to an embodiment of the present disclosure, the present disclosure further provides a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to enable a computer to execute any of the above methods.

[0219] According to an embodiment of the present disclosure, the present disclosure further provides a computer program product, including a computer program, and the computer program implements any of the above methods when executed by a processor.

[0220] Fig.12 A schematic block diagram of an example electronic device 1200 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.

[0221] like Fig.12 As shown, the device 1200 includes a computing unit 1201, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 1202 or a computer program loaded from a storage unit 1208 into a random access memory (RAM) 1203. In the RAM 1203, various programs and data required for the operation of the device 1200 can also be stored. The computing unit 1201, the ROM 1202, and the RAM 1203 are connected to each other via a bus 1204. An input / output (I / O) interface 1205 is also connected to the bus 1204.

[0222] A number of components in the device 1200 are connected to the I / O interface 1205, including: an input unit 1206, such as a keyboard, a mouse, etc.; an output unit 1207, such as various types of displays, speakers, etc.; a storage unit 1208, such as a disk, an optical disk, etc.; and a communication unit 1209, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 1209 allows the device 1200 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0223] The computing unit 1201 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 1201 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 1201 performs the various methods and processes described above, such as the above-mentioned large model pruning method and / or the large model-based answering method. For example, in some embodiments, the large model pruning method and / or the large model-based answering method may be implemented as a computer software program, which is tangibly included in a machine-readable medium, such as a storage unit 1208. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 1200 via the ROM 1202 and / or the communication unit 1209. When the computer program is loaded into the RAM 1203 and executed by the computing unit 1201, one or more steps of the large model pruning method and / or the large model-based answering method described above may be performed. Alternatively, in other embodiments, the computing unit 1201 may be configured to execute the large model pruning method and / or the large model-based response method in any other appropriate manner (eg, by means of firmware).

[0224] 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), complex 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.

[0225] 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.

[0226] 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.

[0227] 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).

[0228] 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.

[0229] A computer system may include clients and servers. Clients and servers 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 to each other.

[0230] 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.

[0231] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.

Claims

1. A large model pruning method, comprising: Based on multiple model parameters of the initial large model, according to a first sample that meets a predetermined requirement, a first label for the first sample, a second sample that does not meet the predetermined requirement, and a second label for the second sample, using a processor to perform a loss calculation task to obtain a first loss value of the first sample and a second loss value of the second sample; According to the first loss value and the second loss value, the processor is used to perform an evaluation task to obtain importance indicators of the multiple model parameters; wherein the importance indicators represent the degree to which the output information determined based on the model parameters meets the predetermined requirements; and Based on the importance index, the processor is used to perform a pruning task on the multiple model parameters to obtain a pruned large model.

2. The method according to claim 1, wherein: Utilizing a processor to perform a loss calculation task to obtain a first loss value of the first sample and a second loss value of the second sample includes: Using the processor, changing the plurality of model parameters based on the candidate mask to obtain changed model parameters; Determining the first loss value using the processor according to the first label and output data obtained by processing the first sample based on the changed parameters; and The second loss value is determined using the processor according to the second label and output data obtained by processing the second sample based on the changed parameters.

3. The method according to claim 2, wherein: The obtaining of importance indicators of the plurality of model parameters by using the processor to perform the evaluation task according to the first loss value and the second loss value includes: Determining a total loss value using the processor according to the first loss value and the second loss value; wherein the total loss value is positively correlated with the first loss value, and the total loss value is negatively correlated with the second loss value; the number of the candidate masks is multiple, and the multiple candidate masks correspond to the multiple total loss values ​​one by one; and According to the minimum total loss among the plurality of total loss values, the processor is used to determine a target mask from the plurality of candidate masks as the importance indicator.

4. The method according to claim 1, wherein: The obtaining of importance indicators of the plurality of model parameters by using the processor to perform the evaluation task according to the first loss value and the second loss value includes: determining, using the processor, a first evaluation value based on a change in the first loss value relative to the plurality of model parameters; determining, using the processor, a second evaluation value based on a change in the second loss value relative to the plurality of model parameters; and According to the first evaluation value and the second evaluation value, the processor is used to determine a total evaluation value as the importance indicator; wherein the total evaluation value is negatively correlated with the first evaluation value, and the total evaluation value is positively correlated with the second evaluation value.

5. The method according to claim 4, wherein: Utilizing a processor to perform a loss calculation task to obtain a first loss value of the first sample and a second loss value of the second sample includes: Using the processor to input the first sample into the initial large model, obtain first output data based on the multiple model parameters, and determine the first loss value according to the difference between the first output data and the first label; and The processor is used to input the second sample into the initial large model, obtain second output data based on the multiple model parameters, and determine the second loss value according to the difference between the second output data and the second label.

6. The method according to any one of claims 1 to 5, further comprising: Based on the pruned large model, determining a training loss value according to training samples and reference labels corresponding to the training samples; as well as According to the training loss value, adjusting the model parameters of the pruned large model to obtain a target model; The training samples include at least one of samples that meet the predetermined requirements and samples that do not meet the predetermined requirements.

7. The method according to claim 6, wherein: The training sample includes a first question text that meets the predetermined requirement, and the reference label includes a first answer text; and the determining of the training loss value based on the pruned large model according to the training sample and the reference label corresponding to the training sample includes: Processing the first question text based on the pruned large model to obtain a first estimated probability distribution of an estimated text for answering the first question text; Determine a first sub-loss according to the first estimated probability distribution and a first target probability distribution determined based on the first answer text; wherein the probability value corresponding to the first answer text in the first target probability distribution is greater than or equal to a first predetermined value; Determine the training loss value according to the first sub-loss.

8. The method according to claim 6, wherein: The training sample includes a second question text that does not meet the predetermined requirement, the reference label includes a second target probability distribution, and each probability value in the second target probability distribution is less than or equal to a second predetermined value; the determining the training loss value based on the pruned large model according to the training sample and the reference label corresponding to the training sample includes: Processing the second question text based on the pruned large model to obtain a second estimated probability distribution of an estimated text for answering the second question text; determining a second sub-loss according to the second estimated probability distribution and the second target probability distribution; The training loss value is determined according to the second sub-loss.

9. The method according to claim 6, wherein: The training sample includes a third question text that meets the predetermined requirement; and the determining of the training loss value based on the pruned large model according to the training sample and a reference label corresponding to the training sample includes: Processing the third question text based on the initial large model to obtain a first reference probability distribution of an estimated text for answering the third question text as the reference label; Processing the third question text based on the pruned large model to obtain a third estimated probability distribution of an estimated text for answering the third question text; determining a third sub-loss according to the reference tag and the third estimated probability distribution; The training loss value is determined according to the third sub-loss.

10. The method according to claim 6, wherein: The training sample includes a fourth question text that does not meet the predetermined requirement; the determining of the training loss value based on the pruned large model according to the training sample and the reference label corresponding to the training sample includes: Processing the fourth question text based on the initial large model to obtain a second reference probability distribution of an estimated text for answering the third question text; the second reference probability distribution represents the probability values ​​of each of the plurality of texts; Adjusting the second reference probability distribution, and using the adjusted second reference probability distribution as the reference label; wherein the probability value of the same text in the second reference probability distribution is negatively correlated with the probability value of the text in the reference label; Processing the fourth question text based on the pruned large model to obtain a fourth estimated probability distribution of an estimated text for answering the third question text; determining a fourth sub-loss according to the reference tag and a fourth estimated probability distribution; The training loss value is determined according to the fourth sub-loss.

11. The method according to claim 6, wherein: The training sample includes an anchor question text, a fifth question text, and a sixth question text, the anchor question text and the fifth question text both meet the predetermined requirement, and the sixth question text does not meet the predetermined requirement; the determining of the training loss value based on the pruned large model according to the training sample and the reference label corresponding to the training sample includes: Processing the anchor question text, the fifth question text and the sixth question text based on the pruned large model to obtain an anchor output representation, a positive sample output representation and a negative sample output representation; wherein the anchor output representation represents an answer text used to answer the anchor question text, the positive sample output representation represents an answer text used to answer the fifth question text, and the negative sample output representation represents an answer text used to answer the sixth question text; Determining a fifth sub-loss according to a difference between the anchor point output representation and the positive sample output representation, and a difference between the anchor point output representation and the negative sample output representation; The training loss value is determined according to the fifth sub-loss.

12. The method according to any one of claims 1 to 11, wherein: The first sample includes a question text that meets the predetermined requirement, and the first label includes an answer text for answering the question text in the first sample; The second sample includes a question text that does not meet the predetermined requirement, and the second tag includes an answer text for answering the question text in the second sample.

13. A response method based on a large model, comprising: Get the question text; Input the question text into the large model to obtain the answer text; Wherein, the large model is obtained by using the method described in any one of claims 1 to 12.

14. A large-scale model pruning device, comprising: a loss determination module, configured to obtain a first loss value of the first sample and a second loss value of the second sample by using a processor to perform a loss calculation task based on a plurality of model parameters of the initial large model, according to a first sample that meets the predetermined requirement, a first label for the first sample, a second sample that does not meet the predetermined requirement, and a second label for the second sample; An indicator determination module, configured to obtain importance indicators of the plurality of model parameters by using the processor to perform an evaluation task according to the first loss value and the second loss value; wherein the importance indicators represent the degree to which the output information determined based on the model parameters meets the predetermined requirements; as well as A pruning module is used to perform pruning tasks on the multiple model parameters using the processor based on the importance index to obtain a pruned large model.

15. The device according to claim 14, wherein: The loss determination module comprises: A reference changing submodule, configured to use the processor to change the plurality of model parameters based on the candidate mask to obtain changed model parameters; a first determination submodule, configured to determine the first loss value using the processor according to the first label and output data obtained by processing the first sample based on the changed parameters; and The second determination submodule is used to determine the second loss value using the processor according to the second label and the output data obtained by processing the second sample based on the changed parameters.

16. The device according to claim 15, wherein: The indicator determination module comprises: a total loss determination submodule, configured to determine a total loss value using the processor according to the first loss value and the second loss value; wherein the total loss value is positively correlated with the first loss value, and the total loss value is negatively correlated with the second loss value; the number of the candidate masks is multiple, and the multiple candidate masks correspond one to one with the multiple total loss values; and The mask determination submodule is used to determine a target mask from the multiple candidate masks using the processor according to the minimum total loss among the multiple total loss values ​​as the importance indicator.

17. The device according to claim 14, wherein: The indicator determination module comprises: A first evaluation value determination submodule, configured to determine a first evaluation value using the processor according to a change of the first loss value relative to the plurality of model parameters; a second evaluation value determination submodule, configured to determine a second evaluation value using the processor according to a change of the second loss value relative to the plurality of model parameters; and The total evaluation value determination submodule is used to determine the total evaluation value as the importance indicator using the processor according to the first evaluation value and the second evaluation value; wherein the total evaluation value is negatively correlated with the first evaluation value, and the total evaluation value is positively correlated with the second evaluation value.

18. The device according to claim 17, wherein: The loss determination module comprises: a third determination submodule, configured to use the processor to input the first sample into the initial large model, obtain first output data based on the multiple model parameters, and determine the first loss value according to a difference between the first output data and the first label; and The fourth determination submodule is used to use the processor to input the second sample into the initial large model, obtain second output data based on the multiple model parameters, and determine the second loss value according to the difference between the second output data and the second label.

19. The device according to any one of claims 14 to 18, further comprising: a training loss value determination module, configured to determine a training loss value based on the pruned large model, according to training samples and reference labels corresponding to the training samples; and An adjustment module, used for adjusting the model parameters of the pruned large model according to the training loss value to obtain a target model; in, The training samples include at least one of samples that meet the predetermined requirements and samples that do not meet the predetermined requirements.

20. The device according to claim 19, wherein The training sample includes a first question text that meets the predetermined requirement, and the reference tag includes a first answer text; The training loss value determination module includes: A first processing submodule, configured to process the first question text based on the pruned large model to obtain a first estimated probability distribution of an estimated text for answering the first question text; A first sub-loss determination submodule, configured to determine a first sub-loss according to the first estimated probability distribution and a first target probability distribution determined based on the first answer text; wherein the probability value corresponding to the first answer text in the first target probability distribution is greater than or equal to a first predetermined value; The first training loss value determination submodule is used to determine the training loss value according to the first sub-loss.

21. The device according to claim 19, wherein The training sample includes a second question text that does not meet the predetermined requirement, the reference tag includes a second target probability distribution, and each probability value in the second target probability distribution is less than or equal to a second predetermined value; The training loss value determination module includes: A second processing submodule, configured to process the second question text based on the pruned large model to obtain a second estimated probability distribution of an estimated text for answering the second question text; A second sub-loss determination submodule, configured to determine a second sub-loss according to the second estimated probability distribution and the second target probability distribution; The second training loss value submodule is used to determine the training loss value according to the second sub-loss.

22. The device according to claim 19, wherein The training sample includes a third question text that meets the predetermined requirement; the training loss value determination module includes: A third processing submodule is used to process the third question text based on the initial large model to obtain a first reference probability distribution of an estimated text for answering the third question text as the reference label; A fourth processing submodule, configured to process the third question text based on the pruned large model to obtain a third estimated probability distribution of an estimated text for answering the third question text; A third sub-loss determination submodule, configured to determine a third sub-loss according to the reference tag and the third estimated probability distribution; The third training loss value submodule is used to determine the training loss value according to the third sub-loss.

23. The device according to claim 19, wherein: The training sample includes a fourth question text that does not meet the predetermined requirement; The training loss value determination module includes: A fifth processing submodule, configured to process the fourth question text based on the initial large model to obtain a second reference probability distribution of an estimated text for answering the third question text; the second reference probability distribution represents the probability values ​​of each of the plurality of texts; An adjustment submodule, used for adjusting the second reference probability distribution, and using the adjusted second reference probability distribution as the reference label; wherein the probability value of the same text in the second reference probability distribution is negatively correlated with the probability value of the text in the reference label; A sixth processing submodule, configured to process the fourth question text based on the pruned large model to obtain a fourth estimated probability distribution of an estimated text for answering the third question text; a fourth sub-loss determination submodule, configured to determine a fourth sub-loss according to the reference tag and a fourth estimated probability distribution; The fourth training loss value submodule is used to determine the training loss value according to the fourth sub-loss.

24. The device according to claim 19, wherein The training sample includes an anchor question text, a fifth question text and a sixth question text, the anchor question text and the fifth question text both meet the predetermined requirements, and the sixth question text does not meet the predetermined requirements; the training loss value determination module includes: A seventh processing submodule is used to process the anchor question text, the fifth question text and the sixth question text based on the pruned large model to obtain an anchor output representation, a positive sample output representation and a negative sample output representation; wherein the anchor output representation represents an answer text used to answer the anchor question text, the positive sample output representation represents an answer text used to answer the fifth question text, and the negative sample output representation represents an answer text used to answer the sixth question text; a fifth sub-loss determination submodule, configured to determine a fifth sub-loss according to a difference between the anchor point output representation and the positive sample output representation, and a difference between the anchor point output representation and the negative sample output representation; The fifth training loss value submodule is used to determine the training loss value according to the fifth sub-loss.

25. The device according to any one of claims 14 to 24, wherein: The first sample includes a question text that meets the predetermined requirement, and the first label includes an answer text for answering the question text in the first sample; The second sample includes a question text that does not meet the predetermined requirement, and the second tag includes an answer text for answering the question text in the second sample.

26. A response device based on a large model, comprising: An acquisition module is used to obtain the question text; An input module, used for inputting the question text into the large model to obtain a response text; Wherein, the large model is obtained using the device described in any one of claims 14 to 26.

27. An electronic device comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable 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 according to any one of claims 1 to 13.

28. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1 to 13.

29. A computer program product comprising a computer program which, when executed by a processor, implements the method according to any one of claims 1 to 13.

Citation Information

Cited By

  • Question and answer method and product of question and answer large language model based on data-driven regularization

    CN120336497A

  • Large language model fine tuning method and system based on task-specific sparse binary mask

    CN122528961A