ToletiSri commited on
Commit
833dc32
1 Parent(s): 7fa7e58

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -28,8 +28,8 @@ class _MLPVectorProjector(nn.Module):
28
  model_name = "microsoft/phi-2"
29
 
30
  with torch.no_grad():
31
- phi2_text = AutoModelForCausalLM.from_pretrained(model_name, trust_remote_code=True, device_map="auto")
32
-
33
  tokenizer_text = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
34
 
35
  ## Audio model
@@ -86,9 +86,10 @@ def example_inference(input_text, count, image, img_qn, audio):
86
 
87
  def textMode(text, count):
88
  count = int(count)
 
89
  inputs = tokenizer_text(text, return_tensors="pt", return_attention_mask=False)
90
  prediction = tokenizer_text.batch_decode(
91
- phi2_text.generate(
92
  **inputs,
93
  max_new_tokens=count,
94
  bos_token_id=tokenizer_text.bos_token_id,
 
28
  model_name = "microsoft/phi-2"
29
 
30
  with torch.no_grad():
31
+ phi2_text = AutoModelForCausalLM.from_pretrained(model_name, trust_remote_code=True, device_map="auto",dtype=torch.float16)
32
+
33
  tokenizer_text = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
34
 
35
  ## Audio model
 
86
 
87
  def textMode(text, count):
88
  count = int(count)
89
+ text = "Question: " + text + "Answer: "
90
  inputs = tokenizer_text(text, return_tensors="pt", return_attention_mask=False)
91
  prediction = tokenizer_text.batch_decode(
92
+ phi2_finetuned.generate(
93
  **inputs,
94
  max_new_tokens=count,
95
  bos_token_id=tokenizer_text.bos_token_id,