Views
No views yet
@article{vihealthbert,
title = {{ViHealthBERT: Pre-trained Language Models for Vietnamese in Health Text Mining}},
author = {Minh Phuc Nguyen, Vu Hoang Tran, Vu Hoang, Ta Duc Huy, Trung H. Bui, Steven Q. H. Truong },
journal = {13th Edition of its Language Resources and Evaluation Conference},
year = {2022}
}transformers:pip install transformers==4.2.0| Model | #params | Arch. | Tokenizer |
|---|---|---|---|
demdecuong/vihealthbert-base-word | 135M | base | Word-level |
demdecuong/vihealthbert-base-syllable | 135M | base | Syllable-level |
1import torch
2from transformers import AutoModel, AutoTokenizer
3
4vihealthbert = AutoModel.from_pretrained("demdecuong/vihealthbert-base-word")
5tokenizer = AutoTokenizer.from_pretrained("demdecuong/vihealthbert-base-word")
6
7# INPUT TEXT MUST BE ALREADY WORD-SEGMENTED!
8line = "Tôi là sinh_viên trường đại_học Công_nghệ ."
9
10input_ids = torch.tensor([tokenizer.encode(line)])
11with torch.no_grad():
12 features = vihealthbert(input_ids) # Models outputs are now tuples# Install the vncorenlp python wrapper
pip3 install vncorenlp
# Download VnCoreNLP-1.1.1.jar & its word segmentation component (i.e. RDRSegmenter)
mkdir -p vncorenlp/models/wordsegmenter
wget https://raw.githubusercontent.com/vncorenlp/VnCoreNLP/master/VnCoreNLP-1.1.1.jar
wget https://raw.githubusercontent.com/vncorenlp/VnCoreNLP/master/models/wordsegmenter/vi-vocab
wget https://raw.githubusercontent.com/vncorenlp/VnCoreNLP/master/models/wordsegmenter/wordsegmenter.rdr
mv VnCoreNLP-1.1.1.jar vncorenlp/
mv vi-vocab vncorenlp/models/wordsegmenter/
mv wordsegmenter.rdr vncorenlp/models/wordsegmenter/VnCoreNLP-1.1.1.jar (27MB) and folder models/ must be placed in the same working folder.# See more details at: https://github.com/vncorenlp/VnCoreNLP
# Load rdrsegmenter from VnCoreNLP
from vncorenlp import VnCoreNLP
rdrsegmenter = VnCoreNLP("/Absolute-path-to/vncorenlp/VnCoreNLP-1.1.1.jar", annotators="wseg", max_heap_size='-Xmx500m')
# Input
text = "Ông Nguyễn Khắc Chúc đang làm việc tại Đại học Quốc gia Hà Nội. Bà Lan, vợ ông Chúc, cũng làm việc tại đây."
# To perform word (and sentence) segmentation
sentences = rdrsegmenter.tokenize(text)
for sentence in sentences:
print(" ".join(sentence))