text_generator / app.py
Wootang01's picture
Update app.py
2aa25db
raw
history blame
2.52 kB
#import libraries and dependencies
import gradio as gr
#from gradio.mix import Parallel
from transformers import pipeline
#instantiate variables as strings
#title="Text Generators"
#title1="Level 1 Text Generator"
#title2="Level 3 Text Generator"
#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."
#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."
#description3="This is the most advanced text generator that a few students were taught to code. Input text and the text generator generates an output text instance. You can resubmit to include that new text as input text."
#examples = [
# ["Zoe Kwan is a 20-year old singer and songwriter who has taken Hong Kong’s music scene by storm."],
# ["What is this life for?"],
# ["Write a short story."],
# ["Once upon a time, "]
#]
#instantiate variables as functions
pipe = pipeline("text-generation", model='EleutherAI/gpt-neo-2.7B', trust_remote_code=True)
#model1 = gr.Interface.load("huggingface/bigscience/bloom-560m")
#model2 = gr.Interface.load("huggingface/google/flan-t5-xl")
#model3 = gr.Interface.load("huggingface/bigscience/bloomz-7b1")
#model4 = gr.Interface.load("huggingface/EleutherAI/gpt-j-6B")
#togethercomputer/GPT-NeoXT-Chat-Base-20B
#decapoda-research/llama-7b-hf
#define functions
#def complete_with_gpt(text):
# # Use the last 50 characters of the text as context
# return text[:-50] + model4(text[-50:])
#with gr.Blocks() as demo:
# with gr.Row():
# textbox = gr.Textbox(placeholder=description3, lines=8)
# with gr.Column():
# btn = gr.Button("Submit")
# btn.click(complete_with_gpt, textbox, textbox)
#tab1 = gr.Interface.load("huggingface/gpt2", title=title1, description=description1, examples=examples)
#tab2 = gr.Parallel(model1, model2, model3, inputs=gr.Textbox(lines=5, label="Input explicit or implicit instructions"), title=title2, description=description2, examples=examples)
#tab3 = demo
#demo1 = gr.TabbedInterface([tab1, tab2, tab3], ["Level 1", "Level 3", "Level 5"], title=title)
#if __name__ == "__main__":
# demo1.launch(debug=True)
gr.Interface.from_pipeline(pipe).launch()