Update app.py
Browse files
app.py
CHANGED
@@ -1,17 +1,13 @@
|
|
1 |
-
|
|
|
2 |
import gradio as gr
|
3 |
|
4 |
-
|
|
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
response_list = []
|
8 |
|
9 |
-
|
10 |
-
|
11 |
-
conversation = chatbot(conversation)
|
12 |
-
|
13 |
-
return conversation.generated_responses[-1]
|
14 |
-
|
15 |
-
demo_chatbot = gr.ChatInterface(vanilla_chatbot, title="Writer - Palmyra-small Chatbot", description="Enter text to start chatting.")
|
16 |
-
|
17 |
-
demo_chatbot.launch()
|
|
|
1 |
+
import torch
|
2 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, TextGenerationPipeline
|
3 |
import gradio as gr
|
4 |
|
5 |
+
model_name = "Writer/palmyra-small"
|
6 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
7 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
8 |
+
model = AutoModelForCausalLM.from_pretrained(model_name).to(device)
|
9 |
|
10 |
+
text_generator = TextGenerationPipeline(model=model, tokenizer=tokenizer)
|
|
|
11 |
|
12 |
+
iface = gr.Interface(fn=text_generator, inputs="text", outputs="text")
|
13 |
+
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|