Classification model training and use method, device, equipment and storage medium

Through the adversarial training classification model, the problems of retesting test results and prediction of error information in software automation tests are solved, and the automatic classification of software test results is realized, which improves the testing efficiency and quality.

CN113591998BActive Publication Date: 2024-12-17SHANGHAI PUDONG DEVELOPMENT BANK
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110887260.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-08-03
Publication Date
2024-12-17
Estimated Expiration
2041-08-03

AI Technical Summary

Technical Problem

In software automation testing, the existing technology relies on a large amount of manpower for repeated regression tests and retest results, which have subjective experience errors, which affect the quality and efficiency of the test, and cannot effectively predict new error information.

Method used

A classification model training method is adopted. By inputting the sample text into the feature model, the word vector of the word is obtained, and the word vector, perturbation vector and position characteristics are processed through the initial model, and the target classification model is obtained to realize software testing. Automatic classification of results.

Benefits of technology

It improves the classification accuracy of software test results, reduces the labor force of testers, and improves the efficiency and quality of software development and testing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113591998B_ABST
    Figure CN113591998B_ABST
Patent Text Reader

Abstract

The present invention discloses a method, device, equipment and storage medium for training and using a classification model, and belongs to the technical field of software automated testing and natural language processing. The method comprises: inputting a sample text into a feature model to obtain word vectors of words in the sample text; processing the word vectors of words, the perturbation vectors of words and the position features of words through an initial model to obtain the classification prediction results of the sample text; wherein the initial model comprises at least one two-layer bidirectional LSTM, an attention mechanism layer and a classification layer; determining a target classification loss value according to the classification prediction results of the sample text and the supervision data of the sample text; and training the initial model according to the target classification loss value to obtain a target classification model. Through the above technical solution, the software test results can be automatically classified, reducing the labor of testers for retesting, thereby improving the efficiency and quality of software development and testing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of software automated testing and natural language processing, and in particular to a method, device, equipment and storage medium for training and using a classification model. Background Art

[0002] With the promotion of DevOps concepts in Internet companies, continuous integration and continuous testing have become the mainstream trend of current project testing. By continuously performing automated testing and analyzing various defects and risks related to the latest software development, developers can be provided with fast and quick feedback to improve the quality of project delivery.

[0003] In the process of software automation testing, testers will design automated test cases for related functions, execute the cases through the test platform, feedback the test results of success and failure, and manually determine whether the cause of the failure information is a defect in the software function. Automated testing often involves repeated regression testing. Repeated testing relies on a lot of manpower costs to retest and analyze the test results, and subjective experience may lead to errors, which affects the quality and efficiency of testing.

[0004] At present, there are also platforms that manually add error information to the information library based on test results each time, and gradually expand the error information resource library, but this method is not predictive and cannot judge new error information. Therefore, how to automatically classify software test results has important practical value for software testing and software development. Summary of the invention

[0005] The present invention provides a method, device, equipment and storage medium for training and using a classification model to achieve automatic classification of software test results.

[0006] In a first aspect, an embodiment of the present invention provides a method for training a classification model, comprising:

[0007] Inputting the sample text into the feature model to obtain word vectors of the words in the sample text; wherein the feature model includes a two-layer bidirectional LSTM; the sample text is a historical software test result, and the types of the historical software test results include environment problems, data problems, business problems, code problems, and case problems;

[0008] The word vector, the perturbation vector and the position feature of the word are processed by the initial model to obtain the classification prediction result of the sample text; wherein the initial model includes at least one two-layer bidirectional LSTM, an attention mechanism layer and a classification layer;

[0009] Determining a target classification loss value according to the classification prediction result of the sample text and the supervision data of the sample text;

[0010] According to the target classification loss value, adversarial training is performed on the initial model to obtain a target classification model.

[0011] In a second aspect, an embodiment of the present invention further provides a method for using a classification model, including:

[0012] Determine the word vector of the words in the target text; the target file is the software test result to be classified;

[0013] The word vectors of the words in the target text are input into the target classification model to obtain the classification prediction result of the target text; wherein the target classification model is obtained by the training method of the classification model described in any one of claims 1-7.

[0014] In a third aspect, an embodiment of the present invention further provides a training device for a classification model, comprising:

[0015] A word vector determination module is used to input a sample text into a feature model to obtain word vectors of words in the sample text; wherein the feature model includes a two-layer bidirectional LSTM; the sample text is a historical software test result, and the types of historical software test results include environment problems, data problems, business problems, code problems, and case problems;

[0016] A prediction result determination module, used to process the word vector, the perturbation vector and the position feature of the word through an initial model to obtain the classification prediction result of the sample text; wherein the initial model includes at least one two-layer bidirectional LSTM, an attention mechanism layer and a classification layer;

[0017] A classification loss value determination module, used to determine a target classification loss value according to the classification prediction result of the sample text and the supervision data of the sample text;

[0018] The classification model determination module is used to perform adversarial training on the initial model according to the target classification loss value to obtain a target classification model.

[0019] In a fourth aspect, an embodiment of the present invention further provides a device for using a classification model, including:

