Deep-Learning Code Classification Interpretation With Sample Differences
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing methods for interpreting deep-learning models for code classification lack robustness and fidelity, leading to unreliable predictions and vulnerability to adversarial attacks due to out-of-distribution inputs and overfitting on individual samples.
Innovation Solution
A sample-difference-based method involving off-line training to generate difference samples through feature deletion and snippet extraction, followed by influence-function-based on-line interpretation to identify contributive training samples, using approximators with the same model structure as the original classification model.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Measurement precision
If perturbation-based feature saliency method is used to interpret deep-learning models, then feature importance can be obtained, but inputs are located outside the distribution of the training set leading to unreliable predictions
Solution Approach 1:
The patent creates copies of the original deep-learning model (approximator models) to serve as interpreters. These copied models are trained on the same training set and use the same architecture, ensuring they operate within the training distribution while still capturing the decision-making logic. The interpreter model copies the essential decision boundaries without requiring out-of-distribution perturbations.
Solution Approach 2:
The patent performs preliminary training of the interpreter model on the complete training set before interpretation. This preliminary action ensures the interpreter learns the decision boundaries from in-distribution data. The influence function is pre-calculated for all training samples, allowing the system to identify which training samples most influence predictions without needing to perturb test inputs outside the distribution.
2Ease of operation
If program reduction method is used to minimize programs to minimal sentence sets, then interpretation can be achieved, but the process is complex and computationally intensive
Solution Approach 1:
The patent replaces the mechanical process of iteratively minimizing code (program reduction) with a mathematical approach using influence functions. Instead of repeatedly modifying and retraining models to identify important features, the influence function provides a closed-form solution that calculates the impact of each training sample in one step. This substitution of mechanical iteration with mathematical computation significantly reduces complexity.
Solution Approach 2:
The patent changes the parameter space from code modifications to model parameter gradients. Rather than modifying code structure and retraining, the method computes gradients of model parameters with respect to training data, then uses these gradients to determine influence. This parameter transformation simplifies the interpretation process from complex code manipulation to straightforward gradient-based computation.
3Measurement precision
If local interpretation optimizes prediction for every input sample independently, then specific sample accuracy improves, but noise in individual input sample is overfitted leading to poor generalization
Solution Approach 1:
The patent merges local sample-specific analysis with global training set information. The influence function combines the gradient of the loss with respect to model parameters (local information) with the gradient of model parameters with respect to training data (global information). This merging ensures that interpretation for each sample is informed by the overall training distribution, preventing overfitting to noise in individual samples while maintaining sample-specific accuracy.
Data Source
AI summary
A sample-difference-based method and system for interpreting a deep-learning model for code classification is provided, wherein the method includes a step of off-line training an interpreter: constructing code transformation for every code sample in a training set to generate difference samples; generating difference samples respectively through feature deletion and code snippets extraction and then calculating feature importance scores accordingly; and inputting the original code samples, the difference samples and the feature importance scores into a neural network to get a trained interpreter; and a step of on-line interpreting the code samples: using the trained interpreter to extract important features from the snippets, then using an influence-function-based method to identify training samples that are most contributive to prediction, comparing the obtained important features and the most contributive training samples, and generating interpretation results for the object samples. The inventive system includes an off-line training module and an on-line interpretation module.


