littlehacker26/Discriminator-Cooperative-Unlikelihood-Prompt-Tuning

★ 27⑂ 2

The code implementation of the EMNLP2022 paper: DisCup: Discriminator Cooperative Unlikelihood Prompt-tuning for Controllable Text Generation

About littlehacker26/Discriminator-Cooperative-Unlikelihood-Prompt-Tuning

littlehacker26/Discriminator-Cooperative-Unlikelihood-Prompt-Tuning is an open-source project on GitHub, mainly written in Python. The code implementation of the EMNLP2022 paper: DisCup: Discriminator Cooperative Unlikelihood Prompt-tuning for Controllable Text Generation It currently holds 27 stars and 2 forks with 0 open issues, and was last pushed on an unknown date (repository created unknown).

Project Overview

AI Homed tracks it on the Today's Trending board.

GitHub Repository Details

Repository littlehacker26/Discriminator-Cooperative-Unlikelihood-Prompt-Tuning · default branch - · size 0 KB · watchers 0 · source: GitHub REST API and repository README

README

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:

you can refer to sentiment_classifier.ipynb, and evaluate the correctness and PPL of your generated csv file. Then, you can convert the csv file to txt, using the function save_csv_to_text, so as to run the evaluate.py to obtain the results of dist-1/2/3 and and domain keyword coverage. you could test the toxicity prob with the Google API, the measurement of dist-1/2/3 and PPL is same as sentiment control task.

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.

GitHub Stars & Activity

27Stars
2Forks
0Open issues
PythonLanguage

GitHub Popularity

GitHub stars27
Forks2
Open issues0
Primary languagePython
License-
Stars gained today0
Created-
Last pushed-

Trending History

Trending statusnot on today's boards

Related AI Projects

1

Significant-Gravitas / AutoGPT

Python★ 187,469⑂ 46,006▲ 27 stars
2

docling-project / docling

Python★ 67,466⑂ 4,869▲ 585 stars
3

openai / openai-python

Python★ 31,666⑂ 5,904▲ 6 stars
4

harvard-edge / cs249r_book

Python★ 28,390⑂ 3,591▲ 28 stars
5

browser-use / browser-harness

Python★ 17,893⑂ 1,750▲ 87 stars
6

FareedKhan-dev / train-llm-from-scratch

Python★ 10,474⑂ 1,450▲ 265 stars
7

zhouxiaoka / autoclip

Python★ 7,934⑂ 1,551▲ 395 stars
8

More AI Rankings