[0020] A word vector determination module, used to determine the word vectors of words in a target text; the target file is a software test result to be classified;

[0021] A prediction result determination module is used to input the word vectors of the words in the target text into the target classification model to obtain the classification prediction result of the target text; wherein, the target classification model is obtained by the training method of the classification model mentioned in the first aspect.

[0022] In a fifth aspect, an embodiment of the present invention further provides an electronic device, including:

[0023] one or more processors;

[0024] A memory for storing one or more programs;

[0025] When the one or more programs are executed by the one or more processors, the one or more processors implement the training method of the classification model provided in the first aspect, or implement the method of using the classification model provided in the second aspect.

[0026] In a sixth aspect, an embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements a training method for a classification model as provided in the first aspect, or implements a method for using a classification model as provided in the second aspect.

[0027] The technical solution of the embodiment of the present invention obtains the word vector of the words in the sample text by inputting the sample text into the feature model, and then processes the word vector, the perturbation vector and the position feature of the word through the initial model to obtain the classification prediction result of the sample text, and determines the target classification loss value according to the classification prediction result of the sample text and the supervision data of the sample text, and then conducts adversarial training on the initial model according to the target classification loss value to obtain the target classification model. The above technical solution inputs the word vector, the perturbation vector and the position feature of the word into the model together, which can learn the long-distance and deep text feature information, thereby improving the classification accuracy of the text; at the same time, the software test results can be automatically classified, reducing the labor of testers for retesting, thereby improving the efficiency and quality of software development and testing. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] Figure 1A is a flow chart of a classification model training method provided in Embodiment 1 of the present invention;

[0029] Figure 1B It is a model diagram of a single LSTM unit provided in Example 1 of the present invention;

[0030] Figure 2A is a flow chart of a classification model training method provided in Embodiment 2 of the present invention;

[0031] Figure 2B It is a model diagram of a feature model and a classification model provided in the second embodiment of the present invention;

[0032] Figure 3 is a flow chart of a method for using a classification model provided in Embodiment 3 of the present invention;

[0033] Figure 4 It is a structural schematic diagram of a classification model training device provided in Embodiment 4 of the present invention;

[0034] Figure 5 is a structural schematic diagram of a device for using a classification model provided in Embodiment 5 of the present invention;

[0035] Figure 6 It is a structural schematic diagram of an electronic device provided in Embodiment 6 of the present invention. DETAILED DESCRIPTION

[0036] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present invention, rather than to limit the present invention. It should also be noted that, for ease of description, only parts related to the present invention, rather than all structures, are shown in the accompanying drawings.

[0037] Embodiment 1

[0038] Figure 1A It is a flowchart of a classification model training method provided in Example 1 of the present invention. This embodiment is applicable to situations where software measurement results are predicted and judged. The method can be executed by a classification model training device, which can be implemented by software and / or hardware and can be integrated into an electronic device that carries the classification model training function, such as a server.

[0039] like Figure 1A As shown, the method may specifically include:

[0040] S110, inputting the sample text into the feature model to obtain word vectors of the words in the sample text; the sample text is a historical software test result, and the types of historical software test results include environmental problems, data problems, business problems, code problems, and case problems.

[0041] In this embodiment, the sample text is the historical software test result, which can be the processed short text data of the software development error code of the mobile software, or the processed short text data of the failure result prompt of the automated testing platform; further, the sample text can be divided into five categories: environmental problems, data problems, business problems, code problems, and case problems.

[0042] Environmental issues include network anomalies, system issues, and service failures, such as network connection failure, backend system return exception, proxy service call exception, communication timeout, etc. Data issues include format issues, time anomalies, data errors, etc., such as the current transaction time is not within the transaction time, the receiving account does not meet the required format, the dynamic password input error, the mobile phone number or password is invalid, etc. Business issues are errors in business logic, such as the contract status is abnormal and cannot be modified, the product is currently not allowed to conduct this transaction, and the account has not passed the risk verification and is not supported yet; Code issues are program development issues that lead to test failures, such as An error occurred, database table insertion error!, com.csii.pe.communication.exception, etc. Case issues are errors in case design that lead to execution failures, such as the inability to locate the text box, the checkpoint "OK" does not exist, and the inability to locate the picture.

[0043] In this embodiment, the feature model can be a charCNN model or a word2vec model. Accordingly, the sample text can be processed based on the charCNN model to obtain the word vectors of the words in the sample text. Furthermore, the sample text can be processed based on the word2vec model to obtain the word vectors of the words in the sample text.

[0044] S120. Process the word vector, the word disturbance vector and the word position feature through the initial model to obtain the classification prediction result of the sample text.

[0045] The so-called perturbation vector of a word refers to the vector of the interference word corresponding to the word. Optionally, the interference word corresponding to the word can be determined first according to the word, and then the interference word is processed according to the charCNN model or the word2vec model to obtain the word vector of the interference word, that is, the perturbation vector of the word.

[0046] Optionally, the expectation and variance of the sample text may be determined based on the word vector and word frequency of the word, and then the perturbation vector of the word may be determined based on the expectation and variance of the sample text and the word. Specifically, the expectation and variance of the sample text may be determined based on the word vector and word frequency of each word in the sample text, for example, by the following formula:

