Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -30,19 +30,14 @@ def load_model(model_id):
|
|
30 |
if not torch.cuda.is_available():
|
31 |
DESCRIPTION += "\n<p>Running on CPU 🥶 This demo does not work on CPU.</p>"
|
32 |
|
33 |
-
if torch.cuda.is_available():
|
34 |
-
model_id = "Nekochu/Luminia-13B-v3"
|
35 |
-
model, tokenizer = load_model(model_id)
|
36 |
-
|
37 |
MODELS = [
|
38 |
-
|
39 |
-
|
40 |
]
|
41 |
|
42 |
@spaces.GPU(duration=120)
|
43 |
def generate(
|
44 |
-
|
45 |
-
custom_model_id: str,
|
46 |
message: str,
|
47 |
chat_history: list[tuple[str, str]],
|
48 |
system_prompt: str,
|
@@ -52,8 +47,7 @@ def generate(
|
|
52 |
top_k: int = 50,
|
53 |
repetition_penalty: float = 1.2,
|
54 |
) -> Iterator[str]:
|
55 |
-
|
56 |
-
model, tokenizer = load_model(selected_model_id)
|
57 |
|
58 |
conversation = []
|
59 |
if system_prompt:
|
@@ -88,18 +82,10 @@ def generate(
|
|
88 |
outputs.append(text)
|
89 |
yield "".join(outputs)
|
90 |
|
91 |
-
model_dropdown = gr.Dropdown(
|
92 |
-
label="Select Predefined Model",
|
93 |
-
choices=[model["name"] for model in MODELS],
|
94 |
-
value=MODELS[0]["name"], # Default to the first model
|
95 |
-
)
|
96 |
-
custom_model_id_input = gr.Textbox(label="Or Enter Custom Model ID", placeholder="Enter model ID here")
|
97 |
-
|
98 |
chat_interface = gr.ChatInterface(
|
99 |
fn=generate,
|
100 |
additional_inputs=[
|
101 |
-
|
102 |
-
custom_model_id_input,
|
103 |
gr.Textbox(label="System prompt", lines=6),
|
104 |
gr.Slider(
|
105 |
label="Max new tokens",
|
@@ -151,4 +137,4 @@ with gr.Blocks(css="style.css") as demo:
|
|
151 |
gr.Markdown(LICENSE)
|
152 |
|
153 |
if __name__ == "__main__":
|
154 |
-
demo.queue(max_size=20).launch()
|
|
|
30 |
if not torch.cuda.is_available():
|
31 |
DESCRIPTION += "\n<p>Running on CPU 🥶 This demo does not work on CPU.</p>"
|
32 |
|
|
|
|
|
|
|
|
|
33 |
MODELS = [
|
34 |
+
"Nekochu/Luminia-13B-v3",
|
35 |
+
"Nekochu/Llama-2-13B-German-ORPO",
|
36 |
]
|
37 |
|
38 |
@spaces.GPU(duration=120)
|
39 |
def generate(
|
40 |
+
model_id: str,
|
|
|
41 |
message: str,
|
42 |
chat_history: list[tuple[str, str]],
|
43 |
system_prompt: str,
|
|
|
47 |
top_k: int = 50,
|
48 |
repetition_penalty: float = 1.2,
|
49 |
) -> Iterator[str]:
|
50 |
+
model, tokenizer = load_model(model_id)
|
|
|
51 |
|
52 |
conversation = []
|
53 |
if system_prompt:
|
|
|
82 |
outputs.append(text)
|
83 |
yield "".join(outputs)
|
84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
chat_interface = gr.ChatInterface(
|
86 |
fn=generate,
|
87 |
additional_inputs=[
|
88 |
+
gr.Dropdown(label="Select Model", choices=MODELS),
|
|
|
89 |
gr.Textbox(label="System prompt", lines=6),
|
90 |
gr.Slider(
|
91 |
label="Max new tokens",
|
|
|
137 |
gr.Markdown(LICENSE)
|
138 |
|
139 |
if __name__ == "__main__":
|
140 |
+
demo.queue(max_size=20).launch()
|