Spaces:
Runtime error
Runtime error
Commit ·
ee3ead4
1
Parent(s): 2ee9864
Gradio demo after changing fine-tuned model output format
Browse files
app.py
CHANGED
|
@@ -8,7 +8,8 @@ model = AutoModelForCausalLM.from_pretrained("SattwikAyyagari/codegen-350M-NL-Ja
|
|
| 8 |
def generate_code(nl_input: str):
|
| 9 |
inputs=tokenizer(f"### Instruction: \n{nl_input}\n\n### Response:\n",return_tensors="pt")
|
| 10 |
outputs=model.generate(**inputs,max_new_tokens=128)
|
| 11 |
-
|
|
|
|
| 12 |
|
| 13 |
demo=gr.Interface(
|
| 14 |
fn=generate_code,
|
|
|
|
| 8 |
def generate_code(nl_input: str):
|
| 9 |
inputs=tokenizer(f"### Instruction: \n{nl_input}\n\n### Response:\n",return_tensors="pt")
|
| 10 |
outputs=model.generate(**inputs,max_new_tokens=128)
|
| 11 |
+
decoded=tokenizer.decode(outputs[0],skip_special_tokens=True)
|
| 12 |
+
return decoded.split("### Response:\n")[-1]
|
| 13 |
|
| 14 |
demo=gr.Interface(
|
| 15 |
fn=generate_code,
|