/ Модель

Характеристики

Контекст
512 токенов
Параметры
159 млн
Архитектура
bert · dense

bert-base-polish-uncased-v1

Заполнение пропусковТекст → текст3 профессии

Uncased-модель BERT для польского языка, предназначенная для предсказания замаскированных слов и дообучения для задач понимания текста.

294скачиваний за 30 дней12лайковвеса обновлены19 мая 2021

Бенчмарки

Как модель справилась с задачами пользователей ailist и что о ней публикуют открытые лидерборды

Публичные оценки

Из открытых лидербордов. Сравнивайте результаты одного теста при одинаковых условиях — отсутствие оценки не значит, что модель хуже.

В подключённых источниках результатов для этой модели пока нет.

Что умеет модель

Описание составлено по карточке модели и метаданным Hugging Face

dkleczek/bert-base-polish-uncased-v1 — uncased польская языковая модель BERT, созданная Дареком Клечеком (Darek Kłeczek). Она предназначена для заполнения замаскированных фрагментов текста и дальнейшего дообучения для задач понимания польского языка. Модель основана на архитектуре BERT с 12 слоями, размерностью скрытого состояния 768 и 12 головами внимания; метаданные указывают 159,3 млн параметров и контекст до 512 токенов. Доступны веса PyTorch и Flax.

Модель обучалась на польских текстах из Open Subtitles, ParaCrawl и Польского парламентского корпуса. Автор отмечает, что в uncased-варианте некоторые польские символы и диакритические знаки могут некорректно обрабатываться токенизатором после приведения к нижнему регистру; это может особенно влиять на классификацию токенов. Обучающий корпус Open Subtitles также содержал много дубликатов, а обучение не использовало Whole Word Masking. Автор рекомендует cased-вариант. В карточке не указана лицензия.

Сценарии применения

  • предсказание пропущенного слова в польском предложении
  • подготовка польских текстовых представлений для дообучения
  • классификация польских текстов после дообучения
  • анализ польской тональности после дообучения
  • разметка сущностей в польском тексте после дообучения

Ограничения

В uncased-варианте токенизатор может некорректно обрабатывать некоторые польские символы и диакритические знаки; это особенно способно повлиять на задачи классификации токенов. Обучающий корпус Open Subtitles содержал дубликаты, а модель не обучалась с Whole Word Masking; автор рекомендует cased-вариант.

Для каких профессий подходит3

Разделы каталога профессий, в задачах которых используется эта модель

Все профессии

Карточка модели

README от автора на Hugging Face, как он его опубликовал

Открыть на Hugging Face

Polbert - Polish BERT

Polish version of BERT language model is here! It is now available in two variants: cased and uncased, both can be downloaded and used via HuggingFace transformers library. I recommend using the cased model, more info on the differences and benchmark results below.

PolBERT image

Cased and uncased variants

  • I initially trained the uncased model, the corpus and training details are referenced below. Here are some issues I found after I published the uncased model:
    • Some Polish characters and accents are not tokenized correctly through the BERT tokenizer when applying lowercase. This doesn't impact sequence classification much, but may influence token classfication tasks significantly.
    • I noticed a lot of duplicates in the Open Subtitles dataset, which dominates the training corpus.
    • I didn't use Whole Word Masking.
  • The cased model improves on the uncased model in the following ways:
    • All Polish characters and accents should now be tokenized correctly.
    • I removed duplicates from Open Subtitles dataset. The corpus is smaller, but more balanced now.
    • The model is trained with Whole Word Masking.

Pre-training corpora

Below is the list of corpora used along with the output of wc command (counting lines, words and characters). These corpora were divided into sentences with srxsegmenter (see references), concatenated and tokenized with HuggingFace BERT Tokenizer.

Uncased

TablesLinesWordsCharacters
Polish subset of Open Subtitles23663540814311996017628097730
Polish subset of ParaCrawl84709501766708851163505275
Polish Parliamentary Corpus9799859121154785938896963
Polish Wikipedia - Feb 202080142061320679861015849191
Total262920423186109325710746349159

Cased

TablesLinesWordsCharacters
Polish subset of Open Subtitles (Deduplicated) 419989422135906561424873235
Polish subset of ParaCrawl84709501766708851163505275
Polish Parliamentary Corpus9799859121154785938896963
Polish Wikipedia - Feb 202080142061320679861015849191
Total682839606464791974543124667

Pre-training details

Uncased

  • Polbert was trained with code provided in Google BERT's github repository (https://github.com/google-research/bert)
  • Currently released model follows bert-base-uncased model architecture (12-layer, 768-hidden, 12-heads, 110M parameters)
  • Training set-up: in total 1 million training steps:
    • 100.000 steps - 128 sequence length, batch size 512, learning rate 1e-4 (10.000 steps warmup)
    • 800.000 steps - 128 sequence length, batch size 512, learning rate 5e-5
    • 100.000 steps - 512 sequence length, batch size 256, learning rate 2e-5
  • The model was trained on a single Google Cloud TPU v3-8

