objectives¶
topic_segmentation.objectives
Training objectives of Yu et al. (2023): topic segmentation (TS), CSSL, and TSSP.
cosine(x, y, temp)
¶
Compute cosine similarity scaled by temperature.
Source code in src/topic_segmentation/objectives.py
9 10 11 | |
section_ids(labels)
¶
Assign topic IDs to boundary candidates, numbered across documents.
Source code in src/topic_segmentation/objectives.py
14 15 16 17 18 19 20 21 22 23 24 25 26 | |
sample_pairs(ids, positives, negatives)
¶
Preceding candidates of the same topic as positives and following candidates as negatives.
Source code in src/topic_segmentation/objectives.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | |
cssl(sequence_output, labels, segment_ids, eop_index, config)
¶
Compute InfoNCE over max-pooled candidate features, using each candidate as an anchor.
Source code in src/topic_segmentation/objectives.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |
TSSP
¶
Bases: Module
Topic-aware sentence structure prediction head on the augmented view.
Source code in src/topic_segmentation/objectives.py
72 73 74 75 76 77 78 79 80 81 | |
classifier = nn.Linear(config.hidden_size, config.num_tssp_labels)
instance-attribute
¶
forward(sequence_output, sent_token_mask, sent_pair_orders)
¶
Source code in src/topic_segmentation/objectives.py
79 80 81 | |
CombinedObjective
¶
Bases: Module
Combine boundary classification, CSSL, and TSSP losses.
Source code in src/topic_segmentation/objectives.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | |
config = config
instance-attribute
¶
classifier = nn.Linear(config.hidden_size, config.num_labels)
instance-attribute
¶
tssp = TSSP(config)
instance-attribute
¶
forward(sequence_output, labels, segment_ids=None, eop_index=None, sent_token_mask=None, sent_pair_orders=None, augmented=False)
¶
Source code in src/topic_segmentation/objectives.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 | |