XiangLi1999 / ContrastiveDecoding

contrastive decoding

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Contrastive Decoding

Contrastive Decoding: Open-ended Text Generation as Optimization

Arxiv Link: https://arxiv.org/abs/2210.15097


Setup

pip install -e transformers 

Run contrastive decoding on a specified prompt:

cd text-generation; 

python run_generation.py --model_name_or_path gpt2-xl --model_type gpt2 --length 256 --prompt "<|endoftext|> A version of Sonic the Hedgehog was developed by Ancient and released in 1991" --student_name_or_path gpt2 --st_coef 1.0   --student_temperature 0.5  --outfile outputs/temp_out.json    --ignore_prefix no

Run contrastive decoding on dataset (see submit_decoding.py for detail):

python run_generation.py --model_name_or_path gpt2-xl --model_type gpt2 --length 256 --prompt_file wikitext --student_name_or_path gpt2 --st_coef 1.0   --student_temperature 0.5  --outfile outputs/temp_out.json    --ignore_prefix no

This code is used for producing all results in the paper. We will release a cleaner version of the code soon;

About

contrastive decoding


Languages

Language:Python 99.7%Language:Cuda 0.3%Language:C++ 0.0%Language:C 0.0%Language:Shell 0.0%