Log parsing method, device, equipment and storage medium based on prompt optimization

The method of generating prompt words through clustering and natural language gradient optimization solves the problems of domain migration and high cost of traditional log parsing models, improves the performance and reliability of log parsing, and reduces costs.

CN118427294BActive Publication Date: 2024-09-27HEFEI UNIV OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410888371.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-04
Publication Date
2024-09-27
Estimated Expiration
2044-07-04

AI Technical Summary

Technical Problem

Traditional log parsing models perform poorly in domain migration, especially when faced with unseen log templates. The performance is limited, and the cost of manually designing prompt words is high, resulting in high difficulty in log parsing and low reliability of identification results.

Method used

By clustering the sample log data set, a candidate example library is generated, and the clustering algorithm is used to filter out the log data with the highest similarity to the log to be input as demonstration examples. An initial prompt word is created based on the demonstration examples and task description text, and uses Natural language gradient optimization generates target prompt words and parses the input log.

Benefits of technology

It improves the performance and generalization ability of log parsing, reduces the cost of log parsing, and enhances the reliability of identification results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118427294B
    Figure CN118427294B
Patent Text Reader

Abstract

The present invention provides a log parsing method, device, equipment and storage medium based on prompt optimization, and relates to the field of computer technology. The log parsing method based on prompt optimization comprises: clustering a sample log data set to generate a candidate example library; the basis of the clustering division includes Top‑K frequent tokens and preset characteristic characters; using a clustering algorithm to screen out at least one log data with the highest similarity to a log to be input from the candidate example library as a demonstration example; the demonstration example includes an input example and an output expectation; creating an initial prompt word based on the demonstration example and a task description text; the task description text includes a task background and a task requirement; optimizing the initial prompt word using a natural language gradient to generate a target prompt word, and parsing the log to be input based on the target prompt word, thereby improving the performance and generalization ability of log parsing and reducing the log parsing cost.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a log parsing method, device, equipment and storage medium based on prompt optimization. Background Art

[0002] Logging is an indispensable task in modern software systems. Logging records the runtime information of the software system in detail, providing developers and support engineers with an important means to monitor the system's operating status and analyze abnormal behaviors and errors. However, with the increasing scale and complexity of software systems, the number and types of logs are also showing a surge. A system may generate millions of logs in a day, and the traditional manual log checking method has become no longer feasible in this case. Log template parsing technology has emerged as the times require. It provides an effective solution for log management and analysis by compressing massive log data into a relatively small set of templates. Log parsing refers to an algorithm that parses logs from semi-structured data to structured data. This algorithm can help us quickly understand the overview of a large number of logs.

[0003] Traditional log parsing models usually rely on heuristic methods and artificial knowledge bases, but they perform poorly in domain transfer. In addition, existing supervised log parsing models have limited performance when faced with unseen log templates. Although the rich knowledge of large models can make up for the lack of generalization of log parsing models to a certain extent, the cost of manually designing prompt words is very high. Summary of the invention

[0004] The purpose of the present invention is to solve the problem of great difficulty in log parsing and low reliability of identification results. The present invention provides a log parsing method, device, equipment and storage medium based on prompt optimization.

[0005] The technical solution of the embodiment of the present application is implemented as follows:

[0006] A first aspect of an embodiment of the present application provides a log parsing method based on prompt optimization, comprising:

[0007] Clustering the sample log data set to generate a candidate sample library; the clustering is based on the Top-K frequent tokens and preset characteristic characters;

[0008] Using a clustering algorithm, at least one log data with the highest similarity to the log to be input is selected from the candidate example library as a demonstration example; the demonstration example includes an input example and an output expectation;

[0009] Creating an initial prompt word based on the demonstration example and the task description text; the task description text includes task background and task requirements;

[0010] The initial prompt word is optimized by using a natural language gradient to generate a target prompt word, and the log to be input is parsed based on the target prompt word.

[0011] Optionally, before clustering the sample log data set to generate a candidate sample library, the method further includes:

[0012] The sample log data set is preprocessed to delete the stop character in the sample log data and replace the timestamp and IP address in the sample log data.

[0013] Optionally, clustering the sample log data set to generate a candidate sample library includes:

[0014] Using Top-K frequent tokens to perform coarse-grained clustering on the sample log data set to generate a first type of data set;

