[Model][0/N] Improve all pooling task | clean up (#25817)
Signed-off-by: wang.yuqi <noooop@126.com>
This commit is contained in:
@@ -50,7 +50,7 @@ from vllm.model_executor.model_loader.weight_utils import default_weight_loader
|
||||
from vllm.sequence import IntermediateTensors
|
||||
|
||||
from ..layers.pooler import DispatchPooler, Pooler
|
||||
from .interfaces import SupportsPP
|
||||
from .interfaces import SupportsCrossEncoding, SupportsPP
|
||||
from .utils import (
|
||||
AutoWeightsLoader,
|
||||
is_pp_missing_parameter,
|
||||
@@ -321,7 +321,7 @@ class GPT2LMHeadModel(nn.Module, SupportsPP):
|
||||
return loader.load_weights(weights)
|
||||
|
||||
|
||||
class GPT2ForSequenceClassification(nn.Module):
|
||||
class GPT2ForSequenceClassification(nn.Module, SupportsCrossEncoding):
|
||||
"""GPT2 Model for sequence classification.
|
||||
|
||||
This class expands GPT2Model with pooling and score functions - last token
|
||||
@@ -358,6 +358,9 @@ class GPT2ForSequenceClassification(nn.Module):
|
||||
}
|
||||
)
|
||||
|
||||
def get_input_embeddings(self, input_ids: torch.Tensor) -> torch.Tensor:
|
||||
return self.transformer.get_input_embeddings(input_ids)
|
||||
|
||||
def load_weights(self, weights: Iterable[tuple[str, torch.Tensor]]):
|
||||
loader = AutoWeightsLoader(self)
|
||||
return loader.load_weights(weights)
|
||||
|
||||
Reference in New Issue
Block a user