📚 book_recs_reranker (Fine-Tuned Cross-Encoder Reranker)
book_recs_reranker is a fine-tuned cross-encoder reranker specialized for second-stage semantic book recommendation. It is based on BAAI/bge-reranker-base (278M parameters) and takes a (query, book_description) pair to compute high-precision relevance scores via full cross-attention.
🚀 Key Improvements (Evaluated on 2,998 Held-Out Queries)
| Metric | Pretrained (bge-reranker-base) | Fine-Tuned (book_recs_reranker) | Absolute Improvement |
|---|---|---|---|
| MRR@10 | 79.14% | 88.73% | +9.59% |
| MAP | 79.13% | 88.71% | +9.58% |
In practice, a top-10 Mean Reciprocal Rank (MRR@10) of 88.73% means the target recommended book is placed at rank #1 for the overwhelming majority of queries.
🛠️ Usage
Using Sentence-Transformers CrossEncoder
from sentence_transformers import CrossEncoder
reranker = CrossEncoder("kanishshandilya/book_recs_reranker")
query = "dystopian rebellion against oppressive surveillance state"
candidates = [
"Title: 1984 | Genres: Dystopia, Classic | Description: Winston Smith lives under the watchful eye of Big Brother in Oceania...",
"Title: The Hunger Games | Genres: YA, Dystopia | Description: Katniss Everdeen volunteers in a televised death match...",
"Title: Pride and Prejudice | Genres: Romance, Classic | Description: Elizabeth Bennet deals with issues of manners and marriage..."
]
pairs = [[query, doc] for doc in candidates]
scores = reranker.predict(pairs)
for doc, score in sorted(zip(candidates, scores), key=lambda x: x[1], reverse=True):
print(f"[{score:+.4f}] {doc[:60]}...")
🧠 Training Methodology
- Goldilocks Zone Hard Negative Mining (ranks 10–45): Bypasses ranks 0–9 to eliminate false-negative poisoning from unlabelled sequels and companion works.
- Multi-Layer False-Negative Suppression: Filters out candidates sharing the same Goodreads author ID, series ID, work ID, or reader-endorsed similar books, with a hard cosine ceiling at 0.82.
- Dynamic Batch Padding: Tokenized in batch collator to achieve maximum throughput.