Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -48,6 +48,7 @@ def evaluate(
|
|
48 |
alpha_presence = presencePenalty,
|
49 |
token_ban = [], # ban the generation of some tokens
|
50 |
token_stop = [0]) # stop generation whenever you see any token here
|
|
|
51 |
all_tokens = []
|
52 |
out_last = 0
|
53 |
out_str = ''
|
@@ -84,12 +85,14 @@ def evaluate(
|
|
84 |
yield out_str.strip()
|
85 |
|
86 |
examples = [
|
87 |
-
[generate_prompt("Tell me about ravens."),
|
88 |
-
[generate_prompt("Écrivez un programme Python pour miner 1 Bitcoin."),
|
89 |
-
[generate_prompt("東京で訪れるべき素晴らしい場所とその紹介をいくつか挙げてください。"),
|
90 |
-
[generate_prompt("Write a story using the following information", "A man named Alex chops a tree down"),
|
91 |
-
["Here is a list of adjectives that describe a person as brave:",
|
92 |
-
[
|
|
|
|
|
93 |
]
|
94 |
|
95 |
##########################################################################
|
@@ -101,7 +104,7 @@ with gr.Blocks(title=title) as demo:
|
|
101 |
with gr.Row():
|
102 |
with gr.Column():
|
103 |
prompt = gr.Textbox(lines=2, label="Prompt", value=generate_prompt("Tell me about ravens."))
|
104 |
-
token_count = gr.Slider(10,
|
105 |
temperature = gr.Slider(0.2, 2.0, label="Temperature", step=0.1, value=1.0)
|
106 |
top_p = gr.Slider(0.0, 1.0, label="Top P", step=0.05, value=0.5)
|
107 |
presence_penalty = gr.Slider(0.0, 1.0, label="Presence Penalty", step=0.1, value=0.4)
|
@@ -110,7 +113,7 @@ with gr.Blocks(title=title) as demo:
|
|
110 |
with gr.Row():
|
111 |
submit = gr.Button("Submit", variant="primary")
|
112 |
clear = gr.Button("Clear", variant="secondary")
|
113 |
-
output = gr.Textbox(label="Output", lines=
|
114 |
data = gr.Dataset(components=[prompt, token_count, temperature, top_p, presence_penalty, count_penalty], samples=examples, label="Example Instructions", headers=["Prompt", "Max Tokens", "Temperature", "Top P", "Presence Penalty", "Count Penalty"])
|
115 |
submit.click(evaluate, [prompt, token_count, temperature, top_p, presence_penalty, count_penalty], [output])
|
116 |
clear.click(lambda: None, [], [output])
|
|
|
48 |
alpha_presence = presencePenalty,
|
49 |
token_ban = [], # ban the generation of some tokens
|
50 |
token_stop = [0]) # stop generation whenever you see any token here
|
51 |
+
ctx = ctx.strip()
|
52 |
all_tokens = []
|
53 |
out_last = 0
|
54 |
out_str = ''
|
|
|
85 |
yield out_str.strip()
|
86 |
|
87 |
examples = [
|
88 |
+
[generate_prompt("Tell me about ravens."), 333, 1, 0.5, 0.4, 0.4],
|
89 |
+
[generate_prompt("Écrivez un programme Python pour miner 1 Bitcoin."), 333, 1, 0.5, 0.4, 0.4],
|
90 |
+
[generate_prompt("東京で訪れるべき素晴らしい場所とその紹介をいくつか挙げてください。"), 333, 1, 0.5, 0.4, 0.4],
|
91 |
+
[generate_prompt("Write a story using the following information", "A man named Alex chops a tree down"), 333, 1, 0.5, 0.4, 0.4],
|
92 |
+
["Here is a list of adjectives that describe a person as brave:", 333, 1, 0.5, 0.4, 0.4],
|
93 |
+
["Here is my proposal to kill all mosquitos.", 333, 1, 0.5, 0.4, 0.4],
|
94 |
+
[generate_prompt("写一篇关于水利工程的流体力学模型的论文,需要详细全面。"), 333, 1, 0.5, 0.4, 0.4],
|
95 |
+
[generate_prompt("You have $100, and your goal is to turn that into as much money as possible with AI and Machine Learning. Please respond with detailed plan."), 333, 1, 0.5, 0.4, 0.4],
|
96 |
]
|
97 |
|
98 |
##########################################################################
|
|
|
104 |
with gr.Row():
|
105 |
with gr.Column():
|
106 |
prompt = gr.Textbox(lines=2, label="Prompt", value=generate_prompt("Tell me about ravens."))
|
107 |
+
token_count = gr.Slider(10, 333, label="Max Tokens", step=10, value=333)
|
108 |
temperature = gr.Slider(0.2, 2.0, label="Temperature", step=0.1, value=1.0)
|
109 |
top_p = gr.Slider(0.0, 1.0, label="Top P", step=0.05, value=0.5)
|
110 |
presence_penalty = gr.Slider(0.0, 1.0, label="Presence Penalty", step=0.1, value=0.4)
|
|
|
113 |
with gr.Row():
|
114 |
submit = gr.Button("Submit", variant="primary")
|
115 |
clear = gr.Button("Clear", variant="secondary")
|
116 |
+
output = gr.Textbox(label="Output", lines=5)
|
117 |
data = gr.Dataset(components=[prompt, token_count, temperature, top_p, presence_penalty, count_penalty], samples=examples, label="Example Instructions", headers=["Prompt", "Max Tokens", "Temperature", "Top P", "Presence Penalty", "Count Penalty"])
|
118 |
submit.click(evaluate, [prompt, token_count, temperature, top_p, presence_penalty, count_penalty], [output])
|
119 |
clear.click(lambda: None, [], [output])
|