[0015] Performing fine-grained clustering on the sample log data set using preset characteristic characters to generate a second type of data set;

[0016] At least part of the sample log data is filtered from the second type of data set to generate a candidate sample library.

[0017] Optionally, the using a clustering algorithm to select at least one log data with the highest similarity to the log to be input from the candidate example library as a demonstration example includes:

[0018] Using a clustering algorithm to obtain the similarity between each log data in the candidate example library and the log to be input;

[0019] At least one log data with the highest similarity to the log to be input is used as a demonstration example.

[0020] Optionally, the initial prompt word P includes:

[0021] ;

[0022] in, Characterizes the task description text, Characterization demonstration example.

[0023] Optionally, the optimizing the initial prompt word by using the natural language gradient to generate a target prompt word, and parsing the log to be input based on the target prompt word, includes:

[0024] Parsing the log to be input using the initial prompt word to obtain a gradient corresponding to a loss function;

[0025] Based on the reverse direction of the gradient, the initial prompt word is updated and parsed and iterated until the loss function reaches a minimum value;

[0026] The initial prompt word corresponding to the minimum value of the loss function is determined as the target prompt word.

[0027] Optionally, the using the initial prompt word to parse the log to be input to obtain the gradient corresponding to the loss function includes:

[0028] Parsing the log to be input using the initial prompt word to obtain an output result;

[0029] The output result and the corresponding initial prompt word are output to the GPT model to obtain the gradient corresponding to the loss function.

[0030] The second aspect of the embodiment of the present application provides a log parsing device based on prompt optimization, including: a clustering module, a screening module, a creation module and a parsing module, wherein:

[0031] The clustering module is configured to perform clustering on the sample log data set to generate a candidate sample library; the clustering is based on the Top-K frequent tokens and preset characteristic characters;

[0032] The screening module is configured to use a clustering algorithm to screen out at least one log data with the highest similarity to the log to be input from the candidate example library as a demonstration example; the demonstration example includes an input example and an output expectation;

[0033] The creation module is configured to create an initial prompt word based on the demonstration example and the task description text; the task description text includes task background and task requirements;

[0034] The parsing module is configured to optimize the initial prompt word by using a natural language gradient to generate a target prompt word, and parse the log to be input based on the target prompt word.

[0035] A third aspect of an embodiment of the present application provides an electronic device, including a processor and a memory; the memory stores a computer program, wherein the computer program, when executed by the processor, implements the log parsing method based on prompt optimization described in the first aspect.

[0036] A fourth aspect of an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method described in the first aspect.

[0037] Compared with the prior art, the technical solution provided by this application has the following beneficial effects:

[0038] The present invention provides a log parsing method, device, equipment and storage medium based on prompt optimization, which clusters and divides a sample log data set through Top-K frequent tokens and preset feature characters to generate a candidate example library, and then uses a clustering algorithm to screen out at least one log data with the highest similarity to a log to be input from the candidate example library as a demonstration example, creates an initial prompt word based on the demonstration example and a task description text, and on this basis, uses a natural language gradient to optimize the initial prompt word to generate a target prompt word, and parses the log to be input based on the target prompt word, thereby improving the performance and generalization ability of log parsing and reducing the cost of log parsing. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] Figure 1 A flow chart of a log parsing method based on prompt optimization provided in an embodiment of the present application;

[0040] Figure 2 A schematic diagram of the structure of a log parsing device based on prompt optimization provided in an embodiment of the present application;

[0041] Figure 3 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0042] Below, embodiments of the present application will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present application. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present application. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of the concepts of the present application.

[0043] The terms used herein are only for describing specific embodiments and are not intended to limit the present application. The terms "include", "comprising", etc. used herein indicate the existence of the features, steps, operations and / or components, but do not exclude the existence or addition of one or more other features, steps, operations or components.

[0044] All terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification, and should not be interpreted in an idealized or overly rigid manner.

[0045] Some block diagrams and / or flow charts are shown in the accompanying drawings. It should be understood that some blocks or combinations thereof in the block diagrams and / or flow charts may be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that these instructions, when executed by the processor, may create a device for implementing the functions / operations described in these block diagrams and / or flow charts.

[0046] In some embodiments, see Figure 1 , Figure 1 A flow chart of a log parsing method based on prompt optimization provided in an embodiment of the present application; the log parsing method based on prompt optimization provided in an embodiment of the present application includes:

