• Stars
    star
    173
  • Rank 220,124 (Top 5 %)
  • Language
    Python
  • Created about 2 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

contrastive decoding

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;