Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -7,10 +7,9 @@ from typing import Iterator
|
|
7 |
|
8 |
model_id = "mistralai/Mistral-Nemo-Instruct-2407"
|
9 |
|
10 |
-
|
11 |
MAX_INPUT_TOKEN_LENGTH = 4096
|
12 |
|
13 |
-
#
|
14 |
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
15 |
model = AutoModelForCausalLM.from_pretrained(
|
16 |
model_id,
|
@@ -55,24 +54,23 @@ def generate(
|
|
55 |
outputs.append(text)
|
56 |
yield "".join(outputs)
|
57 |
|
58 |
-
|
59 |
-
# Настройка интерфейса Gradio
|
60 |
iface = gr.ChatInterface(
|
61 |
generate,
|
62 |
chatbot=gr.Chatbot(height=600),
|
63 |
-
textbox=gr.Textbox(placeholder="
|
64 |
-
title="
|
65 |
-
description="
|
66 |
theme="soft",
|
67 |
-
retry_btn="
|
68 |
-
undo_btn="
|
69 |
-
clear_btn="
|
70 |
additional_inputs=[
|
71 |
-
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="
|
72 |
-
gr.Slider(minimum=0.1, maximum=2.0, value=0.7, step=0.1, label="
|
73 |
gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p (nucleus sampling)"),
|
74 |
],
|
75 |
)
|
76 |
|
77 |
-
#
|
78 |
iface.launch()
|
|
|
7 |
|
8 |
model_id = "mistralai/Mistral-Nemo-Instruct-2407"
|
9 |
|
|
|
10 |
MAX_INPUT_TOKEN_LENGTH = 4096
|
11 |
|
12 |
+
# Load tokenizer and model
|
13 |
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
14 |
model = AutoModelForCausalLM.from_pretrained(
|
15 |
model_id,
|
|
|
54 |
outputs.append(text)
|
55 |
yield "".join(outputs)
|
56 |
|
57 |
+
# Set up Gradio interface
|
|
|
58 |
iface = gr.ChatInterface(
|
59 |
generate,
|
60 |
chatbot=gr.Chatbot(height=600),
|
61 |
+
textbox=gr.Textbox(placeholder="Enter your message here...", container=False, scale=7),
|
62 |
+
title="Chat with Mistral Next v1.1",
|
63 |
+
description="This is a chat interface for the Mistral Next v1.1 Chat 4B model. Ask questions and get answers!",
|
64 |
theme="soft",
|
65 |
+
retry_btn="Retry",
|
66 |
+
undo_btn="Undo Last",
|
67 |
+
clear_btn="Clear",
|
68 |
additional_inputs=[
|
69 |
+
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Maximum number of new tokens"),
|
70 |
+
gr.Slider(minimum=0.1, maximum=2.0, value=0.7, step=0.1, label="Temperature"),
|
71 |
gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p (nucleus sampling)"),
|
72 |
],
|
73 |
)
|
74 |
|
75 |
+
# Launch the interface
|
76 |
iface.launch()
|