Hugging Face model: MdRayhanEnuCC/bilstm_crf_pacific
Author: MdRayhanEnuCC
Created: 2026-02-12 23:43:57
Last modified: 2026-02-13 00:23:22
Pipeline: text-classification
Library: transformers
Likes: 0 | Downloads: 0
Tags: transformers, text-classification, en, base_model:google-bert/bert-base-uncased, base_model:finetune:google-bert/bert-base-uncased, license:afl-3.0, endpoints_compatible, region:us
Base model relation: finetune
Base models: id: google-bert/bert-base-uncased
Card metadata:
license: afl-3.0
language: en
metrics: accuracy, f1, precision, recall, roc_auc
base_model: google-bert/bert-base-uncased
pipeline_tag: text-classification
library_name: transformers
model: name: MuSIc-SIP
version: 1.0.0
type: Input-Incomplete Sequence Labeling
task: System Initiative Prediction
description: Predicts system initiative labels for the NEXT unseen system utterance
given only user utterances and past system responses.

CRITICAL: During inference, the target system utterance is COMPLETELY ABSENT
from input. The model's output IS the predicted label for this hidden utterance.

CRF Variant: DistanceCRF
Num classes: 2
Hidden size: 256
Lambda MLE: 0.1

[BERT] Loading /mnt/scratch/users/40645696/convqa_eval/bert-base-uncased...
[BERT] Loaded, hidden_size=768
[Prior BiLSTM] 768 → 1536 (bidirectional)
[Posterior BiLSTM] 768 → 1536 (bidirectional)
[MultiTurnCRF] Variant: DistanceCRF, Tags: 2
  Added Who2Who transitions
  Added initiative count transitions
  Added distance-based transitions

architecture: bert_encoder: type: HuggingFaceBERT
model_name: bert-base-uncased
output_dim: 768
pooling: [CLS] token
shared_weights: yes
description: Encodes each utterance into fixed-length representation
input: user_utterance: shape: 1, N, L
dtype: torch.long
description: User turn tokens [CLS] ... [SEP] [PAD]
system_utterance: shape: 1, N, L
dtype: torch.long
description: System turn tokens [CLS] ... [SEP] [PAD]
output: user_repr: shape: N, 768
dtype: torch.float
system_repr: shape: N, 768
dtype: torch.float
parameters: N: num_pairs - number of user-system exchanges
L: max_len - maximum token length (typically 32-128)
prior_encoder: type: BiLSTM
input_size: 768
hidden_size: 256
num_layers: 2
bidirectional: yes
dropout: 0.5
description: Processes PARTIAL conversation X₁:ₜ₋₁ for inference
input: shape: 1, seq_len, 768
seq_len: 2*(pair_idx) + 1 (missing system turn)
output: shape: 1, seq_len, 512
description: Concatenated forward/backward hidden states
posterior_encoder: type: BiLSTM
input_size: 768
hidden_size: 256
num_layers: 2
bidirectional: yes
dropout: 0.5
description: Processes FULL conversation X₁:ₜ for training only
input: shape: 1, seq_len, 768
seq_len: 2*(pair_idx+1) (complete turns)
output: shape: 1, seq_len, 512
emission_projections: prior: type: nn.Linear
in_features: 512
out_features: 2
description: Projects prior hidden states to emission scores
posterior: type: nn.Linear
in_features: 512
out_features: 2
description: Projects posterior hidden states to emission scores
crf_layer: type: MultiTurnCRF
num_tags: 2
description: Context-dependent transition matrices
matrices: global: name: matrice_all
shape: 2, 2
description: Overall transition probabilities (baseline)
role_based: enabled: yes
matrices: user_to_system: name: matrice_u2s
shape: 2, 2
description: Transition when User → System
system_to_user: name: matrice_s2u
shape: 2, 2
description: Transition when System → User
position_based: enabled: yes
num_matrices: 19
names: matrice_1_2, matrice_2_3, ..., matrice_19_20
shape: 2, 2
description: Transition depends on absolute turn position
initiative_count: enabled: yes
matrices: zero_initiatives: name: matrice_u2s_I0
shape: 2, 2
description: No system initiative before this turn
one_initiative: name: matrice_u2s_I1
shape: 2, 2
description: 1 system initiative before this turn
two_plus_initiatives: name: matrice_u2s_I2_more
shape: 2, 2
description: 2+ system initiatives before this turn
initiative_distance: enabled: yes
matrices: distance_2: name: matrice_u2s_Id2
shape: 2, 2
description: Distance = 2 (consecutive)
distance_4_plus: name: matrice_u2s_Id4_more
shape: 2, 2
description: Distance ≥ 4 (non-consecutive)
variants: VanillaCRF: description: Single global transition matrix
matrix_selection: bank[4][state['overall']]
total_parameters: 4
Who2whoCRF: description: Role-based transitions only
matrix_selection: bank[0][state['who2who']]
total_parameters: 8
PositionCRF: description: Position-based transitions only
matrix_selection: bank[1][state['position']]
total_parameters: 76
Who2who_PositionCRF: description: Role + Position (additive)
matrix_selection: bank[0][state['who2who']] + bank[1][state['position']]
total_parameters: 84
IntimeCRF: description: Role + Initiative count
matrix_selection: if state['who2who'] == 1: bank[0][1]
else: bank[2][state['Intime']]

