A method for code defect prediction and localization based on multi-task interaction

CN122547656APending Publication Date: 2026-08-11DALIAN MARITIME UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-04-23
Publication Date
2026-08-11

AI Technical Summary

Technical Problem

为了解决现有技术中数据鲁棒性不足、专家特征粗粒度建模以及预测与定位任务协同性差的问题,本发明提供了一种基于多任务交互的代码缺陷预测和定位方法,包括如下步骤:

Benefits of technology

(1)本发明通过专家特征分析层将多维连续函数分解为单变量函数的嵌套叠加,并结合跨粒度协同架构,显著提升了缺陷预测的准确性。同时,开发团队能够在资源受限的情况下,以更少的代码检查量捕获相同比例的缺陷提交,有效提高了代码审查效率。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122547656A_ABST
    Figure CN122547656A_ABST
Patent Text Reader

Abstract

This invention relates to the field of software quality assurance technology, specifically to a method for code defect prediction and localization based on multi-task interaction, comprising the following steps: acquiring and parsing original code change data, dividing it into three feature levels: expert features, text sequences, and code line structures; filtering non-semantic noise using symbolic standardization to generate a normalized sequence; eliminating scale differences using a quantile-based standardization method to generate standardized expert features; inputting the normalized sequence and standardized expert features into a defect prediction network, outputting the defect prediction probability at the code submission level; inputting the code line structure into a defect localization network, outputting the defect probability distribution for each line of code; constructing a total loss function to optimize the defect prediction network and the defect localization network. This invention significantly improves defect prediction accuracy and localization precision, reduces code review workload, and exhibits excellent robustness and generalization ability in cross-project scenarios.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of software quality assurance technology, specifically to a method for predicting and locating code defects based on multi-task interaction. Background Technology

[0002] In the field of software quality assurance, Just-In-Time Defect Prediction (JIT-DP) primarily identifies code submissions that may introduce defects by analyzing program change characteristics, while Just-In-Time Defect Localization (JIT-DL) focuses on precisely locating specific lines of defective code during the code submission process. Current mainstream technologies range from traditional shallow feature engineering methods to deep learning-based semantic extraction models, and multi-task learning frameworks that combine pre-trained models.

[0003] For example, Mockus et al. constructed a logistic regression model using software change attributes for defect prediction. [1] Subsequently, Yang et al. proposed using deep belief networks to extract high-order representation information from expert features in code submissions. [2] With the development of deep learning, semantic models based on neural networks have been widely proposed. Hoang et al. used convolutional neural networks to extract the semantics of submission information and code change interactions, proposing the DeepJIT model. [3] In recent years, the industry has begun to explore joint optimization of prediction and localization tasks, such as the JIT-Fine two-stage framework proposed by Yan et al., which combines logistic regression and N-gram. [4] And JIT-Smart, a multi-task learning framework based on the CodeBERT shared coding layer proposed by Chen et al. [5] .

[0004] However, the aforementioned existing technologies still have significant shortcomings in practical agile development and continuous delivery scenarios. First, existing data preprocessing methods lack data robustness and generalization ability, making it difficult to cope with highly dynamic unstructured noise in code change data. Furthermore, traditional standardization methods based on rigid rules are extremely sensitive to extreme outliers, leading to severe distortion of feature distribution. Second, existing works generally rely on fixed activation functions and pre-defined network architectures when processing multi-dimensional expert features, lacking the ability to fine-grained modeling of complex nonlinear synergistic effects between features. Finally, in terms of task architecture design, neither the decoupled two-stage design, which is prone to information loss, nor existing multi-task learning frameworks effectively address the dual challenges of dynamic noise interference and coarse-grained modeling of expert features, thus severely limiting the model's defect prediction accuracy and code review efficiency in complex cross-project scenarios.

[0005] Therefore, there is an urgent need for an instant code defect prediction and localization method that is robust, capable of fine-grained modeling of nonlinear synergistic effects of expert features, and enables deep interaction between prediction and localization tasks.

[0006] Reference documents:

