Model robustness verification method and device, electronic equipment and storage medium

By obtaining the loss value during the training process of the big model fine-tuning and generating verification data sets, the robustness of the big model after fine-tuning is evaluated, and the problem of inability to fully evaluate the robustness of the model in the existing technology is solved, and systematic and accurate and robust verification of the LoRA fine-tuning model is achieved.

CN119886345APending Publication Date: 2025-04-25CHINA TELECOM CORP LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411961227.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-27
Publication Date
2025-04-25

AI Technical Summary

Technical Problem

The prior art cannot fully evaluate the robustness of large models after fine-tuning, especially the model stability and performance in different scenarios.

Method used

By obtaining the loss value of the large model during fine-tuning training, the model to be verified is determined, and a validation dataset is generated to evaluate the robustness of the model. The specific steps include obtaining keywords in the training dataset, generating a verification dataset, calculating the similarity between the answers generated by the model to be verified and the answers in the verification dataset, and finally determining the robustness score of the model based on the similarity.

Benefits of technology

The systematic and accurate robustness verification of multiple LoRA fine-tuning models is achieved, and the problem of failure to fully evaluate the robustness of the fine-tuning model in the prior art is solved, thereby improving the robustness and stability of the model in practical applications.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119886345A_ABST
    Figure CN119886345A_ABST
Patent Text Reader

Abstract

The invention discloses a model robustness verification method and device, electronic equipment and a storage medium. The method comprises the following steps: acquiring a loss value corresponding to each training batch in a fine tuning training process of a large model, and determining a to-be-verified model from fine tuning models obtained from each training batch according to the loss value; a training data set adopted in the fine tuning training process is obtained, and a verification data set is generated according to keywords contained in question texts in the training data set; obtaining an answer result generated by the to-be-verified model according to the question text in the verification data set; and determining the similarity between an answer result generated by the to-be-verified model and an answer result corresponding to the question text in the verification data set, and determining a robustness score of the to-be-verified model according to the similarity. The technical problem that a large model fine tuning verification scheme in the related technology cannot fully evaluate the robustness of the fine tuning model is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of large model fine-tuning verification, and specifically, to a model robustness verification method, device, electronic device and storage medium. Background Art

[0002] With the development of deep learning, large-scale language models are increasingly used in natural language processing. In order to meet the needs of different tasks, model fine-tuning technology is widely used, among which LoRA (Low-Rank Adaptation) technology has attracted attention due to its high efficiency and low resource consumption. However, the robustness of the fine-tuned model in practical applications is still an important issue, especially the stability and performance of the model in different scenarios. The verification methods in related technologies often cannot fully reflect the advantages and disadvantages of the fine-tuned model, and lack a mechanism for comprehensive analysis of multi-batch models. Therefore, a verification and analysis method is needed to solve this problem.

[0003] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention

[0004] The embodiments of the present application provide a model robustness verification method, device, electronic device and storage medium to at least solve the technical problem in the related art that the large model fine-tuning verification scheme cannot fully evaluate the robustness of the fine-tuning model.

[0005] According to one aspect of an embodiment of the present application, a method for verifying the robustness of a model is provided, comprising: obtaining loss values ​​corresponding to each training batch during fine-tuning training of a large model, and determining a model to be verified from the fine-tuning models obtained from each training batch based on the loss values; obtaining a training data set used in the fine-tuning training process, and generating a verification data set based on keywords contained in a question text in the training data set, wherein the training data set or the verification data set both contain multiple sample data, and the sample data include: a question text, and an answer result corresponding to the question text, and the sample data contained in the training data set is different from that contained in the verification data set; obtaining an answer result generated by the model to be verified based on the question text in the verification data set; determining the similarity between the answer result generated by the model to be verified and the answer result corresponding to the question text in the verification data set, and determining a robustness score of the model to be verified based on the similarity.

[0006] Optionally, determining the model to be verified from the fine-tuned models obtained from each training batch based on the loss value includes: determining a loss curve based on the loss values ​​corresponding to each training batch, wherein the loss curve is used to characterize the changing trend of the loss value during the model training process; extracting key features in the loss curve, wherein the key features include at least one of the following: the rate of decrease of the loss value, the statistical characteristics of the loss value, and the statistical characteristics include at least one of the following: maximum, mean, median, standard deviation; determining the performance parameters of the fine-tuned model corresponding to each training batch based on the key features, and determining the model to be verified based on the performance parameters, wherein the performance parameters are used to characterize the accuracy of the fine-tuned model in answering the question text.

[0007] Optionally, generating a verification data set based on keywords contained in the question text in the training data set includes: dividing the question text in the training data set into multiple word segments, and determining keywords in the word segments; determining synonyms and / or near-synonyms corresponding to the keywords, and replacing the keywords in the question text with the synonyms and / or near-synonyms; adding the new question text obtained after the replacement, and the answer results corresponding to the question text, as sample data to the verification data set; using a natural language generation model, based on the answer results in the training data set, generating a new question text corresponding to the answer results, and adding the newly generated question text and the corresponding answer results as sample data to the verification data set.

