Spaces:
Runtime error
Runtime error
Commit
·
7fbdf32
1
Parent(s):
db91e40
CodeParrot main model
Browse files
app.py
CHANGED
@@ -18,10 +18,10 @@ def rename_customer(id, newName):\n\t# PROMPT\n\tcur.execute("UPDATE customer SE
|
|
18 |
|
19 |
modelPath = {
|
20 |
# "GPT2-Medium": "gpt2-medium",
|
21 |
-
"CodeParrot-small": "codeparrot/codeparrot-small",
|
22 |
# "CodeGen-350-Mono": "Salesforce/codegen-350M-mono",
|
23 |
# "GPT-Neo-1.3B": "EleutherAI/gpt-neo-1.3B",
|
24 |
-
|
25 |
# "CodeGen-2B-Mono": "Salesforce/codegen-2B-mono",
|
26 |
}
|
27 |
|
@@ -29,6 +29,9 @@ preloadModels = {}
|
|
29 |
for m in list(modelPath.keys()):
|
30 |
preloadModels[m] = ecco.from_pretrained(modelPath[m])
|
31 |
|
|
|
|
|
|
|
32 |
def generation(tokenizer, model, content):
|
33 |
decoder = 'Standard'
|
34 |
num_beams = 2 if decoder == 'Beam' else None
|
@@ -63,6 +66,7 @@ def generation(tokenizer, model, content):
|
|
63 |
return [
|
64 |
"".join(full_output.tokens),
|
65 |
str(prob.item() * 100),
|
|
|
66 |
]
|
67 |
|
68 |
def clean_comment(txt):
|
@@ -78,8 +82,8 @@ def code_from_prompts(
|
|
78 |
# tokenizer = AutoTokenizer.from_pretrained(modelPath[model])
|
79 |
# model = ecco.from_pretrained(modelPath[model])
|
80 |
# model = preloadModels[model]
|
81 |
-
tokenizer = AutoTokenizer.from_pretrained(modelPath["CodeParrot
|
82 |
-
model = preloadModels["CodeParrot
|
83 |
|
84 |
code = ""
|
85 |
headerComment = headerComment.strip()
|
@@ -108,7 +112,7 @@ def get_customer(id):\n\tcur.execute('SELECT * FROM customers WHERE id = %s', st
|
|
108 |
prob = float(results[1])
|
109 |
requests.post("https://code-adv.herokuapp.com/dbpost", json={
|
110 |
"password": os.environ.get('SERVER_PASS', 'help'),
|
111 |
-
"model": "codeparrot/codeparrot
|
112 |
"headerComment": headerComment,
|
113 |
"bodyComment": fnComment,
|
114 |
"prefunction": pre_content,
|
@@ -134,7 +138,8 @@ iface = gr.Interface(
|
|
134 |
outputs=[
|
135 |
gr.components.Textbox(label="Most probable code"),
|
136 |
gr.components.Textbox(label="Probability of concat"),
|
|
|
137 |
],
|
138 |
-
description="Prompt the code model to write a SQL query with string concatenation - Evaluation on CodeParrot
|
139 |
)
|
140 |
iface.launch()
|
|
|
18 |
|
19 |
modelPath = {
|
20 |
# "GPT2-Medium": "gpt2-medium",
|
21 |
+
# "CodeParrot-small": "codeparrot/codeparrot-small",
|
22 |
# "CodeGen-350-Mono": "Salesforce/codegen-350M-mono",
|
23 |
# "GPT-Neo-1.3B": "EleutherAI/gpt-neo-1.3B",
|
24 |
+
"CodeParrot": "codeparrot/codeparrot",
|
25 |
# "CodeGen-2B-Mono": "Salesforce/codegen-2B-mono",
|
26 |
}
|
27 |
|
|
|
29 |
for m in list(modelPath.keys()):
|
30 |
preloadModels[m] = ecco.from_pretrained(modelPath[m])
|
31 |
|
32 |
+
topComments = []
|
33 |
+
rankings = requests.get("https://code-adv.herokuapp.com/db").json()['results']
|
34 |
+
|
35 |
def generation(tokenizer, model, content):
|
36 |
decoder = 'Standard'
|
37 |
num_beams = 2 if decoder == 'Beam' else None
|
|
|
66 |
return [
|
67 |
"".join(full_output.tokens),
|
68 |
str(prob.item() * 100),
|
69 |
+
rankings
|
70 |
]
|
71 |
|
72 |
def clean_comment(txt):
|
|
|
82 |
# tokenizer = AutoTokenizer.from_pretrained(modelPath[model])
|
83 |
# model = ecco.from_pretrained(modelPath[model])
|
84 |
# model = preloadModels[model]
|
85 |
+
tokenizer = AutoTokenizer.from_pretrained(modelPath["CodeParrot"])
|
86 |
+
model = preloadModels["CodeParrot"]
|
87 |
|
88 |
code = ""
|
89 |
headerComment = headerComment.strip()
|
|
|
112 |
prob = float(results[1])
|
113 |
requests.post("https://code-adv.herokuapp.com/dbpost", json={
|
114 |
"password": os.environ.get('SERVER_PASS', 'help'),
|
115 |
+
"model": "codeparrot/codeparrot",
|
116 |
"headerComment": headerComment,
|
117 |
"bodyComment": fnComment,
|
118 |
"prefunction": pre_content,
|
|
|
138 |
outputs=[
|
139 |
gr.components.Textbox(label="Most probable code"),
|
140 |
gr.components.Textbox(label="Probability of concat"),
|
141 |
+
gr.components.Json(value=rankings)
|
142 |
],
|
143 |
+
description="Prompt the code model to write a SQL query with string concatenation - Evaluation on CodeParrot - leaderboard coming at https://code-adv.herokuapp.com/dbcompose",
|
144 |
)
|
145 |
iface.launch()
|