numb3r3 commited on
Commit
182734b
1 Parent(s): 03c97a6

chore: update readme

Browse files
Files changed (1) hide show
  1. README.md +94 -0
README.md CHANGED
@@ -21,3 +21,97 @@ license: cc-by-nc-4.0
21
  </p>
22
 
23
  # jina-reranker-v2-base-multilingual
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  </p>
22
 
23
  # jina-reranker-v2-base-multilingual
24
+
25
+
26
+ # Usage
27
+
28
+ 1. The easiest way to starting using `jina-reranker-v2-base-multilingual` is to use Jina AI's [Reranker API](https://jina.ai/reranker/).
29
+
30
+ ```bash
31
+ curl https://api.jina.ai/v1/rerank \
32
+ -H "Content-Type: application/json" \
33
+ -H "Authorization: Bearer YOUR_API_KEY" \
34
+ -d '{
35
+ "model": "jina-reranker-v2-base-multilingual",
36
+ "query": "Organic skincare products for sensitive skin",
37
+ "documents": [
38
+ "Eco-friendly kitchenware for modern homes",
39
+ "Biodegradable cleaning supplies for eco-conscious consumers",
40
+ "Organic cotton baby clothes for sensitive skin",
41
+ "Natural organic skincare range for sensitive skin",
42
+ "Tech gadgets for smart homes: 2024 edition",
43
+ "Sustainable gardening tools and compost solutions",
44
+ "Sensitive skin-friendly facial cleansers and toners",
45
+ "Organic food wraps and storage solutions",
46
+ "All-natural pet food for dogs with allergies",
47
+ "Yoga mats made from recycled materials"
48
+ ],
49
+ "top_n": 3
50
+ }'
51
+ ```
52
+
53
+ 2. Alternatively, you can use the latest version of the `sentence-transformers>=0.27.0` library. You can install it via pip:
54
+
55
+ ```bash
56
+ pip install -U sentence-transformers
57
+ ```
58
+
59
+ Then, you can use the following code to interact with the model:
60
+
61
+ ```python
62
+ from sentence_transformers import CrossEncoder
63
+
64
+ # Load the model, here we use our base sized model
65
+ model = CrossEncoder("jinaai/jina-reranker-v2-base-multilingual", num_labels=1, trust_remote_code=True)
66
+
67
+
68
+ # Example query and documents
69
+ query = "Organic skincare products for sensitive skin"
70
+ documents = [
71
+ "Eco-friendly kitchenware for modern homes",
72
+ "Biodegradable cleaning supplies for eco-conscious consumers",
73
+ "Organic cotton baby clothes for sensitive skin",
74
+ "Natural organic skincare range for sensitive skin",
75
+ "Tech gadgets for smart homes: 2024 edition",
76
+ "Sustainable gardening tools and compost solutions",
77
+ "Sensitive skin-friendly facial cleansers and toners",
78
+ "Organic food wraps and storage solutions",
79
+ "All-natural pet food for dogs with allergies",
80
+ "Yoga mats made from recycled materials"
81
+ ]
82
+
83
+ results = model.rank(query, documents, return_documents=True, top_k=3)
84
+ ```
85
+
86
+ 3. You can also use the `transformers` library to interact with the model programmatically.
87
+
88
+ ```python
89
+ !pip install transformers
90
+ from transformers import AutoModelForSequenceClassification
91
+
92
+ model = AutoModelForSequenceClassification.from_pretrained(
93
+ 'jinaai/jina-reranker-v2-base-multilingual', num_labels=1, trust_remote_code=True
94
+ )
95
+
96
+ # Example query and documents
97
+ query = "Organic skincare products for sensitive skin"
98
+ documents = [
99
+ "Eco-friendly kitchenware for modern homes",
100
+ "Biodegradable cleaning supplies for eco-conscious consumers",
101
+ "Organic cotton baby clothes for sensitive skin",
102
+ "Natural organic skincare range for sensitive skin",
103
+ "Tech gadgets for smart homes: 2024 edition",
104
+ "Sustainable gardening tools and compost solutions",
105
+ "Sensitive skin-friendly facial cleansers and toners",
106
+ "Organic food wraps and storage solutions",
107
+ "All-natural pet food for dogs with allergies",
108
+ "Yoga mats made from recycled materials"
109
+ ]
110
+
111
+ # construct sentence pairs
112
+ sentence_pairs = [[query, doc] for doc in documents]
113
+
114
+ scores = model.compute_score(sentence_pairs)
115
+ ```
116
+
117
+ That's it! You can now use the `jina-reranker-v2-base-multilingual` model in your projects.