[0008] Optionally, the method also includes: determining the semantic topic similarity and sentence structure similarity between each question text in the training data set, wherein the semantic topic similarity is used to characterize the degree of semantic similarity between the question texts, and the sentence structure similarity is used to characterize the degree of grammatical structure similarity between the question texts; obtaining at least two question texts, wherein the semantic topic similarity between the obtained question texts exceeds a preset topic similarity threshold, and the sentence structure similarity exceeds a preset structure similarity threshold; fusing the at least two question texts to obtain a new question text, and fusing the answer results corresponding to the at least two question texts in the training data set to obtain a new answer result; and adding the newly obtained question text and answer result as sample data to the verification data set.

[0009] Optionally, determining the similarity between the answer result generated by the model to be verified and the answer result corresponding to the question text in the verification data set includes: dividing the answer result into multiple participles, and determining the weight coefficient corresponding to each participle, wherein the weight coefficient is used to characterize the contribution of the participle to the semantics; based on the weight coefficient, converting the answer result generated by the model to be verified into a first vector, and converting the answer result in the verification data set into a second vector; and determining the cosine similarity between the first vector and the second vector.

[0010] Optionally, determining the weight coefficient corresponding to each participle includes: counting the number of times each participle appears in the answer result to obtain the word frequency corresponding to the participle; determining the inverse document frequency corresponding to each participle, wherein the inverse document frequency is used to characterize the prevalence of the participle in the answer result; and determining the weight coefficient corresponding to the participle based on the word frequency and the inverse document frequency.

[0011] Optionally, based on the similarity, determining the robustness score of the model to be verified includes: standardizing the similarity based on the maximum similarity and the minimum similarity; converting the standardized similarity into a percentage score to obtain a robustness score, and sorting each model to be verified in order from high to low according to the robustness score, and sending the sorted models to be verified and the corresponding robustness scores to the front-end interactive interface for display.

[0012] According to another aspect of an embodiment of the present application, another method for verifying the robustness of a model is provided, including: obtaining loss values ​​corresponding to multiple training batches during fine-tuning training of a large model, and determining a model to be verified from the fine-tuning models obtained from the multiple training batches based on the loss values; obtaining a training data set used in the fine-tuning training process, and determining a verification data set corresponding to the training data set, wherein the verification data set is used to verify the fine-tuning model obtained by training the training data set, and the verification data set at least includes sample data determined based on keywords in a question text in the training data set, and the sample data in the verification data set and the training data set both include: question text, and sample answer results corresponding to the question text, and the sample data contained in the training data set is different from that contained in the verification data set; obtaining a target answer result generated by the model to be verified based on the question text in the verification data set; determining the similarity between the target answer result and the sample answer result corresponding to the question text in the verification data set, and determining the robustness score of the model to be verified based on the similarity.

[0013] According to another aspect of the embodiment of the present application, a model robustness verification device is also provided, including: a model selection module, used to obtain the loss value corresponding to each training batch during the fine-tuning training of the large model, and determine the model to be verified from the fine-tuning models obtained from each training batch based on the loss value; a verification set construction module, used to obtain the training data set used in the fine-tuning training process, and generate a verification data set based on the keywords contained in the question text in the training data set, wherein the training data set or the verification data set contains multiple sample data, and the sample data includes: question text, and answer results corresponding to the question text, and the sample data contained in the training data set is different from that contained in the verification data set; a model testing module, used to obtain the answer result generated by the model to be verified based on the question text in the verification data set; a result verification module, used to determine the similarity between the answer result generated by the model to be verified and the answer result corresponding to the question text in the verification data set, and determine the robustness score of the model to be verified based on the similarity.

[0014] According to another aspect of the embodiments of the present application, there is also provided an electronic device, including: a memory and a processor, the processor being used to run a program stored in the memory, wherein a robustness verification method of a model is executed when the program is run.

[0015] According to another aspect of the embodiments of the present application, a non-volatile storage medium is provided, the non-volatile storage medium includes a stored computer program, wherein the device where the non-volatile storage medium is located executes a robustness verification method of a model by running the computer program.

[0016] According to another aspect of the embodiments of the present application, a computer program product is provided, including a computer program, which implements the steps of the model robustness verification method when the computer program is executed by a processor.

[0017] In an embodiment of the present application, a method is adopted in which the loss value corresponding to each training batch during the fine-tuning training of a large model is obtained, and based on the loss value, a model to be verified is determined from the fine-tuning models obtained from each training batch; a training data set used in the fine-tuning training process is obtained, and a verification data set is generated based on the keywords contained in the question text in the training data set, wherein the training data set or the verification data set contains multiple sample data, and the sample data includes: a question text, and an answer result corresponding to the question text, and the sample data contained in the training data set is different from that contained in the verification data set; the answer result generated by the model to be verified based on the question text in the verification data set is obtained; the similarity between the answer result generated by the model to be verified and the answer result corresponding to the question text in the verification data set is determined, and based on the similarity, a robustness score of the model to be verified is determined. By enhancing the generation of the verification set and the method of calculating the similarity, the purpose of systematically and accurately verifying the robustness of multiple LoRA fine-tuning models is achieved, thereby solving the technical problem that the large model fine-tuning verification scheme in the related art cannot fully evaluate the robustness of the fine-tuning model. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0019] Figure 1 It is a hardware structure block diagram of a computer terminal (or electronic device) for implementing a method for robustness verification of a model provided in an embodiment of the present application;

