Spaces:
Running
on
Zero
Running
on
Zero
MohamedRashad
commited on
Commit
·
45266c6
1
Parent(s):
5502bf7
Refactor model ID handling in app.py and update requirements.txt
Browse files
app.py
CHANGED
@@ -2,6 +2,7 @@ import spaces
|
|
2 |
from transformers import AutoModelForCausalLM, AutoTokenizer, TextIteratorStreamer
|
3 |
import torch
|
4 |
import gradio as gr
|
|
|
5 |
from threading import Thread
|
6 |
import subprocess
|
7 |
subprocess.run('pip install -U flash-attn --no-build-isolation', env={'FLASH_ATTENTION_SKIP_CUDA_BUILD': "TRUE"}, shell=True)
|
@@ -11,9 +12,9 @@ models_available = [
|
|
11 |
"silma-ai/SILMA-9B-Instruct-v1.0",
|
12 |
"inceptionai/jais-adapted-7b-chat",
|
13 |
"inceptionai/jais-family-6p7b-chat",
|
14 |
-
"
|
15 |
-
|
16 |
-
"
|
17 |
]
|
18 |
|
19 |
tokenizer_a, model_a = None, None
|
@@ -69,6 +70,7 @@ def load_model_b(model_id):
|
|
69 |
|
70 |
@spaces.GPU()
|
71 |
def generate_both(system_prompt, input_text, chatbot_a, chatbot_b, max_new_tokens=2048, temperature=0.2, top_p=0.9, repetition_penalty=1.1):
|
|
|
72 |
text_streamer_a = TextIteratorStreamer(tokenizer_a, skip_prompt=True)
|
73 |
text_streamer_b = TextIteratorStreamer(tokenizer_b, skip_prompt=True)
|
74 |
|
@@ -163,7 +165,7 @@ def generate_both(system_prompt, input_text, chatbot_a, chatbot_b, max_new_token
|
|
163 |
def clear():
|
164 |
return [], []
|
165 |
|
166 |
-
arena_notes = """Important Notes:
|
167 |
- Sometimes an error may occur when generating the response, in this case, please try again.
|
168 |
"""
|
169 |
|
@@ -173,11 +175,12 @@ with gr.Blocks() as demo:
|
|
173 |
gr.Markdown(arena_notes)
|
174 |
system_prompt = gr.Textbox(lines=1, label="System Prompt", value="أنت متحدث لبق باللغة العربية!", rtl=True, text_align="right", show_copy_button=True)
|
175 |
with gr.Row(variant="panel"):
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
|
|
181 |
with gr.Row(variant="panel"):
|
182 |
with gr.Column(scale=1):
|
183 |
submit_btn = gr.Button(value="Generate", variant="primary")
|
|
|
2 |
from transformers import AutoModelForCausalLM, AutoTokenizer, TextIteratorStreamer
|
3 |
import torch
|
4 |
import gradio as gr
|
5 |
+
|
6 |
from threading import Thread
|
7 |
import subprocess
|
8 |
subprocess.run('pip install -U flash-attn --no-build-isolation', env={'FLASH_ATTENTION_SKIP_CUDA_BUILD': "TRUE"}, shell=True)
|
|
|
12 |
"silma-ai/SILMA-9B-Instruct-v1.0",
|
13 |
"inceptionai/jais-adapted-7b-chat",
|
14 |
"inceptionai/jais-family-6p7b-chat",
|
15 |
+
"inceptionai/jais-family-2p7b-chat",
|
16 |
+
"inceptionai/jais-family-1p3b-chat",
|
17 |
+
"inceptionai/jais-family-590m-chat",
|
18 |
]
|
19 |
|
20 |
tokenizer_a, model_a = None, None
|
|
|
70 |
|
71 |
@spaces.GPU()
|
72 |
def generate_both(system_prompt, input_text, chatbot_a, chatbot_b, max_new_tokens=2048, temperature=0.2, top_p=0.9, repetition_penalty=1.1):
|
73 |
+
|
74 |
text_streamer_a = TextIteratorStreamer(tokenizer_a, skip_prompt=True)
|
75 |
text_streamer_b = TextIteratorStreamer(tokenizer_b, skip_prompt=True)
|
76 |
|
|
|
165 |
def clear():
|
166 |
return [], []
|
167 |
|
168 |
+
arena_notes = """## Important Notes:
|
169 |
- Sometimes an error may occur when generating the response, in this case, please try again.
|
170 |
"""
|
171 |
|
|
|
175 |
gr.Markdown(arena_notes)
|
176 |
system_prompt = gr.Textbox(lines=1, label="System Prompt", value="أنت متحدث لبق باللغة العربية!", rtl=True, text_align="right", show_copy_button=True)
|
177 |
with gr.Row(variant="panel"):
|
178 |
+
with gr.Column():
|
179 |
+
model_dropdown_a = gr.Dropdown(label="Model A", choices=models_available, value=None)
|
180 |
+
chatbot_a = gr.Chatbot(label="Model A", rtl=True, likeable=True, show_copy_button=True, height=500)
|
181 |
+
with gr.Column():
|
182 |
+
model_dropdown_b = gr.Dropdown(label="Model B", choices=models_available, value=None)
|
183 |
+
chatbot_b = gr.Chatbot(label="Model B", rtl=True, likeable=True, show_copy_button=True, height=500)
|
184 |
with gr.Row(variant="panel"):
|
185 |
with gr.Column(scale=1):
|
186 |
submit_btn = gr.Button(value="Generate", variant="primary")
|