Skip to content

Instantly share code, notes, and snippets.

@Norod
Created July 5, 2022 10:51
Show Gist options
  • Select an option

  • Save Norod/7b8fd37b69e5098f4b033d95acc7e103 to your computer and use it in GitHub Desktop.

Select an option

Save Norod/7b8fd37b69e5098f4b033d95acc7e103 to your computer and use it in GitHub Desktop.
hebrew-gpt_neo-small minimal gradio demo using gradio and transformers pipeline
import gradio as gr
from transformers import pipeline
title = "Hebrew GPT-Neo Demo"
description = ""
article = "<p></p>"
examples = [
['צחוקים ושיגועים'],
["למנשה פומפרניקל יש"],
["פעם אחת לפני שנים רבות"]
]
model_id = "Norod78/hebrew-gpt_neo-small"
text_generator = pipeline('text-generation', model=model_id, tokenizer=model_id)
max_length = 256
top_k = 40
top_p = 0.92
def text_generation(input_text):
generated_text = text_generator(input_text,
max_length=max_length,
top_k=top_k,
top_p=top_p,
do_sample=True,
repetition_penalty=25.0,
num_return_sequences=1)
return generated_text[0]["generated_text"]
gr.Interface(
text_generation,
[gr.inputs.Textbox(lines=2, label="Enter input text")],
[gr.outputs.Textbox(type="auto", label="Text Generated")],
title=title,
description=description,
examples=examples,
theme="default"
).launch()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment