Call to pipeline.predict() fails
See original GitHub issueSystem Info
transformers
version: 4.21.1- Platform: macOS-12.5.1-arm64-arm-64bit
- Python version: 3.9.12
- Huggingface_hub version: 0.2.1
- PyTorch version (GPU?): 1.12.1 (False)
- Tensorflow version (GPU?): 2.9.2 (False)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using GPU in script?: No
- Using distributed or parallel set-up in script?: No
Who can help?
Information
- The official example scripts
- My own modified scripts
Tasks
- An officially supported task in the
examples
folder (such as GLUE/SQuAD, …) - My own task or dataset (give details below)
Reproduction
Execute the following piece of code resulted in an exception that is pasted below.
from transformers import pipeline
pipe = pipeline("text-classification")
print(pipe.predict(["This restaurant is awesome"]))
Exception:
Traceback (most recent call last):
File "pipeline_test.py", line 5, in <module>
print(pipe.predict(["This restaurant is awesome"]))
File "miniconda3/envs/mlflow-py3.9/lib/python3.9/site-packages/transformers/pipelines/base.py", line 840, in predict
return self(X=X)
File "miniconda3/envs/mlflow-py3.9/lib/python3.9/site-packages/transformers/pipelines/text_classification.py", line 138, in __call__
result = super().__call__(*args, **kwargs)
TypeError: __call__() missing 1 required positional argument: 'inputs'
Expected behavior
Successful predictions as shown below
[{'label': 'POSITIVE', 'score': 0.9998743534088135}]
Proposed fix
I dig a bit deeper into the implementation based on the exception and found out that this change fixes the issue. If this indeed a fix, I am happy to create a PR.
Issue Analytics
- State:
- Created a year ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Pipeline Sklearn ( missing basic ) Predictions Error
This dataset is KC Housing Dataset from Kaggle. I am trying to build a simple Linear regression , using Pipelines. However, I am...
Read more >sklearn Pipeline
Call transform of each transformer in the pipeline. The transformed data are finally passed to the final estimator that calls predict method.
Read more >Error getting prediction explanation using shap_values ...
I am building an NLP model to predict language type (C/C++/C#/Python...) for a given code. Now I need to provide an explanation for...
Read more >Getting online predictions with scikit-learn - AI Platform
You can deploy and serve scikit-learn pipelines on AI Platform Prediction. ... your request to create an AI Platform Prediction model version fails....
Read more >How to Improve Machine Learning Code Quality with Scikit ...
The Scikit-learn library has tools called Pipeline and ... Our goal is to predict whether a candidate will change jobs based on their ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks ! Again as I said, this is very old code maybe it broke a long time ago already and your PR is good (and we probably need to add a test to make sure we don’t break again).
Hi @Narsil ,
This is exactly what happens in Pipeline’s predict method. I would rather prefer to fix the issue at the source than creating a workaround.
I understand your concern regarding breaking changes. however I believe, this change is not going to be a breaking change, and the predict function is not usable in its current state.
I will go ahead and create a PR. Prior to that I will run all the tests to make sure, the fix does not introduce any breaking changes. Let us see how it rolls 😃
Thanks for the response.