Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,59 @@
|
|
1 |
-
---
|
2 |
-
license: apache-2.0
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
datasets:
|
4 |
+
- unicamp-dl/mmarco
|
5 |
+
language:
|
6 |
+
- vi
|
7 |
+
library_name: sentence-transformers
|
8 |
+
pipeline_tag: sentence-similarity
|
9 |
+
tags:
|
10 |
+
- cross-encoder
|
11 |
+
- rerank
|
12 |
+
---
|
13 |
+
|
14 |
+
## Installation
|
15 |
+
- Install `sentence-transformers` (recommend):
|
16 |
+
|
17 |
+
- `pip install sentence-transformers`
|
18 |
+
|
19 |
+
- Install `transformers` (optional):
|
20 |
+
|
21 |
+
- `pip install transformers`
|
22 |
+
|
23 |
+
- Install `pyvi` to word segment:
|
24 |
+
|
25 |
+
- `pip install pyvi`
|
26 |
+
|
27 |
+
|
28 |
+
## Usage with transformers
|
29 |
+
|
30 |
+
```python
|
31 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
32 |
+
import torch
|
33 |
+
|
34 |
+
model = AutoModelForSequenceClassification.from_pretrained('itdainb/vietnamese-cross-encoder')
|
35 |
+
tokenizer = AutoTokenizer.from_pretrained('itdainb/vietnamese-cross-encoder')
|
36 |
+
|
37 |
+
features = tokenizer(['How many people live in Berlin?', 'How many people live in Berlin?'], padding=True, truncation=True, return_tensors="pt")
|
38 |
+
|
39 |
+
model.eval()
|
40 |
+
with torch.no_grad():
|
41 |
+
scores = model(**features).logits
|
42 |
+
print(scores)
|
43 |
+
```
|
44 |
+
|
45 |
+
## Usage with sentence-transformers
|
46 |
+
|
47 |
+
Using this model becomes easy when you have [sentence-transformers](https://www.SBERT.net) installed:
|
48 |
+
|
49 |
+
```
|
50 |
+
pip install -U sentence-transformers
|
51 |
+
```
|
52 |
+
|
53 |
+
Then you can use the model like this:
|
54 |
+
|
55 |
+
```python
|
56 |
+
from sentence_transformers import CrossEncoder
|
57 |
+
model = CrossEncoder('itdainb/vietnamese-cross-encoder', max_length=256)
|
58 |
+
scores = model.predict([('Query', 'Paragraph1'), ('Query', 'Paragraph2') , ('Query', 'Paragraph3')])
|
59 |
+
```
|