{"id":13901219,"url":"https://github.com/THUNLP-AIPoet/MixPoet","last_synced_at":"2025-07-17T21:32:40.060Z","repository":{"id":38305703,"uuid":"251295601","full_name":"THUNLP-AIPoet/MixPoet","owner":"THUNLP-AIPoet","description":"Source codes of MixPoet: Diverse Poetry Generation via Learning Controllable Mixed Latent Space (AAAI 2020)","archived":false,"fork":false,"pushed_at":"2020-11-19T08:42:07.000Z","size":1881,"stargazers_count":145,"open_issues_count":5,"forks_count":30,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-08-07T21:45:16.689Z","etag":null,"topics":["chinese","poetry-generator","style"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/THUNLP-AIPoet.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-30T12:19:13.000Z","updated_at":"2024-02-29T04:54:17.000Z","dependencies_parsed_at":"2022-09-05T09:11:26.263Z","dependency_job_id":null,"html_url":"https://github.com/THUNLP-AIPoet/MixPoet","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/THUNLP-AIPoet%2FMixPoet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/THUNLP-AIPoet%2FMixPoet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/THUNLP-AIPoet%2FMixPoet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/THUNLP-AIPoet%2FMixPoet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/THUNLP-AIPoet","download_url":"https://codeload.github.com/THUNLP-AIPoet/MixPoet/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226305256,"owners_count":17603776,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chinese","poetry-generator","style"],"created_at":"2024-08-06T21:01:01.205Z","updated_at":"2024-11-25T09:30:59.862Z","avatar_url":"https://github.com/THUNLP-AIPoet.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# MixPoet\nThe source code of [*MixPoet: Diverse Poetry Generation via Learning Controllable Mixed Latent Space*](https://arxiv.org/pdf/2003.06094.pdf) (AAAI 2020).\n\n## 1. Rights\nAll rights reserved.\n\n## 2. Requirements\n* python\u003e=3.7.0\n* pytorch\u003e=1.3.1\n* sklearn\u003e=0.19.2\n* matplotlib\u003e=2.2.3 \n\n## 3. Data Preparation\nTo train the model and generate poems, please \n\n* add the training, validation and testing sets of our [THU-CCPC](https://github.com/THUNLP-AIPoet/Datasets/tree/master/CCPC) data into the *MixPoet/preprocess/*  directory;\n* add the pingsheng.txt, zesheng.txt, pingshui.txt and pingshui_amb.pkl files of our [THU-CRRD](https://github.com/THUNLP-AIPoet/Datasets/tree/master/CRRD) set into the *MixPoet/data/*  directory.\n\nWe provide a small sampled subset of the labelled CQCF in the *preprocess*  directory to test these codes. We will consider releasing the full CQCF set in the future.  You can also use your own data.\n\n## 4. Preprocessing\nIn Mixpoet/preprocess/, just run:\n```\npython preprocess.py --n 150000\n```\nThe parameter *n* indicates the number of unlabelled instances to be used for semi-supervised training. When one uses the provided sampled CQCF set, we recommend *n* is about 150,000. With a larger labelled dataset, one can set a larger *n*.\n\nAfter running preprocess.py, please move the generated vocab.pickle, ivocab.pickle, semi_train.pickle and semi_valid.pickle into *MixPoet/corpus/*,  and move test_inps.txt and training_lines.txt into *MixPoet/data/*.\n\n## 5. Training\nIn MixPoet/codes/, run:\n```\npython train.py\n```\nThe encoder and decoder will be pre-trained as a denoising autoencoder, and the classifiers will be pre-trained with the labelled poems. Then the MixPoet model is trained based on these pre-trained modules.\n\nOne can also edit MixPoet/codes/**config.py**  to modify the configuration, such as the hidden size, embedding size, data path, training epoch, learning rate and so on.\n\nDuring the training process, some training information is outputed, such as:\n\n\u003cdiv align=center\u003e\u003cimg width=\"81%\" height=\"81%\" src=\"pictures/p3.png\"/\u003e\u003c/div\u003e\n\nThe training and validation information is saved in MixPoet/log/.\n\n## 6. Generation\nTo generate a poem in an interactive interface, in MixPoet/codes/, run:\n```\npython generate.py -v 1\n```\nThen one can input the keyword, length and factor labels, and then get the generated pome:\n\n\u003cdiv align=center\u003e\n\u003cimg width=\"70%\" height=\"70%\" src=\"pictures/p5.png\"/\u003e\n\u003cimg width=\"70%\" height=\"70%\" src=\"pictures/p6.png\"/\u003e\n\u003c/div\u003e\n\n\nBy running:\n```\npython generate.py -v 1 -s 1\n```\none can manually select each generated line from the beam candidates.\n\nTo generate poems with an input testing file, which contains a set of keywords, run:\n```\npython generate.py -m file -l 5 -i ../data/test_inps.txt -o outs_5char.txt\n```\nwhere l = 5 or 7, indicating the 5-char-line or 7-char-line quatrains.\n\n## 7. Cite\nIf you use our source code, please kindly cite this paper:\n\nXiaoyuan Yi, Ruoyu Li, Cheng Yang, Wenhao Li and Maosong Sun. 2020.  MixPoet: Diverse Poetry Generation via Learning Controllable Mixed Latent Space. In *Proceedings of The Thirty-Fourth AAAI Conference on Artificial Intelligence*, New York, USA.\n\nThe bib format is as follows:\n```\n@inproceedings{Mixpoet:20,\n    author  = {Xiaoyuan Yi and Ruoyu Li and Cheng Yang and Wenhao Li and Maosong Sun},\n    title   = {MixPoet: Diverse Poetry Generation via Learning Controllable Mixed Latent Space},\n    year    = \"2020\",\n    booktitle = {Proceedings of The Thirty-Fourth AAAI Conference on Artificial Intelligence},\n    address = {New York, USA}\n}\n```\n\n## 8. System\nThis work is a part of the automatic Chinese poetry generation system, [THUAIPoet (Jiuge, 九歌)](https://jiuge.thunlp.cn) developed by Research Center for Natural Language Processing, Computational Humanities and Social Sciences, Tsinghua University (清华大学人工智能研究院, 自然语言处理与社会人文计算研究中心). Please refer to [THUNLP](https://github.com/thunlp) and [THUNLP Lab](http://nlp.csai.tsinghua.edu.cn/site2/) for more information.\n\n\u003cdiv align=center\u003e\u003cimg width=\"190\" height=\"180\" src=\"pictures/logo.jpg\"/\u003e\u003c/div\u003e\n\n## 9. Contact\nIf you have any questions, suggestions or bug reports, please feel free to email yi-xy16@mails.tsinghua.edu.cn or mtmoonyi@gmail.com.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTHUNLP-AIPoet%2FMixPoet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FTHUNLP-AIPoet%2FMixPoet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTHUNLP-AIPoet%2FMixPoet/lists"}