File size: 686 Bytes
5f5bbb4
87a242d
 
 
92db42e
87a242d
 
7ffef6e
87a242d
 
 
8b69f55
 
87a242d
 
87c4f95
a2895c9
87a242d
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#level 4.5 text generator
import gradio as gr
from transformers import pipeline

generator = pipeline('text-generation', model='EleutherAI/gpt-neo-125M')

def generate(text):
    result = generator(text, max_length=100, num_return_sequences=1)
    return result[0]["generated_text"]

examples = [
    ["Zoe Kwan is a 20-year old singer and songwriter who has taken Hong Kong’s music scene by storm."],
    ["Zoe only recently began writing songs."],
]

demo = gr.Interface(fn=generate, inputs=gr.inputs.Textbox(lines=5, label="Input Text"), outputs=gr.outputs.Textbox(label="Generated Text"), 
                    title="Text Generator GPT-Neo-125M", examples=examples)

demo.launch()