Views
No views yet

JinaBERT itself is a unique variant of the BERT architecture that supports the symmetric bidirectional variant of ALiBi. 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.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) 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.| Model Name | Layers | Hidden Size | Parameters (Millions) |
|---|---|---|---|
| jina-reranker-v1-base-en | 12 | 768 | 137.0 |
| jina-reranker-v1-turbo-en | 6 | 384 | 37.8 |
| jina-reranker-v1-tiny-en | 4 | 384 | 33.0 |
Currently, thejina-reranker-v1-base-enmodel is not available on Hugging Face. You can access it via the Jina AI Reranker API.
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.jina-reranker-v1-tiny-en is to use Jina AI's Reranker API.1curl https://api.jina.ai/v1/rerank \
2 -H "Content-Type: application/json" \
3 -H "Authorization: Bearer YOUR_API_KEY" \
4 -d '{
5 "model": "jina-reranker-v1-tiny-en",
6 "query": "Organic skincare products for sensitive skin",
7 "documents": [
8 "Eco-friendly kitchenware for modern homes",
9 "Biodegradable cleaning supplies for eco-conscious consumers",
10 "Organic cotton baby clothes for sensitive skin",
11 "Natural organic skincare range for sensitive skin",
12 "Tech gadgets for smart homes: 2024 edition",
13 "Sustainable gardening tools and compost solutions",
14 "Sensitive skin-friendly facial cleansers and toners",
15 "Organic food wraps and storage solutions",
16 "All-natural pet food for dogs with allergies",
17 "Yoga mats made from recycled materials"
18 ],
19 "top_n": 3
20}'sentence-transformers>=0.27.0 library. You can install it via pip:pip install -U sentence-transformers1from sentence_transformers import CrossEncoder
2
3# Load the model, here we use our tiny sized model
4model = CrossEncoder("jinaai/jina-reranker-v1-tiny-en", trust_remote_code=True)
5
6# Example query and documents
7query = "Organic skincare products for sensitive skin"
8documents = [
9 "Eco-friendly kitchenware for modern homes",
10 "Biodegradable cleaning supplies for eco-conscious consumers",
11 "Organic cotton baby clothes for sensitive skin",
12 "Natural organic skincare range for sensitive skin",
13 "Tech gadgets for smart homes: 2024 edition",
14 "Sustainable gardening tools and compost solutions",
15 "Sensitive skin-friendly facial cleansers and toners",
16 "Organic food wraps and storage solutions",
17 "All-natural pet food for dogs with allergies",
18 "Yoga mats made from recycled materials"
19]
20
21results = model.rank(query, documents, return_documents=True, top_k=3)transformers library to interact with the model programmatically.1!pip install transformers
2from transformers import AutoModelForSequenceClassification
3
4model = AutoModelForSequenceClassification.from_pretrained(
5 'jinaai/jina-reranker-v1-tiny-en', num_labels=1, trust_remote_code=True
6)
7
8# Example query and documents
9query = "Organic skincare products for sensitive skin"
10documents = [
11 "Eco-friendly kitchenware for modern homes",
12 "Biodegradable cleaning supplies for eco-conscious consumers",
13 "Organic cotton baby clothes for sensitive skin",
14 "Natural organic skincare range for sensitive skin",
15 "Tech gadgets for smart homes: 2024 edition",
16 "Sustainable gardening tools and compost solutions",
17 "Sensitive skin-friendly facial cleansers and toners",
18 "Organic food wraps and storage solutions",
19 "All-natural pet food for dogs with allergies",
20 "Yoga mats made from recycled materials"
21]
22
23# construct sentence pairs
24sentence_pairs = [[query, doc] for doc in documents]
25
26scores = model.compute_score(sentence_pairs)transformers.js library to run the model directly in JavaScript (in-browser, Node.js, Deno, etc.)!npm i @xenova/transformers1import { AutoTokenizer, AutoModelForSequenceClassification } from '@xenova/transformers';
2
3const model_id = 'jinaai/jina-reranker-v1-tiny-en';
4const model = await AutoModelForSequenceClassification.from_pretrained(model_id, { quantized: false });
5const tokenizer = await AutoTokenizer.from_pretrained(model_id);
6
7/**
8 * Performs ranking with the CrossEncoder on the given query and documents. Returns a sorted list with the document indices and scores.
9 * @param {string} query A single query
10 * @param {string[]} documents A list of documents
11 * @param {Object} options Options for ranking
12 * @param {number} [options.top_k=undefined] Return the top-k documents. If undefined, all documents are returned.
13 * @param {number} [options.return_documents=false] If true, also returns the documents. If false, only returns the indices and scores.
14 */
15async function rank(query, documents, {
16 top_k = undefined,
17 return_documents = false,
18} = {}) {
19 const inputs = tokenizer(
20 new Array(documents.length).fill(query),
21 { text_pair: documents, padding: true, truncation: true }
22 )
23 const { logits } = await model(inputs);
24 return logits.sigmoid().tolist()
25 .map(([score], i) => ({
26 corpus_id: i,
27 score,
28 ...(return_documents ? { text: documents[i] } : {})
29 })).sort((a, b) => b.score - a.score).slice(0, top_k);
30}
31
32// Example usage:
33const query = "Organic skincare products for sensitive skin"
34const documents = [
35 "Eco-friendly kitchenware for modern homes",
36 "Biodegradable cleaning supplies for eco-conscious consumers",
37 "Organic cotton baby clothes for sensitive skin",
38 "Natural organic skincare range for sensitive skin",
39 "Tech gadgets for smart homes: 2024 edition",
40 "Sustainable gardening tools and compost solutions",
41 "Sensitive skin-friendly facial cleansers and toners",
42 "Organic food wraps and storage solutions",
43 "All-natural pet food for dogs with allergies",
44 "Yoga mats made from recycled materials",
45]
46
47const results = await rank(query, documents, { return_documents: true, top_k: 3 });
48console.log(results);jina-reranker-v1-tiny-en model in your projects.| Model Name | NDCG@10 (17 BEIR datasets) | NDCG@10 (5 LoCo datasets) | Hit Rate (LlamaIndex RAG) |
|---|---|---|---|
jina-reranker-v1-base-en | 52.45 | 87.31 | 85.53 |
jina-reranker-v1-turbo-en | 49.60 | 69.21 | 85.13 |
jina-reranker-v1-tiny-en (you are here) | 48.54 | 70.29 | 85.00 |
mxbai-rerank-base-v1 | 49.19 | - | 82.50 |
mxbai-rerank-xsmall-v1 | 48.80 | - | 83.69 |
ms-marco-MiniLM-L-6-v2 | 48.64 | - | 82.63 |
ms-marco-MiniLM-L-4-v2 | 47.81 | - | 83.82 |
bge-reranker-base | 47.89 | - | 83.03 |
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.