Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import os
|
| 3 |
+
|
| 4 |
+
demo = gr.Blocks()
|
| 5 |
+
|
| 6 |
+
#'spaces/Gradio-Blocks/Codex_OpenAI' did not work due to paramerts error
|
| 7 |
+
#'huggingface/facebook/incoder-6B' inference error
|
| 8 |
+
#huggingface/Salesforce/codegen-2B-mono 500 Error
|
| 9 |
+
|
| 10 |
+
name_list = [
|
| 11 |
+
'gpt2',
|
| 12 |
+
'lm-human-preference-details/train_policy_accelerate_tf_adam_gpt2_xl_grad_accu__sentiment_offline_5k.json__seed2',
|
| 13 |
+
'lm-human-preference-details/train_policy_accelerate_tf_adam_gpt2_xl_grad_accu__descriptiveness_offline_5k.json__seed1',
|
| 14 |
+
]
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
interfaces = [gr.load(f"models/{name}") for name in name_list]
|
| 18 |
+
def generate_code_os(text):
|
| 19 |
+
return [interface(text) for interface in interfaces]
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
def set_example(example: list) -> dict:
|
| 23 |
+
return gr.Textbox.update(value=example[0])
|
| 24 |
+
|
| 25 |
+
with gr.Blocks() as demo:
|
| 26 |
+
gr.Markdown("Compare RLHF Stylistic Models")
|
| 27 |
+
with gr.Box():
|
| 28 |
+
with gr.Row():
|
| 29 |
+
with gr.Column():
|
| 30 |
+
input_text = gr.Textbox(label = "Write your prompt here", lines=4)
|
| 31 |
+
with gr.Row():
|
| 32 |
+
btn = gr.Button("Generate")
|
| 33 |
+
|
| 34 |
+
# example_text = gr.Dataset(components=[input_text], samples=examples)
|
| 35 |
+
# example_text.click(fn=set_example,
|
| 36 |
+
# inputs = example_text,
|
| 37 |
+
# outputs= example_text)
|
| 38 |
+
gr.Examples(
|
| 39 |
+
[["The young maid said"], ["The table has arrived at the house"]],
|
| 40 |
+
[input_text],
|
| 41 |
+
)
|
| 42 |
+
with gr.Column():
|
| 43 |
+
with gr.Column():
|
| 44 |
+
btn.click(generate_code_os, inputs = input_text, outputs = [gr.Textbox(label=name_list[_], lines=4) for _ in range(len(name_list))])
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
demo.launch(enable_queue=True,debug=True)
|