Spaces:
Running
Running
Initial commit
Browse files- README.md +0 -1
- app.py +48 -0
- requirements.txt +2 -0
README.md
CHANGED
@@ -10,4 +10,3 @@ pinned: false
|
|
10 |
license: apache-2.0
|
11 |
---
|
12 |
|
13 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
10 |
license: apache-2.0
|
11 |
---
|
12 |
|
|
app.py
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from prompt_generator import generate_prompt
|
3 |
+
|
4 |
+
tokenizers = [
|
5 |
+
"google/gemma-7b",
|
6 |
+
"meta-llama/Llama-2-7b",
|
7 |
+
"mistralai/Mistral-7B-v0.1",
|
8 |
+
"facebook/opt-2.7b",
|
9 |
+
"microsoft/phi-2",
|
10 |
+
"THUDM/chatglm3-6b",
|
11 |
+
"Qwen/Qwen1.5-7B-Chat",
|
12 |
+
"bigscience/bloom-560m",
|
13 |
+
"ise-uiuc/Magicoder-S-DS-6.7B",
|
14 |
+
"google/flan-t5-base",
|
15 |
+
"TinyLlama/TinyLlama-1.1B-Chat-v1.0",
|
16 |
+
"google-bert/bert-base-uncased",
|
17 |
+
]
|
18 |
+
|
19 |
+
|
20 |
+
def generate(model_id, num_tokens):
|
21 |
+
output_file = f"prompt_{num_tokens}.jsonl"
|
22 |
+
prompt = generate_prompt(model_id, int(num_tokens), silent=True, output_file=output_file)
|
23 |
+
return prompt, output_file
|
24 |
+
|
25 |
+
|
26 |
+
demo = gr.Interface(
|
27 |
+
fn=generate,
|
28 |
+
title="Prompt Generator",
|
29 |
+
description="Generate prompts with a given length for testing transformer models. "
|
30 |
+
"Prompt source: https://archive.org/stream/alicesadventures19033gut/19033.txt",
|
31 |
+
inputs=[
|
32 |
+
gr.Dropdown(label="Tokenizer", choices=tokenizers, allow_custom_value=True),
|
33 |
+
gr.Textbox(label="Number of Tokens"),
|
34 |
+
],
|
35 |
+
outputs=[gr.Textbox(label="prompt", show_copy_button=True), gr.File(label="Json file")],
|
36 |
+
examples=[
|
37 |
+
["mistralai/Mistral-7B-v0.1", 32],
|
38 |
+
["mistralai/Mistral-7B-v0.1", 64],
|
39 |
+
["mistralai/Mistral-7B-v0.1", 128],
|
40 |
+
["mistralai/Mistral-7B-v0.1", 512],
|
41 |
+
["mistralai/Mistral-7B-v0.1", 1024],
|
42 |
+
["mistralai/Mistral-7B-v0.1", 2048],
|
43 |
+
],
|
44 |
+
cache_examples=False,
|
45 |
+
allow_flagging=False,
|
46 |
+
)
|
47 |
+
|
48 |
+
demo.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
transformers
|
2 |
+
git+https://github.com/helena-intel/prompt-generator.git
|