Cased

  • Same approach as uncased model, with the following differences:
    • Whole Word Masking
  • Training set-up:
    • 100.000 steps - 128 sequence length, batch size 2048, learning rate 1e-4 (10.000 steps warmup)
    • 100.000 steps - 128 sequence length, batch size 2048, learning rate 5e-5
    • 100.000 steps - 512 sequence length, batch size 256, learning rate 2e-5

Usage

Polbert is released via HuggingFace Transformers library.

For an example use as language model, see this notebook file.

Uncased

from transformers import *
model = BertForMaskedLM.from_pretrained("dkleczek/bert-base-polish-uncased-v1")
tokenizer = BertTokenizer.from_pretrained("dkleczek/bert-base-polish-uncased-v1")
nlp = pipeline('fill-mask', model=model, tokenizer=tokenizer)
for pred in nlp(f"Adam Mickiewicz wielkim polskim {nlp.tokenizer.mask_token} był."):
  print(pred)
# Output:
# {'sequence': '[CLS] adam mickiewicz wielkim polskim poeta był. [SEP]', 'score': 0.47196975350379944, 'token': 26596}
# {'sequence': '[CLS] adam mickiewicz wielkim polskim bohaterem był. [SEP]', 'score': 0.09127858281135559, 'token': 10953}
# {'sequence': '[CLS] adam mickiewicz wielkim polskim człowiekiem był. [SEP]', 'score': 0.0647173821926117, 'token': 5182}
# {'sequence': '[CLS] adam mickiewicz wielkim polskim pisarzem był. [SEP]', 'score': 0.05232388526201248, 'token': 24293}
# {'sequence': '[CLS] adam mickiewicz wielkim polskim politykiem był. [SEP]', 'score': 0.04554257541894913, 'token': 44095}

Cased

model = BertForMaskedLM.from_pretrained("dkleczek/bert-base-polish-cased-v1")
tokenizer = BertTokenizer.from_pretrained("dkleczek/bert-base-polish-cased-v1")
nlp = pipeline('fill-mask', model=model, tokenizer=tokenizer)
for pred in nlp(f"Adam Mickiewicz wielkim polskim {nlp.tokenizer.mask_token} był."):
  print(pred)
# Output:
# {'sequence': '[CLS] Adam Mickiewicz wielkim polskim pisarzem był. [SEP]', 'score': 0.5391148328781128, 'token': 37120}
# {'sequence': '[CLS] Adam Mickiewicz wielkim polskim człowiekiem był. [SEP]', 'score': 0.11683262139558792, 'token': 6810}
# {'sequence': '[CLS] Adam Mickiewicz wielkim polskim bohaterem był. [SEP]', 'score': 0.06021466106176376, 'token': 17709}
# {'sequence': '[CLS] Adam Mickiewicz wielkim polskim mistrzem był. [SEP]', 'score': 0.051870670169591904, 'token': 14652}
# {'sequence': '[CLS] Adam Mickiewicz wielkim polskim artystą był. [SEP]', 'score': 0.031787533313035965, 'token': 35680}

See the next section for an example usage of Polbert in downstream tasks.

Evaluation

Thanks to Allegro, we now have the KLEJ benchmark, a set of nine evaluation tasks for the Polish language understanding. The following results are achieved by running standard set of evaluation scripts (no tricks!) utilizing both cased and uncased variants of Polbert.

ModelAverageNKJP-NERCDSC-ECDSC-RCBDPolEmo2.0-INPolEmo2.0-OUTDYKPSCAR
Polbert cased81.793.693.493.852.787.471.159.198.685.2
Polbert uncased81.490.193.993.555.088.168.859.498.885.4

Note how the uncased model performs better than cased on some tasks? My guess this is because of the oversampling of Open Subtitles dataset and its similarity to data in some of these tasks. All these benchmark tasks are sequence classification, so the relative strength of the cased model is not so visible here.

Bias

The data used to train the model is biased. It may reflect stereotypes related to gender, ethnicity etc. Please be careful when using the model for downstream task to consider these biases and mitigate them.

Acknowledgements

  • I'd like to express my gratitude to Google TensorFlow Research Cloud (TFRC) for providing the free TPU credits - thank you!
  • Also appreciate the help from Timo Möller from deepset for sharing tips and scripts based on their experience training German BERT model.
  • Big thanks to Allegro for releasing KLEJ Benchmark and specifically to Piotr Rybak for help with the evaluation and pointing out some issues with the tokenization.
  • Finally, thanks to Rachel Thomas, Jeremy Howard and Sylvain Gugger from fastai for their NLP and Deep Learning courses!

Author

Darek Kłeczek - contact me on Twitter @dk21

References

Как запустить

На своей GPU в ailist. Цена — по текущим предложениям провайдеров

GPU в ailist

Универсальный рантайм · fill-mask

Можно запустить

Подбираем GPU…

Класс архитектуры
BertForMaskedLM
Ревизия весов
62be982

0 моделей