|
|
--- |
|
|
license: mit |
|
|
task_categories: |
|
|
- question-answering |
|
|
- text-generation |
|
|
language: |
|
|
- vi |
|
|
tags: |
|
|
- vietnamese |
|
|
- t5 |
|
|
- nlp |
|
|
- question-generation |
|
|
pretty_name: HVU Question Generation Dataset |
|
|
size_categories: |
|
|
- 10K<n<100K |
|
|
--- |
|
|
|
|
|
# HVU_GQ |
|
|
|
|
|
**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**. |
|
|
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. |
|
|
|
|
|
--- |
|
|
|
|
|
## 📚 Overview |
|
|
|
|
|
This repository enables you to: |
|
|
1. Fine-tune the [VietAI/vit5-base](https://huggingface.co/datasets/DANGDOCAO/GeneratingQuestions) model on your own QA dataset. |
|
|
2. Generate multiple, diverse questions given a user-provided text passage (context). |
|
|
|
|
|
--- |
|
|
|
|
|
## 📁 Dataset Format |
|
|
|
|
|
Your dataset must follow the **SQuAD v2.0** JSON structure: |
|
|
|
|
|
```json |
|
|
{ |
|
|
"version": "v2.0", |
|
|
"data": [ |
|
|
{ |
|
|
"title": "Đồ uống nào của Việt Nam từng lọt top ngon nhất thế giới?", |
|
|
"paragraphs": [ |
|
|
{ |
|
|
"qas": [ |
|
|
{ |
|
|
"id": "q1_1", |
|
|
"question": "Đồ uống nào của Việt Nam từng lọt top ngon nhất thế giới?", |
|
|
"answers": [ |
|
|
{ |
|
|
"text": "Theo bản đánh giá tháng 2/2023 của Taste Atlas...", |
|
|
"answer_start": "Theo bản đánh giá tháng 2/2023 của Taste Atlas..." |
|
|
} |
|
|
], |
|
|
"is_impossible": false |
|
|
} |
|
|
] |
|
|
} |
|
|
] |
|
|
} |
|
|
] |
|
|
} |
|
|
``` |
|
|
|
|
|
**Required fields:** |
|
|
- `title` → used as context |
|
|
- `question` → target question |
|
|
- `answers[0].text` → seed answer for training |
|
|
- `is_impossible` → filter for valid QAs |
|
|
|
|
|
**File name:** `30ktrain.json` (UTF-8) |
|
|
|
|
|
--- |
|
|
|
|
|
## 📁 Datasets |
|
|
|
|
|
This repository provides datasets for **training** and **evaluating** Vietnamese question generation models. |
|
|
|
|
|
### 🔹 `DataTotalQCAtriples30k/` |
|
|
- **`30ktrain.json`** → 30,000 QCA triples for training. |
|
|
|
|
|
### 🔹 `Datatest1k/` |
|
|
- **`testorgin1k.json`** → 1,000 examples for manual & automatic evaluation. |
|
|
|
|
|
### 🔹 `Datatrain29k/` |
|
|
- **`29kcorpustag.json`** → 29,000 preprocessed QCA triples. |
|
|
|
|
|
> All files are UTF-8 encoded and ready for direct use in NLP pipelines. |
|
|
|
|
|
--- |
|
|
|
|
|
## 📊 Evaluation Results |
|
|
|
|
|
We performed **manual evaluation on 500 samples** and **automatic evaluation on 1,000 samples**. |
|
|
|
|
|
| Evaluation Type | Precision | Recall | F1-Score | |
|
|
|------------------|-----------|--------|----------| |
|
|
| Automatic (1000) | 0.85 | 0.83 | 0.84 | |
|
|
| Manual (500) | 0.88 | 0.86 | 0.87 | |
|
|
|
|
|
--- |
|
|
|
|
|
## 🔧 Installation |
|
|
|
|
|
Create a virtual environment and install dependencies: |
|
|
|
|
|
### Windows (PowerShell) |
|
|
```powershell |
|
|
python -m venv .venv |
|
|
.venv\Scripts\Activate.ps1 |
|
|
python -m pip install --upgrade pip |
|
|
pip install torch transformers datasets scikit-learn |
|
|
``` |
|
|
|
|
|
### Linux / macOS |
|
|
```bash |
|
|
python3 -m venv .venv |
|
|
source .venv/bin/activate |
|
|
python -m pip install --upgrade pip |
|
|
pip install torch transformers datasets scikit-learn |
|
|
``` |
|
|
|
|
|
--- |
|
|
|
|
|
## 🚀 Training (Fine-tuning) |
|
|
|
|
|
Make sure `30ktrain.json` is in the same folder as `fine_tune_qg.py`. |
|
|
|
|
|
Run: |
|
|
```bash |
|
|
python fine_tune_qg.py |
|
|
``` |
|
|
|
|
|
**What happens:** |
|
|
- Loads `30ktrain.json` |
|
|
- Splits into 80% train / 20% validation |
|
|
- Tokenizes using `T5Tokenizer` |
|
|
- Fine-tunes `VietAI/vit5-base` for 3 epochs |
|
|
- Saves model + tokenizer to `t5-viet-qg-finetuned/` |
|
|
|
|
|
**Key training parameters** (edit in `fine_tune_qg.py` if needed): |
|
|
- `per_device_train_batch_size`: 1 |
|
|
- `learning_rate`: 2e-4 |
|
|
- `num_train_epochs`: 3 |
|
|
- `max_input_length`: 512 |
|
|
- `max_target_length`: 64 |
|
|
|
|
|
--- |
|
|
|
|
|
## 💡 Generating Questions |
|
|
|
|
|
Once training is done, use `generate_question.py` to generate new questions. |
|
|
|
|
|
Ensure: |
|
|
- `MODEL_DIR` → `t5-viet-qg-finetuned/` |
|
|
- `DATA_PATH` → `30ktrain.json` |
|
|
|
|
|
Run: |
|
|
```bash |
|
|
python generate_question.py |
|
|
``` |
|
|
|
|
|
Steps: |
|
|
1. Enter a context passage (Vietnamese) |
|
|
2. Enter number of questions (default 20, max 200) |
|
|
3. Script will: |
|
|
- Find best match in dataset by title similarity |
|
|
- Use matched answer + your context |
|
|
- Generate multiple unique questions with top-k & top-p sampling |
|
|
4. Output lists generated questions. |
|
|
|
|
|
--- |
|
|
|
|
|
## ⚙️ Generation Settings |
|
|
|
|
|
In `generate_question.py`, tweak: |
|
|
- `top_k` (default 60) |
|
|
- `top_p` (default 0.95) |
|
|
- `temperature` (default 0.9) |
|
|
- `no_repeat_ngram_size` (default 3) |
|
|
- `repetition_penalty` (default 1.12) |
|
|
|
|
|
--- |
|
|
|
|
|
## 📂 Project Structure |
|
|
|
|
|
``` |
|
|
. |
|
|
├── fine_tune_qg.py |
|
|
├── generate_question.py |
|
|
├── 30ktrain.json |
|
|
├── t5-viet-qg-finetuned/ |
|
|
├── README.md |
|
|
└── LICENSE |
|
|
``` |
|
|
|
|
|
--- |
|
|
|
|
|
## 🔍 Example Usage |
|
|
|
|
|
**Training** |
|
|
```bash |
|
|
python fine_tune_qg.py |
|
|
``` |
|
|
|
|
|
**Generating** |
|
|
```bash |
|
|
python generate_question.py |
|
|
``` |
|
|
|
|
|
Example: |
|
|
``` |
|
|
Nhập đoạn văn bản: |
|
|
Cà phê sữa đá là đồ uống nổi tiếng ở Việt Nam. |
|
|
|
|
|
Nhập vào số lượng câu hỏi bạn cần: 5 |
|
|
|
|
|
✅ Các câu hỏi mới được sinh ra: |
|
|
1. Loại cà phê nào nổi tiếng ở Việt Nam? |
|
|
2. Tại sao cà phê sữa đá được yêu thích? |
|
|
3. Cà phê sữa đá gồm những nguyên liệu gì? |
|
|
4. Nguồn gốc của cà phê sữa đá là từ đâu? |
|
|
5. Cà phê sữa đá Việt Nam được pha chế như thế nào? |
|
|
``` |
|
|
|
|
|
--- |
|
|
|
|
|
## 🤝 Contribution |
|
|
|
|
|
You’re welcome to: |
|
|
- Open issues |
|
|
- Submit pull requests |
|
|
- Suggest new datasets |
|
|
|
|
|
--- |
|
|
|
|
|
## 📄 License |
|
|
|
|
|
Licensed under the MIT License – see the `LICENSE` file for details. |
|
|
|
|
|
--- |
|
|
|
|
|
## 📬 Contact |
|
|
|
|
|
- **Ha Nguyen-Tien** (Corresponding author) |
|
|
Email: nguyentienha@hvu.edu.vn |
|
|
|
|
|
- **Phuc Le-Hong** |
|
|
Email: Lehongphuc20021408@gmail.com |
|
|
|
|
|
- **DANG DO CAO** |
|
|
Email: docaodang532001@gmail.com |
|
|
|
|
|
--- |
|
|
|
|
|
*This repository is part of an effort to advance Vietnamese NLP by making question generation more accessible for researchers and developers.* |