[0007] [1] Audris Mockus and David M Weiss. Predicting risk of softwarechanges. Bell Labs Technical Journal, 5(2):169–180, 2000. [2] Xinli Yang, David Lo, Xin Xia, Yun Zhang, and Jianling Sun. Deeplearning for just-in-time defect prediction. In 2015 IEEEInternationalconference on software quality, reliability and security, pages17–26. IEEE, 2015. [3] Thong Hoang, Hoa Khanh Dam, Yasutaka Kamei, David Lo, and NaoyasuUbayashi. Deepjit: an end-to-end deep learning framework for just-in-timedefect prediction. In 2019 IEEE / ACM 16th International Conference on MiningSoftware Repositories (MSR), pages 34–45. IEEE, 2019. [4] Meng Yan, Xin Xia, Yuanrui Fan, Ahmed E Hassan, David Lo, andShanping Li. Just-in-time defect identification and localization: Atwo-phaseframework. IEEE Transactions on Software Engineering, 48(1):82–101, 2020. [5] Xiangping Chen, Furen Xu, Yuan Huang, Neng Zhang, and ZibinZheng. Jit-smart: A multi-task learning framework for just-in-timedefectprediction and localization. Proceedings of the ACM on Software Engineering, 1(FSE):1–23, 2024. Summary of the Invention To address the problems of insufficient data robustness, coarse-grained modeling of expert features, and poor coordination between prediction and localization tasks in existing technologies, this invention provides a code defect prediction and localization method based on multi-task interaction, comprising the following steps: The original code change data is acquired and parsed, and the original code change data is divided into three feature levels: expert features, text sequence, and code line structure. Based on the text sequence, non-semantic noise is filtered out using symbolic normalization to generate a normalized sequence; Based on the aforementioned expert features, a quantile-based standardization method is used to eliminate scale differences and generate standardized expert features. A defect prediction network is established, and the normalized sequence and the standardized expert features are input into the defect prediction network. A cross-granularity feature fusion method is used to output the defect prediction probability at the code submission level. A defect localization network is established. The code line structure is input into the defect localization network, and a bidirectional hierarchical encoding combined with an attention mechanism is used to output the defect probability distribution of each line of code. A total loss function is constructed based on the defect prediction probability and the defect probability distribution, and the defect prediction network and the defect localization network are optimized.

[0008] Furthermore, a symbolic normalization mapping function is used to map the basic symbols in the text sequence to normalized symbols, and a normalized sequence is generated by sequence concatenation. The formula for the normalized sequence is:

[0009] in, Indicates the first input sequences The normalized sequence, Represents the symbolic normalization mapping function, , , ..., Represents the basic symbols in a text sequence. This represents a sequence concatenation operation. Indicates the length of the sequence.

[0010] Furthermore, the quantile-based standardization method includes: The median of each expert feature dimension is calculated using an empirical distribution function. The formula for the median is:

[0011] in, Indicates the first The median of the expert characteristics, This indicates the infimum operation. Indicates the value of the expert feature. Represents the set of real numbers. Indicates the first The empirical distribution function of the expert features; The formula for generating standardized expert features by eliminating the distributional differences in feature scales using interquartile range is as follows:

[0012] in, Indicates the first Characteristics of standardization experts Indicates the first Input values ​​for dimensional expert features, Indicates the first Interquartile range of the expert features.

[0013] Furthermore, the defect prediction network includes a semantic aggregation layer, a line-level encoding layer, and an expert feature analysis layer; the semantic aggregation layer uses a pre-trained model with a dynamic masking strategy to extract global contextual semantic features of code changes; the line-level encoding layer receives the line-level representation output by the defect localization network, and generates a structured feature representation vector at the code submission level by averaging the log odds of all lines of code, the formula for which is:

[0014] in, A structured feature representation vector representing the code submission level. Indicates the total number of lines of code. The output of the defect localization network represents the first... The log-odds ratio of the line of code; The expert feature analysis layer decomposes the multidimensional continuous function into a nested superposition of univariate functions, as shown in the formula:

[0015] in, This represents the nonlinear output result after multidimensional expert feature fusion. Indicates the first Expert features of dimensional input, The total dimension representing expert characteristics This represents the underlying learnable basis function acting on a one-dimensional feature. This represents a high-order nonlinear combination function used for feature aggregation.

