Abnormity processing method in code generation process

Through the machine learning model, the code generation process is monitored in real time, combined with historical data to identify abnormal patterns and trigger corrective measures in stages, the problems of low efficiency and false alarms and missed reports of traditional abnormality detection methods are solved, and higher abnormal detection accuracy and system robustness are achieved.

CN119883870AActive Publication Date: 2025-04-25TAIJI COMPUTER CORPORATION LIMITED
View PDF 11 Cites 0 Cited by

Patent Information

Application Number
CN202510379090.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-28
Publication Date
2025-04-25
Estimated Expiration
2045-03-28

AI Technical Summary

Technical Problem

Traditional rules-based exception detection methods are difficult to deal with complex and changeable exception patterns, are inefficient and prone to false positives or missed reports, and are difficult to effectively deal with abnormal situations in the code generation process.

Method used

Through machine learning models, the code generation process is monitored in real time, combined with historical data to identify abnormal patterns, and corrective measures are triggered in stages. First, the first abnormality detection is performed and the first corrective action is triggered, and then the second abnormality detection is performed according to the environment dynamics and the second corrective action is triggered. Finally, the correction effect is evaluated and continuous improvement is carried out.

Benefits of technology

It improves the accuracy and system robustness of abnormal detection, effectively deals with abnormal situations in complex environments, reduces false alarms and missed reports, optimizes the exception handling process, and reduces the need for manual intervention.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119883870A_ABST
    Figure CN119883870A_ABST
Patent Text Reader

Abstract

The invention provides an exception handling method in a code generation process, which belongs to the technical field of exception detection and comprises the steps of collecting historical data in the code generation process, analyzing the historical data by using a machine learning algorithm, identifying an exception mode and training a machine learning model by using the exception mode. Deploying the machine learning model into a code generation process, monitoring code parameters in real time, performing first anomaly detection on the code generation process to obtain a first anomaly detection result, triggering a first correction measure of the system, recording environmental dynamics when an anomaly is detected, and performing second anomaly detection on the code generation process according to the environmental dynamics to obtain a second anomaly detection result; according to the method, the first abnormal detection result is obtained, the second abnormal detection result is obtained, the second correction measure is triggered, the execution effect of the first correction measure and the second correction measure is judged and improved, the accuracy of abnormal detection and the robustness of the system are improved, abnormal conditions in a complex environment are effectively dealt with, false alarms and missing alarms are reduced, and the abnormal processing flow is optimized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of exception detection, and in particular to an exception handling method in a code generation process. Background Art

[0002] Modern software systems are becoming increasingly complex, involving a large number of parameters, dependent libraries, and operating environments. The code generation process has also become more complicated, making it difficult to predict and handle abnormal situations. Traditional rule-based anomaly detection methods are difficult to cope with complex and changeable abnormal patterns, are inefficient, and are prone to false positives or negatives.

[0003] Therefore, the present invention provides an exception handling method in a code generation process. Summary of the invention

[0004] The present invention provides an exception handling method in the code generation process, which monitors the code generation process in real time through a machine learning model, identifies abnormal patterns in combination with historical data, and triggers corrective measures in stages. First, the first abnormality detection is performed and the first corrective measure is triggered, then the second abnormality detection is performed and the second corrective measure is triggered according to the environmental dynamics, and finally the correction effect is evaluated and continuously improved, thereby improving the accuracy of abnormality detection and the robustness of the system, effectively responding to abnormal situations in complex environments, reducing false positives and false negatives, optimizing the abnormality handling process, and reducing the need for manual intervention.

[0005] The present invention provides an exception handling method in a code generation process, comprising: Step 1: Collect historical data from the code generation process, use machine learning algorithms to analyze the historical data, identify abnormal patterns, and use the abnormal patterns to train the machine learning model; Step 2: deploying the machine learning model into the code generation process, monitoring code parameters in real time and performing a first anomaly detection on the code generation process, obtaining a first anomaly detection result, and triggering a first corrective measure of the system; Step 3: Record the environment dynamics when the anomaly is detected, and perform a second anomaly detection on the code generation process according to the environment dynamics to obtain a second anomaly detection result, thereby triggering a second corrective measure; Step 4: Determine the effectiveness of the first and second corrective measures and make improvements.

[0006] The present invention provides an exception handling method in a code generation process, which collects historical data in the code generation process, uses a machine learning algorithm to analyze the historical data, identifies abnormal patterns, and uses the abnormal patterns to train a machine learning model, including: Cleaning and converting the historical data to obtain processed data, classifying and extracting features from the processed data to obtain key features and classification features in the code generation process; Matching the machine learning algorithms based on the key features and the classification features to obtain a first machine learning algorithm and a second machine learning algorithm to obtain an abnormal pattern; A machine learning model is trained based on the anomaly pattern.

