Fix ClapProcessor to merge feature_extractor output into the returned BatchEncoding #31767
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Info
transformers
version: 4.42.3Problem
CLAP examples break for fused models. The
ClapModel.__call__
implementation for fused models requires the is_longer argument to be set, but currently ClapProcessor only sets input_features, resulting in a NoneType error. See the following MWE and stacktrace:Note that if you pull from
'laion/clap-htsat-unfused'
instead, the code runs fine.Fix
Merge the output of the feature extractor rather than set individual keys.
This will break if
ClapFeatureExtractor.__call__
returns something that can't be unpacked into the kwargs ofClapModel.__call__
. However, I think it's reasonable to expect the outputs ofClapFeatureExtractor.__call__
to always constitute valid inputs toClapModel.__call__
.@ArthurZucker