Sample-difference-based method and system for interpreting deep-learning model for code classification

US12393404B2 · US · B2

Patent metadata
FieldValue
Publication numberUS-12393404-B2
Application numberUS-202318475447-A
CountryUS
Kind codeB2
Filing dateSep 27, 2023
Priority dateDec 9, 2022
Publication dateAug 19, 2025
Grant dateAug 19, 2025

How to read this patent

A practical reading order for non-experts. Skip the full description unless you need deep technical detail.

  1. Title

    What the patent document calls the invention.

  2. Abstract

    A short plain-language summary of the technical disclosure.

  3. Assignees and inventors

    Who owns or filed the patent and who is credited as inventor.

  4. Key dates

    Filing, priority, publication, and grant dates set the timeline.

  5. First independent claim

    The legal scope of protection — read this for what is actually claimed.

  6. CPC / IPC classifications

    Technology tags used to group this patent with similar filings.

  7. Citations and related patents

    Prior art links and similar publications in this corpus.

Abstract

Official abstract text for this publication.

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.

First claim

Opening claim text (preview).

What is claimed is: 1. A sample-difference-based method for interpreting a deep-learning model for code classification, the method comprising: off-line training an interpreter comprising: constructing code transformation for every code sample in a training set to generate difference samples; generating the difference samples through feature deletion and inputting samples before and after the feature deletion into the model to be interpreted to acquire prediction confidence levels corresponding to tags in the training set, calculating a difference between the prediction confidence levels of two samples as feature importance scores; generating the difference samples through extracting code snippets and inputting the code snippet made using a feature immediately before a feature to be calculated as its snipping point and the code snippet made using the feature to be calculated as its snipping point into the model to be interpreted to acquire the prediction confidence levels corresponding to the tags, calculating the difference between the prediction confidence levels of two samples as the feature importance scores; and inputting the original samples, the difference samples and the feature importance scores into a neural network, constructing a deep neural network framework for the interpreter and two approximators, defining a loss function, then fixing the two approximators and training the interpreter, then fixing the interpreter and training the two approximators, and circularly iterating the training until loss convergence, so as to eventually obtain a trained interpreter; and on-line interpreting the code samples comprising: using the trained interpreter to extract important features from snippets of object code samples, then using an influence-function-based method to calculate an effect of removing a training sample in the training set on loss of prediction sample, so as to identify training samples in the training set that are most contributive to prediction for the training sample, comparing the extracted important features and the most contributive training samples, and generating interpretation results for the object code samples, wherein the constructing code transformation to generate the difference samples comprises: for the input code samples, scanning all code transformation points that meet transformation requirements, generating a plurality of transformation vectors of corresponding dimensions, conducting the code transformation with the generated transformation vectors, screening the generated difference samples, and deleting the samples that do not meet expectations so as to get a difference sample set. 2. The method of claim 1 , wherein the off-line training the interpreter comprises: deleting the features and calculating the feature importance scores: deleting each feature in the code samples individually, to generate the difference samples, so that a number of the generated difference samples is equal to a number of the features; inputting the difference samples into the model to be interpreted for prediction, and generating the feature importance scores of the corresponding features according to variation in prediction values caused by deletion of the features. 3. The method of claim 1 , wherein the off-line training the interpreter comprises: forming the snippets and calculating the feature importance scores: for the code samples, defining each of the features as a snipping point, and extracting the features between a first feature of the sample and the snipping point, so as to get the code snippets, tail-padding each of the code snippets with zeros to generate the vectors of an identical length, inputting the vectors into the model to be interpreted for the prediction, generating the feature importance scores of the corresponding features according to variation in prediction values caused by movement of the snipping points. 4. The method of claim 1 , wherein the framework of the interpreter and two approximators is designed such that the approximators have a structure that is identical to a structure of the original model to be interpreted, and that the interpreter has a model structure determined by format of input data, wherein if the data are input as sequences, the interpreter is designed as a Recurrent Neural Network; or if the data are input as abstract syntax trees (ASTs), the interpreter is designed as an AST-based Convolutional Neural Network. 5. The method of claim 1 , wherein the on-line interpreting the code samples comprises: extracting the important features from the object code samples: inputting the vectors of the object code samples into the trained interpreter to acquire a feature importance score vector, and extracting features with relatively high feature importance scores, so as to obtain the important features of the object code samples; identifying the training samples that are most contributive to prediction for the object code samples; and integrating the important features and the training samples to generate the interpretation result, wherein the interpretation result is visualizable. 6. A sample-difference-based system for interpreting a deep-learning model for code classification, the system comprising a processor that comprises: an off-line training module, configured for: constructing code transformation for every code sample in a training set to generate difference samples; generating the difference samples through feature deletion and inputting samples before and after the feature deletion into the model to be interpreted to acquire prediction confidence levels corresponding to tags in the training set, calculating a difference between the prediction confidence levels of two samples as feature importance scores; generating the difference samples through extracting code snippets and inputting the code snippet made using a feature immediately before a feature to be calculated as its snipping point and the code snippet made using the feature to be calculated as its snipping point into the model to be interpreted to acquire the prediction confidence levels corresponding to the tags, calculating the difference between the prediction confidence levels of two samples as the feature importance scores; and inputting the original samples, the difference samples and the feature importance scores into a neural network, constructing a deep neural network framework for the interpreter and two approximators, defining a loss function, then fixing the two approximators and training the interpreter, then fixing the interpreter and training the two approximators, and circularly iterating the training until loss convergence, so as to eventually obtain a trained interpreter; and an on-line interpretation module, configured for: using the trained interpreter to extract important features from object code samples, then using an influence-function-based method to calculate an effect of removing a training sample in the training set on loss of prediction sample, so as to identify training samples in the training set that are most contributive to prediction for the training sample, comparing the extracted important features and the most contributive training samples, and generating interpretation results for the object code samples, the off-line training module is configured to process the input code samples by scanning all code transformation points that meet transformation requirements, generating a plurality of transformation vectors of corresponding dimensions, conducting the code transformation with the generated transformation vectors, screening the generated difference samples, and deleting the samples that do not meet expectations so as to get a difference sample set. 7. The system of claim 6 , wherein the off-line training module comp

Assignees

Inventors

Classifications

  • G06F8/42Primary

    Syntactic analysis · CPC title

  • G06F8/35Primary

    model driven · CPC title

Patent family

Related publications grouped by family.

External sources

Frequently asked questions

Answers are generated from the same data shown on this page.

What does patent US12393404B2 cover?
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…
Who is the assignee on this patent?
Univ Huazhong Science Tech
What technology area does this patent fall under?
Primary CPC classification G06F8/42. Mapped technology areas include Physics.
When was this patent published?
Publication date Tue Aug 19 2025 00:00:00 GMT+0000 (Coordinated Universal Time) (B2). Legal status and post-grant events are not shown on this page.
What related patents are in patentsdb?
We list 12 related publications on this page (citations in our corpus or others sharing the same primary CPC).