[0007] The present invention provides an exception handling method in a code generation process, which matches a machine learning algorithm based on key features and classification features, obtains a first machine learning algorithm and a second machine learning algorithm, and performs abnormal pattern recognition, including: Encode the classification features using a first machine learning algorithm, build a first model by combining the key features and the encoded classification features, call a first prediction method of the first model, detect abnormal points, the prediction results of the abnormal points are -1, and the normal points are 1, and the detected abnormal points are first marked and output as a first abnormal point set; Using a second machine learning algorithm to set the number of neighbors and the ratio of outliers based on the key features and the classification features, constructing a second model, calling a second prediction method of the second model, detecting outliers, performing a second marking on the detected outliers, and outputting the second outlier set; Comparing the first abnormal point set with the second abnormal point set, and finally marking the intersection of the first abnormal point set and the second abnormal point set to obtain a final abnormal point set; The characteristic distribution statistics of the final abnormal point set are performed to obtain the abnormal pattern.

[0008] The present invention provides an exception handling method in a code generation process, which deploys the machine learning model into the code generation process, monitors code parameters in real time, performs a first exception detection on the code generation process, obtains a first exception detection result, and triggers a first corrective measure of the system, including: Integrate the trained machine learning model into the code generation tool, call it in real time, collect code parameters in the code generation process in real time, and the machine learning model sets a first threshold for the code parameters; A first abnormality detection is performed based on the first threshold, a first abnormality detection result is obtained, and a first corrective measure is implemented.

[0009] The present invention provides an exception handling method in a code generation process, wherein a machine learning model sets a first threshold value for the code parameter, including: ,in, represents the first threshold; represents the weight coefficient of the sliding window; t represents time; T represents the time length of the sliding window; Indicates time The signal value at time ; Indicates time The mean value of represents the exponential weighted average; k represents the adjustment coefficient; represents the exponentially weighted moving variance.

[0010] The present invention provides an exception handling method in a code generation process, which records the environment dynamics when the exception is detected, and performs a second exception detection on the code generation process according to the environment dynamics to obtain a second exception detection result, thereby triggering a second corrective measure, including: Generate a second anomaly detection based on the first anomaly detection result recording the environmental variables, external dependencies, and user behaviors when the anomaly is detected; A second abnormality detection result in the code generation process is determined according to the second abnormality detection, triggering a second corrective measure.

[0011] The present invention provides an exception handling method in a code generation process, which generates a second exception detection based on the first exception detection result recording the environment variables, external dependencies and user behaviors when the exception is detected, and includes: Analyze the correlation between the environmental variable and the first anomaly detection result, and generate an environmental detection based on the correlation; Monitor the running status of the external dependency service, perform indicator analysis on the performance indicators of the external dependency service, determine the propagation path of the exception from the external dependency service to the code generation process based on the indicator analysis, and generate an external dependency detection; Analyze the input data and operation sequence submitted by the user, determine the user characteristics, establish a user profile based on the user characteristics, and generate user detection by combining the input data, operation sequence and user profile; A second anomaly detection is generated by combining the environment detection, external dependency detection and user detection.

[0012] The present invention provides an exception handling method in a code generation process, which determines the execution effects of a first corrective measure and a second corrective measure and makes improvements, including: Conducting a quantitative evaluation on the first corrective measure and the second corrective measure to obtain a first effect, and conducting a qualitative evaluation on the first corrective measure and the second corrective measure to obtain a second effect; An execution effect is obtained by combining the first effect and the second effect, and the first corrective measure and the second corrective measure are improved according to the execution effect.

[0013] Compared with the prior art, the beneficial effects of this application are as follows: the code generation process is monitored in real time through a machine learning model, abnormal patterns are identified in combination with historical data, and corrective measures are triggered in stages. First, the first abnormality detection is performed and the first corrective measure is triggered, then the second abnormality detection is performed and the second corrective measure is triggered according to the environment dynamics, and finally the correction effect is evaluated and continuously improved, thereby improving the accuracy of abnormality detection and the robustness of the system, effectively responding to abnormal situations in complex environments, reducing false positives and false negatives, optimizing the abnormality handling process, and reducing the need for manual intervention.

[0014] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained by the structures particularly pointed out in the written description and the accompanying drawings.

[0015] The technical solution of the present invention is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] The accompanying drawings are used to provide a further understanding of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation of the present invention. In the accompanying drawings: Figure 1 The present invention is a flowchart of an exception handling method in a code generation process provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0017] The preferred embodiments of the present invention are described below in conjunction with the accompanying drawings. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present invention, and are not used to limit the present invention.

[0018] Embodiment 1: The embodiment of the present invention provides a method for handling exceptions in a code generation process, such as Figure 1 As shown, including: Step 1: Collect historical data from the code generation process, use machine learning algorithms to analyze the historical data, identify abnormal patterns, and use the abnormal patterns to train the machine learning model; Step 2: deploying the machine learning model into the code generation process, monitoring code parameters in real time and performing a first anomaly detection on the code generation process, obtaining a first anomaly detection result, and triggering a first corrective measure of the system; Step 3: Record the environment dynamics when the anomaly is detected, and perform a second anomaly detection on the code generation process according to the environment dynamics to obtain a second anomaly detection result, thereby triggering a second corrective measure; Step 4: Determine the effectiveness of the first and second corrective measures and make improvements.

