Skip to content

Commit 7f881ec

Browse files
committed
release: 0.5.2
1 parent 256fca6 commit 7f881ec

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Welcome to `rerankers`! Our goal is to provide users with a simple API to use an
1414

1515
## Updates
1616

17+
- v0.5.2: Minor ColBERT fixes
1718
- v0.5.1: Minor change making RankedResults subscribable, meaning results[0] will return the first result, etc...
1819
- v0.5.0: Added support for the current state-of-the-art rerankers, BAAI's series of `BGE` layerwise LLM rerankers, based on [Gemma](https://huggingface.co/BAAI/bge-reranker-v2.5-gemma2-lightweight) and MiniCPM. These are different from RankGPT, as they're not listwise: the models are repurposed as "cross-encoders", and do output logit scores.
1920
- v0.4.0: ColBERT performance improvement! It should now be faster and result in stronger results following implementation of the JaColBERTv2.5 dynamic query length method. This version also now supports HuggingFace's Text-Embedding-Server (TEI) inference as an API reranker option, thanks to [@srisudarsan](https://github.com/srisudarsan).

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ packages = [
1414
name = "rerankers"
1515

1616

17-
version = "0.5.1"
17+
version = "0.5.2"
1818

1919
description = "A unified API for various document re-ranking models."
2020

rerankers/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
from rerankers.documents import Document
33

44
__all__ = ["Reranker", "Document"]
5-
__version__ = "0.5.1"
5+
__version__ = "0.5.2"

rerankers/models/colbert_ranker.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,12 @@ def __init__(
224224
self.verbose,
225225
)
226226
self.tokenizer = AutoTokenizer.from_pretrained(model_name)
227-
self.model = AutoModel.from_pretrained(model_name, torch_dtype=dtype).to(
228-
self.device
227+
self.model = (
228+
ColBERTModel.from_pretrained(
229+
model_name,
230+
)
231+
.to(self.device)
232+
.to(self.dtype)
229233
)
230234
self.model.eval()
231235
self.query_max_length = 32 # Lower bound
@@ -335,10 +339,10 @@ def _encode(
335339
)
336340

337341
# Calculate QLEN dynamically for each query
338-
if original_length % 32 <= 8:
342+
if original_length % 16 <= 8:
339343
QLEN = original_length + 8
340344
else:
341-
QLEN = ceil(original_length / 32) * 32
345+
QLEN = ceil(original_length / 16) * 16
342346

343347
if original_length < QLEN:
344348
pad_length = QLEN - original_length
@@ -372,7 +376,7 @@ def _to_embs(self, encoding) -> torch.Tensor:
372376
batch_encoding = {
373377
key: val[i : i + self.batch_size] for key, val in encoding.items()
374378
}
375-
batch_embs = self.model(**batch_encoding).last_hidden_state.squeeze(1)
379+
batch_embs = self.model(**batch_encoding)
376380
batched_embs.append(batch_embs)
377381
embs = torch.cat(batched_embs, dim=0)
378382
if self.normalize:

0 commit comments

Comments
 (0)