Sentence Similarity
sentence-transformers
Safetensors
Transformers
Vietnamese
roberta
feature-extraction
Instructions to use NghiemAbe/Vi-Legal-Bi-Encoder-v2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use NghiemAbe/Vi-Legal-Bi-Encoder-v2 with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("NghiemAbe/Vi-Legal-Bi-Encoder-v2") sentences = [ "The weather is lovely today.", "It's so sunny outside!", "He drove to the stadium." ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [3, 3] - Transformers
How to use NghiemAbe/Vi-Legal-Bi-Encoder-v2 with Transformers:
# Load model directly from transformers import AutoTokenizer, AutoModel tokenizer = AutoTokenizer.from_pretrained("NghiemAbe/Vi-Legal-Bi-Encoder-v2") model = AutoModel.from_pretrained("NghiemAbe/Vi-Legal-Bi-Encoder-v2") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files
README.md
CHANGED
|
@@ -27,7 +27,8 @@ Then you can use the model like this:
|
|
| 27 |
|
| 28 |
```python
|
| 29 |
from sentence_transformers import SentenceTransformer
|
| 30 |
-
|
|
|
|
| 31 |
|
| 32 |
model = SentenceTransformer('NghiemAbe/Vi-Legal-Bi-Encoder-v2')
|
| 33 |
embeddings = model.encode(sentences)
|
|
@@ -52,7 +53,7 @@ def mean_pooling(model_output, attention_mask):
|
|
| 52 |
|
| 53 |
|
| 54 |
# Sentences we want sentence embeddings for
|
| 55 |
-
sentences = [
|
| 56 |
|
| 57 |
# Load model from HuggingFace Hub
|
| 58 |
tokenizer = AutoTokenizer.from_pretrained('NghiemAbe/Vi-Legal-Bi-Encoder-v2')
|
|
|
|
| 27 |
|
| 28 |
```python
|
| 29 |
from sentence_transformers import SentenceTransformer
|
| 30 |
+
from pyvi.ViTokenizer import tokenize
|
| 31 |
+
sentences = [tokenize("This is an example sentence"), tokenize("Each sentence is converted")]
|
| 32 |
|
| 33 |
model = SentenceTransformer('NghiemAbe/Vi-Legal-Bi-Encoder-v2')
|
| 34 |
embeddings = model.encode(sentences)
|
|
|
|
| 53 |
|
| 54 |
|
| 55 |
# Sentences we want sentence embeddings for
|
| 56 |
+
sentences = [tokenize("This is an example sentence"), tokenize("Each sentence is converted")]
|
| 57 |
|
| 58 |
# Load model from HuggingFace Hub
|
| 59 |
tokenizer = AutoTokenizer.from_pretrained('NghiemAbe/Vi-Legal-Bi-Encoder-v2')
|