mt5 base chinese qg
algoletIntroduction
The MT5-Base-Chinese-QG model is designed for generating questions in Chinese using the MT5 architecture. It is available for online use and can be integrated with Python for local applications.
Architecture
This model is based on the MT5 architecture, which is a multilingual variant of Google's T5 (Text-to-Text Transfer Transformer) model. It is fine-tuned specifically for the task of Chinese question generation.
Training
The model's performance is evaluated using the ROUGE metric, with scores of:
- ROUGE-1: 0.4041
- ROUGE-2: 0.2104
- ROUGE-L: 0.3843
Guide: Running Locally
-
Install the Necessary Package
Install thequestion-generation
package via pip:pip install question-generation
-
Load the Model with Transformers
Use thetransformers
library to load the tokenizer and model:import torch from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("algolet/mt5-base-chinese-qg") model = AutoModelForSeq2SeqLM.from_pretrained("algolet/mt5-base-chinese-qg") model.eval()
-
Generate Questions
Prepare the input text and generate questions:text = "question generation: 在一个寒冷的冬天,赶集完回家的农夫在路边发现了一条冻僵了的蛇。他很可怜蛇,就把它放在怀里。..." inputs = tokenizer(text, return_tensors='pt', truncation=True, max_length=512) with torch.no_grad(): outs = model.generate(input_ids=inputs["input_ids"], attention_mask=inputs["attention_mask"], max_length=128, no_repeat_ngram_size=4, num_beams=4) question = tokenizer.decode(outs[0], skip_special_tokens=True) questions = [q.strip() for q in question.split("<sep>") if len(q.strip()) > 0] print(questions)
-
Cloud GPU Suggestions
To optimize performance, consider using cloud GPUs from providers like AWS, Google Cloud, or Azure for running the model.
License
The usage and distribution of the MT5-Base-Chinese-QG model are subject to the terms and conditions outlined on the respective platform where it is hosted. Please refer to Hugging Face's licensing details for further information.