[Model] Deprecate the score task (this will not affect users). (#37537)

Signed-off-by: wang.yuqi <yuqi.wang@daocloud.io>
This commit is contained in:
wang.yuqi
2026-03-20 08:07:56 +00:00
committed by GitHub
parent dcee9be95a
commit ed359c497a
22 changed files with 184 additions and 163 deletions
@@ -68,22 +68,24 @@ class TokenEmbeddingPoolerHead(TokenPoolerHead):
if self.head_dtype is not None:
pooled_data = pooled_data.to(self.head_dtype)
# pooled_data shape: [n_tokens, hidden_dimension]
# pooled_data shape: [n_tokens, hidden_size]
# Apply ST projector
if self.projector is not None:
pooled_data = self.projector(pooled_data)
# pooled_data shape: [n_tokens, embedding_dimension]
embeddings = self.projector(pooled_data)
else:
embeddings = pooled_data
# embeddings shape: [n_tokens, embedding_size]
# for matryoshka representation
pooled_data = pooled_data[..., : pooling_param.dimensions]
embeddings = embeddings[..., : pooling_param.dimensions]
# for normalize
if self.activation is not None and pooling_param.use_activation:
pooled_data = self.activation(pooled_data)
embeddings = self.activation(embeddings)
# pooled_data shape: [n_tokens, embedding_dimension]
return pooled_data
# embeddings shape: [n_tokens, embedding_size]
return embeddings
class TokenClassifierPoolerHead(TokenPoolerHead):
@@ -118,16 +120,16 @@ class TokenClassifierPoolerHead(TokenPoolerHead):
# hidden_states shape: [n_token, hidden_size]
if self.classifier is not None:
scores = self.classifier(pooled_data)
logits = self.classifier(pooled_data)
else:
scores = pooled_data
# scores shape: [n_token, num_labels]
logits = pooled_data
# logits shape: [n_token, num_labels]
if self.logit_bias is not None:
scores -= self.logit_bias
logits -= self.logit_bias
if self.activation is not None and pooling_param.use_activation:
scores = self.activation(scores)
logits = self.activation(logits)
# scores shape: [n_token, num_labels]
return scores
# logits shape: [n_token, num_labels]
return logits
@@ -116,7 +116,7 @@ def pooler_for_token_classify(
*,
pooling: TokenPoolingMethod | TokenPoolingFn | None = None,
classifier: ClassifierFn | None = None,
act_fn: PoolerActivation | str | None = None,
act_fn: PoolerActivation | None = None,
):
if pooling is None:
pooling = get_tok_pooling_method(pooler_config.get_tok_pooling_type())