total_parameters: 20
DistanceCRF: description: Role + Initiative count + Distance
matrix_selection: if state['who2who'] == 1: bank[0][1]
elif state['Intime'] == 0: bank[2][0]
else: bank[3][state['Distance']]

total_parameters: 22
operations: forward_algorithm: description: Compute total score (log-sum-exp over all paths)
equation: α_t = logsumexp(α_{t-1} + emission_t + transition)
complexity: O(T·N²) where N=2
viterbi_decoding: description: Find most likely label sequence
equation: δ_t(j) = max_i[δ_{t-1}(i) + transition(i,j)] + emission_t(j)
backpointers: Store argmax for backtracking
complexity: O(T·N²) where N=2
gold_score: description: Score of true label sequence
equation: ∑ emission(y_t) + ∑ transition(y_{t-1}, y_t | context_t)
modes: train: description: Model has access to ALL utterances (including future system)
input: required: user_utterance: shape: 1, N, L
present: yes
system_utterance: shape: 1, N, L
present: yes
description: FUTURE system utterance at turn T IS OBSERVED
user_labels: shape: 1, N
dtype: torch.long
present: yes
description: Ground truth user initiative labels
system_labels: shape: 1, N
dtype: torch.long
present: yes
description: Ground truth system initiative labels
process: step_1: Encode all utterances with BERT
step_2: Posterior encoder processes FULL conversation X₁:ₜ
step_3: Compute posterior emission scores for ALL turns
step_4: Prior encoder processes PARTIAL conversation X₁:ₜ₋₁
step_5: Compute prior emission score for turn T (approximation)
step_6: CRF computes gold_score (true path) and total_score (all paths)
step_7: MSE loss forces prior ≈ posterior at turn T
output: loss_crf: type: torch.Tensor
equation: mean(total_scores - gold_scores)
loss_mle: type: torch.Tensor
equation: MSE(prior_emission, posterior_emission[T].detach())
total_loss: type: torch.Tensor
equation: loss_crf + λ * loss_mle
lambda_default: 0.1
labels: status: ALL LABELS OBSERVED
system_turn_T: OBSERVED - used as target
inference: description: ⚠️ CRITICAL: System utterance at turn T is COMPLETELY ABSENT from input.
The model's output IS the predicted label for this hidden utterance.

input: required: user_utterance: shape: 1, N, L
present: yes
description: Current user turn IS observed
system_utterance: shape: 1, N, L
present: no
description: ❌ FUTURE system utterance at turn T IS HIDDEN
optional: user_labels: present: no
description: Not used during inference
system_labels: present: no
description: Not used during inference - these ARE the targets!
process: step_1: Encode observed utterances with BERT
step_2: Build partial sequence WITHOUT system_turn_T
step_3: Prior encoder processes X₁:ₜ₋₁ + user_turn_T only
step_4: Prior emission generates APPROXIMATION of missing system_turn_T
step_5: Posterior encoder processes known turns for history
step_6: Combine known emissions + prior emission (as if it were real)
step_7: Viterbi decoding finds most likely label sequence
step_8: Extract last label → THIS IS THE PREDICTION FOR HIDDEN SYSTEM
output: predictions: type: List[int]
shape: N
description: ⭐ PRIMARY OUTPUT: Predicted labels for EACH system turn.
For turn N, this is the model's guess for the UNSEEN system response.

