deltadebugging
Science Score: 26.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (5.9%) to scientific vocabulary
Repository
Basic Info
- Host: GitHub
- Owner: oussema18
- License: mit
- Language: Python
- Default Branch: main
- Size: 20.6 MB
Statistics
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
- Releases: 0
Metadata Files
README.md
Delta Debugging Algorithm for CodeBERT
based on Sivand Repo : https://github.com/mdrafiqulrabin/SIVAND/tree/5d3101f3c35b7572a3680ae899e813f4de67eb6f
CodeBERT Model
Some changes were applied to confirm the codeBERT Model prediction task : 1. loadmodelM() function in helper.py file :
>def load_model_M(model_path=""):
model = RobertaForMaskedLM.from_pretrained("microsoft/codebert-base-mlm")
return model
- predictionwithM() function in helper.pyfile :
>def predictionwithM(model, code):
pred, score, loss = None, None, 0
tokenizer = RobertaTokenizer.frompretrained("microsoft/codebert-base-mlm")
fillmask = pipeline("fill-mask", model=model, tokenizer=tokenizer)
predictions = fillmask(code)
pred, score = findmaxscoretoken(predictions)
return pred, score, loss
## Usage Example
Setting the input
when running the codeBERT Model with this input code:
CODE = for i in range(enumerate(j)) : print(< mask >)
```
model = RobertaForMaskedLM.frompretrained("microsoft/codebert-base-mlm") tokenizer = RobertaTokenizer.frompretrained("microsoft/codebert-base-mlm")
CODE = " for i in range(enumerate(j)) : print(
```
we get in fact the token 'i' as the token with highest score :
outputs = [
{'score': 0.952255368232727, 'token': 118, 'tokenstr': 'i', 'sequence': 'for i in range(enumerate(j)) : print(i)'},
{'score': 0.027622802183032036, 'token': 267, 'tokenstr': 'j', 'sequence': 'for i in range(enumerate(j)) : print(j)'},
{'score': 0.0017873893957585096, 'token': 100, 'tokenstr': 'I', 'sequence': 'for i in range(enumerate(j)) : print(I)'},
{'score': 0.0016388560179620981, 'token': 33850, 'tokenstr': 'jj', 'sequence': 'for i in range(enumerate(j)) : print(jj)'},
{'score': 0.0008160002762451768, 'token': 330, 'token_str': 'k', 'sequence': 'for i in range(enumerate(j)) : print(k)'}
]
now we want to know which tokens can be removed so the prediction won't change and still be the token i.
in the MyDD.py file, you would set the methodname and the methodbody variables as the hidden token (mask) and the code without the token. So for this example, we want the model to predict the token 'in'. so we hide with the word < mask > (for i in range(enumerate(j)): print(< mask >)) and pass it as the method body and i as the hidden token for the methodname :
```
methodname, method_body = "i", "for i in range(enumerate(j)) : print(
```
Understanding the output
in the console, the minimal tokens required to preserve the original prediction for the input code
dd: done
The 1-minimal prediction-preserving input is [(2, 'i'), (17, '('), (18, '<'), (19, 'mask'), (20, '>')]
Removing any element will make the prediction go away.
this will mean that the minimal tokens are
i(< mask >
Results correctness
to verify the correctness of the outputs we would pass the i(< mask > code to the codeBERT Model and see if the prediction is still i : ```
model = RobertaForMaskedLM.frompretrained("microsoft/codebert-base-mlm") tokenizer = RobertaTokenizer.frompretrained("microsoft/codebert-base-mlm")
CODE = "i(
outputs = fill_mask(CODE) ```
Indeed the model will predict the token i with the highest score for CODE = "i(< mask >":
outputs = [
{'score': 0.22026327252388,'token': 118, 'tokenstr': 'i', 'sequence': 'i(i'},
{'score': 0.027704259380698204,'token': 4839, 'tokenstr': ' )', 'sequence': 'i( )'},
{'score': 0.025121279060840607, 'token': 1178, 'tokenstr': 'x', 'sequence': 'i(x'},
{'score': 0.02374928630888462, 'token': 428, 'tokenstr': 'b', 'sequence': 'i(b'},
{'score': 0.01792656071484089, 'token': 506, 'token_str': 'f', 'sequence': 'i(f'}
]
Owner
- Name: oussama masmoudi
- Login: oussema18
- Kind: user
- Repositories: 1
- Profile: https://github.com/oussema18
GitHub Events
Total
Last Year
Dependencies
- com.github.javaparser:javaparser-core 3.14.5
- com.github.javaparser:javaparser-core 3.14.5