Spaces:
Sleeping
Sleeping
Add prefix and source file options
Browse files- README.md +1 -1
- app.py +22 -6
- requirements.txt +2 -1
README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
---
|
2 |
-
title: Prompt Generator
|
3 |
emoji: ⚡
|
4 |
colorFrom: blue
|
5 |
colorTo: green
|
|
|
1 |
---
|
2 |
+
title: Test Prompt Generator
|
3 |
emoji: ⚡
|
4 |
colorFrom: blue
|
5 |
colorTo: green
|
app.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
import gradio as gr
|
2 |
-
from
|
3 |
|
4 |
tokenizers = [
|
5 |
"google/gemma-7b",
|
@@ -16,20 +16,36 @@ tokenizers = [
|
|
16 |
]
|
17 |
|
18 |
|
19 |
-
def generate(model_id, num_tokens):
|
20 |
output_file = f"prompt_{num_tokens}.jsonl"
|
21 |
-
prompt = generate_prompt(model_id, int(num_tokens),
|
22 |
return prompt, output_file
|
23 |
|
24 |
|
25 |
demo = gr.Interface(
|
26 |
fn=generate,
|
27 |
title="Test Prompt Generator",
|
28 |
-
description="Generate prompts with a given
|
29 |
"Prompt source: https://archive.org/stream/alicesadventures19033gut/19033.txt",
|
30 |
inputs=[
|
31 |
-
gr.Dropdown(
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
],
|
34 |
outputs=[gr.Textbox(label="prompt", show_copy_button=True), gr.File(label="Json file")],
|
35 |
examples=[
|
|
|
1 |
import gradio as gr
|
2 |
+
from test_prompt_generator import generate_prompt
|
3 |
|
4 |
tokenizers = [
|
5 |
"google/gemma-7b",
|
|
|
16 |
]
|
17 |
|
18 |
|
19 |
+
def generate(model_id, num_tokens, prefix=None, source_text=None):
|
20 |
output_file = f"prompt_{num_tokens}.jsonl"
|
21 |
+
prompt = generate_prompt(model_id, int(num_tokens), prefix=prefix, source_text=source_text, output_file=output_file)
|
22 |
return prompt, output_file
|
23 |
|
24 |
|
25 |
demo = gr.Interface(
|
26 |
fn=generate,
|
27 |
title="Test Prompt Generator",
|
28 |
+
description="Generate prompts with a given number of tokens for testing transformer models. "
|
29 |
"Prompt source: https://archive.org/stream/alicesadventures19033gut/19033.txt",
|
30 |
inputs=[
|
31 |
+
gr.Dropdown(
|
32 |
+
label="Tokenizer",
|
33 |
+
choices=tokenizers,
|
34 |
+
value="mistralai/Mistral-7B-v0.1",
|
35 |
+
allow_custom_value=True,
|
36 |
+
info="Select a tokenizer from this list or paste a model_id from a model on the Hugging Face Hub",
|
37 |
+
),
|
38 |
+
gr.Number(
|
39 |
+
label="Number of Tokens", minimum=4, maximum=2048, value=32, info="Enter a number between 4 and 2048."
|
40 |
+
),
|
41 |
+
gr.Textbox(
|
42 |
+
label="Prefix (optional)",
|
43 |
+
info="If given, the start of the prompt will be this prefix. Example: 'Summarize the following text:'",
|
44 |
+
),
|
45 |
+
gr.Textbox(
|
46 |
+
label="Source text (optional)",
|
47 |
+
info="By default, prompts will be generated from Alice in Wonderland. Enter text here to use that instead.",
|
48 |
+
),
|
49 |
],
|
50 |
outputs=[gr.Textbox(label="prompt", show_copy_button=True), gr.File(label="Json file")],
|
51 |
examples=[
|
requirements.txt
CHANGED
@@ -1,2 +1,3 @@
|
|
1 |
transformers
|
2 |
-
|
|
|
|
1 |
transformers
|
2 |
+
sentencepiece
|
3 |
+
git+https://github.com/helena-intel/test-prompt-generator.git
|