A sample injection method, apparatus, device, and storage medium for a model.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-12
- Publication Date
- 2026-03-10
AI Technical Summary
Traditional sample injection methods lack effective control over sample quality, relevance to business scenarios, and the impact on model parameters, resulting in noise and low-correlation samples interfering with model learning, reducing prediction accuracy and model performance stability.
By combining sample features with business scenario context features to calculate injection weights, generating parameter masks, introducing risk scores and outputting consistency scores, the sample injection process is dynamically controlled, and the model training process is optimized.
This improves the model's learning efficiency of key information, enhances prediction accuracy, strengthens its adaptability to complex data, and ensures the model's robustness and stability during the iteration process.
Smart Images

Figure CN121009369B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a sample injection method, apparatus, device and storage medium for a model. Background Technology
[0002] With the rapid development of artificial intelligence technology, machine learning models have demonstrated strong application potential in many fields such as image recognition, speech processing, and natural language understanding. The predictive accuracy of these models has become one of the core metrics for measuring their performance. The method and quality of injecting sample data, which serves as the training data for the model, directly affect the model's learning effect and final performance.
[0003] In traditional model training, sample injection often takes a simple and direct approach. For example, after all collected samples are randomly divided into training, validation, and test sets in a fixed proportion, the training set samples are injected into the model all at once or in fixed batches for training. During this process, there is rarely any targeted adjustment to the injection order, quantity, or quality of the samples.
[0004] However, traditional sample injection schemes have significant drawbacks. During the injection process, due to a lack of effective control, samples containing a large amount of noise or those with low relevance to the target task may be injected into the model indiscriminately. This interferes with the model's learning and extraction of effective features, making it difficult for the model to accurately grasp data patterns during training, ultimately leading to a significant decrease in the model's prediction accuracy. Summary of the Invention
[0005] This application provides a sample injection method, apparatus, device, and storage medium for a model, which can accurately grasp data patterns and improve the prediction accuracy of the model.
[0006] To achieve the above objectives, this application adopts the following technical solution:
[0007] Firstly, this application provides a sample injection method for a model, including:
[0008] Obtain the business scenario corresponding to the model and the sample data to be injected, wherein the sample data includes text data, structured data and image data;
[0009] Feature extraction is performed on the sample data to obtain sample features, the business scenario is encoded to obtain business scenario context features, and the injection weight of the sample data is calculated based on the sample features and the business scenario context features.
[0010] The sample data is input into the model to obtain the output of the model; the sample loss of the sample data is determined based on the output and the true label corresponding to the sample data; and the parameter mask is calculated based on the sample loss.
[0011] The injection process of the sample data is controlled according to the injection weight and the parameter mask.
[0012] Optionally, the method further includes:
[0013] Extract the key components from the sample data;
[0014] The risk score of the sample data is determined based on the average predicted probability of the key component in multiple irrelevant scenarios.
[0015] Based on the risk score, the injection weight and the parameter mask are adjusted.
[0016] Optionally, adjusting the injection weights and the parameter mask based on the risk score includes:
[0017] If the risk score is less than the risk threshold, the injection weight and the parameter mask are adjusted.
[0018] Optionally, the injection weights are adjusted in the following ways:
[0019]
[0020] in, This indicates the adjusted injection weight. Indicates the risk adjustment factor. This indicates the injection weight before adjustment;
[0021] The parameter mask is adjusted in the following way:
[0022]
[0023] in, This represents the adjusted parameter mask. This represents the parameter mask before adjustment. This represents the set of parameters after pruning.
[0024] Optionally, the method further includes:
[0025] Obtain the first output result of multiple sample data to be injected before being injected into the model and the second output result after being injected into the model; obtain the first probability of the multiple sample data to be injected for the target output result before being injected into the model and the second probability of the target output result after being injected into the model;
[0026] An output consistency score is obtained based on multiple corresponding first and second output results; an ability drift score is obtained based on multiple corresponding first and second probabilities.
[0027] The model version is selected based on the output consistency score and the capability drift score.
[0028] Optionally, selecting the model version based on the output consistency score and the capability drift score includes:
[0029] If the output consistency score is less than the first scoring threshold, or the capability drift score is greater than or equal to the second scoring threshold, the model is restored to the previous version.
[0030] Optionally, calculating the injection weight of the sample data based on the sample features and the business scenario context features includes:
[0031]
[0032] in, This indicates the injection weight before adjustment. Indicates sample features, Represents the contextual features of the business scenario. Indicates the bias term. This represents the normalization function.
[0033] Secondly, this application provides a sample injection device for a model, comprising:
[0034] The acquisition module is used to acquire the business scenario corresponding to the model and the sample data to be injected. The sample data includes text data, structured data and image data.
[0035] The data processing module is used to extract features from the sample data to obtain sample features, encode the business scenario to obtain business scenario context features, calculate the injection weight of the sample data based on the sample features and the business scenario context features, input the sample data into the model to obtain the output result of the model, determine the sample loss of the sample data based on the output result and the real label corresponding to the sample data, and calculate the parameter mask based on the sample loss.
[0036] The control module is used to control the injection process of the sample data according to the injection weight and the parameter mask.
[0037] Thirdly, this application provides a computing device, including a memory and a processor;
[0038] The memory stores one or more computer programs, the one or more computer programs including instructions; when the instructions are executed by the processor, the computing device performs the method as described in any one of the first aspects.
[0039] Fourthly, this application provides a computer-readable storage medium for storing a computer program for performing the method as described in any one of the first aspects.
[0040] As can be seen from the above technical solution, this application has at least the following beneficial effects:
[0041] In this application, firstly, by combining sample features with business scenario context features to calculate injection weights, samples that are more relevant to the current business scenario and have more effective features can be given higher injection priority. This avoids the interference problems of noisy samples and low-relevance samples caused by indiscriminate injection in traditional solutions, enabling the model to focus more on learning key information and improving training efficiency from the source.
[0042] Secondly, the parameter mask generated based on sample loss can dynamically control the degree of influence of samples on model parameters, reducing the interference of noisy or outlier samples on model parameter updates, helping the model to more accurately grasp data patterns, thereby significantly improving the final prediction accuracy. Simultaneously, the introduction of risk scoring allows for secondary adjustments to the injected weights and parameter mask, further optimizing the impact of low-risk samples on the model, enabling the model to more fully absorb effective information and enhancing its adaptability to complex data.
[0043] Furthermore, by dynamically selecting model versions through output consistency scores and capability drift scores, abnormal fluctuations in model performance that may occur during sample injection can be detected in a timely manner. When output consistency is too low or capability drift is too high, the model can quickly revert to the previous stable version, effectively preventing a sharp drop in model performance due to fluctuations in sample quality and ensuring the robustness of the model during the iteration process.
[0044] It should be understood that the descriptions of technical features, technical solutions, beneficial effects, or similar language in this application do not imply that all features and advantages can be achieved in any single embodiment. Rather, it is understood that the description of a feature or beneficial effect means that a specific technical feature, technical solution, or beneficial effect is included in at least one embodiment. Therefore, the descriptions of technical features, technical solutions, or beneficial effects in this specification do not necessarily refer to the same embodiment. Furthermore, the technical features, technical solutions, and beneficial effects described in this embodiment can be combined in any suitable manner. Those skilled in the art will understand that embodiments can be implemented without one or more specific technical features, technical solutions, or beneficial effects of a particular embodiment. In other embodiments, additional technical features and beneficial effects may be identified in specific embodiments that do not embody all embodiments. Attached Figure Description
[0045] Figure 1 A flowchart of a sample injection method for a model provided in this application embodiment;
[0046] Figure 2 A schematic diagram of a sample injection device for a model provided in an embodiment of this application;
[0047] Figure 3 This is a schematic diagram of a computing device provided in an embodiment of this application. Detailed Implementation
[0048] The terms "first," "second," and "third," etc., used in this application specification and accompanying drawings are used to distinguish different objects, not to limit a specific order.
[0049] In the embodiments of this application, the terms "exemplary" or "for example" are used to indicate that something is an example, illustration, or description. Any embodiment or design that is described as "exemplary" or "for example" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design. Specifically, the use of the terms "exemplary" or "for example" is intended to present the relevant concepts in a specific manner.
[0050] To ensure clarity and conciseness in the description of the following embodiments, a brief introduction to the related technologies is given first:
[0051] Sample features are a set of information extracted from sample data that characterizes the features of the data. By analyzing them, we can gain insight into the inherent patterns of the data.
[0052] Business scenario context features are feature representations of the business scenario in which the model is applied, reflecting key information related to the scenario, such as business objectives and user behavior characteristics.
[0053] The current technical challenge in machine learning lies in the simplistic and crude nature of traditional sample injection methods. During the injection process, there is a lack of effective control over sample quality, relevance to the business scenario, and impact on model parameters. A large number of noisy samples with low relevance to the target task are indiscriminately injected, making it difficult for the model to accurately extract effective features from the complex data during training, thus interfering with the learning of data patterns. This interference causes the model to fail to accurately map the input-output relationship during prediction, severely reducing prediction accuracy and failing to meet the high-precision requirements of practical applications such as medical diagnosis and financial risk prediction. Furthermore, due to the unreasonable sample injection during model training iterations, model performance fluctuates significantly, making stable and continuous optimization difficult, hindering the widespread application and effectiveness of models in complex and ever-changing business environments.
[0054] In view of this, embodiments of this application provide a sample injection method for a model, which can be executed by a processing device. The processing device can be a terminal or a server. Terminals include, but are not limited to, smartphones, tablets, laptops, personal digital assistants, or smart wearable devices. The server can be a cloud server, such as a central server in a central cloud computing cluster or an edge server in an edge cloud computing cluster. Alternatively, the server can be a server in a local data center. A local data center refers to a data center directly controlled by the user.
[0055] To address the problems of indiscriminate sample injection in traditional sample injection schemes, which leads to interference with model learning and low prediction accuracy, this application constructs a dynamic and precise sample injection control mechanism. By deeply associating sample data with business scenarios and combining sample characteristics and model feedback information, the sample injection process is controlled in a multi-dimensional and refined manner to achieve targeted and effective sample injection and stable model training. Specifically, the sample injection weights are first determined by combining sample features with business scenario context features to highlight the role of high-value samples; then, parameter masks are generated based on sample loss to control the impact of samples on model parameters; simultaneously, risk scoring is introduced to further optimize injection weights and parameter masks; finally, consistency and capability drift scores are output to ensure the stability of the model version, forming a full-process optimization system of feature association, dynamic control, risk filtering, and version protection, thereby improving the model's learning effect and prediction performance.
[0056] To make the technical solution of this application clearer and easier to understand, the following describes a sample injection method for a model provided by an embodiment of this application, in conjunction with the accompanying drawings. Figure 1 As shown, this figure is a flowchart of a sample injection method for a model provided in an embodiment of this application. The method includes:
[0057] S201. The processing device obtains the business scenario corresponding to the model and the sample data to be injected. The sample data includes text data, structured data and image data.
[0058] When the processing device acquires the business scenario corresponding to the model, it encodes the business tags, process nodes or scenario description text associated with each knowledge and uses a pre-trained language model to transform this business scenario information into a high-dimensional embedding vector, i.e., business scenario context features, in order to clarify the specific business environment in which the model is applied.
[0059] For the sample data to be injected, the processing device acquires and preprocesses it through a multimodal knowledge input and feature extraction module. This module supports unified access to multiple data types, including text, structured data, and image data. After access, the processing device automatically completes data parsing, semantic feature extraction, and business tag recognition, such as recognizing the meaning of fields in a table, extracting pixel information from an image, analyzing the core semantics of text, and recognizing key indicators of structured data. It also performs embedding encoding on the context information of the samples, transforming multimodal samples into a unified knowledge feature representation, providing standardized input for subsequent weight allocation, risk assessment, and other processes.
[0060] S202. Extract features from the sample data to obtain sample features.
[0061] The processing device uses a multimodal knowledge input and feature extraction module to process received text data, structured data, and image data in a targeted manner. For text data, it extracts semantic information and converts it into text embedding features; for structured data (such as tables, database records, etc.), it parses the meaning of fields and associates them with data to generate structured embedding features; for image data, it analyzes pixel information, visual features, etc., to obtain image embedding features.
[0062] Subsequently, the embedding features of these three modalities are merged into a unified knowledge feature representation through the feature concatenation (Concat) operation, as shown in the expression:
[0063]
[0064] in, This represents the features of the fused samples. For feature splicing, Represents text embedding features. This refers to structured embedding features. Image embedding features.
[0065] Fusion sample features It contains the core information of the sample data, providing the basic input for subsequent steps such as weighting and risk assessment, ensuring that different types of sample data can be effectively identified and processed by the model, and achieving accurate injection of multimodal knowledge.
[0066] S203. Encode the business scenario to obtain the business scenario context features.
[0067] The processing device first collects business scenario information associated with the knowledge. This information includes, but is not limited to, the business tags corresponding to each piece of knowledge, specific nodes in the business process, and textual descriptions of the business scenario. Then, a pre-trained language model is used to encode this business scenario information, transforming it into a high-dimensional embedding vector, which is the business scenario context feature.
[0068] S204. Calculate the injection weight of the sample data based on the sample characteristics and business scenario context characteristics.
[0069] Injection weights are a quantitative metric used to measure the impact of sample data on model parameter updates during the knowledge injection process. Their value directly determines the strength of the sample's influence on model learning. The calculation expression is:
[0070]
[0071] in, This indicates the injection weight before adjustment. Indicates sample features, Represents the contextual features of the business scenario. Indicates the bias term. This represents the normalization function.
[0072] The higher the injected weight, the greater the impact of the sample on the model parameter update; conversely, the lower the weight, the smaller the impact.
[0073] S205. Input the sample data into the model and obtain the model's output. Based on the output and the true labels corresponding to the sample data, determine the sample loss of the sample data. Calculate the parameter mask based on the sample loss.
[0074] The processing device inputs the sample data (text, structured data, images, etc.) to be injected into the model, and the model generates corresponding output results after calculation. Then, the system compares the output results with the true labels corresponding to the sample data, and calculates the difference between the two using a preset loss function (such as cross-entropy). This difference value is the sample loss, which reflects the degree of prediction bias of the model for that sample.
[0075] Based on the sample loss, the parameter mask is further calculated, and the expression is:
[0076]
[0077] in, Indicates the parameter mask. For indicator functions, For sample loss, For gradient threshold, This represents the gradient. The model parameter vector is calculated using the backpropagation algorithm. Sample loss The gradient represents the sensitivity of the parameters to the current loss.
[0078] When the absolute value of the gradient is less than the gradient threshold When the parameter position is allowed to be updated, the indicator function outputs 1; otherwise, it outputs 0, indicating that the parameter position is masked and will not be updated.
[0079] The purpose of parameter masking is to filter out parameters that have a minimal impact on the loss of the current sample, allowing only these parameters to participate in the update. This limits the interference of high-gradient parameters on the model, enabling precise control over the range of sample injection, reducing the risk of knowledge contamination, and ensuring the stability of model learning. High-gradient parameters may be caused by noise or outlier samples.
[0080] This method also adjusts the injected weight parameter mask based on the risk score, further reducing its impact on the model. When the risk score is less than a risk threshold, the injected weights and parameter mask are adjusted.
[0081] First, the key components are extracted from the sample data. Then, the risk score of the sample data is determined based on the average predicted probability of the key components in multiple irrelevant scenarios. Finally, the injection weights and parameter masks are adjusted based on the risk score.
[0082] The processing equipment extracts key parts from the sample data. These key parts are usually the content that best represents the core information of the sample, such as keywords in text data, key indicators in structured data, and key feature regions in image data. They are the core objects of subsequent risk assessment.
[0083] Then, these key components are input into multiple irrelevant scenarios, and the prediction probability of the key component by the model in each irrelevant scenario is obtained. The average of these prediction probabilities is calculated and used as the risk score for the sample data. A lower average value indicates a lower probability that the key component is predicted by the model in irrelevant scenarios, meaning a higher risk that the model may produce unexpected generalizations or incorrect outputs in irrelevant scenarios after the sample is injected; conversely, a higher average value indicates a lower risk. The expression for the risk score is:
[0084]
[0085] in, This represents a risk score; the lower the risk score, the higher the risk. This indicates the key parts before knowledge injection. In the The predicted probabilities for each irrelevant scenario Indicates the number of irrelevant scenes.
[0086] When the risk score of the sample data is lower than the set risk threshold, it means that injecting the sample may lead to unexpected generalization or incorrect output in irrelevant scenarios, thus posing a risk of knowledge contamination. In this case, the system will make targeted adjustments to the injection weights and parameter masks.
[0087] For the injected weights, the adjustment expression is:
[0088]
[0089] in, This indicates the adjusted injection weight. Indicates the risk adjustment factor. The value range is 0-1. This represents the injection weights before adjustment. Using this formula, the injection weights of low-risk scores (i.e., high-risk samples) are proportionally reduced, decreasing their impact on model parameter updates.
[0090] For the parameter mask, the adjustment expression is:
[0091]
[0092] in, This represents the adjusted parameter mask. This represents the parameter mask before adjustment. This represents the set of parameters after pruning. This is a subset of parameters that has a relatively small impact on the core capabilities of the model, selected through parameter pruning techniques. It can be considered a low-risk score, i.e., a safe range of parameters for injecting high-risk samples. (Parameter mask before adjustment) It is based on sample loss gradient generation, used to initially limit the range of parameter updates, but may still contain some key parameters; while... The adjusted parameter mask after taking the intersection. Only parameters that simultaneously satisfy the conditions of having little impact on the current sample loss and belonging to low-risk safety parameters are retained, further narrowing the range of allowed updates, thereby minimizing the interference of high-risk samples on key model parameters and reducing the risk of knowledge pollution and capability drift.
[0093] S206. Control the injection process of sample data according to the injection weight and parameter mask.
[0094] During actual injection, the model first calculates the gradient based on the sample loss, then applies the injected weights to scale the gradient, while simultaneously using a parameter mask to restrict the parameter positions where the gradient applies. Only parameters with a mask value of 1 will be updated according to the weighted gradient, thus achieving dual control: the magnitude of the influence is regulated by the weights, and the scope of the influence is defined by the mask.
[0095] For high-risk samples, the injection weights are lowered and the parameter mask is adjusted based on the risk score to further reduce their impact on the model; while low-risk samples are injected normally according to the initial weights and mask. This dynamic control mechanism based on weights and masks ensures effective learning of samples highly relevant to the business scenario while avoiding knowledge contamination caused by noise or high-risk samples, thus achieving both security and accuracy in knowledge injection.
[0096] The method also includes:
[0097] Obtain the first output result of the multiple sample data to be injected before the injection model and the second output result after the injection model; obtain the first probability of the multiple sample data to be injected for the target output result before the injection model and the second probability of the target output result after the injection model.
[0098] Obtaining the output results and target output probabilities of multiple sample data to be injected into the model before and after injection is a key operation to evaluate whether knowledge injection affects the stability of the model by comparing the model's processing results of the same samples before and after knowledge injection.
[0099] The target output is the expected output based on the sample data, such as the correct answer or standard conclusion, and serves as a benchmark for evaluating the accuracy of the model's output.
[0100] Before injecting the sample data into the model, the sample data to be injected is input into the current model. At this point, the input is not for knowledge injection, but rather to allow the model to reason about the sample data, and the result is the first output result. At the same time, the probability of the model outputting the target result is recorded, i.e., the first probability. This step is to capture the original performance state of the model before receiving this batch of new knowledge.
[0101] After the sample data is injected and the model parameters are updated, the same multiple samples are input into the updated model again. The resulting inference is the second output, and the probability that the model outputs the same target result is recorded, i.e., the second probability. This step is used to reflect the performance change of the model after absorbing new knowledge.
[0102] By acquiring these two sets of data, we can provide a basis for subsequent calculations of consistency scores and capability drift scores, thereby determining whether knowledge injection leads to abnormal model output and ensuring the stability and security of the model.
[0103] Based on multiple corresponding first and second output results, an output consistency score is obtained.
[0104] The indicator function is set to 1 when the first output matches the second output; otherwise, it is set to 0. The output consistency score reflects the degree of agreement between the model's output after knowledge injection and before injection. The expression is:
[0105]
[0106] in, This indicates the output consistency score. Indicates the number of sample data. Indicates the first The first output result of each sample data before it is injected into the model Indicates the first The second output result after the sample data is injected into the model.
[0107] Ability drift scores are obtained based on multiple corresponding first and second probabilities.
[0108] Capability drift score is an important indicator for judging whether a model has anomalies. If the score exceeds a set threshold, it means that knowledge injection may cause the model's original capabilities to degenerate or shift. The larger the difference, the more obvious the model's capability drift. The expression is:
[0109]
[0110] in, Indicates ability drift score, It is the total number of sample data used for testing. Indicates the number to be injected Each sample data point outputs the target result before being injected into the model. The first probability, that is, before knowledge injection, the model's probability of the first... Each test sample outputs the answer. The probability, Indicates the number to be injected Each sample data point, after being injected into the model, outputs results targeting the desired outcome. The second probability, that is, after knowledge injection, the model outputs the answer to the same test sample. The probability of.
[0111] The model version is selected based on the output consistency score and capability drift score.
[0112] Specifically, if the output consistency score is less than the first score threshold, or the capability drift score is greater than or equal to the second score threshold, the model will be reverted to the previous version. This is an exception rollback mechanism designed to ensure model stability and reliability.
[0113] When the score is less than the first score threshold, it indicates that the model's output results after injecting new knowledge differ significantly from those before injection, and there is a risk of abnormal output. When the score is greater than or equal to the second score threshold, it indicates that the model's original capabilities may have degraded or shifted.
[0114] When any of the above situations occur, it is determined that knowledge injection has had an adverse effect on the model. To prevent this effect from persisting, a rollback mechanism will be triggered immediately to restore the model to the previous stable version, i.e., the state before knowledge injection, thereby ensuring the overall availability of the model and business security.
[0115] Based on the above description, this application has the following beneficial effects:
[0116] In this application, firstly, by combining sample features with business scenario context features to calculate injection weights, samples that are more relevant to the current business scenario and have more effective features can be given higher injection priority. This avoids the interference problems of noisy samples and low-relevance samples caused by indiscriminate injection in traditional solutions, enabling the model to focus more on learning key information and improving training efficiency from the source.
[0117] Secondly, the parameter mask generated based on sample loss can dynamically control the degree of influence of samples on model parameters, reducing the interference of noisy or outlier samples on model parameter updates, helping the model to more accurately grasp data patterns, thereby significantly improving the final prediction accuracy. Simultaneously, the introduction of risk scoring allows for secondary adjustments to the injected weights and parameter mask, further optimizing the impact of low-risk samples on the model, enabling the model to more fully absorb effective information and enhancing its adaptability to complex data.
[0118] Furthermore, by dynamically selecting model versions through output consistency scores and capability drift scores, abnormal fluctuations in model performance that may occur during sample injection can be detected in a timely manner. When output consistency is too low or capability drift is too high, the model can quickly revert to the previous stable version, effectively preventing a sharp drop in model performance due to fluctuations in sample quality and ensuring the robustness of the model during the iteration process.
[0119] The above text combined Figure 1 The sample injection method for the model provided in the embodiments of this application has been described in detail. The apparatus and device provided in the embodiments of this application will be described below with reference to the accompanying drawings.
[0120] like Figure 2 As shown in the figure, this is a schematic diagram of a sample injection device for a model provided in an embodiment of this application. The device includes:
[0121] The acquisition module 301 is used to acquire the business scenario corresponding to the model and the sample data to be injected, wherein the sample data includes text data, structured data and image data;
[0122] Data processing module 302 is used to extract features from the sample data to obtain sample features, encode the business scenario to obtain business scenario context features, calculate the injection weight of the sample data based on the sample features and the business scenario context features, input the sample data into the model to obtain the output result of the model, determine the sample loss of the sample data based on the output result and the real label corresponding to the sample data, and calculate the parameter mask based on the sample loss.
[0123] The control module 303 is used to control the injection process of the sample data according to the injection weight and the parameter mask.
[0124] Optionally, the acquisition module 301 is also used to extract key parts from the sample data;
[0125] The data processing module 302 is further configured to determine the risk score of the sample data based on the average predicted probability of the key component in multiple irrelevant scenarios.
[0126] The control module 303 is also used to adjust the injection weight and the parameter mask according to the risk score.
[0127] Optionally, the control module 303 is specifically used to adjust the injection weight and the parameter mask when the risk score is less than the risk threshold.
[0128] Optionally, the control module 303 is specifically used to adjust the injected weights in the following ways:
[0129]
[0130] in, This indicates the adjusted injection weight. Indicates the risk adjustment factor. This indicates the injection weight before adjustment;
[0131] The parameter mask is adjusted in the following way:
[0132]
[0133] in, This represents the adjusted parameter mask. This represents the parameter mask before adjustment. This represents the set of parameters after pruning.
[0134] Optionally, the acquisition module 301 is further configured to acquire a first output result of the multiple sample data to be injected before being injected into the model and a second output result after being injected into the model; and to acquire a first probability of the multiple sample data to be injected for the target output result before being injected into the model and a second probability of the multiple sample data for the target output result after being injected into the model.
[0135] The data processing module 302 is also used to obtain an output consistency score based on multiple corresponding first output results and second output results; and to obtain a capability drift score based on multiple corresponding first probabilities and second probabilities.
[0136] The control module 303 is also used to select a version of the model based on the output consistency score and the capability drift score.
[0137] Optionally, the control module 303 is specifically used to select to restore the model to the previous version when the output consistency score is less than the first score threshold or the capability drift score is greater than or equal to the second score threshold.
[0138] Optionally, the data processing module 302 is specifically used to calculate the injection weight of the sample data based on the sample features and the business scenario context features, including:
[0139]
[0140] in, This indicates the injection weight before adjustment. Indicates sample features, Represents the contextual features of the business scenario. Indicates the bias term. This represents the normalization function.
[0141] The sample injection device of the model according to the embodiments of this application can correspond to the execution of the method described in the embodiments of this application, and the other operations and / or functions of each module / unit of the sample injection device of the model are respectively for implementing Figure 1 For the sake of brevity, the corresponding processes of each method in the illustrated embodiments will not be described in detail here.
[0142] This application also provides a computing device. For example... Figure 3As shown in the figure, this is a schematic diagram of a computing device provided in an embodiment of this application. The computing device 700 includes a bus 701, a processor 702, a communication interface 703, and a memory 704. The processor 702, the memory 704, and the communication interface 703 communicate with each other via the bus 701.
[0143] The 701 bus can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of representation, Figure 3 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.
[0144] The processor 702 can be any one or more of the following processors: central processing unit (CPU), graphics processing unit (GPU), microprocessor (MP), or digital signal processor (DSP).
[0145] The communication interface 703 is used for external communication.
[0146] Memory 704 may include volatile memory, such as random access memory (RAM). Memory 704 may also include non-volatile memory, such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid state drive (SSD).
[0147] The memory 704 stores executable code, and the processor 702 executes the executable code to perform the sample injection method of the aforementioned model.
[0148] Specifically, in achieving Figure 2 In the case of the illustrated embodiment, and Figure 2 When the modules or units of the sample injection device of the model described in the embodiment are implemented by software, the execution... Figure 2The software or program code required for the functions of each module / unit can be partially or entirely stored in memory 704. Processor 702 executes the program code corresponding to each unit stored in memory 704 to execute the sample injection method of the aforementioned model.
[0149] This application also provides a computer-readable storage medium. The computer-readable storage medium can be any available medium that a computing device can store, or a data storage device such as a data center containing one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state drive). The computer-readable storage medium includes instructions that instruct the computing device to execute the sample injection method of the above-described model.
[0150] This application also provides a computer program product comprising one or more computer instructions. When the computer instructions are loaded and executed on a computing device, all or part of the processes or functions described in this application are generated.
[0151] The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions may be transmitted from one website, computer, or data center to another website, computer, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) means.
[0152] When the computer program product is executed by a computer, the computer executes any of the sample injection methods of the aforementioned model. The computer program product can be a software installation package; when any of the sample injection methods of the aforementioned model is required, the computer program product can be downloaded and executed on the computer.
[0153] The descriptions of the processes or structures corresponding to the above figures each have their own emphasis. For parts of a process or structure that are not described in detail, please refer to the relevant descriptions of other processes or structures.
[0154] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions within the technical scope disclosed in this application should be covered within the scope of protection of this application.
Claims
1. A sample injection method of a model, characterized by, The method comprises: obtaining a business scenario corresponding to the model and sample data to be injected, the sample data comprising text data, structured data and image data; extracting features of the sample data to obtain sample features, encoding the business scenario to obtain a business scenario context feature, and calculating an injection weight of the sample data according to the sample features and the business scenario context feature; inputting the sample data into the model to obtain an output result of the model, determining a sample loss of the sample data according to the output result and a true label corresponding to the sample data, and calculating a parameter mask according to the sample loss; controlling an injection process of the sample data according to the injection weight and the parameter mask; extracting a key part in the sample data; determining a risk score of the sample data according to an average value of prediction probabilities of the key part in multiple unrelated scenarios; adjusting the injection weight and the parameter mask according to the risk score; the adjusting the injection weight and the parameter mask according to the risk score comprises: in a case where the risk score is less than a risk threshold, adjusting the injection weight and the parameter mask; the injection weight is adjusted in the following manner: wherein, denotes the adjusted injection weight, denotes the risk adjustment factor, denotes the unadjusted injection weight; the parameter mask is adjusted in the following manner: wherein, denotes the adjusted parameter mask, denotes the unadjusted parameter mask, denotes the pruned parameter set.
2. The method of claim 1, wherein, the method further comprises: obtaining first output results of multiple sample data to be injected before the sample data is injected into the model and second output results of the multiple sample data after the sample data is injected into the model, and obtaining first probabilities of the multiple sample data to be injected with respect to a target output result before the sample data is injected into the model and second probabilities of the multiple sample data with respect to the target output result after the sample data is injected into the model; wherein the sample data to be injected is input into the current model before the sample data is injected into the model, at this time, the input is not for knowledge injection, but for the model to reason on the sample data, and the obtained result is the first output result; obtaining an output consistency score according to multiple corresponding first output results and second output results, and obtaining an ability drift score according to multiple corresponding first probabilities and second probabilities; selecting a version of the model according to the output consistency score and the ability drift score.
3. The method of claim 2, wherein, the selecting the version of the model according to the output consistency score and the ability drift score comprises: in a case where the output consistency score is less than a first score threshold or the ability drift score is greater than or equal to a second score threshold, selecting to restore the model to a previous version.
4. The method of claim 1, wherein, the calculating the injection weight of the sample data according to the sample features and the business scenario context feature comprises: wherein, denotes the injection weight before adjustment, denotes the sample feature, denotes the business scenario context feature, denotes the bias term, denotes the normalization function.
5. A sample injection device for a model, characterized by, the apparatus comprises: an obtaining module, configured to obtain a business scenario corresponding to the model and sample data to be injected, the sample data comprising text data, structured data and image data; The data processing module is configured to perform feature extraction on the sample data to obtain sample features, encode the business scenario to obtain a business scenario context feature, and calculate an injection weight of the sample data according to the sample features and the business scenario context feature; input the sample data into the model to obtain an output result of the model; determine a sample loss of the sample data according to the output result and a true label corresponding to the sample data, and calculate a parameter mask according to the sample loss. The control module is configured to control an injection process of the sample data according to the injection weight and the parameter mask. The control module is configured to control an injection process of the sample data according to the injection weight and the parameter mask. extract a key part in the sample data; determine a risk score of the sample data according to an average value of prediction probabilities of the key part in multiple irrelevant scenarios; and adjust the injection weight and the parameter mask when the risk score is less than a risk threshold. The control module is specifically configured to adjust the injection weight in the following manner: wherein, denotes the adjusted injection weight, denotes the risk adjustment factor, denotes the unadjusted injection weight; The parameter mask is adjusted in the following manner: wherein, denotes the adjusted parameter mask, denotes the unadjusted parameter mask, denotes the pruned parameter set.
6. A computing device, comprising: The computing device includes a memory and a processor. The memory stores one or more computer programs including instructions, and when the instructions are executed by the processor, the computing device performs the method of any one of claims 1 to 4.
7. A computer-readable storage medium, characterized in that, The computer readable storage medium is configured to store a computer program for executing the method of any one of claims 1 to 4.
Citation Information
Patent Citations
Text processing model training method and device, electronic equipment and storage medium
CN119988960A