|
import gradio as gr |
|
from transformers import pipeline |
|
|
|
|
|
def generate_text(prompt1, prompt2): |
|
|
|
model = "EleutherAI/gpt-neo-125M" |
|
summarization = pipeline("text-generation", model=model) |
|
|
|
prompt = "Explain " + prompt1 + " to a " + prompt + " grader below." |
|
|
|
result = summarization(prompt, max_length=32) |
|
return result[0]["generated_text"] |
|
|
|
|
|
inputs = [gr.inputs.Textbox(lines=5, label="Prompt 1:"), gr.inputs.Textbox(lines=5, label="Prompt 2:")] |
|
|
|
|
|
outputs = gr.outputs.Textbox(label="Generated Text") |
|
|
|
|
|
app = gr.Interface(generate_text, inputs, outputs, title="GPT-2 Text Generation Demo") |
|
|
|
|
|
app.launch() |