levena commited on
Commit
f0a4346
·
1 Parent(s): 3ea9848
Files changed (1) hide show
  1. app.py +11 -7
app.py CHANGED
@@ -7,14 +7,18 @@ def greet(name):
7
 
8
 
9
  @spaces.GPU
10
- def infer(name: str = "Who are you?"):
11
- from transformers import pipeline
 
 
 
 
 
 
 
 
 
12
 
13
- messages = [
14
- {"role": "user", "content": name},
15
- ]
16
- pipe = pipeline("text-generation", model="microsoft/Phi-3-mini-4k-instruct", trust_remote_code=True)
17
- return pipe(messages)
18
 
19
  text_input = gr.Textbox(label="Input Text", placeholder="test")
20
 
 
7
 
8
 
9
  @spaces.GPU
10
+ def infer(input_text: str = "Who are you?"):
11
+
12
+ # messages = [
13
+ # {"role": "user", "content": name},
14
+ # ]
15
+ model = transformers.AutoModelForCausalLM.from_pretrained("microsoft/Phi-3-mini-4k-instruct", trust_remote_code=True)
16
+ token = transformers.AutoTokenizer.from_pretrained("microsoft/Phi-3-mini-4k-instruct", trust_remote_code=True)
17
+ token.encode(input_text, return_tensors="pt" )
18
+ output = model(input_ids)
19
+ print(output)
20
+ return output
21
 
 
 
 
 
 
22
 
23
  text_input = gr.Textbox(label="Input Text", placeholder="test")
24