[0019] In this embodiment, historical data are various data records accumulated during the code generation process, which are used to train the machine learning model to identify abnormal patterns and contain sufficient information to characterize the state and performance of the code generation process, as well as various factors that may cause abnormalities, including indicator data of the code generation process, code parameters and input data, environment variables, etc.

[0020] In this embodiment, the machine learning algorithm includes a first machine learning algorithm and a second machine learning algorithm.

[0021] In this embodiment, by cleaning, converting, classifying and extracting features from historical data, key features and classification features in the code generation process are extracted. Based on these features, the machine learning algorithms (first and second algorithms) are matched to identify abnormal patterns and train the machine learning model.

[0022] In this embodiment, abnormal patterns are identified patterns that deviate significantly from normal situations, for example, a combination of high code complexity, large code size, and high memory usage results in excessively long code generation time, and frequent errors in the code generation process for certain types of input data.

[0023] In this embodiment, the machine learning model is a trained model that can detect anomalies. The input is key features and classification features (cleaned, transformed, and possibly feature engineered). The output is: For anomaly detection: A probability score indicating the likelihood that an instance is an anomaly. Then a threshold is set to classify the instance as an anomaly or non-anomaly. For classification / regression: A class label (anomaly type) or a predicted code generation time. For example, the isolation forest model may output a score of 0.95 for a data point, indicating that it is highly likely to be an anomaly. The random forest model may classify it as a "memory problem" anomaly.

[0024] In this embodiment, code parameters are input values ​​and settings used by the code generation tool to generate code. For example, in a Python to C++ code generation script, the parameters may include: code specification, a high-level specification of the code to be generated (e.g., a JSON object); optimization level, an integer representing the code optimization level; target platform, a string indicating the target platform (e.g., "x86_64", "ARM").

[0025] In this embodiment, the first exception detection result is the output of the first exception detection step, indicating whether the code generation process is running normally or an exception is detected. For example, the output may be a Boolean value (True indicates an exception, False indicates normal) or a probability score indicating the possibility of an exception.

[0026] In this embodiment, the first corrective action is the action taken by the system to resolve the detected anomaly. For example, if an anomaly is detected (code generation time exceeds a threshold), the first corrective action may be, Retry: rerun the code generation process with the same parameters, Warning: issue a warning to the user with information about the detected anomaly, Fallback strategy: generate a simplified version of the code (possibly reducing the optimization level) to avoid long generation time, Logging: record detailed information about the exception for later analysis.

[0027] In this embodiment, the second anomaly detection result is the result of the second anomaly detection, indicating the potential root cause of the long initial code generation time, for example, insufficient memory (low available memory) is the main reason, slow database response time (high database response time) is the bottleneck, and the user provides abnormally complex input (high input data complexity).

[0028] In this embodiment, the second corrective action is a measure taken to address the root cause identified by the second anomaly detection, for example, if insufficient memory is the cause: the system may suggest increasing available memory or optimizing the code generation process to reduce memory usage.

[0029] In this embodiment, the environmental dynamics include environmental variables, external dependencies, and user behaviors.

[0030] In this embodiment, the effects of the first and second corrective measures are quantitatively and qualitatively evaluated to comprehensively evaluate the two types of measures. The quantitative evaluation uses specific indicators (such as repair time, success rate, etc.) to measure efficiency, while the qualitative evaluation considers the complexity and maintainability of the measures. The final comprehensive evaluation results are used to guide improvement measures to form a closed-loop continuous optimization mechanism.

[0031] The working principle and beneficial effects of the above technical solution are: monitor the code generation process in real time through machine learning models, identify abnormal patterns in combination with historical data, and trigger corrective measures in stages. First, the first anomaly detection is performed and the first corrective measure is triggered. Then, the second anomaly detection is performed and the second corrective measure is triggered according to the dynamic environment. Finally, the correction effect is evaluated and continuously improved, thereby improving the accuracy of anomaly detection and system robustness, effectively responding to abnormal situations in complex environments, reducing false positives and false negatives, optimizing the exception handling process, and reducing the need for manual intervention.

[0032] Embodiment 2: The embodiment of the present invention provides an exception handling method in a code generation process, which collects historical data in the code generation process, uses a machine learning algorithm to analyze the historical data, identifies abnormal patterns, and uses the abnormal patterns to train a machine learning model, including: Cleaning and converting the historical data to obtain processed data, classifying and extracting features from the processed data to obtain key features and classification features in the code generation process; Matching the machine learning algorithms based on the key features and the classification features to obtain a first machine learning algorithm and a second machine learning algorithm to obtain an abnormal pattern; A machine learning model is trained based on the anomaly pattern.

[0033] In this embodiment, data cleaning and conversion, cleaning, and cleaning errors and inconsistencies in the original data. For example: handling missing values, replacing missing code generation times with the mean, or deleting entries containing missing data (if there is not much missing data), removing outliers, identifying and removing extremely high or extremely low code generation times (which may be errors), such as using box plots or Z-scores; data type conversion, ensuring that all data is in the correct format (for example, converting strings representing time to numeric values).

