--- license: apache-2.0 datasets: - ltg/norec language: - 'no' pipeline_tag: token-classification model-index: - name: SSA-Perin results: - task: type: structured sentiment analysis dataset: name: NoReC type: NoReC metrics: - name: Unlabeled sentiment tuple F1 type: Unlabeled sentiment tuple F1 value: 44.12% - name: Target F1 type: Target F1 value: 56.44% - name: Relative polarity precision type: Relative polarity precision value: 93.19% --- We here release a pretrained model (and an easy-to-run wrapper) for structured sentiment analysis of Norwegian text, pre-trained on the [NoReC_fine dataset](https://github.com/ltgoslo/norec_fine). This is an implementation of the method described in the paper [Direct parsing to sentiment graphs](https://aclanthology.org/2022.acl-short.51/) by Samuel et al., 2022. To see a demo of how it works, you can try the model in a [Hugging Face Space](https://huggingface.co/spaces/ltg/ssa-perin). ## Example usage The model attempts to identify the following components for a given sentence: source expressions (the opinion holder), target expressions (what the opinion is directed towards), polar expressions (the part of the text indicating that an opinion expressed), and finally the polarity (positive or negative). For more information about the definition of these concepts, please the paper [A Fine-grained Sentiment Dataset for Norwegian](https://aclanthology.org/2020.lrec-1.618/) by Øvrelid et al. 2020. For each identified expression, the character offsets in the text are also provided. Here is an eaxmple showing to use the model for predicting such sentiment tuples: ```python >>> import model_wrapper >>> model = model_wrapper.PredictionModel() >>> model.predict(['vi liker svart kaffe']) [{'sent_id': '0', 'text': 'vi liker svart kaffe', 'opinions': [{'Source': [['vi'], ['0:2']], 'Target': [['svart', 'kaffe'], ['9:14', '15:20']], 'Polar_expression': [['liker'], ['3:8']], 'Polarity': 'Positive'}]}] ``` ## Details about the model configuration The method proposed by Samuel et al. 2022 suggests three different ways to encode the sentiment graph: "node-centric", "labeled-edge", and "opinion-tuple". The model released here - uses "labeled-edge" graph encoding, - does not use character-level embedding, - all other hyperparameters are set to [default values](https://github.com/jerbarnes/direct_parsing_to_sent_graph/blob/main/perin/config/edge_norec.yaml), - is trained on top of underlying masked language model [NorBERT 2](https://huggingface.co/ltg/norbert2). It achieves the following results on the held-out test set of NoReC_fine: | Unlabeled sentiment tuple F1 | Target F1 | Relative polarity precision | |:----------------------------:|:----------:|:---------------------------:| | 0.434 | 0.541 | 0.926 | The scripts used for training can be found on the [github](https://github.com/jerbarnes/direct_parsing_to_sent_graph) repository accompanying the paper by Samuel et al., 2022. ## Quote us If you use this model in your academic work, please quote the following paper: ```bibtex @inproceedings{samuel2022, title={Direct parsing to sentiment graphs}, author={David Samuel and Jeremy Barnes and Robin Kurtz and Stephan Oepen and Lilja Øvrelid and Erik Velldal}, year={2022}, booktitle = "Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics", address = "Dublin, Ireland" } ```