lazarusrolando commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,41 +1,25 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from transformers import
|
| 3 |
-
import torch
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
model = AutoModelForCausalLM.from_pretrained(
|
| 10 |
-
MODEL_ID,
|
| 11 |
-
torch_dtype=torch.float32
|
| 12 |
)
|
| 13 |
|
| 14 |
-
def
|
| 15 |
-
|
| 16 |
message,
|
| 17 |
-
return_tensors="pt"
|
| 18 |
-
)
|
| 19 |
-
|
| 20 |
-
outputs = model.generate(
|
| 21 |
-
**inputs,
|
| 22 |
max_new_tokens=128,
|
| 23 |
-
|
| 24 |
-
|
| 25 |
)
|
| 26 |
|
| 27 |
-
return
|
| 28 |
-
outputs[0],
|
| 29 |
-
skip_special_tokens=True
|
| 30 |
-
)
|
| 31 |
|
| 32 |
demo = gr.Interface(
|
| 33 |
-
fn=
|
| 34 |
-
inputs=gr.Textbox(
|
| 35 |
-
|
| 36 |
-
placeholder="Ask OpenHusky..."
|
| 37 |
-
),
|
| 38 |
-
outputs="text",
|
| 39 |
title="OpenHusky"
|
| 40 |
)
|
| 41 |
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
|
|
|
| 3 |
|
| 4 |
+
pipe = pipeline(
|
| 5 |
+
"text-generation",
|
| 6 |
+
model="lazarus19/OpenHusky"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
)
|
| 8 |
|
| 9 |
+
def chat(message):
|
| 10 |
+
result = pipe(
|
| 11 |
message,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
max_new_tokens=128,
|
| 13 |
+
do_sample=True,
|
| 14 |
+
temperature=0.7
|
| 15 |
)
|
| 16 |
|
| 17 |
+
return result[0]["generated_text"]
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
demo = gr.Interface(
|
| 20 |
+
fn=chat,
|
| 21 |
+
inputs=gr.Textbox(label="Message"),
|
| 22 |
+
outputs=gr.Textbox(label="Response"),
|
|
|
|
|
|
|
|
|
|
| 23 |
title="OpenHusky"
|
| 24 |
)
|
| 25 |
|