[0047] S110, clustering the sample log data set to generate a candidate sample library; the basis for clustering includes Top-K frequent tokens and preset characteristic characters.

[0048] S120, using a clustering algorithm to select at least one log data with the highest similarity to the log to be input from the candidate example library as a demonstration example; the demonstration example includes an input example and an output expectation.

[0049] S130, creating an initial prompt word based on the demonstration example and the task description text; the task description text includes task background and task requirements.

[0050] S140, optimizing the initial prompt word by using natural language gradient to generate a target prompt word, and parsing the input log based on the target prompt word.

[0051] The goal of log parsing is to automatically identify and extract a set of representative templates by analyzing the original log data set, so that each template can accurately reflect the general structure of the log message and cover the changes in the original log data as much as possible.

[0052] In this embodiment, the sample log data may be part of the original data set, including multiple log messages. First, the sample log data set is clustered using Top-K frequent tokens, and on this basis, the sample log data set is further clustered using preset feature characters. Tokens may be words, phrases, numbers, or other meaningful text fragments. Each log message is split into separate tokens, and by traversing all log messages and counting the number of occurrences of each token, the frequency of each token in all log messages can be counted, and the K tokens with the highest frequency of occurrence are selected from all tokens as frequent tokens. The value of K can be adjusted according to actual needs. These tokens usually represent the most representative or relevant information in the log message. The preset feature characters may be some constants in the log message, where some constants of the log message are defined as special formats and it is assumed that log messages from the same template usually share the same special format.

[0053] The kNN algorithm, K-Means algorithm, spectral clustering algorithm, etc. can be used to filter log data from the candidate sample library using clustering algorithms. Taking the kNN algorithm as an example, the idea of ​​the kNN algorithm (k-Nearest Neighbors) is that if most of the k nearest neighboring samples of a sample in the feature space belong to a certain category, then the sample also belongs to this category. In the regression task, kNN uses the average value of the k nearest neighbor samples as the prediction value. It should be noted that the clustering algorithm can also be other types of algorithms, which can be selected according to actual needs and are not limited to this.

[0054] In natural language processing (NLP), gradient is a mathematical concept used to describe the growth rate or direction of a function at a certain point. In optimization algorithms, especially in deep learning, gradient represents the direction and step size of model parameter updates. Due to the complexity of NLP tasks, calculating gradients involves a lot of computing resources and time. Therefore, some techniques are needed to speed up the calculation and update process of gradients, such as gradient descent. The basic idea of ​​gradient descent is to update parameters in the opposite direction of the gradient corresponding to the current point of the function, so that the function value continues to decrease, thus approaching the local minimum.

[0055] In one example, the kNN algorithm can be used to screen out at least one log data with the highest similarity to the log to be input from the candidate example library as a demonstration example, and then create initial prompt words based on the demonstration example and the task description text. On this basis, the initial prompt words are optimized using the gradient descent method to generate target prompt words, and the input log is parsed based on the target prompt words, thereby improving the performance and generalization ability of log parsing and reducing the cost of log parsing.

[0056] In some embodiments, at S110, before clustering the sample log data set to generate a candidate example library, the log parsing method further includes:

[0057] The sample log data set is preprocessed to delete the stop character in the sample log data and replace the timestamp and IP address in the sample log data.

[0058] When processing log data containing special symbols (such as stop characters, timestamps, and IP addresses), these special symbols may affect the clustering effect. Clustering algorithms usually divide data sets based on similarity measures between data points (such as distance, density, etc.). The presence of special symbols may interfere with this similarity measure, resulting in inaccurate or unexpected clustering results. Therefore, before clustering the sample log data set and generating a candidate sample library, the sample log data set needs to be preprocessed to eliminate or reduce the impact of these special characters on the clustering results.

[0059] In some embodiments, S110, clustering the sample log data set to generate a candidate example library includes:

[0060] Use Top-K frequent tokens to perform coarse-grained clustering on the sample log data set to generate the first type of data set;

[0061] Perform fine-grained clustering on the sample log data set using preset characteristic characters to generate the second type of data set;

[0062] At least part of the sample log data is filtered from the second type of data set to generate a candidate sample library.

