huggingface / transformers

🤗 Transformers: State-of-the-art Machine Learning for Pytorch, TensorFlow, and JAX.
https://huggingface.co/transformers
Apache License 2.0
134.94k stars 27k forks source link

Bug in the question answering pipeline #6395

Closed elronbandel closed 4 years ago

elronbandel commented 4 years ago

Environment info

Information

The bug appears since transformers 3.0.1 but not before.

Model I am using distilbert-base-cased-distilled-squad:

The problem arises when using:

from transformers import pipeline model = "distilbert-base-cased-distilled-squad" qa_pipeline = pipeline( "question-answering", model=model, tokenizer=model, )

instance = { "question": "what is your product?", "context": " is an amazing new platform that help businesses of students from BarIlan University that are enthusiastic about conversational AI. The difference between our Sprybot platform and other chat bots is that constructing chat bot is a long and hard process and with Sprybot you can do it quickly and eaily. You can construct chatbot using our platform just by feeding textual description of you business that contain any details important for costumers. The time it takes to create a bot using our platform is the time takes you to describe your business. In order to create Sprybot we used natural language processing and state of the art deep learning artificial intelligence. At the moment you cant buy our product because its still under construction. Sprybot can answer questions about your business but it can not talk about anything else other than the information was fed to it." } qa_pipeline(instance)


Notice: little changes in the context text make the bug to not show up
## To reproduce

Steps to reproduce the behavior:

1. [fully reproduced on google colab](https://colab.research.google.com/drive/1YqamXA6qq8xxWXhq6VqEA9clHsEVW7sh?usp=sharing)

KeyError Traceback (most recent call last)

in () 4 } 5 ----> 6 qa_pipeline(instance) 1 frames /usr/local/lib/python3.6/dist-packages/transformers/pipelines.py in __call__(self, *args, **kwargs) 1314 ), 1315 } -> 1316 for s, e, score in zip(starts, ends, scores) 1317 ] 1318 /usr/local/lib/python3.6/dist-packages/transformers/pipelines.py in (.0) 1314 ), 1315 } -> 1316 for s, e, score in zip(starts, ends, scores) 1317 ] 1318 KeyError: 0 ``` ## Expected behavior get the qa pipline output with no errors
LysandreJik commented 4 years ago

Hi! This bug was patched on master. Can you install from source and let me know if this fixes your issue?

pip install git+https://github.com/huggingface/transformers

elronbandel commented 4 years ago

This fixed it! Thank you!