[0034] In this embodiment, transformation is changing the representation of data to make it more suitable for machine learning. For example: normalization / standardization, scaling the code generation time to a standard range (e.g., 0-1 or a mean of 0 and a standard deviation of 1), preventing features with large values ​​from dominating the model, feature engineering, creating new features based on existing features. For example, the rate of change of code generation time can be calculated, processing the data, cleaning and transforming the data, preparing it for analysis, which may be a CSV file, a Pandas DataFrame, or a similar data structure.

[0035] In this embodiment, the key features are features that are highly correlated with the code generation time, such as code size (number of lines of code, number of functions), code complexity (cyclomatic complexity, nesting level), number of external library calls, CPU usage during code generation, and memory usage during code generation.

[0036] In this embodiment, the classification feature is a feature that classifies a data point (e.g., "normal" or "abnormal"). For example: code generation time, the main feature is classified as normal or abnormal according to the threshold, error flag, a binary feature, indicates whether an error occurred during the code generation process, and a data point may be as follows: [1000, 5, 20, 60%, 50%, 0], which respectively represent [code size (LOC), complexity, number of external calls, CPU usage, memory usage, error flag].

[0037] In this embodiment, the first machine learning algorithm is an algorithm for anomaly detection, such as Isolation Forest, which is good at detecting outliers in high-dimensional data, and One-Class Support Vector Machine, which is effective at one-class classification (identifying anomalies in a set of mostly normal data).

[0038] In this embodiment, the second machine learning algorithm is a classification or regression algorithm used to further understand the cause after the initial anomaly detection. For example: random forest is used to classify anomalies into different types (e.g., memory problems, long compilation time), linear regression is used to predict code generation time based on features to identify factors that cause long generation time.

[0039] In this embodiment, a first machine learning algorithm is used to encode classification features and construct a first model, detect outliers and output a first outlier point set; at the same time, a second machine learning algorithm is used to construct a second model, detect outliers and output a second outlier point set, compare the two outlier point sets, take their intersection as the final outlier point set, and statistically analyze the feature distribution to identify abnormal patterns.

[0040] The working principle and beneficial effects of the above technical solution are: by cleaning, converting, classifying and extracting features from historical data, key features and classification features in the code generation process are extracted. Based on these features, the machine learning algorithms (first and second algorithms) are matched to identify abnormal patterns and train machine learning models, thereby achieving accurate detection and prediction of abnormalities in the code generation process and improving the efficiency and accuracy of abnormality detection.

[0041] Embodiment 3: The embodiment of the present invention provides an exception handling method in a code generation process, which matches a machine learning algorithm based on key features and classification features, obtains a first machine learning algorithm and a second machine learning algorithm, and performs abnormal pattern recognition, including: Encode the classification features using a first machine learning algorithm, build a first model by combining the key features and the encoded classification features, call a first prediction method of the first model, detect abnormal points, the prediction results of the abnormal points are -1, and the normal points are 1, and the detected abnormal points are first marked and output as a first abnormal point set; Using a second machine learning algorithm to set the number of neighbors and the ratio of outliers based on the key features and the classification features, constructing a second model, calling a second prediction method of the second model, detecting outliers, performing a second marking on the detected outliers, and outputting the second outlier set; Comparing the first abnormal point set with the second abnormal point set, and finally marking the intersection of the first abnormal point set and the second abnormal point set to obtain a final abnormal point set; The characteristic distribution statistics of the final abnormal point set are performed to obtain the abnormal pattern.

[0042] In this embodiment, the process of encoding categorical features using the first machine learning algorithm is to convert the categorical features (for example, "error flag" - 0 means no error, 1 means an error) into a numerical representation that the machine learning algorithm can understand. Common encoding techniques include: one-hot encoding, creating a new binary feature for each category (for example, "error flag" becomes two features: "error_0" and "error_1"), label encoding, assigning a unique integer to each category (for example, 0 means no error, 1 means an error). For example, if we have a "programming language" feature with categories "Python", "Java" and "C++", one-hot encoding will create three new features: "language_Python", "language_Java" and "language_C++", and the value of each feature is 1 or 0, depending on the language used.

[0043] In this embodiment, the first model is built using a first machine learning algorithm, and anomaly detection can be performed using an isolation forest model, receiving numerical features (code generation time, code size, complexity, encoded categorical features) as input, a first prediction method, the model predicts whether each data point is an anomaly (-1) or a normal point (1), a first labeling, data points predicted to be anomalies (-1) are labeled as potential anomalies, and the first anomaly point set is a set of potential anomalies labeled by the first model. For example, the isolation forest model may label data points with extremely long code generation time as anomalies (-1), even if other features appear to be normal.

[0044] In this embodiment, a second model is constructed and a second prediction method is called. The number of neighbors is a parameter used in algorithms such as the local anomaly factor, which determines how many neighbors to consider when evaluating the anomaly score of a data point, the proportion of anomalies, and an estimate of the expected percentage of anomalies.

