Yuefu is proposed by Huawei’s Noah’s Ark. It proposes a method for generating ancient Chinese poetry based on the GPT model. It uses large-scale Chinese news corpus training to obtain a Chinese GPT model, and collects a large number of ancient Chinese poems, words, and couplets in a specific format. After sorting, and then inputting the sorted data into the GPT model for fine-tune, a high-quality ancient poetry generation system is obtained.
Reference paper: Yi Liao, Yasheng Wang, Qun Liu, Xin Jiang: “GPT-based Generation for Classical Chinese Poetry”, 2019
Before starting the training, first configure the environment variables related to the program running. For environment variable configuration information, see:
Set the checkpoint path, the default is ModelZoo_Yuefu_TF/
Set main_1p.sh
, configuration parameters for non-distributed training of Transformer model.
max_decode_len: the maximum generation length, the default setting is 80
Title: Enter the subject of the poetry you want to generate
Type: Enter the subject of the poetry you want to generate, including five-character quatrain poetry, five-character quatrain, seven-character quatrain, seven-character quatrain
export JOB_ID=10086
export DEVICE_ID=3
export RANK_ID=0
export RANK_SIZE=1
export RANK_TABLE_FILE=${dir}/device_table_1p.json
export USE_NPU=True
export POETRY_TYPE=-1
export max_decode_len=80
python3 poetry_v2.py --title="Mid-Autumn Festival" --type="Seven Words Quatrains"
Set options in main_1p.sh, including max_decode_len and other hyperparameters,Run the script:
sh main_1p.sh
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。