Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -23,14 +23,13 @@ def generate(
|
|
| 23 |
temperature,
|
| 24 |
top_p,
|
| 25 |
top_k,
|
| 26 |
-
random_seed,
|
| 27 |
seed,
|
| 28 |
):
|
| 29 |
|
| 30 |
input_text = f"{system_prompt}, {prompt}"
|
| 31 |
input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to(device)
|
| 32 |
|
| 33 |
-
if
|
| 34 |
seed = random.randint(1, 100000)
|
| 35 |
torch.manual_seed(seed)
|
| 36 |
else:
|
|
@@ -64,9 +63,7 @@ top_p = gr.Slider(value=1, minimum=0, maximum=2, step=0.05, interactive=True, la
|
|
| 64 |
|
| 65 |
top_k = gr.Slider(value=1, minimum=1, maximum=100, step=1, interactive=True, label="Top K", info="Higher k means more diverse outputs by considering a range of tokens")
|
| 66 |
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
manual_seed = gr.Number(value=42, interactive=True, label="Manual Seed", info="A starting point to initiate the generation process", visible=lambda use_random_seed: not use_random_seed)
|
| 70 |
|
| 71 |
|
| 72 |
examples = [
|
|
@@ -78,18 +75,16 @@ examples = [
|
|
| 78 |
0.5,
|
| 79 |
1,
|
| 80 |
50,
|
| 81 |
-
False,
|
| 82 |
42,
|
| 83 |
]
|
| 84 |
]
|
| 85 |
|
| 86 |
gr.Interface(
|
| 87 |
fn=generate,
|
| 88 |
-
inputs=[prompt, system_prompt, max_new_tokens, repetition_penalty, temperature, top_p, top_k,
|
| 89 |
outputs=gr.Textbox(label="Better Prompt", interactive=True),
|
| 90 |
title="SuperPrompt-v1",
|
| 91 |
description="Make your prompts more detailed!<br>Model used: https://huggingface.co/roborovski/superprompt-v1<br>Hugging Face Space made by [Nick088](https://linktr.ee/Nick088)",
|
| 92 |
examples=examples,
|
| 93 |
-
live=True,
|
| 94 |
concurrency_limit=20,
|
| 95 |
).launch(show_api=False)
|
|
|
|
| 23 |
temperature,
|
| 24 |
top_p,
|
| 25 |
top_k,
|
|
|
|
| 26 |
seed,
|
| 27 |
):
|
| 28 |
|
| 29 |
input_text = f"{system_prompt}, {prompt}"
|
| 30 |
input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to(device)
|
| 31 |
|
| 32 |
+
if seed == 0:
|
| 33 |
seed = random.randint(1, 100000)
|
| 34 |
torch.manual_seed(seed)
|
| 35 |
else:
|
|
|
|
| 63 |
|
| 64 |
top_k = gr.Slider(value=1, minimum=1, maximum=100, step=1, interactive=True, label="Top K", info="Higher k means more diverse outputs by considering a range of tokens")
|
| 65 |
|
| 66 |
+
manual_seed = gr.Number(value=42, interactive=True, label="Seed", info="A starting point to initiate the generation process, put 0 for a random one")
|
|
|
|
|
|
|
| 67 |
|
| 68 |
|
| 69 |
examples = [
|
|
|
|
| 75 |
0.5,
|
| 76 |
1,
|
| 77 |
50,
|
|
|
|
| 78 |
42,
|
| 79 |
]
|
| 80 |
]
|
| 81 |
|
| 82 |
gr.Interface(
|
| 83 |
fn=generate,
|
| 84 |
+
inputs=[prompt, system_prompt, max_new_tokens, repetition_penalty, temperature, top_p, top_k, seed],
|
| 85 |
outputs=gr.Textbox(label="Better Prompt", interactive=True),
|
| 86 |
title="SuperPrompt-v1",
|
| 87 |
description="Make your prompts more detailed!<br>Model used: https://huggingface.co/roborovski/superprompt-v1<br>Hugging Face Space made by [Nick088](https://linktr.ee/Nick088)",
|
| 88 |
examples=examples,
|
|
|
|
| 89 |
concurrency_limit=20,
|
| 90 |
).launch(show_api=False)
|