Spaces:
Runtime error
Runtime error
add examples, newer model
Browse files
app.py
CHANGED
|
@@ -4,22 +4,38 @@ import torch
|
|
| 4 |
import random
|
| 5 |
import gradio as gr
|
| 6 |
|
| 7 |
-
model_path = "shuttie/mistral-
|
| 8 |
|
| 9 |
generator = pipeline(
|
| 10 |
task="text-generation",
|
| 11 |
model=model_path,
|
| 12 |
torch_dtype=torch.bfloat16,
|
|
|
|
| 13 |
device_map="auto",
|
| 14 |
)
|
| 15 |
|
| 16 |
-
prompt = "
|
| 17 |
|
| 18 |
def make_response(message, history):
|
| 19 |
input = prompt.format(input=message)
|
| 20 |
-
generated = generator(input, return_full_text=False, max_new_tokens=
|
| 21 |
return generated[0]["generated_text"]
|
| 22 |
|
| 23 |
|
| 24 |
if __name__ == "__main__":
|
| 25 |
-
gr.ChatInterface(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
import random
|
| 5 |
import gradio as gr
|
| 6 |
|
| 7 |
+
model_path = "shuttie/mistral-nemo-dadjokes-v1"
|
| 8 |
|
| 9 |
generator = pipeline(
|
| 10 |
task="text-generation",
|
| 11 |
model=model_path,
|
| 12 |
torch_dtype=torch.bfloat16,
|
| 13 |
+
#device="cuda"
|
| 14 |
device_map="auto",
|
| 15 |
)
|
| 16 |
|
| 17 |
+
prompt = "[INST] {input} [/INST]"
|
| 18 |
|
| 19 |
def make_response(message, history):
|
| 20 |
input = prompt.format(input=message)
|
| 21 |
+
generated = generator(input, return_full_text=False, max_new_tokens=64, num_return_sequences=1)
|
| 22 |
return generated[0]["generated_text"]
|
| 23 |
|
| 24 |
|
| 25 |
if __name__ == "__main__":
|
| 26 |
+
gr.ChatInterface(
|
| 27 |
+
make_response,
|
| 28 |
+
textbox=gr.Textbox(placeholder="Ask me a question", container=False, scale=7),
|
| 29 |
+
examples=[
|
| 30 |
+
"My Wife gets mad at my pickle puns",
|
| 31 |
+
"I saw a couple cows smoking as they played poker",
|
| 32 |
+
"A vegan enters the bar and says",
|
| 33 |
+
"Accidentally took my cat’s medication.",
|
| 34 |
+
"My grandpa has the heart of a lion",
|
| 35 |
+
"Why can’t dinosaurs laugh?",
|
| 36 |
+
"Why don’t Americans use the metric system?",
|
| 37 |
+
"How do you catch a squirrel?",
|
| 38 |
+
"My girlfriend invited me over to finally meet her cannibal father.",
|
| 39 |
+
"Last time I stayed in a hotel I asked for the porn channel to be disabled"
|
| 40 |
+
],
|
| 41 |
+
).launch(server_name="0.0.0.0",share=True)
|