Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Sentiment Analysis (RoBERTa) Prediction Error #5202

Closed
ericluo04 opened this issue May 14, 2021 · 3 comments
Closed

Sentiment Analysis (RoBERTa) Prediction Error #5202

ericluo04 opened this issue May 14, 2021 · 3 comments
Labels

Comments

@ericluo04
Copy link

ericluo04 commented May 14, 2021

Hello! I'm working in a google colab notebook and find the below error when trying to predict using the RoBERTa pretrained sentiment analysis model:

---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-9-ad5209ed4732> in <module>()
      1 # load sentiment analysis model
      2 predictor = Predictor.from_path("https://storage.googleapis.com/allennlp-public-models/stanford-sentiment-treebank-roberta.2021-03-11.tar.gz")
----> 3 predictor.predict("a very well-made, funny and entertaining picture.")

3 frames
/usr/local/lib/python3.7/dist-packages/allennlp_models/classification/dataset_readers/stanford_sentiment_tree_bank.py in text_to_instance(self, tokens, sentiment)
    113         """
    114         assert isinstance(
--> 115             tokens, list
    116         )  # If tokens is a str, nothing breaks but the results are garbage, so we check.
    117         if self._tokenizer is None:

AssertionError:

My package installation code is:

# upgrade nltk
!pip install -U nltk

# AllenNLP (SOTA NLP)
!pip install allennlp==2.1.0 allennlp-models==2.1.0
from allennlp.predictors.predictor import Predictor
import allennlp_models.tagging

Running this code (straight from the documentation) produces the mentioned error:

# load sentiment analysis model
predictor = Predictor.from_path("https://storage.googleapis.com/allennlp-public-models/stanford-sentiment-treebank-roberta.2021-03-11.tar.gz")
predictor.predict("a very well-made, funny and entertaining picture.")

The model itself seems to load but the predictions throw an unidentified error. Any help would be much appreciated - thanks so much!

@ericluo04 ericluo04 added the bug label May 14, 2021
@epwalsh
Copy link
Member

epwalsh commented May 17, 2021

Can you try updating AllenNLP to 2.4.0?

@AkshitaB
Copy link
Contributor

@ericluo04 As @epwalsh mentioned, the issue seems to be resolved in later versions. The instructions on the demo should be updated with: allenai/allennlp-models#264

@ericluo04
Copy link
Author

Updating fixed the issue. Thanks so much @epwalsh @AkshitaB!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants