Commit ·
fb8b8c3
1
Parent(s): 932a249
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,8 +7,7 @@ import spaces
|
|
| 7 |
import torch
|
| 8 |
from transformers import AutoModelForCausalLM, AutoTokenizer, TextIteratorStreamer
|
| 9 |
|
| 10 |
-
|
| 11 |
-
HF_TOKEN = "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"
|
| 12 |
|
| 13 |
MAX_MAX_NEW_TOKENS = 2048
|
| 14 |
DEFAULT_MAX_NEW_TOKENS = 1024
|
|
@@ -31,7 +30,6 @@ if torch.cuda.is_available():
|
|
| 31 |
tokenizer = AutoTokenizer.from_pretrained(model_id, use_auth_token=HF_TOKEN)
|
| 32 |
tokenizer.use_default_system_prompt = False
|
| 33 |
|
| 34 |
-
|
| 35 |
@spaces.GPU
|
| 36 |
def generate(
|
| 37 |
message: str,
|
|
@@ -79,13 +77,59 @@ def generate(
|
|
| 79 |
|
| 80 |
chat_interface = gr.ChatInterface(
|
| 81 |
fn=generate,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
stop_btn=None,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
)
|
| 84 |
|
| 85 |
with gr.Blocks(css="style.css") as demo:
|
| 86 |
gr.Markdown(DESCRIPTION)
|
| 87 |
gr.DuplicateButton(value="Duplicate Space for private use", elem_id="duplicate-button")
|
| 88 |
chat_interface.render()
|
|
|
|
| 89 |
|
| 90 |
if __name__ == "__main__":
|
| 91 |
demo.queue(max_size=20).launch()
|
|
|
|
| 7 |
import torch
|
| 8 |
from transformers import AutoModelForCausalLM, AutoTokenizer, TextIteratorStreamer
|
| 9 |
|
| 10 |
+
HF_TOKEN = "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" ##Llama Write Token
|
|
|
|
| 11 |
|
| 12 |
MAX_MAX_NEW_TOKENS = 2048
|
| 13 |
DEFAULT_MAX_NEW_TOKENS = 1024
|
|
|
|
| 30 |
tokenizer = AutoTokenizer.from_pretrained(model_id, use_auth_token=HF_TOKEN)
|
| 31 |
tokenizer.use_default_system_prompt = False
|
| 32 |
|
|
|
|
| 33 |
@spaces.GPU
|
| 34 |
def generate(
|
| 35 |
message: str,
|
|
|
|
| 77 |
|
| 78 |
chat_interface = gr.ChatInterface(
|
| 79 |
fn=generate,
|
| 80 |
+
additional_inputs=[
|
| 81 |
+
gr.Textbox(label="System prompt", lines=6),
|
| 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 |
stop_btn=None,
|
| 119 |
+
examples=[
|
| 120 |
+
["Hello there! How are you doing?"],
|
| 121 |
+
["Can you explain briefly to me what is the Python programming language?"],
|
| 122 |
+
["Explain the plot of Cinderella in a sentence."],
|
| 123 |
+
["How many hours does it take a man to eat a Helicopter?"],
|
| 124 |
+
["Write a 100-word article on 'Benefits of Open-Source in AI research'"],
|
| 125 |
+
],
|
| 126 |
)
|
| 127 |
|
| 128 |
with gr.Blocks(css="style.css") as demo:
|
| 129 |
gr.Markdown(DESCRIPTION)
|
| 130 |
gr.DuplicateButton(value="Duplicate Space for private use", elem_id="duplicate-button")
|
| 131 |
chat_interface.render()
|
| 132 |
+
gr.Markdown(LICENSE)
|
| 133 |
|
| 134 |
if __name__ == "__main__":
|
| 135 |
demo.queue(max_size=20).launch()
|