Migrate model card from transformers-repo
Browse filesRead announcement at https://discuss.huggingface.co/t/announcement-all-model-cards-will-be-migrated-to-hf-co-model-repos/2755
Original file history: https://github.com/huggingface/transformers/commits/master/model_cards/vinai/phobert-large/README.md
README.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# <a name="introduction"></a> PhoBERT: Pre-trained language models for Vietnamese
|
| 2 |
+
|
| 3 |
+
Pre-trained PhoBERT models are the state-of-the-art language models for Vietnamese ([Pho](https://en.wikipedia.org/wiki/Pho), i.e. "Phở", is a popular food in Vietnam):
|
| 4 |
+
|
| 5 |
+
- Two PhoBERT versions of "base" and "large" are the first public large-scale monolingual language models pre-trained for Vietnamese. PhoBERT pre-training approach is based on [RoBERTa](https://github.com/pytorch/fairseq/blob/master/examples/roberta/README.md) which optimizes the [BERT](https://github.com/google-research/bert) pre-training procedure for more robust performance.
|
| 6 |
+
- PhoBERT outperforms previous monolingual and multilingual approaches, obtaining new state-of-the-art performances on four downstream Vietnamese NLP tasks of Part-of-speech tagging, Dependency parsing, Named-entity recognition and Natural language inference.
|
| 7 |
+
|
| 8 |
+
The general architecture and experimental results of PhoBERT can be found in our EMNLP-2020 Findings [paper](https://arxiv.org/abs/2003.00744):
|
| 9 |
+
|
| 10 |
+
@article{phobert,
|
| 11 |
+
title = {{PhoBERT: Pre-trained language models for Vietnamese}},
|
| 12 |
+
author = {Dat Quoc Nguyen and Anh Tuan Nguyen},
|
| 13 |
+
journal = {Findings of EMNLP},
|
| 14 |
+
year = {2020}
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
**Please CITE** our paper when PhoBERT is used to help produce published results or is incorporated into other software.
|
| 18 |
+
|
| 19 |
+
For further information or requests, please go to [PhoBERT's homepage](https://github.com/VinAIResearch/PhoBERT)!
|
| 20 |
+
|
| 21 |
+
### Installation <a name="install2"></a>
|
| 22 |
+
- Python 3.6+, and PyTorch 1.1.0+ (or TensorFlow 2.0+)
|
| 23 |
+
- Install `transformers`:
|
| 24 |
+
- `git clone https://github.com/huggingface/transformers.git`
|
| 25 |
+
- `cd transformers`
|
| 26 |
+
- `pip3 install --upgrade .`
|
| 27 |
+
|
| 28 |
+
### Pre-trained models <a name="models2"></a>
|
| 29 |
+
|
| 30 |
+
Model | #params | Arch. | Pre-training data
|
| 31 |
+
---|---|---|---
|
| 32 |
+
`vinai/phobert-base` | 135M | base | 20GB of texts
|
| 33 |
+
`vinai/phobert-large` | 370M | large | 20GB of texts
|
| 34 |
+
|
| 35 |
+
### Example usage <a name="usage2"></a>
|
| 36 |
+
|
| 37 |
+
```python
|
| 38 |
+
import torch
|
| 39 |
+
from transformers import AutoModel, AutoTokenizer
|
| 40 |
+
|
| 41 |
+
phobert = AutoModel.from_pretrained("vinai/phobert-large")
|
| 42 |
+
tokenizer = AutoTokenizer.from_pretrained("vinai/phobert-large")
|
| 43 |
+
|
| 44 |
+
# INPUT TEXT MUST BE ALREADY WORD-SEGMENTED!
|
| 45 |
+
line = "Tôi là sinh_viên trường đại_học Công_nghệ ."
|
| 46 |
+
|
| 47 |
+
input_ids = torch.tensor([tokenizer.encode(line)])
|
| 48 |
+
|
| 49 |
+
with torch.no_grad():
|
| 50 |
+
features = phobert(input_ids) # Models outputs are now tuples
|
| 51 |
+
|
| 52 |
+
## With TensorFlow 2.0+:
|
| 53 |
+
# from transformers import TFAutoModel
|
| 54 |
+
# phobert = TFAutoModel.from_pretrained("vinai/phobert-large")
|
| 55 |
+
```
|