[0045] In this embodiment, the second model can use the LOF model, using the same input features as the first model, but focusing on local density to identify outliers, the number of neighbors, the proportion of outliers, and the parameters that affect the sensitivity of the model. The second prediction method is that the LOF model calculates the anomaly score for each data point. Points exceeding the threshold (based on the "proportion of outliers") are marked as outliers, the second mark is the outliers identified by the LOF model, and the second outlier set is the set of outliers identified by the second model. For example, LOF may identify a cluster of data points with abnormally long code generation time and high complexity as outliers, even if some of them are not marked as abnormal by the isolation forest.

[0046] In this embodiment, the intersection of the first outlier point set and the second outlier point set represents the outliers identified by both models, which increases the confidence in anomaly detection. The final outlier point set is a set of outliers marked by both models. For example, only data points marked as outliers by both isolation forest and LOF are included in the final outlier point set.

[0047] In this embodiment, feature distribution statistics is to analyze the distribution of key features in the final anomaly point set, including calculating the summary statistics (mean, median, standard deviation, etc.) of each feature in the anomaly set; the anomaly pattern is the feature of the feature distribution in the final anomaly point set that reveals the anomaly pattern. For example, the analysis may find that the characteristics of the anomaly point are abnormally high code complexity, abnormally large code size, and frequent calls to specific external libraries.

[0048] The working principle and beneficial effects of the above technical solution are: encoding the classification features and constructing the first model through the first machine learning algorithm, detecting abnormal points and outputting the first abnormal point set; at the same time, using the second machine learning algorithm to construct the second model, detecting abnormal points and outputting the second abnormal point set, comparing the two abnormal point sets, taking their intersection as the final abnormal point set, statistically analyzing the feature distribution to identify abnormal patterns, and adapting to complex and changeable abnormal situations.

[0049] Embodiment 4: The embodiment of the present invention provides an exception handling method in a code generation process, deploying the machine learning model into the code generation process, monitoring code parameters in real time and performing a first exception detection on the code generation process, obtaining a first exception detection result, and triggering a first corrective measure of the system, including: Integrate the trained machine learning model into the code generation tool, call it in real time, collect code parameters in the code generation process in real time, and the machine learning model sets a first threshold for the code parameters; A first abnormality detection is performed based on the first threshold, a first abnormality detection result is obtained, and a first corrective measure is implemented.

[0050] In this embodiment, the code generation tool is a software application for generating code, for example: a compiler (such as GCC or Clang), a code generator for a specific framework (for example, a code generator for a game engine).

[0051] In this embodiment, the integration is to embed the trained machine learning model into the code generation tool so that it can be accessed and used during the code generation process. This usually involves creating an API or interface that allows the code generation tool to communicate with the machine learning model. For example, you may write a Python function that receives code generation parameters as input, calls the trained machine learning model (for example, a pre-trained scikit-learn model loaded from a file), and returns the prediction result. This function will be integrated into the code generation script.

[0052] In this embodiment, the first threshold is dynamically determined by the machine learning model according to the input code parameters, indicating the boundary between the normal range and the abnormal range of the code generation time. The threshold is not a fixed value, but changes dynamically according to the context of the code generation parameters. For example, if the code specification is complex and the optimization level is high, the model may set a higher threshold for the code generation time because these factors tend to increase the generation time.

[0053] The working principle and beneficial effect of the above technical solution are: integrating the trained machine learning model into the code generation tool, collecting code parameters in real time and setting a first threshold. Anomaly detection is performed based on the first threshold, the detection result is obtained and the first corrective measure is triggered, thereby realizing real-time monitoring and exception handling of the code generation process, reducing the impact of exceptions on the code generation process, improving the system response speed, correcting exceptions in a timely manner, and enhancing the robustness and reliability of the code generation tool.

[0054] Embodiment 5: An embodiment of the present invention provides an exception handling method in a code generation process, wherein a machine learning model sets a first threshold value for the code parameter, including: ,in, represents the first threshold; represents the weight coefficient of the sliding window; t represents time; T represents the time length of the sliding window; Indicates time The signal value at time ; Indicates time The mean value of represents the exponentially weighted average; k represents the adjustment coefficient; Denotes the exponentially weighted moving variance.

[0055] The working principle and beneficial effect of the above technical solution are: the first threshold is dynamically adjusted using the sliding window method and the exponential weighted moving average method. The sliding window method calculates the mean and variance of the signal value, and the exponential weighted moving average method pays more attention to recent data. By adjusting the weight coefficient k, the sensitivity and stability of the threshold are balanced, so that the system can respond to anomalies in a timely manner and avoid false alarms, thereby improving the sensitivity and accuracy of anomaly detection.

