Spaces:
Sleeping
Sleeping
File size: 854 Bytes
e107cb6 1c57da9 e107cb6 1c57da9 e107cb6 d4d7a43 e107cb6 1c57da9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
import gradio as gr
from transformers import T5Tokenizer, MT5ForConditionalGeneration
model_name = "google/mt5-base"
tokenizer = T5Tokenizer.from_pretrained(model_name, use_fast=False)
model = MT5ForConditionalGeneration.from_pretrained(model_name)
def humanize(text):
prompt = "paraphrase: " + text
inputs = tokenizer(prompt, return_tensors="pt", truncation=True, padding=True)
outputs = model.generate(**inputs, max_length=512, num_beams=4)
return tokenizer.decode(outputs[0], skip_special_tokens=True)
gr.Interface(
fn=humanize,
inputs=gr.Textbox(lines=10, label="Vstupný text (česky alebo slovensky)"),
outputs=gr.Textbox(label="Prepísaný text"),
title="Humanizer CZ/SK (MT5)",
description="Prepíše český alebo slovenský text do prirodzenejšej formy pomocou multijazyčného modelu MT5."
).launch()
|