[0047]

[0048]

[0049] Among them, w k Represents the word vector of the kth word in the sample text, f krepresents the frequency of the kth word in all text samples, E(w) represents the expectation of the sample text, Var(w) represents the variance of the sample text, and N represents the number of words in each sample text.

[0050] Then, according to the expectation and variance of the sample text and the words, the perturbation vector of the word is determined, for example, it can be determined by the following formula:

[0051]

[0052] Among them, w' k represents the perturbation vector of the kth word, w k Represents the word vector of the kth word.

[0053] It is understandable that by adding perturbation vectors of words for adversarial training, the training performance of the model can be improved, thereby improving the model's ability to defend against interference samples.

[0054] The so-called position feature refers to the position feature of each word in a word. Optionally, the words in the word can be encoded according to the length of the word to obtain the position feature of the word. Specifically, the length of each word is determined. If the length is 1, the part is a single word, which is marked with the number "0"; if the length is greater than 1, the part is a word, the first word of the word is marked with the number "1", the last word is marked with the number "3", and the rest is marked with the number "2". For example, if it is a word with a length of 1, the position feature of the word is 0; if it is a word with a length of 2, the position feature of the word is 13; if it is a word with a length of 4, the position feature of the word is 1223.

[0055] It is understandable that introducing position features into word vectors can provide richer feature information to improve classification accuracy.

[0056] It should be noted that the vector dimensions of the word vector, the word perturbation vector, and the word position feature are the same.

[0057] The initial model includes at least one two-layer bidirectional long short-term memory (LSTM), an attention mechanism layer, and a classification layer. The attention mechanism layer is used to weight the feature representation output by the bidirectional LSTM; the classification layer is used to classify the weighted feature representation; the bidirectional LSTM is used to predict words. In order to more accurately predict words in combination with the context, the forward LSTM and the backward LSTM are used. The forward LSTM is used to predict the following context based on the previous context, that is, the first k-1 words are used to predict the kth word; the backward LSTM is used to predict the previous context based on the following context, that is, the words after k are used to predict the kth word.

[0058] Both the forward LSTM layer and the backward LSTM layer include two layers of LSTM, which makes up for the lack of contextual semantic information in a single-layer LSTM. Furthermore, each LSTM layer corresponds to an output layer, which can predict the complete past and future contextual information at each moment in the text sequence. Figure 1B As shown in Figure 1, LSTM designs three control gates to implement a controllable memory neural unit. As shown in formula (1), the forget gate determines which information output at the previous moment needs to be discarded, and uses the Sigmoid function to output a value between 0 and 1, 1 means completely retained, and 0 means completely discarded; as shown in formulas (2) and (3), the input gate determines which information is saved to the memory unit, which consists of two parts: one part is the Sigmoid layer, which determines what value to update; the other part is the tanh layer, which creates a new candidate value vector; as shown in formula (4), the forget gate obtains the information f that needs to be discarded k , the input gate obtains the value i that needs to be updated k After that, the cell state changes from C k-1 Update to C k As shown in equations (5) and (6), the output gate determines which information can be output, uses the Sigmoid function to regularize it into a weight between 0 and 1, uses the tanh function to transform the memory value to a value between -1 and 1, and then compares it with the output value o of the output gate. k Multiply them together to get the final output formula.

[0059] f k =σ(W f ·[h k-1 ,w k ]+b f ) (1)

[0060] i k =σ(W i ·[h k-1 ,w k ]+b i ) (2)

[0061]

[0062]

[0063] o k =σ(W o ·[h k-1 ,w k ]+b o ) (5)

[0064] h k =o k *tanh(C k) (6)

[0065] Among them, w k Represents the word vector input at time k, h k-1 It is represented as the output of LSTM at time k-1, σ represents the Sigmoid function, W f , W i , W o , W c They are the forget gate, input gate, output gate, updated weight vector, and b f 、b i 、b c 、b o is its corresponding bias vector. Under the action of three control gate switches, LSTM can solve the long-distance dependency problem and, to a certain extent, the gradient vanishing and gradient exploding problems. The output vector of the forward LSTM is and the output vector of the reverse LSTM The calculation method of is similar to that of a single LSTM, and the final output vector is obtained by merging the forward output vector and the reverse output vector.

[0066] Optionally, the word vector, the word perturbation vector and the word position feature are combined and concatenated, and input into the bidirectional LSTM to obtain the feature representation of each word in the sample text, and then the feature representation of each word in the sample text is input into the attention mechanism layer. In the attention mechanism layer, different weights are assigned to the feature representation of each word in the sample text to obtain the optimized feature representation. For example, the optimized feature representation can be determined by the following formula:

[0067] u k =tanh(W s h k +b s )

[0068]

[0069]

[0070] Among them, h k is the feature representation at time k learned by bidirectional LSTM, W s 、b s 、u s is the parameter of the attention mechanism; u k h k The hidden layer representation obtained through a simple neural network layer; a k h k The scoring weight of the corresponding feature word's contribution to distinguishing text categories; k is the feature vector of the final text information, that is, the optimized feature representation.

