-
Notifications
You must be signed in to change notification settings - Fork 27.5k
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
allow unused input parameters passthrough when chunking in asr pipelines #33889
allow unused input parameters passthrough when chunking in asr pipelines #33889
Conversation
cc @Rocketknight1 for pipelines and @ylacombe for ASR |
Hey @VictorAtIfInsurance, thanks for this PR! From a quick look, I think we'd rather raise an Error when some parameters are unused, rather than just passing them through. Especially because we want to avoid silent errors or mis-usages. For example, let's say I misspelled the much-used |
Hi, I should've marked this as WIP. The test is not setup for properly testing the intention of the PR, it should be unused inputs and not any unused parameter as is written in the test now. One of the reasons for this PR is inconsistent behaviour when passing chunking_length_s as a parameter to the pipeline. E.g. I wouldv'e expected the outputs from these two different pipe calls to have the same structure of the output, i.e. that the assert would pass,
But printing the outputs gives
I.e. the unused parameter in the input "survives" when not using chunking but is removed when using chunking. The behaviour from the non chunking pipeline call comes from this line, so would expect something similar for chunking as well
Where the behaviour of the non chunking pipeline is especially useful if you generate your input data through a generator where you can directly call the pipeline with the generator while also retrieve metadata returned from the generator, without the extra step of first retrieving the next item, and call the pipe separately. See example:
which prints
In these instances it wouldv'e been super useful to pass along the unused inputs. I hope this makes sense and that you agree with my intended behaviour. I will update the tests accordingly in that case, and sorry for posting unfinished code for review. |
2ebdb16
to
ac1116b
Compare
I've now added some code examples explaining my issue, and updated the test accordingly:) |
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.
Hey @VictorAtIfInsurance, this actually makes sense, especially since we pass extra parameters when we don't chunk.
I'm pretty sure it doesn't align with the pipeline philosophy though, and we could maybe ask @Rocketknight1's opinion on this!
I think keeping the output consistent with different input kwargs definitely fits with our philosophy! @VictorAtIfInsurance we're actually working on a project to standardize the inputs and outputs for our pipeline classes, to match an inference spec that will be common across lots of projects like TGI / transformers.js / etc. See this PR. If this PR makes the pipeline always compliant with the Hub output spec, then I'm definitely in favour of it! Can you:
Other than that this PR looks good to me. |
b39fbf7
to
4f43b4a
Compare
Hi, Thanks for the input. I rebased and added check against As i change the output from the pipeline call the test fails locally, which is to be expected since it doesn't follow the output structure. So this is probably not the way to go forward. Though then the non-chunk version of ASR pipeline has a problem on main, see the second assert in What would be the correct way to handle invalid kwargs using the new standardized inputs for pipelines. Raise an exception such as in Or maybe a warning would be better in that case as it could break backwards compatibility for the users? What would be the best next step here @ylacombe? I think consistence is important, but maybe my proposed change is not the way to go as it deviates from the standardized approach. |
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.
Hey @VictorAtIfInsurance, indeed it is not compatible with AutomaticSpeechRecognitionOutput
, that you can find here.
I think keeping the output consistent with different input kwargs definitely fits with our philosophy!
@Rocketknight1, I'm not sure to follow, AutomaticSpeechRecognitionOutput
are really constraining and some models (say Whisper
) might return many more output fields! How can we reconcile both?
@ylacombe It's okay for models to return many output fields, but we're trying to get the pipelines to have standardized inputs/outputs, so that they can fit into a standard inference API. However, in this case, the pipeline obviously has compliance issues already, as mentioned in #34087. I didn't realize this, I'm sorry! I don't think we should delay this PR because of issues in |
@ylacombe I've removed the compliance check in the test, making the test pass. Let me know if I should update anything more here. |
fd8d15f
to
ec1d73b
Compare
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. |
Rebased main as some tests failed due to missing files. |
1fd7168
to
9cdf43d
Compare
@Rocketknight1 Could we rerun the workflow? The last time it failed as I was missing some files from main, but now it should be rebased. |
@ylacombe are we ready for merge?:) |
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.
LGTM, let's rebase on main ?
9cdf43d
to
3835ade
Compare
Sure, though there were no merge conflicts |
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.
Very nice thanks!
@ylacombe would you mind merging this PR, I do not have write access to do it myself. |
Merged sorry for the wait! |
…nes (huggingface#33889) * allow unused parameter passthrough when chunking in asr pipelines * format code * format * run fixup * update tests * update parameters to pipline in test * updates parametrs in tests * change spelling in gitignore * revert .gitignore to main * add git ignore of devcontainer folder * assert asr output follows expected inference output type * run fixup * Remove .devcontainer from .gitignore * remove compliance check
…nes (huggingface#33889) * allow unused parameter passthrough when chunking in asr pipelines * format code * format * run fixup * update tests * update parameters to pipline in test * updates parametrs in tests * change spelling in gitignore * revert .gitignore to main * add git ignore of devcontainer folder * assert asr output follows expected inference output type * run fixup * Remove .devcontainer from .gitignore * remove compliance check
What does this PR do?
Harmonizing behaviour for what input data is passthrough automatic speech recognition pipelines.
Today you can get different return dictionaries keys when using ASR pipeline with and without the call parameter
chunk_length_s
. With this parameter you will only get a dictionary with the transformed input data, while omitting this parameter allows you to retrieve any unused input data parameter back in the resulting dictionary. This inconsistency can be confusing as sometimes you need to keep track of which inputs corresponds to which outputs, while it is not obvious to a user why.The following code snippet highlights these differences:
This will print the following and fail the assert.
Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
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.