We reconstructed the vocabulary and fine-tuned the ParsBERT v1.1 on the new Persian corpora in order to provide some functionalities for using ParsBERT in other scopes!
Please follow the
ParsBERT repo for the latest information about previous and current models.
ParsBERT is a monolingual language model based on Google’s BERT architecture. This model is pre-trained on large Persian corpora with various writing styles from numerous subjects (e.g., scientific, novels, news) with more than 3.9M documents, 73M sentences, and 1.3B words.
Paper presenting ParsBERT:
arXiv:2005.12515
You can use the raw model for either masked language modeling or next sentence prediction, but it's mostly intended to
be fine-tuned on a downstream task. See the
model hub to look for
fine-tuned versions on a task that interests you.
1from transformers import AutoConfig, AutoTokenizer, TFAutoModel
2
3config = AutoConfig.from_pretrained("HooshvareLab/bert-fa-base-uncased")
4tokenizer = AutoTokenizer.from_pretrained("HooshvareLab/bert-fa-base-uncased")
5model = TFAutoModel.from_pretrained("HooshvareLab/bert-fa-base-uncased")
6
7text = "ما در هوشواره معتقدیم با انتقال صحیح دانش و آگاهی، همه افراد میتوانند از ابزارهای هوشمند استفاده کنند. شعار ما هوش مصنوعی برای همه است."
8tokenizer.tokenize(text)
9
10>>> ['ما', 'در', 'هوش', '##واره', 'معتقدیم', 'با', 'انتقال', 'صحیح', 'دانش', 'و', 'اگاهی', '،', 'همه', 'افراد', 'میتوانند', 'از', 'ابزارهای', 'هوشمند', 'استفاده', 'کنند', '.', 'شعار', 'ما', 'هوش', 'مصنوعی', 'برای', 'همه', 'است', '.']
1from transformers import AutoConfig, AutoTokenizer, AutoModel
2
3config = AutoConfig.from_pretrained("HooshvareLab/bert-fa-base-uncased")
4tokenizer = AutoTokenizer.from_pretrained("HooshvareLab/bert-fa-base-uncased")
5model = AutoModel.from_pretrained("HooshvareLab/bert-fa-base-uncased")
ParsBERT trained on a massive amount of public corpora (
Persian Wikidumps,
MirasText) and six other manually crawled text data from a various type of websites (
BigBang Page scientific,
Chetor lifestyle,
Eligasht itinerary,
Digikala digital magazine,
Ted Talks general conversational, Books
novels, storybooks, short stories from old to the contemporary era).
As a part of ParsBERT methodology, an extensive pre-processing combining POS tagging and WordPiece segmentation was carried out to bring the corpora into a proper format.
Objective goals during training are as below (after 300k steps).
1***** Eval results *****
2global_step = 300000
3loss = 1.4392426
4masked_lm_accuracy = 0.6865794
5masked_lm_loss = 1.4469004
6next_sentence_accuracy = 1.0
7next_sentence_loss = 6.534152e-05
ParsBERT is evaluated on three NLP downstream tasks: Sentiment Analysis (SA), Text Classification, and Named Entity Recognition (NER). For this matter and due to insufficient resources, two large datasets for SA and two for text classification were manually composed, which are available for public use and benchmarking. ParsBERT outperformed all other language models, including multilingual BERT and other hybrid deep learning models for all tasks, improving the state-of-the-art performance in Persian language modeling.
1@article{ParsBERT,
2 title={ParsBERT: Transformer-based Model for Persian Language Understanding},
3 author={Mehrdad Farahani, Mohammad Gharachorloo, Marzieh Farahani, Mohammad Manthouri},
4 journal={ArXiv},
5 year={2020},
6 volume={abs/2005.12515}
7}
Post a Github issue on the
ParsBERT Issues repo.