[0071] It can be understood that compared with the traditional method of directly summing and averaging the updated output vectors corresponding to each moment of the LSTM layer, it is assumed that each feature word has the same contribution to distinguishing text categories; in the present invention, the weight of unimportant words is set to a smaller proportion, while the weight of words with strong category distinction ability is set to a larger proportion. Therefore, the attention mechanism is introduced to divide different proportional weights into areas with different contributions to the current task, thereby enhancing the expression of words with category distinction ability, weakening the influence of redundant features on text classification, and screening out more critical information for classification from a large amount of information to improve the accuracy of classification.

[0072] Then, the optimized feature representation is input into the classification layer for text classification. The classification layer can use the Softmax classifier as follows:

[0073]

[0074] Among them, x is the input text, θ is the parameter learned by model training, y is the classification label, and the model finally outputs p(y i |x,θ) is the category with the largest probability value, i∈{1, 2, 3, …, n}, and n represents the number of text categories.

[0075] S130: Determine a target classification loss value according to the classification prediction result of the sample text and the supervision data of the sample text.

[0076] In this embodiment, a cross entropy loss function is used to determine a target classification loss value based on the classification prediction result of the sample text and the supervision data of the sample text.

[0077] S140. According to the target classification loss value, the initial model is subjected to adversarial training to obtain a target classification model.

[0078] In this embodiment, the initial model is continuously iteratively optimized according to the target classification loss value until the target classification loss value reaches the minimum, then the iterative optimization is stopped, and the model at the time of stopping the iteration is used as the target classification model.

[0079] The technical solution of the embodiment of the present invention obtains the word vector of the words in the sample text by inputting the sample text into the feature model, and then processes the word vector, the perturbation vector and the position feature of the word through the initial model to obtain the classification prediction result of the sample text, and determines the target classification loss value according to the classification prediction result of the sample text and the supervision data of the sample text, and then conducts adversarial training on the initial model according to the target classification loss value to obtain the target classification model. The above technical solution inputs the word vector, the perturbation vector and the position feature of the word into the model together, which can learn the long-distance and deep text feature information, thereby improving the classification accuracy of the text; at the same time, the software test results can be automatically classified, reducing the labor of testers for retesting, thereby improving the efficiency and quality of software development and testing.

[0080] On the basis of the above technical solution, since the original text often contains a lot of noise, including non-text data, labels, special symbols and other information, in order to save storage space, optimize operating efficiency and the accuracy of subsequent word segmentation and word vector representation, effective filtering will be performed to eliminate interference with text data information mining. As an optional method of an embodiment of the present invention, a data filtering algorithm and / or a word segmentation algorithm can be used to process the original text to obtain a sample text.

[0081] For example, the useless information in the original text can be removed by using regular expression matching. The regular expression in this article uses the re module in Python, and the re.sub() function is used to remove symbols in the original text.

[0082] For another example, you can also choose Jieba open source library to segment the original text. Jieba word segmentation system supports three word segmentation modes: precise mode, full mode and search engine mode. Due to the problem of word ambiguity in the full mode, the search engine mode has a large amount of calculation and occupies a lot of resources, while the precise mode can segment the text most accurately, and segment the original text into word sequences with independent semantic information, which is suitable for text analysis tasks. Therefore, according to actual business needs, the present invention selects the precise mode of Jieba word segmentation system to perform word segmentation on the filtered original text. The key function is jieba.cut(), which saves the text to the output file in lines.

[0083] For another example, in order to save storage space and improve computing efficiency, stop word processing is performed after the text segmentation preprocessing to filter out some high-frequency words or characters that have no practical meaning and have no effect on the text analysis results. The present invention uses the stop word list of Harbin Institute of Technology and the stop word list of Baidu to remove words such as numerals, prepositions and auxiliary words that are useless for text sentiment analysis.

[0084] It is understandable that filtering invalid data and redundant data in the original text and normalizing the original text can save storage space and improve computing efficiency, thereby also improving the classification accuracy of subsequent texts.

[0085] On the basis of the above-mentioned embodiments, as an optional method of the embodiments of the present invention, the visualization of text classification results and the implementation of functional interfaces can also be implemented. The text classification results obtained from the data processing layer are received, and the classification results are visualized according to categories. The classification function is encapsulated as an interface device. The execution results of the corresponding module can be directly obtained by calling the interface for subsequent use and integration.

[0086] Optionally, for category distribution visualization, the distribution of each text in each classification category is counted, such as frequency, etc., and the statistical results are visualized using bar charts and pie charts. Specifically, visualization of text classification results can intuitively show the characteristics and future trends of the data and provide decision support for users. After the text is classified, its classification results are saved as structured data in the labeled text corpus, from which the classification results are queried and the visualization chart is drawn using the echarts.js component. Finally, the visualization function is improved to form a user interaction interface for users to access and use through a browser.

