| 293 | |
| 294 | |
| 295 | class RewardPoolerHead(PoolerHead): |
| 296 | |
| 297 | def __init__(self, model_config: Optional["ModelConfig"] = None) -> None: |
| 298 | super().__init__(activation=PoolerClassify(static_num_labels=False)) |
| 299 | self.model_config = model_config |
| 300 | |
| 301 | def forward(self, pooled_data: Union[list[paddle.Tensor], paddle.Tensor], pooling_metadata: PoolingMetadata): |
| 302 | pooling_params = get_pooling_params(pooling_metadata) |
| 303 | |
| 304 | flags = [p.softmax for p in pooling_params] |
| 305 | if len(set(flags)) == 1: |
| 306 | if flags[0]: |
| 307 | pooled_data = self.activation(pooled_data) |
| 308 | else: |
| 309 | pooled_data = [self.activation(vecs) if f else vecs for vecs, f in zip(pooled_data, flags)] |
| 310 | |
| 311 | return pooled_data |
| 312 | |
| 313 | |
| 314 | class PoolingMethod(nn.Layer, ABC): |
no outgoing calls