helenai commited on
Commit
23f6a23
1 Parent(s): 19b3783

Add prefix and source file options

Browse files
Files changed (3) hide show
  1. README.md +1 -1
  2. app.py +22 -6
  3. 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 prompt_generator import generate_prompt
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), silent=True, 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 length for testing transformer models. "
29
  "Prompt source: https://archive.org/stream/alicesadventures19033gut/19033.txt",
30
  inputs=[
31
- gr.Dropdown(label="Tokenizer", choices=tokenizers, allow_custom_value=True),
32
- gr.Textbox(label="Number of Tokens"),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
- git+https://github.com/helena-intel/prompt-generator.git
 
 
1
  transformers
2
+ sentencepiece
3
+ git+https://github.com/helena-intel/test-prompt-generator.git