Views
No views yet
1from transformers import pipeline
2
3model_id = "haukelicht/roberta-base-group-mention-detector-uk-manifestos"
4
5classifier = pipeline(task="ner", model=model_id, aggregation_strategy="simple")
6
7text = "Our party fights for the deprived and the vulnerable in our country."
8annotations = classifier(text)
9print(annotations)
10
11# get annotations' character start and end indexes
12locations = [(anno['start'], anno['end']) for anno in annotations]
13locations
14
15# index the source text using first annotation as an example
16loc = locations[0]
17text[slice(*loc)]| type | seq-eval F1 | soft seq-eval F1 | sentence level F1 |
|---|---|---|---|
| social group | 0.718 | 0.775 | 0.938 |
| political group | 0.925 | 0.933 | 0.990 |
| political institution | 0.706 | 0.736 | 0.954 |
| organization, public institution, or collective actor | 0.609 | 0.605 | 0.931 |
| implicit social group reference | 0.697 | 0.600 | 0.951 |