Explainer / app.py
sr5434's picture
Create app.py
f3b4b05
raw
history blame
867 Bytes
import gradio as gr
from transformers import pipeline
# Define the function that will process the text
def generate_text(prompt1, prompt2):
# Define the GPT-2 model and the processing pipeline
model = "EleutherAI/gpt-neo-125M"
summarization = pipeline("text-generation", model=model)
# Concatenate the two prompts
prompt = "Explain " + prompt1 + " to a " + prompt + " grader below."
# Generate the text
result = summarization(prompt, max_length=32)
return result[0]["generated_text"]
# Create the input interface
inputs = [gr.inputs.Textbox(lines=5, label="Prompt 1:"), gr.inputs.Textbox(lines=5, label="Prompt 2:")]
# Create the output interface
outputs = gr.outputs.Textbox(label="Generated Text")
# Create the app
app = gr.Interface(generate_text, inputs, outputs, title="GPT-2 Text Generation Demo")
# Run the app
app.launch()