AttributeError when running question answering models for result
See original GitHub issuetransformers
version: 4.11.1- Platform: Linux-5.4.104±x86_64-with-Ubuntu-18.04-bionic
- Python version: 3.7.12
- PyTorch version (GPU?): 1.9.0+cu102 (False)
- Tensorflow version (GPU?): 2.6.0 (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
I am using bert-multi-cased-finetuned-xquadv1 for question answering I was trying it with the example from the model repo website (https://huggingface.co/mrm8488/bert-multi-cased-finetuned-xquadv1)for the example given in the website it’s working fine but when I tried with custom input I fetched from the crawler it’s failing with the AttributeError: ‘list’ object has no attribute ‘tolist’
The problem arises when using:
from transformers import pipeline qa_pipeline = pipeline( “question-answering”, model=“mrm8488/bert-multi-cased-finetuned-xquadv1”, tokenizer=“mrm8488/bert-multi-cased-finetuned-xquadv1” ) qa_pipeline({ ‘context’: “Yes Bank founder Rana Kapoor has approached the Bombay High Court, challenging a special court’s order from August this year that had remanded him in police custody for a week in a multi-crore loan fraud case. Kapoor, who is currently lodged in Taloja Jail, is an accused in the loan fraud case and some related matters being probed by the CBI and Enforcement Directorate. A single bench presided over by Justice S K Shinde on Tuesday posted the plea for further hearing on October 14. In his plea filed through advocate Vijay Agarwal, Kapoor claimed that the special court’s order permitting the CBI’s request for police custody on August 14 was illegal and in breach of the due process of law. Therefore, his police custody and subsequent judicial custody in the case were all illegal. Kapoor has urged the High Court to quash and set aside the special court’s order dated August 14. As per his plea, in August this year, the CBI had moved two applications before the special court, one seeking permission to arrest Kapoor, who was already in judicial custody at the time in another case, and the other, seeking his police custody. While the special court refused to grant permission to the CBI to arrest Kapoor, it granted the central agency’s plea for his custody. Kapoor, however, said in his plea that before filing an application for his arrest, the CBI had not followed the process of issuing him a notice under Section 41 of the CrPC for appearance before it. He further said that the CBI had not taken prior sanction as mandated under section 17 A of the Prevention of Corruption Act for prosecuting him. The special court, however, had said in its order at the time that as Kapoor was already in judicial custody in another case and was not a free man the procedure mandated under Section 41 of the CrPC need not have been adhered to as far as issuing a prior notice of appearance was concerned. ADVERTISING It had also said that case records showed that the investigating officer had taken an approval from a managing director of Yes Bank before beginning the proceedings against Kapoor and such a permission was a valid sanction. However, Kapoor in his plea said that the above order was bad in law and sought that it be quashed and set aside. The law mandated that if initial action was not in consonance with legal procedures, then all subsequent actions must be held as illegal, he said, urging the High Court to declare the CBI remand and custody and all subsequent proceedings including the further custody as illegal and void ab-initio. In a separate plea before the High Court, Kapoor’s daughter Rakhee Kapoor-Tandon has sought exemption from in-person appearance before a special PMLA court. Rakhee has stated that she is a resident of the United Kingdom and is unable to travel to India owing to restrictions imposed due to the COVID-19 pandemic. According to the CBI, in the present case, Kapoor had obtained a gratification or pecuniary advantage of ₹ 307 crore, and thereby caused Yes Bank a loss of ₹ 1,800 crore by extending credit facilities to Avantha Group, when it was not eligible for the same”, ‘question’: “Is this person invovled in fraud?”
})
To reproduce
Steps to reproduce the behaviour:
- Just follow the code snippet given above
Expected behavior
{‘answer’: ‘a loan fraud case’, ‘end’: 250, ‘score’: 0.552571678161621, ‘start’: 276}
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (2 by maintainers)
Thank you for raising this error! This indeed happens when the length is too long, great diagnosis @DeepP2667!
Putting @Narsil in cc
So I was doing some more experiments and found that this works fine when I have installed transformer version 4.10.2 and 4.10.3
@LysandreJik @Narsil please look into this also and @DeepP2667 you can use downgrade the transformer version and use it for the time being