[0020] Figure 2 It is a schematic diagram of a method flow for robustness verification of a model provided in an embodiment of the present application;

[0021] Figure 3 It is a schematic diagram of a method flow for verifying the robustness of LoRA fine-tuning training results based on a large model provided in an embodiment of the present application;

[0022] Figure 4 It is a schematic diagram of a method flow for robustness verification of another model provided in an embodiment of the present application;

[0023] Figure 5 It is a structural schematic diagram of a model robustness verification device provided according to an embodiment of the present application. DETAILED DESCRIPTION

[0024] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.

[0025] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0026] In order to facilitate those skilled in the art to better understand the embodiments of the present application, some technical terms or nouns involved in the embodiments of the present application are explained as follows:

[0027] LoRA fine-tuning: It is a technology used for fine-tuning large models, which achieves an efficient and low-resource fine-tuning process by reducing the adjustable part of the model parameters.

[0028] Data analysis model: A large-scale language model with powerful analysis and reasoning capabilities, used to process and analyze complex data. It can identify and extract key information from the data and provide intelligent analysis results.

[0029] Robustness: refers to the ability of a model to maintain its functionality or performance in the face of uncertainty, noise, or abnormal situations. In this application, robustness mainly refers to the ability of a fine-tuned LoRA model to maintain high performance and stability under different verification conditions.

[0030] TF-IDF (Term Frequency-Inverse Document Frequency) algorithm: is a statistical method used to evaluate the importance of words in a set of documents.

[0031] Weighted cosine similarity: When calculating the similarity of text vectors, different weights are assigned to specific keywords to reflect their semantic importance, thereby improving the accuracy of similarity calculation.

[0032] The verification methods in related technologies often fail to fully reflect the advantages and disadvantages of the fine-tuned models, and lack a mechanism for comprehensive analysis of multi-batch models, making it impossible to fully evaluate the robustness of the fine-tuned models.

[0033] In order to solve the above problems, relevant solutions are provided in the embodiments of the present application, which are described in detail below.

[0034] According to an embodiment of the present application, a method embodiment of robustness verification of a model is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0035] The method embodiments provided in the embodiments of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Figure 1 FIG. 1 shows a hardware structure block diagram of a computer terminal (or electronic device) for implementing a robustness verification method of a model. Figure 1 As shown, the computer terminal 10 (or electronic device) may include one or more (102a, 102b, ..., 102n are used to illustrate) processors 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 104 for storing data, and a transmission device 106 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the BUS bus), a network interface, a power supply and / or a camera. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations shown.

[0036] It should be noted that the one or more processors 102 and / or other data processing circuits described above may generally be referred to herein as "data processing circuits". The data processing circuits may be embodied in whole or in part as software, hardware, firmware, or any other combination thereof. In addition, the data processing circuit may be a single independent processing module, or may be incorporated in whole or in part into any of the other components in the computer terminal 10 (or electronic device). As involved in the embodiments of the present application, the data processing circuit acts as a processor control (e.g., selection of a variable resistor terminal path connected to an interface).

[0037] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the robustness verification method of the model in the embodiment of the present application. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, that is, the robustness verification method of the above model is realized. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the computer terminal 10 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.

[0038] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the computer terminal 10. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0039] The display may be, for example, a touch screen liquid crystal display (LCD) that enables a user to interact with a user interface of the computer terminal 10 (or electronic device).

[0040] In the above operating environment, the embodiment of the present application provides a method for verifying the robustness of a model. Figure 2 is a schematic diagram of a method flow for robustness verification of a model provided in an embodiment of the present application, such as Figure 2 As shown, the method comprises the following steps:

[0041] Step S202, obtaining the loss value corresponding to each training batch during the fine-tuning training of the large model, and determining the model to be verified from the fine-tuning models obtained from each training batch based on the loss value;

[0042] Step S204, obtaining a training data set used in the fine-tuning training process, and generating a verification data set based on the keywords contained in the question text in the training data set, wherein the training data set or the verification data set both contain a plurality of sample data, and the sample data include: the question text, and the answer result corresponding to the question text, and the sample data contained in the training data set is different from that contained in the verification data set;

[0043] Step S206, obtaining the answer result generated by the model to be verified based on the question text in the verification data set;

[0044] Step S208, determining the similarity between the answer result generated by the model to be verified and the answer result corresponding to the question text in the verification data set, and determining the robustness score of the model to be verified based on the similarity.

