🚀 Swedish BERT Models for Sentiment Analysis
Recorded Future and AI Sweden jointly release two Swedish language models for sentiment analysis, fine - tuned from an existing Swedish model to handle multi - label sentiment analysis tasks.
🚀 Quick Start
Recorded Future, in collaboration with AI Sweden, has released two language models for sentiment analysis in Swedish. These two models are based on the [KB/bert - base - swedish - cased](https://huggingface.co/KB/bert - base - swedish - cased) model and have been fine - tuned to address a multi - label sentiment analysis task.
The models have been fine - tuned for the sentiments of fear and violence. They output three floats corresponding to the labels "Negative", "Weak sentiment", and "Strong Sentiment" at the respective indexes.
The models are trained on Swedish data with a conversational focus, collected from various internet sources and forums. Note that these models are only trained on Swedish data and only support the inference of Swedish input texts. The inference metrics for all non - Swedish inputs are not defined, and such inputs are considered out - of - domain data.
The current models are supported at Transformers version >= 4.3.3 and Torch version 1.8.0. Compatibility with older versions has not been verified.
✨ Features
Swedish - Sentiment - Fear
The model can be imported from the transformers library by running:
from transformers import BertForSequenceClassification, BertTokenizerFast
tokenizer = BertTokenizerFast.from_pretrained("RecordedFuture/Swedish - Sentiment - Fear")
classifier_fear = BertForSequenceClassification.from_pretrained("RecordedFuture/Swedish - Sentiment - Fear")
Once the model and tokenizer are initialized, the model can be used for inference.
Sentiment Definitions
Strong Sentiment
The strong sentiment includes but is not limited to texts that:
- Hold an expressive emphasis on fear and/or anxiety
Weak Sentiment
The weak sentiment includes but is not limited to texts that:
- Express fear and/or anxiety in a neutral way
Verification Metrics
During training, the model had maximized validation metrics at the following classification breakpoint:
Classification Breakpoint |
F - score |
Precision |
Recall |
0.45 |
0.8754 |
0.8618 |
0.8895 |
Swedish - Sentiment - Violence
The model can be imported from the transformers library by running:
from transformers import BertForSequenceClassification, BertTokenizerFast
tokenizer = BertTokenizerFast.from_pretrained("RecordedFuture/Swedish - Sentiment - Violence")
classifier_violence = BertForSequenceClassification.from_pretrained("RecordedFuture/Swedish - Sentiment - Violence")
Once the model and tokenizer are initialized, the model can be used for inference.
Sentiment Definitions
Strong Sentiment
The strong sentiment includes but is not limited to texts that:
- Reference highly violent acts
- Hold an aggressive tone
Weak Sentiment
The weak sentiment includes but is not limited to texts that:
- Include general violent statements that do not fall under the strong sentiment
Verification Metrics
During training, the model had maximized validation metrics at the following classification breakpoint:
Classification Breakpoint |
F - score |
Precision |
Recall |
0.35 |
0.7677 |
0.7456 |
0.791 |
📄 License
This project is released under the MIT license.