[0063] In this embodiment, the sample log data set is firstly coarse-grained clustered using Top-K frequent tokens, and the K tokens with the highest frequency of occurrence are selected from all tokens as frequent tokens, based on which the first type of data set is generated, and then fine-grained clustering is performed based on some constants in the log messages to generate the second type of data set. At this point, the second type of data set contains multiple types of log data. According to actual needs, part of the sample log data can be extracted from each type of data in proportion to generate a candidate example library.

[0064] In some embodiments, S120, using a clustering algorithm to select at least one log data with the highest similarity to the log to be input from the candidate example library as a demonstration example, includes:

[0065] Use clustering algorithm to obtain the similarity between each log data in the candidate sample library and the log to be input;

[0066] At least one log data with the highest similarity to the log to be input is used as a demonstration example.

[0067] In this embodiment, a clustering algorithm can be used to determine the distance between each log data in the candidate example library and the log to be input. This distance can be Euclidean distance, Manhattan distance, etc. The similarity between the log data in the candidate example library and the log to be input can be determined based on the distance. Here, each log data can be sorted according to the similarity. If there are multiple log data with the same similarity to the log to be input, and it is greater than the similarity between other log data and the log to be input, then these multiple log data are used as demonstration examples, or any one of the log data is selected as a demonstration example. If there is a log data with a similarity to the log to be input that is greater than the similarity between other log data and the log to be input, then this log data is used as a demonstration example.

[0068] In some embodiments, the initial prompt word P includes:

[0069] ;

[0070] in, Characterizes the task description text, Characterization demonstration example.

[0071] In this embodiment, the prompt words are semantically divided into two parts: task description text and demo examples . Represents the task description text, which describes the specific task to be completed and provides the background information and requirements of the task; The main purpose is to show how to complete the task through examples, including the input and expected output of the example. In this way, the prompt word provides both clear guidance on the task and specific example references, thereby better guiding it to produce the expected results.

[0072] In some embodiments, S140, optimizing the initial prompt word by using the natural language gradient to generate the target prompt word, and parsing the input log based on the target prompt word, including:

[0073] Use the initial prompt word to parse the input log and obtain the gradient corresponding to the loss function;

[0074] Update the initial prompt word based on the reverse direction of the gradient and perform parsing iterations until the loss function reaches the minimum value;

[0075] The initial prompt word corresponding to the minimum value of the loss function is determined as the target prompt word.

[0076] In this embodiment, the sample log data set is divided into batches, and for each input log, the closest demonstration example is found in the candidate example library to construct a prompt word. Subsequently, the prompt word is used to extract the pattern of the input log, and the result of each extraction error is recorded. Based on these error results, the corresponding gradient can be obtained. Therefore, the prompt word is adjusted in the opposite direction of the gradient in the hope of obtaining better extraction results in the next iteration. Here, three semantic templates, namely, pre-, middle- and post-, can be used to generate random initial prompt words based on randomly selected task examples. Among them, the pre-template, at the beginning of the prompt word, is used to introduce the theme information or task background; the middle template, in the middle part of the prompt word, is used to explain the main content of the task or task requirements. The post-template, at the end of the prompt word, is used to emphasize the key points or output expectations. By emphasizing key information in different positions, the adaptability and effectiveness of the prompt word can be effectively improved.

[0077] In some embodiments, the input log is parsed using the initial prompt word to obtain the gradient corresponding to the loss function, including:

[0078] Parsing the log to be input using the initial prompt word to obtain an output result;

[0079] Output the output result and the corresponding initial prompt word to the GPT model to obtain the gradient corresponding to the loss function.

[0080] In this embodiment, each time the prompt word extracts an incorrect log pattern, the error result is recorded. Then, the error result and the corresponding prompt word are input into the GPT model together, and GPT interprets the reason for the error in the prompt word extraction result, that is, the corresponding gradient, so that the prompt word can be adjusted and optimized along the opposite direction of the gradient.

[0081] The embodiment of the present application clusters and divides the sample log data set through Top-K frequent tokens and preset characteristic characters to generate a candidate example library, and then uses a clustering algorithm to filter out at least one log data with the highest similarity to the log to be input from the candidate example library as a demonstration example, and creates an initial prompt word based on the demonstration example and the task description text. On this basis, the initial prompt word is optimized using natural language gradients to generate target prompt words, and the input log is parsed based on the target prompt word, thereby improving the performance and generalization ability of log parsing and reducing the cost of log parsing.

