xiangli1999 / contrastivedecoding Goto Github PK
View Code? Open in Web Editor NEWcontrastive decoding
contrastive decoding
Hi, I am wondering how I can add new model into this repo like mistral and llama.
@XiangLi1999 Thanks for your great work!
I am trying to reproduce the results on wikitext but meet some problems.
I use your script:
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.jsonl --ignore_prefix no
And then evaluate the output file by:
python eval_script.py ./outputs/temp_out.jsonl
The output is
{'name': './outputs/temp_out.jsonl', 'rep-2': 9.5, 'rep-3': 1.87, 'rep-4': 0.4, 'diversity': 0.8845241939999999, 'mauve': 0.8812567264373257, 'coherence': 0.5913593170305366} (I disable other metrics)
which is different from reported results in the paper (coherence = 0.59 v.s. 0.69).
I find that ./outputs_ignorePrefix_ccnews_256/wikitext_results/wikitext_gpt2-1.0-t0.5_gpt2-xl_256.jsonl
can produces correct metric values. May I ask two questions:
wikitext_gpt2-1.0-t0.5_gpt2-xl_256.jsonl
mean? For example, 256 seems output length, 0.5 is student temperature. What does 1.0 indicate?Dear @XiangLi1999 and @ari-holtzman,
if I understand correctly the paper, in section 3.4, mentions that the amateur (student) model is conditioned on a context window which starts from the last token of the prompt. I cannot find any trace of such a choice in the code, for instance here and here the whole input is passed to the amateur model, as seen by the expert too.
I cannot find the relative study in the ablation script either.
Am I missing some argument/logic that sets the amateur's context window somewhere else in the code?
Best,
Marco
Seems no citation is given.
Thanks for open source the Contrastive Decoding, it is really an interest and smart method.
I found you have copied the whole Transformers library, and just changed around two files.
Why not use python dynamic binding to patch Transformers generation methods? I think it will be easier to maintain and debug.
e.g.
import torch
import transformers.generation_utils as gu
@torch.no_grad()
def generate(self, ...):
...
@torch.no_grad()
def sample(self, ...):
...
gu.GenerationMixin.generate = generate
gu.GenerationMixin.sample = sample
Hi @XiangLi1999 and @ari-holtzman,
Thanks for releasing your codebase and interesting work! I had a quick question about the --ignore_prefix
flag. Would you suggest setting this to yes
or no
? In the ablation experiments in Table 5, it seems like setting it to yes
was slightly better? However, the default setting in the README file is no
.
I was wondering how much this setting affects MAUVE score and quality, and what would you suggest?
Best Wishes,
Kalpesh
Hello @XiangLi1999 and @ari-holtzman,
I'm trying to follow the implementation of the typical decoding baselines in the code base.
Here a typical
argument is passed, but the generate method does not accept any such argument but only an optional argument typical_p
. At the same time I am unable to find any call to model_kwargs['"typical"]
anywhere so it seems no warping of the logits to do typical sampling is ever performed.
Am I missing something trivial?
@XiangLi1999 Hello there, I am trying to run your code as it is with the commands provided with no changes whatsoever, however, I am still getting the following error.
"ValueError: The following model_kwargs
are not used by the model: ['min_prob', 'student_lm', 'teacher_student', 'model_kwargs_student', 'st_coef', 'tokenizer', 'student_min_prob', 'student_temperature', 'use_cap_student', 'use_switch'] (note: typos in the generate arguments will also show up in this list)"
Can you help me with this? Is there any specific way to rectify this or am I supposed to simply drop these arguments from the parts where they are coded?
Hi, Lisa! Thanks for the great work and many thanks for releasing the code and data!
I just found the results of contrastive decoding can be a little different with different pytorch versions.
Could you please advise which specific pytorch version you were using when producing those *jsonl files?
Many thanks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.