probabilities: type: np.ndarray
shape: N, 2
description: Softmax probabilities for each class
confidences: type: List[float]
shape: N
description: Confidence score for each prediction (max probability)
labels: status: SYSTEM TURN T LABELS ARE HIDDEN - THESE ARE THE TARGETS
system_turn_T: ❌ NOT OBSERVED - model must PREDICT this
data_flow: training_sequence: stage: Input
tensors: user: [1, N, L] (torch.long) - Token IDs
system: [1, N, L] (torch.long) - Token IDs
user_labels: [1, N] (torch.long) - 0/1
system_labels: [1, N] (torch.long) - 0/1, stage: BERT Encoding
operation: utterance_encoder(user_flat)
transform: [N, L, 768] → [N, 768] (pooled), stage: Posterior BiLSTM
operation: posterior_encoder(seq_tensor)
transform: [1, 2*(pair_idx+1), 768] → [1, 2*(pair_idx+1), 512], stage: Posterior Emission
operation: posterior_emission_project(post_hidden)
transform: [2*(pair_idx+1), 512] → [2*(pair_idx+1), 2], stage: Prior BiLSTM
operation: prior_encoder(seq_tensor[:, :-1, :])
transform: [1, 2*pair_idx+1, 768] → [1, 2*pair_idx+1, 512], stage: Prior Emission
operation: prior_emission_project(prior_hidden[:, -1, :])
transform: [1, 512] → [1, 2], stage: CRF
operation: crf(emissions, labels, features)
outputs: gold_score, total_score, stage: Loss
operation: total_score - gold_score + λ·MSE(prior, posterior[T])
output: total_loss
inference_sequence: stage: Input
tensors: user: [1, N, L] (torch.long) - Token IDs
system: [1, N-1, L] (torch.long) - Past system responses ONLY
note: ❌ System_Turn_N is COMPLETELY ABSENT from input, stage: BERT Encoding
operation: utterance_encoder(flattened)
output: user_repr [N, 768], system_repr [N-1, 768], stage: Sequence Assembly
operation: build_partial_sequence(pair_idx)
output: [u₀, s₀, u₁, s₁, ..., u_pair_idx]
note: s_pair_idx is MISSING - this is the target we're predicting, stage: Prior BiLSTM
operation: prior_encoder(seq_tensor)
input: [1, 2*pair_idx+1, 768]
output: [1, 2*pair_idx+1, 512], stage: Prior Emission
operation: prior_emission_project(hidden[:, -1, :])
output: [1, 2] - APPROXIMATION of missing system_turn_T emission
note: This is a LEARNED guess of what the system's label would be, stage: Posterior BiLSTM (History)
operation: posterior_encoder(seq_tensor[:, :-1, :])
output: emissions for all KNOWN turns, stage: CRF Decoding
operation: crf.decode(combined_emissions, features)
algorithm: Viterbi - max over paths, stage: Output
operation: predictions[-1]
output: ⭐ PREDICTED LABEL FOR HIDDEN SYSTEM TURN_T
note: THIS IS THE MODEL'S OUTPUT - the label for the unseen future
baselines: VanillaCRF: class: VanillaCRF(MuSIcBase)
description: Single global transition matrix - standard linear-chain CRF
crf_variant: VanillaCRF
transition_matrices: 1
parameters: 4
training: sees_system_turn_T: yes
uses_labels: yes
inference: sees_system_turn_T: no
predicts_system_turn_T: yes
matrix_selection: bank[4][state['overall']]
Who2whoCRF: class: Who2whoCRF(MuSIcBase)
description: Role-based transitions only
crf_variant: Who2whoCRF
transition_matrices: 2
parameters: 8
matrix_selection: bank[0][state['who2who']]
PositionCRF: class: PositionCRF(MuSIcBase)
description: Position-based transitions only
crf_variant: PositionCRF
transition_matrices: 19
parameters: 76
matrix_selection: bank[1][state['position']]
Who2who_PositionCRF: class: Who2who_PositionCRF(MuSIcBase)
description: Role + Position (additive combination)
crf_variant: Who2who_PositionCRF
transition_matrices: 21
parameters: 84
matrix_selection: bank[0][state['who2who']] + bank[1][state['position']]
IntimeCRF: class: IntimeCRF(MuSIcBase)
description: Role + Initiative count history
crf_variant: IntimeCRF
transition_matrices: 5
parameters: 20
matrix_selection: if state['who2who'] == 1: bank[0][1]
else: bank[2][state['Intime']]

DistanceCRF: class: DistanceCRF(MuSIcBase)
description: Role + Initiative count + Initiative distance
crf_variant: DistanceCRF
transition_matrices: 7
parameters: 28
matrix_selection: if state['who2who'] == 1: bank[0][1]
elif state['Intime'] == 0: bank[2][0]
else: bank[3][state['Distance']]

hyperparameters: model: bert_model: bert-base-uncased
hidden_size: 256
num_layers: 2
dropout: 0.5
num_classes: 2
lambda_mle: 0.1
optimization: optimizer: AdamW
learning_rate: 2e-05
weight_decay: 0.01
scheduler: linear_warmup
warmup_steps: 0.1
training: batch_size: 1
epochs: 10
gradient_clip: 1
early_stopping_patience: 3
evaluation_metric: f1
crf_variants: VanillaCRF, Who2whoCRF, PositionCRF, Who2who_PositionCRF, IntimeCRF, DistanceCRF
diagnostic: name: MSE Loss
description: Prior-posterior agreement, name: CRF Loss
description: Sequence modeling quality, name: Confidence Calibration
description: Probability vs accuracy
critical_insight: ╔══════════════════════════════════════════════════════════════════════════╗
║                                                                          ║
║   DURING INFERENCE:                                                      ║
║   ─────────────────                                                      ║
║                                                                          ║
║   INPUT:  [u₀, s₀, u₁, s₁, u₂]  ← s₂ is COMPLETELY ABSENT              ║
║                                   (never given to model)                 ║
║                                                                          ║
║   OUTPUT: y_s₂                    ← PREDICTED label for s₂              ║
║                                   (THIS IS THE MODEL'S OUTPUT)           ║
║                                                                          ║
║   The model is NOT classifying the input.                               ║
║   The model is PREDICTING the label of an UNSEEN future utterance.      ║
║                                                                          ║
╚══════════════════════════════════════════════════════════════════════════╝