ViT5: Pretrained Text-to-Text Transformer for Vietnamese Language Generation
Paper • 2205.06457 • Published
ViT5 is a pretrained text-to-text transformer model designed specifically for Vietnamese language generation tasks. It is based on the T5 (Text-to-Text Transfer Transformer) architecture developed by Google, which has been adapted and fine-tuned for the Vietnamese language. ViT5 is capable of handling various natural language processing (NLP) tasks such as translation, summarization, question answering, and text generation, all within the Vietnamese linguistic context.
The Vietnamese QA dataset, created by Nguyen et al. (2020), is known as UIT-ViQuAD and was introduced in their research paper. This dataset has also been used in a shared task.
from transformers import pipeline
context="""
Trường Đại học Công nghệ Thông tin (ĐH CNTT), Đại học Quốc gia Thành phố Hồ Chí Minh (ĐHQG-HCM) là trường đại học công lập đào tạo về công nghệ thông tin và truyền thông (CNTT&TT) được thành lập theo quyết định số 134/2006/QĐ-TTg ngày 08/06/2006 của Thủ tướng Chính phủ. Là trường thành viên của ĐHQG-HCM, trường ĐH CNTT có nhiệm vụ đào tạo nguồn nhân lực công nghệ thông tin chất lượng cao, góp phần tích cực vào sự phát triển của nền công nghiệp công nghệ thông tin Việt Nam, đồng thời tiến hành nghiên cứu khoa học và chuyển giao công nghệ thông tin tiên tiến, đặc biệt là hướng vào các ứng dụng nhằm góp phần đẩy mạnh sự nghiệp công nghiệp hóa, hiện đại hóa đất nước.
Sau hơn 10 năm xây dựng và phát triển, hiện trường ĐH CNTT sở hữu cơ sở vật chất gồm khu học tập, nghiên cứu và làm việc được đầu tư xây dựng khang trang, hiện đại với tổng diện tích trên 14 hecta trong khuôn viên khu đô thị ĐHQG-HCM.
"""
question="""
Trường UIT mang trong mình nhiệm vụ gì?
"""
pipe = pipeline("question-answering", model="PhucDanh/vit5-fine-tuning-for-question-answering")
pipe(question=question, context=context)
from transformers import AutoTokenizer
from transformers import AutoModelForQuestionAnswering
import torch
context="""
Trường Đại học Công nghệ Thông tin (ĐH CNTT), Đại học Quốc gia Thành phố Hồ Chí Minh (ĐHQG-HCM) là trường đại học công lập đào tạo về công nghệ thông tin và truyền thông (CNTT&TT) được thành lập theo quyết định số 134/2006/QĐ-TTg ngày 08/06/2006 của Thủ tướng Chính phủ. Là trường thành viên của ĐHQG-HCM, trường ĐH CNTT có nhiệm vụ đào tạo nguồn nhân lực công nghệ thông tin chất lượng cao, góp phần tích cực vào sự phát triển của nền công nghiệp công nghệ thông tin Việt Nam, đồng thời tiến hành nghiên cứu khoa học và chuyển giao công nghệ thông tin tiên tiến, đặc biệt là hướng vào các ứng dụng nhằm góp phần đẩy mạnh sự nghiệp công nghiệp hóa, hiện đại hóa đất nước.
Sau hơn 10 năm xây dựng và phát triển, hiện trường ĐH CNTT sở hữu cơ sở vật chất gồm khu học tập, nghiên cứu và làm việc được đầu tư xây dựng khang trang, hiện đại với tổng diện tích trên 14 hecta trong khuôn viên khu đô thị ĐHQG-HCM.
"""
question="""
Trường UIT mang trong mình nhiệm vụ gì?
"""
tokenizer = AutoTokenizer.from_pretrained("PhucDanh/vit5-fine-tuning-for-question-answering")
try:
tokenizer.model_input_names.remove("token_type_ids")
except:
print("already removed!!!")
inputs = tokenizer(question, context, return_tensors="pt")
model = AutoModelForQuestionAnswering.from_pretrained("PhucDanh/vit5-fine-tuning-for-question-answering")
with torch.no_grad():
outputs = model(**inputs)
answer_start_index = outputs.start_logits.argmax()
answer_end_index = outputs.end_logits.argmax()
predict_answer_tokens = inputs.input_ids[0, answer_start_index : answer_end_index + 1]
print(tokenizer.decode(predict_answer_tokens))
Contact for API token authentication
import requests
API_URL = "https://api-inference.huggingface.co/models/PhucDanh/vit5-fine-tuning-for-question-answering"
headers = {"Authorization": "Bearer hf_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}
def query(payload):
response = requests.post(API_URL, headers=headers, json=payload)
return response.json()
output = query({
"inputs": {
"question": "What is my name?",
"context": "My name is Clara and I live in Berkeley."
},
})
@article{phan2022vit5,
title={Vit5: Pretrained text-to-text transformer for vietnamese language generation},
author={Phan, Long and Tran, Hieu and Nguyen, Hieu and Trinh, Trieu H},
journal={arXiv preprint arXiv:2205.06457},
year={2022}
}
@article{raffel2020exploring,
title={Exploring the limits of transfer learning with a unified text-to-text transformer},
author={Raffel, Colin and Shazeer, Noam and Roberts, Adam and Lee, Katherine and Narang, Sharan and Matena, Michael and Zhou, Yanqi and Li, Wei and Liu, Peter J},
journal={Journal of machine learning research},
volume={21},
number={140},
pages={1--67},
year={2020}
}
@article{Nguyen_2022,
title={VLSP 2021-ViMRC Challenge: Vietnamese Machine Reading Comprehension},
volume={38},
ISSN={2615-9260},
url={http://dx.doi.org/10.25073/2588-1086/vnucsce.340},
DOI={10.25073/2588-1086/vnucsce.340},
number={2},
journal={VNU Journal of Science: Computer Science and Communication Engineering},
publisher={Vietnam National University Journal of Science},
author={Nguyen, Kiet and Tran, Son Quoc and Nguyen, Luan Thanh and Huynh, Tin Van and Luu, Son Thanh and Nguyen, Ngan Luu-Thuy},
year={2022},
month=dec}