CoolFace
Modelpublic

dumitrescustefan/bert-base-romanian-uncased-v1

sourceHugging Facemitupdated 1y agoView on Hugging Face
13likes999downloads
Model Card

bert-base-romanian-uncased-v1

The BERT base, uncased model for Romanian, trained on a 15GB corpus, version v1.0

How to use

python
from transformers import AutoTokenizer, AutoModel
import torch

# load tokenizer and model
tokenizer = AutoTokenizer.from_pretrained("dumitrescustefan/bert-base-romanian-uncased-v1", do_lower_case=True)
model = AutoModel.from_pretrained("dumitrescustefan/bert-base-romanian-uncased-v1")

# tokenize a sentence and run through the model
input_ids = torch.tensor(tokenizer.encode("Acesta este un test.", add_special_tokens=True)).unsqueeze(0)  # Batch size 1
outputs = model(input_ids)

# get encoding
last_hidden_states = outputs[0]  # The last hidden-state is the first element of the output tuple

Remember to always sanitize your text! Replace `s and t` cedilla-letters to comma-letters with :

text = text.replace("ţ", "ț").replace("ş", "ș").replace("Ţ", "Ț").replace("Ş", "Ș")

because the model was NOT trained on cedilla `s and ts. If you don't, you will have decreased performance due to <UNK>`s and increased number of tokens per word.

Evaluation

Evaluation is performed on Universal Dependencies Romanian RRT UPOS, XPOS and LAS, and on a NER task based on RONEC. Details, as well as more in-depth tests not shown here, are given in the dedicated evaluation page.

The baseline is the Multilingual BERT model `bert-base-multilingual-(un)cased`, as at the time of writing it was the only available BERT model that works on Romanian.

ModelUPOSXPOSNERLAS
bert-base-multilingual-uncased97.6595.7283.9187.65
bert-base-romanian-uncased-v198.1896.8485.2689.61

Corpus

The model is trained on the following corpora (stats in the table below are after cleaning):

CorpusLines(M)Words(M)Chars(B)Size(GB)
OPUS55.05635.044.0453.8
OSCAR33.561725.8211.41111
Wikipedia1.5460.470.4110.4
Total90.152421.3315.86715.2

Citation

If you use this model in a research paper, I'd kindly ask you to cite the following paper:

Stefan Dumitrescu, Andrei-Marius Avram, and Sampo Pyysalo. 2020. The birth of Romanian BERT. In Findings of the Association for Computational Linguistics: EMNLP 2020, pages 4324–4328, Online. Association for Computational Linguistics.

or, in bibtex:

@inproceedings{dumitrescu-etal-2020-birth,
    title = "The birth of {R}omanian {BERT}",
    author = "Dumitrescu, Stefan  and
      Avram, Andrei-Marius  and
      Pyysalo, Sampo",
    booktitle = "Findings of the Association for Computational Linguistics: EMNLP 2020",
    month = nov,
    year = "2020",
    address = "Online",
    publisher = "Association for Computational Linguistics",
    url = "https://aclanthology.org/2020.findings-emnlp.387",
    doi = "10.18653/v1/2020.findings-emnlp.387",
    pages = "4324--4328",
}
Acknowledgements
  • —We'd like to thank Sampo Pyysalo from TurkuNLP for helping us out with the compute needed to pretrain the v1.0 BERT models. He's awesome!