Theskull312 commited on
Commit
30a4d26
1 Parent(s): 1d439dd

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +31 -0
README.md ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## Model description
2
+ This model is a sequence-to-sequence question generator which takes an answer and context as an input, and generates a question as an output. It is based on a pretrained mt5-base model.
3
+
4
+ ## Training data
5
+ The model was fine-tuned on [XQuAD](https://github.com/deepmind/xquad)
6
+
7
+ ## Example usage
8
+ ```python
9
+ from transformers import MT5ForConditionalGeneration, AutoTokenizer
10
+ import torch
11
+
12
+ model = MT5ForConditionalGeneration.from_pretrained("noah-ai/mt5-base-question-generation-vi")
13
+ tokenizer = AutoTokenizer.from_pretrained("noah-ai/mt5-base-question-generation-vi")
14
+
15
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
16
+ model = model.to(device)
17
+
18
+ # Content used to create a set of questions
19
+ context = '''Thành phố Hồ Chí Minh (còn gọi là Sài Gòn) tên gọi cũ trước 1975 là Sài Gòn hay Sài Gòn-Gia Định là thành phố lớn nhất ở Việt Nam về dân số và quy mô đô thị hóa. Đây còn là trung tâm kinh tế, chính trị, văn hóa và giáo dục tại Việt Nam. Thành phố Hồ Chí Minh là thành phố trực thuộc trung ương thuộc loại đô thị đặc biệt của Việt Nam cùng với thủ đô Hà Nội.Nằm trong vùng chuyển tiếp giữa Đông Nam Bộ và Tây Nam Bộ, thành phố này hiện có 16 quận, 1 thành phố và 5 huyện, tổng diện tích 2.061 km². Theo kết quả điều tra dân số chính thức vào thời điểm ngày một tháng 4 năm 2009 thì dân số thành phố là 7.162.864 người (chiếm 8,34% dân số Việt Nam), mật độ dân số trung bình 3.419 người/km². Đến năm 2019, dân số thành phố tăng lên 8.993.082 người và cũng là nơi có mật độ dân số cao nhất Việt Nam. Tuy nhiên, nếu tính những người cư trú không đăng ký hộ khẩu thì dân số thực tế của thành phố này năm 2018 là gần 14 triệu người.'''
20
+
21
+ encoding = tokenizer.encode_plus(context, return_tensors="pt")
22
+
23
+ input_ids, attention_masks = encoding["input_ids"].to(device), encoding["attention_mask"].to(device)
24
+
25
+ output = model.generate(input_ids=input_ids, attention_mask=attention_masks, max_length=256)
26
+
27
+ question = tokenizer.decode(output[0], skip_special_tokens=True,clean_up_tokenization_spaces=True)
28
+
29
+ question
30
+ #question: Thành phố hồ chí minh có bao nhiêu quận?
31
+ ```