Text Generation
Transformers
PyTorch
Chinese
mt5
text2text-generation
questions and answers generation
Eval Results (legacy)
Instructions to use lmqg/mt5-base-zhquad-qag with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use lmqg/mt5-base-zhquad-qag with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="lmqg/mt5-base-zhquad-qag")# Load model directly from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("lmqg/mt5-base-zhquad-qag") model = AutoModelForSeq2SeqLM.from_pretrained("lmqg/mt5-base-zhquad-qag", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use lmqg/mt5-base-zhquad-qag with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "lmqg/mt5-base-zhquad-qag" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "lmqg/mt5-base-zhquad-qag", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/lmqg/mt5-base-zhquad-qag
- SGLang
How to use lmqg/mt5-base-zhquad-qag with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "lmqg/mt5-base-zhquad-qag" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "lmqg/mt5-base-zhquad-qag", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "lmqg/mt5-base-zhquad-qag" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "lmqg/mt5-base-zhquad-qag", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use lmqg/mt5-base-zhquad-qag with Docker Model Runner:
docker model run hf.co/lmqg/mt5-base-zhquad-qag
commit files to HF hub
Browse files- README.md +135 -0
- eval/metric.first.answer.paragraph.questions_answers.lmqg_qag_zhquad.default.json +1 -0
- eval/samples.test.hyp.paragraph.questions_answers.lmqg_qag_zhquad.default.txt +0 -0
- eval/samples.validation.hyp.paragraph.questions_answers.lmqg_qag_zhquad.default.txt +0 -0
- trainer_config.json +1 -0
README.md
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
---
|
| 3 |
+
license: cc-by-4.0
|
| 4 |
+
metrics:
|
| 5 |
+
- bleu4
|
| 6 |
+
- meteor
|
| 7 |
+
- rouge-l
|
| 8 |
+
- bertscore
|
| 9 |
+
- moverscore
|
| 10 |
+
language: zh
|
| 11 |
+
datasets:
|
| 12 |
+
- lmqg/qag_zhquad
|
| 13 |
+
pipeline_tag: text2text-generation
|
| 14 |
+
tags:
|
| 15 |
+
- questions and answers generation
|
| 16 |
+
widget:
|
| 17 |
+
- text: "南安普敦的警察服务由汉普郡警察提供。南安普敦行动的主要基地是一座新的八层专用建筑,造价3000万英镑。该建筑位于南路,2011年启用,靠近 南安普敦中央 火车站。此前,南安普顿市中心的行动位于市民中心西翼,但由于设施老化,加上计划在旧警察局和地方法院建造一座新博物馆,因此必须搬迁。在Portswood、Banister Park、Hille和Shirley还有其他警察局,在南安普顿中央火车站还有一个英国交通警察局。"
|
| 18 |
+
example_title: "Questions & Answers Generation Example 1"
|
| 19 |
+
model-index:
|
| 20 |
+
- name: lmqg/mt5-base-zhquad-qag
|
| 21 |
+
results:
|
| 22 |
+
- task:
|
| 23 |
+
name: Text2text Generation
|
| 24 |
+
type: text2text-generation
|
| 25 |
+
dataset:
|
| 26 |
+
name: lmqg/qag_zhquad
|
| 27 |
+
type: default
|
| 28 |
+
args: default
|
| 29 |
+
metrics:
|
| 30 |
+
- name: QAAlignedF1Score-BERTScore (Question & Answer Generation)
|
| 31 |
+
type: qa_aligned_f1_score_bertscore_question_answer_generation
|
| 32 |
+
value: 73.57
|
| 33 |
+
- name: QAAlignedRecall-BERTScore (Question & Answer Generation)
|
| 34 |
+
type: qa_aligned_recall_bertscore_question_answer_generation
|
| 35 |
+
value: 74.12
|
| 36 |
+
- name: QAAlignedPrecision-BERTScore (Question & Answer Generation)
|
| 37 |
+
type: qa_aligned_precision_bertscore_question_answer_generation
|
| 38 |
+
value: 73.07
|
| 39 |
+
- name: QAAlignedF1Score-MoverScore (Question & Answer Generation)
|
| 40 |
+
type: qa_aligned_f1_score_moverscore_question_answer_generation
|
| 41 |
+
value: 49.76
|
| 42 |
+
- name: QAAlignedRecall-MoverScore (Question & Answer Generation)
|
| 43 |
+
type: qa_aligned_recall_moverscore_question_answer_generation
|
| 44 |
+
value: 49.92
|
| 45 |
+
- name: QAAlignedPrecision-MoverScore (Question & Answer Generation)
|
| 46 |
+
type: qa_aligned_precision_moverscore_question_answer_generation
|
| 47 |
+
value: 49.62
|
| 48 |
+
---
|
| 49 |
+
|
| 50 |
+
# Model Card of `lmqg/mt5-base-zhquad-qag`
|
| 51 |
+
This model is fine-tuned version of [google/mt5-base](https://huggingface.co/google/mt5-base) for question & answer pair generation task on the [lmqg/qag_zhquad](https://huggingface.co/datasets/lmqg/qag_zhquad) (dataset_name: default) via [`lmqg`](https://github.com/asahi417/lm-question-generation).
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
### Overview
|
| 55 |
+
- **Language model:** [google/mt5-base](https://huggingface.co/google/mt5-base)
|
| 56 |
+
- **Language:** zh
|
| 57 |
+
- **Training data:** [lmqg/qag_zhquad](https://huggingface.co/datasets/lmqg/qag_zhquad) (default)
|
| 58 |
+
- **Online Demo:** [https://autoqg.net/](https://autoqg.net/)
|
| 59 |
+
- **Repository:** [https://github.com/asahi417/lm-question-generation](https://github.com/asahi417/lm-question-generation)
|
| 60 |
+
- **Paper:** [https://arxiv.org/abs/2210.03992](https://arxiv.org/abs/2210.03992)
|
| 61 |
+
|
| 62 |
+
### Usage
|
| 63 |
+
- With [`lmqg`](https://github.com/asahi417/lm-question-generation#lmqg-language-model-for-question-generation-)
|
| 64 |
+
```python
|
| 65 |
+
from lmqg import TransformersQG
|
| 66 |
+
|
| 67 |
+
# initialize model
|
| 68 |
+
model = TransformersQG(language="zh", model="lmqg/mt5-base-zhquad-qag")
|
| 69 |
+
|
| 70 |
+
# model prediction
|
| 71 |
+
question_answer_pairs = model.generate_qa("南安普敦的警察服务由汉普郡警察提供。南安普敦行动的主要基地是一座新的八层专用建筑,造价3000万英镑。该建筑位于南路,2011年启用,靠近南安普敦中央火车站。此前,南安普顿市中心的行动位于市民中心西翼,但由于设施老化,加上计划在旧警察局和地方法院建造一座新博物馆,因此必须搬迁。在Portswood、Banister Park、Hille和Shirley还有其他警察局,在南安普顿中央火车站还有一个英国交通警察局。")
|
| 72 |
+
|
| 73 |
+
```
|
| 74 |
+
|
| 75 |
+
- With `transformers`
|
| 76 |
+
```python
|
| 77 |
+
from transformers import pipeline
|
| 78 |
+
|
| 79 |
+
pipe = pipeline("text2text-generation", "lmqg/mt5-base-zhquad-qag")
|
| 80 |
+
output = pipe("南安普敦的警察服务由汉普郡警察提供。南安普敦行动的主要基地是一座新的八层专用建筑,造价3000万英镑。该建筑位于南路,2011年启用,靠近 南安普敦中央 火车站。此前,南安普顿市中心的行动位于市民中心西翼,但由于设施老化,加上计划在旧警察局和地方法院建造一座新博物馆,因此必须搬迁。在Portswood、Banister Park、Hille和Shirley还有其他警察局,在南安普顿中央火车站还有一个英国交通警察局。")
|
| 81 |
+
|
| 82 |
+
```
|
| 83 |
+
|
| 84 |
+
## Evaluation
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
- ***Metric (Question & Answer Generation)***: [raw metric file](https://huggingface.co/lmqg/mt5-base-zhquad-qag/raw/main/eval/metric.first.answer.paragraph.questions_answers.lmqg_qag_zhquad.default.json)
|
| 88 |
+
|
| 89 |
+
| | Score | Type | Dataset |
|
| 90 |
+
|:--------------------------------|--------:|:--------|:-------------------------------------------------------------------|
|
| 91 |
+
| QAAlignedF1Score (BERTScore) | 73.57 | default | [lmqg/qag_zhquad](https://huggingface.co/datasets/lmqg/qag_zhquad) |
|
| 92 |
+
| QAAlignedF1Score (MoverScore) | 49.76 | default | [lmqg/qag_zhquad](https://huggingface.co/datasets/lmqg/qag_zhquad) |
|
| 93 |
+
| QAAlignedPrecision (BERTScore) | 73.07 | default | [lmqg/qag_zhquad](https://huggingface.co/datasets/lmqg/qag_zhquad) |
|
| 94 |
+
| QAAlignedPrecision (MoverScore) | 49.62 | default | [lmqg/qag_zhquad](https://huggingface.co/datasets/lmqg/qag_zhquad) |
|
| 95 |
+
| QAAlignedRecall (BERTScore) | 74.12 | default | [lmqg/qag_zhquad](https://huggingface.co/datasets/lmqg/qag_zhquad) |
|
| 96 |
+
| QAAlignedRecall (MoverScore) | 49.92 | default | [lmqg/qag_zhquad](https://huggingface.co/datasets/lmqg/qag_zhquad) |
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
## Training hyperparameters
|
| 101 |
+
|
| 102 |
+
The following hyperparameters were used during fine-tuning:
|
| 103 |
+
- dataset_path: lmqg/qag_zhquad
|
| 104 |
+
- dataset_name: default
|
| 105 |
+
- input_types: ['paragraph']
|
| 106 |
+
- output_types: ['questions_answers']
|
| 107 |
+
- prefix_types: None
|
| 108 |
+
- model: google/mt5-base
|
| 109 |
+
- max_length: 512
|
| 110 |
+
- max_length_output: 256
|
| 111 |
+
- epoch: 4
|
| 112 |
+
- batch: 2
|
| 113 |
+
- lr: 0.001
|
| 114 |
+
- fp16: False
|
| 115 |
+
- random_seed: 1
|
| 116 |
+
- gradient_accumulation_steps: 32
|
| 117 |
+
- label_smoothing: 0.15
|
| 118 |
+
|
| 119 |
+
The full configuration can be found at [fine-tuning config file](https://huggingface.co/lmqg/mt5-base-zhquad-qag/raw/main/trainer_config.json).
|
| 120 |
+
|
| 121 |
+
## Citation
|
| 122 |
+
```
|
| 123 |
+
@inproceedings{ushio-etal-2022-generative,
|
| 124 |
+
title = "{G}enerative {L}anguage {M}odels for {P}aragraph-{L}evel {Q}uestion {G}eneration",
|
| 125 |
+
author = "Ushio, Asahi and
|
| 126 |
+
Alva-Manchego, Fernando and
|
| 127 |
+
Camacho-Collados, Jose",
|
| 128 |
+
booktitle = "Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing",
|
| 129 |
+
month = dec,
|
| 130 |
+
year = "2022",
|
| 131 |
+
address = "Abu Dhabi, U.A.E.",
|
| 132 |
+
publisher = "Association for Computational Linguistics",
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
```
|
eval/metric.first.answer.paragraph.questions_answers.lmqg_qag_zhquad.default.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"validation": {"Bleu_1": 0.2077453790649394, "Bleu_2": 0.15669616212849166, "Bleu_3": 0.11329327069798292, "Bleu_4": 0.0675205628662687, "METEOR": 0.13149550299405027, "ROUGE_L": 0.2609240515597465, "BERTScore": 0.7150794306427541, "MoverScore": 0.49850276047443437, "QAAlignedF1Score (BERTScore)": 0.7350379663139712, "QAAlignedRecall (BERTScore)": 0.7253406724703527, "QAAlignedPrecision (BERTScore)": 0.7460203931739798, "QAAlignedF1Score (MoverScore)": 0.49478330796740533, "QAAlignedRecall (MoverScore)": 0.48941958475894903, "QAAlignedPrecision (MoverScore)": 0.5005154693716379}, "test": {"Bleu_1": 0.08653450389859453, "Bleu_2": 0.06361653603763276, "Bleu_3": 0.04326443681415462, "Bleu_4": 0.024136296807001266, "METEOR": 0.10530923349771895, "ROUGE_L": 0.19016124779262342, "BERTScore": 0.632117692622639, "MoverScore": 0.4921711252598822, "QAAlignedF1Score (BERTScore)": 0.7356638345459832, "QAAlignedRecall (BERTScore)": 0.7411721341960391, "QAAlignedPrecision (BERTScore)": 0.7307381935071808, "QAAlignedF1Score (MoverScore)": 0.4976474798290538, "QAAlignedRecall (MoverScore)": 0.4992147354755327, "QAAlignedPrecision (MoverScore)": 0.49618864901132487}}
|
eval/samples.test.hyp.paragraph.questions_answers.lmqg_qag_zhquad.default.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
eval/samples.validation.hyp.paragraph.questions_answers.lmqg_qag_zhquad.default.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
trainer_config.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"dataset_path": "lmqg/qag_zhquad", "dataset_name": "default", "input_types": ["paragraph"], "output_types": ["questions_answers"], "prefix_types": null, "model": "google/mt5-base", "max_length": 512, "max_length_output": 256, "epoch": 4, "batch": 2, "lr": 0.001, "fp16": false, "random_seed": 1, "gradient_accumulation_steps": 32, "label_smoothing": 0.15}
|