Views
No views yet
sentences-transformers
transformers
| Model | #params | Arch. |
|---|---|---|
VoVanPhuc/sup-SimCSE-VietNamese-phobert-base | 135M | base |
VoVanPhuc/unsup-SimCSE-VietNamese-phobert-base | 135M | base |
sentences-transformerssentence-transformers:pip install -U sentence-transformerspyvi to word segment:pip install pyvi1from sentence_transformers import SentenceTransformer
2from pyvi.ViTokenizer import tokenize
3
4model = SentenceTransformer('VoVanPhuc/sup-SimCSE-VietNamese-phobert-base')
5
6sentences = ['Kẻ đánh bom đinh tồi tệ nhất nước Anh.',
7 'Nghệ sĩ làm thiện nguyện - minh bạch là việc cấp thiết.',
8 'Bắc Giang tăng khả năng điều trị và xét nghiệm.',
9 'HLV futsal Việt Nam tiết lộ lý do hạ Lebanon.',
10 'việc quan trọng khi kêu gọi quyên góp từ thiện là phải minh bạch, giải ngân kịp thời.',
11 '20% bệnh nhân Covid-19 có thể nhanh chóng trở nặng.',
12 'Thái Lan thua giao hữu trước vòng loại World Cup.',
13 'Cựu tuyển thủ Nguyễn Bảo Quân: May mắn ủng hộ futsal Việt Nam',
14 'Chủ ki-ốt bị đâm chết trong chợ đầu mối lớn nhất Thanh Hoá.',
15 'Bắn chết người trong cuộc rượt đuổi trên sông.'
16 ]
17
18sentences = [tokenize(sentence) for sentence in sentences]
19embeddings = model.encode(sentences)transformerstransformers:pip install -U transformerspyvi to word segment:pip install pyvi1import torch
2from transformers import AutoModel, AutoTokenizer
3from pyvi.ViTokenizer import tokenize
4
5PhobertTokenizer = AutoTokenizer.from_pretrained("VoVanPhuc/sup-SimCSE-VietNamese-phobert-base")
6model = AutoModel.from_pretrained("VoVanPhuc/sup-SimCSE-VietNamese-phobert-base")
7
8sentences = ['Kẻ đánh bom đinh tồi tệ nhất nước Anh.',
9 'Nghệ sĩ làm thiện nguyện - minh bạch là việc cấp thiết.',
10 'Bắc Giang tăng khả năng điều trị và xét nghiệm.',
11 'HLV futsal Việt Nam tiết lộ lý do hạ Lebanon.',
12 'việc quan trọng khi kêu gọi quyên góp từ thiện là phải minh bạch, giải ngân kịp thời.',
13 '20% bệnh nhân Covid-19 có thể nhanh chóng trở nặng.',
14 'Thái Lan thua giao hữu trước vòng loại World Cup.',
15 'Cựu tuyển thủ Nguyễn Bảo Quân: May mắn ủng hộ futsal Việt Nam',
16 'Chủ ki-ốt bị đâm chết trong chợ đầu mối lớn nhất Thanh Hoá.',
17 'Bắn chết người trong cuộc rượt đuổi trên sông.'
18 ]
19
20sentences = [tokenize(sentence) for sentence in sentences]
21
22inputs = PhobertTokenizer(sentences, padding=True, truncation=True, return_tensors="pt")
23
24with torch.no_grad():
25 embeddings = model(**inputs, output_hidden_states=True, return_dict=True).pooler_output@article{gao2021simcse,
title={{SimCSE}: Simple Contrastive Learning of Sentence Embeddings},
author={Gao, Tianyu and Yao, Xingcheng and Chen, Danqi},
journal={arXiv preprint arXiv:2104.08821},
year={2021}
}
@inproceedings{phobert,
title = {{PhoBERT: Pre-trained language models for Vietnamese}},
author = {Dat Quoc Nguyen and Anh Tuan Nguyen},
booktitle = {Findings of the Association for Computational Linguistics: EMNLP 2020},
year = {2020},
pages = {1037--1042}
}