Given logits regarding the entire vocabulary, return the probs over the label words set. Args: logits (:obj:`Tensor`): The logits over the entire vocabulary. Returns: :obj:`Tensor`: The logits over the label words set.
(self, logits: torch.Tensor)
| 197 | return label_logits |
| 198 | |
| 199 | def normalize(self, logits: torch.Tensor) -> torch.Tensor: |
| 200 | """ |
| 201 | Given logits regarding the entire vocabulary, return the probs over the label words set. |
| 202 | |
| 203 | Args: |
| 204 | logits (:obj:`Tensor`): The logits over the entire vocabulary. |
| 205 | |
| 206 | Returns: |
| 207 | :obj:`Tensor`: The logits over the label words set. |
| 208 | |
| 209 | """ |
| 210 | batch_size = logits.shape[0] |
| 211 | return F.softmax(logits.reshape(batch_size, -1), dim=-1).reshape(*logits.shape) |
| 212 | |
| 213 | |
| 214 | def aggregate(self, label_words_logits: torch.Tensor) -> torch.Tensor: |