[0016] Furthermore, the defect localization network includes a word embedding layer, which is used to vectorize the code matrix. The vectorization formula is as follows:

[0017] in, This represents the vectorized two-dimensional code feature matrix. This indicates word embedding operations. This represents the input matrix consisting of the original code line identifiers.

[0018] Furthermore, the defect localization network also includes a bidirectional long short-term memory layer, which is used to perform the bidirectional hierarchical encoding, including inline semantic modeling of token sequences and interline logic capture of code line sequences.

[0019] Furthermore, the attention mechanism includes an intra-line attention mechanism and an inter-line attention mechanism; the inter-line attention mechanism is used to weight the representation of each line of code; the intra-line attention mechanism calculates the implicit feature representation of each token through a non-linear transformation, and the formula for the implicit feature representation is:

[0020] in, Indicates the first The implicit feature representation of a token after nonlinear transformation. This represents the hyperbolic tangent activation function. This represents the learnable weight matrix. Indicates the first Each token is a hidden layer state vector output by a bidirectional long short-term memory layer. Represents a learnable bias vector; The normalized attention weight for each token is calculated based on the implicit feature representation, using the following formula:

[0021] in, Indicates the first Normalized attention weights for each token, Represented by natural constant e An exponential function with base 0. This represents the transpose of the latent feature representation vector. This represents a vector of learnable contextual attention parameters at the token level. This represents the index variable for iterating through all tokens in the current single line of code.

[0022] Furthermore, the defect localization network also includes a feedforward layer, which outputs a defect probability distribution for each line of code. The formula is:

[0023] in, and Represents a fully connected linear mapping. Represents a non-linear activation function. This indicates the weighted result after interline attention mechanism. The vector representing the line of code.

[0024] Further, the defect prediction task loss is calculated based on the defect prediction probability, and the defect location task loss is calculated based on the defect probability distribution. The total loss function is a weighted sum of the defect prediction task loss and the defect location task loss. The formula is:

[0025] in, This represents the loss value of the defect prediction task. This represents the loss value of the defect localization task. This represents the weighting coefficients of the hyperparameters in the defect prediction task. This represents the hyperparameter weighting coefficients for the defect localization task.

[0026] Furthermore, the defect prediction task loss adopts a focus loss function, the formula of which is:

[0027] in, Indicates the focal loss value. This represents the probability that the defect prediction network predicts the true defect category. α This represents the class weight coefficient used to balance positive and negative samples. This represents the focusing parameter used to control the weights of easy and difficult samples.

[0028] Compared with the prior art, the present invention has the following beneficial effects: (1) This invention decomposes multidimensional continuous functions into nested superpositions of univariate functions through an expert feature analysis layer, and combines this with a cross-granularity collaborative architecture, which significantly improves the accuracy of defect prediction. At the same time, the development team can capture the same proportion of defect submissions with less code inspection under resource constraints, effectively improving code review efficiency.

[0029] (2) This invention relies on bidirectional hierarchical coding and attention mechanism between lines to significantly improve the hit rate of line-level defect localization, greatly reduce the ineffective time consumption of developers to check irrelevant code, and effectively suppress false alarms.

[0030] (3) This invention, through symbol standardization and quantile-based robust standardization preprocessing, can effectively cope with noise interference in code change data and data differences between different projects, and has good stability and cross-project adaptability. Attached Figure Description

[0031] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0032] Figure 1 This is a flowchart of a code defect prediction and localization method based on multi-task interaction according to the present invention. Detailed Implementation

[0033] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.

[0034] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0035] This invention provides the following technical solutions: like Figure 1 As shown, this invention provides a method for predicting and locating code defects based on multi-task interaction, specifically including the following steps: S1. Obtain and parse the original code change data, and divide the original code change data into three feature levels: expert features, text sequence, and code line structure.

[0036] S2. Based on the text sequence, non-semantic noise is filtered out using symbolic standardization to generate a normalized sequence.

