transformers/tests
Amir Mohammad Fakhimi 3314fe1760
Add validation for maximum sequence length in modeling_whisper.py (#33196)
* Add validation for maximum sequence length in modeling_whisper.py

Added a validation check to ensure that the sequence length of labels does not exceed the maximum allowed length of 448 tokens. If the sequence length exceeds this limit, a ValueError is raised with a descriptive error message.

This change prevents the model from encountering errors or unexpected behavior due to excessively long sequences during training or fine-tuning, ensuring consistent input dimensions and improving overall robustness.

* Change exception message in src/transformers/models/whisper/modeling_whisper.py

The exception message is for whisper's label's sequence max length.

Co-authored-by: Yoach Lacombe <52246514+ylacombe@users.noreply.github.com>

* Change 448 to config.max_target_positions in src/transformers/models/whisper/modeling_whisper.py

It's for whisper's config.max_target_positions.

Co-authored-by: Yoach Lacombe <52246514+ylacombe@users.noreply.github.com>

* Change method's documentation in src/transformers/models/whisper/modeling_whisper.py

* Add test for maximum label's sequence length in test_modeling_whisper.py

* Add self to modeling_whisper.py

* Update test_modeling_whisper.py with respect to automatic validations

* Update modeling_whisper.py with respect to ci/circleci: check_code_quality

* Update test_modeling_whisper.py with respect to ci/circleci: check_code_quality

* Update test_modeling_whisper.py with respect to ci/circleci: tests_generate

* Update test_modeling_whisper.py with respect to ci/circleci: tests_generate

* Update test_modeling_whisper.py with respect to ci/circleci: check_code_quality

* Separate test_labels_sequence_max_length tests in test_modeling_whisper.py

* Update test_modeling_whisper.py with respect to ci/circleci: check_code_quality

* Remove assert from test_modeling_whisper.py

* Add max_target_positions to WhisperModelTester in test_modeling_whisper.py

* Update test_modeling_whisper.py with respect to ci/circleci: check_code_quality

* Update test_modeling_whisper.py with respect to ci/circleci: tests_generate

* Update test_modeling_whisper.py

* Change test_labels_sequence_max_length_error_after_changing_config in test_modeling_whisper.py

* Change self.config.max_target_positions to self.max_target_positions modeling_whisper.py

* Add new tests in test_modeling_whisper.py

* Update test_modeling_whisper.py

---------

Co-authored-by: Yoach Lacombe <52246514+ylacombe@users.noreply.github.com>
2024-09-06 14:09:49 +02:00
..
agents Multi agents with manager (#32687) 2024-09-04 17:30:54 +02:00
benchmark
bettertransformer
deepspeed Revert PR 32299, flag users when Zero-3 was missed (#32851) 2024-08-16 12:35:41 -04:00
extended Skip tests properly (#31308) 2024-06-26 21:59:08 +01:00
fixtures
fsdp 🚨🚨🚨 Update min version of accelerate to 0.26.0 (#32627) 2024-08-20 11:42:36 +02:00
generation Fix: StaticCache & inputs_embeds (#32932) 2024-09-06 12:56:59 +05:00
models Add validation for maximum sequence length in modeling_whisper.py (#33196) 2024-09-06 14:09:49 +02:00
optimization fix: Fixed the 1st argument name in classmethods (#31907) 2024-07-11 12:11:50 +01:00
peft_integration
pipelines Add assistant prefill for chat templates and TextGenerationPipeline (#33198) 2024-09-02 13:23:47 +01:00
quantization Add Qwen2Moe GGUF loading support (#33264) 2024-09-05 17:42:03 +02:00
repo_utils Refactor CI: more explicit (#30674) 2024-08-30 18:17:25 +02:00
sagemaker Fixed log messages that are resulting in TypeError due to too many arguments (#32017) 2024-07-17 10:56:44 +01:00
tokenization #32184 save total_vocab_size (#32240) 2024-08-05 09:22:48 +02:00
trainer Only disallow DeepSpeed Zero-3 for auto bs finder (#31731) 2024-09-03 09:16:28 -04:00
utils support loading model without config.json file (#32356) 2024-09-06 13:49:47 +02:00
__init__.py
test_backbone_common.py
test_configuration_common.py Refactor: Removed un-necessary object base class (#32230) 2024-07-26 10:33:02 +02:00
test_feature_extraction_common.py
test_image_processing_common.py Update kwargs validation for preprocess with decorator (#32024) 2024-08-06 11:33:05 +01:00
test_image_transforms.py fix: center_crop occasionally outputs off-by-one dimension matrix (#30934) 2024-05-21 13:56:52 +01:00
test_modeling_common.py Llava Onevision: add model (#32673) 2024-09-05 14:43:20 +05:00
test_modeling_flax_common.py add sdpa to ViT [follow up of #29325] (#30555) 2024-05-16 10:56:11 +01:00
test_modeling_tf_common.py
test_pipeline_mixin.py Config: unified logic to retrieve text config (#33219) 2024-09-04 12:03:30 +01:00
test_processing_common.py Modify ProcessorTesterMixin for better generalization (#32637) 2024-08-13 11:48:53 -04:00
test_sequence_feature_extraction_common.py
test_tokenization_common.py Add assistant prefill for chat templates and TextGenerationPipeline (#33198) 2024-09-02 13:23:47 +01:00