numb3r3
commited on
Commit
•
ddfd320
1
Parent(s):
e8c33a6
chore: init readme
Browse files
README.md
ADDED
@@ -0,0 +1,121 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
library_name: transformers
|
3 |
+
license: apache-2.0
|
4 |
+
language:
|
5 |
+
- en
|
6 |
+
tags:
|
7 |
+
- reranker
|
8 |
+
- cross-encoder
|
9 |
+
---
|
10 |
+
|
11 |
+
<br><br>
|
12 |
+
|
13 |
+
<p align="center">
|
14 |
+
<img src="https://aeiljuispo.cloudimg.io/v7/https://cdn-uploads.huggingface.co/production/uploads/603763514de52ff951d89793/AFoybzd5lpBQXEBrQHuTt.png?w=200&h=200&f=face" alt="Finetuner logo: Finetuner helps you to create experiments in order to improve embeddings on search tasks. It accompanies you to deliver the last mile of performance-tuning for neural search applications." width="150px">
|
15 |
+
</p>
|
16 |
+
|
17 |
+
<p align="center">
|
18 |
+
<b>Trained by <a href="https://jina.ai/"><b>Jina AI</b></a>.</b>
|
19 |
+
</p>
|
20 |
+
|
21 |
+
# jina-reranker-v1-tiny-en
|
22 |
+
|
23 |
+
This model is designed for **blazing-fast** reranking while maintaining **competitive performance**. What's more, it leverages the power of our [JinaBERT](https://arxiv.org/abs/2310.19923) model as its foundation. `JinaBERT` itself is a unique variant of the BERT architecture that supports the symmetric bidirectional variant of [ALiBi](https://arxiv.org/abs/2108.12409). This allows `jina-reranker-v1-tiny-en` to process significantly longer sequences of text compared to other reranking models, up to an impressive **8,192** tokens.
|
24 |
+
|
25 |
+
To achieve the remarkable speed, the `jina-reranker-v1-tiny-en` employ a technique called knowledge distillation. Here, a complex, but slower, model (like our original [jina-reranker-v1-base-en](https://jina.ai/reranker/)) acts as a teacher, condensing its knowledge into a smaller, faster student model. This student retains most of the teacher's knowledge, allowing it to deliver similar accuracy in a fraction of the time.
|
26 |
+
|
27 |
+
Here's a breakdown of the reranker models we provide:
|
28 |
+
|
29 |
+
| Model Name | Layers | Hidden Size | Parameters (Millions) |
|
30 |
+
| ------------------------------------------------------------------------------------ | ------ | ----------- | --------------------- |
|
31 |
+
| [jina-reranker-v1-base-en](https://jina.ai/reranker/) | 12 | 768 | 137.0 |
|
32 |
+
| [jina-reranker-v1-turbo-en](https://huggingface.co/jinaai/jina-reranker-v1-turbo-en) | 6 | 384 | 37.8 |
|
33 |
+
| [jina-reranker-v1-tiny-en](https://huggingface.co/jinaai/jina-reranker-v1-tiny-en) | 4 | 384 | 33.0 |
|
34 |
+
|
35 |
+
> Currently, the `jina-reranker-v1-base-en` model is not available on Hugging Face. You can access it via the [Jina AI Reranker API](https://jina.ai/reranker/).
|
36 |
+
|
37 |
+
As you can see, the `jina-reranker-v1-turbo-en` offers a balanced approach with **6 layers** and **37.8 million** parameters. This translates to fast search and reranking while preserving a high degree of accuracy. The `jina-reranker-v1-tiny-en` prioritizes speed even further, achieving the fastest inference speeds with its **4-layer**, **33.0 million** parameter architecture. This makes it ideal for scenarios where absolute top accuracy is less crucial.
|
38 |
+
|
39 |
+
# Usage
|
40 |
+
|
41 |
+
The easiest way to starting using `jina-reranker-v1-tiny-en` is to use Jina AI's [Reranker API](https://jina.ai/reranker/).
|
42 |
+
|
43 |
+
```bash
|
44 |
+
curl https://api.jina.ai/v1/rerank \
|
45 |
+
-H "Content-Type: application/json" \
|
46 |
+
-H "Authorization: Bearer YOUR_API_KEY" \
|
47 |
+
-d '{
|
48 |
+
"model": "jina-reranker-v1-tiny-en",
|
49 |
+
"query": "Organic skincare products for sensitive skin",
|
50 |
+
"documents": [
|
51 |
+
"Eco-friendly kitchenware for modern homes",
|
52 |
+
"Biodegradable cleaning supplies for eco-conscious consumers",
|
53 |
+
"Organic cotton baby clothes for sensitive skin",
|
54 |
+
"Natural organic skincare range for sensitive skin",
|
55 |
+
"Tech gadgets for smart homes: 2024 edition",
|
56 |
+
"Sustainable gardening tools and compost solutions",
|
57 |
+
"Sensitive skin-friendly facial cleansers and toners",
|
58 |
+
"Organic food wraps and storage solutions",
|
59 |
+
"All-natural pet food for dogs with allergies",
|
60 |
+
"Yoga mats made from recycled materials"
|
61 |
+
],
|
62 |
+
"top_n": 3
|
63 |
+
}'
|
64 |
+
```
|
65 |
+
|
66 |
+
Alternatively, you can use the `transformers` library to interact with the model programmatically.
|
67 |
+
|
68 |
+
```python
|
69 |
+
!pip install transformers
|
70 |
+
from transformers import AutoModelForSequenceClassification
|
71 |
+
|
72 |
+
model = AutoModelForSequenceClassification.from_pretrained(
|
73 |
+
'jinaai/jina-reranker-v1-tiny-en', num_labels=1, trust_remote_code=True
|
74 |
+
)
|
75 |
+
|
76 |
+
# Example query and documents
|
77 |
+
query = "Organic skincare products for sensitive skin"
|
78 |
+
documents = [
|
79 |
+
"Eco-friendly kitchenware for modern homes",
|
80 |
+
"Biodegradable cleaning supplies for eco-conscious consumers",
|
81 |
+
"Organic cotton baby clothes for sensitive skin",
|
82 |
+
"Natural organic skincare range for sensitive skin",
|
83 |
+
"Tech gadgets for smart homes: 2024 edition",
|
84 |
+
"Sustainable gardening tools and compost solutions",
|
85 |
+
"Sensitive skin-friendly facial cleansers and toners",
|
86 |
+
"Organic food wraps and storage solutions",
|
87 |
+
"All-natural pet food for dogs with allergies",
|
88 |
+
"Yoga mats made from recycled materials"
|
89 |
+
]
|
90 |
+
|
91 |
+
# construct sentence pairs
|
92 |
+
sentence_pairs = [[query, doc] for doc in documents]
|
93 |
+
|
94 |
+
scores = model.compute_score(sentence_pairs)
|
95 |
+
```
|
96 |
+
|
97 |
+
# Evaluation
|
98 |
+
|
99 |
+
We evaluated Jina Reranker on 3 key benchmarks to ensure top-tier performance and search relevance.
|
100 |
+
|
101 |
+
| Model Name | NDCG@10 (17 BEIR datasets) | NDCG@10 (5 LoCo datasets) | Hit Rate (LlamaIndex RAG) |
|
102 |
+
| ---------------------------- | -------------------------- | ------------------------- | ------------------------- |
|
103 |
+
| `jina-rereanker-v1-base-en` | **52.45** | **87.31** | **85.53** |
|
104 |
+
| `jina-rereanker-v1-turbo-en` | **49.60** | **69.21** | **85.13** |
|
105 |
+
| `jina-rereanker-v1-tiny-en` | **48.54** | **70.29** | **85.00** |
|
106 |
+
| `mxbai-rerank-base-v1` | 49.19 | - | 82.50 |
|
107 |
+
| `mxbai-rerank-xsmall-v1` | 48.80 | - | 83.69 |
|
108 |
+
| `ms-marco-MiniLM-L-6-v2` | 48.64 | - | 82.63 |
|
109 |
+
| `ms-marco-MiniLM-L-4-v2` | 47.81 | - | 83.82 |
|
110 |
+
| `bge-reranker-base` | 47.89 | - | 83.03 |
|
111 |
+
|
112 |
+
**Note:**
|
113 |
+
|
114 |
+
- `NDCG@10` is a measure of ranking quality, with higher scores indicating better search results. `Hit Rate` measures the percentage of relevant documents that appear in the top 10 search results.
|
115 |
+
- The results of LoCo datasets on other models are not available since they **do not support** long documents more than 512 tokens.
|
116 |
+
|
117 |
+
For more details, please refer to our [benchmarking page](https://jina.ai/reranker/).
|
118 |
+
|
119 |
+
# Contact
|
120 |
+
|
121 |
+
Join our [Discord community](https://discord.jina.ai/) and chat with other community members about ideas.
|