Jiuge: a Human-Machine Collaborative Chinese Classical Poetry Generation System
Total Page:16
File Type:pdf, Size:1020Kb
Jiuge: A Human-Machine Collaborative Chinese Classical Poetry Generation System Zhipeng Guo1∗ , Xiaoyuan Yi1∗, Maosong Sun1y , Wenhao Li1, Cheng Yang1, Jiannan Liang1, Huimin Chen1, Yuhui Zhang1, Ruoyu Li2 1Department of Computer Science and Technology, Tsinghua University, Beijing, China Institute for Artificial Intelligence, Tsinghua University, Beijing, China State Key Lab on Intelligent Technology and Systems, Tsinghua University, Beijing, China 26ESTATES PTE LTD, Singapore Abstract Zhang et al., 2017; Yi et al., 2017). Besides the research value of exploring human writing mech- Research on the automatic generation of po- anism and computer creativity, these models and etry, the treasure of human culture, has lasted for decades. Most existing systems, however, systems could also benefit electronic entertain- are merely model-oriented, which input some ment, advertisement, and poetry education. user-specified keywords and directly complete However, the recently released Chinese poetry the generation process in one pass, with lit- generation systems are mainly model-oriented, tle user participation. We believe that the which take some user inputs and directly complete machine, being a collaborator or an assistant, the generation in one pass, resulting in poor user should not replace human beings in poetic cre- participation. Moreover, these systems generate ation. Therefore, we proposed Jiuge, a human- machine collaborative Chinese classical po- poetry in fewer styles and genres, and provide lim- etry generation system. Unlike previous sys- ited options for users. For example, the Daoxi- tems, Jiuge allows users to revise the unsatis- angju system1 requires the user to determine the fied parts of a generated poem draft repeatedly. rhyme, which creates a barrier for beginners. The According to the revision, the poem will be dy- Oude system2 simplifies the user’s choices and namically updated and regenerated. After the only allows the input of a few options and genres. revision and modification procedure, the user The Microsoft Quatrain3 provides limited candi- can write a satisfying poem together with Ji- dates of a theme and each line, but it only supports uge system collaboratively. Besides, Jiuge can accept multi-modal inputs, such as keywords, the generation of quatrains. plain text or images. By exposing the options Due to the lack of user participation, the above of poetry genres, styles and revision modes, Ji- systems are mainly designed for entertainment. uge, acting as a professional assistant, allows We argue that the leading role in literary creation constant and active participation of users in should not be a machine, or at least not only a ma- poetic creation. chine, because it is difficult for machines to handle 1 Introduction the complex expressions of one’s emotion and the use of images in poetic creation. Language is one of the most important forms of Rather than completely replace humans, a better human intelligence, among different genres, po- way is to utilize the system to assist human cre- etry is a beautiful, poetic and artistic genre which ation. The human-machine collaboration mech- expresses one’s emotions and ideas with relatively anism in Jiuge system can not only improve the fewer words. Across various countries, nationali- emotions and semantics of generated poems but ties, and cultures, poetry is always fascinating, im- also guide and teach beginners to understand the pacting profoundly on the development of human poetic creation process. civilization. In summary, the contributions of our Jiuge sys- Recently, researchers have worked on automatic tem are as follows: poetry generation. Meanwhile, neural networks have proven to be powerful on this task (Zhang • Multi-modal input. Jiuge can accept multi- and Lapata, 2014; Wang et al., 2016; Yan, 2016; 1http://www.poeming.com/web/ ∗ indicates equal contribution 2https://crl.ptopenlab.com:8800/poem/index y Corresponding author: M.Sun([email protected]) 3http://duilian.msra.cn/jueju/ 25 Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics: System Demonstrations, pages 25–30 Florence, Italy, July 28 - August 2, 2019. c 2019 Association for Computational Linguistics Collaborative Revision Module Keywords: plane, blue sky Plain Text: There is a plane in the blue sky. Automatic Reference Recommendation Revision Modes Picture: Static/Local Dynamic/Global Dynamic The swan goose is flying outside the clouds. Extract Expand The heavy mist almost make the Main Framework Transform ferry invisible. Keywords: fly, blue sky, swan goose, vast Working Memory Model The vast road has extended to Pattern Checking thousands of miles away. Genere Control Re-Ranking Unsupervised Style Control It's so remote that it seems like it reaches the sky. Quatrain, Acrostic, Iambic Genre: Acrostic Poetry Generation Style: Standard, Sadness about seasons, … Input Preprocessing Module Generation Model Postprocessing Model Final Poetry Figure 1: The architecture of Jiuge system. modal input such as keywords, plain text, and and removes the ones that do not conform to struc- even images. For modern concepts in the in- tural and phonological requirements. At last, the put, Jiuge utilizes a knowledge graph to map collaborative revision module interacts with the them into relevant keywords in classical Chi- user and dynamically updates the draft for several nese poetry. times according to the user’s revision, to collabo- ratively create a satisfying poem. • Various styles and genres. Unlike previous We detail each module in the following parts. systems, Jiuge provides more than twenty op- tions of genre and ten options of style, and 2.2 Input Preprocessing Module can generate more diverse poems. Keyword Extraction. Jiuge allows multi-modal input to meet the needs of generating poetry ac- • Human-machine collaboration . Jiuge sup- cording to keywords, tweets or photos. ports human-machine collaborative and inter- For plain text, we first use THULAC4 (Li and active generation. The user can revise the un- Sun, 2009) to conduct Chinese word segmentation satisfied parts of a generated poem. In terms and compute the importance r(w) of each word w: of the revision, Jiuge will dynamically update and re-generate the poem. During this pro- r(w)=[α∗ti(w)+(1−α)∗tr(w)]; (1) cess, Jiuge also offers candidate words and where ti(w) and tr(w) are the TF-IDF (Term human-authored poetry as references for be- Frequency-Inverse Document Frequency) value ginners. and TextRank (Mihalcea and Tarau, 2004) score 2 Architecture calculated with the whole poetry corpus respec- tively. α is a hyper-parameter to balance the 2.1 Overview weights of ti(w) and tr(w). Afterwards, we se- We show the overall architecture of Jiuge system lect top K words with the highest scores. in Fig.1, which mainly consists of four modules: For each image, we use the Aliyun image recog- 5 1) input preprocessing, 2) generation, 3) postpro- nition tool , which gives the names of five rec- cessing and 4) collaborative revision. Given the ognized objects with corresponding probability user-specified genre, style, and inputs (keywords, s(w). Then we select top K words with the high- plain text or images), the preprocessing module est s(w) · r(w). extracts several keywords from the inputs and then Keyword Mapping. The extracted or recog- conducts keyword expansion to introduce richer nized keywords could be some modern concepts, information. Jiuge also transforms the words in such as airplane and refrigerator. Since these modern concepts, which are incompatible with words never occur in the classical poetry corpus, classical Chinese poetry (written in ancient Chi- the generation module will take them as a UNK nese language), such as refrigerator and airplane, symbol and generate totally irrelevant poems. to appropriate relevant ones, e.g., airplane ! fly. To address this problem, we build a Poetry With these preprocessed keywords, the generation Knowledge Graph (PKG) from Wikipedia data, module generates a poem draft. The postprocess- 4http://thulac.thunlp.org/ ing module re-ranks the candidates of each line 5https://ai.aliyun.com/image 26 PKG PWCG (fly) (egret) ! = 0.33 !"#$% = 25.3 (airplane) (fly) ! = 0.08 !"#$% = 27.1 ! = 0.13 !"#$% = 20.7 (wing) (swan goose) (wind) (butterfly) (a) (b) Figure 2: (a) A sampled subgraph of PKG. (b) A sam- pled subgraph of PWCG. which contains 616; 360 entities and 5; 102; 192 relations. 40; 276 of these entities occur in our po- Figure 3: The simplified structure of the working mem- etry corpus. Before keywords extension and selec- ory model, which mainly comprise an encoder, a de- tion, we first use PKG to map the modern concepts coder and there memory components. xi is the i-th line and x is the j-word in the i-th line. Please refer to (Yi to its most relevant entities in poetry, to guarantee i;j et al., 2018b) for more details. both quality and relevance of generated poems. For a modern concept word wi, we score its ory model (Yi et al., 2018b), which takes at most each neighbor word wj by: K preprocessed keywords as input. The encoder maps each word or line into vector representa- N p(wj ) g(wj )=tfwiki(wj jwi) · log( ) · arctan( ); 1+df(wj ) τ tions, and the decoder generates each line word- (2) by-word. The topic memory stores keywords ex- where tfwiki(wjjwi) is the term frequency of wj plicitly and independently, which can learn a flex- in the Wikipedia article of wi, df(wj) is the num- ible order and form of keywords expression. The ber of Wikipedia articles containing wj, N is the history memory and local memory are dynami- number of Wikipedia articles, and p(wj) is the cally read and written to improve the context co- word frequency counted in all articles. We give an herence of generated poems. example of mapping the modern word “airplane” Genere Control. Chinese classical poetry in- in Fig.2(a). volves various genres, and each genre strictly de- Keyword Extension.