sileod / tasksource

Datasets collection and preprocessings framework for NLP extreme multitask learning
Apache License 2.0
147 stars 8 forks source link

Error when using model in HF pipeline #2

Closed assaftibm closed 1 year ago

assaftibm commented 1 year ago

Hi, Thanks for this great work.

I'm getting a type error when trying to use the model sileod/deberta-v3-base-tasksource-nli in a HF pipeline.

Could you please check?

Code to reproduce:

from transformers import pipeline

# Fails: TypeError: _batch_encode_plus() got an unexpected keyword argument 'candidate_labels'
model = "sileod/deberta-v3-base-tasksource-nli"

# Works:
# model = "facebook/bart-large-mnli"

pipe = pipeline(model=model)

print(pipe("I have a problem with my iphone that needs to be resolved asap!",
           candidate_labels=["urgent", "not urgent", "phone", "tablet", "computer"]))

The full exception log is:

Traceback (most recent call last):
  File "test.py", line 11, in <module>
    print(pipe("I have a problem with my iphone that needs to be resolved asap!",
  File "venv/lib/python3.9/site-packages/transformers/pipelines/text_classification.py", line 155, in __call__
    result = super().__call__(*args, **kwargs)
  File "venv/lib/python3.9/site-packages/transformers/pipelines/base.py", line 1119, in __call__
    return self.run_single(inputs, preprocess_params, forward_params, postprocess_params)
  File "venv/lib/python3.9/site-packages/transformers/pipelines/base.py", line 1125, in run_single
    model_inputs = self.preprocess(inputs, **preprocess_params)
  File "venv/lib/python3.9/site-packages/transformers/pipelines/text_classification.py", line 179, in preprocess
    return self.tokenizer(inputs, return_tensors=return_tensors, **tokenizer_kwargs)
  File "venv/lib/python3.9/site-packages/transformers/tokenization_utils_base.py", line 2548, in __call__
    encodings = self._call_one(text=text, text_pair=text_pair, **all_kwargs)
  File "venv/lib/python3.9/site-packages/transformers/tokenization_utils_base.py", line 2654, in _call_one
    return self.encode_plus(
  File "venv/lib/python3.9/site-packages/transformers/tokenization_utils_base.py", line 2727, in encode_plus
    return self._encode_plus(
  File "venv/lib/python3.9/site-packages/transformers/tokenization_utils_fast.py", line 500, in _encode_plus
    batched_output = self._batch_encode_plus(
TypeError: _batch_encode_plus() got an unexpected keyword argument 'candidate_labels'

As mentioned in the code above - the model facebook/bart-large-mnli works fine (uncomment the appropriate line to verify).

Output of transformers-cli env:

- `transformers` version: 4.29.2
- Platform: macOS-13.3.1-arm64-arm-64bit
- Python version: 3.9.6
- Huggingface_hub version: 0.14.1
- Safetensors version: not installed
- PyTorch version (GPU?): 2.0.1 (False)
- Tensorflow version (GPU?): not installed (NA)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using GPU in script?: <fill in>
- Using distributed or parallel set-up in script?: <fill in>

Thanks!

sileod commented 1 year ago

Thanks for the heads up, it now works again. I edited the model metadata but I didn't think it would impact the pipeline.