Aspect-Based-Sentiment-Analysis icon indicating copy to clipboard operation
Aspect-Based-Sentiment-Analysis copied to clipboard

Getting error with basic first code

Open theoflaus opened this issue 3 years ago • 6 comments

Hi, I tried only the first lines of code that were :

import aspect_based_sentiment_analysis as absa

nlp = absa.load()
text = ("We are great fans of Slack, but we wish the subscriptions "
        "were more accessible to small startups.")

slack, price = nlp(text, aspects=['slack', 'price'])
assert price.sentiment == absa.Sentiment.negative
assert slack.sentiment == absa.Sentiment.positive

and got the following error :

Traceback (most recent call last): File "test_absa.py", line 3, in nlp = absa.load() File "C:\Users\theo.flaus\Anaconda3\envs\test\lib\site-packages\aspect_based_sentiment_analysis\loads.py", line 34, in load model = BertABSClassifier.from_pretrained(name, config=config) File "C:\Users\theo.flaus\Anaconda3\envs\test\lib\site-packages\transformers\modeling_tf_utils.py", line 2699, in from_pretrained model(model.dummy_inputs) # build the network with dummy inputs File "C:\Users\theo.flaus\Anaconda3\envs\test\lib\site-packages\keras\utils\traceback_utils.py", line 67, in error_handler raise e.with_traceback(filtered_tb) from None File "C:\Users\theo.flaus\Anaconda3\envs\test\lib\site-packages\aspect_based_sentiment_analysis\models.py", line 141, in call outputs = self.bert( ValueError: Exception encountered when calling layer "bert_abs_classifier" (type BertABSClassifier). The first argument to Layer.call must always be passed.

Call arguments received by layer "bert_abs_classifier" (type BertABSClassifier): • token_ids={'input_ids': 'tf.Tensor(shape=(3, 5), dtype=int32)'} • attention_mask=None • token_type_ids=None • training=False • bert_kwargs=<class 'inspect._empty'>

Any idea how to solve this ?

theoflaus avatar Nov 26 '22 15:11 theoflaus

Same here, any solutions?

klawicka avatar Jan 11 '23 12:01 klawicka

I got the same error. For me it was solved when I installed from the environment.yml. My problem in specific is that I had Python >3.7

octokami avatar Feb 06 '23 15:02 octokami

A bit late, but can confirm (at least for me) changing Python version immediately fixed the issue.

To create a new virtual environment with Python version 3.6 in Jupyter Notebook, take a look at this.

This is what it looks like for me: image

VedantNemane avatar Mar 28 '23 13:03 VedantNemane

I am unable to install python version 3.6 on jupyter notebook colab. I get an error like this image Any ideas why this might be the case? @VedantNemane

sudip-modi avatar Dec 30 '23 17:12 sudip-modi

@VedantNemane I installed 3.6.13 venv on pycharm and that can deal with the installation at least. btw 3.6.8 and 3.6.10 didn't help installing this package. Thanks for the guide!

morinstar avatar Jan 10 '24 08:01 morinstar

for me error is : RecursionError: maximum recursion depth exceeded in instancecheck

gyanendrarawat avatar Jun 10 '24 19:06 gyanendrarawat