-
Notifications
You must be signed in to change notification settings - Fork 31.2k
Overload pipeline to return the appropriate type for a task #26125
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
Conversation
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. |
|
cc @Narsil |
|
I do understand where this is coming from, and I do agree the pipeline object is quite complex, having some helps from LSP would be super nice ! I am a big hater of overload. I would much more strongly advocate having independant functions, or much better yet IMO, simple low level code that would make everything obvious. Wouldn't |
I had no idea beforehand that pipeline would return an AutomaticSpeechRecognition object though. Our users would not know this either. If pipeline is the core object that transformers runs all of its predictions through, I really would like to know through my IDE what arguments I can pass to it, in what format. Right now, it's
Here we are only changing the signature, there is still only one function body. We can even add a test to make sure none of the overloads diverge from the main implementation. And the overloads can be put in another file / cleaned up, made this PR to start the discussion. |
The thing is, throughout our docs and existing code, the format that is used and encouraged is: |
➕ on this, unleashing the full potential of pipelines would be great and not requiring to go only is good for devs. But yes let's find a great solution that is easy to maintain! |
|
I could add CI tests that ensure that no overloaded |
|
are there any other comments/suggestions @ArthurZucker @Narsil ? |
|
I think I am fine with adding a check for this yes! |
|
Commenting here as there's a related open PR regarding #27275 and the use of overloads for types. Previously a similar proposal was very strongly rejected (comment and PR) and I agree with @Narsil's comments. I'm generally against introducing overloads. However, this does seem to be an issue which is raised by many independent community members and finding an easy to maintain alternative we can agree on would be good. Perhaps we can open an issue to discuss addressing this more generally? |
|
This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread. Please note that issues that do not follow the contributing guidelines are likely to be ignored. |

Previously, if I use the pipeline method, e.g.
transcriber = pipeline("automatic-speech-recognition", model="openai/whisper-base.en"), the type hinting assumestranscriberis a genericPipelineobject. This means I get no help from editor to get any of the documentation for the specific arguments I can pass to this type of pipeline, the AutomaticSpeechRecognitionPipeline. I have to open my browser and search the internet to see what inputs the pipeline accepts in what format, etc.Fixed this by overloading the return type based on the task passed to the constructor. Makes everything much easier to use for our end users!