Data set generation method and system for API anomaly detection
By combining small-scale expert datasets and large language models, and utilizing autoencoders and variational autoencoders to evaluate the quality of forged data samples, this approach addresses the diversity and authenticity issues of existing methods when generating API anomaly detection datasets, enabling the generation and automated screening of high-quality datasets.
Patent Information
- Application Number
- CN202410279277.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-12
- Publication Date
- 2026-11-24
- Estimated Expiration
- 2044-03-12
AI Technical Summary
Existing methods struggle to generate high-quality, diverse API anomaly detection datasets, especially when dealing with complex API request data. Traditional methods rely on data distribution assumptions and generate data that lacks authenticity and credibility, while large language models may contain biases and lack creativity when generating specific types of data.
By combining small-scale expert datasets and large language models, we construct expert datasets and synthetic datasets, evaluate the quality of forged data samples using autoencoder and variational autoencoder models, and generate high-quality API anomaly detection datasets through a generation-screening loop.
While ensuring data structure consistency, a large amount of diverse API anomaly detection data is generated, improving the overall quality and relevance of the dataset, and automatically evaluating sample quality to screen out high-quality data.
Smart Images

Figure CN118245796B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of API anomaly detection technology, and in particular to a dataset generation method and system for API anomaly detection. Background Technology
[0002] With the rapid development of the information society, Application Programming Interfaces (APIs) play a crucial role in internet communication as channels for data interaction between programs. APIs allow different software modules or applications to share functionality, enabling developers to build complex applications on top of existing services or libraries, while various terminals can access relevant information in a similar way. However, while the widespread use of APIs enhances application flexibility, it also exposes application logic and sensitive data (such as personal identification, location, and health information) to potential attackers. Therefore, research on API anomaly detection has become crucial. Current research primarily focuses on API traffic or API call sequences. However, many abnormal API calls may be reflected in the API request content, making them impossible to deduce through statistical and sequential monitoring of API calls. Compared to these tasks, anomaly detection of API requests is a more challenging task. This task requires analyzing the content of API requests, which will not be limited to numerical data; some abnormal API requests may appear as abnormal text, abnormal code, etc. Moreover, API request data often involves user privacy, and few organizations or institutions are willing to publicly release API request datasets, severely hindering the development of this field.
[0003] In the field of data generation, traditional methods are primarily based on statistical and machine learning techniques, such as Bayesian networks, Markov models, decision trees, and clustering algorithms. These methods generate new data instances by analyzing and learning the statistical properties of data. For example, Bayesian networks can generate data with specific conditional probability distributions through probabilistic inference; Markov models generate data sequences through state transition probabilities; decision trees generate new data points by learning the mapping relationship between features and outputs; and clustering algorithms synthesize new data instances by discovering the inherent structure in the data. Each method has its advantages; for instance, Bayesian networks excel in handling uncertainty and incorporating prior knowledge, while clustering algorithms effectively discover the inherent structure of data in unsupervised learning. In recent years, with the development of deep learning, large language models, such as generative pre-trained models based on the Transformer architecture (GPT series), have become an emerging method for data generation. These models learn rich language representations and contextual information through pre-training on large-scale datasets. In terms of data generation, large language models can generate coherent and logically consistent text data based on given contextual information. For example, GPT models can generate context-appropriate articles, stories, or dialogues based on given text prompts. The advantage of these models lies in their ability to capture nuances of language and generate highly realistic text data.
[0004] While existing methods can generate high-quality data in some scenarios, they also have some limitations. First, traditional methods often rely on assumptions about data distribution, such as Gaussian distribution or linear relationships, which often do not hold true for complex real-world data. Second, these methods have limited effectiveness when dealing with high-dimensional and unstructured data (such as text, images, and sound), because in these cases, the inherent structure of the data can be very complex and difficult to capture with simple statistical models. Furthermore, traditional methods may fail to maintain the diversity and complexity of the generated data, resulting in a lack of authenticity and credibility. Methods based on conventional large language models have achieved significant results in data generation, but they still face some challenges and limitations. The data generated by the models may contain biased and inaccurate information because the models only learn patterns from the training data, which may contain biased or erroneous information. In addition, large language models may require further fine-tuning when generating specific types of data (such as scientific papers or technical documents) to ensure the professionalism and accuracy of the generated content. The text generated by the models may sometimes lack creativity and novelty because the models tend to repeat patterns seen in the training data. For complex scenarios like API anomaly detection, existing methods often struggle to generate large amounts of high-quality data. This is because API data differs from traditional text or numerical data; it involves various data types and structures, such as HTTP request methods, URL paths, query parameters, header information, request bodies, and response bodies. Furthermore, API behavior is highly dependent on its underlying business logic or expert knowledge, making it exceptionally difficult to simply simulate or generate this type of data. Summary of the Invention
[0005] To address the shortcomings of existing data generation methods in generating data for API anomaly detection, this invention proposes a dataset generation method and system for API anomaly detection. This method focuses on generating a large number of high-quality API anomaly detection datasets by utilizing existing small-scale API request expert datasets and large language models.
[0006] To achieve the above objectives, the technical solution of the present invention includes the following contents.
[0007] A dataset generation method for API anomaly detection, the method comprising:
[0008] Construct an expert dataset containing normal and abnormal samples, and initialize a synthetic dataset;
[0009] Samples were collected from expert datasets and synthetic datasets, and then a large model was trained to learn the format features of the examples based on the generated example datasets to obtain fake data samples.
[0010] Based on the deviation between the features of fake data samples and the features of normal samples, a first quality score for fake data samples is generated.
[0011] A second quality score for the fake data samples is generated based on the differences between the fake data samples.
[0012] The fake data samples are filtered based on the first quality score and the second quality score, and the filtering results are put into the synthetic dataset. Then, the process of sampling samples in the expert dataset and the synthetic dataset is repeated until the final dataset composed of the expert dataset and the synthetic dataset meets the set requirements.
[0013] Furthermore, the construction of the expert dataset containing normal and abnormal samples includes:
[0014] In simulation workflow systems or other business systems, API call data is collected through system logs; wherein, the API call data includes: normal API call data and abnormal API call data;
[0015] After manually annotating the API call data, an expert dataset is generated.
[0016] Furthermore, after the large model learns the format features of the examples based on the generated example dataset, it obtains fake data samples, including:
[0017] The examples in the example dataset are concatenated and then the prompt words are added to obtain the complete prompt;
[0018] The large model is invoked, and a fake data sample is generated in conjunction with the complete prompt; wherein the fake data sample is similar in form to the one in question but different in content.
[0019] Furthermore, the step of generating a first quality score for the fake data sample based on the deviation between the features of the fake data sample and the features of the normal sample includes:
[0020] An autoencoder model is trained using normal samples from an expert dataset as training data.
[0021] The forged data sample is input into the autoencoder model, and the reconstruction loss is calculated;
[0022] The reconstruction loss is normalized to obtain the first quality score for each forged data sample.
[0023] Furthermore, an autoencoder model is trained using normal samples from the expert dataset as training data, including:
[0024] After converting normal samples into text form, the corresponding normal sample features are obtained based on the language model.
[0025] Based on an autoencoder network, the reconstructed features corresponding to the features of the normal sample are calculated.
[0026] Based on the normal sample features and the corresponding reconstructed features, calculate the reconstruction loss and KL loss;
[0027] The autoencoder network is adjusted based on the reconstruction loss and the KL loss to obtain the autoencoder model.
[0028] Furthermore, generating a second quality score for the forged data samples based on the differences between them includes:
[0029] A variational autoencoder model is trained using fake data samples; wherein the model parameters of the variational autoencoder model are θ.
[0030] By applying the influence function to the variational autoencoder model, new model parameters for the variational autoencoder model corresponding to each forged data sample are obtained. Where, p i Let represent the i-th forged data sample, and ∈ indicate the degree of influence;
[0031] Based on model parameters θ and new model parameters The second quality score of the forged data sample is obtained.
[0032] Furthermore, the new model parameters are characterized by... Where Θ represents the model parameter space, n represents the total number of fake data samples, and L(p i ,θ) represents the forged data sample p i The loss for the variational autoencoder model.
[0033] Furthermore, the second mass fraction in, This represents the set of forged data samples, and the result calculated using the Hessian function. n represents the total number of fake data samples. This indicates that the data sample p is improved to the degree of ∈. i The loss of the new model trained with the weights in the entire fake dataset. The operator represents the gradient of the model parameters. The parameters of the new model, Represents data sample p i Loss on the new model.
[0034] Further, the step of filtering the forged data samples based on the first quality score and the second quality score includes:
[0035] The first quality score and the second quality score are weighted to obtain the quality score of the forged data sample.
[0036] Based on the quality scores of the forged data samples, the top-K most valuable forged data samples are selected.
[0037] A dataset generation system for API anomaly detection, the system comprising:
[0038] The expert dataset building module is used to build expert datasets that include normal and abnormal samples;
[0039] The synthetic dataset initialization module is used to initialize a synthetic dataset.
[0040] The fake dataset generation module is used to sample from expert datasets and synthetic datasets, and then guide a large model to learn the format features of the examples based on the generated example datasets to obtain fake data samples.
[0041] The first quality score calculation module is used to generate the first quality score of the fake data sample based on the deviation between the features of the fake data sample and the features of the normal sample.
[0042] The second quality score calculation module is used to generate a second quality score for the fake data samples based on the differences between the fake data samples.
[0043] The final dataset generation module is used to filter the fake data samples according to the first quality score and the second quality score, put the filtering results into the synthetic dataset, and then return to the process of sampling samples in the expert dataset and the synthetic dataset until the final dataset composed of the expert dataset and the synthetic dataset meets the set requirements.
[0044] Unlike datasets generated by traditional methods, the datasets generated using the method proposed in this invention can improve the overall diversity and quality (reasonableness, correct annotation, and spurious bias) of the dataset while preserving domain-specific data format characteristics (such as specific attributes like HTTP request methods, URL paths, and query parameters). Specifically, for API anomaly detection, this method first simulates a workflow system and manually annotates system logs to obtain a small-scale expert dataset as a seed dataset, containing a certain number of normal and anomalous samples. After obtaining the seed dataset, a large language model is used to randomly sample this dataset, and the powerful few-shot learning capability of the large language model is used to generate a large number of API request data with the same form but different content as forged data. Although LLM can generate highly diverse samples, it may sometimes generate low-quality or even erroneous samples. However, the factors for judging sample quality are usually very subjective, and it is impractical to directly calculate them to judge the quality of the samples. Therefore, this invention uses the expert dataset and the forged dataset respectively to evaluate the sample quality through model performance proxy, filters the forged data, and uses a continuous generation-filtering loop to obtain the final high-quality API anomaly detection dataset.
[0045] Compared with the prior art, the present invention can achieve at least the following technical effects.
[0046] 1. This invention addresses the problem that existing data generation methods struggle to generate data with complex structures and diverse information types. It proposes a data generation method based on combining small-scale expert datasets with large language models. This method generates a large amount of similar data with rich diversity while maintaining data structure consistency.
[0047] 2. This invention addresses the problem that most existing data generation methods cannot effectively assess the quality of samples for data filtering, thus proposing a multi-path filtering method. It utilizes expert knowledge and the internal characteristics of fabricated datasets to automatically score the quality of each sample, thereby filtering out high-quality data. Attached Figure Description
[0048] Figure 1 This is a flowchart illustrating the method of the present invention.
[0049] Figure 2 This is a schematic diagram of the API anomaly detection data generation framework proposed in this invention. Detailed Implementation
[0050] The specific embodiments of the present invention will be described in further detail below with reference to the accompanying drawings and examples. The following examples are for illustrative purposes only and are not intended to limit the scope of the invention.
[0051] The dataset generation method for API anomaly detection proposed in this invention consists of five parts: constructing an expert dataset, generating a large number of fake datasets using a large language model, quality assessment based on an expert filtering model, quality assessment based on a fake filtering model, and iterative data generation and filtering.
[0052] To enable the large model to generate data in the same format as real API calls, a small-scale API call dataset was manually constructed as a seed dataset. This dataset is built upon a simulated workflow system. Various components and functions are defined on the workflow to simulate an e-commerce application. In this web application, users can register by providing personal information and browse and purchase goods. Each sample in this dataset was collected manually and contains a certain number of normal and abnormal requests. The abnormal requests include various risk types, such as injection attacks, directory traversal attacks, cross-site scripting (XSS) attacks, performance issues, invalid values, sensitive data leakage, and unauthorized access attacks. For each sample, the more important request parameter values are collected as the main attributes of the API call data. This dataset can provide samples of real API call data for subsequent data generation based on the large language model to learn from, thereby generating data in the same format as real API calls.
[0053] Manually generating large amounts of data line by line is time-consuming and labor-intensive. Recent work has shown that large language models have great potential in data generation. Therefore, this invention utilizes a small-scale expert dataset (seed dataset) and a large language model to generate a large number of fake datasets. It is worth noting that real-world API anomaly detection tasks typically involve scenarios with small samples and unknown risks. This means that API anomaly detection datasets do not actually require many anomalous samples for training. Therefore, in the data generation stage, the large language model is only used to generate normal API call samples. In the process of generating fake data using the large language model, this invention uses a sampling-hint approach to guide the large language model in generating data. In the first step, several samples are sampled from the expert dataset, and a small number of samples (if any) are sampled from the synthetic dataset as context examples. Sampling from the synthetic dataset is to increase the diversity of the data; the synthetic dataset is the dataset obtained by filtering the fake dataset generated by the large model.
[0054] There are many factors that influence data selection and sample quality assessment, such as annotation accuracy, diversity, and spurious bias. However, these factors are often highly subjective, and directly calculating them to determine sample quality is impractical. Therefore, this invention utilizes expert datasets and fake datasets to evaluate sample quality through model performance proxies. The core idea of the expert filtering model is to use normal samples from the expert dataset as guidance to judge the sample quality of the fake dataset. Specifically, this invention uses normal samples from the expert dataset as training data to train an autoencoder model, and then calculates the reconstruction loss on the fake dataset to obtain a score indicating whether a sample deviates from the features of normal samples. The core idea of the fake filtering model is to understand the impact of each training point in the fake dataset on the model's prediction. By training another variational autoencoder on this dataset in a self-supervised manner and applying an influence function to this model, an impact score for each sample on the model loss can be obtained. This score can serve as a substitute for a sample quality score.
[0055] According to the design scheme provided by this invention, a dataset generation method for API anomaly detection specifically includes the following steps:
[0056] Step 1. Construct a small-scale expert dataset. Collect API call data through manual or automated calls using a simulated workflow system or other business systems. These calls require manual intervention to perform different types of API attacks on the system, such as injection attacks, cross-site scripting attacks, and directory traversal attacks. Collect data on these normal and abnormal API calls from system logs and manually annotate them. The annotated data collected after manual calls constitutes a small-scale expert dataset.
[0057] Step 2. Generate a large amount of fake data based on the large language model and expert dataset. Using the small-scale expert dataset obtained in Step 1 as a seed dataset, the large model is guided to learn the format features of existing samples through a sampling-cue approach to generate samples that are similar in form but different in content. During the sampling process, four normal samples are sampled from the expert dataset, and two normal samples (if any) are sampled from the synthetic dataset as example data. Sampling from the synthetic dataset is to increase data diversity; the synthetic dataset is a dataset obtained by filtering the fake dataset generated by the large model. After sampling, these samples are concatenated as examples, and then cue words are added to construct complete cue words. After the cue words are constructed, the fake samples are generated by calling the API of the large language model. Continuously sampling the expert dataset, constructing cue words, and calling the large model will eventually generate a large amount of unfiltered fake data.
[0058] In one embodiment, using the given sampled samples: sample 1, sample 2, sample 3…, the prompt for generating a fake dataset using a large language model is: “Sample 1, sample 2, sample 3… + Given the above API request data samples, please generate new data samples. The new data samples should have the same format as the example data but different content. Please output the data directly.”
[0059] Step 3. Data Quality Assessment Based on the Expert Filtering Model. Normal API call samples from the expert dataset are used as training data to train the autoencoder model. Then, reconstruction loss and KL loss are calculated on the fake dataset to obtain scores indicating whether a sample deviates from the features of normal samples. Specifically, since the API data contains various forms of features, it is uniformly converted into text. A small language model, such as BERT or word2vector, is used to input each sample as text to obtain features. After converting each sample into features, it is input into the autoencoder network to calculate the reconstructed features. Then, the reconstruction loss and KL loss are used to optimize the expert filtering model, enabling it to learn the features of truly normal samples. After obtaining the expert model, samples from the fake dataset are input into the expert filtering model, and the reconstruction loss is calculated as a sample quality score to evaluate sample quality. A higher reconstruction loss means that the sample's features differ greatly from the features of normal samples in the training data, indicating lower sample quality. After normalizing the sample quality scores, a sample quality score table is obtained for subsequent sample selection.
[0060] Given an expert dataset, the process of transforming the samples into features and then using an autoencoder model to obtain reconstructed features to calculate loss and optimize the expert filtering model can be expressed as:
[0061] h i =BERT(e i ),
[0062] h′ i =VAE(h i ),
[0063]
[0064] in, The loss e when training an autoencoder model using an expert dataset i This represents data samples converted into text form. BERT is a small language model that can transform text input into feature representations. i The language embedding features of the samples. VAE is a variational autoencoder model, h′ i for h iThe reconstructed features are defined by KL, where u and σ are parameters of the approximate posterior distribution of the latent variables generated by the encoder in the VAE, and N represents the normal distribution function. After training the expert filtering model, the reconstructed features obtained by inputting the encoded samples from the fake dataset into the expert filtering model are compared with the encoded features to obtain the reconstruction loss, i.e., the sample quality score.
[0065] Step 4. Data Quality Assessment Based on the Pseudo-Filtering Model. This process also utilizes the method from Step 3 to transform samples into features using a small language model. Then, a new variational autoencoder model is directly trained using the fake dataset. An influence function is applied to this model to obtain the influence score of each sample on the model's loss. The influence function calculates the impact on the final model loss by increasing the sample's weight, thus yielding the sample's influence score. Since the model is trained on a large amount of fake data, a higher influence score indicates that the sample differs significantly from the others. A higher influence score means that increasing the weight of the corresponding sample will increase the model loss more, implying a lower-quality sample. After normalizing the sample quality scores, we obtain a second list of sample quality scores.
[0066] In one embodiment, new model parameters are obtained by perturbing the sample weights in the influence function. The process can be expressed as:
[0067]
[0068] Where θ represents the model parameters, and Θ represents the model parameter space. L(p) represents a fake dataset. i ,θ) represents sample p i For the loss of the current model, if the sample p is increased by a very small amount... i If the weights are given, then the parameters of the new model can be expressed as:
[0069] In one embodiment, the process of calculating the influence score of a sample based on the process of perturbing the sample according to the influence function can be expressed as:
[0070]
[0071] in, This indicates that the data sample p is improved to the degree of ∈. i The loss of the new model trained with the weights in the entire fake dataset. The operator represents the gradient of the model parameters. The parameters of the new model, Represents data sample p iLoss on the new model. It is a Hessian function.
[0072] Step 5. Iterative Data Generation and Filtering. The final sample quality score is obtained by averaging the quality scores of corresponding samples in the two quality score lists. Finally, the top-K most valuable samples are selected as the filtered samples and added to the synthetic dataset. By continuously iterating through the above steps, this invention can ultimately generate a large amount of high-quality API call data.
[0073] In summary, the method proposed in this invention, which combines expert datasets with large language models to generate domain-specific datasets, can produce a large amount of formatted, highly diverse, and realistic domain-specific data through continuous generation-filtering iterations with only a small amount of expert knowledge.
[0074] The multi-path screening model proposed in this invention can automatically score data quality by combining knowledge from external expert datasets with the inherent characteristics of the fabricated dataset. It indirectly obtains the quality scores of all data by utilizing a model performance proxy, thereby filtering out high-quality data and ultimately improving the overall quality of the dataset.
[0075] The present invention will be further described below with reference to a specific embodiment.
[0076] Figure 1 The overall flowchart of this invention includes five parts: collecting expert datasets, generating a large number of fake datasets using a large language model, quality assessment based on an expert filtering model, quality assessment based on a fake filtering model, and cyclical data generation and filtering.
[0077] Step 1. Collect expert dataset. Manually perform service calls using a simulated workflow system to collect 200 normal API call data points and 210 abnormal API call data points. The abnormal API call data includes 7 risk types: injection attack, directory traversal attack, cross-site scripting (XSS) attack, performance issues, invalid values, sensitive data leakage, and unauthorized access attack. There are 30 API call data points for each type of abnormality.
[0078] Step 2. Generate a large number of fake datasets using a large language model. Figure 2This invention presents a cyclical data generation and filtering framework. During the generation of the fake dataset, four data points are first randomly sampled from the expert dataset, and then two data points are sampled from the synthetic dataset (if the synthetic dataset already contains data). Based on the sampled data, a prompt is constructed: "Sample 1, Sample 2, Sample 3… + Given the above API request data samples, please generate new data samples. The new data samples should have the same format as the example data but different content. Please output the data directly." This prompt is then used to access GPT-3.5-turbo via API calls to generate fake data. Through multiple sampling and prompting processes using a large language model, a large amount of fake data is generated.
[0079] Step 3. Data quality assessment based on the expert filtering model. Given the set of normal samples ε={e i For each sample e in the i = 1, 2, ..., n group, first... i The input is transformed into text feature representation in the language model BERT:
[0080] h i =BERT(e i ),
[0081] Then, the autoencoder model is used to obtain reconstructed features, and the reconstruction loss and KL loss are calculated to optimize the expert filtering model. This process can be expressed as:
[0082] h i ′=VAE(h i ),
[0083]
[0084] Using the calculated loss The expert filtering model can be optimized using the error backpropagation algorithm.
[0085] After training the expert model, samples from the fake dataset are input into the expert filtering model, and the reconstruction loss is calculated to evaluate the sample quality. A higher reconstruction loss means that the features of the sample differ greatly from the features of normal samples in the training data, indicating lower sample quality. After normalizing the sample scores, a sample quality score table S1 can be obtained for subsequent sample selection.
[0086] Step 4. Data Quality Assessment Based on the Pseudo-Filtering Model. This process also utilizes the method from Step 3 to transform samples into features using a small language model. Then, a new variational autoencoder model is directly trained using the fake dataset. Simultaneously, an influence function is applied to this model to obtain the influence score of each sample on the model loss. In practical applications, the influence function can be directly called using the pytorch_influence_functions library in Python to obtain the sample influence score. Since the model is trained on a large amount of fake data, a higher influence score indicates that the sample is significantly different from the other samples. A higher influence score indicates that increasing the weight of the corresponding sample will increase the model loss more, meaning a lower-quality sample. After normalizing the sample quality scores, a second list of sample quality scores, S2, is obtained.
[0087] Step 5. After obtaining two quality score tables, S1 and S2, average the two quality scores for each sample to obtain the final quality score. Select the top 50 samples with the highest quality scores as the filtered samples and add them to the synthetic dataset. Repeat the above steps to iteratively generate and filter this process, thereby obtaining a large amount of high-quality API anomaly detection data.
[0088] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit them. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features therein. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope defined by the claims of the present invention.
Claims
1. A data set generation method for API anomaly detection, characterized by, The method includes: Construct an expert dataset containing normal and abnormal samples, and initialize a synthetic dataset; Samples were collected from expert datasets and synthetic datasets, and then a large model was trained to learn the format features of the examples based on the generated example datasets to obtain fake data samples. Based on the deviation between the features of fake data samples and the features of normal samples, a first quality score for fake data samples is generated. A second quality score for the fake data samples is generated based on the differences between the fake data samples. The forged data samples are filtered based on the first quality score and the second quality score, and the filtering results are placed into the synthetic dataset. Then, the process returns to sampling samples from the expert dataset and the synthetic dataset until the final dataset composed of the expert dataset and the synthetic dataset meets the set requirements. The step of generating a first quality score for the forged data samples based on the deviation between the features of the forged data samples and the features of normal samples includes: An autoencoder model is trained using normal samples from an expert dataset as training data. The forged data sample is input into the autoencoder model, and the reconstruction loss is calculated; The reconstruction loss is normalized to obtain the first quality score for each forged data sample; The training of an autoencoder model using normal samples from the expert dataset as training data includes: After converting normal samples into text form, the corresponding normal sample features are obtained based on the language model. Based on an autoencoder network, the reconstructed features corresponding to the features of the normal sample are calculated. Based on the normal sample features and the corresponding reconstructed features, calculate the reconstruction loss and KL loss; The autoencoder network is adjusted based on the reconstruction loss and the KL loss to obtain the autoencoder model; Among them, a second quality score for the fake data sample is generated based on the differences between the fake data samples, including: A variational autoencoder model is trained using fake data samples; wherein the model parameters of the variational autoencoder model are: ; By applying the influence function to the variational autoencoder model, new model parameters for the variational autoencoder model corresponding to each forged data sample are obtained. ; Based on model parameters and new model parameters The second quality score of the forged data sample is obtained. Among them, the new model parameters ;in, Represents the model parameter space. This indicates the total number of forged data samples. Indicates a sample of forged data For the loss of the variational autoencoder model, Indicates the first A sample of fake data. Indicates the degree of impact; Wherein, the second mass fraction ;in, This represents the set of forged data samples, and the result calculated using the Hessian function. , This indicates the total number of forged data samples. Indicated by Increase the degree of data sample The loss of the new model trained with the weights in the entire fake dataset. The operator represents the gradient of the model parameters. The parameters of the new model, Represents data samples Loss on the new model.
2. The method according to claim 1, characterized in that, The construction of the expert dataset, which includes normal and abnormal samples, includes: In simulation workflow systems or other business systems, API call data is collected through system logs; wherein, the API call data includes: normal API call data and abnormal API call data; After manually annotating the API call data, an expert dataset is generated.
3. The method according to claim 1, characterized in that, After the large model learns the format features of the examples based on the generated example dataset, fake data samples are obtained, including: The examples in the example dataset are concatenated and then the prompt words are added to obtain the complete prompt; The large model is invoked, and a fake data sample is generated in conjunction with the complete prompt; wherein the fake data sample is similar in form to the example but different in content.
4. The method according to claim 1, characterized in that, The step of filtering forged data samples based on the first quality score and the second quality score includes: The first quality score and the second quality score are weighted to obtain the quality score of the forged data sample. Based on the quality scores of the forged data samples, the top-K most valuable forged data samples are selected.
5. A dataset generation system for API anomaly detection, characterized in that, The system includes: The expert dataset building module is used to build expert datasets that include normal and abnormal samples; The synthetic dataset initialization module is used to initialize a synthetic dataset. The fake dataset generation module is used to sample from expert datasets and synthetic datasets, and then guide a large model to learn the format features of the examples based on the generated example datasets to obtain fake data samples. The first quality score calculation module is used to generate the first quality score of the fake data sample based on the deviation between the features of the fake data sample and the features of the normal sample. The second quality score calculation module is used to generate a second quality score for the fake data samples based on the differences between the fake data samples. The final dataset generation module is used to filter the fake data samples according to the first quality score and the second quality score, put the filtering results into the synthetic dataset, and then return to the step of sampling samples in the expert dataset and the synthetic dataset until the final dataset composed of the expert dataset and the synthetic dataset meets the set requirements. The step of generating a first quality score for a fake data sample based on the deviation between the features of the fake data sample and the features of the normal sample includes: An autoencoder model is trained using normal samples from an expert dataset as training data. The forged data sample is input into the autoencoder model, and the reconstruction loss is calculated; The reconstruction loss is normalized to obtain the first quality score for each forged data sample; The training of an autoencoder model using normal samples from the expert dataset as training data includes: After converting normal samples into text form, the corresponding normal sample features are obtained based on the language model. Based on an autoencoder network, the reconstructed features corresponding to the features of the normal sample are calculated. Based on the normal sample features and the corresponding reconstructed features, calculate the reconstruction loss and KL loss; The autoencoder network is adjusted based on the reconstruction loss and the KL loss to obtain the autoencoder model; Among them, a second quality score for the fake data sample is generated based on the differences between the fake data samples, including: A variational autoencoder model is trained using fake data samples; wherein the model parameters of the variational autoencoder model are: ; By applying the influence function to the variational autoencoder model, new model parameters for the variational autoencoder model corresponding to each forged data sample are obtained. ; Based on model parameters and new model parameters The second quality score of the forged data sample is obtained. Among them, the new model parameters ;in, Represents the model parameter space. This indicates the total number of forged data samples. Indicates a sample of forged data For the loss of the variational autoencoder model, Indicates the first A sample of fake data. Indicates the degree of impact; Wherein, the second mass fraction ;in, This represents the set of forged data samples, and the result calculated using the Hessian function. , This indicates the total number of forged data samples. Indicated by Increase the degree of data sample The loss of the new model trained with the weights in the entire fake dataset. The operator represents the gradient of the model parameters. The parameters of the new model, Represents data samples Loss on the new model.
Citation Information
Patent Citations
Deepfake traceability system based on big data federated learning architecture
CN113723220A
Transaction fraud behavior identification method and device based on multi-layer auto-encoder
CN117314638A
