DANGDOCAO commited on
Commit
1fde615
·
verified ·
1 Parent(s): 76e3516

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +262 -0
README.md ADDED
@@ -0,0 +1,262 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ dataset_name: HVU_GQ
3
+ language:
4
+ - vi
5
+ license: mit
6
+ task_categories:
7
+ - text-generation
8
+ - question-generation
9
+ task_ids:
10
+ - question-answering
11
+ - text-generation
12
+ pretty_name: HVU Question Generation Dataset
13
+ size_categories:
14
+ - 10K<n<100K
15
+ source_datasets:
16
+ - original
17
+ tags:
18
+ - vietnamese
19
+ - t5
20
+ - nlp
21
+ - question-generation
22
+ ---
23
+
24
+ # HVU_GQ
25
+
26
+ **HHVU_GQ** is a project dedicated to sharing datasets and tools for **Question Generation Processing (NLP)**, developed and maintained by the research team at **Hung Vuong University (HVU), Phu Tho, Vietnam**.
27
+ This project is supported by **Hung Vuong University, Phu Tho, Vietnam**, with the aim of advancing research and applications in low-resource language processing, particularly for the Vietnamese language.
28
+
29
+ ---
30
+
31
+ ## 📚 Overview
32
+
33
+ This repository enables you to:
34
+ 1. Fine-tune the [VietAI/vit5-base](https://huggingface.co/datasets/DANGDOCAO/GeneratingQuestions) model on your own QA dataset.
35
+ 2. Generate multiple, diverse questions given a user-provided text passage (context).
36
+
37
+ ---
38
+
39
+ ## 📁 Dataset Format
40
+
41
+ Your dataset must follow the **SQuAD v2.0** JSON structure:
42
+
43
+ ```json
44
+ {
45
+ "version": "v2.0",
46
+ "data": [
47
+ {
48
+ "title": "Đồ uống nào của Việt Nam từng lọt top ngon nhất thế giới?",
49
+ "paragraphs": [
50
+ {
51
+ "qas": [
52
+ {
53
+ "id": "q1_1",
54
+ "question": "Đồ uống nào của Việt Nam từng lọt top ngon nhất thế giới?",
55
+ "answers": [
56
+ {
57
+ "text": "Theo bản đánh giá tháng 2/2023 của Taste Atlas...",
58
+ "answer_start": "Theo bản đánh giá tháng 2/2023 của Taste Atlas..."
59
+ }
60
+ ],
61
+ "is_impossible": false
62
+ }
63
+ ]
64
+ }
65
+ ]
66
+ }
67
+ ]
68
+ }
69
+ ```
70
+
71
+ **Required fields:**
72
+ - `title` → used as context
73
+ - `question` → target question
74
+ - `answers[0].text` → seed answer for training
75
+ - `is_impossible` → filter for valid QAs
76
+
77
+ **File name:** `30ktrain.json` (UTF-8)
78
+
79
+ ---
80
+
81
+ ## 📁 Datasets
82
+
83
+ This repository provides datasets for **training** and **evaluating** Vietnamese question generation models.
84
+
85
+ ### 🔹 `DataTotalQCAtriples30k/`
86
+ - **`30ktrain.json`** → 30,000 QCA triples for training.
87
+
88
+ ### 🔹 `Datatest1k/`
89
+ - **`testorgin1k.json`** → 1,000 examples for manual & automatic evaluation.
90
+
91
+ ### 🔹 `Datatrain29k/`
92
+ - **`29kcorpustag.json`** → 29,000 preprocessed QCA triples.
93
+
94
+ > All files are UTF-8 encoded and ready for direct use in NLP pipelines.
95
+
96
+ ---
97
+
98
+ ## 📊 Evaluation Results
99
+
100
+ We performed **manual evaluation on 500 samples** and **automatic evaluation on 1,000 samples**.
101
+
102
+ | Evaluation Type | Precision | Recall | F1-Score |
103
+ |------------------|-----------|--------|----------|
104
+ | Automatic (1000) | 0.85 | 0.83 | 0.84 |
105
+ | Manual (500) | 0.88 | 0.86 | 0.87 |
106
+
107
+ ---
108
+
109
+ ## 🔧 Installation
110
+
111
+ Create a virtual environment and install dependencies:
112
+
113
+ ### Windows (PowerShell)
114
+ ```powershell
115
+ python -m venv .venv
116
+ .venv\Scripts\Activate.ps1
117
+ python -m pip install --upgrade pip
118
+ pip install torch transformers datasets scikit-learn
119
+ ```
120
+
121
+ ### Linux / macOS
122
+ ```bash
123
+ python3 -m venv .venv
124
+ source .venv/bin/activate
125
+ python -m pip install --upgrade pip
126
+ pip install torch transformers datasets scikit-learn
127
+ ```
128
+
129
+ ---
130
+
131
+ ## 🚀 Training (Fine-tuning)
132
+
133
+ Make sure `30ktrain.json` is in the same folder as `fine_tune_qg.py`.
134
+
135
+ Run:
136
+ ```bash
137
+ python fine_tune_qg.py
138
+ ```
139
+
140
+ **What happens:**
141
+ - Loads `30ktrain.json`
142
+ - Splits into 80% train / 20% validation
143
+ - Tokenizes using `T5Tokenizer`
144
+ - Fine-tunes `VietAI/vit5-base` for 3 epochs
145
+ - Saves model + tokenizer to `t5-viet-qg-finetuned/`
146
+
147
+ **Key training parameters** (edit in `fine_tune_qg.py` if needed):
148
+ - `per_device_train_batch_size`: 1
149
+ - `learning_rate`: 2e-4
150
+ - `num_train_epochs`: 3
151
+ - `max_input_length`: 512
152
+ - `max_target_length`: 64
153
+
154
+ ---
155
+
156
+ ## 💡 Generating Questions
157
+
158
+ Once training is done, use `generate_question.py` to generate new questions.
159
+
160
+ Ensure:
161
+ - `MODEL_DIR` → `t5-viet-qg-finetuned/`
162
+ - `DATA_PATH` → `30ktrain.json`
163
+
164
+ Run:
165
+ ```bash
166
+ python generate_question.py
167
+ ```
168
+
169
+ Steps:
170
+ 1. Enter a context passage (Vietnamese)
171
+ 2. Enter number of questions (default 20, max 200)
172
+ 3. Script will:
173
+ - Find best match in dataset by title similarity
174
+ - Use matched answer + your context
175
+ - Generate multiple unique questions with top-k & top-p sampling
176
+ 4. Output lists generated questions.
177
+
178
+ ---
179
+
180
+ ## ⚙️ Generation Settings
181
+
182
+ In `generate_question.py`, tweak:
183
+ - `top_k` (default 60)
184
+ - `top_p` (default 0.95)
185
+ - `temperature` (default 0.9)
186
+ - `no_repeat_ngram_size` (default 3)
187
+ - `repetition_penalty` (default 1.12)
188
+
189
+ ---
190
+
191
+ ## 📂 Project Structure
192
+
193
+ ```
194
+ .
195
+ ├── fine_tune_qg.py
196
+ ├── generate_question.py
197
+ ├── 30ktrain.json
198
+ ├── t5-viet-qg-finetuned/
199
+ ├── README.md
200
+ └── LICENSE
201
+ ```
202
+
203
+ ---
204
+
205
+ ## 🔍 Example Usage
206
+
207
+ **Training**
208
+ ```bash
209
+ python fine_tune_qg.py
210
+ ```
211
+
212
+ **Generating**
213
+ ```bash
214
+ python generate_question.py
215
+ ```
216
+
217
+ Example:
218
+ ```
219
+ Nhập đoạn văn bản:
220
+ Cà phê sữa đá là đồ uống nổi tiếng ở Việt Nam.
221
+
222
+ Nhập vào số lượng câu hỏi bạn cần: 5
223
+
224
+ ✅ Các câu hỏi mới được sinh ra:
225
+ 1. Loại cà phê nào nổi tiếng ở Việt Nam?
226
+ 2. Tại sao cà phê sữa đá được yêu thích?
227
+ 3. Cà phê sữa đá gồm những nguyên liệu gì?
228
+ 4. Nguồn gốc của cà phê sữa đá là từ đâu?
229
+ 5. Cà phê sữa đá Việt Nam được pha chế như thế nào?
230
+ ```
231
+
232
+ ---
233
+
234
+ ## 🤝 Contribution
235
+
236
+ You’re welcome to:
237
+ - Open issues
238
+ - Submit pull requests
239
+ - Suggest new datasets
240
+
241
+ ---
242
+
243
+ ## 📄 License
244
+
245
+ Licensed under the MIT License – see the `LICENSE` file for details.
246
+
247
+ ---
248
+
249
+ ## 📬 Contact
250
+
251
+ - **Ha Nguyen-Tien** (Corresponding author)
252
+ Email: nguyentienha@hvu.edu.vn
253
+
254
+ - **Phuc Le-Hong**
255
+ Email: Lehongphuc20021408@gmail.com
256
+
257
+ - **DANG DO CAO**
258
+ Email: docaodang532001@gmail.com
259
+
260
+ ---
261
+
262
+ *This repository is part of an effort to advance Vietnamese NLP by making question generation more accessible for researchers and developers.*