littlehacker26 / Discriminator-Cooperative-Unlikelihood-Prompt-Tuning

The code implementation of the EMNLP2022 paper: DisCup: Discriminator Cooperative Unlikelihood Prompt-tuning for Controllable Text Generation
25 stars 2 forks source link
controllable-text-generation prompt-tuning text-generation

DisCup

This repository contains code for the paper DisCup: Discriminator Cooperative Unlikelihood Prompt Tuning for Controllable Text Generation which is appeared at EMNLP2022. If you have any questions, please feel free to create an issue or contact the email of the first author: zhanghanqing@bit.edu.cn

Welcome to our new work, Controllable Text Generation with Residual Memory Transformer (RMT), which can be regarded as a updated version of DisCup.

Description of Main files

Dependence

After downloading the trained check-points, you also can directly jump to Controllable Text Generation, conducting text generation experiments.

Discriminator Training

It contains the training process of attribute-discriminator, and it is the premise of the DisCup.

Sentiment classifer training

Detoxic classifer training

Parameter Configuration

Control-prompt Tuning

It contains the training process of control-prompts for vanilla-prompt tuning and DisCup.

Sentiment control task

Detoxic task

Parameter Configuration

Controllable Text Generation

It contains the generation processes for vanilla-prompt and DisCup.

Sentiment control task

Detoxic task

Parameter Configuration

Evaluation:

Citation

@inproceedings{zhang-song-2022-discup,
    title = "{D}is{C}up: Discriminator Cooperative Unlikelihood Prompt-tuning for Controllable Text Generation",
    author = "Zhang, Hanqing  and
      Song, Dawei",
    booktitle = "Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing",
    month = dec,
    year = "2022",
    address = "Abu Dhabi, United Arab Emirates",
    publisher = "Association for Computational Linguistics",
    url = "https://aclanthology.org/2022.emnlp-main.223",
    pages = "3392--3406",
    abstract = "Prompt learning with immensely large Casual Language Models (CLMs) has been shown promising for attribute-controllable text generation (CTG). However, vanilla prompt tuning tends to imitate training corpus characteristics beyond the control attributes, resulting in a poor generalization ability. Moreover, it is less able to capture the relationship between different attributes, further limiting the control performance. In this paper, we propose a new CTG approach, namely DisCup, which incorporates the attribute knowledge of discriminator to optimize the control-prompts, steering a frozen CLM to produce attribute-specific texts. Specifically, the frozen CLM model, capable of producing multitudinous texts, is first used to generate the next-token candidates based on the context, so as to ensure the diversity of tokens to be predicted. Then, we leverage an attribute-discriminator to select desired/undesired tokens from those candidates, providing the inter-attribute knowledge. Finally, we bridge the above two traits by an unlikelihood objective for prompt-tuning. Extensive experimental results show that DisCup can achieve a new state-of-the-art control performance while maintaining an efficient and high-quality text generation, only relying on around 10 virtual tokens.",
}

The part of the code was built on top of All NLP Tasks Are Generation Tasks: A General Pretraining Framework.