[0087] Optionally, for the functional interface, first implement the parameter acquisition related functions of the interface, then implement the data reading and query related functions, and finally specify the format of the returned data to implement the data output related functions. Specifically, the text classification result output interface receives the text string input by the user and adds a parameter to indicate the input content type. If the user inputs a text string, the text string is first converted into a word vector of the words in the text by the method provided in the above embodiment, and then the probability distribution of each category is obtained using the classification model. The output probability distribution is a vector in the form of a string array, which is converted into a string array and then output. In order to unify the subsequent calls to this functional interface and the data structure of other parts, the interface uses the HyperText Transfer Protocol (http) to send a cross-domain request to obtain data, and the obtained data is packaged in json form and then output.

[0088] Embodiment 2

[0089] Figure 2A is a flow chart of a classification model training method provided in Example 2 of the present invention, which is optimized on the basis of the above-mentioned embodiment and provides an optional implementation scheme. Figure 2Bis a model diagram of a feature model and a classification model provided in the second embodiment of the present invention, wherein the feature model includes a two-layer bidirectional LSTM, the classification model includes a two-layer bidirectional LSTM, an attention mechanism layer and a classification layer, wherein the classification layer adopts a softmax classifier, and optionally, the sample text sequence {x1, x2, x3, ..., x k}After being input into the feature model, the word vector {w1, w2, w3, …, w k}, and determine the perturbation vector corresponding to each word vector; then input the word vector and position feature into the bidirectional LSTM, and input the output result of the bidirectional LSTM into the attention mechanism layer, which assigns weights {a1, a2, a3, …, a k}, and then input the output of the attention mechanism layer into the classification layer for classification. Optional, such as Figure 2A As shown, the method may specifically include:

[0090] S210. Input the sample text into the feature model to obtain word vectors of the words in the sample text; wherein the feature model includes a two-layer bidirectional LSTM; the sample text is a historical software test result, and the types of historical software test results include environmental problems, data problems, business problems, code problems, and case problems.

[0091] In this embodiment, optionally, the sample text may be input into the feature model to obtain the word vectors of the words in the sample text; Figure 2B As shown in the figure, the feature model includes a two-layer bidirectional LSTM, namely the forward LSTM and the backward LSTM. The forward LSTM is used to predict the following context based on the previous context, that is, to use the first k-1 words to predict the kth word; the backward LSTM is used to predict the previous context based on the following context, that is, to use the words after k to predict the kth word. For example, for a text {x1, x2, ..., x k , …, x N}, x k Represents the word to be predicted in the text, as shown in the following formula:

[0092]

[0093]

[0094] Among them, formula (7) is the backward language model, formula (8) is the forward language model, and the bidirectional LSTM combines the forward language model and the backward language model to maximize the likelihood function of the bidirectional language model. Formula (9) is the likelihood function of the bidirectional language model:

[0095]

[0096] in and are the parameters of the forward LSTM layer and the backward LSTM layer.

[0097] It should be noted that the feature model is pre-trained using the Wikipedia Chinese corpus as a benchmark vocabulary; when determining the word vectors of words in the sample text, the feature model is fine-tuned, and the sample text is input into the fine-tuned feature model to obtain the word vectors of the words in the sample text.

[0098] It can be understood that by processing the sample text with the pre-trained bidirectional LSTM, the dynamic word vector corresponding to the contextual text information, that is, the word vector of the word, can be obtained.

[0099] S220. Process the word vector, the word disturbance vector and the word position feature through the initial model to obtain the classification prediction result of the sample text.

[0100] Among them, Figure 2B As shown in the figure, the initial model includes a two-layer bidirectional LSTM, an attention mechanism layer and a classification layer, wherein a two-layer bidirectional LSTM is a forward LSTM and a backward LSTM, wherein the forward LSTM is used to predict the following context based on the previous context, that is, the first k-1 words are used to predict the kth word; the backward LSTM is used to predict the previous context based on the following context, that is, the words after k are used to predict the kth word; the attention mechanism layer is used to weight the feature representation output by the bidirectional LSTM; and the classification layer is used to classify the weighted feature representation.

[0101] In this embodiment, the word vector and position feature are processed by the initial model to obtain the first classification prediction result of the sample text. Specifically, the word vector and position feature are combined accordingly and input into the initial model to obtain the first classification prediction result of the sample text.

[0102] At the same time, the disturbance vector and position feature are processed by the initial model to obtain the second classification prediction result of the sample text. Specifically, the disturbance vector and position feature are combined accordingly and input into the initial model to obtain the second classification prediction result of the sample text.

[0103] S230: Determine a target classification loss value according to the classification prediction result of the sample text and the supervision data of the sample text.

[0104] In this embodiment, based on the cross entropy loss function, the first classification loss value is determined according to the first classification prediction result and the supervised data, and the second classification loss value is determined according to the second classification prediction result and the supervised data, and then the target classification loss value is determined according to the first classification loss value and the second classification loss value. Specifically, the average of the first classification loss value and the second classification loss value is used as the target classification loss value. For example, it can be determined by the following formula:

[0105]

[0106] loss1=-logp(y|w k )