[0082] In some embodiments, see Figure 2 , Figure 2The schematic diagram of the structure of the log parsing device based on prompt optimization provided in the embodiment of the present application. The log parsing device 200 based on prompt optimization provided in the embodiment of the present application comprises: a clustering module 210, a screening module 220, a creation module 230 and a parsing module 240, wherein:

[0083] The clustering module 210 is configured to perform clustering on the sample log data set to generate a candidate sample library; the clustering is based on the Top-K frequent tokens and preset feature characters.

[0084] The screening module 220 is configured to use a clustering algorithm to screen out at least one log data with the highest similarity to the log to be input from the candidate example library as a demonstration example; the demonstration example includes an input example and an output expectation;

[0085] A creation module 230 is configured to create an initial prompt word based on the demonstration example and the task description text; the task description text includes the task background and task requirements;

[0086] The parsing module 240 is configured to optimize the initial prompt word by using the natural language gradient to generate the target prompt word, and parse the input log based on the target prompt word.

[0087] In some embodiments, the log parsing device 200 based on prompt optimization further includes a preprocessing module; the preprocessing module is specifically configured as follows:

[0088] The sample log data set is preprocessed to delete the stop character in the sample log data and replace the timestamp and IP address in the sample log data.

[0089] In some embodiments, the clustering module 210 is specifically configured as follows:

[0090] Use Top-K frequent tokens to perform coarse-grained clustering on the sample log data set to generate the first type of data set;

[0091] Perform fine-grained clustering on the sample log data set using preset characteristic characters to generate the second type of data set;

[0092] At least part of the sample log data is filtered from the second type of data set to generate a candidate sample library.

[0093] In some embodiments, the screening module 220 is specifically configured as follows:

[0094] Use clustering algorithm to obtain the similarity between each log data in the candidate sample library and the log to be input;

[0095] At least one log data with the highest similarity to the log to be input is used as a demonstration example.

[0096] In some embodiments, the initial prompt word P includes:

[0097] ;

[0098] in, Characterizes the task description text, Characterization demonstration example.

[0099] In some embodiments, the parsing module 240 is specifically configured as follows:

[0100] Parsing the input log using the initial prompt word to obtain the gradient corresponding to the loss function;

[0101] Update the initial prompt word based on the reverse direction of the gradient and perform parsing iterations until the loss function reaches the minimum value;

[0102] The initial prompt word corresponding to the minimum value of the loss function is determined as the target prompt word.

[0103] In some embodiments, the parsing module 240 is further configured to:

[0104] Parsing the log to be input using the initial prompt word to obtain an output result;

[0105] Output the output result and the corresponding initial prompt word to the GPT model to obtain the gradient corresponding to the loss function.

[0106] The log parsing device based on prompt optimization provided in the embodiment of the present application can implement each process in the embodiment corresponding to the above-mentioned log parsing method based on prompt optimization. To avoid repetition, it will not be repeated here.

[0107] It should be noted that the log parsing device based on prompt optimization provided in the embodiment of the present application and the log parsing method based on prompt optimization provided in the embodiment of the present application are based on the same application concept. Therefore, the specific implementation of this embodiment can refer to the implementation of the aforementioned log parsing method based on prompt optimization, and the repeated parts will not be repeated.

[0108] In some embodiments, see Figure 3 , Figure 3 The electronic device 300 provided in the embodiment of the present application includes a processor 310 and a memory 320; the memory 320 stores a computer program, wherein the computer program implements the above-mentioned log parsing method based on prompt optimization when executed by the processor.

[0109] Specifically, the processor 310 may include, for example, a general-purpose microprocessor, an instruction set processor and / or a related chipset and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 310 may also include an onboard memory for cache purposes. The processor 310 may be a single processing unit or multiple processing units for executing different actions of the method flow according to the embodiment of the present application.

[0110] The memory 320 may be any medium capable of containing, storing, conveying, propagating or transmitting instructions. For example, the memory 320 may include, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared or semiconductor system, device, component or propagation medium. Specific examples of the memory 320 include: a magnetic storage device, such as a magnetic tape or a hard disk (HDD); an optical storage device, such as a compact disk (CD-ROM); a random access memory (RAM) or a flash memory; and / or a wired / wireless communication link.

