import gradio as gr from transformers import pipeline def convert(prompt): model = pipeline('text-generation', model='bigscience/bloom-1b1') result = model(prompt, repetition_penalty = 2.0, max_length=200, num_beams = 2, num_beam_groups = 2, top_k=1, temperature=0.9, diversity_penalty = 0.9) return result[0]['generated_text'] with gr.Blocks() as bls: gr.Markdown("Here is a Text Generation app") with gr.Row(): inp = gr.Textbox(label="Type your prompt here and click Run", placeholder='Example: The main cloud services of AWS are:') out = gr.Textbox(label="Output") btn = gr.Button("Run") btn.click(fn=convert, inputs=inp, outputs=out) bls.launch()