fix: add missing module
Browse files
README.md
CHANGED
@@ -50,48 +50,16 @@ curl https://api.jina.ai/v1/rerank \
|
|
50 |
}'
|
51 |
```
|
52 |
|
53 |
-
2.
|
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', trust_remote_code=True
|
94 |
)
|
|
|
95 |
|
96 |
# Example query and documents
|
97 |
query = "Organic skincare products for sensitive skin"
|
|
|
50 |
}'
|
51 |
```
|
52 |
|
53 |
+
2. You can also use the `transformers` library to interact with the model programmatically.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
|
55 |
```python
|
56 |
!pip install transformers
|
57 |
from transformers import AutoModelForSequenceClassification
|
58 |
|
59 |
model = AutoModelForSequenceClassification.from_pretrained(
|
60 |
+
'jinaai/jina-reranker-v2-base-multilingual', trust_remote_code=True,
|
61 |
)
|
62 |
+
model.to('cuda')
|
63 |
|
64 |
# Example query and documents
|
65 |
query = "Organic skincare products for sensitive skin"
|