[0045] Through the above steps, by enhancing the generation of verification sets and similarity calculation methods, the purpose of systematic and accurate robustness verification of multiple LoRA fine-tuning models is achieved, thereby solving the technical problem that the large model fine-tuning verification scheme in the related technology cannot fully evaluate the robustness of the fine-tuning model, thereby further improving the robustness and stability of the LoRA fine-tuning model in practical applications.

[0046] The following further introduces the robustness verification method of the model in steps S202 to S208 of the embodiment of the present application.

[0047] Figure 3 It is a schematic diagram of a method flow for verifying the robustness of LoRA fine-tuning training results based on a large model provided in an embodiment of the present application, such as Figure 3 shown.

[0048] First, obtain the loss value corresponding to each training batch during the fine-tuning training of the large model, and select multiple fine-tuning models as the models to be verified based on the loss value. The specific steps are as follows.

[0049] In some embodiments of the present application, determining a model to be verified from the fine-tuned models obtained from each training batch based on the loss value includes: determining a loss curve based on the loss values ​​corresponding to each training batch, wherein the loss curve is used to characterize the changing trend of the loss value during the model training process; extracting key features in the loss curve, wherein the key features include at least one of the following: the rate of decrease of the loss value, the statistical characteristics of the loss value, and the statistical characteristics include at least one of the following: maximum, mean, median, standard deviation; determining the performance parameters of the fine-tuned models corresponding to each training batch based on the key features, and determining the model to be verified based on the performance parameters, wherein the performance parameters are used to characterize the accuracy of the fine-tuned model in answering the question text.

[0050] Specifically, obtain the complete log of fine-tuning training, process the training loss value data (including but not limited to: data cleaning, format unification, etc.), organize the loss value data of different batches of LoRA fine-tuning models, and analyze them in combination with the complete training loss value data. For example, you can use a large data analysis model to analyze, draw a loss curve, and observe the training trend of the model. At the same time, combine the complete training loss value data, use statistical methods (such as mean, median, standard deviation, etc.) to evaluate the model performance, and then select multiple LoRA fine-tuning models with the best performance as models to be verified.

[0051] Alternatively, you can choose to determine the fine-tuning model corresponding to a preset number of training batches with the smallest loss value as the model to be verified.

[0052] The embodiment of the present application sorts and processes the loss value data of different batches of LoRA fine-tuning models, uses the data analysis model for comprehensive analysis, and selects the fine-tuning model with the best performance. This method ensures that the selected model performs stably over multiple training cycles and avoids the results being affected by accidental factors in a single training cycle.

[0053] Afterwards, the fine-tuned LoRA model (model to be verified) selected by the large model is loaded to facilitate the next step. At the same time, the training data set used in the fine-tuning training process is read, and the verification set is generated based on the training data set, wherein the training data set or the verification data set contains multiple sample data, and the sample data includes: question text, and the answer result corresponding to the question text, and the sample data contained in the training data set is different from that contained in the verification data set. The specific steps are as follows.

[0054] In some embodiments of the present application, generating a verification data set based on the keywords contained in the question text in the training data set includes the following steps: dividing the question text in the training data set into multiple word segments, and determining the keywords in the word segments; determining the synonyms and / or near-synonyms corresponding to the keywords, and replacing the keywords in the question text with the synonyms and / or near-synonyms; adding the new question text obtained after the replacement, and the answer result corresponding to the question text, as sample data to the verification data set; using a natural language generation model, generating a new question text corresponding to the answer result based on the answer result in the training data set, and adding the newly generated question text and the corresponding answer result as sample data to the verification data set.

[0055] Specifically, after reading the training data set, a semantic analysis model can be used to extract keywords from the question text in the training set, providing a basis for the subsequent generation of the verification set. Then, based on the extracted keywords, a synonym dictionary or a large language model is used to replace some of the keywords with synonyms or near-synonyms, while ensuring that the replaced text is still semantically reasonable. The new question text obtained after the replacement and the answer results corresponding to the question text are added as sample data to the verification data set to achieve the effect of enhancing the verification set.

[0056] Among them, when determining the synonyms or near-synonyms of keywords, it is necessary to consider the applicability of the synonyms or near-synonyms in the context of the original text to ensure that the semantics after replacement are still reasonable; and it is also possible to evaluate whether the semantic strength and emotional color of the synonyms or near-synonyms match the original words to avoid changing the original meaning of the sentence.

[0057] At the same time, answer text (answer results) can also be extracted from the training dataset, and a natural language generation model can be used to generate new question text based on the answer text, evaluate the quality and relevance of the generated question text, ensure that they are valuable supplements to the validation set, and add the generated question text to the validation dataset, thereby further enriching and enhancing the diversity of the validation set.

[0058] In addition, as an optional implementation, the method also includes the following steps: determining the semantic topic similarity and sentence structure similarity between each question text in the training data set, wherein the semantic topic similarity is used to characterize the degree of semantic similarity between the question texts, and the sentence structure similarity is used to characterize the degree of grammatical structure similarity between the question texts; obtaining at least two question texts, wherein the semantic topic similarity between the obtained question texts exceeds a preset topic similarity threshold, and the sentence structure similarity exceeds a preset structure similarity threshold; fusing at least two question texts to obtain a new question text, and fusing the answer results corresponding to at least two question texts in the training data set to obtain a new answer result; and adding the newly obtained question text and answer result as sample data to the verification data set.