[0037] In a preferred embodiment of this application, a symbol normalization mapping function is used to map the basic symbols in the text sequence to normalized symbols, and a normalized sequence is generated by sequence concatenation. The formula for the normalized sequence is:

[0038] in, Indicates the first input sequences The normalized sequence, Represents the symbolic normalization mapping function, , , ..., Represents the basic symbols in a text sequence. This represents a sequence concatenation operation. Indicates the length of the sequence.

[0039] S3. Based on the expert features, a quantile-based standardization method is used to eliminate scale differences and generate standardized expert features.

[0040] The quantile-based standardization method includes: S31. Calculate the median of each dimension of expert features using an empirical distribution function. The formula for the median is:

[0041] in, Indicates the first The median of the expert characteristics, This indicates the infimum operation. Indicates the value of the expert feature. Represents the set of real numbers. Indicates the first The empirical distribution function of the expert features; S32. The formula for generating standardized expert features by eliminating the distribution differences of feature scales using interquartile range is as follows:

[0042] in, Indicates the first Characteristics of standardization experts Indicates the first Input values ​​for dimensional expert features, Indicates the first Interquartile range of the expert features.

[0043] S4. Establish a defect prediction network, input the normalized sequence and the standardized expert features into the defect prediction network, and output the defect prediction probability at the code submission level by using cross-granularity feature fusion.

[0044] S41. The defect prediction network includes a semantic aggregation layer, a row-level coding layer, and an expert feature analysis layer.

[0045] S42. The semantic aggregation layer uses a pre-trained model with a dynamic masking strategy to extract global contextual semantic features of code changes.

[0046] S43. The line-level coding layer receives the line-level representation output by the defect localization network, and generates a structured feature representation vector at the code submission level by averaging the log-odds of all lines of code. The formula for the structured feature representation vector is:

[0047] in, A structured feature representation vector representing the code submission level. Indicates the total number of lines of code. The output of the defect localization network represents the first... The log odds of a line of code.

[0048] S44. The expert feature analysis layer decomposes the multidimensional continuous function into a nested superposition of univariate functions, as shown in the formula:

[0049] in, This represents the nonlinear output result after multidimensional expert feature fusion. Indicates the first Expert features of dimensional input, The total dimension representing expert characteristics This represents the underlying learnable basis function acting on a one-dimensional feature. This represents a high-order nonlinear combination function used for feature aggregation.

[0050] S5. Establish a defect localization network. Input the code line structure into the defect localization network, and use bidirectional hierarchical encoding combined with an attention mechanism to output the defect probability distribution of each line of code.

[0051] S51. The defect localization network includes a word embedding layer, which is used to vectorize the code matrix. The vectorization formula is as follows:

[0052] in, This represents the vectorized two-dimensional code feature matrix. This indicates word embedding operations. This represents the input matrix consisting of the original code line identifiers.

[0053] S52. The defect localization network further includes a bidirectional long short-term memory layer, which is used to perform the bidirectional hierarchical encoding, including inline semantic modeling of token sequences and interline logic capture of code line sequences.

[0054] S53. The attention mechanism includes an intra-line attention mechanism and an inter-line attention mechanism; the inter-line attention mechanism is used to weight the representation of each line of code; the intra-line attention mechanism calculates the implicit feature representation of each token through a non-linear transformation, and the formula for the implicit feature representation is:

[0055] in, Indicates the first The implicit feature representation of a token after nonlinear transformation. This represents the hyperbolic tangent activation function. This represents the learnable weight matrix. Indicates the first Each token is a hidden layer state vector output by a bidirectional long short-term memory layer. This represents a learnable bias vector.

[0056] S54. Calculate the normalized attention weight for each token based on the implicit feature representation, using the following formula:

[0057] in, Indicates the first Normalized attention weights for each token, Represented by natural constant e An exponential function with base 0. This represents the transpose of the latent feature representation vector. This represents a vector of learnable contextual attention parameters at the token level. This represents the index variable for iterating through all tokens in the current single line of code.

[0058] S55. The defect localization network further includes a feedforward layer, which is used to output the defect probability distribution for each line of code. The formula is:

