Skip to main content

Module relation_train

Module relation_train 

Source
Expand description

Head C: the biaffine relation scorer — the head that makes dimension 2 real.

Relation polarity is a property of the argument side, not of the predicate token, so it cannot be produced by token tagging: knowing that “develops” is a REL span says nothing about which entity acts and which is acted upon. Head C binds arguments explicitly. For a predicted pair (h, t) with relation r the projector emits rel/r/+ on h and rel/r/- on t.

§Architecture

  encoder hidden [T,H] ──span pooling──▶ span reps [S,H']   H' = 2H (start ⊕ mean)
                                             │
                         biaffine:  s(h,t)_r = hᵀ W_r t  +  U_r·[h;t]  +  b_r
                                             │
                                      pair logits [S,S,R+1]
                                             │
                      TYPE MASK from the spec: for facets (f_h, f_t) only relations
                      declared `head=f_h, tail=f_t` are scorable; everything else is −∞

The type mask is the load-bearing detail. develops: org → system means the reversed pairing is unrepresentable, not merely unlikely — the paper’s guarded fragment enforced inside the model, and the reason Head C’s output is linter-clean by construction.

Structs§

BiaffineHead
Biaffine pair scorer over pooled span representations.
RelReport

Functions§

pool_span
Pool one span from encoder hidden states: start ⊕ mean over the tokens overlapping the span, giving a 2H representation. Endpoint+mean is the standard span encoding; it keeps boundary information that a pure mean discards.
save
Persist Head C beside the tagger checkpoint.
train_relations
Train Head C on top of a (frozen) tuned encoder. The encoder is reloaded read-only from the step-2 checkpoint: Head A already learned the span representations, so Head C only needs to learn the pair geometry, which keeps this stage cheap and stable.
type_allowed
The type mask: true where relation class r is declarable for a pair of facets. Class 0 (none) is always allowed; a declared relation is allowed only for its exact head/tail facets.