question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AttributeError when running question answering models for result

See original GitHub issue
  • transformers 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

@LysandreJik

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:

  1. Just follow the code snippet given above

image

Expected behavior

{‘answer’: ‘a loan fraud case’, ‘end’: 250, ‘score’: 0.552571678161621, ‘start’: 276}

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
LysandreJikcommented, Sep 30, 2021

Thank you for raising this error! This indeed happens when the length is too long, great diagnosis @DeepP2667!

Putting @Narsil in cc

1reaction
tanish36commented, Oct 1, 2021

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 image

@LysandreJik @Narsil please look into this also and @DeepP2667 you can use downgrade the transformer version and use it for the time being

Read more comments on GitHub >

github_iconTop Results From Across the Web

AttributeError: 'module' object has no attribute 'model'
It's called models.Model and not models.model (case sensitive). Fix your Poll model like this - class Poll(models.Model): question = models.
Read more >
What to do when you get an error - Hugging Face Course
To do so, first log in by running either the following in a Jupyter notebook: ... An example of a question answering dataset...
Read more >
AttributeError: module 'typing' has no attribute '_ClassVar ...
That's a big part of the question. It works just fine on my local machine, but gives this error when run on my...
Read more >
BERT Fine-Tuning Tutorial with PyTorch - Chris McCormick
This post will explain how you can modify and fine-tune BERT to create a powerful NLP model that quickly gives you state of...
Read more >
AttributeError: module 'tensorflow.python.keras.utils' has no ...
I'm trying to run the code below in my Jupyter Notebook. I get: AttributeError: module 'tensorflow.python.keras.utils' has no attribute 'to_categorical'.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found