[0107] loss adv = -logp(y|w k ')

[0108] Among them, loss1 is the first classification loss value of the model when the input layer is not disturbed, loss adv is the second classification loss value of the model after the embedding layer is disturbed, loss1 and loss adv Take the average to calculate the target classification loss.

[0109] It is understandable that the idea of ​​adversarial training is to generate erroneous samples (i.e., perturbation samples) and add them to the training process to improve the ability to defend against hostile samples, thereby making the model more generalizable and robust.

[0110] S240. According to the target classification loss value, the initial model is subjected to adversarial training to obtain a target classification model.

[0111] In this embodiment, the initial model is continuously iteratively optimized according to the target classification loss value until the target classification loss value reaches the minimum, then the iterative optimization is stopped, and the model at the time of stopping the iteration is used as the target classification model.

[0112] The technical solution of the embodiment of the present invention obtains the word vector of the words in the sample text by inputting the sample text into the feature model, and then processes the word vector, the perturbation vector and the position feature of the word through the initial model to obtain the classification prediction result of the sample text, and determines the target classification loss value according to the classification prediction result of the sample text and the supervision data of the sample text, and then conducts adversarial training on the initial model according to the target classification loss value to obtain the target classification model. The above technical solution inputs the word vector, the perturbation vector and the position feature of the word into the model together, which can learn the long-distance and deep text feature information, thereby improving the classification accuracy of the text; at the same time, the software test results can be automatically classified, reducing the labor of testers for retesting, thereby improving the efficiency and quality of software development and testing.

[0113] Embodiment 3

[0114] Figure 3 This is a flowchart of a method for using a classification model provided in Example 3 of the present invention. This embodiment is applicable to situations where software test results are predicted and judged. The method can be executed by a device for using the classification model. The device can be implemented by software and / or hardware and can be integrated into an electronic device that carries the function of using the classification model, such as a server.

[0115] like Figure 3 As shown, the method may specifically include:

[0116] S310, determining the word vectors of the words in the target text; the target file is the software test result to be classified.

[0117] The target text refers to the software test result text that needs to be predicted and judged, that is, the software test result to be classified.

[0118] In this embodiment, the target text can be input into a pre-trained feature model to obtain word vectors of words in the target text. The feature model can include a two-layer bidirectional LSTM.

[0119] S320: Input the word vectors of the words in the target text into the target classification model to obtain the classification prediction results of the target text.

[0120] The target classification model is obtained by the classification model training method provided in any of the above embodiments.

[0121] In this embodiment, the word vectors of the words in the target text are input into the target classification model, and the classification prediction results of the target text are obtained after being processed by the target classification model.

[0122] The technical method of the embodiment of the present invention determines the word vector of the word in the target text, and then inputs the word vector of the word in the target text into the target classification model to obtain the classification prediction result of the target text. The above technical solution can automatically classify the software test results, reduce the labor of testers for retesting, and thus improve the efficiency and quality of software development and testing.

[0123] Embodiment 4

[0124] Figure 4 It is a structural diagram of a classification model training device provided in Example 4 of the present invention. This embodiment can be applied to situations where prediction and judgment are performed based on software measurement results. The device can be implemented by software and / or hardware and can be integrated into an electronic device that carries the classification model training function, such as a server.

[0125] like Figure 4 As shown, the device may specifically include a word vector determination module 410, a prediction result determination module 420, a classification loss value determination module 430 and a classification model determination module 440, wherein:

[0126] The word vector determination module 410 is used to input the sample text into the feature model to obtain the word vector of the words in the sample text; wherein the feature model includes a two-layer bidirectional LSTM; the sample text is a historical software test result, and the types of the historical software test results include environment problems, data problems, business problems, code problems, and case problems;

[0127] The prediction result determination module 420 is used to process the word vector, the perturbation vector and the position feature of the word through the initial model to obtain the classification prediction result of the sample text; wherein the initial model includes at least one two-layer bidirectional LSTM, an attention mechanism layer and a classification layer;

[0128] A classification loss value determination module 430 is used to determine a target classification loss value according to the classification prediction result of the sample text and the supervision data of the sample text;

[0129] The classification model determination module 440 is used to perform adversarial training on the initial model according to the target classification loss value to obtain the target classification model.

[0130] The technical solution of the embodiment of the present invention obtains the word vector of the words in the sample text by inputting the sample text into the feature model, and then processes the word vector, the perturbation vector and the position feature of the word through the initial model to obtain the classification prediction result of the sample text, and determines the target classification loss value according to the classification prediction result of the sample text and the supervision data of the sample text, and then conducts adversarial training on the initial model according to the target classification loss value to obtain the target classification model. The above technical solution inputs the word vector, the perturbation vector and the position feature of the word into the model together, which can learn the long-distance and deep text feature information, thereby improving the classification accuracy of the text; at the same time, the software test results can be automatically classified, reducing the labor of testers for retesting, thereby improving the efficiency and quality of software development and testing.

[0131] Furthermore, the prediction result determination module 420 is specifically used for:

[0132] Through the initial model, the word vector and position features are processed to obtain the first classification prediction result of the sample text;

[0133] The disturbance vector and position features are processed through the initial model to obtain the second classification prediction result of the sample text.

[0134] Furthermore, the classification loss value determination module 430 is specifically used for:

[0135] Determine the first classification loss value based on the first classification prediction result and the supervision data;

[0136] Determine the second classification loss value based on the second classification prediction result and the supervision data;

[0137] According to the first classification loss value and the second classification loss value, a target classification loss value is determined.

[0138] Furthermore, the device also includes a disturbance vector determination module, and the disturbance vector determination module is specifically used to:

[0139] Determine the expectation and variance of the sample text based on the word vector and word frequency of the word;

[0140] The perturbation vector of the word is determined according to the expectation and variance of the sample text and the word.

[0141] Furthermore, the device also includes a location feature determination module, which is specifically used to:

[0142] According to the length of the word, the characters in the word are encoded to obtain the positional features of the word.

[0143] Furthermore, the device also includes a sample text determination module, which is specifically used to:

[0144] The original text is processed using a data filtering algorithm and / or a word segmentation algorithm to obtain a sample text.

[0145] The above-mentioned classification model training device can execute the classification model training method provided by any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0146] Embodiment 5

