From 2eaaec5885331d255ac8c0d0053572cbf4433e06 Mon Sep 17 00:00:00 2001 From: Benjamin Piwowarski Date: Tue, 5 Mar 2024 19:16:53 +0100 Subject: [PATCH] fix: use dimension as a property --- src/xpmir/neural/interaction/colbert.py | 2 +- src/xpmir/text/adapters.py | 2 +- src/xpmir/text/encoders.py | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/xpmir/neural/interaction/colbert.py b/src/xpmir/neural/interaction/colbert.py index 5921dda..64b09a7 100644 --- a/src/xpmir/neural/interaction/colbert.py +++ b/src/xpmir/neural/interaction/colbert.py @@ -43,7 +43,7 @@ def __validate__(self): def __initialize__(self, options): super().__initialize__(options) - self.linear = nn.Linear(self.encoder.dimension(), self.linear_dim, bias=False) + self.linear = nn.Linear(self.encoder.dimension, self.linear_dim, bias=False) def _encode( self, diff --git a/src/xpmir/text/adapters.py b/src/xpmir/text/adapters.py index 342d041..b6c7a5a 100644 --- a/src/xpmir/text/adapters.py +++ b/src/xpmir/text/adapters.py @@ -16,7 +16,7 @@ def static(self): @property def dimension(self): - return self.encoder.dimension() + return self.encoder.dimension def forward(self, texts: List[InputType], options=None) -> RepresentationOutput: emb_texts = self.encoder(texts, options=options) diff --git a/src/xpmir/text/encoders.py b/src/xpmir/text/encoders.py index 01afed4..12f3f45 100644 --- a/src/xpmir/text/encoders.py +++ b/src/xpmir/text/encoders.py @@ -245,5 +245,6 @@ def static(self): """Whether embeddings parameters are learnable""" return self.encoder.static() + @property def dimension(self): - return self.encoder.dimension() + return self.encoder.dimension