Log representation model training method and device and log classification method and device
By training the log representation model, using element position information to process log data, the problem of log data statistics breaking under automatic point burial technology is solved, and the log data classification accuracy is achieved.
Patent Information
- Application Number
- CN202411513871.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-28
- Publication Date
- 2025-03-28
AI Technical Summary
Automatic point buried technology causes log data of the same element to be stored separately when updating web pages or applications, resulting in breakage of log data statistics.
By training the log representation model, the matching relationship between element position information and log data is used to construct training samples, so that the model can capture element position information, thereby improving accuracy during classification.
It effectively solves the problem of log data statistics breakage, and improves the accuracy of log data classification through the use of text representation model.
Smart Images

Figure CN119721287A_ABST
Abstract
Description
Technical Field
[0001] One or more embodiments of the present specification relate to the field of data analysis technology, and more particularly to a log representation model training, log classification method and device. Background Art
[0002] Data analysis is the key to enterprises' insight into business opportunities, optimized decision-making and strategic planning. Accurate collection of log data is the basis for data analysis. At present, the log data of elements in web pages (or application) is mainly collected by using client-side embedding technology.
[0003] Tracking technology is divided into manual tracking and automatic tracking. Manual tracking has defects such as high labor costs, untimely updates, and difficult data management. Therefore, automatic tracking is favored by enterprises. Automatic tracking automatically analyzes the elements in the web page (or application) page after introducing the tracking SDK, and then triggers the exposure and click events of these elements according to the business logic, and then uses the algorithm to summarize the log data by element. However, since automatic tracking lacks the unique identification of elements like manual tracking, when the web page (or application) is updated and the elements change, the log data of the same element reported by the automatic tracking may be stored separately as data of different elements, which leads to the problem of discontinuity in log data statistics. Summary of the invention
[0004] One or more embodiments of the present specification describe a method for training a log representation model. The trained log representation model can be used to classify log data, thereby ensuring the continuity of the counted log data.
[0005] In a first aspect, a method for training a log representation model is provided, comprising:
[0006] Obtaining a log data set obtained by embedding points on web page elements, wherein a single log data item includes a plurality of attribute fields and field values describing the web page elements; the plurality of attribute fields includes an element position field;
[0007] Flattening each attribute field and / or field value of each attribute field in each log data in the log data set to obtain a corresponding first text, and determining a corresponding second text based on a target field value of an element position field in each log data;
[0008] Forming a positive sample based on the first text and the second text corresponding to the same target field value, and forming a negative sample based on the first text and the second text corresponding to different target field values;
[0009] The log representation model is trained based on the positive samples and the negative samples.
[0010] In a second aspect, a log classification method is provided, including:
[0011] Obtain target log data to be classified, and flatten the target log data to obtain target text;
[0012] Obtaining a log representation model, where the log representation model is trained according to the method of the first aspect above;
[0013] Using the log representation model to process the target text and each candidate text in the candidate set respectively, to obtain text representations of the target text and each candidate text; wherein a single candidate text corresponds to a web page element;
[0014] Based on the text representation, calculating the similarity between the target text and each candidate text;
[0015] The web page element corresponding to the candidate text with the highest similarity among the candidate texts is determined as the target web page element corresponding to the target log data.
[0016] In a third aspect, a training device for a log representation model is provided, comprising:
[0017] An acquisition unit is used to acquire a log data set obtained by embedding points on web page elements, wherein a single log data includes a plurality of attribute fields and field values describing the web page elements; the plurality of attribute fields includes an element position field;
[0018] A processing unit, configured to flatten each attribute field and / or field value of each attribute field in each log data in the log data set to obtain a corresponding first text, and determine a corresponding second text based on a target field value of an element position field in each log data;
[0019] A forming unit, configured to form a positive sample based on the first text and the second text corresponding to the same target field value, and to form a negative sample based on the first text and the second text corresponding to different target field values;
[0020] A training unit is used to train the log representation model based on the positive samples and the negative samples.
[0021] In a fourth aspect, a log classification device is provided, comprising:
[0022] An acquisition unit, used for acquiring target log data to be classified, and performing flattening processing on the target log data to obtain a target text;
[0023] The acquisition unit is further used to acquire a log representation model, where the log representation model is trained according to the method of the first aspect;
[0024] A processing unit, used to process the target text and each candidate text in the candidate set respectively using the log representation model to obtain text representations of the target text and each candidate text; wherein a single candidate text corresponds to a web page element;
[0025] A calculation unit, used for calculating the similarity between the target text and each candidate text based on the text representation;
[0026] The determination unit is used to determine the web page element corresponding to the candidate text with the highest similarity among the candidate texts as the target web page element corresponding to the target log data.
[0027] In a fifth aspect, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed in a computer, the computer is caused to execute the method of the first or second aspect.
[0028] In a sixth aspect, a computing device is provided, comprising a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, the method of the first or second aspect is implemented.
[0029] The training method of the log representation model provided in one or more embodiments of the present specification constructs corresponding training samples for the log representation model based on the matching relationship between element position information and log data, thereby enabling the trained log representation model to effectively capture the element position information in the log data. Since the element position information is closely associated with the web page elements, when the log data is classified using the text representation output by the log representation model for the log data, the accuracy of log data classification can be greatly improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] In order to more clearly illustrate the technical solutions of the embodiments of this specification, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0031] Figure 1 Schematic diagram of the target application provided for this specification;
[0032] Figure 2 A schematic diagram of an implementation scenario of an embodiment disclosed in this specification;
[0033] Figure 3 A flow chart of a method for training a log representation model according to an embodiment of the present specification is shown;
[0034] Figure 4A schematic diagram of a training method for a log representation model in an example of this specification is shown;
[0035] Figure 5 A schematic diagram of a training method for a log representation model in another example of this specification is shown;
[0036] Figure 6 A schematic diagram of a training device for a log representation model according to an embodiment of the present specification is shown;
[0037] Figure 7 A schematic diagram of a log classification device according to an embodiment of the present specification is shown. DETAILED DESCRIPTION
[0038] The solution provided in this specification is described below in conjunction with the accompanying drawings.
[0039] As mentioned above, when collecting log data of elements in a web page (or application) based on automatic tracking technology, there will be a problem of disconnection in the counted log data (referred to as statistical data). For example, suppose you need to collect log data for each button in the target application, and the initial position of each button is as follows: Figure 1 As shown on the left, after a period of time, the target application is updated and the positions of the buttons are as follows Figure 1 As shown on the right, after the target application is updated, the positions of the first three buttons have changed, and this change will cause the characteristics of some elements in the log data to change as well. This will cause the log data of the same button to be stored separately as data of different buttons.
[0040] In order to solve the problem of discontinuity of statistical data, the inventor of the present solution conceived of classifying the statistical log data, that is, classifying (clustering) the log data collected for the same element into the same category.
[0041] In order to classify log data, the inventor of this solution has investigated some clustering algorithms for log data and found that these clustering algorithms are only applicable to system logs and cannot be effectively migrated to log data collected based on automatic point-of-sale technology (hereinafter also referred to as point-of-sale logs). For system logs, the generating subject is a fixed system component, and the generating logic, format and even content of the system logs follow a unified standard, showing a high degree of consistency. This feature enables the algorithm to run under the same stable generation mechanism when applying the clustering algorithm to the system log, whether in the training phase or the application phase, effectively avoiding the generalization problem caused by the diversity of data sources. In other words, the homogeneity of the system log ensures the stable performance and high-precision prediction of the clustering algorithm in this scenario. However, the point-of-sale log presents very different characteristics. This type of log originates from the interaction between users and various pages. Due to the different design layouts, functional modules, and interaction logics of different pages, the log data generated by them has significant differences in content structure and other aspects. When a clustering algorithm trained for a specific page is attempted to be applied to other pages, the generalization performance of the algorithm will face severe challenges due to the significant changes in data distribution. Specifically, the clustering boundaries that originally performed well on the source page may not be able to accurately divide the log data of the target page, resulting in confusion and misjudgment of the classification results.
[0042] Based on this, the inventor of this solution proposes to classify log data using the method of text representation learning. That is, a log representation model is trained to map the element features in the log data to a high-dimensional dense vector space. After obtaining the vector corresponding to the log data, the log data belonging to the same element (especially the same element with changed element features) is classified into one category through the dense vector similarity matching mechanism, thereby ensuring the continuity of data statistics. To achieve this goal, it depends on a key assumption that the similarity of elements in the vector space should closely reflect the sample similarity in the real world, that is, the geometric distance or similarity measure between vectors should be consistent with the inherent semantic or functional similarity between samples. This requires that the automatic feature extraction capability of the log representation model be fully utilized in order to accurately capture and retain the key information that can uniquely identify the identity of the element, and to let the vector learn the "semantic" information representing the identity in the element features through the representation learning method. In short, when classifying log data based on the text representation learning method, the problem of weak generalization of the existing clustering algorithm can be solved.
[0043] When using the above-mentioned text representation method, the first problem faced is: how to represent the log data as text. In this regard, this solution proposes to obtain the corresponding text by flattening each attribute field and / or the field value of each attribute field in the log data. The second problem faced is: how to train a representation model suitable for log data. In this regard, this solution proposes to construct corresponding training samples for the log representation model based on the matching relationship between the element position information and the log data, so that the trained log representation model can effectively capture the element position information in the log data. Since there is a close correlation between the element position information and the web page elements, when the log data is classified using the text representation output by the log representation model, the accuracy of log data classification can be greatly improved.
[0044] In addition, this scheme also proposes to train the representation model based on contrastive learning, and to construct sample positive examples in contrastive learning based on two different enhancement strategies: one is the random dropout strategy, and the other is the strategy of replacing the relevant element tag information group. Among them, the use of the strategy of replacing the relevant element tag information group is conducive to improving the robustness of the model to changes in element features.
[0045] The above is the inventive concept provided in this specification. Based on the inventive concept, the present solution can be implemented. The present solution is described in detail below.
[0046] Figure 2 A schematic diagram of an implementation scenario of an embodiment disclosed in this specification. Figure 2 In the example, the log data set includes n log data: log data 1-log data n, each log data includes multiple attribute fields and field values describing web page elements. For each log data, a text can be determined based on each attribute field and / or the field value of each attribute field, and another text can be determined based on the target field value of the element position field. Then, a positive sample can be formed based on two texts corresponding to the same target field value, and a negative sample can be formed based on two texts corresponding to different target field values. Finally, the log representation model is trained based on the positive samples and the negative samples.
[0047] Figure 3 The flowchart of the training method of the log representation model according to one embodiment of the present specification is shown. The method can be executed by any device, equipment, platform, or device cluster with computing and processing capabilities. Figure 3 As shown, the method may include the following steps:
[0048] Step S302, obtaining a log data set obtained by embedding points on web page elements.
[0049] The web page elements here may refer to controls in a web page (or application), which may include but are not limited to: buttons, text boxes, drop-down lists, radio buttons, check boxes, etc.
[0050] A single log data in the above log data set includes multiple attribute fields and field values describing web page elements, and the multiple attribute fields include at least an element position field. The field value of the element position field can indicate the path from the corresponding node to the top node in the document object model DOM tree corresponding to the web page to which the web page element belongs. In an example, the path can be formed by the tag information of the element corresponding to each node.
[0051] In addition, the above-mentioned multiple attribute fields also include at least one of the following: a web page address field, a device pixel ratio field, a web page element's own attribute field, and a related element's own attribute field, etc. Among them, the element position field, the web page address field, and the device pixel ratio field can be collectively referred to as the global features of the web page element.
[0052] In one embodiment, the related elements of any web page element may include the following three items: the element represented by the parent node of the node corresponding to the web page element in the corresponding DOM tree (referred to as the parent element), the element represented by the left sibling node (referred to as the left sibling element), and the element represented by the right sibling node (referred to as the right sibling element).
[0053] Of course, in practice, the related elements of any web page element may also include only any two or any one of the above three items, and this specification does not limit this.
[0054] Finally, the own attribute field of the above-mentioned web page elements or related elements may include several sub-fields, and the several sub-fields may include at least one of the following: element tag, unique identifier id, class attribute, element content, pixel width, pixel height, display type, flex attribute and type of positioning method, etc.
[0055] The field value of the above-mentioned element tag field is an html tag, which can indicate the function of the corresponding web page element (ie, the related element), and thus can play a role in identifying the element category to a certain extent.
[0056] In an example, a single piece of log data may be as shown in Table 1:
[0057] Table 1
[0058]
[0059] Among them, "xpath" is the element position field, "device_pixel_ratio" is the device pixel ratio field, "url" is the web page address field, "self_dom" is the own attribute field of the web page element, "prev_dom", "parent_dom" and "next_dom" are the own attribute fields of the related elements, and "prev_dom" is the own attribute field of the left sibling element, "parent_dom" is the own attribute field of the parent element, and "next_dom" is the own attribute field of the right sibling element.
[0060] In addition, "tag" is the element tag subfield, "id" is the unique identifier id subfield, "class" is the class attribute subfield, "attributes" is other attribute subfields, "innertext" is the element content subfield, "style_width" is the pixel width subfield, "style_height" is the pixel height subfield, "style_display" is the display type subfield, "style_flex" is the flex attribute subfield, and "style_position" is the type subfield of the positioning method.
[0061] Step S304, flattening each attribute field and / or field value of each attribute field in each log data in the log data set to obtain the corresponding text t1, and determining the corresponding text t2 based on the target field value of the element position field in each log data.
[0062] It should be noted that in this solution, the flattening processing methods for each log data are similar. Therefore, the following takes a log data Log1 as an example to illustrate the corresponding flattening processing method.
[0063] In one embodiment, for the log data Log1, the field name and field value of each attribute field therein may be converted into a corresponding character string, and the character strings may be concatenated in sequence to obtain the text t1 corresponding to the log data Log1.
[0064] In a more specific embodiment, the field name and field value of each attribute field can be transformed in an iterative manner. Specifically, the field name and field value of each attribute field can be used as the current field name and current field value in turn, and then the string conversion is performed on them, and then the conversion result is spliced after the current string to obtain an updated string for the next round of iteration, until the field name and field value of each attribute field are converted. After that, the updated string obtained in the last round is determined as the text t1 corresponding to the log data Log1.
[0065] It should be understood that in the first round of iteration, the current string is an empty string.
[0066] Taking the log data in Table 1 as an example, after flattening the log data according to this embodiment, the obtained text t1 may be as shown in Table 2.
[0067] Table 2
[0068]
[0069] It should be understood that Table 2 is only an exemplary description. In practice, attribute fields with empty field values (ie, "null") may be ignored, and this specification does not limit this.
[0070] In addition, for the log data Log1, the field name of the element position field and its field value can be converted into a corresponding character string together, so as to obtain the text t2 corresponding to the log data Log1.
[0071] In another embodiment, for the log data Log1, the field values of the attribute fields except the attribute fields of the related elements can be converted into corresponding character strings, and the character strings are sequentially concatenated to obtain the text t1 corresponding to the log data Log1.
[0072] In this embodiment, the field values of the attribute fields other than the own attribute fields of the related elements may also be transformed in an iterative manner. The specific transformation process is described above and will not be repeated here.
[0073] Taking the log data in Table 1 as an example, the text t1 obtained by flattening the log data according to this embodiment may be as shown in Table 3.
[0074] Table 3
[0075]
[0076] Likewise, in practice, empty field values (ie, "null") may be ignored, and this specification does not limit this.
[0077] In addition, for the log data Log1, the field value of the element position field therein may be converted into a corresponding character string, thereby obtaining the text t2 corresponding to the log data Log1.
[0078] It should be understood that the flattening processing method provided in this embodiment mainly takes into account the change of related element information when a web page element changes position. The change of related element information will cause a large change in the representation of the same web page element, thereby increasing the difficulty of model judgment. Therefore, all related element information is removed, that is, the three fields of prev_dom, next_dom and parent_dom are removed, and the field values of the remaining attribute fields are converted into strings.
[0079] In yet another embodiment, for the log data Log1, the field values of the attribute fields therein are converted into corresponding character strings, and the character strings are sequentially concatenated to obtain the text t1 corresponding to the log data Log1.
[0080] In this embodiment, the field value of each attribute field may also be transformed in an iterative manner. The specific transformation process is described above and will not be repeated here.
[0081] It should be understood that for the log data in Table 1, after flattening according to this embodiment, the resulting text t1 can also refer to that shown in Table 3, except that the text t1 will also include character strings corresponding to the field values of each subfield included in the own attribute field of the related element.
[0082] In addition, it should be understood that in this embodiment, the method for obtaining the text t2 corresponding to the log data Log1 is the same as the method for obtaining the text t2 in the above another embodiment.
[0083] It should be understood that the flattening processing method provided in this embodiment is mainly based on the consideration that the field names in each log data are exactly the same. Including the character strings corresponding to these field names in the text is to add the same information to all log data, which may make the similarity between the texts greater. At the same time, it also fails to provide information that is helpful in distinguishing the log data. Therefore, this embodiment only converts the field values of each attribute field into a character string.
[0084] In another embodiment, for the log data Log1, the field values of the attribute fields therein are converted into corresponding character strings, and the character strings are sequentially concatenated to obtain a concatenated character string, and the field values of the element tag subfields in the own attribute fields of the related elements in the log data Log1 are read to form a related element tag information group. The related element tag information group is concatenated at the front end of the concatenated character string to obtain the text t1 corresponding to the log data Log1.
[0085] It should be understood that, when the related elements of a web page element include: a left sibling element, a parent element, and a right sibling element, the above-mentioned related element tag information group is a triple.
[0086] Taking the log data in Table 1 as an example, the text t1 obtained by flattening the log data according to this embodiment may be as shown in Table 4.
[0087] Table 4
[0088]
[0089] Among them, "(null,div,null)" is a triple formed based on the field values of the tag subfields of the element tags of the left sibling element, the parent element, and the right sibling element.
[0090] In addition, it should be understood that in this embodiment, the method for obtaining the text t2 corresponding to the log data Log1 is the same as the method for obtaining the text t2 in the above another embodiment.
[0091] It should be noted that although the other embodiment mentioned above removes the interference of relevant element information on element category judgment when the position changes, it also makes the model completely unable to use relevant element information to assist in judgment. In order to properly retain some relevant element information to participate in the training of data representation, and at the same time enhance the robustness of the model to changes in relevant element information caused by element position changes during the comparative learning training phase, this embodiment splices the relevant element tag information group at the front end of the above-mentioned spliced string to form text t1. Here, the relevant element tag information group is spliced at the front end instead of the back end to prevent some data from being too long and being truncated during data preprocessing, thereby causing the loss of relevant element information.
[0092] Similar to the method of acquiring the text t1 and the text t2 corresponding to the log data Log1, the text t1 and the text t2 corresponding to each log data in the log data set can be acquired.
[0093] In summary, the log data flattening processing method provided by this solution can improve the quality of representation rather than simply mining the information within the representation, thereby solving the problem of weak generalization of existing text clustering methods.
[0094] Step S306 , forming a positive sample based on the text t1 and the text t2 corresponding to the same target field value, and forming a negative sample based on the text t1 and the text t2 corresponding to different target field values.
[0095] It should be noted that since different log data in the log data set may correspond to the same web page element, different log data may contain the same target field value. It should be understood that when different log data contain the same target field value, the text t2 corresponding to each log data is repeated. Therefore, the text t2 corresponding to each log data can be deduplicated in advance, and then, for the text t1 corresponding to any log data, the text t2 with the same target field value is selected from the deduplicated text t2 to form a positive sample; and the text t2 with a different target field value is selected to form a negative sample.
[0096] Of course, in practice, the above-mentioned deduplication processing steps may not be performed. In this case, after selecting text t2 for any text t1, it is necessary to compare the currently selected text t2 with the selected text t2 to determine whether it is a duplicate selection. If it is a duplicate selection, the currently selected text t2 is abandoned.
[0097] Step S308: training a log representation model based on the positive samples and the negative samples.
[0098] The log representation model here can be implemented as a pre-trained encoder based on natural language text, which can be, for example, one of the following: a contrast representation model SimCSE, a BERT model, etc.
[0099] In order to make the pre-trained encoder based on natural language text better adapt to log data, this solution proposes to train the pre-trained encoder based on the element position search task (XPS search task for short). It should be noted that the purpose of the above XPS search task is to inject the matching relationship between the element position and the log data itself into the model, so that the representation (also called representation) learned by the model can more accurately reflect the semantics of the log data, that is, better adapt to the characteristics of the log data.
[0100] It should be understood that the log data classification task based on similarity matching is similar to the information retrieval task, that is, given a query q, find the corresponding document d. In order to inject the matching relationship between the element position and the log data itself into the model, this solution uses the text t2 determined based on the element position information as the "query" and the text t1 determined based on the log data as the "candidate document" to form a query document pair. At the same time, the document is used as an anchor point to sample positive and negative examples of the query to form a positive and negative query document pair (that is, the above-mentioned positive and negative samples). The specific positive and negative sample construction method refers to the above-mentioned step S306, which will not be repeated here.
[0101] Figure 4 A schematic diagram of a training method for a log representation model in an example of this specification is shown. Figure 4In , the log representation model can be used to process positive samples and negative samples respectively to obtain comprehensive representations r1 and r2 of positive samples and negative samples respectively. Using the classification model, the matching scores z1 and z2 corresponding to the positive samples and negative samples are determined based on the comprehensive representations r1 and r2 respectively. According to the matching scores z1 and z2, the loss l1 is calculated, and the loss l1 is positively correlated with the matching score z1 and negatively correlated with the matching score z2. Based on the comprehensive loss L, the parameters of the log representation model are adjusted, and the comprehensive loss at least includes the loss l1.
[0102] The above-mentioned using the log representation model to process the positive samples (or negative samples) respectively specifically refers to using the log representation model to process the concatenated text of the text t1 and the text t2 in the positive sample (or negative sample) respectively.
[0103] The above-mentioned comprehensive representation r1 and comprehensive representation r2 can be understood as the overall representation corresponding to [CLS] output by the log representation model for positive samples and negative samples respectively.
[0104] In addition, the above classification model can be implemented as a multilayer perceptron (MLP). Specifically, the MLP can be used to map the above comprehensive representations r1 and r2 into two scalars, and the two scalars are used as the matching scores z1 and z2 corresponding to the positive sample and the negative sample, respectively.
[0105] In one example, the loss l1 can be calculated as follows:
[0106]
[0107] Among them, (q + ,d) is a positive sample, (q - ,d) is a negative sample, B is the number of negative samples, score(q + ,d) is the matching score z1, score(q - ,d) is the matching score z2.
[0108] After calculating the above loss l1, it can be directly used as the comprehensive loss L, and based on the comprehensive loss L, the back propagation method is used to calculate the update gradients of the parameters of the log representation model and the classification model, thereby updating the parameters of each log representation model and the classification model.
[0109] It should be noted that in order to prevent the catastrophic forgetting of the masked vocabulary recovery ability during training, this scheme also proposes to train the log representation model in combination with the masked language model MLM task.
[0110] Specifically, before the above-mentioned concatenated text is input into the log representation model, a preset proportion of characters therein may be masked with preset characters. Afterwards, the masked concatenated text is processed using the log representation model to obtain the prediction results output by the log representation model for the masked characters. Finally, based on the difference between the masked characters and their prediction results, based on the cross entropy loss function, the loss l2 and the comprehensive loss L based on the loss l1 and the loss l2 can be calculated, and the update gradients of the parameters of the log representation model and the classification model can be calculated using the back propagation method, thereby updating the parameters of the log representation model and the classification model.
[0111] It should be understood that when this scheme trains the log representation model based on the loss l2, it can effectively capture the semantic information contained in the element's own attributes, which helps to improve the accuracy of log data classification.
[0112] In addition, in this scheme, the weights of the above-mentioned loss l1 and loss l2 can be set to 1, and then the weighted sum of the two losses can be obtained to obtain the above-mentioned comprehensive loss L, which can facilitate the model to more fully adapt to the inherent characteristics of log data, and thereby extract an effective representation that is more suitable for such special text structures.
[0113] At this point, a round of iterative training of the log representation model based on loss l1 or comprehensive loss L is completed. Then, in the next round of iteration, the log representation model can be trained based on contrast loss. That is to say, in this solution, the log representation model can be trained alternately based on loss l1 and contrast loss, or the log representation model can be trained alternately based on comprehensive loss L and contrast loss.
[0114] The following describes the process of training a log representation model based on contrastive loss.
[0115] Figure 5 A schematic diagram of a training method for a log representation model in another example of this specification is shown. Figure 5 In the example, the enhanced text t1' of the text t1 corresponding to each log data is obtained. The log representation model is used to process the text t1 and its enhanced text t1' corresponding to each log data, and the text representation h and text representation h corresponding to each log data are obtained. p Based on the text representation h and text representation h p , calculate the contrast loss, and use the contrast loss to adjust the parameters of the log representation model.
[0116] In this scheme, sample positive examples (consisting of text t1 and enhanced text t1') in contrastive learning can be constructed based on two different enhancement strategies: one is a random dropout strategy, and the other is a strategy of replacing related element tag information groups.
[0117] Among them, the random dropout strategy is a method that imposes minimal disturbance on text representation, and is more likely to maintain the stability of the original intention of the text during the disturbance process. Given the universal applicability of the random dropout strategy on natural language text and log data, this scheme also adopts this data augmentation strategy in contrastive learning.
[0118] In addition, the strategy of replacing the relevant element tag information group is proposed by the inventor of this solution based on the characteristics of log data and the characteristics of classification tasks. It should be noted that when constructing sample positive examples based on this strategy, the robustness of the log representation model to the position change of elements before and after the web page or application is updated can be enhanced.
[0119] In a more specific implementation, one of the two enhancement strategies may be selected for execution with a probability of 50%. Of course, in practice, only one enhancement strategy may be selected to construct a sample positive example, and this specification does not limit this.
[0120] Among them, under the random dropout strategy, the enhanced text t1' and text t1 corresponding to any log data are the same, so the text representation h and text representation h corresponding to any log data are p The method for obtaining is as follows: obtain the same initial text representation obtained by processing the text t1 and its enhanced text t1' corresponding to any log data using the log representation model, and perform two random zeroing processes on the elements in the initial text representation to obtain text representation h and text representation h p Among them, in any random zeroing process, a number of randomly selected elements will be set to zero.
[0121] Under the strategy of replacing the relevant element tag information group, the enhanced text of the text t1 corresponding to any log data is obtained by randomly replacing the relevant element tag information group in the text t1.
[0122] For example, the relevant element tag information group in the text t1 corresponding to any log data can be replaced with the relevant element tag information group in the text t1 corresponding to other log data. It should be understood that the relevant element tag information groups before and after the replacement are different.
[0123] It should be noted that under the above two strategies, the texts t1 corresponding to different log data constitute negative examples of each other.
[0124] Specifically, the contrast loss can be calculated based on the difference between the two text representations corresponding to the positive sample and the difference between the two text representations corresponding to the negative sample, based on the InfoNCE loss function, and the contrast loss is positively correlated to the difference between the two text representations corresponding to the positive sample, and negatively correlated to the difference between the two text representations corresponding to the negative sample.
[0125] It should be noted that in this scheme, the purpose of introducing the above-mentioned contrast loss is to align the log data corresponding to the same web page element, ensure that the positions of different log data from the same web page element are closer in the representation space, and at the same time increase the distance between the log data corresponding to different elements in the representation space, which helps to improve the robustness of the model to changes in element features before and after the web page or application is updated.
[0126] It should be understood that after multiple rounds of alternating training of the log representation model based on the comprehensive loss L (or loss l1) and the contrast loss, the log representation model obtained in the last round of training is used as the final log representation model to classify the log data. The classification process is explained below.
[0127] Obtain the target log data to be classified, and flatten the target log data to obtain the target text. Use the log representation model obtained by the above training to process the target text and each candidate text in the candidate set respectively, and obtain the text representation of the target text and each candidate text. Among them, a single candidate text corresponds to a web page element. Based on the text representation of the target text and each candidate text, calculate the similarity between the target text and each candidate text. The web page element corresponding to the candidate text with the highest similarity among the candidate texts is determined as the target web page element corresponding to the target log data.
[0128] The similarity mentioned above may include but is not limited to cosine similarity, Euclidean distance, Manhattan distance, Pearson correlation coefficient, etc.
[0129] In summary, the training method of the log representation model provided in the embodiments of this specification first proposes that the log representation model can be trained based on the XPS search task, so that the trained log representation model can effectively capture the element position information in the log data, thereby improving the performance on the log data classification task. Secondly, it is also proposed that the log representation model can be trained in combination with the XPS search task and the MLM task. This two-pronged strategy helps to prevent the problem of catastrophic forgetting in the pre-trained encoder during the training process on the one hand, and on the other hand, it can be adaptively adjusted according to the characteristic differences between the log data and the conventional natural language text, so as to more accurately construct the semantic representation at the word level. Finally, it is also proposed that the log representation model can be trained based on the contrastive learning task, thereby strengthening the similarity representation of the same web page element under different variants, while enhancing the ability to distinguish the differences between different web page elements.
[0130] Corresponding to the above-mentioned log representation model training method, an embodiment of the present specification also provides a log representation model training device, such as Figure 6 As shown, the device may include:
[0131] The acquisition unit 602 is used to acquire a log data set obtained by embedding points on web page elements, wherein a single log data includes multiple attribute fields and field values describing the web page elements, and the multiple attribute fields include an element position field.
[0132] Processing unit 604 is used to flatten each attribute field and / or field value of each attribute field in each log data in the log data set to obtain the corresponding first text, and determine the corresponding second text based on the target field value of the element position field in each log data.
[0133] The forming unit 606 is configured to form a positive sample based on the first text and the second text corresponding to the same target field value, and form a negative sample based on the first text and the second text corresponding to different target field values.
[0134] The training unit 608 is used to train the log representation model based on the positive samples and the negative samples.
[0135] The target field value of the element position field in any first log data is the path from the corresponding node of the first web page element in the corresponding DOM tree to the top node.
[0136] The above-mentioned multiple attribute fields also include at least one of the following:
[0137] The web page address field, the device pixel ratio field, the web page element's own attribute field, and the related element's own attribute field.
[0138] The above-mentioned own attribute field includes several subfields, and the several subfields include at least one of the following:
[0139] Element tag, unique identifier id, class attribute, element content, pixel width, pixel height, display type, flex attribute and type of positioning method.
[0140] In addition, related elements of any of the above web page elements include:
[0141] The element represented by the parent node, the element represented by the left sibling node, and the element represented by the right sibling node of the corresponding node of the web page element in the corresponding DOM tree.
[0142] In one embodiment, the processing unit 604 is specifically configured to:
[0143] For any first log data, the field name and field value of each attribute field therein are converted into corresponding character strings, and the character strings are sequentially concatenated to obtain the first text corresponding to the first log data.
[0144] In another embodiment, the above-mentioned attribute fields include the own attribute fields of the related elements, and the processing unit 604 is specifically used to:
[0145] For any first log data, the field values of the attribute fields other than the own attribute field of the relevant element are converted into corresponding character strings, and the character strings are sequentially concatenated to obtain the first text corresponding to the first log data.
[0146] In yet another embodiment, the processing unit 604 includes:
[0147] The conversion submodule 6042 is used for converting the field value of each attribute field in any first log data into corresponding strings, and sequentially concatenating the strings to obtain a concatenated string;
[0148] The determination submodule 6044 is used to determine the first text corresponding to the first log data according to the concatenated character string.
[0149] In a more specific embodiment, each attribute field includes an own attribute field of a related element, and the own attribute field includes an element tag subfield;
[0150] The determination submodule 6044 is specifically used for:
[0151] Read the field value of the element tag subfield from the first log data to form a related element tag information group;
[0152] The related element tag information group is concatenated at the front end of the concatenated character string to obtain the first text corresponding to the first log data.
[0153] In one embodiment, the training unit 608 includes:
[0154] A processing submodule 6082 is used to process the positive sample and the negative sample respectively by using the log representation model to obtain a first comprehensive representation and a second comprehensive representation of the positive sample and the negative sample respectively;
[0155] A mapping submodule 6084 is used to determine, using the classification model, a first matching score and a second matching score corresponding to the positive sample and the negative sample respectively based on the first comprehensive representation and the second comprehensive representation;
[0156] A calculation submodule 6086, configured to calculate a first loss according to the first matching score and the second matching score;
[0157] The adjustment submodule 6088 is used to adjust the parameters of the log characterization model based on the comprehensive loss, where the comprehensive loss includes at least the first loss.
[0158] The processing submodule 6082 is specifically used for:
[0159] splicing the first text and the second text in the input sample into a spliced text, where the input sample is the positive sample or the negative sample;
[0160] Masking a preset proportion of words in the spliced text with preset words, and processing the masked spliced text using the log representation model;
[0161] The device also includes:
[0162] A calculation unit 610, configured to use the masked characters in the concatenated text as sample labels to calculate a second loss;
[0163] The determination unit 612 is used to determine the comprehensive loss according to the first loss and the second loss.
[0164] In one embodiment, the acquisition unit 602 is further configured to acquire an enhanced text of the first text corresponding to each piece of log data;
[0165] The processing unit 604 is further configured to use the log representation model to process the first text and the enhanced text corresponding to each piece of log data respectively, to obtain the first text representation and the second text representation corresponding to each piece of log data;
[0166] The training unit 608 is further configured to calculate a contrast loss based on the first text representation and the second text representation, and adjust parameters of the log representation model using the contrast loss.
[0167] In one embodiment, each piece of log data includes first log data, and a first text corresponding to the first log data is the same as its enhanced text;
[0168] The first text representation and the second text representation corresponding to the first log data are obtained by performing random zeroing processing on elements in the same initial text representation output by the log representation model for the first text and the enhanced text thereof.
[0169] In another embodiment, the first text includes a related element tag information group, and each piece of log data includes second log data;
[0170] The enhanced text of the first text corresponding to the second log data is obtained by randomly replacing the relevant element tag information group in the first text.
[0171] In one embodiment, the log representation model is one of the following: a comparison representation model SimCSE, a BERT model.
[0172] The functions of the functional units of the device in the above-mentioned embodiment of this specification can be implemented through the steps of the above-mentioned method embodiment. Therefore, the specific working process of the device provided by one embodiment of this specification will not be repeated here.
[0173] An embodiment of the present specification provides a device for training a log representation model, and the trained log representation model can be used to classify log data, thereby ensuring the continuity of the counted log data.
[0174] Corresponding to the above-mentioned log classification method, an embodiment of this specification also provides a log classification device, such as Figure 7 As shown, the device may include:
[0175] The acquisition unit 702 is used to acquire target log data to be classified, and flatten the target log data to obtain target text.
[0176] The acquisition unit 702 is further configured to acquire a log representation model. Figure 3 The method shown is trained.
[0177] The processing unit 704 is used to process the target text and each candidate text in the candidate set respectively by using the log representation model to obtain text representations of the target text and each candidate text, wherein a single candidate text corresponds to a web page element.
[0178] The calculation unit 706 is used to calculate the similarity between the target text and each candidate text based on the text representation.
[0179] The determination unit 708 is used to determine the web page element corresponding to the candidate text with the highest similarity among the candidate texts as the target web page element corresponding to the target log data.
[0180] The functions of the functional units of the device in the above-mentioned embodiment of this specification can be implemented through the steps of the above-mentioned method embodiment. Therefore, the specific working process of the device provided by one embodiment of this specification will not be repeated here.
[0181] A log classification device provided by an embodiment of the present specification can realize accurate classification of log data.
[0182] According to another embodiment, there is also provided a computer-readable storage medium having a computer program stored thereon, which, when executed in a computer, causes the computer to execute a combination of Figure 3 The method described.
[0183] According to another embodiment of the present invention, a computing device is provided, including a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, the Figure 3 The method described.
[0184] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the medium or device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0185] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0186] The specific implementation methods described above further illustrate the purpose, technical solutions and beneficial effects of this specification. It should be understood that the above description is only the specific implementation method of this specification and is not intended to limit the protection scope of this specification. Any modifications, equivalent substitutions, improvements, etc. made on the basis of the technical solutions of this specification should be included in the protection scope of this specification.
Claims
1. A method for training a log representation model, comprising: Get the log data set obtained by embedding points on web page elements, where a single log data includes: Describe multiple attribute fields and their field values of web page elements; The multiple attribute fields include an element position field; Flattening each attribute field and / or field value of each attribute field in each log data in the log data set to obtain a corresponding first text, and determining a corresponding second text based on a target field value of an element position field in each log data; Forming a positive sample based on the first text and the second text corresponding to the same target field value, and forming a negative sample based on the first text and the second text corresponding to different target field values; The log representation model is trained based on the positive samples and the negative samples.
2. The method according to claim 1, wherein: The target field value of the element position field in any first log data is the path from the corresponding node of the first web page element in the corresponding DOM tree to the top node.
3. The method according to claim 1, wherein: The plurality of attribute fields also include at least one of the following: The web page address field, the device pixel ratio field, the web page element's own attribute field, and the related element's own attribute field.
4. The method according to claim 3, wherein: The own attribute field includes several subfields, and the several subfields include at least one of the following: Element tag, unique identifier id, class attribute, element content, pixel width, pixel height, display type, flex attribute and type of positioning method.
5. The method according to claim 3, wherein: The relevant elements of any web page element include: The element represented by the parent node, the element represented by the left sibling node, and the element represented by the right sibling node of the corresponding node of the web page element in the corresponding DOM tree.
6. The method according to claim 1, wherein: The obtaining of the corresponding first text includes: For any first log data, the field name and field value of each attribute field therein are converted into corresponding character strings, and the character strings are sequentially concatenated to obtain the first text corresponding to the first log data.
7. The method according to claim 1, wherein: Each attribute field includes an attribute field of a related element; and obtaining the corresponding first text includes: For any first log data, the field values of the attribute fields other than the own attribute field of the related element are converted into corresponding character strings, and the character strings are sequentially concatenated to obtain the first text corresponding to the first log data.
8. The method according to claim 1, wherein: The obtaining of the corresponding first text includes: For any first log data, convert the field value of each attribute field therein into corresponding strings, and sequentially concatenate the strings to obtain a concatenated string; A first text corresponding to the first log data is determined according to the concatenated character string.
9. The method according to claim 8, wherein: Each attribute field includes an attribute field of a related element, and the attribute field includes an element tag subfield; The determining, according to the concatenated character string, a first text corresponding to the first log data includes: Read the field value of the element tag subfield from the first log data to form a related element tag information group; The related element tag information group is concatenated at the front end of the concatenated string to obtain a first text corresponding to the first log data.
10. The method according to claim 1, wherein: The training of the log representation model comprises: Using the log representation model to process the positive sample and the negative sample respectively, to obtain a first comprehensive representation and a second comprehensive representation of the positive sample and the negative sample respectively; Determine, by using a classification model, a first matching score and a second matching score corresponding to the positive sample and the negative sample, respectively, based on the first comprehensive representation and the second comprehensive representation; Calculating a first loss according to the first matching score and the second matching score; Parameters of the log characterization model are adjusted based on a comprehensive loss, the comprehensive loss including at least the first loss.
11. The method according to claim 10, wherein: The using the log representation model to process the positive samples and negative samples respectively includes: splicing the first text and the second text in the input sample into a spliced text; the input sample is the positive sample or the negative sample; Masking a preset proportion of characters in the spliced text with preset characters, and processing the masked spliced text using the log representation model; The method further comprises: Taking the masked words in the concatenated text as sample labels, and calculating the second loss; The comprehensive loss is determined based on the first loss and the second loss.
12. The method according to claim 1, further comprising: Obtaining enhanced text of the first text corresponding to each of the log data; Using the log representation model, respectively process the first text and the enhanced text corresponding to each of the log data to obtain the first text representation and the second text representation corresponding to each of the log data; Based on the first text representation and the second text representation, a contrast loss is calculated, and the contrast loss is used to adjust the parameters of the log representation model.
13. The method according to claim 12, wherein: Each piece of log data includes first log data; the first text corresponding to the first log data is the same as the enhanced text thereof; The first text representation and the second text representation corresponding to the first log data are obtained by performing random zeroing processing on elements in the same initial text representation output by the log representation model for the first text and the enhanced text thereof.
14. The method according to claim 12, wherein: The first text includes a related element tag information group; each piece of log data includes second log data; The enhanced text of the first text corresponding to the second log data is obtained by randomly replacing the relevant element tag information group in the first text.
15. The method according to claim 1, wherein: The log representation model is one of the following: a comparative representation model SimCSE, a BERT model.
16. A log classification method, comprising: Obtain target log data to be classified, and flatten the target log data to obtain target text; Obtaining a log representation model, where the log representation model is trained according to the method as claimed in claim 1; Using the log representation model to process the target text and each candidate text in the candidate set respectively, to obtain text representations of the target text and each candidate text; wherein a single candidate text corresponds to a web page element; Based on the text representation, calculating the similarity between the target text and each candidate text; The web page element corresponding to the candidate text with the highest similarity among the candidate texts is determined as the target web page element corresponding to the target log data.
17. A training device for a log representation model, comprising: The acquisition unit is used to acquire a log data set obtained by embedding points on web page elements, wherein a single log data includes: Describe multiple attribute fields and their field values of web page elements; The multiple attribute fields include an element position field; A processing unit, configured to flatten each attribute field and / or field value of each attribute field in each log data in the log data set to obtain a corresponding first text, and determine a corresponding second text based on a target field value of an element position field in each log data; A forming unit, configured to form a positive sample based on the first text and the second text corresponding to the same target field value, and to form a negative sample based on the first text and the second text corresponding to different target field values; A training unit is used to train the log representation model based on the positive samples and the negative samples.
18. The device according to claim 17, wherein: The processing unit comprises: The conversion submodule is used for converting the field value of each attribute field in any first log data into corresponding strings, and sequentially concatenating the strings to obtain a concatenated string; A determination submodule is used to determine the first text corresponding to the first log data according to the concatenated character string.
19. The device according to claim 18, wherein: Each attribute field includes an attribute field of a related element, and the attribute field includes an element tag subfield; The determination submodule is specifically used for: Read the field value of the element tag subfield from the first log data to form a related element tag information group; The related element tag information group is concatenated at the front end of the concatenated string to obtain a first text corresponding to the first log data.
20. The device according to claim 17, wherein: The training unit comprises: A processing submodule, configured to process the positive sample and the negative sample respectively by using the log representation model to obtain a first comprehensive representation and a second comprehensive representation of the positive sample and the negative sample respectively; A mapping submodule, configured to determine, by using a classification model, a first matching score and a second matching score corresponding to the positive sample and the negative sample respectively based on the first comprehensive representation and the second comprehensive representation; A calculation submodule, configured to calculate a first loss according to the first matching score and the second matching score; An adjustment submodule is used to adjust the parameters of the log characterization model based on the comprehensive loss, and the comprehensive loss at least includes the first loss.
21. The device according to claim 20, wherein: The processing submodule is specifically used for: splicing the first text and the second text in the input sample into a spliced text; the input sample is the positive sample or the negative sample; Masking a preset proportion of characters in the spliced text with preset characters, and processing the masked spliced text using the log representation model; The device also includes: A calculation unit, used for calculating a second loss by taking the masked words in the concatenated text as sample labels; A determining unit is used to determine the comprehensive loss according to the first loss and the second loss.
22. The device according to claim 17, The acquisition unit is further used to acquire the enhanced text of the first text corresponding to each of the log data; The processing unit is further used to use the log representation model to process the first text and the enhanced text corresponding to each of the log data respectively, to obtain the first text representation and the second text representation corresponding to each of the log data; The training unit is further configured to calculate a contrast loss based on the first text representation and the second text representation, and to adjust parameters of the log representation model using the contrast loss.
23. A log classification device, comprising: An acquisition unit, used for acquiring target log data to be classified, and performing flattening processing on the target log data to obtain a target text; The acquisition unit is further used to acquire a log representation model, where the log representation model is trained according to the method according to claim 1; A processing unit, used to process the target text and each candidate text in the candidate set respectively using the log representation model to obtain text representations of the target text and each candidate text; wherein a single candidate text corresponds to a web page element; A calculation unit, used for calculating the similarity between the target text and each candidate text based on the text representation; The determination unit is used to determine the web page element corresponding to the candidate text with the highest similarity among the candidate texts as the target web page element corresponding to the target log data.
24. A computer-readable storage medium having a computer program stored thereon, wherein: When the computer program is executed in a computer, the computer is caused to execute the method according to any one of claims 1 to 16.
25. A computing device comprising a memory and a processor, wherein: The memory stores executable codes, and when the processor executes the executable codes, the method according to any one of claims 1 to 16 is implemented.