Sahibsingh12 commited on
Commit
aeacbe1
·
1 Parent(s): 1345934

files changed

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -14,9 +14,14 @@ import torch
14
  model = AutoModelForCausalLM.from_pretrained("Sahibsingh12/phi-1-5-finetuned-cazton_complete", trust_remote_code=True, torch_dtype=torch.float32)
15
  tokenizer = AutoTokenizer.from_pretrained("microsoft/phi-1_5", trust_remote_code=True)
16
 
 
 
 
 
 
17
 
18
  def greet(name):
19
  return "Hello " + name + "!!"
20
 
21
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
22
- iface.launch()
 
14
  model = AutoModelForCausalLM.from_pretrained("Sahibsingh12/phi-1-5-finetuned-cazton_complete", trust_remote_code=True, torch_dtype=torch.float32)
15
  tokenizer = AutoTokenizer.from_pretrained("microsoft/phi-1_5", trust_remote_code=True)
16
 
17
+ def infer(text):
18
+ inputs = tokenizer(f'''question: {text} answer: ''', return_tensors="pt", return_attention_mask=False)
19
+ outputs = model.generate(**inputs, max_length=116)
20
+ text = tokenizer.batch_decode(outputs)[0]
21
+ return text
22
 
23
  def greet(name):
24
  return "Hello " + name + "!!"
25
 
26
+ iface = gr.Interface(fn=infer, inputs="text", outputs="text")
27
+ iface.launch(share=True)