[0059] in, and Represents a fully connected linear mapping. Represents a non-linear activation function. This indicates the weighted result after interline attention mechanism. The vector representing the line of code.

[0060] S6. Construct a total loss function based on the defect prediction probability and the defect probability distribution, and optimize the defect prediction network and the defect localization network.

[0061] In a preferred embodiment of this application, the defect prediction task loss is calculated based on the defect prediction probability, and the defect location task loss is calculated based on the defect probability distribution. The total loss function is a weighted sum of the defect prediction task loss and the defect location task loss. The formula is:

[0062] in, This represents the loss value of the defect prediction task. This represents the loss value of the defect localization task. This represents the weighting coefficients of the hyperparameters in the defect prediction task. This represents the hyperparameter weighting coefficients for the defect localization task.

[0063] In a preferred embodiment of this application, the defect prediction task loss adopts a focus loss function, the formula of which is:

[0064] in, Indicates the focal loss value. This represents the probability that the defect prediction network predicts the true defect category. α This represents the class weight coefficient used to balance positive and negative samples. This represents the focusing parameter used to control the weights of easy and difficult samples.

[0065] This invention improves the F1 score in defect prediction tasks by 2.76% and the area under the curve (AUC) by 1.79% compared to the existing state-of-the-art (SOTA) model. Simultaneously, it reduces the amount of code to be reviewed (CodeChurn@20%Recall_line), a core indicator reflecting actual code review efficiency, by 2.88%. This means that development teams, with limited resources, can capture the same proportion of defect submissions with less code review. Secondly, it significantly improves the fine-grained accuracy of defect localization and effectively suppresses false positives. Relying on bidirectional hierarchical coding within and between lines and a dynamic attention mechanism, this invention improves the top 5-line hit rate (Top5-Acc) by 3.10% and the top 10-line hit rate (Top10-Acc) by 2.55% in line-level defect localization tasks. Furthermore, the amount of code required to find the 20% defective lines (CodeChurn@20%Recall_line) decreased significantly by 18.58%, and the initial false positives (IFA) decreased by 3.57%, greatly reducing the time developers spend checking irrelevant code. Experiments show that in cross-project scenarios, the F1 score of this invention improved by an average of 9.84%, especially in highly complex projects, where the initial false positives (IFA) decreased significantly by 16.19%, demonstrating strong industrial application stability and cross-domain adaptability.

[0066] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for predicting and locating code defects based on multi-task interaction, characterized in that, Includes the following steps: The original code change data is acquired and parsed, and the original code change data is divided into three feature levels: expert features, text sequence, and code line structure. Based on the text sequence, non-semantic noise is filtered out using symbolic normalization to generate a normalized sequence; Based on the aforementioned expert features, a quantile-based standardization method is used to eliminate scale differences and generate standardized expert features. A defect prediction network is established, and the normalized sequence and the standardized expert features are input into the defect prediction network. A cross-granularity feature fusion method is used to output the defect prediction probability at the code submission level. A defect localization network is established. The code line structure is input into the defect localization network, and a bidirectional hierarchical encoding combined with an attention mechanism is used to output the defect probability distribution of each line of code. A total loss function is constructed based on the defect prediction probability and the defect probability distribution, and the defect prediction network and the defect localization network are optimized.

2. The code defect prediction and localization method based on multi-task interaction according to claim 1, characterized in that, The basic symbols in the text sequence are mapped to normalized symbols using a symbol normalization mapping function, and a normalized sequence is generated by sequence concatenation. The formula for the normalized sequence is: in, Indicates the first input sequences The normalized sequence, Represents the symbolic normalization mapping function, , , ..., Represents the basic symbols in a text sequence. This represents a sequence concatenation operation. Indicates the length of the sequence.

3. The code defect prediction and localization method based on multi-task interaction according to claim 1, characterized in that, The quantile-based standardization method includes: The median of each expert feature dimension is calculated using an empirical distribution function. The formula for the median is: in, Indicates the first The median of the expert characteristics, This indicates the infimum operation. Indicates the value of the expert feature. Represents the set of real numbers. Indicates the first The empirical distribution function of the expert features; The formula for generating standardized expert features by eliminating the distributional differences in feature scales using interquartile range is as follows: in, Indicates the first Characteristics of standardization experts Indicates the first Input values ​​for dimensional expert features, Indicates the first Interquartile range of the expert features.