[0056] Embodiment 6: An embodiment of the present invention provides an exception handling method in a code generation process, which records the environment dynamics when the exception is detected, and performs a second exception detection on the code generation process according to the environment dynamics to obtain a second exception detection result, thereby triggering a second corrective measure, including: Generate a second anomaly detection based on the first anomaly detection result recording the environmental variables, external dependencies, and user behaviors when the anomaly is detected; A second abnormality detection result in the code generation process is determined according to the second abnormality detection, triggering a second corrective measure.

[0057] In this embodiment, environment variables are system-specific settings that affect the code generation process, such as, number of CPU cores, the number of CPU cores available for the code generation process. A small number may result in long generation times, available memory, the amount of available memory. Low memory may cause slowdowns or crashes, and operating system version, the operating system version. Older or unstable operating system versions may have performance issues.

[0058] In this embodiment, the external dependency is the status and performance of external services or resources that the code generation process depends on, such as database response time, the average response time of database queries used in the code generation process. Slow database queries can significantly affect overall performance, network latency, if the code generation process accesses external APIs or resources, it is network latency. High latency will increase generation time, file system IOPS, the number of input / output operations per second (IOPS) of the file system. Slow I / O may cause bottlenecks.

[0059] In this embodiment, user behavior is an action by a user that may affect the code generation process, such as input data size, the size of the input data provided by the user for code generation. Larger inputs may increase generation time, input data complexity, a measure of the complexity of the user input data (e.g., the number of elements in a data structure or the nesting level of a configuration file). More complex inputs may result in longer generation times, and user experience level, an indicator of the user's proficiency with the code generation tool. Inexperienced users may create inputs that lead to unexpected results or longer processing times.

[0060] The working principle and beneficial effects of the above technical solution are: after the first anomaly detection finds a problem, the system environment at that time (environmental variables, external dependencies, user behavior, etc.) is recorded as the input features of the second anomaly detection. The second anomaly detection model uses these features to identify the root cause of the anomaly and trigger a more accurate second corrective measure, more accurately locate the cause of the anomaly, improve the efficiency of anomaly handling, reduce the false alarm rate, and improve system stability and reliability.

[0061] Embodiment 7: An embodiment of the present invention provides an exception handling method in a code generation process, which generates a second exception detection based on a first exception detection result recording the environment variables, external dependencies, and user behaviors when the exception is detected, including: Analyze the correlation between the environmental variable and the first anomaly detection result, and generate an environmental detection based on the correlation; Monitor the running status of the external dependency service, perform indicator analysis on the performance indicators of the external dependency service, determine the propagation path of the exception from the external dependency service to the code generation process based on the indicator analysis, and generate an external dependency detection; Analyze the input data and operation sequence submitted by the user, determine the user characteristics, establish a user profile based on the user characteristics, and generate user detection by combining the input data, operation sequence and user profile; A second anomaly detection is generated by combining the environment detection, external dependency detection and user detection.

[0062] In this embodiment, the association relationship is to find the statistical association between the environment variable and the first abnormal detection result (for example, those tasks that run too long). Correlation analysis, regression analysis and other methods can be used. For example, a hypothesis analysis finds that when the system available memory is lower than a certain threshold, the probability of the code generation time being too long increases significantly, indicating that there is an association relationship between insufficient available memory and the code generation time being too long.

[0063] In this embodiment, the environment detection is based on this association relationship, and an environment detection program is designed to continuously monitor the available memory. If the available memory is lower than a preset threshold, an alarm will be issued to indicate that there may be a performance problem.

[0064] In this embodiment, the running status of the external dependency service is monitored, the performance indicators of the external dependency service are analyzed, and the propagation path of the exception from the external dependency service to the code generation process is determined based on the indicator analysis, and the external dependency detection is generated: the running status is to continuously monitor the running status of the external services (for example, database, network service, cache, etc.) on which the code generation process depends, including checking the availability and connection status of the service, for example, the code generation process depends on a database. The external dependency detection module monitors the connection status and query response time of the database.

[0065] In this embodiment, the performance indicators are key performance indicators collected from external dependent services, such as the average query response time of the database, the average latency of the network service, the hit rate of the cache, etc.

[0066] In this embodiment, the index analysis is to analyze these performance indicators and find the correlation with the excessively long code generation time. For example, it can be analyzed whether the database query response time is significantly longer in the task with excessively long code generation time.

[0067] In this embodiment, the propagation path attempts to determine how the exception is propagated from the external dependent service to the code generation process. For example, if it is found that the increase in database query response time is highly correlated with the excessively long code generation time, then it can be inferred that the database performance problem is the cause of the excessively long code generation time.

[0068] In this embodiment, external dependency detection is based on indicator analysis and propagation path analysis, and an external dependency detection program is designed. The program continuously monitors the key performance indicators of the external dependency service and issues an alarm when the indicator exceeds a preset threshold.

[0069] In this embodiment, the input data and operation sequence submitted by the user are analyzed, the user characteristics are determined, and a user profile is established based on the user characteristics. The input data, operation sequence and user profile are combined to generate user detection: input data and operation sequence submitted by the user (input data and operation sequence submitted by the user): record the input data (for example, code specifications, parameters, etc.) in the code generation request submitted by the user and the operation sequence performed by the user, for example, record the size and complexity of the code specification submitted by the user, and the code generation option selected by the user.

