Semantic Role Labeling: Who Did What to Whom
Module: Natural Language Processing | Difficulty: Advanced
PropBank Args
SRL as Sequence Labeling
Evaluation
| Model | CoNLL-2012 F1 |
|---|---|
| BERT | 86.2 |
| RoBERTa | 88.5 |
import torch
import torch.nn as nn
class SRLModel(nn.Module):
def __init__(self, bert_model, n_roles):
super().__init__()
self.bert = bert_model
self.role_classifier = nn.Linear(768, n_roles)
def forward(self, input_ids, attention_mask):
outputs = self.bert(input_ids, attention_mask=attention_mask)
hidden = outputs.last_hidden_state
return self.role_classifier(hidden)
Research Insight: SRL provides shallow semantic understanding of text. Neural models improved SRL by 10+ F1 points by learning contextual representations. The key insight is that SRL benefits from pre-trained language models because argument structure is partially captured by language modeling.