Vehicle machine log detection model training method and device, electronic equipment and storage medium
By refining the vehicle log data and applying the weighted longest common subsequence matching model, a vehicle log detection model is generated, which solves the problem of low accuracy in log anomaly detection and improves the accuracy of log event extraction.
Patent Information
- Application Number
- CN202310916998.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-24
- Publication Date
- 2026-11-24
- Estimated Expiration
- 2043-07-24
AI Technical Summary
In existing technologies, the log data preprocessing module does not perform regularization processing on the log data itself, and the log template matching stage does not perform weighting based on the log structure, resulting in low accuracy of log anomaly detection.
By refining the vehicle log data, a target log template is generated. A preset weighted longest common subsequence matching model is used to perform sliding window segmentation and neural network training to generate a vehicle log detection model.
It improves the accuracy of log anomaly detection, solves the prediction bias problem caused by uneven log distribution, and enhances the accuracy of log event extraction.
Smart Images

Figure CN117149479B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of log detection technology, and in particular to a method, apparatus, electronic device, and storage medium for training a vehicle log detection model. Background Technology
[0002] With the continuous development of technology, computer applications are playing an increasingly important role in people's production and daily lives. Logs are crucial carriers of computer system operating status and events. They record system status and important events at key points to aid in troubleshooting system failures and performing root cause analysis. Therefore, logs are an excellent source of information for online monitoring and anomaly detection. By detecting anomalies in system logs, actionable information can be provided at critical moments, thereby ensuring the efficient and stable operation of the system.
[0003] Currently, the relevant technology detects logs by combining bidirectional slice GRU (Gated Recurrent Unit) with gated attention mechanism. However, the log data preprocessing module does not perform regularization processing on the log data itself, resulting in insufficient representation of the obtained log key. This leads to prediction bias caused by the uneven distribution of logs with different log keys, making it impossible to avoid prediction bias caused by the uneven distribution of logs in log anomaly detection, which further affects the accuracy of log anomaly detection. Summary of the Invention
[0004] This invention provides a method, apparatus, electronic device, and storage medium for training a vehicle log detection model. It solves the problems in related technologies, such as the log data preprocessing module not performing regularization processing based on the log data itself, the log template matching stage not combining log structure for weighting, and the prediction model not adjusting for prediction bias caused by uneven log distribution when predicting the results. This invention improves the accuracy of log anomaly detection.
[0005] The first aspect of this invention provides a method for training a vehicle log detection model, comprising the following steps:
[0006] Obtain the vehicle system logs to be detected, generate vehicle system log data corresponding to the vehicle system logs, and perform fine-grained processing on the vehicle system log data to obtain fine-grained log data;
[0007] Based on the refined log data, the word vectors of the log words in the target log template are determined, and the weighted average of the word vectors of the log words is used as the target log template vector; wherein, the target log template is generated using a preset weighted longest common subsequence matching model;
[0008] The vehicle log data is segmented using a sliding window to obtain the segmentation result. The segmentation result is then processed using the target log template vector to obtain the training dataset.
[0009] A preset neural network is trained based on the dataset to be trained to obtain the vehicle log detection model.
[0010] Furthermore, the process of acquiring the vehicle system logs to be detected, generating corresponding vehicle system log data, and performing fine-grained processing on the vehicle system log data to obtain refined log data includes:
[0011] Based on the preset log format standard, the vehicle log to be detected is parsed to generate the corresponding vehicle log data;
[0012] The vehicle log data is transformed to obtain structured log data;
[0013] Based on preset standards, the log version, log parameters, log content, log date, log time and / or log level in the structured log data are refined, and the combination word separation, file path identification, IP address identification and numeric string identification are also performed to obtain the refined log data.
[0014] Furthermore, the process of generating the target log template includes:
[0015] Obtain any fine-grained log from the fine-grained log data;
[0016] Based on a preset similarity formula, the similarity between any of the refined logs and all log templates in the preset log template library is calculated to obtain multiple similarity values;
[0017] Determine whether the maximum value among the multiple similarity values is greater than a preset threshold;
[0018] If so, update the preset log template library based on any of the refined logs, and obtain the target log template according to the updated preset log template library.
[0019] Furthermore, the preset similarity formula is:
[0020]
[0021]
[0022] Where a is the weight corresponding to the log subsystem word, b is the weight corresponding to other words, x[i] is the i-th word of the template sequence, y[j] is the j-th word of the sequence to be calculated, J is the length of the sequence to be calculated, and I is the length of the template sequence.
[0023] Furthermore, the step of determining the word vectors of log words in the target log template based on the refined log data, and using the weighted average of the word vectors of the log words as the target log template vector, includes:
[0024] Based on a pre-defined continuous bag-of-words model, word vectors are trained on the refined log data to obtain the trained refined log data.
[0025] Based on the preset template vector calculation formula, the word vector of each log word in the target log template is calculated according to the refined log data after training.
[0026] The weighted average of the word vectors of the log words is used as the target log template vector.
[0027] Furthermore, the vehicle log data is segmented using a sliding window to obtain a segmentation result. The segmentation result is then processed using the target log template vector to obtain a training dataset, including:
[0028] Each log entry in the target log template is template-encoded, and each log entry is mapped to the corresponding template address;
[0029] A preset sequence segmentation strategy is used to segment the vehicle log data using a sliding window to obtain the template address to be input;
[0030] Based on the target log template vector, the template address to be input is expanded into a target input vector;
[0031] The training dataset is obtained based on the target input vector.
[0032] A second aspect of the present invention provides a vehicle log detection model training device, comprising:
[0033] The log acquisition module is used to acquire the vehicle system logs to be detected, generate vehicle system log data corresponding to the vehicle system logs, and perform fine-grained processing on the vehicle system log data to obtain fine-grained log data.
[0034] The vector determination module is used to determine the word vectors of log words in the target log template based on the refined log data, and to use the weighted average of the word vectors of the log words as the target log template vector; wherein, the target log template is generated using a preset weighted longest common subsequence matching model;
[0035] The data processing module is used to perform sliding window segmentation on the vehicle log data to obtain the segmentation result, and to process the segmentation result using the target log template vector to obtain the training dataset.
[0036] The training model module is used to train a preset neural network based on the dataset to be trained, so as to obtain the vehicle log detection model.
[0037] Furthermore, the log acquisition module includes:
[0038] The generation submodule is used to parse the vehicle logs to be detected based on a preset log format standard and generate the vehicle log data corresponding to the vehicle logs.
[0039] The conversion submodule is used to convert the vehicle log data to obtain structured log data;
[0040] The processing submodule is used to perform fine-grained processing on the log version, log parameters, log content, log date, log time and / or log level in the structured log data based on preset standards, as well as to identify combined words, file paths, IP addresses and numeric strings to obtain the fine-grained log data.
[0041] A third aspect of the present invention provides an electronic device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the vehicle log detection model training method as described in the above embodiments.
[0042] A fourth aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon, which is executed by a processor to implement the vehicle log detection model training method as described in the above embodiments.
[0043] Beneficial effects of the embodiments of the present invention:
[0044] The vehicle-mounted system log detection model training method provided in this invention involves acquiring the vehicle-mounted system logs to be detected, generating corresponding vehicle-mounted system log data, refining the vehicle-mounted system log data to obtain refined log data, determining the word vectors of log words in the target log template based on the refined log data, and using the weighted average of the word vectors of the log words as the target log template vector. The vehicle-mounted system log data is then segmented using a sliding window to obtain the segmentation result. The segmentation result is processed using the target log template vector to obtain the training dataset. A preset neural network is trained based on the training dataset to obtain the vehicle-mounted system log detection model. This invention uses a weighted optimized longest common subsequence model for log event extraction, increasing the computational weight of key log fields and improving the accuracy of log event extraction. It solves the problems in related technologies where the log data preprocessing module does not incorporate regularization processing based on the log data itself, and the log template matching stage does not incorporate weighting based on the log structure, leading to prediction bias and thus improving the accuracy of log anomaly detection. Attached Figure Description
[0045] The above and / or additional aspects and advantages of the present invention will become apparent and readily understood from the following description of the embodiments taken in conjunction with the accompanying drawings, wherein:
[0046] Figure 1 This is a flowchart illustrating the steps of a vehicle log detection model training method provided in an embodiment of the present invention.
[0047] Figure 2 A flowchart illustrating the generation of a log template according to an embodiment of the present invention;
[0048] Figure 3 This is a schematic diagram of structured log data according to an embodiment of the present invention;
[0049] Figure 4 This is a schematic diagram of the word2vector model structure in the vehicle log detection model training method of an embodiment of the present invention;
[0050] Figure 5 This is a flowchart of a vehicle log detection model training method according to an embodiment of the present invention;
[0051] Figure 6 This is a schematic diagram of the structure of the vehicle log detection model training device according to an embodiment of the present invention;
[0052] Figure 7 This is a schematic diagram of the structure of an electronic device according to an embodiment of the present invention. Detailed Implementation
[0053] Embodiments of the present invention are described in detail below, examples of which are illustrated in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain the present invention, and should not be construed as limiting the present invention.
[0054] The following description, with reference to the accompanying drawings, outlines a vehicle-mounted system log detection model training method, apparatus, electronic device, and storage medium according to embodiments of the present invention. Addressing the issues mentioned in the background art, such as the log data preprocessing module not performing regularization on the log data itself, the log template matching stage not incorporating log structure for weighting, and the prediction model's failure to adjust for prediction bias caused by uneven log distribution, the present invention provides a vehicle-mounted system log detection model training method. In this method, by refining the vehicle-mounted system log data and combining it with a target log template generated using a preset weighted longest common subsequence matching model, a training dataset is obtained. A preset neural network is then trained based on this training dataset to obtain the vehicle-mounted system log detection model, thereby improving the accuracy of log anomaly detection.
[0055] Reference Figure 1 , Figure 1 This is a flowchart illustrating the steps of a vehicle log detection model training method provided in an embodiment of the present invention, as follows: Figure 1 As shown, the training method for the vehicle log detection model includes the following steps:
[0056] Step 101: Obtain the vehicle log to be detected, generate vehicle log data corresponding to the vehicle log, and perform fine-grained processing on the vehicle log data to obtain refined log data.
[0057] It should be noted that, in order to make the log detection value of the log data to be detected more accurate by inputting the model input vector into the vehicle log detection model based on the log data to be detected, this embodiment of the invention trains a preset neural network based on the vehicle log to be detected and the training dataset to obtain an accurate output vehicle log detection model.
[0058] In this embodiment of the invention, the test log data printed by the vehicle infotainment system during operation is obtained. The vehicle infotainment system refers to the in-vehicle infotainment product installed in a car, which enables information communication between people and the vehicle, and between the vehicle and the outside world (vehicle-to-vehicle communication).
[0059] Step 102: Based on refined log data, determine the word vectors of log words in the target log template, and use the weighted average of the word vectors of the log words as the target log template vector;
[0060] The target log template is generated using a preset weighted longest common subsequence matching model.
[0061] Specifically, the method based on the preset weighted longest common subsequence involves weighting the words of the corresponding subsystems in the log data, while leaving the remaining words unweighted. The result is used to characterize the similarity between two templates, and the calculation formula is as follows:
[0062]
[0063]
[0064] Where a is the weight corresponding to the log subsystem word, b is the weight corresponding to other words, x[i] is the i-th word of the template sequence, y[j] is the j-th word of the sequence to be calculated, J is the length of the sequence to be calculated, and I is the length of the template sequence.
[0065] When calculating the threshold, the `code_cls` matching is weighted accordingly. This field represents the subsystem or module where the log belongs. In the experiment, the weights of `code_cls` and `content` were set to a = 1.5 and b = 1. For example, the similarity value of the sentence "EryaAudioManger isInMyFocus false status" relative to the template "EryaAudioManger isInMyFocus*status" is 0.875 ((1.5+1+1) / 4). Its dynamic programming process is shown in Table 1.
[0066] Table 1
[0067] EryaAudioManger isInMyFocus false status 0 0 0 0 0 EryaAudioManger 0 1.5 1.5 1.5 1.5 isInMyFocus 0 1.5 2.5 2.5 2.5 * 0 1.5 2.5 2.5 2.5 status 0 1.5 2.5 2.5 3.5
[0068] Further, in some embodiments, based on the regularized log data, word vectors of each log word in the target log template are calculated, and the weighted average of the word vectors of each log word is used as the target log template vector. This includes: training word vectors on the regularized log data based on a preset continuous bag-of-words (COBW) model word2vector model to obtain trained regularized log data; and calculating word vectors of each log word in the target log template using the trained regularized log data based on a preset template vector calculation formula, wherein the preset template vector calculation formula is:
[0069]
[0070] Among them, WordVec i is the word vector, and l is the template length.
[0071] It should be understood that, such as Figure 4 As shown, based on the log data after regularization, the word vector of each log word is calculated using the word2vector model based on CBOW (Continuous Bag Of Words). The weighted average of the word vectors of the entire log template is then used as the vector of the log template.
[0072] Specifically, the process of generating the target log template based on the preset weighted longest common subsequence matching model, which uses dynamic programming to solve for the longest common subsequence, is as follows: Figure 2 As shown, by writing log data, word segmentation is performed to determine whether a word exists in the template library. Log length and template length are compared, and a matching threshold is set to generate a log template. If the word does not exist in the template library, non-common words are replaced with '*', consecutive non-common words are marked with a single '*', and each log entry is matched to the corresponding log template. The extraction result from the log template in this embodiment is as follows: Figure 2 As shown.
[0073] Step 103: Perform sliding window segmentation on the vehicle log data to obtain the segmentation results. Use the target log template vector to process the segmentation results to obtain the training dataset.
[0074] Step 104: Train a preset neural network based on the dataset to be trained to obtain the vehicle log detection model.
[0075] In some embodiments, before inputting the vehicle-mounted log detection model, vehicle-mounted log data is acquired, converted into structured log data, and regularized to obtain regularized log data. A target log template is generated based on a preset weighted longest common subsequence matching model. Based on the regularized log data, word vectors for each log word in the target log template are calculated, and the weighted average of the word vectors is used as the target log template vector. The vehicle-mounted log data is then segmented using a sliding window, and the segmentation result is expanded using the target log template vector to obtain a training dataset. A preset model is then trained using this training dataset.
[0076] A neural network is used to obtain a log anomaly detection model, which is used to identify the current vehicle system log data and generate log detection results.
[0077] The vehicle-mounted system log detection model training method provided in this invention involves acquiring the vehicle-mounted system logs to be detected, generating corresponding vehicle-mounted system log data, refining the vehicle-mounted system log data to obtain refined log data, determining the word vectors of log words in the target log template based on the refined log data, and using the weighted average of the word vectors of the log words as the target log template vector. The vehicle-mounted system log data is then segmented using a sliding window to obtain the segmentation result. The segmentation result is processed using the target log template vector to obtain the training dataset. A preset neural network is trained based on the training dataset to obtain the vehicle-mounted system log detection model. This invention uses a weighted optimized longest common subsequence model for log event extraction, increasing the computational weight of key log fields and improving the accuracy of log event extraction. It solves the problems in related technologies where the log data preprocessing module does not incorporate regularization processing based on the log data itself, and the log template matching stage does not incorporate weighting based on the log structure, leading to prediction bias and thus improving the accuracy of log anomaly detection.
[0078] Furthermore, the vehicle system logs to be detected are obtained, corresponding vehicle system log data is generated, and the vehicle system log data is refined to obtain refined log data, including:
[0079] Based on the preset log format standard, the vehicle log to be detected is parsed to generate the corresponding vehicle log data;
[0080] The vehicle log data is transformed to obtain structured log data;
[0081] Based on preset standards, the log version, log parameters, log content, log date, log time and / or log level in the structured log data are refined, and the combination word separation, file path identification, IP address identification and numeric string identification are also performed to obtain the refined log data.
[0082] The process of generating the target log template includes:
[0083] Obtain any fine-grained log from the fine-grained log data;
[0084] Based on a preset similarity formula, the similarity between any of the refined logs and all log templates in the preset log template library is calculated to obtain multiple similarity values;
[0085] Determine whether the maximum value among the multiple similarity values is greater than a preset threshold;
[0086] If so, update the preset log template library based on any of the refined logs, and obtain the target log template according to the updated preset log template library.
[0087] Furthermore, the step of determining the word vectors of log words in the target log template based on the refined log data, and using the weighted average of the word vectors of the log words as the target log template vector, includes:
[0088] Based on a pre-defined continuous bag-of-words model, word vectors are trained on the refined log data to obtain the trained refined log data.
[0089] Based on the preset template vector calculation formula, the word vector of each log word in the target log template is calculated according to the refined log data after training.
[0090] The weighted average of the word vectors of the log words is used as the target log template vector.
[0091] Specifically, in this embodiment of the invention, vehicle log data is acquired, converted into structured log data, and refined into refined log data.
[0092] In some embodiments, the vehicle log data is converted into structured log data, including: automatically parsing the vehicle log data based on a preset log format standard to obtain structured log data.
[0093] Specifically, this embodiment of the invention acquires vehicle system log data printed during vehicle operation. The vehicle system log data includes the date, time, process ID, thread ID, log level, log tag, and log content. According to the Android standard, the log levels, from highest to lowest, are ERROR, WARN, INFO, DEBUG, and VERBOSE.
[0094] The preset log format standard can be a standard set by those skilled in the art. For example, the main format of the preset log format standard is: date, time, process number, thread number, log level, log tag, and log content. In this embodiment of the invention, the vehicle log data is parsed and formatted into a dataframe (a type of distributed dataset) file to obtain structured log data.
[0095] Specifically, the log format after structuring the original vehicle system log data can be as follows: Figure 3 As shown in the diagram. Here, date represents the date, time represents the specific time, code_1 represents the system process ID, code_2 represents the system thread ID, tag represents the standard Android log level, code_cls represents the category of the corresponding subsystem, and content represents the detailed log content.
[0096] Furthermore, in some embodiments, the structured data is refined to obtain refined log data, including: refining the log version, log parameters, log content, log date, log time and / or log level in the structured data based on a preset unified standard, as well as combining word separation, file path identification, IP address identification and numeric string identification to obtain refined log data.
[0097] Among them, word delimiter is determined by whether the string contains "uppercase letters, -, _, #" excluding the first and last characters. File path, IP address and numeric string recognition are performed using regular expression methods.
[0098] Furthermore, the vehicle log data is segmented using a sliding window to obtain a segmentation result. The segmentation result is then processed using the target log template vector to obtain a training dataset, including:
[0099] Each log entry in the target log template is template-encoded, and each log entry is mapped to the corresponding template address;
[0100] A preset sequence segmentation strategy is used to segment the vehicle log data using a sliding window to obtain the template address to be input;
[0101] Based on the target log template vector, the template address to be input is expanded into a target input vector;
[0102] The training dataset is obtained based on the target input vector.
[0103] The vehicle-mounted system log detection model training method proposed in this invention involves acquiring the vehicle-mounted system logs to be detected, generating corresponding vehicle-mounted system log data, refining the log data to obtain refined log data, determining the word vectors of log words in the target log template based on the refined log data, and using the weighted average of the word vectors of the log words as the target log template vector. The vehicle-mounted system log data is then segmented using a sliding window to obtain the segmentation result. The segmentation result is further processed using the target log template vector to obtain the training dataset. A preset neural network is then trained based on the training dataset to obtain the vehicle-mounted system log detection model. This invention uses a weighted optimized longest common subsequence model for log event extraction, increasing the computational weight of key log fields and improving the accuracy of log event extraction. It addresses issues in related technologies, such as the log data preprocessing module not incorporating regularization into the log data itself and the log template matching stage not incorporating weighting based on the log structure, leading to prediction bias and thus improving the accuracy of log anomaly detection.
[0104] To enable those skilled in the art to further understand the vehicle log detection model training method of the present invention, the following detailed description is provided in conjunction with specific embodiments, such as... Figure 5 As shown.
[0105] First, during the training phase, logs generated during normal device operation are collected to obtain the training set. The specific steps are as follows:
[0106] Step 1: Obtain the logs printed during normal device operation, convert the log structure into dataframe structured data, and preprocess log version, log parameters, special symbols and other issues through the log regularization module;
[0107] Step 2: Use the optimized weighted longest common subsequence module to train log templates based on the training set, and generate a matching log template ID for each log content in the training set;
[0108] Step 3: Using a COBW-based word2vector model, word vectors are trained on the regularized log data. A weighted average of the word vectors is used to calculate the log template vector for each template, corresponding one-to-one with the template ID. This yields the template, ID, and log vector for each log entry.
[0109] Step 4: Set the window length h (in the experiment, the range is 5-8), and the step size s = 1 (i.e., the sliding window step size is 1). Extract training sample data for each log sequence by sliding the window. Each time the window is slid, a training sample is obtained. Match each sequence sample to the corresponding log template id. Combine the samples to obtain the training set and validation set.
[0110] Step 5: Train the model network using the training data and the S-LSTM algorithm framework to obtain the prediction model.
[0111] Taking h=5 as an example, where X train Each template ID (20 / 21 / 22 / 23 / 24 / 25) is converted into a corresponding 512-dimensional vector during training. train Preserve the template ID, do not use the template vector. The entire training process is a self-learning process based on the sample dataset. The output layer uses softmax, minimizing the predicted output. and actual output Y train The model is trained using the squared loss error, and the trained model parameters are saved for use in the subsequent inference stage.
[0112] During the inference phase (i.e., the anomaly detection phase), the trained model parameters are loaded to predict anomalies in the input content. Let the input template sequence w = [20, 21, 22, 23]. After model calculation, the resulting conditional probability distribution is {24: 0.7595, 34: 0.2103, ..., 5: 0.0001}, ordered in descending order of probability. In actual log printing, there are cases where the same input sequence corresponds to multiple different outputs, such as conditional statements. These types of logs are not considered anomalous logs. Therefore, a more reasonable approach is to extract N results with probability values greater than a given threshold. If the newly generated template is among these N results, the corresponding log is considered normal; otherwise, it is considered an anomalous log.
[0113] As can be seen from the above process of collecting training data, the entire process only requires that the training data come from logs from normal system operation or where the proportion of failures is very small. Data labels are automatically generated by the log template matching model and do not require manual annotation; therefore, the log anomaly detection model can be considered an unsupervised deep learning model.
[0114] The vehicle log detection model training method proposed in this embodiment of the invention performs regularization processing on the log data to be detected, matches the corresponding log template based on the regularized log data, constructs a model input vector based on the template vector of the corresponding log template, and inputs it into a pre-constructed log anomaly detection model to obtain the log detection value of the log data to be detected. When the log detection value is greater than a preset threshold, the log data to be detected is determined to be a normal log; otherwise, the log data to be detected is determined to be an abnormal log. This solves the problems in related technologies, such as the log data preprocessing module not performing regularization processing based on the log data itself, the log template matching stage not incorporating log structure for weighting, and the prediction model not adjusting for prediction bias caused by uneven log distribution. It can effectively improve the model's understanding of log templates and characterize the correlation between templates, thereby improving the accuracy of anomaly detection.
[0115] Reference Figure 6 The diagram illustrates the structure of a vehicle log detection model training device provided in an embodiment of the present invention. The device may include:
[0116] The log acquisition module 301 is used to acquire the vehicle system logs to be detected, generate vehicle system log data corresponding to the vehicle system logs, and perform fine-grained processing on the vehicle system log data to obtain fine-grained log data.
[0117] The vector determination module 302 is used to determine the word vectors of log words in the target log template based on the refined log data, and to use the weighted average of the word vectors of the log words as the target log template vector; wherein, the target log template is generated using a preset weighted longest common subsequence matching model;
[0118] Data processing module 303 is used to perform sliding window segmentation on the vehicle log data to obtain segmentation results, and to process the segmentation results using the target log template vector to obtain the training dataset;
[0119] The training model module 304 is used to train a preset neural network based on the dataset to be trained to obtain the vehicle log detection model.
[0120] Furthermore, the log acquisition module 301 includes:
[0121] The generation submodule is used to parse the vehicle logs to be detected based on a preset log format standard and generate the vehicle log data corresponding to the vehicle logs.
[0122] The conversion submodule is used to convert the vehicle log data to obtain structured log data;
[0123] The processing submodule is used to perform fine-grained processing on the log version, log parameters, log content, log date, log time and / or log level in the structured log data based on preset standards, as well as to identify combined words, file paths, IP addresses and numeric strings to obtain the fine-grained log data.
[0124] Furthermore, the process of generating the target log template includes:
[0125] The acquisition submodule is used to acquire any fine-grained log from the fine-grained log data;
[0126] The similarity calculation submodule is used to calculate the similarity between any refined log and all log templates in the preset log template library based on a preset similarity formula, and obtain multiple similarity values.
[0127] The judgment submodule is used to determine whether the maximum value among the multiple similarity values is greater than a preset threshold.
[0128] The update submodule is used to update the preset log template library based on any of the refined logs, and obtain the target log template according to the updated preset log template library.
[0129] Furthermore, the preset similarity formula is:
[0130]
[0131]
[0132] Where a is the weight corresponding to the log subsystem word, b is the weight corresponding to other words, x[i] is the i-th word of the template sequence, y[j] is the j-th word of the sequence to be calculated, J is the length of the sequence to be calculated, and I is the length of the template sequence.
[0133] Furthermore, the vector determination module 302 includes:
[0134] The first training submodule is used to train word vectors on the refined log data based on a preset continuous bag-of-words model to obtain the trained refined log data.
[0135] The calculation submodule is used to calculate the word vector of each log word in the target log template based on the preset template vector calculation formula and the refined log data after training.
[0136] A vector determination submodule is used to take the weighted average of the word vectors of the log words as the target log template vector.
[0137] Furthermore, the data processing module 303 includes:
[0138] The encoding submodule is used to perform template encoding on each log entry based on the target log template, and to map each log entry to the corresponding template address;
[0139] The segmentation submodule is used to perform sliding window segmentation on the vehicle log data using a preset sequence segmentation strategy to obtain the template address to be input;
[0140] The vector processing submodule is used to expand the template address to be input into a target input vector based on the target log template vector;
[0141] The training dataset submodule is used to obtain the training dataset based on the target input vector.
[0142] The vehicle-mounted system log detection model training method proposed in this invention involves acquiring the vehicle-mounted system logs to be detected, generating corresponding vehicle-mounted system log data, refining the log data to obtain refined log data, determining the word vectors of log words in the target log template based on the refined log data, and using the weighted average of the word vectors of the log words as the target log template vector. The vehicle-mounted system log data is then segmented using a sliding window to obtain the segmentation result. The segmentation result is further processed using the target log template vector to obtain the training dataset. A preset neural network is then trained based on the training dataset to obtain the vehicle-mounted system log detection model. This invention uses a weighted optimized longest common subsequence model for log event extraction, increasing the computational weight of key log fields and improving the accuracy of log event extraction. It addresses issues in related technologies, such as the log data preprocessing module not incorporating regularization into the log data itself and the log template matching stage not incorporating weighting based on the log structure, leading to prediction bias and thus improving the accuracy of log anomaly detection.
[0143] This invention also provides an electronic device, such as... Figure 7 As shown, it includes a processor 401, a communication interface 402, a memory 403, and a communication bus 404, wherein the processor 401, the communication interface 402, and the memory 403 communicate with each other through the communication bus 404.
[0144] Memory 403 is used to store computer programs;
[0145] When the processor 401 executes the program stored in the memory 403, it implements the following vehicle log detection model training steps.
[0146] The communication bus mentioned above can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into address bus, data bus, control bus, etc. For ease of illustration, only one thick line is used to represent it in the diagram, but this does not mean that there is only one bus or one type of bus.
[0147] The communication interface is used for communication between the aforementioned terminal and other devices.
[0148] The memory may include random access memory (RAM) or non-volatile memory, such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.
[0149] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0150] In another embodiment of the present invention, a computer-readable storage medium is also provided, which stores instructions that, when executed on a computer, cause the computer to perform the vehicle log detection model training method described in any of the above embodiments.
[0151] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the present invention are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid state disk (SSD)).
[0152] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0153] The various embodiments in this specification are described in a related manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the system embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions of the method embodiments.
[0154] The above description is merely a preferred embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention are included within the scope of protection of the present invention.
Claims
1. A method for training a vehicle log detection model, characterized in that, The method includes: Obtain the vehicle system logs to be detected, generate vehicle system log data corresponding to the vehicle system logs, and perform fine-grained processing on the vehicle system log data to obtain fine-grained log data; Based on the refined log data, the word vectors of log words in the target log template are determined, and the weighted average of the word vectors of the log words is used as the target log template vector; wherein, the target log template is generated using a preset weighted longest common subsequence matching model; the method based on the preset weighted longest common subsequence is to perform weighted calculation on the words of the corresponding subsystem of the log data, while the remaining words are not weighted, and the calculation result is used to characterize the similarity between the two templates; The vehicle log data is segmented using a sliding window to obtain the segmentation result. The segmentation result is then processed using the target log template vector to obtain the training dataset. A preset neural network is trained based on the dataset to be trained to obtain the vehicle log detection model; The process of acquiring the vehicle system logs to be detected, generating corresponding vehicle system log data, and performing fine-grained processing on the vehicle system log data to obtain refined log data includes: Based on the preset log format standard, the vehicle log to be detected is parsed to generate the vehicle log data corresponding to the vehicle log. The vehicle log data is transformed to obtain structured log data; Based on preset standards, the log version, log parameters, log content, log date, log time and / or log level in the structured log data are refined, and the combination word separation, file path identification, IP address identification and numeric string identification are also performed to obtain the refined log data.
2. The method according to claim 1, characterized in that, The process of generating the target log template includes: Obtain any fine-grained log from the fine-grained log data; Based on a preset similarity formula, the similarity between any refined log and all log templates in the preset log template library is calculated to obtain multiple similarity values; Determine whether the maximum value among the multiple similarity values is greater than a preset threshold; If so, update the preset log template library based on any of the refined logs, and obtain the target log template according to the updated preset log template library.
3. The method according to claim 2, characterized in that, The preset similarity formula is: ; ; in, The weights corresponding to the terms in the log subsystem. The weights corresponding to other words, For the template sequence number One word, For the sequence to be calculated One word, Let be the length of the sequence to be calculated. The length of the template sequence.
4. The method according to claim 1, characterized in that, The step of determining the word vectors of log words in the target log template based on the refined log data, and using the weighted average of the word vectors of the log words as the target log template vector, includes: Based on a pre-defined continuous bag-of-words model, word vectors are trained on the refined log data to obtain the trained refined log data. Based on the preset template vector calculation formula, the word vector of each log word in the target log template is calculated according to the refined log data after training. The weighted average of the word vectors of the log words is used as the target log template vector.
5. The method according to claim 1, characterized in that, The vehicle log data is segmented using a sliding window to obtain a segmentation result. The segmentation result is then processed using the target log template vector to obtain a training dataset, including: Each log entry in the target log template is template-encoded, and each log entry is mapped to the corresponding template address; A preset sequence segmentation strategy is used to segment the vehicle log data using a sliding window to obtain the template address to be input; Based on the target log template vector, the template address to be input is expanded into a target input vector; The training dataset is obtained based on the target input vector.
6. A vehicle log detection model training device, characterized in that, The device includes: The log acquisition module is used to acquire the vehicle system logs to be detected, generate vehicle system log data corresponding to the vehicle system logs, and perform fine-grained processing on the vehicle system log data to obtain fine-grained log data. The vector determination module is used to determine the word vectors of log words in the target log template based on the refined log data, and to use the weighted average of the word vectors of the log words as the target log template vector; wherein, the target log template is generated using a preset weighted longest common subsequence matching model; the method based on the preset weighted longest common subsequence is to perform weighted calculation on the words of the corresponding subsystem of the log data, while the remaining words are not weighted, and the calculation result is used to characterize the similarity between the two templates; The data processing module is used to perform sliding window segmentation on the vehicle log data to obtain the segmentation result, and to process the segmentation result using the target log template vector to obtain the training dataset. The training model module is used to train a preset neural network based on the dataset to be trained, so as to obtain the vehicle log detection model. The log acquisition module includes: The generation submodule is used to parse the vehicle logs to be detected based on a preset log format standard and generate the vehicle log data corresponding to the vehicle logs. The conversion submodule is used to convert the vehicle log data to obtain structured log data; The processing submodule is used to perform fine-grained processing on the log version, log parameters, log content, log date, log time and / or log level in the structured log data based on preset standards, as well as to identify combined words, file paths, IP addresses and numeric strings to obtain the fine-grained log data.
7. An electronic device, characterized in that, include: The system includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the vehicle log detection model training method as described in any one of claims 1-5.
8. A computer storage medium having a computer program stored thereon, characterized in that, The program is executed by the processor for use in implementing the vehicle log detection model training method as described in any one of claims 1-5.
Citation Information
Patent Citations
Method for extracting computer software log template on line
CN112560407A
Abnormality Detection System and Abnormality Detection Method
US20180075235A1
