Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# What is this
|
2 |
+
This is a deepseek coder 7b model trained to predict commit messages for a diff.
|
3 |
+
|
4 |
+
# Languages trained on:
|
5 |
+
```py
|
6 |
+
LANGS = [
|
7 |
+
"Python",
|
8 |
+
"Rust",
|
9 |
+
"JavaScript",
|
10 |
+
"Java",
|
11 |
+
"Go",
|
12 |
+
"C++",
|
13 |
+
"C#",
|
14 |
+
"Ruby",
|
15 |
+
"PHP",
|
16 |
+
"TypeScript",
|
17 |
+
"C",
|
18 |
+
"Scala",
|
19 |
+
"Swift",
|
20 |
+
"Kotlin",
|
21 |
+
"Objective-C",
|
22 |
+
"Perl",
|
23 |
+
"Haskell",
|
24 |
+
"Bash",
|
25 |
+
"Sh",
|
26 |
+
"Lua",
|
27 |
+
"R",
|
28 |
+
"Julia",
|
29 |
+
]
|
30 |
+
```
|
31 |
+
|
32 |
+
# How to prompt:
|
33 |
+
```python
|
34 |
+
import difflib
|
35 |
+
class NDiff:
|
36 |
+
def __init__(self, s1, s2):
|
37 |
+
self.s1 = s1
|
38 |
+
self.s2 = s2
|
39 |
+
self.diff = difflib.ndiff(s1.split("\n"), s2.split("\n"))
|
40 |
+
|
41 |
+
def __str__(self):
|
42 |
+
return "\n".join([l for l in self.diff if l[0] != "?"])
|
43 |
+
|
44 |
+
def str_colored(self):
|
45 |
+
import colored
|
46 |
+
|
47 |
+
buf = ""
|
48 |
+
for l in self.diff:
|
49 |
+
if l[0] == "?":
|
50 |
+
continue
|
51 |
+
if l[0] == "-":
|
52 |
+
buf += colored.stylize(l, colored.fg("red"))
|
53 |
+
elif l[0] == "+":
|
54 |
+
buf += colored.stylize(l, colored.fg("green"))
|
55 |
+
else:
|
56 |
+
buf += l
|
57 |
+
buf += "\n"
|
58 |
+
return buf
|
59 |
+
|
60 |
+
def num_removed(self):
|
61 |
+
return len([l for l in self.diff if l[0] == "-"])
|
62 |
+
|
63 |
+
def num_added(self):
|
64 |
+
return len([l for l in self.diff if l[0] == "+"])
|
65 |
+
|
66 |
+
def __repr__(self):
|
67 |
+
return self.__str__()
|
68 |
+
|
69 |
+
def format_prompt(old, new):
|
70 |
+
diff_header = "<diff>"
|
71 |
+
instr_header = "<commit_message>"
|
72 |
+
diff = str(NDiff(old, new))
|
73 |
+
return f"{diff_header}\n{diff}\n{instr_header}\n"
|
74 |
+
|
75 |
+
def gen(old, new, max_new_tokens=200, temperature=0.45, top_p=0.90):
|
76 |
+
prompt = format_prompt(old, new)
|
77 |
+
toks = tokenizer.encode(prompt, return_tensors="pt").to(model.device)
|
78 |
+
outs = model.generate(toks, max_new_tokens=max_new_tokens, do_sample=True, temperature=temperature, top_p=top_p)
|
79 |
+
return [tokenizer.decode(out[len(toks[0]):], skip_special_tokens=True) for out in outs]
|
80 |
+
```
|
81 |
+
|
82 |
+
use the "gen" function with the old and new code
|