[0147] Figure 5 It is a structural diagram of a device for using a classification model provided in Example 5 of the present invention. This embodiment can be applied to situations where software test results are predicted and judged. The device can be implemented by software and / or hardware and can be integrated into an electronic device that carries the function of using the classification model, such as a server.

[0148] like Figure 5 As shown, the device may specifically include a word vector determination module 510 and a prediction result determination module 520, wherein:

[0149] The word vector determination module 510 is used to determine the word vectors of words in the target text; the target file is the software test result to be classified;

[0150] The prediction result determination module 520 is used to input the word vectors of the words in the target text into the target classification model to obtain the classification prediction result of the target text; wherein the target classification model is obtained by the training method of the classification model provided by any of the above embodiments.

[0151] The technical method of the embodiment of the present invention determines the word vector of the word in the target text, and then inputs the word vector of the word in the target text into the target classification model to obtain the classification prediction result of the target text. The above technical solution can automatically classify the software test results, reduce the labor of testers for retesting, and thus improve the efficiency and quality of software development and testing.

[0152] The above-mentioned classification model use device can execute the classification model use method provided by any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0153] Embodiment 6

[0154] Figure 6 is a structural diagram of an electronic device provided by Embodiment 6 of the present invention, Figure 6 A block diagram is shown of an exemplary apparatus suitable for implementing an exemplary embodiment of the present invention. Figure 6The device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0155] like Figure 6 As shown, the electronic device 12 is in the form of a general purpose computing device. The components of the electronic device 12 may include, but are not limited to: one or more processors or processing units 16, a system memory 28, and a bus 18 that connects various system components (including the system memory 28 and the processing unit 16).

[0156] Bus 18 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor or a local bus using any of a variety of bus architectures. By way of example, these architectures include, but are not limited to, an Industry Standard Architecture (ISA) bus, a Micro Channel Architecture (MAC) bus, an Enhanced ISA bus, a Video Electronics Standards Association (VESA) local bus, and a Peripheral Component Interconnect (PCI) bus.

[0157] The electronic device 12 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by the electronic device 12, including volatile and non-volatile media, removable and non-removable media.

[0158] The system memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory (cache 32). The electronic device 12 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 34 may be used to read and write non-removable, non-volatile magnetic media ( Figure 6 not shown, usually called a "hard drive"). Although Figure 6 Not shown in the figure, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, a DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to the bus 18 via one or more data medium interfaces. The system memory 28 may include at least one program product having a set (e.g., at least one) of program modules that are configured to perform the functions of the various embodiments of the present invention.

[0159] A program / utility 40 having a set (at least one) of program modules 42 may be stored, for example, in system memory 28, such program modules 42 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment. Program modules 42 generally perform the functions and / or methods of the embodiments described in the embodiments of the present invention.

[0160] The electronic device 12 may also communicate with one or more external devices 14 (e.g., keyboards, pointing devices, displays 24, etc.), may communicate with one or more devices that enable a user to interact with the electronic device 12, and / or may communicate with any device that enables the electronic device 12 to communicate with one or more other computing devices (e.g., network cards, modems, etc.). Such communication may be performed via an input / output (I / O) interface 22. Furthermore, the electronic device 12 may also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) via a network adapter 20. As shown, the network adapter 20 communicates with other modules of the electronic device 12 via a bus 18. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0161] The processing unit 16 executes various functional applications and data processing by running the programs stored in the system memory 28, such as implementing the training method of the classification model or the use method of the classification model provided in the embodiment of the present invention.

[0162] Embodiment 7

[0163] Embodiment 7 of the present invention further provides a computer-readable storage medium on which a computer program (or computer-executable instructions) is stored. When the program is executed by a processor, it is used to execute the training method of the classification model or the method of using the classification model provided in the embodiment of the present invention.

[0164] The computer storage medium of the embodiment of the present invention can adopt any combination of one or more computer-readable media. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example, but not limited to, a system, device or device of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination of the above. More specific examples (non-exhaustive list) of computer-readable storage media include: 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 this document, a computer-readable storage medium can be any tangible medium containing or storing a program, which can be used by an instruction execution system, a device or a device or used in combination with it.

