Views
No views yet
1{
2 "response_to_event": "Yes" | "No",
3 "event_name": "string or null",
4 "country": "string or null",
5 "political_issue": "string or null"
6}Note: labels for event_name and political_issue are inherently noisy (free-text, long-tail), which is reflected in evaluation.
1from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
2import torch, json
3
4model_id = "https://huggingface.co/z-dickson/BART_political_event_detection"
5tok = AutoTokenizer.from_pretrained(model_id)
6model = AutoModelForSeq2SeqLM.from_pretrained(model_id).to("cuda" if torch.cuda.is_available() else "cpu")
7
8
9text = "Following the devastating floods in Slovenia, our party calls for stronger climate resilience measures."
10inputs = tok(text, return_tensors="pt").to(model.device)
11outputs = model.generate(**inputs, max_new_tokens=128)
12response = tok.decode(outputs[0], skip_special_tokens=True)
13response_json = json.loads(response)
14response_json
15
16{
17 "response_to_event": "Yes",
18 "event_name": "Floods in Slovenia",
19 "country": "Slovenia",
20 "political_issue": "Climate adaptation policy"
21}