Views
No views yet
1>>> from transformers import BertTokenizerFast
2>>> from .model import BertForTokenAndSequenceJointClassification
3>>>
4>>> tokenizer = BertTokenizerFast.from_pretrained('bert-base-cased')
5>>> model = BertForTokenAndSequenceJointClassification.from_pretrained(
6>>> "QCRI/PropagandaTechniquesAnalysis-en-BERT",
7>>> revision="v0.1.0",
8>>> )
9>>>
10>>> inputs = tokenizer.encode_plus("Hello, my dog is cute", return_tensors="pt")
11>>> outputs = model(**inputs)
12>>> sequence_class_index = torch.argmax(outputs.sequence_logits, dim=-1)
13>>> sequence_class = model.sequence_tags[sequence_class_index[0]]
14>>> token_class_index = torch.argmax(outputs.token_logits, dim=-1)
15>>> tokens = tokenizer.convert_ids_to_tokens(inputs.input_ids[0][1:-1])
16>>> tags = [model.token_tags[i] for i in token_class_index[0].tolist()[1:-1]]1@inproceedings{da-san-martino-etal-2019-fine,
2 title = "Fine-Grained Analysis of Propaganda in News Article",
3 author = "Da San Martino, Giovanni and
4 Yu, Seunghak and
5 Barr{\'o}n-Cede{\~n}o, Alberto and
6 Petrov, Rostislav and
7 Nakov, Preslav",
8 booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP)",
9 month = nov,
10 year = "2019",
11 address = "Hong Kong, China",
12 publisher = "Association for Computational Linguistics",
13 url = "https://www.aclweb.org/anthology/D19-1565",
14 doi = "10.18653/v1/D19-1565",
15 pages = "5636--5646",
16 abstract = "Propaganda aims at influencing people{'}s mindset with the purpose of advancing a specific agenda. Previous work has addressed propaganda detection at document level, typically labelling all articles from a propagandistic news outlet as propaganda. Such noisy gold labels inevitably affect the quality of any learning system trained on them. A further issue with most existing systems is the lack of explainability. To overcome these limitations, we propose a novel task: performing fine-grained analysis of texts by detecting all fragments that contain propaganda techniques as well as their type. In particular, we create a corpus of news articles manually annotated at fragment level with eighteen propaganda techniques and propose a suitable evaluation measure. We further design a novel multi-granularity neural network, and we show that it outperforms several strong BERT-based baselines.",
17}