Spaces:
Runtime error
Runtime error
updated
Browse files
app.py
CHANGED
@@ -1,11 +1,12 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
2 |
|
3 |
def chat_with_phi2(input_text):
|
4 |
-
# Encoding the input text
|
5 |
encoded_input = tokenizer(input_text, return_tensors='pt')
|
6 |
-
# Generating output using the fine-tuned model
|
7 |
output = model.generate(**encoded_input, max_length=50)
|
8 |
-
# Decoding the output tokens to a string
|
9 |
response = tokenizer.decode(output[0], skip_special_tokens=True)
|
10 |
return response
|
11 |
|
@@ -17,5 +18,4 @@ interface = gr.Interface(
|
|
17 |
description="Ask any question about Washington and Lee University!"
|
18 |
)
|
19 |
|
20 |
-
interface.launch()
|
21 |
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
3 |
+
|
4 |
+
tokenizer = AutoTokenizer.from_pretrained("<lehmanc25>/my-phi2-model")
|
5 |
+
model = AutoModelForCausalLM.from_pretrained("<lehmanc25>/my-phi2-model")
|
6 |
|
7 |
def chat_with_phi2(input_text):
|
|
|
8 |
encoded_input = tokenizer(input_text, return_tensors='pt')
|
|
|
9 |
output = model.generate(**encoded_input, max_length=50)
|
|
|
10 |
response = tokenizer.decode(output[0], skip_special_tokens=True)
|
11 |
return response
|
12 |
|
|
|
18 |
description="Ask any question about Washington and Lee University!"
|
19 |
)
|
20 |
|
|
|
21 |
|