Views
No views yet
Formal style1from transformers import MT5Tokenizer, AutoModelForSeq2SeqLM
2
3tokenizer = MT5Tokenizer.from_pretrained("ntphiep/viT5_tst_coarse")
4model = AutoModelForSeq2SeqLM.from_pretrained("ntphiep/viT5_tst_coarse")
5
6def predict(text):
7 inputs = tokenizer(text, return_tensors="pt", padding='longest', max_length=64)
8 input_ids = inputs.input_ids
9 attention_mask = inputs.attention_mask
10 output = model.generate(input_ids, attention_mask=attention_mask, max_length=64)
11 return tokenizer.decode(output[0], skip_special_tokens=True)
12
13
14text = "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."
15result = predict(text)
16print("👉 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