Semantic log analysis system based on large language model
By designing a combination of subword feature extraction, semantic recognition and parse tree modules on a large language model, the deficiencies of the log parsing method in terms of generalization, efficiency and privacy protection are solved, and semantic parsing and parsing of log templates and parameters are realized. Label prediction meets the needs for efficient processing of complex log data.
Patent Information
- Application Number
- CN202410559790.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-08
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2044-05-08
AI Technical Summary
Existing log parsing methods have deficiencies in generalization, efficiency, and privacy protection. Traditional methods are difficult to meet the needs of efficient parsing and semantic understanding of complex log data. Methods based on large language models have high calling costs and runtime overhead, and Large-scale real-time logs cannot be effectively processed.
A semantic log parsing system based on a large language model is designed, including a subword feature extraction module, a semantic recognition module and a parsing tree module. The LLAMA2 model is modified to remove the causal mask, and a multi-head cross-attention mechanism and tree structure storage are used. Implement semantic parsing and label prediction of log templates and parameters, and perform efficient template matching and updating during the inference phase.
It achieves high-precision analysis on logs from different sources, has good generalization and stability, can maintain high efficiency in large-scale real-time logs, avoids network delays and privacy issues, and adapts to the needs of complex downstream tasks.
Smart Images

Figure CN118606286A
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of natural language processing, and in particular relates to a semantic log parsing system based on a large language model. Background Art
[0002] Log parsing is a key step in automated log analysis. The goal is to convert unstructured or semi-structured raw logs into a structured format for further management, understanding, and analysis tasks. Current log parsing methods can be roughly divided into three categories: unsupervised methods, supervised methods, and methods based on large language models. Unsupervised methods use strategies such as frequent pattern mining, log clustering, and heuristic methods to extract the invariant parts of logs as templates. Supervised methods use natural language processing technology to train models using labeled log data. Both methods have the problem of poor generalization: as logs change, unsupervised methods need to adjust rules and a large number of hyperparameters, while supervised methods need to retrain models. Methods based on large language models utilize pre-trained knowledge in large language models to improve model generalization. However, most of the existing log parsers based on large language models rely on OpenAI's online API interface, which is greatly affected by network latency fluctuations and ChatGPT version changes. In addition, log data usually contains a large amount of private business information, and the use of online API interfaces will lead to privacy issues.
[0003] On the other hand, traditional log parsers focus on extracting log templates while ignoring the rich semantic information contained in log variables. In other words, they can only distinguish constants and variables in logs without further understanding and analyzing the variables. With the development of artificial intelligence in the IT industry, the demand for downstream tasks such as anomaly detection, root cause analysis, and log summarization is growing, and traditional parsers that only extract log templates can no longer meet these needs.
[0004] In addition, with the rapid development of software systems, logs in real scenarios are becoming increasingly large and complex. In real production environments, software systems generate tens of thousands of logs per second. Although existing supervised parsers have surpassed traditional unsupervised parsers in parsing accuracy, their low operating efficiency limits their application in real-world scenarios. Log parsers based on large language models face the same challenge: despite their powerful functionality and good generalization capabilities, their high call cost and runtime overhead make it impractical to directly use large language models to parse large amounts of real-time logs.
[0005] In summary, it is urgent to design a log parsing method that can run offline, has good generalization, can maintain high parsing accuracy and stability for logs from different sources, and does not require additional adjustments. It needs to have semantic log parsing capabilities, be able to predict the semantics of log parameters while extracting log templates, and output semantic labels of log templates and log parameters for downstream tasks. In addition, it needs to have high parsing efficiency when facing large-scale real-time logs of large software systems. Summary of the invention
[0006] The purpose of the present invention is to provide a semantic log parsing system based on a large language model with high accuracy and good stability.
[0007] The semantic log parsing system based on a large language model provided by the present invention comprises the following modules: a subword feature extraction module, a semantic recognition module, and a parse tree module; wherein:
[0008] The subword feature extraction module is used for word segmentation and log subword feature extraction; log parsing is used as a sequence labeling task; the structure of LLAMA2 is adapted to the parsing task by removing the causal mask, and the rich knowledge of the large language model is used to extract accurate feature representation for each subword;
[0009] The semantic recognition module, based on a multi-head cross-attention mechanism, integrates the features of each subword, and then extracts the log template and predicts the semantic category of the log parameter;
[0010] The parsing tree module stores the parsed templates in a tree structure, is built and updated synchronously with the parsing process, and is used to accelerate the reasoning process of large-scale real-time logs.
[0011] Further:
[0012] The subword feature extraction module includes an LLAMA2 word segmenter and an LLAMA2 model with causal mask deleted (hereinafter referred to as LogLLAMA). LogLLAMA is connected to the LLAMA2 word segmenter. The LLAMA2 word segmenter accepts an original log sentence as input and divides it into several words, each word is divided into several subwords, and each subword is identified by a unique identifier. The number of subwords in each log sentence is limited, and if there are more, they are truncated, and if there are fewer, they are filled with specific subwords; LogLLAMA accepts these subwords as input and extracts the features of each subword.
[0013] Large language models including LLAMA2 are usually designed for text generation tasks, but directly using large language models to generate templates based on logs often leads to errors such as incomplete parameter identification, inclusion of irrelevant text, or misaligned log structures. However, for log parsing tasks, accuracy is critical, and even small deviations may seriously affect downstream tasks such as anomaly detection. Therefore, text generation methods are not suitable for log parsing; this paper regards log parsing as a sequence labeling task.
[0014] On the other hand, directly applying instruction fine-tuning to sequence labeling tasks on large language models leads to poor results. This is because large language models usually adopt a decoder-only autoregressive architecture and use causal masks in the decoder to prevent information leakage during text generation. This mechanism only allows the model to access unidirectional information, limiting its ability to perceive context when extracting sub-word features.
[0015] Therefore, in the present invention, LogLLAMA modifies the structure of LLAMA2, such as Figure 2 As shown in the figure, specifically, the LLAMA2 includes: N layers of multi-head self-attention layers with causal masks, and LogLLAMA includes N layers of multi-head self-attention layers, that is, the causal masks are removed; removing the causal masks enables the model to perceive the entire context of the log when extracting the current sub-word features. This design can ensure that the model has a consistent and comprehensive understanding of the log and improve the performance of large language models in log parsing.
[0016] In the training phase, LogLLAMA uses the Lora method to efficiently fine-tune parameters to adapt it to log parsing tasks. In the inference phase, it can be directly applied to log data from various sources without additional fine-tuning.
[0017] The semantic recognition module includes a multi-head attention network and a fully connected network, and the fully connected network is connected after the multi-head attention network.
[0018] Conventional sequence labeling tasks use the first subword of each word for feature extraction and classification, but this method is not suitable for log parsing because the length of log words is usually much longer than that of ordinary words. Using only the first subword will lead to semantic loss, which is not conducive to subsequent semantic log parsing. In order to solve this problem, the semantic recognition module of the present invention adopts a multi-head cross-attention mechanism for feature fusion, so that the word feature can take into account the features of each subword.
[0019] like Figure 1 As shown in Figure 2, the multi-head attention network aggregates all sub-word features of each word into a word feature. Specifically, for the i-th log word, its corresponding word feature The calculation is as follows:
[0020]
[0021] Among them, V SA V is an additional, learnable aggregation vector used to aggregate subword features. As training progresses, V SA The learnability of H enables it to be continuously optimized based on training logs, making it more and more suitable for semantic parsing. i1 ,H i2 ,…,H in is the feature of each subword; W Q , W K , W V is a learnable weight parameter; Attn() is a standard multi-head attention function. When performing feature aggregation on each word, V SA , W Q , W K , W V The parameters involved in the function Attn() are shared to enhance the model's transfer learning and pattern recognition capabilities. In particular, the calculation formula for the standard multi-head attention is:
[0022] Attn(Q,K,V)=Concat(head1,…,head h )W O , (2)
[0023] Among them, the function Concat() represents matrix concatenation, W O are learnable parameters, head1,…,head h For different attention heads, the calculation formula is:
[0024]
[0025]
[0026] Among them, d k is the dimension of k.
[0027] The multi-head attention network outputs the features of each word The fully connected network performs log semantic classification on each word based on these features. Assuming that the total number of semantic categories of a word is K, the fully connected layer maps the word features to K dimensions. In the present invention, the total number of semantic categories K is 17, including one template constant category and 16 parameter semantic categories, which are specifically defined as follows:
[0028]
[0029]
[0030] During training, the cross entropy loss CE_Loss of each word is calculated. Specifically, for a certain word, its word feature is Then its loss function is:
[0031]
[0032] Among them, K is the total number of semantic categories of words, and the function FC() is a fully connected network. The model predicts the probability that the word belongs to label i. i is the true label corresponding to the word, that is:
[0033]
[0034] In the reasoning stage, considering the ambiguity and ambiguity of log semantics, the following prediction strategy is adopted: for words predicted as parameters (the category corresponding to the maximum prediction probability belongs to parameters), the top three parameter semantic categories with the highest prediction probability are retained as the results; for words predicted as template constants, their template constant categories are retained as the prediction results.
[0035] The parse tree module uses a tree structure similar to but different from the prefix tree to store log templates: the root node of the parse tree does not store content; each intermediate node is a template word or a placeholder "<*>" representing a parameter; each leaf node is a log template library, storing a number of log templates containing parameter semantic tags.
[0036] The present invention introduces a parsing tree module to accelerate model reasoning, which is based on the fact that in real scenarios, many logs are the same, or only slightly different in a few parameters, because they come from the same log template. Therefore, for a new log, it is very likely to correspond to a template that has been parsed before. If each template obtained can be stored during the reasoning process and these templates are queried before each parsing, the result can be obtained directly, thereby accelerating the reasoning process.
[0037] like Figure 3 As shown, the parse tree is constructed as follows:
[0038] For templates whose first word is a constant, use the first word as the first-level intermediate node and store the log template in the leaf node of the intermediate node. For templates whose first word is a parameter, use the "<*>" key as the first-level intermediate node; if the second word is a constant, use the second word as the second-level intermediate node and store the log template in the leaf node of the second-level intermediate node; if the second word is a parameter, use the "<*>" key as the second-level intermediate node and store the log template in the leaf node of the second-level intermediate node.
[0039] The construction and update of the parse tree is synchronized with the model inference process. When a new log arrives, it first enters the parse tree for log template matching. If the search can proceed along the tree to a leaf node, the log is similar to each template in the template library of the current leaf node. The similarity calculation formula for logs and templates is as follows:
[0040]
[0041] Among them, function S() means to segment the log or template by space, and function len() calculates the number of words after segmenting the log or template by space. Select three (if any) most similar log templates to match the input log with regular expressions. If the match is successful, the semantic labels of the template and its parameters are directly output as the prediction result; if no template is matched successfully, or the search cannot be performed to the leaf node, the log is sent to the parser for log parsing, and the parse tree is updated according to the prediction result, and the new log template and its corresponding parameter semantic labels are stored in the parse tree.
[0042] The present invention at least has the following beneficial effects:
[0043] The present invention designs a semantic log parsing method based on a large language model. The improved LLAMA2 structure is used to apply the rich pre-training knowledge of the large model to the log parsing method, which enhances the generalization ability of the model; the semantic parsing module enables the model to predict the semantic labels of parameters while extracting log templates to meet the needs of increasingly complex downstream tasks; the parsing tree module accelerates the large-scale real-time log reasoning process. Unlike most log parsers based on large language models, the present invention can run offline, avoiding problems such as network delays, interface changes and data security. After fine-tuning using log data from several different sources, the present invention can directly parse logs from other sources without the need for additional training.
[0044] Other advantages, objectives and features of the present invention will be embodied in part through the following description, and in part will be understood by those skilled in the art through study and practice of the invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] Figure 1 It is a diagram of the structure of the semantic log parsing system based on the large language model of the present invention.
[0046] Figure 2 This is a structural comparison diagram of LLAMA2 and LogLLAMA.
[0047] Figure 3 This is the structure diagram of the parse tree module. DETAILED DESCRIPTION
[0048] The present invention is further described below through specific embodiments in conjunction with the accompanying drawings.
[0049] The present invention provides a semantic log parsing method based on a large language model, which includes the following modules:
[0050] (1) Subword feature extraction module, including LLAMA2 word segmenter and LLAMA2 model with causal mask removed (hereinafter referred to as LogLLAMA). LogLLAMA is connected after LLAMA2 word segmenter. LLAMA2 word segmenter takes an original log sentence as input and divides it into several words, each word is divided into several subwords. Then, LogLLAMA extracts the features of these subwords. LogLLAMA modifies the structure of LLAMA2 by removing the causal mask, so that it can perceive the context of each word and adapt to the log parsing task.
[0051] (2) A semantic recognition module, which includes a multi-head attention network and a fully connected network, wherein the fully connected network is connected to the multi-head attention network. The multi-head attention network aggregates all subwords of each word into a word feature, and the fully connected network semantically classifies the words based on these features. Furthermore, the present invention designs 17 categories, including 1 template constant category and 16 parameter semantic categories. Cross entropy loss is used in the training phase. In the inference phase, if the category corresponding to the maximum predicted probability of a word is the template constant class, it is predicted as a template constant; if the category corresponding to the maximum predicted probability of a word is the parameter semantic class, it is predicted as a parameter, and the three semantic categories with the highest predicted probabilities are taken as the prediction results.
[0052] (3) Parsing tree module: This module uses a tree structure similar to a prefix tree to store the log templates obtained through parsing. Its construction and update are synchronized with the log reasoning process. Before parsing, the three most similar log templates are selected from all the templates in the parse tree for regular expression matching. If the match is successful, the template is directly output as the prediction result. If there is no template that can be successfully matched, the log is sent to the parser for parsing, and the template obtained through parsing is stored in the parse tree.
[0053] The specific model training and reasoning steps are as follows:
[0054] (1) Parsing tree query
[0055] When a new log arrives, it first enters the parse tree for log template matching. If the search can proceed along the tree to a leaf node, the log is compared with each template in the template library of the current leaf node for similarity. The similarity calculation formula for logs and templates is as follows:
[0056]
[0057] Among them, the function S() means to segment the log or template by space, and the function len() calculates the number of words after the log or template is segmented by space. Select three (if any) most similar log templates to match the input log with regular expressions. If the match is successful, the semantic labels of the template and its parameters are directly output as the prediction result; if no template is matched successfully, or the search cannot be performed to the leaf node, the log is sent to the parser for log parsing.
[0058] (2) Subword feature extraction
[0059] The subword feature extraction module includes the LLAMA2 word segmenter and the LLAMA2 model with the causal mask removed (hereinafter referred to as LogLLAMA). LogLLAMA is connected to the LLAMA2 word segmenter. The LLAMA2 word segmenter takes an original log sentence as input and divides it into several words. Each word is divided into several subwords, and each subword is identified by a unique identifier. The number of subwords in each log sentence is limited. If there are more, they are truncated, and if there are fewer, they are filled with specific subwords.
[0060] LogLLAMA accepts these subwords as input and extracts features for each subword. Figure 2 As shown in Figure 1, LogLLAMA modifies the structure of LLAMA2 and removes the causal mask, so that the model can perceive the entire context of the log when extracting the current subword feature. This design can ensure a consistent and comprehensive understanding of the log and improve the performance of large language models in log parsing.
[0061] In the training phase, LogLLAMA uses the Lora method to efficiently fine-tune parameters to adapt it to log parsing tasks. In the inference phase, it can be directly applied to log data from various sources without additional fine-tuning.
[0062] (3) Semantic Recognition
[0063] The semantic recognition module includes a multi-head attention network and a fully connected network, and the fully connected network is connected after the multi-head attention network.
[0064] like Figure 1 As shown in Figure 2, the multi-head attention network aggregates all sub-word features of each word into a word feature. Specifically, for the i-th log word, its corresponding word feature The calculation is as follows:
[0065]
[0066] Among them, V SA V is an additional, learnable aggregation vector used to aggregate subword features. As training progresses, V SAThe learnability of H enables it to be continuously optimized based on training logs, making it more and more suitable for semantic parsing. i1 ,H i2 ,…,H in is the feature of each subword; W Q , W K , W V is a learnable weight parameter; Attn() is a standard multi-head attention function. When performing feature aggregation on each word, V SA , W Q , W K , W V The parameters involved in the function Attn() are shared to enhance the model's transfer learning and pattern recognition capabilities. In particular, the calculation formula for the standard multi-head attention is
[0067] Attn(Q,K,V)=Concat(head1,…,head h )W O
[0068] Among them, the function Concat() represents matrix concatenation, W O are learnable parameters, head1,…,head h For different attention heads, the calculation formula is:
[0069]
[0070]
[0071] Among them, d k is the dimension of k.
[0072] The multi-head attention network outputs the features of each word The fully connected network will perform log semantic classification for each word based on these features. Assuming that the total number of semantic categories of a word is K, the fully connected layer maps the word features to K dimensions. In this method, K = 17, including a template constant category and 16 parameter semantic categories, which are specifically defined as follows:
[0073] Serial number category Semantic Category 0 O Template constants 1 OID Unique identifier 2 OBN name 3 LOI address 4 TID type 5 SID state 6 TPA Time 7 TDA Time Range 8 OBA quantity 9 OBO order 10 CRS Number of resources 11 OBD Data content 12 CMD instruction 13 INR Interval 14 VER Version Information 15 ERR Error or exception information 16 OTP other .
[0074] During training, the cross entropy loss CE_Loss of each word is calculated. Specifically, for a certain word, its word feature is Then its loss function is:
[0075]
[0076] Among them, K=17 is the total number of semantic categories of words, and the function FC() is a fully connected network. The model predicts the probability that the word belongs to label i. i is the true label corresponding to the word, that is:
[0077]
[0078] In the inference stage, due to the ambiguity and ambiguity of log semantics, the following prediction strategy will be adopted: for words predicted as parameters (i.e., the category corresponding to the maximum prediction probability belongs to the parameter), the top three parameter semantic categories with the highest prediction probability are retained as the result; for words predicted as template constants, their template constant category is retained as the prediction result.
[0079] (4) Parsing tree update
[0080] After parsing is completed, the parse tree is updated according to the storage rules of the parse tree, and the predicted template and its parameter semantic labels are stored in a leaf node template library of the parse tree.
[0081] Testing and verification of the present invention
[0082] The present invention selects two data sets, LogPub and LogBase, to test the performance of the present invention on conventional log parsing data sets and semantic log parsing data sets.
[0083] LogPub, launched by the LogPAI team, is a well-known general log parsing dataset, containing 50.4 million logs from 14 sources and about 3,500 log templates. LogPub only distinguishes between templates and parameters, and does not further distinguish the semantic categories of parameters. Therefore, we added semantic annotations based on its data.
[0084] LogBase is a dataset we built specifically for semantic log parsing tasks. The construction steps are:
[0085] (1) Use a web crawler to crawl the 121 projects with the highest number of stars from GitHub.
[0086] (2) Use JavaParser to build a log template mining algorithm to extract all possible log templates from the project source code.
[0087] (3) Design tips, using contextual learning to enable a large language model to generate simulated logs based on these templates.
[0088] (4) Invite two experienced software engineers and four graduate students to screen, annotate and cross-validate these simulated logs. LogBase contains 1.1 million logs from 121 sources and approximately 74,500 log templates.
[0089] To verify the superiority of this method, this embodiment is compared with the following existing log parsing methods on a public data set:
[0090] Drain (from "He P, Zhu J, Zheng Z, et al. Drain: An online log parsing approach with fixed depth tree [C] / / 2017IEEE international conference on webservices(ICWS).IEEE, 2017:33-40.");
[0091] UniParser (excerpted from "Liu Y, Zhang
[0092] LogPPT (from "Le VH, Zhang H. Log parsing with prompt-based few-shotlearning[C] / / 2023IEEE / ACM 45th International Conference on SoftwareEngineering(ICSE).IEEE,2023:2438-2449."); LILAC (from "Jiang Z, Liu J, Chen Z, etal. Llmparser: A llm-based log parsing framework[J].arXiv preprint arXiv:2310.01796,2023.");
[0093] LLMParser (from "Ma Z, Chen AR, Kim DJ, et al. LLMParser: An ExploratoryStudyon Using Large Language Models for Log Parsing[C] / / 2024IEEE / ACM 46thInternationalConference on Software Engineering(ICSE).IEEE Computer Society, 2024:883-883.");
[0094] LILAC (excerpted from "Jiang Z, Liu J, Chen Z, et al. Llmparser:A llm-based logparsingframework[J].arXiv preprint arXiv:2310.01796,2023.");
[0095] VALB (Excerpted from "Li Z, Luo C, Chen TH, et al. Did we miss something important? studying and exploring variable-aware log abstraction[C] / / 2023IEEE / ACM 45thInternationalConference on Software Engineering(ICSE).IEEE, 2023:830-842.").
[0096] This embodiment uses GA, PA and FTA as indicators for conventional log parsing, and uses SPA and SPA+ as indicators for semantic log parsing. SPA is the ratio of correctly parsed logs to the total number of logs. If the model correctly distinguishes log templates and parameters, and for each parameter, the semantic prediction results of the model contain the true semantic category of the parameter, the log is considered to be correctly parsed. SPA+ is similar to SPA, but more stringent. It is considered to be correctly parsed only when the label with the highest output probability in the model matches the true semantic category. The results on LogPub and LogBase are shown in Table 1 and Table 2, respectively.
[0097] On LogPub, the present invention achieved the highest average performance in all indicators. In terms of grouping performance, the average GA of the present invention is 93.3%, which is 0.6% higher than LILAC. In terms of traditional parsing performance, the PA and FTA of the present invention are 93.6% and 84.4%, respectively, which are 11.5% and 0.2% higher than LILAC, and 27.2% and 76.6% higher than LogPPT. This shows that the present invention can effectively extract log templates and log parameters. In terms of semantic parsing, the SPA and SPA+ of the present invention both significantly exceed the current best semantic log parser VALB: SPA is 83.2%, and SPA+ is 55.9%, which are 29% and 22.1% higher than VALB, respectively. These results show that the present invention can accurately identify the meaning of log parameters while accurately extracting log templates.
[0098] On LogBase, the present invention also achieves the highest average performance in all indicators. In terms of grouping performance, the average GA of SemanticLog is 75.6%, which is 8.2% higher than VALB. For traditional log parsing, its PA and FTA are 82.4% and 56.4%, respectively, which are 9.9% and 30% higher than VALB. In terms of semantic log parsing, the SPA and SPA+ of the present invention are 77.4% and 66%, respectively, which exceed VALB by 15.4% and 31%, respectively. LogBase is much more complex than LogPub. These results show that the present invention has excellent generalization ability and can accurately process large-scale complex log data.
[0099] Table 1 Performance comparison on LogPub
[0100]
[0101] Table 2 Performance comparison on LogBase
[0102]
Claims
1. A semantic log parsing system based on a large language model, characterized in that: It includes subword feature extraction module, semantic recognition module and parse tree module; among them: The subword feature extraction module is used for word segmentation and log subword feature extraction; and log parsing is used as a sequence labeling task; specifically, the structure of LLAMA2 is adapted to the parsing task by removing the causal mask, and the rich knowledge of the large language model is used to extract accurate feature representation for each subword; The semantic recognition module, based on a multi-head cross-attention mechanism, integrates the features of each subword, and then extracts the log template and predicts the semantic category of the log parameter; The parsing tree module stores the parsed templates in a tree structure, is built and updated synchronously with the parsing process, and is used to accelerate the reasoning process of large-scale real-time logs.
2. The semantic log parsing system based on a large language model according to claim 1, characterized in that: The subword feature extraction module includes an LLAMA2 word segmenter and an LLAMA2 model with a causal mask deleted, which is recorded as LogLLAMA; LogLLAMA is connected to the LLAMA2 word segmenter; the LLAMA2 word segmenter accepts an original log sentence as input and divides it into several words, each word is divided into several subwords, and each subword is identified by a unique identifier; the number of subwords in each log sentence is limited, and if there are more, they are truncated, and if there are fewer, they are filled with specific subwords; LogLLAMA accepts these subwords as input and extracts the features of each subword; Here, the LLAMA2 model includes: N layers of multi-head self-attention layers with causal masks, and LogLLAMA is the LLAMA2 model with the causal masks removed, that is, LogLLAMA includes N layers of multi-head self-attention layers; removing the causal masks enables the model to perceive the entire context of the log when extracting the current subword feature; During the training phase, LogLLAMA uses the Lora method to efficiently fine-tune parameters to adapt it to log parsing tasks; during the inference phase, it is directly applied to log data from various sources without additional fine-tuning.
3. The semantic log parsing system based on a large language model according to claim 2, characterized in that: The semantic recognition module includes a multi-head cross attention network and a fully connected network, and the fully connected network is connected after the multi-head attention network; The multi-head attention network aggregates all sub-word features of each word into a single word feature; Specifically, for the i-th log word, its corresponding word feature The calculation is as follows: Among them, V SA V is an additional, learnable aggregation vector used to aggregate subword features. As training progresses, V SA The learnability of H enables it to be continuously optimized based on training logs, making it more and more suitable for semantic parsing; i1 ,H i2 ,…,H in is the feature of each subword; W Q , W K , W V is a learnable weight parameter; Attn() is a standard multi-head attention function; when performing feature aggregation on each word, V SA , W Q , W K , W V The parameters involved in the function Attn() are shared to enhance the model's transfer learning and pattern recognition capabilities; the calculation formula for the standard multi-head attention is: Attn(Q,K,V)=Concat(head1,…,head h )W O , (2) Among them, the function Concat() represents matrix concatenation, W O are learnable parameters, head1,…,head h For different attention heads, the calculation formula is: head i =Attention(QW i Q ,KW i K ,VW i V ), (3) Among them, d k is the dimension of k; The multi-head attention network outputs the features of each word The fully connected network performs log semantic classification on each word based on these features; assuming the total number of semantic categories of a word is K, the fully connected layer maps the word features to K dimensions; During training, the cross entropy loss CE_Loss of each word is calculated; specifically, for a certain word, its word feature is Then its loss function is: Among them, K is the total number of semantic categories of words, and the function FC() is a fully connected network. The model predicts the probability that the word belongs to label i; y i is the true label corresponding to the word, that is: In the reasoning stage, considering the ambiguity and ambiguity of log semantics, the following prediction strategy is adopted: for words predicted as parameters, that is, the category corresponding to the maximum prediction probability belongs to the parameter, and the top three parameter semantic categories with the highest prediction probability are retained as the result; for words predicted as template constants, their template constant category is retained as the prediction result.
4. The semantic log parsing system based on a large language model according to claim 3 is characterized in that: The total number of semantic categories K is 17, including one template constant category and 16 parameter semantic categories, which are specifically defined as follows:
5. The semantic log parsing system based on a large language model according to claim 3 or 4, characterized in that: The parse tree module uses a tree structure similar to a prefix tree to store log templates, but with the following differences: the root node of the parse tree does not store content; each intermediate node is a template word or a placeholder "<*>" representing a parameter; each leaf node is a log template library, storing a number of log templates containing parameter semantic tags; It is constructed as follows: For templates whose first word is a constant, use the first word as the first-level intermediate node and store the log template in the leaf node of the intermediate node; for templates whose first word is a parameter, use the "<*>" key as the first-level intermediate node; if the second word is a constant, use the second word as the second-level intermediate node and store the log template in the leaf node of the second-level intermediate node; if the second word is a parameter, use the "<*>" key as the second-level intermediate node and store the log template in the leaf node of the second-level intermediate node; The construction and update of the parse tree are synchronized with the model inference process; when a new log arrives, it first enters the parse tree for log template matching; if the search can proceed along the tree to the leaf node, the log is similar to each template in the template library of the current leaf node. The similarity calculation formula for logs and templates is as follows: The function S() means segmenting the log or template by spaces, and the function len() calculates the number of words in the log or template after segmentation by spaces. The three most similar log templates are selected to perform regular expression matching with the input log. If the match is successful, the semantic labels of the template and its parameters are directly output as the prediction results. If no template matches successfully, or the search cannot proceed to a leaf node, the log is sent to the parser for log parsing, and the parse tree is updated based on the prediction results, and the new log template and its corresponding parameter semantic labels are stored in the parse tree.
Citation Information
Patent Citations
System fault diagnosis method and device based on log semantic mining
CN110288004A
Video description generation method based on perceptual grammar knowledge
CN115410120A
Hierarchical language model system for optimized query response generation
GB202316605D0
Language Modeling For Conversational Understanding Domains Using Semantic Web Resources
US20150332670A1
Cited By
Mask mixing method in log anomaly detection language model self-supervised training
CN119248618A
Fault detection method based on large model
CN119311519A
A large model-based fault detection method
CN119311519B
Acupuncture positioning method based on image processing
CN119648800A
Acupuncture Location Method Based on Image Processing
CN119648800B
