Dialogue Act Recognition: Understanding Conversational Structure
Module: Natural Language Processing | Difficulty: Advanced
Dialogue Acts
| Act | Example |
|---|---|
| Statement | "The weather is nice." |
| Question | "What time is it?" |
| Request | "Please close the door." |
| Agreement | "Yes, I agree." |
Classification
Hierarchical Model
import torch
import torch.nn as nn
class DialogueActClassifier(nn.Module):
def __init__(self, bert_model, n_acts):
super().__init__()
self.bert = bert_model
self.context_lstm = nn.LSTM(768, 256, batch_first=True)
self.classifier = nn.Linear(256, n_acts)
def forward(self, input_ids, attention_mask):
outputs = self.bert(input_ids, attention_mask=attention_mask)
cls_output = outputs.last_hidden_state[:, 0]
context_out, _ = self.context_lstm(cls_output.unsqueeze(1))
return self.classifier(context_out.squeeze(1))
Research Insight: Dialogue act recognition is essential for understanding conversational intent. The key insight is that dialogue acts are determined by both the utterance and the dialogue context. Models that use context outperform those that only use the current utterance by 10-15%.