Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,26 +1,20 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
3 |
-
# Load your model
|
4 |
-
model_name = "WICKED4950/
|
5 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
6 |
-
model = AutoModelForCausalLM.from_pretrained(model_name
|
7 |
|
8 |
# Define the chatbot function
|
9 |
-
def
|
10 |
-
inputs = tokenizer
|
11 |
-
outputs = model.generate(inputs, max_length=
|
12 |
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
13 |
return response
|
14 |
|
15 |
-
#
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
description="A simple chatbot deployed using Hugging Face Spaces and Gradio!"
|
22 |
-
)
|
23 |
-
|
24 |
-
# Launch the app
|
25 |
-
if __name__ == "__main__":
|
26 |
-
interface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
3 |
+
# Load your model
|
4 |
+
model_name = "WICKED4950/Esther400K_1epoch"
|
5 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
6 |
+
model = AutoModelForCausalLM.from_pretrained(model_name)
|
7 |
|
8 |
# Define the chatbot function
|
9 |
+
def chatbot(input_text):
|
10 |
+
inputs = tokenizer(input_text, return_tensors="pt")
|
11 |
+
outputs = model.generate(inputs["input_ids"], max_length=100)
|
12 |
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
13 |
return response
|
14 |
|
15 |
+
# Gradio interface
|
16 |
+
iface = gr.Interface(fn=chatbot,
|
17 |
+
inputs="text",
|
18 |
+
outputs="text",
|
19 |
+
title="Your Chatbot")
|
20 |
+
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|