uber-research/PPLM has 1,154 GitHub stars and 204 forks. GitHot measured 0 stars in 24 hours and 0 in 7 days. Last checked 2026-11-13 18:56 UTC. Last push 2024-02-20.
측정된 스타 증가
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 기록 수집 중
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
소개
Plug and Play Language Model implementation. Allows to steer topic and attributes of GPT-2 models.
머신러닝README.md
OriginalPPLM
This repository contains code to run the Plug and Play Language Model (PPLM), as described in this blog post and arXiv paper. A demo and Colab notebook are also available.
Note: If you are planning on using PPLM as a baseline, and would like to use the parameters listed in the paper's Appendix, please use the LM and the discriminator from this folder. Alternatively, tune the hyperparamters on your own if you are using the code/models in the main directory and/or the 🤗/Transformers for a fair comparison (the optimal parameters for these models/discriminators are roughly off by a factor of 5 from those used in the paper).
PPLM is also integrated into the 🤗/Transformers repository.

Plug and Play Language Models: a Simple Approach to Controlled Text Generation
Authors: Sumanth Dathathri, Andrea Madotto, Janice Lan, Jane Hung, Eric Frank, Piero Molino, Jason Yosinski, and Rosanne Liu
PPLM allows a user to flexibly plug in one or more tiny attribute models representing the desired steering objective into a large, unconditional language model (LM). The method has the key property that it uses the LM as is—no training or fine-tuning is required—which enables researchers to leverage best-in-class LMs even if they do not have the extensive hardware required to train them.
See also our arXiv paper, blog post, and try it out for yourself with no setup using the Colab notebook.
Setup
pip install -r requirements.txt
Citation
@inproceedings{
Dathathri2020Plug,
title={Plug and Play Language Models: A Simple Approach to Controlled Text Generation},
author={Sumanth Dathathri and Andrea Madotto and Janice Lan and Jane Hung and Eric Frank and Piero Molino and Jason Yosinski and Rosanne Liu},
booktitle={International Conference on Learning Representations},
year={2020},
url={https://openreview.net/forum?id=H1edEyBKDS}
}
PPLM-BoW
Example command for bag-of-words control
python run_pplm.py -B military --cond_text "The potato" --length 50 --gamma 1.5 --num_iterations 3 --num_samples 10 --stepsize 0.03 --window_length 5 --kl_scale 0.01 --gm_scale 0.99 --colorama --sample
Tuning hyperparameters for bag-of-words control
Increase
--stepsizeto intensify topic control, and decrease its value to soften the control.--stepsize 0recovers the original uncontrolled GPT-2 model.If the language being generated is repetitive (For e.g. "science science experiment experiment"), there are several options to consider:
a) Reduce the--stepsize
b) Increase--kl_scale(the KL-loss coefficient) or decrease--gm_scale(the gm-scaling term)
c) Add--grad-length xxwhere xx is an (integer <= length, e.g.--grad-length 30).
PPLM-Discrim
Example command for discriminator based sentiment control
python run_pplm.py -D sentiment --class_label 2 --cond_text "My dog died" --length 50 --gamma 1.0 --num_iterations 10 --num_samples 10 --stepsize 0.04 --kl_scale 0.01 --gm_scale 0.95 --sample
Tuning hyperparameters for discriminator control
Increase
--stepsizeto intensify topic control, and decrease its value to soften the control.--stepsize 0recovers the original uncontrolled GPT-2 model.Use
--class_label 3for negative, and--class_label 2for positive
The discriminator and the GPT-2 model in the root directory are different from those used for the analysis in the paper. Code and models corresponding to the paper can be found here.
관련 프로젝트 살펴보기
tensorflow/tensorflow
모두를 위한 오픈소스 머신러닝 프레임워크
201,593 스타huggingface/transformers
🤗 Transformers: 텍스트, 비전, 오디오, 멀티모달 분야의 최첨단 머신러닝 모델을 위한 모델 정의 프레임워크로, 추론과 학습을 모두 지원합니다.
168,950 스타AUTOMATIC1111/stable-diffusion-webui
Stable Diffusion 웹 UI
165,305 스타Comfy-Org/ComfyUI
그래프와 노드로 구성된 인터페이스를 갖춘, 가장 강력하고 모듈성이 뛰어난 확산 모델 GUI, API, 백엔드입니다. 세계에서 가장 빠른 로컬 추론 엔진입니다.
146,687 스타