Text Style Transfer
Collection
Paraphrase a sentence into another sentence with a different style while preserve semantic.
•
4 items
•
Updated
•
1
Formal style
from transformers import MT5Tokenizer, AutoModelForSeq2SeqLM
tokenizer = MT5Tokenizer.from_pretrained("ntphiep/viT5_tst_coarse")
model = AutoModelForSeq2SeqLM.from_pretrained("ntphiep/viT5_tst_coarse")
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 = "Bọn công nhân thì được trả bằng thóc, một thằng bình thường kiếm được có 5 bao rưỡi thóc một tháng, còn thằng quản đốc thì được tận 7 bao rưỡi."
result = predict(text)
print("👉 Output:", result)
👉 Output: Công nhân được trả lương bằng thóc, một người bình thường thu được 5 bao rưỡi thóc mỗi tháng, trong khi người quản đốc được hưởng 7 bao
Base model
VietAI/vit5-base