Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -1,25 +1,17 @@
|
|
1 |
-
from transformers import AutoTokenizer,
|
2 |
import gradio as grad
|
3 |
-
|
4 |
-
mdl =
|
5 |
|
|
|
|
|
|
|
|
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
num_beams=5,
|
15 |
-
repetition_penalty=2.5,
|
16 |
-
|
17 |
-
early_stopping=True
|
18 |
-
)
|
19 |
-
|
20 |
-
response = text2text_tkn.decode(tkn_ids[0], skip_special_tokens=True)
|
21 |
-
return response
|
22 |
-
|
23 |
-
para=grad.Textbox(lines=10, label="Paragraph", placeholder="Copy paragraph")
|
24 |
-
out=grad.Textbox(lines=1, label="Summary")
|
25 |
-
grad.Interface(text2text_summary, inputs=para, outputs=out).launch()
|
|
|
1 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
2 |
import gradio as grad
|
3 |
+
codegen_tkn = AutoTokenizer.from_pretrained("Salesforce/codegen-350M-mono")
|
4 |
+
mdl = AutoModelForCausalLM.from_pretrained("Salesforce/codegen-350M-mono")
|
5 |
|
6 |
+
def codegen(intent):
|
7 |
+
# give input as text which reflects intent of the program.
|
8 |
+
#text = " write a function which takes 2 numbers as input and returns the larger of the two"
|
9 |
+
input_ids = codegen_tkn(intent, return_tensors="pt").input_ids
|
10 |
|
11 |
+
gen_ids = mdl.generate(input_ids, max_length=128)
|
12 |
+
response = codegen_tkn.decode(gen_ids[0], skip_special_tokens=True)
|
13 |
+
return response
|
14 |
|
15 |
+
output=grad.Textbox(lines=1, label="Generated Python Code", placeholder="")
|
16 |
+
inp=grad.Textbox(lines=1, label="Place your intent here")
|
17 |
+
grad.Interface(codegen, inputs=inp, outputs=output).launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|