[0059] For example, the structured parts of two or more selected questions or answers (such as topics, keywords, etc.) can be combined according to predefined mixing rules to merge into a new question or answer. This can be achieved by simple splicing, selective merging, or using more complex text generation techniques.

[0060] The embodiments of the present application enhance the diversity and coverage of the validation set by generating a new validation set, so that the generalization ability and robustness of the model can be more comprehensively evaluated.

[0061] After obtaining the verification data set, you can use the enhanced verification data set to make requests to multiple loaded LoRA fine-tuning models (models to be verified) and collect the answer texts output by these models, that is, the answer results generated by the model to be verified based on the question text in the verification data set.

[0062] Then, the robustness score of the model to be verified can be determined by calculating the similarity between the answer result generated by the model to be verified and the answer result corresponding to the question text in the verification data set, wherein the steps of calculating the similarity are as follows.

[0063] In some embodiments of the present application, determining the similarity between the answer result generated by the model to be verified and the answer result corresponding to the question text in the verification data set includes the following steps: dividing the answer result into multiple participles, and determining the weight coefficient corresponding to each participle, wherein the weight coefficient is used to characterize the contribution of the participle to the semantics; based on the weight coefficient, converting the answer result generated by the model to be verified into a first vector, and converting the answer result in the verification data set into a second vector; and determining the cosine similarity between the first vector and the second vector.

[0064] In some embodiments of the present application, determining the weight coefficient corresponding to each participle includes the following steps: counting the number of times each participle appears in the answer result to obtain the word frequency corresponding to the participle; determining the inverse document frequency corresponding to each participle, wherein the inverse document frequency is used to characterize the prevalence of the participle in the answer result; determining the weight coefficient corresponding to the participle based on the word frequency and the inverse document frequency.

[0065] Specifically, you can write a similarity algorithm API, use the TF-IDF algorithm to vectorize the answer text (answer result) in the verification set, pass in the extracted keywords, and weight the keywords in combination with TF-IDF to increase the weight of words that contribute a lot to semantics, thereby improving the accuracy and pertinence of similarity calculations. Through the role of IDF, the weight of words that contribute less semantically can be reduced, thereby reducing the impact on similarity calculations. Then, weighted cosine similarity calculations are performed on the keyword-weighted vectors.

[0066] In this embodiment, similarity calculation can be performed by building a LangChain Agent. First, an Agent tool is customized to call the similarity algorithm API to automatically process the similarity calculation between the answer results in the validation set and the answer results generated by the fine-tuning model. The Agent will call the tool cyclically, compare the answer results in the validation set with the answers generated by the model one by one, and obtain the similarity score.

[0067] The embodiment of the present application uses the similarity algorithm API and TF-IDF to vectorize the answer text in the verification set and the answer text generated by the model to be verified, and weights them according to the extracted keywords. The weighted cosine similarity calculation is used to convert it into a percentage score to improve the accuracy and pertinence of the similarity calculation. This process ensures that higher weights are given to words with great semantic contribution, and reduces the impact of words with less semantic contribution, thereby improving the accuracy of the analysis.

[0068] After obtaining the similarity, the robustness score of the model to be verified can be determined based on the similarity. The specific steps are as follows.

[0069] In some embodiments of the present application, determining the robustness score of the model to be verified based on the similarity includes the following steps: standardizing the similarity based on the maximum similarity and the minimum similarity; converting the standardized similarity into a percentage score to obtain a robustness score, and sorting each model to be verified in order from high to low according to the robustness score, and sending the sorted models to be verified and the corresponding robustness scores to the front-end interactive interface for display.

[0070] Specifically, the Agent can call up the data analysis model to further analyze these similarity scores, evaluate the robustness of each LoRA fine-tuning model on the validation set, and generate a score based on a percentage. Finally, LangChainAgent will rank the evaluation results of each LoRA fine-tuning model according to the score, display the results of the LoRA fine-tuning model robustness verification, and output a detailed analysis report.

[0071] The embodiment of the present application realizes the call of the similarity algorithm API by combining LangChain Agent, and automatically processes the similarity calculation. Through the analysis of the calculation results by the large model, the percentage scores of multiple batches of LoRA fine-tuning models are generated and ranked. This integrated method improves the analysis efficiency, reduces manual intervention, and provides comprehensive data support for the robustness verification of the fine-tuning model.

[0072] This application solution uses a large data analysis model to analyze the training loss values ​​of multiple batches of LoRA fine-tuning models, and can accurately identify the best performing model, thereby providing a reliable basis for performance evaluation. This can select the optimal fine-tuning model; the enhanced validation set generated by the large model covers more semantic variants and improves the quality of the validation set. This diverse validation set can better test the performance of the model in different scenarios, enhance the robustness and adaptability of the model; by combining the optimized TF-IDF similarity algorithm with the weighted cosine similarity calculation method, the accuracy of the similarity analysis is improved. Accurate similarity calculation can better evaluate the matching degree between the output of the model and the reference answer, thereby providing more reliable model evaluation results; combined with the automated processing capabilities of LangChain Agent, the automation and systematization of model evaluation are realized. Through the intelligent analysis of the large data analysis model, model scores and rankings can be efficiently generated, reducing manual intervention and improving the efficiency and accuracy of the analysis.

