Update README.md
Browse files
README.md
CHANGED
@@ -16,4 +16,62 @@ datasets:
|
|
16 |
---
|
17 |
|
18 |
## Fintuned Salesforce/codet5-small base model using 1000000 rows of data with git commits of different types of random languages for 5 epochs
|
19 |
-
## Took a total of 10 hours in a gpu of RTX 4060TI 16GB VRAM.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
---
|
17 |
|
18 |
## Fintuned Salesforce/codet5-small base model using 1000000 rows of data with git commits of different types of random languages for 5 epochs
|
19 |
+
## Took a total of 10 hours in a gpu of RTX 4060TI 16GB VRAM.
|
20 |
+
## Use the below instructions for inference
|
21 |
+
```
|
22 |
+
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
23 |
+
|
24 |
+
Load the correct CodeT5 tokenizer and model
|
25 |
+
model_name = "Salesforce/codet5-small"
|
26 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
27 |
+
model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
|
28 |
+
|
29 |
+
#Example Git diff input
|
30 |
+
git_diff = """
|
31 |
+
diff --git a/example.py b/example.py
|
32 |
+
index 3b18e12..b3f7e54 100644
|
33 |
+
--- a/example.py
|
34 |
+
+++ b/example.py
|
35 |
+
@@ -1,5 +1,6 @@
|
36 |
+
-def greet():
|
37 |
+
- print("Hello, world!")
|
38 |
+
+def greet_user(name):
|
39 |
+
+ print(f"Hello, {name}!")
|
40 |
+
|
41 |
+
-def farewell():
|
42 |
+
- print("Goodbye!")
|
43 |
+
+def farewell_user(name):
|
44 |
+
+ print(f"Goodbye, {name}!")
|
45 |
+
"""
|
46 |
+
|
47 |
+
#keep the instrcution unchanged, becus the model was trained on this static instruction
|
48 |
+
instruction = "Generate a commit message based on the following Git diff:\n\n"
|
49 |
+
|
50 |
+
task_input = instruction + git_diff
|
51 |
+
|
52 |
+
# Tokenize the input
|
53 |
+
inputs = tokenizer(
|
54 |
+
task_input,
|
55 |
+
max_length=512, # Truncate if necessary
|
56 |
+
truncation=True,
|
57 |
+
padding="max_length",
|
58 |
+
return_tensors="pt"
|
59 |
+
)
|
60 |
+
|
61 |
+
# Generate commit message
|
62 |
+
outputs = model.generate(
|
63 |
+
inputs["input_ids"],
|
64 |
+
max_length=50,
|
65 |
+
num_beams=5, # Use beam search
|
66 |
+
temperature=0.9, # Adds controlled randomness
|
67 |
+
top_p=0.9, # Nucleus sampling
|
68 |
+
early_stopping=True
|
69 |
+
)
|
70 |
+
|
71 |
+
# Decode the generated commit message
|
72 |
+
commit_message = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
73 |
+
|
74 |
+
# Print the result
|
75 |
+
print("Generated Commit Message:")
|
76 |
+
print(commit_message)
|
77 |
+
```
|