[0165] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry computer-readable program code. 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. Computer-readable signal media 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.

[0166] The program code embodied on the computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.

[0167] The computer program code for performing the operation of the embodiments of the present invention can be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as an independent software package, partially on the user's computer and partially on a remote computer, or completely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (e.g., using an Internet service provider to connect through the Internet).

[0168] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the embodiments of the present invention are described in more detail through the above embodiments, the embodiments of the present invention are not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims

1. A classification model training method, characterized in that: include: Inputting the sample text into the feature model to obtain word vectors of the words in the sample text; wherein the feature model includes a two-layer bidirectional LSTM; the sample text is a historical software test result, and the types of the historical software test results include environment problems, data problems, business problems, code problems, and case problems; The word vector, the perturbation vector and the position feature of the word are processed by the initial model to obtain the classification prediction result of the sample text; wherein the initial model includes at least one two-layer bidirectional LSTM, an attention mechanism layer and a classification layer; Determining a target classification loss value according to the classification prediction result of the sample text and the supervision data of the sample text; According to the target classification loss value, adversarial training is performed on the initial model to obtain a target classification model; The initial model is used to process the word vector, the perturbation vector and the position feature of the word to obtain the classification prediction result of the sample text, including: The word vector, word perturbation vector and word position feature are combined and concatenated, and input into the bidirectional LSTM to obtain the feature representation of each word in the sample text; The feature representation of each word in the sample text is input into the attention mechanism layer. In the attention mechanism layer, different weights are assigned to the feature representation of each word in the sample text to obtain the optimized feature representation; The optimized feature representation is input into the classification layer for text classification.

2. The method according to claim 1, characterized in that The initial model is used to process the word vector, the word disturbance vector and the word position feature to obtain the classification prediction result of the sample text, including: Processing the word vector and position feature through the initial model to obtain a first classification prediction result of the sample text; The disturbance vector and position feature are processed by the initial model to obtain a second classification prediction result of the sample text.

3. The method according to claim 2, characterized in that The step of determining a target classification loss value according to the classification prediction result of the sample text and the supervision data of the sample text includes: Determining a first classification loss value according to the first classification prediction result and the supervision data; Determining a second classification loss value according to the second classification prediction result and the supervision data; A target classification loss value is determined according to the first classification loss value and the second classification loss value.

4. The method according to claim 1, characterized in that: Also includes: Determine the expectation and variance of the sample text according to the word vector of the word and the word frequency of the word; A disturbance vector of the word is determined according to the expectation and variance of the sample text and the word.

5. The method according to claim 1, characterized in that Also includes: According to the length of the word, the characters in the word are encoded to obtain the position feature of the word.

6. The method according to claim 1, characterized in that Also includes: The original text is processed using a data filtering algorithm and / or a word segmentation algorithm to obtain the sample text.

7. A method for using a classification model, characterized in that: include: Determine the word vector of the words in the target text; the target file is the software test result to be classified; The word vectors of the words in the target text are input into the target classification model to obtain the classification prediction result of the target text; wherein the target classification model is obtained by the training method of the classification model described in any one of claims 1-6.

8. A training device for a classification model, characterized in that: include: A word vector determination module is used to input a sample text into a feature model to obtain word vectors of words in the sample text; wherein the feature model includes a two-layer bidirectional LSTM; the sample text is a historical software test result, and the types of historical software test results include environment problems, data problems, business problems, code problems, and case problems; A prediction result determination module, used to process the word vector, the perturbation vector and the position feature of the word through an initial model to obtain the classification prediction result of the sample text; wherein the initial model includes at least one two-layer bidirectional LSTM, an attention mechanism layer and a classification layer; A classification loss value determination module, used to determine a target classification loss value according to the classification prediction result of the sample text and the supervision data of the sample text; A classification model determination module, used to perform adversarial training on the initial model according to the target classification loss value to obtain a target classification model; The initial model is used to process the word vector, the perturbation vector and the position feature of the word to obtain the classification prediction result of the sample text, including: The word vector, word perturbation vector and word position feature are combined and concatenated, and input into the bidirectional LSTM to obtain the feature representation of each word in the sample text; The feature representation of each word in the sample text is input into the attention mechanism layer. In the attention mechanism layer, different weights are assigned to the feature representation of each word in the sample text to obtain the optimized feature representation; The optimized feature representation is input into the classification layer for text classification.

9. A device for using a classification model, characterized in that: include: A word vector determination module is used to determine the word vectors of words in the target text; The target file is a software test result to be classified; A prediction result determination module is used to input the word vectors of the words in the target text into the target classification model to obtain the classification prediction result of the target text; wherein the target classification model is obtained by the training method of the classification model described in any one of claims 1-6.

10. An electronic device, characterized in that: include: one or more processors; A memory for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the training method of the classification model described in any one of claims 1 to 6, or the method of using the classification model described in claim 7.

11. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, it implements the training method of the classification model described in any one of claims 1 to 6, or the method of using the classification model described in claim 7.