[0073] According to an embodiment of the present application, an embodiment of another model robustness verification method is also provided. Figure 4 FIG. 1 is a schematic diagram of another method flow for robustness verification of a model provided in an embodiment of the present application. Figure 4 As shown, the method includes:

[0074] Step S402, obtaining loss values ​​corresponding to multiple training batches during the fine-tuning training of the large model, and determining a model to be verified from the fine-tuning models obtained from the multiple training batches based on the loss values;

[0075] Step S404, obtaining a training data set used in the fine-tuning training process, and determining a verification data set corresponding to the training data set, wherein the verification data set is used to verify the fine-tuning model obtained by training the training data set, and the verification data set at least includes sample data determined according to keywords in the question text in the training data set, and the sample data in the verification data set and the training data set both include: question text, and sample answer results corresponding to the question text, and the sample data contained in the training data set is different from that contained in the verification data set;

[0076] Step S406, obtaining the target answer result generated by the model to be verified based on the question text in the verification data set;

[0077] Step S408, determining the similarity between the target answer result and the sample answer result corresponding to the question text in the verification data set, and determining the robustness score of the model to be verified based on the similarity.

[0078] It should be noted that the robustness verification method of the model provided in this embodiment is the same as Figure 2The robustness verification method of the model shown corresponds to another method embodiment. Therefore, the relevant explanations and instructions on the robustness verification method of the above-mentioned model are also applicable to the embodiments of the present application and will not be repeated here.

[0079] According to an embodiment of the present application, an embodiment of a device for verifying the robustness of a model is also provided. Figure 5 is a schematic diagram of the structure of a model robustness verification device provided according to an embodiment of the present application. Figure 5 As shown, the device comprises:

[0080] The model selection module 50 is used to obtain the loss value corresponding to each training batch during the fine-tuning training of the large model, and determine the model to be verified from the fine-tuning models obtained from each training batch based on the loss value;

[0081] The verification set construction module 52 is used to obtain the training data set used in the fine-tuning training process, and generate a verification data set based on the keywords contained in the question text in the training data set, wherein the training data set or the verification data set both contain a plurality of sample data, and the sample data include: the question text and the answer result corresponding to the question text, and the sample data contained in the training data set is different from that contained in the verification data set;

[0082] A model testing module 54 is used to obtain the answer result generated by the model to be verified based on the question text in the verification data set;

[0083] The result verification module 56 is used to determine the similarity between the answer result generated by the model to be verified and the answer result corresponding to the question text in the verification data set, and determine the robustness score of the model to be verified based on the similarity.

[0084] Optionally, determining the model to be verified from the fine-tuned models obtained from each training batch based on the loss value includes: determining a loss curve based on the loss values ​​corresponding to each training batch, wherein the loss curve is used to characterize the changing trend of the loss value during the model training process; extracting key features in the loss curve, wherein the key features include at least one of the following: the rate of decrease of the loss value, the statistical characteristics of the loss value, and the statistical characteristics include at least one of the following: maximum, mean, median, standard deviation; determining the performance parameters of the fine-tuned model corresponding to each training batch based on the key features, and determining the model to be verified based on the performance parameters, wherein the performance parameters are used to characterize the accuracy of the fine-tuned model in answering the question text.

[0085] Optionally, generating a verification data set based on keywords contained in the question text in the training data set includes: dividing the question text in the training data set into multiple word segments, and determining keywords in the word segments; determining synonyms and / or near-synonyms corresponding to the keywords, and replacing the keywords in the question text with the synonyms and / or near-synonyms; adding the new question text obtained after the replacement, and the answer results corresponding to the question text, as sample data to the verification data set; using a natural language generation model, based on the answer results in the training data set, generating a new question text corresponding to the answer results, and adding the newly generated question text and the corresponding answer results as sample data to the verification data set.

[0086] Optionally, the verification set construction module 52 is also used to: determine the semantic topic similarity and sentence structure similarity between each question text in the training data set, wherein the semantic topic similarity is used to characterize the degree of semantic similarity between the question texts, and the sentence structure similarity is used to characterize the degree of grammatical structure similarity between the question texts; obtain at least two question texts, wherein the semantic topic similarity between the obtained question texts exceeds a preset topic similarity threshold, and the sentence structure similarity exceeds a preset structure similarity threshold; fuse the at least two question texts to obtain a new question text, and fuse the answer results corresponding to the at least two question texts in the training data set to obtain a new answer result; and add the newly obtained question text and answer result as sample data to the verification data set.

