Yu Sheng: Human-in-Loop Classical C hinese Poetry Generation System (2023)

Abstract: The development of poetry generation system mainly focuses on enhancing the capacity of generation model. However, the demands of customization and polishing are generally ignored, which highly reduces the scope of application. In this work, we present Yu Sheng, a web-based poetry generation system that is featured a human-in-loop generation framework, providing various customization options for users with different backgrounds to engage in the process of poetry composition. To this end, we propose two methods and train the models that can perform constrained generation and fine-grained polishing. The automatic and human evaluation results show that our system has a strong ability to generate and polish poetry compared to other vanilla models. Our system is publicly accessible at: https://yusheng.cis.um.edu.mo .

## introduction classical chinese poetry is written with specific rules such as historical period, phonology, etc., attracting researchers from different fields to study its writing mechanism. apart from the in-depth analysis of poetry writing process, the automatic generation of classical chinese poetry is an emerging research task of open-ended text generation. several research lines of poetry generation has been investigated in the past few years such as combinatory process @xcite , template-based method @xcite , machine learning @xcite , and deep learning @xcite . recently, the pre-trained language model is utilized to capture poetry prior knowledge @xcite and build the downstream generation models. previous research focuses on building the generation model with an end-to-end pipeline, polishing @xcite is an essential part of poetry generation that can be helpful to reduce linguistic errors and enhance the aesthetic. although there are numerous online systems that can generate classical chinese poetry based on the keywords, 234 few works integrate the polishing function into the generation system. jiuge foot_3 allows the user to make the adjustment by providing candidate words but is limited to word-level replacements, which is not flexible in adjusting the poetry-level polishing. moreover, the design of polishing services should be user-oriented. the current system @xcite allows users to select the candidate words, but it is not friendly for non-professional users due to their insufficient background in poetry composition, which is also limited for professional users to polish the results. to alleviate the aforementioned problems, we design and implement a human-in-loop classical chinese poetry generation system, yu sheng. yu sheng not only supports the poetry generation with diverse genres and constraints, but also provides fine-grained polishing functions where the unsatisfactory parts can be refined with automatic adjustment. in order to build models that are capable to handle the above functions, we propose two methods for constraint integration and poetry polishing. specifically, the global attention mechanism is proposed to integrate different kinds of constraints. for building the polishing model, we utilize the multi-task learning approach to train the model with mask prediction and sentence reconstruction tasks. moreover, the data augmentation techniques are also used to alleviate the scarcity of task-specific data. both automatic and human evaluation results have shown the effectiveness of our proposed polishing-based generation model. by deploying the model trained with the above methods, yu sheng is characterized by customizable keyword: 夏天 modern chinese: 夏天阳光很热烈 imageries: 夏日 | 霞 | 烟 word amount: 3, 4, 5, 6, 7 ... sentence amount: 2, 4, 6, 8, 10 ... level and oblique tones: 平起偏格 rhymes: 一东, 二冬, 三江, 四支 masked prediction sentence reconstruction ## methodology the generation pipeline of yu sheng includes two stages: poetry generation and poetry polishing. it not only supports automatic poetry generation from given information, but also accepts any existing poems as input for polishing. in this section, we first describe the proposed methods for building the generation and polishing models and introduce the data augmentation methods for compensating the data used in supervised training. ## functionality design as shown in figure 2 , we specially design three main functions for yu sheng system, meeting the model diversity (distinct) ↑ f-score ↑ distinct-1 distinct-2 word amount sentence amount tones rhyme user's demand at different levels. as the fundamental function, the user can easily obtain poetry by indicating expected features. as for people who have advanced requirements of aesthetics, they can pay more effort into poetry generation by using two polishing modes for optimizing the generation draft. the dynamic polishing provides the functionality of poetry-level refinement. the user can simply select the unsatisfactory words or sentences as the target, and then the system will perform automatic polishing for updating the chosen parts. if the user wants to dive deeper and make subtle changes, static polishing can recommend substitutes for the unsatisfactory text, where the user can choose the proper candidate and manually replace the corresponding parts. moreover, professional user can import their own poetry work and obtain inspiration from polishing candidates provided by yu sheng. to facilitate polishing process, the system will provide explanatory information of each feature to user for understanding the candidates. for improving the inference speed in a practical environment, we enable a inherit-based decoding trick for polishing task, which significantly reduces response time by preserving the unchanged tokens at each decoding step. the whole generation pipeline makes up of the aforementioned functions, and the specific use cases of each function are introduced in appendix. ## discussion figure 3 presents a case of using yu sheng to customize poetry generation with constraints. constrained poem generation as shown in figure 3a , the user may first use the feature selector to customize all generation constraints. then the user enters the topic words according to the type of keywords and click generate button, yu sheng will return the results in the demonstration panel. ## conclusion and future work we propose yu sheng, a comprehensive, humanin-loop classical chinese poetry generation system. yu sheng establishes a generation pipeline that covers multi-dimensional demands of generation and polishing, enabling amateurs to engage in the process of poetry generation, and provide inspirations for composition work of human poets. it provides the functionalities for users with different backgrounds to conduct poetry composition conveniently and flexibly. with the global attention mechanism and the human-in-loop poetry generation paradigm, yu sheng could be easily updated with diverse constraints and further extended to different languages. in the future, we will also collect the data and construct an annotated polishing corpus for training a more robust polishing model.