update the examples
Browse files
README.md
CHANGED
@@ -45,19 +45,15 @@ curl https://api.jina.ai/v1/rerank \
|
|
45 |
-H "Authorization: Bearer YOUR_API_KEY" \
|
46 |
-d '{
|
47 |
"model": "jina-reranker-m0",
|
48 |
-
"query": "
|
49 |
"documents": [
|
50 |
-
{"text": "
|
51 |
-
{"text": "
|
52 |
-
{"text": "
|
53 |
-
{"text": "
|
54 |
-
{"text": "
|
55 |
-
{"text": "
|
56 |
-
|
57 |
-
{"text": "新的化妆趋势注重鲜艳的颜色和创新的技巧"},
|
58 |
-
{"text": "敏感肌のために特別に設計された天然有機スキンケア製品"},
|
59 |
-
{"text": "新しいメイクのトレンドは鮮やかな色と革新的な技術に焦点を当てています"}
|
60 |
-
|
61 |
],
|
62 |
"top_n": 3
|
63 |
}'
|
@@ -83,34 +79,42 @@ model = AutoModel.from_pretrained(
|
|
83 |
|
84 |
model.to('cuda') # or 'cpu' if no GPU is available
|
85 |
model.eval()
|
86 |
-
|
87 |
# Example query and documents
|
88 |
-
query = "
|
89 |
documents = [
|
90 |
-
"
|
91 |
-
"
|
92 |
-
"
|
93 |
-
"
|
94 |
-
"
|
95 |
-
"
|
96 |
-
"针对敏感肌专门设计的天然有机护肤产品",
|
97 |
-
"新的化妆趋势注重鲜艳的颜色和创新的技巧",
|
98 |
-
"敏感肌のために特別に設計された天然有機スキンケア製品",
|
99 |
-
"新しいメイクのトレンドは鮮やかな色と革新的な技術に焦点を当てています",
|
100 |
]
|
101 |
|
102 |
# construct sentence pairs
|
103 |
-
|
104 |
|
105 |
-
scores = model.compute_score(
|
106 |
```
|
107 |
|
108 |
The scores will be a list of floats, where each float represents the relevance score of the corresponding document to the query. Higher scores indicate higher relevance.
|
109 |
For instance the returning scores in this case will be:
|
110 |
```bash
|
111 |
-
[0.
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
```
|
|
|
|
45 |
-H "Authorization: Bearer YOUR_API_KEY" \
|
46 |
-d '{
|
47 |
"model": "jina-reranker-m0",
|
48 |
+
"query": "What are the top AI conferences in 2025?",
|
49 |
"documents": [
|
50 |
+
{"text": "NeurIPS, ICML, and CVPR remain the leading AI research conferences in 2025."},
|
51 |
+
{"text": "CES showcases consumer technology advancements."},
|
52 |
+
{"text": "E3 is a major gaming expo featuring new console releases."},
|
53 |
+
{"text": "ACL 和 EMNLP 是自然语言处理领域最重要的学术会议,每年都吸引顶尖研究人员。"},
|
54 |
+
{"text": "Die ICLR konzentriert sich auf neue Entwicklungen im Deep Learning und ist eine der einflussreichsten KI-Konferenzen."},
|
55 |
+
{"text": "قمة الويب في لشبونة تشمل مواضيع الذكاء الاصطناعي ولكنها ليست مؤتمرًا أكاديميًا متخصصًا."},
|
56 |
+
|
|
|
|
|
|
|
|
|
57 |
],
|
58 |
"top_n": 3
|
59 |
}'
|
|
|
79 |
|
80 |
model.to('cuda') # or 'cpu' if no GPU is available
|
81 |
model.eval()
|
|
|
82 |
# Example query and documents
|
83 |
+
query = "What are the top AI conferences in 2025?"
|
84 |
documents = [
|
85 |
+
"NeurIPS, ICML, and CVPR remain the leading AI research conferences in 2025." ,
|
86 |
+
"CES showcases consumer technology advancements.",
|
87 |
+
"E3 is a major gaming expo featuring new console releases.",
|
88 |
+
"ACL 和 EMNLP 是自然语言处理领域最重要的学术会议,每年都吸引顶尖研究人员。",
|
89 |
+
"Die ICLR konzentriert sich auf neue Entwicklungen im Deep Learning und ist eine der einflussreichsten KI-Konferenzen.",
|
90 |
+
"قمة الويب في لشبونة تشمل مواضيع الذكاء الاصطناعي ولكنها ليست مؤتمرًا أكاديميًا متخصصًا."
|
|
|
|
|
|
|
|
|
91 |
]
|
92 |
|
93 |
# construct sentence pairs
|
94 |
+
text_pairs = [[query, doc] for doc in documents]
|
95 |
|
96 |
+
scores = model.compute_score(text_pairs, max_length=1024, doc_type="text")
|
97 |
```
|
98 |
|
99 |
The scores will be a list of floats, where each float represents the relevance score of the corresponding document to the query. Higher scores indicate higher relevance.
|
100 |
For instance the returning scores in this case will be:
|
101 |
```bash
|
102 |
+
[0.9990890026092529, 0.9230391979217529, 0.8872045874595642, 0.9817357659339905, 0.9811668992042542, 0.9585376977920532]
|
103 |
+
```
|
104 |
+
|
105 |
+
For handling the images, you can use the following code snippet:
|
106 |
+
```python
|
107 |
+
# Example query and documents
|
108 |
+
query = "What is the ghibli style?"
|
109 |
+
documents = [
|
110 |
+
"https://static0.gamerantimages.com/wordpress/wp-content/uploads/2023/05/doraemon.jpg",
|
111 |
+
"https://static0.gamerantimages.com/wordpress/wp-content/uploads/2024/01/iconic-anime-manga-art-styles-hayao-miyazaki-isao-takahata.jpg",
|
112 |
+
]
|
113 |
+
|
114 |
+
# construct sentence pairs
|
115 |
+
image_pairs = [[query, doc] for doc in documents]
|
116 |
+
|
117 |
+
scores = model.compute_score(image_pairs, max_length=2048, doc_type="image")
|
118 |
+
# [0.9688562154769897, 0.9886682629585266]
|
119 |
```
|
120 |
+
|