[0087] Optionally, determining the similarity between the answer result generated by the model to be verified and the answer result corresponding to the question text in the verification data set includes: dividing the answer result into multiple participles, and determining the weight coefficient corresponding to each participle, wherein the weight coefficient is used to characterize the contribution of the participle to the semantics; based on the weight coefficient, converting the answer result generated by the model to be verified into a first vector, and converting the answer result in the verification data set into a second vector; and determining the cosine similarity between the first vector and the second vector.

[0088] Optionally, determining the weight coefficient corresponding to each participle includes: counting the number of times each participle appears in the answer result to obtain the word frequency corresponding to the participle; determining the inverse document frequency corresponding to each participle, wherein the inverse document frequency is used to characterize the prevalence of the participle in the answer result; and determining the weight coefficient corresponding to the participle based on the word frequency and the inverse document frequency.

[0089] Optionally, based on the similarity, determining the robustness score of the model to be verified includes: standardizing the similarity based on the maximum similarity and the minimum similarity; converting the standardized similarity into a percentage score to obtain a robustness score, and sorting each model to be verified in order from high to low according to the robustness score, and sending the sorted models to be verified and the corresponding robustness scores to the front-end interactive interface for display.

[0090] It should be noted that the various modules in the robustness verification device of the above-mentioned model can be program modules (for example, a set of program instructions that implement a certain specific function) or hardware modules. For the latter, it can be expressed in the following forms, but is not limited to this: the expression form of each of the above-mentioned modules is a processor, or the functions of each of the above-mentioned modules are implemented by a processor.

[0091] It should be noted that the robustness verification device of the model provided in this embodiment can be used to perform Figure 2 The robustness verification method of the model shown, therefore, the relevant explanations and instructions on the robustness verification method of the above model are also applicable to the embodiments of the present application and will not be repeated here.

[0092] An embodiment of the present application also provides a non-volatile storage medium, the non-volatile storage medium includes a stored computer program, wherein the device where the non-volatile storage medium is located executes the following model robustness verification method by running the computer program: obtaining the loss value corresponding to each training batch during the fine-tuning training of the large model, and determining the model to be verified from the fine-tuning models obtained from each training batch based on the loss value; obtaining the training data set used in the fine-tuning training process, and generating a verification data set based on the keywords contained in the question text in the training data set, wherein the training data set or the verification data set contains multiple sample data, the sample data includes: question text, and answer results corresponding to the question text, and the sample data contained in the training data set is different from that contained in the verification data set; obtaining the answer result generated by the model to be verified based on the question text in the verification data set; determining the similarity between the answer result generated by the model to be verified and the answer result corresponding to the question text in the verification data set, and determining the robustness score of the model to be verified based on the similarity.

[0093] The present application also provides a computer program product, including a computer program, which, when executed by a processor, implements the steps of the robustness verification method of the model described in each embodiment of the present application: obtaining the loss value corresponding to each training batch during the fine-tuning training of the large model, and determining the model to be verified from the fine-tuning models obtained from each training batch based on the loss value; obtaining the training data set used in the fine-tuning training process, and generating a verification data set based on the keywords contained in the question text in the training data set, wherein the training data set or the verification data set contains multiple sample data, and the sample data includes: question text, and answer results corresponding to the question text, and the sample data contained in the training data set is different from that contained in the verification data set; obtaining the answer result generated by the model to be verified based on the question text in the verification data set; determining the similarity between the answer result generated by the model to be verified and the answer result corresponding to the question text in the verification data set, and determining the robustness score of the model to be verified based on the similarity.

[0094] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.

[0095] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.

[0096] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.

[0097] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0098] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0099] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk and other media that can store program codes.

[0100] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.

Claims

1. A method for verifying the robustness of a model, characterized in that: include: Obtain the loss value corresponding to each training batch during the fine-tuning training of the large model, and determine the model to be verified from the fine-tuning models obtained from each of the training batches based on the loss value; Acquire a training data set used in the fine-tuning training process, and generate a verification data set based on the keywords contained in the question text in the training data set, wherein the training data set or the verification data set both contain a plurality of sample data, and the sample data include: the question text and the answer result corresponding to the question text, and the sample data contained in the training data set is different from that contained in the verification data set; Obtaining an answer result generated by the model to be verified based on the question text in the verification data set; Determine the similarity between the answer result generated by the model to be verified and the answer result corresponding to the question text in the verification data set, and determine the robustness score of the model to be verified based on the similarity.

2. The robustness verification method of the model according to claim 1, characterized in that: Determining the model to be verified from the fine-tuned models obtained from each of the training batches according to the loss value includes: Determine a loss curve according to the loss values ​​corresponding to each of the training batches, wherein the loss curve is used to characterize the change trend of the loss value during the model training process; Extracting key features from the loss curve, wherein the key features include at least one of the following: a decreasing speed of the loss value, a statistical feature of the loss value, and the statistical feature includes at least one of the following: a maximum, a mean, a median, and a standard deviation; Based on the key features, performance parameters of the fine-tuning model corresponding to each of the training batches are determined, and based on the performance parameters, the model to be verified is determined, wherein the performance parameters are used to characterize the accuracy of the fine-tuning model in answering the question text.