4. The code defect prediction and localization method based on multi-task interaction according to claim 1, characterized in that, The defect prediction network includes a semantic aggregation layer, a row-level coding layer, and an expert feature analysis layer; The semantic aggregation layer uses a pre-trained model with a dynamic masking strategy to extract global contextual semantic features of code changes; the line-level coding layer receives the line-level representation output by the defect localization network, and generates a structured feature representation vector at the code submission level by averaging the log odds of all lines of code. The formula for the structured feature representation vector is: in, A structured feature representation vector representing the code submission level. Indicates the total number of lines of code. The output of the defect localization network represents the first... The log-odds ratio of the line of code; The expert feature analysis layer decomposes the multidimensional continuous function into a nested superposition of univariate functions, as shown in the formula: in, This represents the nonlinear output result after multidimensional expert feature fusion. Indicates the first Expert features of dimensional input, The total dimension representing the characteristics of experts This represents the underlying learnable basis function acting on a one-dimensional feature. This represents a high-order nonlinear combination function used for feature aggregation.

5. The code defect prediction and localization method based on multi-task interaction according to claim 1, characterized in that, The defect localization network includes a word embedding layer, which is used to vectorize the code matrix. The vectorization formula is as follows: in, This represents the vectorized two-dimensional code feature matrix. This indicates word embedding operations. This represents the input matrix consisting of the original code line identifiers.

6. The code defect prediction and localization method based on multi-task interaction according to claim 5, characterized in that, The defect localization network also includes a bidirectional long short-term memory layer, which is used to perform the bidirectional hierarchical encoding, including inline semantic modeling of token sequences and interline logic capture of code line sequences.

7. The code defect prediction and localization method based on multi-task interaction according to claim 6, characterized in that, The attention mechanism includes an intra-line attention mechanism and an inter-line attention mechanism; the inter-line attention mechanism is used to weight the representation of each line of code; the intra-line attention mechanism calculates the implicit feature representation of each token through a non-linear transformation, and the formula for the implicit feature representation is: in, Indicates the first The implicit feature representation of a token after nonlinear transformation. This represents the hyperbolic tangent activation function. This represents the learnable weight matrix. Indicates the first Each token is a hidden layer state vector output by a bidirectional long short-term memory layer. Represents a learnable bias vector; The normalized attention weight for each token is calculated based on the implicit feature representation, using the following formula: in, Indicates the first Normalized attention weights for each token, Represented by natural constant e An exponential function with base 0. This represents the transpose of the latent feature representation vector. This represents a vector of learnable contextual attention parameters at the token level. This represents the index variable for iterating through all tokens in the current single line of code.

8. The code defect prediction and localization method based on multi-task interaction according to claim 7, characterized in that, The defect localization network further includes a feedforward layer, which outputs the defect probability distribution for each line of code. The formula is: in, and Represents a fully connected linear mapping. Represents a non-linear activation function. This indicates the weighted result after interline attention mechanism. The vector representing the line of code.

9. The code defect prediction and localization method based on multi-task interaction according to claim 1, characterized in that, The defect prediction task loss is calculated based on the defect prediction probability, and the defect location task loss is calculated based on the defect probability distribution. The total loss function is a weighted sum of the defect prediction task loss and the defect location task loss. The formula is: in, This represents the loss value of the defect prediction task. This represents the loss value of the defect localization task. This represents the weighting coefficients of the hyperparameters in the defect prediction task. This represents the hyperparameter weighting coefficients for the defect localization task.

10. A code defect prediction and localization method based on multi-task interaction according to claim 9, characterized in that, The defect prediction task loss adopts the focus loss function, and the formula is: in, Indicates the focal loss value. This represents the probability that the defect prediction network predicts the true defect category. α This represents the class weight coefficient used to balance positive and negative samples. This represents the focusing parameter used to control the weights of easy and difficult samples.