Spaces:
Runtime error
Runtime error
File size: 1,375 Bytes
0fd7b28 e85570c 0fd7b28 30016b4 e85570c 0fd7b28 e85570c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
import gradio as gr
from transformers import AutoTokenizer, TFGPT2LMHeadModel
review_model = TFGPT2LMHeadModel.from_pretrained("kmkarakaya/turkishReviews-ds")
review_tokenizer = AutoTokenizer.from_pretrained("kmkarakaya/turkishReviews-ds")
def generate_review(prompt):
input_ids = review_tokenizer.encode(prompt, return_tensors='tf')
context_length = 40
output = review_model.generate(
input_ids,
do_sample=True,
max_length=context_length,
top_k=10,
no_repeat_ngram_size=2,
early_stopping=True
)
return(review_tokenizer.decode(output[0], skip_special_tokens=True))
title="Review Generator"
description= "Generate a review in Turkish by providing a prompt. Generation takes 15 seconds on average."
article = "<p style='text-align: center'><a href='https://youtube.com/playlist?list=PLQflnv_s49v9d9w-L0S8XUXXdNks7vPBL' target='_blank'>Full Code is here: </a></p>"
examples=["Bir hafta önce aldığım cep telefonu",
"Tatil için rezervasyon yaptırdım.",
"Henüz alalı bir"]
demo = gr.Interface(fn=generate_review,
inputs="text",
outputs="text",
examples=examples,
title=title,
description= description,
article = article
)
demo.launch() |