[0070] In this embodiment, the user features are extracted from the data and operation sequences submitted by the user. For example, the user often submits large and complex code specifications, or the user often selects options with a high optimization level.

[0071] In this embodiment, the user portrait is established based on user characteristics. For example, users can be divided into different portraits such as novice users, advanced users, and high-demand users.

[0072] In this embodiment, user detection is to design a user detection program to identify user behavior patterns that may cause code generation time to be too long based on user portraits. For example, if it is found that tasks submitted by high-demand users often have code generation time that is too long, the program can issue an alarm.

[0073] The working principle and beneficial effects of the above technical solution are: by analyzing the correlation between the first anomaly detection result and environmental variables, external dependencies and user behavior, three types of auxiliary detection are constructed: environmental detection, external dependency detection and user detection. The auxiliary detection identifies potential abnormal factors from different dimensions respectively, and the second anomaly detection is generated by combining the three types of detection results to more accurately locate the root cause of the problem, thereby triggering a more effective second corrective measure, reducing false alarms and missed alarms, more effectively identifying the cause of the anomaly, and improving system stability and self-healing capabilities.

[0074] Embodiment 8: An embodiment of the present invention provides an exception handling method in a code generation process, which determines the execution effects of a first corrective measure and a second corrective measure and performs improvements, including: Conducting a quantitative evaluation on the first corrective measure and the second corrective measure to obtain a first effect, and conducting a qualitative evaluation on the first corrective measure and the second corrective measure to obtain a second effect; An execution effect is obtained by combining the first effect and the second effect, and the first corrective measure and the second corrective measure are improved according to the execution effect.

[0075] In this embodiment, quantitative evaluation is to use numerical indicators to measure the effectiveness of corrective measures. For example, the first corrective measure is re-running, and the corresponding quantitative evaluation includes the average repair time, how long it takes on average to successfully generate code after re-running (the lower the value, the better), the success rate, and what proportion of the problems are solved by re-running; the second corrective measure is database optimization, and the corresponding quantitative evaluation includes the average code generation time, how long the average code generation time is after database optimization, and the database query response time, whether the optimization reduces the average response time of database queries.

[0076] In this embodiment, the first effect is the result of quantitative evaluation. For example, the re-run mechanism reduces the average repair time by 15%, but the success rate is only 70%, and the database optimization reduces the average code generation time by 30% and the database query response time by 40%.

[0077] In this embodiment, the qualitative evaluation is to evaluate various aspects of the corrective measures that are difficult to quantify. For example, when the first corrective measure is rerun, the corresponding qualitative evaluation includes simplicity, whether the rerun mechanism is easy to implement and understand, robustness, when the problem is caused by a temporary problem, whether the rerun is always effective, or there are some cases where it fails repeatedly, resource consumption, whether the rerun consumes too many system resources; when the second corrective measure is database optimization, the corresponding qualitative evaluation includes maintainability, whether the database optimization changes are easy to maintain and update, scope of impact, whether the database optimization has any unexpected impact on other parts of the system, and implementation difficulty, whether it is difficult to implement database optimization.

[0078] In this embodiment, the second effect is the result of qualitative evaluation. For example, the re-run mechanism is easy to implement, but not robust enough; it fails in some cases. Database optimization is relatively complex to implement, but improves system stability.

[0079] In this example, the execution effect is a summary of quantitative and qualitative results that comprehensively evaluates the effectiveness of each corrective action. For example, while the rerun mechanism provides a quick but unreliable solution, database optimization provides a more sustainable solution and brings significant performance improvements despite the increased initial implementation complexity.

[0080] In this embodiment, the improvement is to modify the corrective measures based on the execution effect, such as improving the retry mechanism, implementing more complex retry logic (e.g., exponential backoff) to more effectively handle transient errors and reduce resource consumption, improving database optimization, further optimizing database queries to obtain greater performance improvements or addressing any unexpected consequences found in the qualitative evaluation. This may include adjusting database settings or using more efficient query patterns, developing new corrective measures, and if both methods are unsatisfactory, developing new corrective measures completely.

[0081] The working principle and beneficial effects of the above technical solution are: through quantitative and qualitative evaluation of the effects of the first and second corrective measures, a comprehensive evaluation of these two types of measures is conducted. The quantitative evaluation uses specific indicators (such as repair time, success rate, etc.) to measure efficiency, and the qualitative evaluation considers the complexity and maintainability of the measures. The final comprehensive evaluation results are used to guide improvement measures, forming a closed-loop continuous optimization mechanism, improving the efficiency and accuracy of exception handling, reducing system failure rate, and improving system stability and reliability.

