Text Style Transfer
Collection
Paraphrase a sentence into another sentence with a different style while preserve semantic.
•
4 items
•
Updated
•
1
Chinese style (kiếm hiệp cổ trang, kiểu vậy :v)
from transformers import MT5Tokenizer, AutoModelForSeq2SeqLM
tokenizer = MT5Tokenizer.from_pretrained("ntphiep/viT5_tst_chinese")
model = AutoModelForSeq2SeqLM.from_pretrained("ntphiep/viT5_tst_chinese")
def predict(text):
inputs = tokenizer(text, return_tensors="pt", padding='longest', max_length=64)
input_ids = inputs.input_ids
attention_mask = inputs.attention_mask
output = model.generate(input_ids, attention_mask=attention_mask, max_length=64)
return tokenizer.decode(output[0], skip_special_tokens=True)
text = "Hội đồng Hy Lạp tại Eo Corinth , với ngoại lệ Sparta , bầu ông lên như là Tổng tư lệnh chống lại quân Ba Tư , mà trước đây chức danh này được phong tặng cho cha ông ."
result = predict(text)
print("👉 Output:", result)
👉 Output: Chư vị Hy Lạp tại địa phận Eo Corinth, ngoại trừ Sparta, đồng lòng suy tôn ngài lên vị trí Thống soái, dẫn dắt quân binh chinh phạt Ba Tư, tước vị cao quý này xưa kia thuộc về lệnh tôn.
Base model
VietAI/vit5-base