This model uses GloVe embeddings and is trained on the binary classification setting of the Stanford Sentiment Treebank. It achieves about 87% on the test set.
Explore live Sentiment Analysis demo at AllenNLP.
from allennlp_models.pretrained import load_predictor
predictor = load_predictor("glove-sst")
sentence = "This film doesn't care about cleverness, wit or any other kind of intelligent humor."
preds = predictor.predict(sentence)
print(f"p(positive)={preds['probs'][0]:.2%}")
# prints: p(positive)=15.60%
You can also get predictions using allennlp command line interface:
echo '{"sentence": "This film doesn'\''t care about cleverness, wit or any other kind of intelligent humor."}' | \
allennlp predict https://storage.googleapis.com/allennlp-public-models/basic_stanford_sentiment_treebank-2020.06.09.tar.gz -
To evaluate the model on Stanford Sentiment Treebank run:
allennlp evaluate https://storage.googleapis.com/allennlp-public-models/basic_stanford_sentiment_treebank-2020.06.09.tar.gz \
https://allennlp.s3.amazonaws.com/datasets/sst/test.txt
To train this model you can use allennlp
CLI tool and the configuration file basic_stanford_sentiment_treebank.jsonnet:
allennlp train basic_stanford_sentiment_treebank.jsonnet -s output_dir
See the AllenNLP Training and prediction guide for more details.
BENCHMARK | MODEL | METRIC NAME | METRIC VALUE | GLOBAL RANK |
---|---|---|---|---|
SST-2 Binary classification | GLoVe-LSTM | Accuracy | 87% | # 2 |