[0082] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for handling exceptions in a code generation process, characterized in that: include: Step 1: Collect historical data from the code generation process, use machine learning algorithms to analyze the historical data, identify abnormal patterns, and use the abnormal patterns to train the machine learning model; Step 2: deploying the machine learning model into the code generation process, monitoring code parameters in real time and performing a first anomaly detection on the code generation process, obtaining a first anomaly detection result, and triggering a first corrective measure of the system; Step 3: Record the environment dynamics when the anomaly is detected, and perform a second anomaly detection on the code generation process according to the environment dynamics to obtain a second anomaly detection result, thereby triggering a second corrective measure; Step 4: Determine the effectiveness of the first and second corrective measures and make improvements.

2. The method for handling exceptions in a code generation process according to claim 1, characterized in that: Collect historical data from the code generation process, use machine learning algorithms to analyze the historical data, identify abnormal patterns, and use the abnormal patterns to train the machine learning model, including: Cleaning and converting the historical data to obtain processed data, classifying and extracting features from the processed data to obtain key features and classification features in the code generation process; Matching the machine learning algorithms based on the key features and the classification features to obtain a first machine learning algorithm and a second machine learning algorithm to obtain an abnormal pattern; A machine learning model is trained based on the anomaly pattern.

3. The method for handling exceptions in a code generation process according to claim 2, characterized in that: The machine learning algorithms are matched based on the key features and the classification features to obtain the first machine learning algorithm and the second machine learning algorithm, and abnormal pattern recognition is performed, including: Encode the classification features using a first machine learning algorithm, build a first model by combining the key features and the encoded classification features, call a first prediction method of the first model, detect abnormal points, the prediction results of the abnormal points are -1, and the normal points are 1, and the detected abnormal points are first marked and output as a first abnormal point set; Using a second machine learning algorithm to set the number of neighbors and the ratio of outliers based on the key features and the classification features, constructing a second model, calling a second prediction method of the second model, detecting outliers, performing a second marking on the detected outliers, and outputting the second outlier set; Comparing the first abnormal point set with the second abnormal point set, and finally marking the intersection of the first abnormal point set and the second abnormal point set to obtain a final abnormal point set; The characteristic distribution statistics of the final abnormal point set are performed to obtain the abnormal pattern.

4. The method for handling exceptions in a code generation process according to claim 1, characterized in that: The machine learning model is deployed into the code generation process, code parameters are monitored in real time, and a first anomaly detection is performed on the code generation process, a first anomaly detection result is obtained, and a first corrective measure of the system is triggered, including: Integrate the trained machine learning model into the code generation tool, call it in real time, collect code parameters in the code generation process in real time, and the machine learning model sets a first threshold for the code parameters; A first abnormality detection is performed based on the first threshold, a first abnormality detection result is obtained, and a first corrective measure is implemented.

5. The method for handling exceptions in a code generation process according to claim 4, characterized in that: The machine learning model sets a first threshold value for the code parameter, including: ,in, represents the first threshold; represents the weight coefficient of the sliding window; t represents time; T represents the time length of the sliding window; Indicates time The signal value at time ; Indicates time The mean value of represents the exponential weighted average; k represents the adjustment coefficient; Denotes the exponentially weighted moving variance.

6. The method for handling exceptions in a code generation process according to claim 1, characterized in that: Recording the environment dynamics when the anomaly is detected, and performing a second anomaly detection on the code generation process according to the environment dynamics to obtain a second anomaly detection result, thereby triggering a second corrective measure, including: Generate a second anomaly detection based on the first anomaly detection result recording the environmental variables, external dependencies, and user behaviors when the anomaly is detected; A second abnormality detection result in the code generation process is determined according to the second abnormality detection, triggering a second corrective measure.

7. The method for handling exceptions in a code generation process according to claim 5, characterized in that: Based on the first anomaly detection result recording the environment variables, external dependencies, and user behaviors when the anomaly is detected, a second anomaly detection is generated, including: Analyze the correlation between the environmental variable and the first anomaly detection result, and generate an environmental detection based on the correlation; Monitor the running status of the external dependency service, perform indicator analysis on the performance indicators of the external dependency service, determine the propagation path of the exception from the external dependency service to the code generation process based on the indicator analysis, and generate an external dependency detection; Analyze the input data and operation sequence submitted by the user, determine the user characteristics, establish a user profile based on the user characteristics, and generate user detection by combining the input data, operation sequence and user profile; A second anomaly detection is generated by combining the environment detection, external dependency detection and user detection.

8. The method for handling exceptions in a code generation process according to claim 1, characterized in that: Determine the effectiveness of the first and second corrective actions and make improvements, including: Conducting a quantitative evaluation on the first corrective measure and the second corrective measure to obtain a first effect, and conducting a qualitative evaluation on the first corrective measure and the second corrective measure to obtain a second effect; An execution effect is obtained by combining the first effect and the second effect, and the first corrective measure and the second corrective measure are improved according to the execution effect.

Citation Information

Patent Citations

  • Ocean single-element observation quality control method based on multi-model fusion

    CN113570000A

  • Abnormal data detection and interpretation method

    CN117874673A

  • Computer software protection system and method based on cloud computing

    CN117892316A

  • Intelligent monitoring verification system

    CN118042084A

  • AI behavior optimization and self-management system

    CN118278538A