3. The robustness verification method of the model according to claim 1, characterized in that: Generating a verification data set based on the keywords contained in the question text in the training data set includes: Segmenting the question text in the training data set into a plurality of segmented words, and determining the keywords in the segmented words; Determine synonyms and / or near-synonyms corresponding to the keywords, and replace the keywords in the question text with the synonyms and / or near-synonyms; Adding the new question text obtained after replacement and the answer result corresponding to the question text as the sample data to the verification data set; A natural language generation model is used to generate new question text corresponding to the answer result based on the answer result in the training data set, and the newly generated question text and the corresponding answer result are added to the verification data set as the sample data.

4. The robustness verification method of the model according to claim 3, characterized in that: The method further comprises: Determine the semantic topic similarity and sentence structure similarity between each of the question texts in the training data set, wherein the semantic topic similarity is used to characterize the degree of similarity of the semantics between the question texts, and the sentence structure similarity is used to characterize the degree of similarity of the grammatical structures between the question texts; Acquire at least two of the question texts, wherein the semantic topic similarity between the acquired question texts exceeds a preset topic similarity threshold, and the sentence structure similarity exceeds a preset structure similarity threshold; Merging the at least two question texts to obtain a new question text, and merging the answer results corresponding to the at least two question texts in the training data set to obtain a new answer result; The newly obtained question text and the answer result are added to the verification data set as the sample data.

5. The robustness verification method of the model according to claim 1, characterized in that: Determining the similarity between the answer result generated by the to-be-verified model and the answer result corresponding to the question text in the verification data set includes: Dividing the answer result into a plurality of participles, and determining a weight coefficient corresponding to each of the participles, wherein the weight coefficient is used to characterize the contribution of the participle to the semantics; According to the weight coefficient, converting the answer result generated by the model to be verified into a first vector, and converting the answer result in the verification data set into a second vector; A cosine similarity between the first vector and the second vector is determined.

6. The robustness verification method of the model according to claim 5, characterized in that: Determining the weight coefficient corresponding to each of the participles includes: Counting the number of times each of the participles appears in the answer result to obtain the word frequency corresponding to the participle; Determine an inverse document frequency corresponding to each of the segmented words, wherein the inverse document frequency is used to characterize the prevalence of the segmented words in the answer results; The weight coefficient corresponding to the word segmentation is determined according to the word frequency and the inverse document frequency.

7. The robustness verification method of the model according to claim 1, characterized in that: Determining the robustness score of the model to be verified based on the similarity includes: normalizing the similarity according to the maximum similarity and the minimum similarity; The standardized similarity is converted into a percentage score to obtain the robustness score, and the models to be verified are sorted in order from high to low according to the robustness score, and the sorted models to be verified and the corresponding robustness scores are sent to the front-end interactive interface for display.

8. A method for verifying the robustness of a model, characterized in that: include: Obtain loss values ​​corresponding to multiple training batches during fine-tuning training of the large model, and determine a model to be verified from the fine-tuning models obtained from the multiple training batches based on the loss values; Acquire a training data set used in the fine-tuning training process, and determine a verification data set corresponding to the training data set, wherein the verification data set is used to verify the fine-tuning model obtained by training the training data set, and the verification data set at least includes sample data determined according to keywords in the question text in the training data set, and the sample data in the verification data set and the training data set both include: question text, and sample answer results corresponding to the question text, and the sample data contained in the training data set is different from that contained in the verification data set; Obtaining a target answer result generated by the model to be verified based on the question text in the verification data set; Determine the similarity between the target answer result and the sample answer result corresponding to the question text in the verification data set, and determine the robustness score of the model to be verified based on the similarity.

9. A model robustness verification device, characterized in that: include: A model selection module is used to obtain the loss value corresponding to each training batch during the fine-tuning training of the large model, and determine the model to be verified from the fine-tuning models obtained from each training batch based on the loss value; A verification set construction module, used to obtain the training data set used in the fine-tuning training process, and generate a verification data set based on the keywords contained in the question text in the training data set, wherein the training data set or the verification data set both contain a plurality of sample data, and the sample data include: the question text and the answer result corresponding to the question text, and the sample data contained in the training data set is different from that contained in the verification data set; A model testing module, used to obtain the answer result generated by the model to be verified based on the question text in the verification data set; The result verification module is used to determine the similarity between the answer result generated by the model to be verified and the answer result corresponding to the question text in the verification data set, and determine the robustness score of the model to be verified based on the similarity.

10. An electronic device, characterized in that: include: A memory and a processor, wherein the processor is used to run a program stored in the memory, wherein the program, when running, executes the robustness verification method of the model described in any one of claims 1 to 8.

11. A non-volatile storage medium, characterized in that: The non-volatile storage medium includes a stored computer program, wherein the device where the non-volatile storage medium is located executes the robustness verification method of the model described in any one of claims 1 to 8 by running the computer program.

12. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the robustness verification method of the model described in any one of claims 1 to 8 are implemented.