Spaces:
Runtime error
Runtime error
malvika2003
commited on
Update qachatbot.py
Browse files- qachatbot.py +29 -29
qachatbot.py
CHANGED
@@ -1,30 +1,30 @@
|
|
1 |
-
import gradio as gr
|
2 |
-
from transformers import AutoTokenizer, TextIteratorStreamer
|
3 |
-
|
4 |
-
# Define the models and their configurations
|
5 |
-
model_name = "phi-2" # Replace with the actual model name
|
6 |
-
model_configuration = {
|
7 |
-
"toeknizer_kwargs": {
|
8 |
-
}
|
9 |
-
|
10 |
-
# Load the tokenizer
|
11 |
-
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
12 |
-
tokenizer_kwargs = model_configuration.get("toeknizer_kwargs", {})
|
13 |
-
|
14 |
-
# Define the Gradio interface
|
15 |
-
def main():
|
16 |
-
with gr.Row():
|
17 |
-
with gr.Column(scale=4):
|
18 |
-
user_text = gr.Textbox(
|
19 |
-
placeholder="Write an email about an alpaca that likes flan",
|
20 |
-
label="User instruction",
|
21 |
-
)
|
22 |
-
model_output = gr.Textbox(label="Model response", interactive=False)
|
23 |
-
performance = gr.Textbox(label="Performance", lines=1, interactive=False)
|
24 |
-
with gr.Column(scale=1):
|
25 |
-
button_clear = gr.Button(value="Clear")
|
26 |
-
button_submit = gr.Button(value="Submit")
|
27 |
-
|
28 |
-
# Run the Gradio interface
|
29 |
-
iface = gr.Interface(fn=main, inputs=user_text, outputs=model_output, performance=performance, live=True)
|
30 |
iface.launch()
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import AutoTokenizer, TextIteratorStreamer
|
3 |
+
|
4 |
+
# Define the models and their configurations
|
5 |
+
model_name = "phi-2" # Replace with the actual model name
|
6 |
+
model_configuration = {
|
7 |
+
"toeknizer_kwargs": {'model_id': 'susnato/phi-2', 'prompt_template': 'Instruct:{instruction}\nOutput:'} # Replace with the actual tokenizer configuration
|
8 |
+
}
|
9 |
+
|
10 |
+
# Load the tokenizer
|
11 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
12 |
+
tokenizer_kwargs = model_configuration.get("toeknizer_kwargs", {})
|
13 |
+
|
14 |
+
# Define the Gradio interface
|
15 |
+
def main():
|
16 |
+
with gr.Row():
|
17 |
+
with gr.Column(scale=4):
|
18 |
+
user_text = gr.Textbox(
|
19 |
+
placeholder="Write an email about an alpaca that likes flan",
|
20 |
+
label="User instruction",
|
21 |
+
)
|
22 |
+
model_output = gr.Textbox(label="Model response", interactive=False)
|
23 |
+
performance = gr.Textbox(label="Performance", lines=1, interactive=False)
|
24 |
+
with gr.Column(scale=1):
|
25 |
+
button_clear = gr.Button(value="Clear")
|
26 |
+
button_submit = gr.Button(value="Submit")
|
27 |
+
|
28 |
+
# Run the Gradio interface
|
29 |
+
iface = gr.Interface(fn=main, inputs=user_text, outputs=model_output, performance=performance, live=True)
|
30 |
iface.launch()
|