Added extra_repr() to pooler classes to improve debuggability (#44805)

Signed-off-by: Taneem Ibrahim <taneem.ibrahim@gmail.com>
This commit is contained in:
Taneem Ibrahim
2026-06-08 03:19:31 +00:00
committed by GitHub
parent 6124a98a9b
commit 5633405964
7 changed files with 73 additions and 0 deletions
@@ -43,6 +43,16 @@ class EmbeddingPoolerHead(SequencePoolerHead):
self.head_dtype = head_dtype
self.activation = activation
def extra_repr(self) -> str:
attrs = []
if self.head_dtype is not None:
attrs.append(f"head_dtype={self.head_dtype}")
if self.projector is not None:
attrs.append("projector=True")
if self.activation is not None:
attrs.append(f"activation={self.activation.__class__.__name__}")
return ", ".join(attrs)
def get_supported_tasks(self) -> Set[PoolingTask]:
return {"embed"}
@@ -124,6 +134,20 @@ class ClassifierPoolerHead(SequencePoolerHead):
self.head_dtype = head_dtype
self.activation = activation
def extra_repr(self) -> str:
attrs = []
if self.head_dtype is not None:
attrs.append(f"head_dtype={self.head_dtype}")
if self.classifier is not None:
attrs.append("classifier=True")
if self.logit_mean is not None:
attrs.append(f"logit_mean={self.logit_mean}")
if self.logit_sigma is not None:
attrs.append(f"logit_sigma={self.logit_sigma}")
if self.activation is not None:
attrs.append(f"activation={self.activation.__class__.__name__}")
return ", ".join(attrs)
def get_supported_tasks(self) -> Set[PoolingTask]:
return {"classify"}
@@ -61,6 +61,12 @@ class SequencePooler(Pooler):
self.pooling = pooling
self.head = head
def extra_repr(self) -> str:
return (
f"pooling={self.pooling.__class__.__name__}, "
f"head={self.head.__class__.__name__}"
)
def get_supported_tasks(self) -> Set[PoolingTask]:
tasks = set(POOLING_TASKS)