-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🤏 New models for tests #2287
🤏 New models for tests #2287
Conversation
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
self.assertListEqual(tokenized_dataset["prompt_input_ids"][0], [5377, 11141]) | ||
self.assertListEqual(tokenized_dataset["prompt_attention_mask"][0], [1, 1]) | ||
self.assertListEqual(tokenized_dataset["answer_input_ids"][0], [318, 1365, 621, 8253, 13]) | ||
self.assertListEqual(tokenized_dataset["prompt_input_ids"][0], [31137]) | ||
self.assertListEqual(tokenized_dataset["prompt_attention_mask"][0], [1]) | ||
self.assertListEqual(tokenized_dataset["answer_input_ids"][0], [374, 2664, 1091, 16965, 13]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tokenizer has changed, so these value have also changed.
self.assertListEqual(processed_dataset["prompt_input_ids"][0], [50256, 5377, 11141]) | ||
self.assertListEqual(processed_dataset["prompt_attention_mask"][0], [1, 1, 1]) | ||
self.assertListEqual(processed_dataset["prompt_input_ids"][0], [31137]) | ||
self.assertListEqual(processed_dataset["prompt_attention_mask"][0], [1]) | ||
self.assertListEqual( | ||
processed_dataset["completion_input_ids"][0], [50256, 5377, 11141, 318, 1365, 621, 8253, 13, 50256] | ||
) | ||
self.assertListEqual(processed_dataset["completion_attention_mask"][0], [1, 1, 1, 1, 1, 1, 1, 1, 1]) | ||
self.assertListEqual( | ||
processed_dataset["completion_labels"][0], [-100, -100, -100, 318, 1365, 621, 8253, 13, 50256] | ||
processed_dataset["completion_input_ids"][0], [31137, 374, 2664, 1091, 16965, 13, 151645] | ||
) | ||
self.assertListEqual(processed_dataset["completion_attention_mask"][0], [1, 1, 1, 1, 1, 1, 1]) | ||
self.assertListEqual(processed_dataset["completion_labels"][0], [-100, 374, 2664, 1091, 16965, 13, 151645]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tokenizer has changed, so this value has also changed.
tests/test_modeling_value_head.py
Outdated
"trl-internal-testing/tiny-random-BartForConditionalGeneration", | ||
"trl-internal-testing/tiny-random-BigBirdPegasusForConditionalGeneration", | ||
"trl-internal-testing/tiny-random-BlenderbotForConditionalGeneration", | ||
"trl-internal-testing/tiny-random-BlenderbotSmallForConditionalGeneration", | ||
"trl-internal-testing/tiny-random-FSMTForConditionalGeneration", | ||
"trl-internal-testing/tiny-random-LEDForConditionalGeneration", | ||
"trl-internal-testing/tiny-random-LongT5ForConditionalGeneration", | ||
"trl-internal-testing/tiny-random-M2M100ForConditionalGeneration", | ||
"trl-internal-testing/tiny-random-MarianMTModel", | ||
"trl-internal-testing/tiny-random-MBartForConditionalGeneration", | ||
"trl-internal-testing/tiny-random-MT5ForConditionalGeneration", | ||
"trl-internal-testing/tiny-random-MvpForConditionalGeneration", | ||
"trl-internal-testing/tiny-random-PegasusForConditionalGeneration", | ||
"trl-internal-testing/tiny-random-PegasusXForConditionalGeneration", | ||
"trl-internal-testing/tiny-random-PLBartForConditionalGeneration", | ||
"trl-internal-testing/tiny-random-ProphetNetForConditionalGeneration", | ||
"trl-internal-testing/tiny-random-SwitchTransformersForConditionalGeneration", | ||
"trl-internal-testing/tiny-random-T5ForConditionalGeneration", | ||
"qgallouedec/tiny-T5ForConditionalGeneration", | ||
"qgallouedec/tiny-BartModel", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only use the two most popular enc-dec models
self.model = AutoModelForCausalLM.from_pretrained(self.model_id) | ||
self.ref_model = AutoModelForCausalLM.from_pretrained(self.model_id) | ||
self.reward_model = AutoModelForSequenceClassification.from_pretrained("EleutherAI/pythia-14m", num_labels=1) | ||
self.reward_tokenizer = AutoTokenizer.from_pretrained("EleutherAI/pythia-14m") | ||
self.reward_tokenizer.chat_template = SIMPLE_CHAT_TEMPLATE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The model already have a chat template
self.t5_model = AutoModelForSeq2SeqLM.from_pretrained(model_id) | ||
self.t5_tokenizer = AutoTokenizer.from_pretrained(model_id) | ||
self.t5_tokenizer.chat_template = SIMPLE_CHAT_TEMPLATE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
T5 doesn't have a chat template
self.tokenizer = AutoTokenizer.from_pretrained(self.model_id) | ||
self.tokenizer.chat_template = "{% for message in messages %}{{'<|im_start|>' + message['role'] + '\n' + message['content'] + '<|im_end|>' + '\n'}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant\n' }}{% endif %}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The model already has a chat template
self.model = AutoModelForSequenceClassification.from_pretrained(self.model_id) | ||
self.model.config.pad_token_id = self.tokenizer.pad_token_id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needed for batched forward in the model
@@ -205,6 +205,7 @@ def setUp(self): | |||
ignore_index=self.ignore_index, | |||
) | |||
|
|||
@unittest.skip("This test must be updated.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test seems very related to the way the codellama/CodeLlama-7b-Instruct-hf tokenizer works (especially on BOS and EOS) and is not general. It should be rewritten in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That model is largely outdated in any case, so I would be fine to replace it with something more recent / standard like StarCoder2 or QwenCoder / DeepSeekCoder
tests/test_dpo_trainer.py
Outdated
["trl-internal-testing/tiny-random-paligemma"], | ||
["trl-internal-testing/tiny-random-llava-1.5"], | ||
("qgallouedec/tiny-Idefics2ForConditionalGeneration",), | ||
# ("qgallouedec/tiny-PaliGemmaForConditionalGeneration",), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
paligemma doesn't have a chat template (not meant for chat). We've to find a way to test it. Dedicated method? We can do it in the future
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent refactor and massive QoL improvements to the tests @qgallouedec! LGTM with a minor question about whether you want to distinguish between tiny base and instruct models
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For reference, we have a similar script in transformers
in case you want to see the generic case: https://github.com/huggingface/transformers/blob/a0f4f3174f4aee87dd88ffda95579f7450934fc8/utils/create_dummy_models.py#L1403
|
||
# Decoder models | ||
for model_id, config_class, model_class, suffix in [ | ||
("bigscience/bloomz-560m", BloomConfig, BloomForCausalLM, None), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After this PR is merged, I would be in favour of just relying on a small, curated set of popular architectures for our tests (e.g. Qwen / Mistral / Llama / Gemma) and remove all the rest where appropriate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, is this script supposed to be re-run whenever we add a model to the list? If so, I recommend adding a note either at the top of this script or in our contributor guide
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
of just relying on a small, curated set of popular architectures
Would you remove any model from this list?
supposed to be re-run whenever we add a model
Yes.
adding a note
I added a note in the script in c851842
|
||
|
||
def push_to_hub(model, tokenizer, suffix=None): | ||
model_class_name = model.__class__.__name__ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure it matters much, but this won't make a distinction between base and instruct models as they share the same class. If we don't care about this difference in our tests, no need to change it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I wasn't sure what to do about that. Most of our tests are based on Qwen2.5 in its instruct version. So I don't know how compatible the trainers are to non-instruct versions. Let's keep it like this for the moment.
@@ -205,6 +205,7 @@ def setUp(self): | |||
ignore_index=self.ignore_index, | |||
) | |||
|
|||
@unittest.skip("This test must be updated.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That model is largely outdated in any case, so I would be fine to replace it with something more recent / standard like StarCoder2 or QwenCoder / DeepSeekCoder
What does this PR do?
Fixes #2177
The models currently used for testing lack uniformity and practicality. Specifically:
trl-internal-testing
,facebook
,philschmid
,hf-internal-testing
, etc.).tiny-random-MistralForCausalLM
,dummy-GPT2-correct-vocab
,gpt2
,pythia-14m
).This PR introduces the following improvements:
trl-internal-testing
).When approved, I'll move every models into
trl-internal-testing
namespace (instead ofqgallouedec
). And probably remove all the old testing models intrl-internal-testing
.Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.