Add pydocstyle to the ruff rules (#52136)
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com> Signed-off-by: Harry Mellor <hej.mellor@gmail.com> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
804e5377aa
commit
8c1557a79c
@@ -39,7 +39,6 @@ _GENERATE_SUFFIXES = [
|
||||
|
||||
def _load_st_projector(model_config: "ModelConfig") -> nn.Module | None:
|
||||
"""Load Sentence-Transformers Dense projection layers."""
|
||||
|
||||
dense_modules = try_get_dense_modules(
|
||||
model_config.model, revision=model_config.revision
|
||||
)
|
||||
@@ -249,8 +248,7 @@ def _create_pooling_model_cls(orig_cls: type[_T]) -> type[_T]:
|
||||
|
||||
|
||||
def as_embedding_model(cls: type[_T]) -> type[_T]:
|
||||
"""
|
||||
Subclass an existing vLLM model to support embeddings.
|
||||
"""Subclass an existing vLLM model to support embeddings.
|
||||
|
||||
By default, the embeddings of the whole prompt are extracted from the
|
||||
normalized hidden state corresponding to the last token.
|
||||
@@ -258,6 +256,7 @@ def as_embedding_model(cls: type[_T]) -> type[_T]:
|
||||
Note:
|
||||
We assume that no extra layers are added to the original model;
|
||||
please implement your own model if this is not the case.
|
||||
|
||||
"""
|
||||
# Avoid modifying existing embedding models
|
||||
if is_pooling_model(cls):
|
||||
@@ -306,8 +305,7 @@ def _resolve_num_labels(hf_config: Any, text_config: Any) -> int:
|
||||
|
||||
|
||||
def as_seq_cls_model(cls: type[_T]) -> type[_T]:
|
||||
"""
|
||||
Subclass an existing vLLM model to support classify and score tasks.
|
||||
"""Subclass an existing vLLM model to support classify and score tasks.
|
||||
|
||||
By default, the class probabilities are extracted from the softmaxed
|
||||
hidden state corresponding to the last token.
|
||||
@@ -316,6 +314,7 @@ def as_seq_cls_model(cls: type[_T]) -> type[_T]:
|
||||
We assume that the classification head is a single linear layer
|
||||
stored as the attribute `score` of the top-level model;
|
||||
please implement your own model if this is not the case.
|
||||
|
||||
"""
|
||||
# Avoid modifying existing classification models
|
||||
if is_pooling_model(cls):
|
||||
@@ -446,8 +445,7 @@ class SequenceClassificationConfig(VerifyAndUpdateConfig):
|
||||
|
||||
|
||||
def _get_language_model_for_seq_cls(model: nn.Module) -> nn.Module:
|
||||
"""
|
||||
Get the language model component for sequence classification conversion.
|
||||
"""Get the language model component for sequence classification conversion.
|
||||
For VLMs, returns the inner language model. For standard LLMs, returns model itself.
|
||||
"""
|
||||
multimodal_model: object = model
|
||||
@@ -481,8 +479,7 @@ def _get_language_model_for_seq_cls(model: nn.Module) -> nn.Module:
|
||||
|
||||
@contextmanager
|
||||
def _disable_seq_cls_loading_on_inner_model(language_model, is_vlm: bool):
|
||||
"""
|
||||
Context manager to temporarily disable sequence classification loading
|
||||
"""Context manager to temporarily disable sequence classification loading
|
||||
on inner VLM models to prevent recursive seq_cls_model_loader calls.
|
||||
"""
|
||||
if not is_vlm:
|
||||
|
||||
Reference in New Issue
Block a user