Update app.py
Browse files
app.py
CHANGED
@@ -8,11 +8,7 @@ import torch
|
|
8 |
from transformers import AutoModelForCausalLM, GemmaTokenizerFast, TextIteratorStreamer
|
9 |
|
10 |
DESCRIPTION = """\
|
11 |
-
#
|
12 |
-
Gemma 2 is Google's latest iteration of open LLMs.
|
13 |
-
This is a demo of [`google/gemma-2-2b-it`](https://huggingface.co/google/gemma-2-2b-it), fine-tuned for instruction following.
|
14 |
-
For more details, please check [our post](https://huggingface.co/blog/gemma2).
|
15 |
-
👉 Looking for a larger and more powerful version? Try the 27B version in [HuggingChat](https://huggingface.co/chat/models/google/gemma-2-27b-it) and the 9B version in [this Space](https://huggingface.co/spaces/huggingface-projects/gemma-2-9b-it).
|
16 |
"""
|
17 |
|
18 |
MAX_MAX_NEW_TOKENS = 2048
|
@@ -78,43 +74,6 @@ with gr.Blocks(css="style.css", fill_height=True) as demo:
|
|
78 |
# Create the chat interface
|
79 |
chat_interface = gr.ChatInterface(
|
80 |
fn=generate,
|
81 |
-
additional_inputs=[
|
82 |
-
gr.Slider(
|
83 |
-
label="Max new tokens",
|
84 |
-
minimum=1,
|
85 |
-
maximum=MAX_MAX_NEW_TOKENS,
|
86 |
-
step=1,
|
87 |
-
value=DEFAULT_MAX_NEW_TOKENS,
|
88 |
-
),
|
89 |
-
gr.Slider(
|
90 |
-
label="Temperature",
|
91 |
-
minimum=0.1,
|
92 |
-
maximum=4.0,
|
93 |
-
step=0.1,
|
94 |
-
value=0.6,
|
95 |
-
),
|
96 |
-
gr.Slider(
|
97 |
-
label="Top-p (nucleus sampling)",
|
98 |
-
minimum=0.05,
|
99 |
-
maximum=1.0,
|
100 |
-
step=0.05,
|
101 |
-
value=0.9,
|
102 |
-
),
|
103 |
-
gr.Slider(
|
104 |
-
label="Top-k",
|
105 |
-
minimum=1,
|
106 |
-
maximum=1000,
|
107 |
-
step=1,
|
108 |
-
value=50,
|
109 |
-
),
|
110 |
-
gr.Slider(
|
111 |
-
label="Repetition penalty",
|
112 |
-
minimum=1.0,
|
113 |
-
maximum=2.0,
|
114 |
-
step=0.05,
|
115 |
-
value=1.2,
|
116 |
-
),
|
117 |
-
],
|
118 |
examples=[
|
119 |
["Hello there! How are you doing?"],
|
120 |
["Can you explain briefly to me what is the Python programming language?"],
|
@@ -126,12 +85,6 @@ with gr.Blocks(css="style.css", fill_height=True) as demo:
|
|
126 |
type="messages",
|
127 |
)
|
128 |
|
129 |
-
# Create the stop button inside the Blocks context
|
130 |
-
stop_button = gr.Button("Stop", elem_id="stop-btn")
|
131 |
-
stop_button.click(fn=stop_generation, inputs=[], outputs=[])
|
132 |
-
|
133 |
-
gr.DuplicateButton(value="Duplicate Space for private use", elem_id="duplicate-button")
|
134 |
-
chat_interface.render()
|
135 |
|
136 |
if __name__ == "__main__":
|
137 |
demo.queue(max_size=20).launch(share=True)
|
|
|
8 |
from transformers import AutoModelForCausalLM, GemmaTokenizerFast, TextIteratorStreamer
|
9 |
|
10 |
DESCRIPTION = """\
|
11 |
+
# Monlam LLM
|
|
|
|
|
|
|
|
|
12 |
"""
|
13 |
|
14 |
MAX_MAX_NEW_TOKENS = 2048
|
|
|
74 |
# Create the chat interface
|
75 |
chat_interface = gr.ChatInterface(
|
76 |
fn=generate,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
examples=[
|
78 |
["Hello there! How are you doing?"],
|
79 |
["Can you explain briefly to me what is the Python programming language?"],
|
|
|
85 |
type="messages",
|
86 |
)
|
87 |
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
|
89 |
if __name__ == "__main__":
|
90 |
demo.queue(max_size=20).launch(share=True)
|