Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,14 +1,44 @@
|
|
1 |
#import libraries and dependencies
|
2 |
import gradio as gr
|
3 |
-
from gradio.mix import Parallel
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
#instantiate variables as functions
|
6 |
model1 = gr.Interface.load("huggingface/EleutherAI/gpt-j-6B")
|
7 |
model2 = gr.Interface.load("huggingface/google/flan-t5-xl")
|
8 |
-
|
9 |
-
model4 = gr.Interface.load("huggingface/
|
10 |
-
|
11 |
-
|
12 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
-
|
|
|
|
1 |
#import libraries and dependencies
|
2 |
import gradio as gr
|
3 |
+
from gradio.mix import Parallel
|
4 |
+
|
5 |
+
#instantiate variables as strings
|
6 |
+
title="Text Generators"
|
7 |
+
description="Select a text generator from the tabs below."
|
8 |
+
description1="This is the basic text generator all students were taught to code using an older, smaller language model. Input text, submit, and the text generator will generate one output text instance."
|
9 |
+
description2="This is a more advanced text generator that many students were taught to code. Input text and the text generator generates three output text instances from three language models. Importantly, two of these language models were designed to process explicit instructions."
|
10 |
+
examples = [
|
11 |
+
["Zoe Kwan is a 20-year old singer and songwriter who has taken Hong Kong’s music scene by storm."],
|
12 |
+
["What is this life for?"],
|
13 |
+
["Write a story that begins, 'Once upon a time, '"]
|
14 |
+
["What is the best way to start a short story?"]
|
15 |
+
]
|
16 |
|
17 |
#instantiate variables as functions
|
18 |
model1 = gr.Interface.load("huggingface/EleutherAI/gpt-j-6B")
|
19 |
model2 = gr.Interface.load("huggingface/google/flan-t5-xl")
|
20 |
+
model3 = gr.Interface.load("huggingface/bigscience/bloomz-560m")
|
21 |
+
model4 = gr.Interface.load("huggingface/EleutherAI/gpt-j-6B")
|
22 |
+
|
23 |
+
#decapoda-research/llama-7b-hf
|
24 |
+
#define functions
|
25 |
+
def complete_with_gpt(text):
|
26 |
+
# Use the last 50 characters of the text as context
|
27 |
+
return text[:-50] + model4(text[-50:])
|
28 |
+
|
29 |
+
with gr.Blocks() as demo:
|
30 |
+
with gr.Row():
|
31 |
+
textbox = gr.Textbox(placeholder="Type here and press enter...", lines=8)
|
32 |
+
with gr.Column():
|
33 |
+
btn = gr.Button("Generate")
|
34 |
+
|
35 |
+
btn.click(complete_with_gpt, textbox, textbox)
|
36 |
+
|
37 |
+
tab1 = gr.Interface.load("huggingface/gpt2", description=description1)
|
38 |
+
tab2 = gr.Paralle(model1, model2, model3, inputs=gr.Textbox(lines=5, label="Input explicit or implicit instructions"), description=description2, examples=examples)
|
39 |
+
tab3 = demo.launch()
|
40 |
+
|
41 |
+
demo1 = gr.TabbedInterface([tab1, tab2, tab3], ["Level 1", "Level 3", "Level 5"], title=title, description=description)
|
42 |
|
43 |
+
if __name__ == "__main__":
|
44 |
+
demo1.launch(debug=True)
|