[0111] The present application also provides a computer-readable medium on which a computer program is stored, and when the program is executed by a processor, the above-mentioned log parsing method is implemented. The computer-readable medium may be included in the device / apparatus / system described in the above-mentioned embodiment; or it may exist independently without being assembled into the device / apparatus / system. The above-mentioned computer-readable medium carries one or more programs, and when the above-mentioned one or more programs are executed, the method according to the embodiment of the present application is implemented.

[0112] According to an embodiment of the present application, a computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium or any combination of the two. A computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, wherein a computer-readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wired, optical cable, radio frequency signal, etc., or any suitable combination of the above.

[0113] Those skilled in the art will appreciate that the features described in the various embodiments and / or claims of the present application may be combined and / or combined in a variety of ways, even if such combinations or combinations are not explicitly described in the present application. In particular, without departing from the spirit and teachings of the present application, the features described in the various embodiments and / or claims of the present application may be combined and / or combined in a variety of ways. All of these combinations and / or combinations fall within the scope of the present application. Therefore, the scope of the present application should not be limited to the above-described embodiments, but should be determined not only by the appended claims, but also by the equivalents of the appended claims.

Claims

1. A log parsing method based on prompt optimization, characterized in that: include: Cluster the sample log data set to generate a candidate sample library; The basis of clustering includes Top-K frequent tokens and preset characteristic characters; Using a clustering algorithm, at least one log data with the highest similarity to the log to be input is selected from the candidate example library as a demonstration example; the demonstration example includes an input example and an output expectation; Creating an initial prompt word based on the demonstration example and the task description text; the task description text includes task background and task requirements; Parsing the log to be input using the initial prompt word to obtain an output result; Output the output result and the corresponding initial prompt word to the GPT model to obtain the gradient corresponding to the loss function; Based on the reverse direction of the gradient, the initial prompt word is updated and parsed and iterated until the loss function reaches a minimum value; The initial prompt word corresponding to the minimum value of the loss function is determined as a target prompt word, and the log to be input is parsed based on the target prompt word.

2. The log parsing method based on prompt optimization according to claim 1 is characterized in that: Before clustering the sample log data set to generate a candidate sample library, the method further includes: The sample log data set is preprocessed to delete the stop character in the sample log data and replace the timestamp and IP address in the sample log data.

3. The log parsing method based on prompt optimization according to claim 2 is characterized in that: The clustering of the sample log data set to generate a candidate sample library includes: Using Top-K frequent tokens to perform coarse-grained clustering on the sample log data set to generate a first type of data set; Performing fine-grained clustering on the sample log data set using preset characteristic characters to generate a second type of data set; At least part of the sample log data is filtered from the second type of data set to generate a candidate sample library.

4. The log parsing method based on prompt optimization according to claim 1 is characterized in that: The method of using a clustering algorithm to select at least one log data with the highest similarity to the log to be input from the candidate example library as a demonstration example includes: Using a clustering algorithm to obtain the similarity between each log data in the candidate example library and the log to be input; At least one log data with the highest similarity to the log to be input is used as a demonstration example.

5. The log parsing method based on prompt optimization according to claim 1 is characterized in that: The initial prompt word P includes: ; in, Characterizes the task description text, Characterization demonstration example.

6. A log parsing device based on prompt optimization, characterized in that: include: Clustering module, screening module, creation module and parsing module, among which, The clustering module is configured to perform clustering on the sample log data set to generate a candidate sample library; the clustering is based on the Top-K frequent tokens and preset characteristic characters; The screening module is configured to use a clustering algorithm to screen out at least one log data with the highest similarity to the log to be input from the candidate example library as a demonstration example; the demonstration example includes an input example and an output expectation; The creation module is configured to create an initial prompt word based on the demonstration example and the task description text; the task description text includes task background and task requirements; The parsing module is configured to parse the log to be input using the initial prompt word to obtain an output result; output the output result and the corresponding initial prompt word to the GPT model to obtain the gradient corresponding to the loss function; update the initial prompt word based on the reverse direction of the gradient and perform parsing iterations until the loss function reaches a minimum value; determine the initial prompt word corresponding to the minimum value of the loss function as the target prompt word, and parse the log to be input based on the target prompt word.

7. An electronic device comprising a processor and a memory; the memory stores a computer program, wherein: When the computer program is executed by the processor, the computer program implements the log parsing method based on prompt optimization according to any one of claims 1 to 5.

8. A computer-readable storage medium having a computer program stored thereon, wherein when the program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.