Search is not available for this dataset
pipeline_tag
stringclasses 48
values | library_name
stringclasses 205
values | text
stringlengths 0
18.3M
| metadata
stringlengths 2
1.07B
| id
stringlengths 5
122
| last_modified
null | tags
listlengths 1
1.84k
| sha
null | created_at
stringlengths 25
25
|
---|---|---|---|---|---|---|---|---|
text-classification | transformers | {"dataset": "empathetic_dialogues"} | benjaminbeilharz/bert-base-uncased-empatheticdialogues-sentiment-classifier | null | [
"transformers",
"pytorch",
"bert",
"text-classification",
"autotrain_compatible",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
text-classification | transformers | {} | benjaminbeilharz/bert-base-uncased-next-turn-classifier | null | [
"transformers",
"pytorch",
"bert",
"text-classification",
"autotrain_compatible",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
text-classification | transformers | {} | benjaminbeilharz/bert-base-uncased-sentiment-classifier | null | [
"transformers",
"pytorch",
"bert",
"text-classification",
"autotrain_compatible",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
null | null | {} | benjaminbeilharz/dialoGPT-medium-empatheticdialogues-generation | null | [
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
text-generation | transformers |
Still figuring out to properly write model cards.
WIP. | {"language": ["en"], "license": "mit", "tags": ["conversational", "pytorch", "transformers", "gpt2"], "datasets": ["empathetic dialogues"]} | benjaminbeilharz/dialoGPT-small-empatheticdialogues-generation | null | [
"transformers",
"pytorch",
"tensorboard",
"gpt2",
"text-generation",
"conversational",
"en",
"license:mit",
"autotrain_compatible",
"endpoints_compatible",
"text-generation-inference",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
text-classification | transformers | {} | benjaminbeilharz/distilbert-base-uncased-empatheticdialogues-sentiment-classifier | null | [
"transformers",
"pytorch",
"distilbert",
"text-classification",
"autotrain_compatible",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
text-classification | transformers | {} | benjaminbeilharz/distilbert-base-uncased-next-turn-classifier | null | [
"transformers",
"pytorch",
"distilbert",
"text-classification",
"autotrain_compatible",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
text-classification | transformers | {} | benjaminbeilharz/distilbert-dailydialog-turn-classifier | null | [
"transformers",
"pytorch",
"distilbert",
"text-classification",
"autotrain_compatible",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
text2text-generation | transformers | {} | benjaminbeilharz/t5-conditioned-next-turn | null | [
"transformers",
"pytorch",
"t5",
"text2text-generation",
"autotrain_compatible",
"endpoints_compatible",
"text-generation-inference",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
null | null | {} | benjaminlevy/CornBERT | null | [
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
null | null | {} | benmanns/press-mentions | null | [
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
text-generation | transformers |
# Misato Katsuragi DialoGPT Model
--- | {"tags": ["conversational"]} | benmrtnz27/DialoGPT-small-misato | null | [
"transformers",
"pytorch",
"gpt2",
"text-generation",
"conversational",
"autotrain_compatible",
"endpoints_compatible",
"text-generation-inference",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
null | null | {} | bennoach/gpt2Spirit | null | [
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
null | null | {} | bennu/gpt-neo-1.3B | null | [
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
question-answering | transformers | {} | benny6/roberta-tydiqa | null | [
"transformers",
"pytorch",
"roberta",
"question-answering",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
fill-mask | transformers | {} | benny6/roberta_QA | null | [
"transformers",
"roberta",
"fill-mask",
"autotrain_compatible",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
table-question-answering | transformers | {} | benschlagman/tapas_fine_tuning | null | [
"transformers",
"pytorch",
"tf",
"tapas",
"table-question-answering",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
text-generation | transformers |
#GPTCartman | {"tags": ["conversational"]} | bensuydam/CartmanBot | null | [
"transformers",
"pytorch",
"gpt2",
"text-generation",
"conversational",
"autotrain_compatible",
"endpoints_compatible",
"text-generation-inference",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
fill-mask | transformers |
# BERT base model (uncased)
Pretrained model on English language using a masked language modeling (MLM) objective. It was introduced in
[this paper](https://arxiv.org/abs/1810.04805) and first released in
[this repository](https://github.com/google-research/bert). This model is uncased: it does not make a difference
between english and English.
Disclaimer: The team releasing BERT did not write a model card for this model so this model card has been written by
the Hugging Face team.
## Model description
BERT is a transformers model pretrained on a large corpus of English data in a self-supervised fashion. This means it
was pretrained on the raw texts only, with no humans labelling them in any way (which is why it can use lots of
publicly available data) with an automatic process to generate inputs and labels from those texts. More precisely, it
was pretrained with two objectives:
- Masked language modeling (MLM): taking a sentence, the model randomly masks 15% of the words in the input then run
the entire masked sentence through the model and has to predict the masked words. This is different from traditional
recurrent neural networks (RNNs) that usually see the words one after the other, or from autoregressive models like
GPT which internally mask the future tokens. It allows the model to learn a bidirectional representation of the
sentence.
- Next sentence prediction (NSP): the models concatenates two masked sentences as inputs during pretraining. Sometimes
they correspond to sentences that were next to each other in the original text, sometimes not. The model then has to
predict if the two sentences were following each other or not.
This way, the model learns an inner representation of the English language that can then be used to extract features
useful for downstream tasks: if you have a dataset of labeled sentences for instance, you can train a standard
classifier using the features produced by the BERT model as inputs.
## Intended uses & limitations
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](https://huggingface.co/models?filter=bert) to look for
fine-tuned versions on a task that interests you.
Note that this model is primarily aimed at being fine-tuned on tasks that use the whole sentence (potentially masked)
to make decisions, such as sequence classification, token classification or question answering. For tasks such as text
generation you should look at model like GPT2.
### How to use
You can use this model directly with a pipeline for masked language modeling:
```python
>>> from transformers import pipeline
>>> unmasker = pipeline('fill-mask', model='bert-base-uncased')
>>> unmasker("Hello I'm a [MASK] model.")
[{'sequence': "[CLS] hello i'm a fashion model. [SEP]",
'score': 0.1073106899857521,
'token': 4827,
'token_str': 'fashion'},
{'sequence': "[CLS] hello i'm a role model. [SEP]",
'score': 0.08774490654468536,
'token': 2535,
'token_str': 'role'},
{'sequence': "[CLS] hello i'm a new model. [SEP]",
'score': 0.05338378623127937,
'token': 2047,
'token_str': 'new'},
{'sequence': "[CLS] hello i'm a super model. [SEP]",
'score': 0.04667217284440994,
'token': 3565,
'token_str': 'super'},
{'sequence': "[CLS] hello i'm a fine model. [SEP]",
'score': 0.027095865458250046,
'token': 2986,
'token_str': 'fine'}]
```
Here is how to use this model to get the features of a given text in PyTorch:
```python
from transformers import BertTokenizer, BertModel
tokenizer = BertTokenizer.from_pretrained('bert-base-uncased')
model = BertModel.from_pretrained("bert-base-uncased")
text = "Replace me by any text you'd like."
encoded_input = tokenizer(text, return_tensors='pt')
output = model(**encoded_input)
```
and in TensorFlow:
```python
from transformers import BertTokenizer, TFBertModel
tokenizer = BertTokenizer.from_pretrained('bert-base-uncased')
model = TFBertModel.from_pretrained("bert-base-uncased")
text = "Replace me by any text you'd like."
encoded_input = tokenizer(text, return_tensors='tf')
output = model(encoded_input)
```
### Limitations and bias
Even if the training data used for this model could be characterized as fairly neutral, this model can have biased
predictions:
```python
>>> from transformers import pipeline
>>> unmasker = pipeline('fill-mask', model='bert-base-uncased')
>>> unmasker("The man worked as a [MASK].")
[{'sequence': '[CLS] the man worked as a carpenter. [SEP]',
'score': 0.09747550636529922,
'token': 10533,
'token_str': 'carpenter'},
{'sequence': '[CLS] the man worked as a waiter. [SEP]',
'score': 0.0523831807076931,
'token': 15610,
'token_str': 'waiter'},
{'sequence': '[CLS] the man worked as a barber. [SEP]',
'score': 0.04962705448269844,
'token': 13362,
'token_str': 'barber'},
{'sequence': '[CLS] the man worked as a mechanic. [SEP]',
'score': 0.03788609802722931,
'token': 15893,
'token_str': 'mechanic'},
{'sequence': '[CLS] the man worked as a salesman. [SEP]',
'score': 0.037680890411138535,
'token': 18968,
'token_str': 'salesman'}]
>>> unmasker("The woman worked as a [MASK].")
[{'sequence': '[CLS] the woman worked as a nurse. [SEP]',
'score': 0.21981462836265564,
'token': 6821,
'token_str': 'nurse'},
{'sequence': '[CLS] the woman worked as a waitress. [SEP]',
'score': 0.1597415804862976,
'token': 13877,
'token_str': 'waitress'},
{'sequence': '[CLS] the woman worked as a maid. [SEP]',
'score': 0.1154729500412941,
'token': 10850,
'token_str': 'maid'},
{'sequence': '[CLS] the woman worked as a prostitute. [SEP]',
'score': 0.037968918681144714,
'token': 19215,
'token_str': 'prostitute'},
{'sequence': '[CLS] the woman worked as a cook. [SEP]',
'score': 0.03042375110089779,
'token': 5660,
'token_str': 'cook'}]
```
This bias will also affect all fine-tuned versions of this model.
## Training data
The BERT model was pretrained on [BookCorpus](https://yknzhu.wixsite.com/mbweb), a dataset consisting of 11,038
unpublished books and [English Wikipedia](https://en.wikipedia.org/wiki/English_Wikipedia) (excluding lists, tables and
headers).
## Training procedure
### Preprocessing
The texts are lowercased and tokenized using WordPiece and a vocabulary size of 30,000. The inputs of the model are
then of the form:
```
[CLS] Sentence A [SEP] Sentence B [SEP]
```
With probability 0.5, sentence A and sentence B correspond to two consecutive sentences in the original corpus and in
the other cases, it's another random sentence in the corpus. Note that what is considered a sentence here is a
consecutive span of text usually longer than a single sentence. The only constrain is that the result with the two
"sentences" has a combined length of less than 512 tokens.
The details of the masking procedure for each sentence are the following:
- 15% of the tokens are masked.
- In 80% of the cases, the masked tokens are replaced by `[MASK]`.
- In 10% of the cases, the masked tokens are replaced by a random token (different) from the one they replace.
- In the 10% remaining cases, the masked tokens are left as is.
### Pretraining
The model was trained on 4 cloud TPUs in Pod configuration (16 TPU chips total) for one million steps with a batch size
of 256. The sequence length was limited to 128 tokens for 90% of the steps and 512 for the remaining 10%. The optimizer
used is Adam with a learning rate of 1e-4, \\(\beta_{1} = 0.9\\) and \\(\beta_{2} = 0.999\\), a weight decay of 0.01,
learning rate warmup for 10,000 steps and linear decay of the learning rate after.
## Evaluation results
When fine-tuned on downstream tasks, this model achieves the following results:
Glue test results:
| Task | MNLI-(m/mm) | QQP | QNLI | SST-2 | CoLA | STS-B | MRPC | RTE | Average |
|:----:|:-----------:|:----:|:----:|:-----:|:----:|:-----:|:----:|:----:|:-------:|
| | 84.6/83.4 | 71.2 | 90.5 | 93.5 | 52.1 | 85.8 | 88.9 | 66.4 | 79.6 |
### BibTeX entry and citation info
```bibtex
@article{DBLP:journals/corr/abs-1810-04805,
author = {Jacob Devlin and
Ming{-}Wei Chang and
Kenton Lee and
Kristina Toutanova},
title = {{BERT:} Pre-training of Deep Bidirectional Transformers for Language
Understanding},
journal = {CoRR},
volume = {abs/1810.04805},
year = {2018},
url = {http://arxiv.org/abs/1810.04805},
archivePrefix = {arXiv},
eprint = {1810.04805},
timestamp = {Tue, 30 Oct 2018 20:39:56 +0100},
biburl = {https://dblp.org/rec/journals/corr/abs-1810-04805.bib},
bibsource = {dblp computer science bibliography, https://dblp.org}
}
```
<a href="https://huggingface.co/exbert/?model=bert-base-uncased">
<img width="300px" src="https://cdn-media.huggingface.co/exbert/button.png">
</a>
| {"language": "en", "license": "apache-2.0", "tags": ["exbert"], "datasets": ["bookcorpus", "wikipedia"]} | benyong/testmodel | null | [
"transformers",
"pytorch",
"tf",
"jax",
"rust",
"bert",
"fill-mask",
"exbert",
"en",
"dataset:bookcorpus",
"dataset:wikipedia",
"arxiv:1810.04805",
"license:apache-2.0",
"autotrain_compatible",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
null | null | {} | benzajtil/DialoGPT-small-harrypotter | null | [
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
null | transformers |
# KcELECTRA: Korean comments ELECTRA
** Updates on 2022.10.08 **
- KcELECTRA-base-v2022 (๊ตฌ v2022-dev) ๋ชจ๋ธ ์ด๋ฆ์ด ๋ณ๊ฒฝ๋์์ต๋๋ค. --> KcELECTRA-base ๋ ํฌ์ `v2022`๋ก ํตํฉ๋์์ต๋๋ค.
- ์ ๋ชจ๋ธ์ ์ธ๋ถ ์ค์ฝ์ด๋ฅผ ์ถ๊ฐํ์์ต๋๋ค.
- ๊ธฐ์กด KcELECTRA-base(v2021) ๋๋น ๋๋ถ๋ถ์ downstream task์์ ~1%p ์์ค์ ์ฑ๋ฅ ํฅ์์ด ์์ต๋๋ค.
---
๊ณต๊ฐ๋ ํ๊ตญ์ด Transformer ๊ณ์ด ๋ชจ๋ธ๋ค์ ๋๋ถ๋ถ ํ๊ตญ์ด ์ํค, ๋ด์ค ๊ธฐ์ฌ, ์ฑ
๋ฑ ์ ์ ์ ๋ ๋ฐ์ดํฐ๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ํ์ตํ ๋ชจ๋ธ์
๋๋ค. ํํธ, ์ค์ ๋ก NSMC์ ๊ฐ์ User-Generated Noisy text domain ๋ฐ์ดํฐ์
์ ์ ์ ๋์ง ์์๊ณ ๊ตฌ์ด์ฒด ํน์ง์ ์ ์กฐ์ด๊ฐ ๋ง์ผ๋ฉฐ, ์คํ์ ๋ฑ ๊ณต์์ ์ธ ๊ธ์ฐ๊ธฐ์์ ๋ํ๋์ง ์๋ ํํ๋ค์ด ๋น๋ฒํ๊ฒ ๋ฑ์ฅํฉ๋๋ค.
KcELECTRA๋ ์์ ๊ฐ์ ํน์ฑ์ ๋ฐ์ดํฐ์
์ ์ ์ฉํ๊ธฐ ์ํด, ๋ค์ด๋ฒ ๋ด์ค์์ ๋๊ธ๊ณผ ๋๋๊ธ์ ์์งํด, ํ ํฌ๋์ด์ ์ ELECTRA๋ชจ๋ธ์ ์ฒ์๋ถํฐ ํ์ตํ Pretrained ELECTRA ๋ชจ๋ธ์
๋๋ค.
๊ธฐ์กด KcBERT ๋๋น ๋ฐ์ดํฐ์
์ฆ๊ฐ ๋ฐ vocab ํ์ฅ์ ํตํด ์๋นํ ์์ค์ผ๋ก ์ฑ๋ฅ์ด ํฅ์๋์์ต๋๋ค.
KcELECTRA๋ Huggingface์ Transformers ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ํตํด ๊ฐํธํ ๋ถ๋ฌ์ ์ฌ์ฉํ ์ ์์ต๋๋ค. (๋ณ๋์ ํ์ผ ๋ค์ด๋ก๋๊ฐ ํ์ํ์ง ์์ต๋๋ค.)
```
๐ก NOTE ๐ก
General Corpus๋ก ํ์ตํ KoELECTRA๊ฐ ๋ณดํธ์ ์ธ task์์๋ ์ฑ๋ฅ์ด ๋ ์ ๋์ฌ ๊ฐ๋ฅ์ฑ์ด ๋์ต๋๋ค.
KcBERT/KcELECTRA๋ User genrated, Noisy text์ ๋ํด์ ๋ณด๋ค ์ ๋์ํ๋ PLM์
๋๋ค.
```
## KcELECTRA Performance
- Finetune ์ฝ๋๋ https://github.com/Beomi/KcBERT-finetune ์์ ์ฐพ์๋ณด์ค ์ ์์ต๋๋ค.
- ํด๋น Repo์ ๊ฐ Checkpoint ํด๋์์ Step๋ณ ์ธ๋ถ ์ค์ฝ์ด๋ฅผ ํ์ธํ์ค ์ ์์ต๋๋ค.
| | Size<br/>(์ฉ๋) | **NSMC**<br/>(acc) | **Naver NER**<br/>(F1) | **PAWS**<br/>(acc) | **KorNLI**<br/>(acc) | **KorSTS**<br/>(spearman) | **Question Pair**<br/>(acc) | **KorQuaD (Dev)**<br/>(EM/F1) |
| :----------------- | :-------------: | :----------------: | :--------------------: | :----------------: | :------------------: | :-----------------------: | :-------------------------: | :---------------------------: |
| **KcELECTRA-base-v2022** | 475M | **91.97** | 87.35 | 76.50 | 82.12 | 83.67 | 95.12 | 69.00 / 90.40 |
| **KcELECTRA-base** | 475M | 91.71 | 86.90 | 74.80 | 81.65 | 82.65 | **95.78** | 70.60 / 90.11 |
| KcBERT-Base | 417M | 89.62 | 84.34 | 66.95 | 74.85 | 75.57 | 93.93 | 60.25 / 84.39 |
| KcBERT-Large | 1.2G | 90.68 | 85.53 | 70.15 | 76.99 | 77.49 | 94.06 | 62.16 / 86.64 |
| KoBERT | 351M | 89.63 | 86.11 | 80.65 | 79.00 | 79.64 | 93.93 | 52.81 / 80.27 |
| XLM-Roberta-Base | 1.03G | 89.49 | 86.26 | 82.95 | 79.92 | 79.09 | 93.53 | 64.70 / 88.94 |
| HanBERT | 614M | 90.16 | 87.31 | 82.40 | 80.89 | 83.33 | 94.19 | 78.74 / 92.02 |
| KoELECTRA-Base | 423M | 90.21 | 86.87 | 81.90 | 80.85 | 83.21 | 94.20 | 61.10 / 89.59 |
| KoELECTRA-Base-v2 | 423M | 89.70 | 87.02 | 83.90 | 80.61 | 84.30 | 94.72 | 84.34 / 92.58 |
| KoELECTRA-Base-v3 | 423M | 90.63 | **88.11** | **84.45** | **82.24** | **85.53** | 95.25 | **84.83 / 93.45** |
| DistilKoBERT | 108M | 88.41 | 84.13 | 62.55 | 70.55 | 73.21 | 92.48 | 54.12 / 77.80 |
\*HanBERT์ Size๋ Bert Model๊ณผ Tokenizer DB๋ฅผ ํฉ์น ๊ฒ์
๋๋ค.
\***config์ ์ธํ
์ ๊ทธ๋๋ก ํ์ฌ ๋๋ฆฐ ๊ฒฐ๊ณผ์ด๋ฉฐ, hyperparameter tuning์ ์ถ๊ฐ์ ์ผ๋ก ํ ์ ๋ ์ข์ ์ฑ๋ฅ์ด ๋์ฌ ์ ์์ต๋๋ค.**
## How to use
### Requirements
- `pytorch ~= 1.8.0`
- `transformers ~= 4.11.3`
- `emoji ~= 0.6.0`
- `soynlp ~= 0.0.493`
### Default usage
```python
from transformers import AutoTokenizer, AutoModel
tokenizer = AutoTokenizer.from_pretrained("beomi/KcELECTRA-base")
model = AutoModel.from_pretrained("beomi/KcELECTRA-base")
```
> ๐ก ์ด์ KcBERT ๊ด๋ จ ์ฝ๋๋ค์์ `AutoTokenizer`, `AutoModel` ์ ์ฌ์ฉํ ๊ฒฝ์ฐ `.from_pretrained("beomi/kcbert-base")` ๋ถ๋ถ์ `.from_pretrained("beomi/KcELECTRA-base")` ๋ก๋ง ๋ณ๊ฒฝํด์ฃผ์๋ฉด ์ฆ์ ์ฌ์ฉ์ด ๊ฐ๋ฅํฉ๋๋ค.
### Pretrain & Finetune Colab ๋งํฌ ๋ชจ์
#### Pretrain Data
- KcBERTํ์ต์ ์ฌ์ฉํ ๋ฐ์ดํฐ + ์ดํ 2021.03์ ์ด๊น์ง ์์งํ ๋๊ธ
- ์ฝ 17GB
- ๋๊ธ-๋๋๊ธ์ ๋ฌถ์ ๊ธฐ๋ฐ์ผ๋ก Document ๊ตฌ์ฑ
#### Pretrain Code
- https://github.com/KLUE-benchmark/KLUE-ELECTRA Repo๋ฅผ ํตํ Pretrain
#### Finetune Code
- https://github.com/Beomi/KcBERT-finetune Repo๋ฅผ ํตํ Finetune ๋ฐ ์ค์ฝ์ด ๋น๊ต
#### Finetune Samples
- NSMC with PyTorch-Lightning 1.3.0, GPU, Colab <a href="https://colab.research.google.com/drive/1Hh63kIBAiBw3Hho--BvfdUWLu-ysMFF0?usp=sharing">
<img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/>
</a>
## Train Data & Preprocessing
### Raw Data
ํ์ต ๋ฐ์ดํฐ๋ 2019.01.01 ~ 2021.03.09 ์ฌ์ด์ ์์ฑ๋ **๋๊ธ ๋ง์ ๋ด์ค/ํน์ ์ ์ฒด ๋ด์ค** ๊ธฐ์ฌ๋ค์ **๋๊ธ๊ณผ ๋๋๊ธ**์ ๋ชจ๋ ์์งํ ๋ฐ์ดํฐ์
๋๋ค.
๋ฐ์ดํฐ ์ฌ์ด์ฆ๋ ํ
์คํธ๋ง ์ถ์ถ์ **์ฝ 17.3GB์ด๋ฉฐ, 1์ต8์ฒ๋ง๊ฐ ์ด์์ ๋ฌธ์ฅ**์ผ๋ก ์ด๋ค์ ธ ์์ต๋๋ค.
> KcBERT๋ 2019.01-2020.06์ ํ
์คํธ๋ก, ์ ์ ํ ์ฝ 9์ฒ๋ง๊ฐ ๋ฌธ์ฅ์ผ๋ก ํ์ต์ ์งํํ์ต๋๋ค.
### Preprocessing
PLM ํ์ต์ ์ํด์ ์ ์ฒ๋ฆฌ๋ฅผ ์งํํ ๊ณผ์ ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
1. ํ๊ธ ๋ฐ ์์ด, ํน์๋ฌธ์, ๊ทธ๋ฆฌ๊ณ ์ด๋ชจ์ง(๐ฅณ)๊น์ง!
์ ๊ทํํ์์ ํตํด ํ๊ธ, ์์ด, ํน์๋ฌธ์๋ฅผ ํฌํจํด Emoji๊น์ง ํ์ต ๋์์ ํฌํจํ์ต๋๋ค.
ํํธ, ํ๊ธ ๋ฒ์๋ฅผ `ใฑ-ใ
๊ฐ-ํฃ` ์ผ๋ก ์ง์ ํด `ใฑ-ํฃ` ๋ด์ ํ์๋ฅผ ์ ์ธํ์ต๋๋ค.
2. ๋๊ธ ๋ด ์ค๋ณต ๋ฌธ์์ด ์ถ์ฝ
`ใ
ใ
ใ
ใ
ใ
`์ ๊ฐ์ด ์ค๋ณต๋ ๊ธ์๋ฅผ `ใ
ใ
`์ ๊ฐ์ ๊ฒ์ผ๋ก ํฉ์ณค์ต๋๋ค.
3. Cased Model
KcBERT๋ ์๋ฌธ์ ๋ํด์๋ ๋์๋ฌธ์๋ฅผ ์ ์งํ๋ Cased model์
๋๋ค.
4. ๊ธ์ ๋จ์ 10๊ธ์ ์ดํ ์ ๊ฑฐ
10๊ธ์ ๋ฏธ๋ง์ ํ
์คํธ๋ ๋จ์ผ ๋จ์ด๋ก ์ด๋ค์ง ๊ฒฝ์ฐ๊ฐ ๋ง์ ํด๋น ๋ถ๋ถ์ ์ ์ธํ์ต๋๋ค.
5. ์ค๋ณต ์ ๊ฑฐ
์ค๋ณต์ ์ผ๋ก ์ฐ์ธ ๋๊ธ์ ์ ๊ฑฐํ๊ธฐ ์ํด ์์ ํ ์ผ์นํ๋ ์ค๋ณต ๋๊ธ์ ํ๋๋ก ํฉ์ณค์ต๋๋ค.
6. `OOO` ์ ๊ฑฐ
๋ค์ด๋ฒ ๋๊ธ์ ๊ฒฝ์ฐ, ๋น์์ด๋ ์์ฒด ํํฐ๋ง์ ํตํด `OOO` ๋ก ํ์ํฉ๋๋ค. ์ด ๋ถ๋ถ์ ๊ณต๋ฐฑ์ผ๋ก ์ ๊ฑฐํ์์ต๋๋ค.
์๋ ๋ช
๋ น์ด๋ก pip๋ก ์ค์นํ ๋ค, ์๋ cleanํจ์๋ก ํด๋ฆฌ๋์ ํ๋ฉด Downstream task์์ ๋ณด๋ค ์ฑ๋ฅ์ด ์ข์์ง๋๋ค. (`[UNK]` ๊ฐ์)
```bash
pip install soynlp emoji
```
์๋ `clean` ํจ์๋ฅผ Text data์ ์ฌ์ฉํด์ฃผ์ธ์.
```python
import re
import emoji
from soynlp.normalizer import repeat_normalize
emojis = ''.join(emoji.UNICODE_EMOJI.keys())
pattern = re.compile(f'[^ .,?!/@$%~๏ผ
ยทโผ()\x00-\x7Fใฑ-ใ
ฃ๊ฐ-ํฃ{emojis}]+')
url_pattern = re.compile(
r'https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)')
import re
import emoji
from soynlp.normalizer import repeat_normalize
pattern = re.compile(f'[^ .,?!/@$%~๏ผ
ยทโผ()\x00-\x7Fใฑ-ใ
ฃ๊ฐ-ํฃ]+')
url_pattern = re.compile(
r'https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)')
def clean(x):
x = pattern.sub(' ', x)
x = emoji.replace_emoji(x, replace='') #emoji ์ญ์
x = url_pattern.sub('', x)
x = x.strip()
x = repeat_normalize(x, num_repeats=2)
return x
```
> ๐ก Finetune Score์์๋ ์ `clean` ํจ์๋ฅผ ์ ์ฉํ์ง ์์์ต๋๋ค.
### Cleaned Data
- KcBERT ์ธ ์ถ๊ฐ ๋ฐ์ดํฐ๋ ์ ๋ฆฌ ํ ๊ณต๊ฐ ์์ ์
๋๋ค.
## Tokenizer, Model Train
Tokenizer๋ Huggingface์ [Tokenizers](https://github.com/huggingface/tokenizers) ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ํตํด ํ์ต์ ์งํํ์ต๋๋ค.
๊ทธ ์ค `BertWordPieceTokenizer` ๋ฅผ ์ด์ฉํด ํ์ต์ ์งํํ๊ณ , Vocab Size๋ `30000`์ผ๋ก ์งํํ์ต๋๋ค.
Tokenizer๋ฅผ ํ์ตํ๋ ๊ฒ์๋ ์ ์ฒด ๋ฐ์ดํฐ๋ฅผ ํตํด ํ์ต์ ์งํํ๊ณ , ๋ชจ๋ธ์ General Downstream task์ ๋์ํ๊ธฐ ์ํด KoELECTRA์์ ์ฌ์ฉํ Vocab์ ๊ฒน์น์ง ์๋ ๋ถ๋ถ์ ์ถ๊ฐ๋ก ๋ฃ์ด์ฃผ์์ต๋๋ค. (์ค์ ๋ก ๋ ๋ชจ๋ธ์ด ๊ฒน์น๋ ๋ถ๋ถ์ ์ฝ 5000ํ ํฐ์ด์์ต๋๋ค.)
TPU `v3-8` ์ ์ด์ฉํด ์ฝ 10์ผ ํ์ต์ ์งํํ๊ณ , ํ์ฌ Huggingface์ ๊ณต๊ฐ๋ ๋ชจ๋ธ์ 848k step์ ํ์ตํ ๋ชจ๋ธ weight๊ฐ ์
๋ก๋ ๋์ด์์ต๋๋ค.
(100k step๋ณ Checkpoint๋ฅผ ํตํด ์ฑ๋ฅ ํ๊ฐ๋ฅผ ์งํํ์์ต๋๋ค. ํด๋น ๋ถ๋ถ์ `KcBERT-finetune` repo๋ฅผ ์ฐธ๊ณ ํด์ฃผ์ธ์.)
๋ชจ๋ธ ํ์ต Loss๋ Step์ ๋ฐ๋ผ ์ด๊ธฐ 100-200k ์ฌ์ด์ ๊ธ๊ฒฉํ Loss๊ฐ ์ค์ด๋ค๋ค ํ์ต ์ข
๋ฃ๊น์ง๋ ์ง์์ ์ผ๋ก loss๊ฐ ๊ฐ์ํ๋ ๊ฒ์ ๋ณผ ์ ์์ต๋๋ค.

### KcELECTRA Pretrain Step๋ณ Downstream task ์ฑ๋ฅ ๋น๊ต
> ๐ก ์๋ ํ๋ ์ ์ฒด ckpt๊ฐ ์๋ ์ผ๋ถ์ ๋ํด์๋ง ํ
์คํธ๋ฅผ ์งํํ ๊ฒฐ๊ณผ์
๋๋ค.

- ์์ ๊ฐ์ด KcBERT-base, KcBERT-large ๋๋น **๋ชจ๋ ๋ฐ์ดํฐ์
์ ๋ํด** KcELECTRA-base๊ฐ ๋ ๋์ ์ฑ๋ฅ์ ๋ณด์
๋๋ค.
- KcELECTRA pretrain์์๋ Train step์ด ๋์ด๊ฐ์ ๋ฐ๋ผ ์ ์ง์ ์ผ๋ก ์ฑ๋ฅ์ด ํฅ์๋๋ ๊ฒ์ ๋ณผ ์ ์์ต๋๋ค.
## ์ธ์ฉํ๊ธฐ/Citation
KcELECTRA๋ฅผ ์ธ์ฉํ์ค ๋๋ ์๋ ์์์ ํตํด ์ธ์ฉํด์ฃผ์ธ์.
```
@misc{lee2021kcelectra,
author = {Junbum Lee},
title = {KcELECTRA: Korean comments ELECTRA},
year = {2021},
publisher = {GitHub},
journal = {GitHub repository},
howpublished = {\url{https://github.com/Beomi/KcELECTRA}}
}
```
๋
ผ๋ฌธ์ ํตํ ์ฌ์ฉ ์ธ์๋ MIT ๋ผ์ด์ผ์ค๋ฅผ ํ๊ธฐํด์ฃผ์ธ์. โบ๏ธ
## Acknowledgement
KcELECTRA Model์ ํ์ตํ๋ GCP/TPU ํ๊ฒฝ์ [TFRC](https://www.tensorflow.org/tfrc?hl=ko) ํ๋ก๊ทธ๋จ์ ์ง์์ ๋ฐ์์ต๋๋ค.
๋ชจ๋ธ ํ์ต ๊ณผ์ ์์ ๋ง์ ์กฐ์ธ์ ์ฃผ์ [Monologg](https://github.com/monologg/) ๋ ๊ฐ์ฌํฉ๋๋ค :)
## Reference
### Github Repos
- [KcBERT by Beomi](https://github.com/Beomi/KcBERT)
- [BERT by Google](https://github.com/google-research/bert)
- [KoBERT by SKT](https://github.com/SKTBrain/KoBERT)
- [KoELECTRA by Monologg](https://github.com/monologg/KoELECTRA/)
- [Transformers by Huggingface](https://github.com/huggingface/transformers)
- [Tokenizers by Hugginface](https://github.com/huggingface/tokenizers)
- [ELECTRA train code by KLUE](https://github.com/KLUE-benchmark/KLUE-ELECTRA)
### Blogs
- [Monologg๋์ KoELECTRA ํ์ต๊ธฐ](https://monologg.kr/categories/NLP/ELECTRA/)
- [Colab์์ TPU๋ก BERT ์ฒ์๋ถํฐ ํ์ต์ํค๊ธฐ - Tensorflow/Google ver.](https://beomi.github.io/2020/02/26/Train-BERT-from-scratch-on-colab-TPU-Tensorflow-ver/)
| {"language": ["ko", "en"], "license": "mit", "tags": ["electra", "korean"]} | beomi/KcELECTRA-base | null | [
"transformers",
"pytorch",
"electra",
"pretraining",
"korean",
"ko",
"en",
"doi:10.57967/hf/0017",
"license:mit",
"endpoints_compatible",
"has_space",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
text2text-generation | transformers | {"license": "mit"} | beomi/KcT5-dev | null | [
"transformers",
"jax",
"t5",
"text2text-generation",
"license:mit",
"autotrain_compatible",
"endpoints_compatible",
"text-generation-inference",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
null | null | {"license": "mit"} | beomi/KcT5 | null | [
"license:mit",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
text-classification | transformers | {} | beomi/beep-KR-Medium-hate | null | [
"transformers",
"pytorch",
"safetensors",
"bert",
"text-classification",
"autotrain_compatible",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
text-classification | transformers | {} | beomi/beep-KcELECTRA-base-bias | null | [
"transformers",
"pytorch",
"safetensors",
"electra",
"text-classification",
"autotrain_compatible",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
text-classification | transformers | {} | beomi/beep-KcELECTRA-base-hate | null | [
"transformers",
"pytorch",
"electra",
"text-classification",
"autotrain_compatible",
"endpoints_compatible",
"has_space",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
null | null | {} | beomi/beep-KcELECTRA-base-hate_singlelabel | null | [
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
text-classification | transformers | {} | beomi/beep-kcbert-base-bias | null | [
"transformers",
"pytorch",
"bert",
"text-classification",
"autotrain_compatible",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
text-classification | transformers | {} | beomi/beep-kcbert-base-hate | null | [
"transformers",
"pytorch",
"bert",
"text-classification",
"autotrain_compatible",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
text-classification | transformers | {} | beomi/beep-klue-roberta-base-bias | null | [
"transformers",
"pytorch",
"roberta",
"text-classification",
"autotrain_compatible",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
text-classification | transformers | {} | beomi/beep-klue-roberta-base-hate | null | [
"transformers",
"pytorch",
"roberta",
"text-classification",
"autotrain_compatible",
"endpoints_compatible",
"has_space",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
text-classification | transformers | {} | beomi/beep-koelectra-base-v3-discriminator-bias | null | [
"transformers",
"pytorch",
"electra",
"text-classification",
"autotrain_compatible",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
text-classification | transformers | {} | beomi/beep-koelectra-base-v3-discriminator-hate | null | [
"transformers",
"pytorch",
"electra",
"text-classification",
"autotrain_compatible",
"endpoints_compatible",
"has_space",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
null | null | {} | beomi/beep-roberta-base-hate | null | [
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
fill-mask | transformers | {} | beomi/detox-kcbert-base | null | [
"transformers",
"pytorch",
"bert",
"fill-mask",
"autotrain_compatible",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
text-classification | transformers |
<!-- This model card has been generated automatically according to the information the Trainer had access to. You
should probably proofread and complete it, then remove this comment. -->
# distilbert-base-uncased-finetuned-cola
This model is a fine-tuned version of [distilbert-base-uncased](https://huggingface.co/distilbert-base-uncased) on the glue dataset.
It achieves the following results on the evaluation set:
- Loss: 0.7525
- Matthews Correlation: 0.5553
## Model description
More information needed
## Intended uses & limitations
More information needed
## Training and evaluation data
More information needed
## Training procedure
### Training hyperparameters
The following hyperparameters were used during training:
- learning_rate: 2e-05
- train_batch_size: 16
- eval_batch_size: 16
- seed: 42
- optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
- lr_scheduler_type: linear
- num_epochs: 5
### Training results
| Training Loss | Epoch | Step | Validation Loss | Matthews Correlation |
|:-------------:|:-----:|:----:|:---------------:|:--------------------:|
| 0.523 | 1.0 | 535 | 0.5024 | 0.4160 |
| 0.3437 | 2.0 | 1070 | 0.5450 | 0.4965 |
| 0.2326 | 3.0 | 1605 | 0.6305 | 0.5189 |
| 0.177 | 4.0 | 2140 | 0.7525 | 0.5553 |
| 0.1354 | 5.0 | 2675 | 0.8630 | 0.5291 |
### Framework versions
- Transformers 4.11.3
- Pytorch 1.9.0+cu111
- Datasets 1.13.3
- Tokenizers 0.10.3
| {"license": "apache-2.0", "tags": ["generated_from_trainer"], "datasets": ["glue"], "metrics": ["matthews_correlation"], "model-index": [{"name": "distilbert-base-uncased-finetuned-cola", "results": [{"task": {"type": "text-classification", "name": "Text Classification"}, "dataset": {"name": "glue", "type": "glue", "args": "cola"}, "metrics": [{"type": "matthews_correlation", "value": 0.5552849676135797, "name": "Matthews Correlation"}]}]}]} | beomi/distilbert-base-uncased-finetuned-cola | null | [
"transformers",
"pytorch",
"tensorboard",
"distilbert",
"text-classification",
"generated_from_trainer",
"dataset:glue",
"license:apache-2.0",
"model-index",
"autotrain_compatible",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
fill-mask | transformers | {} | beomi/exKcBERT-kowiki | null | [
"transformers",
"pytorch",
"exbert",
"fill-mask",
"autotrain_compatible",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
fill-mask | transformers | {} | beomi/exKcBERT-paws-extonly | null | [
"transformers",
"pytorch",
"exbert",
"fill-mask",
"autotrain_compatible",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
fill-mask | transformers | {} | beomi/exKcBERT-paws | null | [
"transformers",
"pytorch",
"exbert",
"fill-mask",
"autotrain_compatible",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
null | null | {} | beomi/exKcBERT | null | [
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
fill-mask | transformers | {} | beomi/kcbert-base-dev | null | [
"transformers",
"pytorch",
"jax",
"bert",
"fill-mask",
"autotrain_compatible",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
fill-mask | transformers |
# KcBERT: Korean comments BERT
** Updates on 2021.04.07 **
- KcELECTRA๊ฐ ๋ฆด๋ฆฌ์ฆ ๋์์ต๋๋ค!๐ค
- KcELECTRA๋ ๋ณด๋ค ๋ ๋ง์ ๋ฐ์ดํฐ์
, ๊ทธ๋ฆฌ๊ณ ๋ ํฐ General vocab์ ํตํด KcBERT ๋๋น **๋ชจ๋ ํ์คํฌ์์ ๋ ๋์ ์ฑ๋ฅ**์ ๋ณด์
๋๋ค.
- ์๋ ๊นํ ๋งํฌ์์ ์ง์ ์ฌ์ฉํด๋ณด์ธ์!
- https://github.com/Beomi/KcELECTRA
** Updates on 2021.03.14 **
- KcBERT Paper ์ธ์ฉ ํ๊ธฐ๋ฅผ ์ถ๊ฐํ์์ต๋๋ค.(bibtex)
- KcBERT-finetune Performance score๋ฅผ ๋ณธ๋ฌธ์ ์ถ๊ฐํ์์ต๋๋ค.
** Updates on 2020.12.04 **
Huggingface Transformers๊ฐ v4.0.0์ผ๋ก ์
๋ฐ์ดํธ๋จ์ ๋ฐ๋ผ Tutorial์ ์ฝ๋๊ฐ ์ผ๋ถ ๋ณ๊ฒฝ๋์์ต๋๋ค.
์
๋ฐ์ดํธ๋ KcBERT-Large NSMC Finetuning Colab: <a href="https://colab.research.google.com/drive/1dFC0FL-521m7CL_PSd8RLKq67jgTJVhL?usp=sharing">
<img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/>
</a>
** Updates on 2020.09.11 **
KcBERT๋ฅผ Google Colab์์ TPU๋ฅผ ํตํด ํ์ตํ ์ ์๋ ํํ ๋ฆฌ์ผ์ ์ ๊ณตํฉ๋๋ค! ์๋ ๋ฒํผ์ ๋๋ฌ๋ณด์ธ์.
Colab์์ TPU๋ก KcBERT Pretrain ํด๋ณด๊ธฐ: <a href="https://colab.research.google.com/drive/1lYBYtaXqt9S733OXdXvrvC09ysKFN30W">
<img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/>
</a>
ํ
์คํธ ๋ถ๋๋ง ์ ์ฒด 12G ํ
์คํธ ์ค ์ผ๋ถ(144MB)๋ก ์ค์ฌ ํ์ต์ ์งํํฉ๋๋ค.
ํ๊ตญ์ด ๋ฐ์ดํฐ์
/์ฝํผ์ค๋ฅผ ์ข๋ ์ฝ๊ฒ ์ฌ์ฉํ ์ ์๋ [Korpora](https://github.com/ko-nlp/Korpora) ํจํค์ง๋ฅผ ์ฌ์ฉํฉ๋๋ค.
** Updates on 2020.09.08 **
Github Release๋ฅผ ํตํด ํ์ต ๋ฐ์ดํฐ๋ฅผ ์
๋ก๋ํ์์ต๋๋ค.
๋ค๋ง ํ ํ์ผ๋น 2GB ์ด๋ด์ ์ ์ฝ์ผ๋ก ์ธํด ๋ถํ ์์ถ๋์ด์์ต๋๋ค.
์๋ ๋งํฌ๋ฅผ ํตํด ๋ฐ์์ฃผ์ธ์. (๊ฐ์
์์ด ๋ฐ์ ์ ์์ด์. ๋ถํ ์์ถ)
๋ง์ฝ ํ ํ์ผ๋ก ๋ฐ๊ณ ์ถ์ผ์๊ฑฐ๋/Kaggle์์ ๋ฐ์ดํฐ๋ฅผ ์ดํด๋ณด๊ณ ์ถ์ผ์๋ค๋ฉด ์๋์ ์บ๊ธ ๋ฐ์ดํฐ์
์ ์ด์ฉํด์ฃผ์ธ์.
- Github๋ฆด๋ฆฌ์ฆ: https://github.com/Beomi/KcBERT/releases/tag/TrainData_v1
** Updates on 2020.08.22 **
Pretrain Dataset ๊ณต๊ฐ
- ์บ๊ธ: https://www.kaggle.com/junbumlee/kcbert-pretraining-corpus-korean-news-comments (ํ ํ์ผ๋ก ๋ฐ์ ์ ์์ด์. ๋จ์ผํ์ผ)
Kaggle์ ํ์ต์ ์ํด ์ ์ ํ(์๋ `clean`์ฒ๋ฆฌ๋ฅผ ๊ฑฐ์น) Dataset์ ๊ณต๊ฐํ์์ต๋๋ค!
์ง์ ๋ค์ด๋ฐ์ผ์
์ ๋ค์ํ Task์ ํ์ต์ ์งํํด๋ณด์ธ์ :)
---
๊ณต๊ฐ๋ ํ๊ตญ์ด BERT๋ ๋๋ถ๋ถ ํ๊ตญ์ด ์ํค, ๋ด์ค ๊ธฐ์ฌ, ์ฑ
๋ฑ ์ ์ ์ ๋ ๋ฐ์ดํฐ๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ํ์ตํ ๋ชจ๋ธ์
๋๋ค. ํํธ, ์ค์ ๋ก NSMC์ ๊ฐ์ ๋๊ธํ ๋ฐ์ดํฐ์
์ ์ ์ ๋์ง ์์๊ณ ๊ตฌ์ด์ฒด ํน์ง์ ์ ์กฐ์ด๊ฐ ๋ง์ผ๋ฉฐ, ์คํ์ ๋ฑ ๊ณต์์ ์ธ ๊ธ์ฐ๊ธฐ์์ ๋ํ๋์ง ์๋ ํํ๋ค์ด ๋น๋ฒํ๊ฒ ๋ฑ์ฅํฉ๋๋ค.
KcBERT๋ ์์ ๊ฐ์ ํน์ฑ์ ๋ฐ์ดํฐ์
์ ์ ์ฉํ๊ธฐ ์ํด, ๋ค์ด๋ฒ ๋ด์ค์์ ๋๊ธ๊ณผ ๋๋๊ธ์ ์์งํด, ํ ํฌ๋์ด์ ์ BERT๋ชจ๋ธ์ ์ฒ์๋ถํฐ ํ์ตํ Pretrained BERT ๋ชจ๋ธ์
๋๋ค.
KcBERT๋ Huggingface์ Transformers ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ํตํด ๊ฐํธํ ๋ถ๋ฌ์ ์ฌ์ฉํ ์ ์์ต๋๋ค. (๋ณ๋์ ํ์ผ ๋ค์ด๋ก๋๊ฐ ํ์ํ์ง ์์ต๋๋ค.)
## KcBERT Performance
- Finetune ์ฝ๋๋ https://github.com/Beomi/KcBERT-finetune ์์ ์ฐพ์๋ณด์ค ์ ์์ต๋๋ค.
| | Size<br/>(์ฉ๋) | **NSMC**<br/>(acc) | **Naver NER**<br/>(F1) | **PAWS**<br/>(acc) | **KorNLI**<br/>(acc) | **KorSTS**<br/>(spearman) | **Question Pair**<br/>(acc) | **KorQuaD (Dev)**<br/>(EM/F1) |
| :-------------------- | :---: | :----------------: | :--------------------: | :----------------: | :------------------: | :-----------------------: | :-------------------------: | :---------------------------: |
| KcBERT-Base | 417M | 89.62 | 84.34 | 66.95 | 74.85 | 75.57 | 93.93 | 60.25 / 84.39 |
| KcBERT-Large | 1.2G | **90.68** | 85.53 | 70.15 | 76.99 | 77.49 | 94.06 | 62.16 / 86.64 |
| KoBERT | 351M | 89.63 | 86.11 | 80.65 | 79.00 | 79.64 | 93.93 | 52.81 / 80.27 |
| XLM-Roberta-Base | 1.03G | 89.49 | 86.26 | 82.95 | 79.92 | 79.09 | 93.53 | 64.70 / 88.94 |
| HanBERT | 614M | 90.16 | **87.31** | 82.40 | **80.89** | 83.33 | 94.19 | 78.74 / 92.02 |
| KoELECTRA-Base | 423M | **90.21** | 86.87 | 81.90 | 80.85 | 83.21 | 94.20 | 61.10 / 89.59 |
| KoELECTRA-Base-v2 | 423M | 89.70 | 87.02 | **83.90** | 80.61 | **84.30** | **94.72** | **84.34 / 92.58** |
| DistilKoBERT | 108M | 88.41 | 84.13 | 62.55 | 70.55 | 73.21 | 92.48 | 54.12 / 77.80 |
\*HanBERT์ Size๋ Bert Model๊ณผ Tokenizer DB๋ฅผ ํฉ์น ๊ฒ์
๋๋ค.
\***config์ ์ธํ
์ ๊ทธ๋๋ก ํ์ฌ ๋๋ฆฐ ๊ฒฐ๊ณผ์ด๋ฉฐ, hyperparameter tuning์ ์ถ๊ฐ์ ์ผ๋ก ํ ์ ๋ ์ข์ ์ฑ๋ฅ์ด ๋์ฌ ์ ์์ต๋๋ค.**
## How to use
### Requirements
- `pytorch <= 1.8.0`
- `transformers ~= 3.0.1`
- `transformers ~= 4.0.0` ๋ ํธํ๋ฉ๋๋ค.
- `emoji ~= 0.6.0`
- `soynlp ~= 0.0.493`
```python
from transformers import AutoTokenizer, AutoModelWithLMHead
# Base Model (108M)
tokenizer = AutoTokenizer.from_pretrained("beomi/kcbert-base")
model = AutoModelWithLMHead.from_pretrained("beomi/kcbert-base")
# Large Model (334M)
tokenizer = AutoTokenizer.from_pretrained("beomi/kcbert-large")
model = AutoModelWithLMHead.from_pretrained("beomi/kcbert-large")
```
### Pretrain & Finetune Colab ๋งํฌ ๋ชจ์
#### Pretrain Data
- [๋ฐ์ดํฐ์
๋ค์ด๋ก๋(Kaggle, ๋จ์ผํ์ผ, ๋ก๊ทธ์ธ ํ์)](https://www.kaggle.com/junbumlee/kcbert-pretraining-corpus-korean-news-comments)
- [๋ฐ์ดํฐ์
๋ค์ด๋ก๋(Github, ์์ถ ์ฌ๋ฌํ์ผ, ๋ก๊ทธ์ธ ๋ถํ์)](https://github.com/Beomi/KcBERT/releases/tag/TrainData_v1)
#### Pretrain Code
Colab์์ TPU๋ก KcBERT Pretrain ํด๋ณด๊ธฐ: <a href="https://colab.research.google.com/drive/1lYBYtaXqt9S733OXdXvrvC09ysKFN30W">
<img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/>
</a>
#### Finetune Samples
**KcBERT-Base** NSMC Finetuning with PyTorch-Lightning (Colab) <a href="https://colab.research.google.com/drive/1fn4sVJ82BrrInjq6y5655CYPP-1UKCLb?usp=sharing">
<img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/>
</a>
**KcBERT-Large** NSMC Finetuning with PyTorch-Lightning (Colab) <a href="https://colab.research.google.com/drive/1dFC0FL-521m7CL_PSd8RLKq67jgTJVhL?usp=sharing">
<img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/>
</a>
> ์ ๋ ์ฝ๋๋ Pretrain ๋ชจ๋ธ(base, large)์ batch size๋ง ๋ค๋ฅผ ๋ฟ, ๋๋จธ์ง ์ฝ๋๋ ์์ ํ ๋์ผํฉ๋๋ค.
## Train Data & Preprocessing
### Raw Data
ํ์ต ๋ฐ์ดํฐ๋ 2019.01.01 ~ 2020.06.15 ์ฌ์ด์ ์์ฑ๋ **๋๊ธ ๋ง์ ๋ด์ค** ๊ธฐ์ฌ๋ค์ **๋๊ธ๊ณผ ๋๋๊ธ**์ ๋ชจ๋ ์์งํ ๋ฐ์ดํฐ์
๋๋ค.
๋ฐ์ดํฐ ์ฌ์ด์ฆ๋ ํ
์คํธ๋ง ์ถ์ถ์ **์ฝ 15.4GB์ด๋ฉฐ, 1์ต1์ฒ๋ง๊ฐ ์ด์์ ๋ฌธ์ฅ**์ผ๋ก ์ด๋ค์ ธ ์์ต๋๋ค.
### Preprocessing
PLM ํ์ต์ ์ํด์ ์ ์ฒ๋ฆฌ๋ฅผ ์งํํ ๊ณผ์ ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
1. ํ๊ธ ๋ฐ ์์ด, ํน์๋ฌธ์, ๊ทธ๋ฆฌ๊ณ ์ด๋ชจ์ง(๐ฅณ)๊น์ง!
์ ๊ทํํ์์ ํตํด ํ๊ธ, ์์ด, ํน์๋ฌธ์๋ฅผ ํฌํจํด Emoji๊น์ง ํ์ต ๋์์ ํฌํจํ์ต๋๋ค.
ํํธ, ํ๊ธ ๋ฒ์๋ฅผ `ใฑ-ใ
๊ฐ-ํฃ` ์ผ๋ก ์ง์ ํด `ใฑ-ํฃ` ๋ด์ ํ์๋ฅผ ์ ์ธํ์ต๋๋ค.
2. ๋๊ธ ๋ด ์ค๋ณต ๋ฌธ์์ด ์ถ์ฝ
`ใ
ใ
ใ
ใ
ใ
`์ ๊ฐ์ด ์ค๋ณต๋ ๊ธ์๋ฅผ `ใ
ใ
`์ ๊ฐ์ ๊ฒ์ผ๋ก ํฉ์ณค์ต๋๋ค.
3. Cased Model
KcBERT๋ ์๋ฌธ์ ๋ํด์๋ ๋์๋ฌธ์๋ฅผ ์ ์งํ๋ Cased model์
๋๋ค.
4. ๊ธ์ ๋จ์ 10๊ธ์ ์ดํ ์ ๊ฑฐ
10๊ธ์ ๋ฏธ๋ง์ ํ
์คํธ๋ ๋จ์ผ ๋จ์ด๋ก ์ด๋ค์ง ๊ฒฝ์ฐ๊ฐ ๋ง์ ํด๋น ๋ถ๋ถ์ ์ ์ธํ์ต๋๋ค.
5. ์ค๋ณต ์ ๊ฑฐ
์ค๋ณต์ ์ผ๋ก ์ฐ์ธ ๋๊ธ์ ์ ๊ฑฐํ๊ธฐ ์ํด ์ค๋ณต ๋๊ธ์ ํ๋๋ก ํฉ์ณค์ต๋๋ค.
์ด๋ฅผ ํตํด ๋ง๋ ์ต์ข
ํ์ต ๋ฐ์ดํฐ๋ **12.5GB, 8.9์ฒ๋ง๊ฐ ๋ฌธ์ฅ**์
๋๋ค.
์๋ ๋ช
๋ น์ด๋ก pip๋ก ์ค์นํ ๋ค, ์๋ cleanํจ์๋ก ํด๋ฆฌ๋์ ํ๋ฉด Downstream task์์ ๋ณด๋ค ์ฑ๋ฅ์ด ์ข์์ง๋๋ค. (`[UNK]` ๊ฐ์)
```bash
pip install soynlp emoji
```
์๋ `clean` ํจ์๋ฅผ Text data์ ์ฌ์ฉํด์ฃผ์ธ์.
```python
import re
import emoji
from soynlp.normalizer import repeat_normalize
emojis = list({y for x in emoji.UNICODE_EMOJI.values() for y in x.keys()})
emojis = ''.join(emojis)
pattern = re.compile(f'[^ .,?!/@$%~๏ผ
ยทโผ()\x00-\x7Fใฑ-ใ
ฃ๊ฐ-ํฃ{emojis}]+')
url_pattern = re.compile(
r'https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)')
def clean(x):
x = pattern.sub(' ', x)
x = url_pattern.sub('', x)
x = x.strip()
x = repeat_normalize(x, num_repeats=2)
return x
```
### Cleaned Data (Released on Kaggle)
์๋ณธ ๋ฐ์ดํฐ๋ฅผ ์ `clean`ํจ์๋ก ์ ์ ํ 12GB๋ถ๋์ txt ํ์ผ์ ์๋ Kaggle Dataset์์ ๋ค์ด๋ฐ์ผ์ค ์ ์์ต๋๋ค :)
https://www.kaggle.com/junbumlee/kcbert-pretraining-corpus-korean-news-comments
## Tokenizer Train
Tokenizer๋ Huggingface์ [Tokenizers](https://github.com/huggingface/tokenizers) ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ํตํด ํ์ต์ ์งํํ์ต๋๋ค.
๊ทธ ์ค `BertWordPieceTokenizer` ๋ฅผ ์ด์ฉํด ํ์ต์ ์งํํ๊ณ , Vocab Size๋ `30000`์ผ๋ก ์งํํ์ต๋๋ค.
Tokenizer๋ฅผ ํ์ตํ๋ ๊ฒ์๋ `1/10`๋ก ์ํ๋งํ ๋ฐ์ดํฐ๋ก ํ์ต์ ์งํํ๊ณ , ๋ณด๋ค ๊ณจ๊ณ ๋ฃจ ์ํ๋งํ๊ธฐ ์ํด ์ผ์๋ณ๋ก stratify๋ฅผ ์ง์ ํ ๋ค ํ์ต์ ์งํํ์ต๋๋ค.
## BERT Model Pretrain
- KcBERT Base config
```json
{
"max_position_embeddings": 300,
"hidden_dropout_prob": 0.1,
"hidden_act": "gelu",
"initializer_range": 0.02,
"num_hidden_layers": 12,
"type_vocab_size": 2,
"vocab_size": 30000,
"hidden_size": 768,
"attention_probs_dropout_prob": 0.1,
"directionality": "bidi",
"num_attention_heads": 12,
"intermediate_size": 3072,
"architectures": [
"BertForMaskedLM"
],
"model_type": "bert"
}
```
- KcBERT Large config
```json
{
"type_vocab_size": 2,
"initializer_range": 0.02,
"max_position_embeddings": 300,
"vocab_size": 30000,
"hidden_size": 1024,
"hidden_dropout_prob": 0.1,
"model_type": "bert",
"directionality": "bidi",
"pad_token_id": 0,
"layer_norm_eps": 1e-12,
"hidden_act": "gelu",
"num_hidden_layers": 24,
"num_attention_heads": 16,
"attention_probs_dropout_prob": 0.1,
"intermediate_size": 4096,
"architectures": [
"BertForMaskedLM"
]
}
```
BERT Model Config๋ Base, Large ๊ธฐ๋ณธ ์ธํ
๊ฐ์ ๊ทธ๋๋ก ์ฌ์ฉํ์ต๋๋ค. (MLM 15% ๋ฑ)
TPU `v3-8` ์ ์ด์ฉํด ๊ฐ๊ฐ 3์ผ, N์ผ(Large๋ ํ์ต ์งํ ์ค)์ ์งํํ๊ณ , ํ์ฌ Huggingface์ ๊ณต๊ฐ๋ ๋ชจ๋ธ์ 1m(100๋ง) step์ ํ์ตํ ckpt๊ฐ ์
๋ก๋ ๋์ด์์ต๋๋ค.
๋ชจ๋ธ ํ์ต Loss๋ Step์ ๋ฐ๋ผ ์ด๊ธฐ 200k์ ๊ฐ์ฅ ๋น ๋ฅด๊ฒ Loss๊ฐ ์ค์ด๋ค๋ค 400k์ดํ๋ก๋ ์กฐ๊ธ์ฉ ๊ฐ์ํ๋ ๊ฒ์ ๋ณผ ์ ์์ต๋๋ค.
- Base Model Loss

- Large Model Loss

ํ์ต์ GCP์ TPU v3-8์ ์ด์ฉํด ํ์ต์ ์งํํ๊ณ , ํ์ต ์๊ฐ์ Base Model ๊ธฐ์ค 2.5์ผ์ ๋ ์งํํ์ต๋๋ค. Large Model์ ์ฝ 5์ผ์ ๋ ์งํํ ๋ค ๊ฐ์ฅ ๋ฎ์ loss๋ฅผ ๊ฐ์ง ์ฒดํฌํฌ์ธํธ๋ก ์ ํ์ต๋๋ค.
## Example
### HuggingFace MASK LM
[HuggingFace kcbert-base ๋ชจ๋ธ](https://huggingface.co/beomi/kcbert-base?text=์ค๋์+๋ ์จ๊ฐ+[MASK]) ์์ ์๋์ ๊ฐ์ด ํ
์คํธ ํด ๋ณผ ์ ์์ต๋๋ค.

๋ฌผ๋ก [kcbert-large ๋ชจ๋ธ](https://huggingface.co/beomi/kcbert-large?text=์ค๋์+๋ ์จ๊ฐ+[MASK]) ์์๋ ํ
์คํธ ํ ์ ์์ต๋๋ค.

### NSMC Binary Classification
[๋ค์ด๋ฒ ์ํํ ์ฝํผ์ค](https://github.com/e9t/nsmc) ๋ฐ์ดํฐ์
์ ๋์์ผ๋ก Fine Tuning์ ์งํํด ์ฑ๋ฅ์ ๊ฐ๋จํ ํ
์คํธํด๋ณด์์ต๋๋ค.
Base Model์ Fine Tuneํ๋ ์ฝ๋๋ <a href="https://colab.research.google.com/drive/1fn4sVJ82BrrInjq6y5655CYPP-1UKCLb?usp=sharing">
<img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/>
</a> ์์ ์ง์ ์คํํด๋ณด์ค ์ ์์ต๋๋ค.
Large Model์ Fine Tuneํ๋ ์ฝ๋๋ <a href="https://colab.research.google.com/drive/1dFC0FL-521m7CL_PSd8RLKq67jgTJVhL?usp=sharing">
<img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/>
</a> ์์ ์ง์ ์คํํด๋ณผ ์ ์์ต๋๋ค.
- GPU๋ P100 x1๋ ๊ธฐ์ค 1epoch์ 2-3์๊ฐ, TPU๋ 1epoch์ 1์๊ฐ ๋ด๋ก ์์๋ฉ๋๋ค.
- GPU RTX Titan x4๋ ๊ธฐ์ค 30๋ถ/epoch ์์๋ฉ๋๋ค.
- ์์ ์ฝ๋๋ [pytorch-lightning](https://github.com/PyTorchLightning/pytorch-lightning)์ผ๋ก ๊ฐ๋ฐํ์ต๋๋ค.
#### ์คํ๊ฒฐ๊ณผ
- KcBERT-Base Model ์คํ๊ฒฐ๊ณผ: Val acc `.8905`

- KcBERT-Large Model ์คํ ๊ฒฐ๊ณผ: Val acc `.9089`

> ๋ ๋ค์ํ Downstream Task์ ๋ํด ํ
์คํธ๋ฅผ ์งํํ๊ณ ๊ณต๊ฐํ ์์ ์
๋๋ค.
## ์ธ์ฉํ๊ธฐ/Citation
KcBERT๋ฅผ ์ธ์ฉํ์ค ๋๋ ์๋ ์์์ ํตํด ์ธ์ฉํด์ฃผ์ธ์.
```
@inproceedings{lee2020kcbert,
title={KcBERT: Korean Comments BERT},
author={Lee, Junbum},
booktitle={Proceedings of the 32nd Annual Conference on Human and Cognitive Language Technology},
pages={437--440},
year={2020}
}
```
- ๋
ผ๋ฌธ์ง ๋ค์ด๋ก๋ ๋งํฌ: http://hclt.kr/dwn/?v=bG5iOmNvbmZlcmVuY2U7aWR4OjMy (*ํน์ http://hclt.kr/symp/?lnb=conference )
## Acknowledgement
KcBERT Model์ ํ์ตํ๋ GCP/TPU ํ๊ฒฝ์ [TFRC](https://www.tensorflow.org/tfrc?hl=ko) ํ๋ก๊ทธ๋จ์ ์ง์์ ๋ฐ์์ต๋๋ค.
๋ชจ๋ธ ํ์ต ๊ณผ์ ์์ ๋ง์ ์กฐ์ธ์ ์ฃผ์ [Monologg](https://github.com/monologg/) ๋ ๊ฐ์ฌํฉ๋๋ค :)
## Reference
### Github Repos
- [BERT by Google](https://github.com/google-research/bert)
- [KoBERT by SKT](https://github.com/SKTBrain/KoBERT)
- [KoELECTRA by Monologg](https://github.com/monologg/KoELECTRA/)
- [Transformers by Huggingface](https://github.com/huggingface/transformers)
- [Tokenizers by Hugginface](https://github.com/huggingface/tokenizers)
### Papers
- [BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding](https://arxiv.org/abs/1810.04805)
### Blogs
- [Monologg๋์ KoELECTRA ํ์ต๊ธฐ](https://monologg.kr/categories/NLP/ELECTRA/)
- [Colab์์ TPU๋ก BERT ์ฒ์๋ถํฐ ํ์ต์ํค๊ธฐ - Tensorflow/Google ver.](https://beomi.github.io/2020/02/26/Train-BERT-from-scratch-on-colab-TPU-Tensorflow-ver/)
| {"language": "ko", "license": "apache-2.0", "tags": ["korean"]} | beomi/kcbert-base | null | [
"transformers",
"pytorch",
"jax",
"safetensors",
"bert",
"fill-mask",
"korean",
"ko",
"arxiv:1810.04805",
"doi:10.57967/hf/0016",
"license:apache-2.0",
"autotrain_compatible",
"endpoints_compatible",
"has_space",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
fill-mask | transformers | {} | beomi/kcbert-large-dev | null | [
"transformers",
"pytorch",
"jax",
"bert",
"fill-mask",
"autotrain_compatible",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
fill-mask | transformers | {} | beomi/kcbert-large | null | [
"transformers",
"pytorch",
"jax",
"safetensors",
"bert",
"fill-mask",
"autotrain_compatible",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
text-generation | transformers | {} | beomi/kcgpt2-dev | null | [
"transformers",
"pytorch",
"jax",
"gpt2",
"text-generation",
"autotrain_compatible",
"endpoints_compatible",
"text-generation-inference",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
text-generation | transformers | {} | beomi/kcgpt2 | null | [
"transformers",
"pytorch",
"gpt2",
"text-generation",
"autotrain_compatible",
"endpoints_compatible",
"text-generation-inference",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
fill-mask | transformers | {} | beomi/kobert | null | [
"transformers",
"pytorch",
"safetensors",
"bert",
"fill-mask",
"autotrain_compatible",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
text-classification | transformers | {} | beomi/korean-hatespeech-classifier | null | [
"transformers",
"pytorch",
"electra",
"text-classification",
"autotrain_compatible",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
text-classification | transformers | {} | beomi/korean-hatespeech-multilabel | null | [
"transformers",
"pytorch",
"electra",
"text-classification",
"autotrain_compatible",
"endpoints_compatible",
"has_space",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
text-classification | transformers | {} | beomi/korean-lgbt-hatespeech-classifier | null | [
"transformers",
"pytorch",
"electra",
"text-classification",
"autotrain_compatible",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
text-generation | transformers |
# Bert base model for Korean
## Update
- Update at 2021.11.17 : Add Native Support for BERT Tokenizer (works with AutoTokenizer, pipeline)
---
* 70GB Korean text dataset and 42000 lower-cased subwords are used
* Check the model performance and other language models for Korean in [github](https://github.com/kiyoungkim1/LM-kor)
```python
from transformers import pipeline
pipe = pipeline('text-generation', model='beomi/kykim-gpt3-kor-small_based_on_gpt2')
print(pipe("์๋
ํ์ธ์! ์ค๋์"))
# [{'generated_text': '์๋
ํ์ธ์! ์ค๋์ ์ ๊ฐ ์์ฆ ์ฌ์ฉํ๊ณ ์๋ ํด๋ ์ง์ํฐ๋ฅผ ์๊ฐํด๋๋ฆฌ๋ ค๊ณ ํด์! ๋ฐ๋ก ์ด ์ ํ!! ๋ฐ๋ก ์ด'}]
```
| {"language": "ko"} | beomi/kykim-gpt3-kor-small_based_on_gpt2 | null | [
"transformers",
"pytorch",
"tf",
"jax",
"gpt2",
"text-generation",
"ko",
"autotrain_compatible",
"endpoints_compatible",
"text-generation-inference",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
token-classification | transformers | # LayoutXLM finetuned on XFUN.ja
```python
import torch
import numpy as np
from PIL import Image, ImageDraw, ImageFont
from pathlib import Path
from itertools import chain
from tqdm.notebook import tqdm
from pdf2image import convert_from_path
from transformers import LayoutXLMProcessor, LayoutLMv2ForTokenClassification
import os
os.environ["TOKENIZERS_PARALLELISM"] = "false"
labels = [
'O',
'B-QUESTION',
'B-ANSWER',
'B-HEADER',
'I-ANSWER',
'I-QUESTION',
'I-HEADER'
]
id2label = {v: k for v, k in enumerate(labels)}
label2id = {k: v for v, k in enumerate(labels)}
def unnormalize_box(bbox, width, height):
return [
width * (bbox[0] / 1000),
height * (bbox[1] / 1000),
width * (bbox[2] / 1000),
height * (bbox[3] / 1000),
]
def iob_to_label(label):
label = label[2:]
if not label:
return 'other'
return label
label2color = {'question':'blue', 'answer':'green', 'header':'orange', 'other':'violet'}
def infer(image, processor, model, label2color):
# Use this if you're loading images
# image = Image.open(img_path).convert("RGB")
image = image.convert("RGB") # loading PDFs
encoding = processor(image, return_offsets_mapping=True, return_tensors="pt", truncation=True, max_length=514)
offset_mapping = encoding.pop('offset_mapping')
outputs = model(**encoding)
predictions = outputs.logits.argmax(-1).squeeze().tolist()
token_boxes = encoding.bbox.squeeze().tolist()
width, height = image.size
is_subword = np.array(offset_mapping.squeeze().tolist())[:,0] != 0
true_predictions = [id2label[pred] for idx, pred in enumerate(predictions) if not is_subword[idx]]
true_boxes = [unnormalize_box(box, width, height) for idx, box in enumerate(token_boxes) if not is_subword[idx]]
draw = ImageDraw.Draw(image)
font = ImageFont.load_default()
for prediction, box in zip(true_predictions, true_boxes):
predicted_label = iob_to_label(prediction).lower()
draw.rectangle(box, outline=label2color[predicted_label])
draw.text((box[0]+10, box[1]-10), text=predicted_label, fill=label2color[predicted_label], font=font)
return image
processor = LayoutXLMProcessor.from_pretrained('beomus/layoutxlm')
model = LayoutLMv2ForTokenClassification.from_pretrained("beomus/layoutxlm")
# imgs = [img_path for img_path in Path('/your/path/imgs/').glob('*.jpg')]
imgs = [convert_from_path(img_path) for img_path in Path('/your/path/pdfs/').glob('*.pdf')]
imgs = list(chain.from_iterable(imgs))
outputs = [infer(img_path, processor, model, label2color) for img_path in tqdm(imgs)]
# type(outputs[0]) -> PIL.Image.Image
``` | {} | beomus/layoutxlm | null | [
"transformers",
"pytorch",
"layoutlmv2",
"token-classification",
"autotrain_compatible",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
text-generation | transformers | {} | beomus/lotr-gpt | null | [
"transformers",
"pytorch",
"safetensors",
"gpt2",
"text-generation",
"autotrain_compatible",
"endpoints_compatible",
"text-generation-inference",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
null | null | {} | bergr7/finbert_sec | null | [
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
text-classification | transformers |
# xtremedistil-emotion
This model is a fine-tuned version of [microsoft/xtremedistil-l6-h256-uncased](https://huggingface.co/microsoft/xtremedistil-l6-h256-uncased) on the emotion dataset.
It achieves the following results on the evaluation set:
- Accuracy: 0.9265
### Training hyperparameters
The following hyperparameters were used during training:
- learning_rate: 3e-05
- train_batch_size: 128
- eval_batch_size: 8
- seed: 42
- num_epochs: 24
### Training results
<pre>
Epoch Training Loss Validation Loss Accuracy
1 No log 1.238589 0.609000
2 No log 0.934423 0.714000
3 No log 0.768701 0.742000
4 1.074800 0.638208 0.805500
5 1.074800 0.551363 0.851500
6 1.074800 0.476291 0.875500
7 1.074800 0.427313 0.883500
8 0.531500 0.392633 0.886000
9 0.531500 0.357979 0.892000
10 0.531500 0.330304 0.899500
11 0.531500 0.304529 0.907000
12 0.337200 0.287447 0.918000
13 0.337200 0.277067 0.921000
14 0.337200 0.259483 0.921000
15 0.337200 0.257564 0.916500
16 0.246200 0.241970 0.919500
17 0.246200 0.241537 0.921500
18 0.246200 0.235705 0.924500
19 0.246200 0.237325 0.920500
20 0.201400 0.229699 0.923500
21 0.201400 0.227426 0.923000
22 0.201400 0.228554 0.924000
23 0.201400 0.226941 0.925500
24 0.184300 0.225816 0.926500
</pre>
| {"license": "apache-2.0", "tags": ["generated_from_trainer"], "datasets": ["emotion"], "metrics": ["accuracy"], "model-index": [{"name": "xtremedistil-emotion", "results": [{"task": {"type": "text-classification", "name": "Text Classification"}, "dataset": {"name": "emotion", "type": "emotion", "args": "default"}, "metrics": [{"type": "accuracy", "value": 0.9265, "name": "Accuracy"}]}, {"task": {"type": "text-classification", "name": "Text Classification"}, "dataset": {"name": "emotion", "type": "emotion", "config": "default", "split": "test"}, "metrics": [{"type": "accuracy", "value": 0.926, "name": "Accuracy", "verified": true, "verifyToken": "eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJoYXNoIjoiYzE3NDg5Y2ZkMDE5OTJmNjYwMTU1MDMwOTUwNTdkOWQ0MWNiZDYxYzUwNDBmNGVkOWU0OWE1MzRiNDYyZDI3NyIsInZlcnNpb24iOjF9.BaDj-FQ6g0cRk7n2MlN2YCb8Iv2VIM2wMwnJeeCTjG15b7TRRfZVtM3CM2WvHymahppscpiqgqPxT7JqkVXkAQ"}, {"type": "precision", "value": 0.8855308537052737, "name": "Precision Macro", "verified": true, "verifyToken": "eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJoYXNoIjoiZGQ3MDlmOTdmZTY3Mjc5MmE1ZmFlZTVhOWIxYjA3ZDRmNjM4YmYzNTVmZTYwNmI2OTRmYmE3NDMyOTIxM2RjOSIsInZlcnNpb24iOjF9.r1_TDJRi4RJfhVlFDe83mRtdhqt5KMtvran6qjzRrcwXqNz7prkocFmgNnntn-fqgg6AXgyi6lwVDcuj5L5VBA"}, {"type": "precision", "value": 0.926, "name": "Precision Micro", "verified": true, "verifyToken": "eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJoYXNoIjoiNzMzMzc4MWY1M2E5Y2M2ZTRiYTc2YzA5YzI4ZWM5MjgzMDgyNjZkMTVjZDYxZGJiMjI0NDdiMWU3ZWM5MjhjYSIsInZlcnNpb24iOjF9.741rqCRY5S8z_QodJ0PvcnccCN79fCE-MeNTEWFegI0oReneULyNOKRulxwxzwY5SN6ILm52xW7km5WJyt8MCg"}, {"type": "precision", "value": 0.9281282413639949, "name": "Precision Weighted", "verified": true, "verifyToken": "eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJoYXNoIjoiODVlOTM3ODVhMWM0MjU4Mzg2OGNkYjc2ZmExODYzOWIzYjdlYzE4OWE0ZWI4ZjcxMjJiMGJiMzdhN2RiNTdlNiIsInZlcnNpb24iOjF9.8-HhpgKNt3nTcblnes4KxzsD7Xot3C6Rldp4463H9gaUNBxHcH19mFcpaSaDT_L3mYqetcW891jyNrHoATzuAg"}, {"type": "recall", "value": 0.8969894921856228, "name": "Recall Macro", "verified": true, "verifyToken": "eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJoYXNoIjoiYTkxYzZiMzY5YjA3ZjExYmNlNGI4N2Q5NTg0MTcxODgxOTc0MjdhM2FjODAzNjhiNDBjMWY2NWUyMjhhYjNiNSIsInZlcnNpb24iOjF9.t5YyyNtkbaGfLVbFIO15wh6o6BqBIXGTEBheffPax61-cZM0HRQg9BufcHFdZ4dvPd_V_AYWrXdarEm-gLSBBg"}, {"type": "recall", "value": 0.926, "name": "Recall Micro", "verified": true, "verifyToken": "eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJoYXNoIjoiZjAxMTUzMmI1YmMwYTBmYzFmM2E3Y2NiY2M4Njc4ZDc1ZWRhMTMyMDVhMWNiMGQ1ZDRiMjcwYmQ0MDAxZmI3NSIsInZlcnNpb24iOjF9.OphK_nR4EkaAUGMdZDq1rP_oBivfLHQhE7XY1HP9izhDd6rV5KobTrSdoxVCHGUtjOm1M6eZqI_1rPpunoCqDQ"}, {"type": "recall", "value": 0.926, "name": "Recall Weighted", "verified": true, "verifyToken": "eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJoYXNoIjoiMGYxYWZlZmY1MWE4ZTU5YzlmZjA3MjVkZGFlMjk4NjFmMTIwZTNlMWU2ZWE1YWE3ZTc3MzI4NmJhYjM5Y2M5NCIsInZlcnNpb24iOjF9.zRx5GUnSb-T6E3s3NsWn1c1szm63jlB8XeqBUZ3J0m5H6P-QAPcVTaMVn8id-_IExS4g856-dT9YMq3pRh91DQ"}, {"type": "f1", "value": 0.8903400738742536, "name": "F1 Macro", "verified": true, "verifyToken": "eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJoYXNoIjoiMzE1NDYxYTdiNjAwYzllZmY4ODc1ZTc1YjMyZjA4Njc1NDhjNDM5ZWNmOThjNzQ1MDE5ZDEyMTY0YTljZDcyMiIsInZlcnNpb24iOjF9.j4U3aOySF94GUF94YGA7DPjynVJ7wStBPu8uinEz_AjQFISv8YvHZOO--Kv2S4iKJPQNSGjmqP8jwtVEKt6-AA"}, {"type": "f1", "value": 0.926, "name": "F1 Micro", "verified": true, "verifyToken": "eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJoYXNoIjoiNTFmYzdiM2FmZDIyMjkxZDk2NGFkMjU4OWJjYzQ1MTJkZThiMmMzYTUzZmJlNjNmYTFlOTRkMTZjODI2NDdiYyIsInZlcnNpb24iOjF9.VY3hvPQL588GY4j9cCJRj1GWZWsdgkRV1F5DKhckC74-w2qFK10zgqSEbb_uhOg3IYLcXev9f8dhIOVcOCPvDg"}, {"type": "f1", "value": 0.9265018282649476, "name": "F1 Weighted", "verified": true, "verifyToken": "eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJoYXNoIjoiM2MyNjM2OGMzYzg5ODFiOWI0ZTkxMDAxYTRkNDYwZWIyZGUyYzhhYTUwYWM4NzJhYTk3MGU2N2E5ZTcyNWExMyIsInZlcnNpb24iOjF9.p_7UeUdm-Qy6yfUlZA9EmtAKUzxhfkDTUMkzNRLJ3HD3aFHHwOo8jIY3lEZ-QkucT-jhofgbnQ-jR56HmB1JDw"}, {"type": "loss", "value": 0.2258329838514328, "name": "loss", "verified": true, "verifyToken": "eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJoYXNoIjoiZTQwM2Y4NGI0MmQwMDkxMTBiYTdlYjkwNjdiMjVhMGZhOTk0Y2MwMmVlODg2YTczNzg1MGZiMDM2NzIyMzE5ZCIsInZlcnNpb24iOjF9.gCzWQrRm8UsOEcZvT_zC568FZmIcQf8G177IDQmxGVGg1vrOonfnPLX1_xlbcID4vDGeVuw5xYEpxXOAc19GDw"}]}]}]} | bergum/xtremedistil-emotion | null | [
"transformers",
"pytorch",
"safetensors",
"bert",
"text-classification",
"generated_from_trainer",
"dataset:emotion",
"license:apache-2.0",
"model-index",
"autotrain_compatible",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
text-classification | transformers | # xtremedistil-l6-h384-emotion
This model is a fine-tuned version of [microsoft/xtremedistil-l6-h384-uncased](https://huggingface.co/microsoft/xtremedistil-l6-h384-uncased) on the emotion dataset.
It achieves the following results on the evaluation set:
- Accuracy: 0.928
This model can be quantized to int8 and retain accuracy
- Accuracy 0.912
<pre>
import transformers
import transformers.convert_graph_to_onnx as onnx_convert
from pathlib import Path
pipeline = transformers.pipeline("text-classification",model=model,tokenizer=tokenizer)
onnx_convert.convert_pytorch(pipeline, opset=11, output=Path("xtremedistil-l6-h384-emotion.onnx"), use_external_format=False)
from onnxruntime.quantization import quantize_dynamic, QuantType
quantize_dynamic("xtremedistil-l6-h384-emotion.onnx", "xtremedistil-l6-h384-emotion-int8.onnx",
weight_type=QuantType.QUInt8)
</pre>
### Training hyperparameters
The following hyperparameters were used during training:
- learning_rate: 3e-05
- train_batch_size: 128
- eval_batch_size: 8
- seed: 42
- num_epochs: 14
### Training results
<pre>
Epoch Training Loss Validation Loss Accuracy
1 No log 0.960511 0.689000
2 No log 0.620671 0.824000
3 No log 0.435741 0.880000
4 0.797900 0.341771 0.896000
5 0.797900 0.294780 0.916000
6 0.797900 0.250572 0.918000
7 0.797900 0.232976 0.924000
8 0.277300 0.216347 0.924000
9 0.277300 0.202306 0.930500
10 0.277300 0.192530 0.930000
11 0.277300 0.192500 0.926500
12 0.181700 0.187347 0.928500
13 0.181700 0.185896 0.929500
14 0.181700 0.185154 0.928000
</pre> | {"license": "apache-2.0", "tags": ["generated_from_trainer"], "datasets": ["emotion"], "metrics": ["accuracy"], "model-index": [{"name": "xtremedistil-l6-h384-emotion", "results": [{"task": {"type": "text-classification", "name": "Text Classification"}, "dataset": {"name": "emotion", "type": "emotion", "args": "default"}, "metrics": [{"type": "accuracy", "value": 0.928, "name": "Accuracy"}]}]}]} | bergum/xtremedistil-l6-h384-emotion | null | [
"transformers",
"pytorch",
"safetensors",
"bert",
"text-classification",
"generated_from_trainer",
"dataset:emotion",
"license:apache-2.0",
"model-index",
"autotrain_compatible",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
text-classification | transformers | # xtremedistil-l6-h384-go-emotion
This model is a fine-tuned version of [microsoft/xtremedistil-l6-h384-uncased](https://huggingface.co/microsoft/xtremedistil-l6-h384-uncased) on the
[go_emotions dataset](https://huggingface.co/datasets/go_emotions).
See notebook for how the model was trained and converted to ONNX format [](https://colab.research.google.com/github/jobergum/emotion/blob/main/TrainGoEmotions.ipynb)
This model is deployed to [aiserv.cloud](https://aiserv.cloud/) for live demo of the model.
See [https://github.com/jobergum/browser-ml-inference](https://github.com/jobergum/browser-ml-inference) for how to reproduce.
### Training hyperparameters
- batch size 128
- learning_rate=3e-05
- epocs 4
<pre>
Num examples = 211225
Num Epochs = 4
Instantaneous batch size per device = 128
Total train batch size (w. parallel, distributed & accumulation) = 128
Gradient Accumulation steps = 1
Total optimization steps = 6604
[6604/6604 53:23, Epoch 4/4]
Step Training Loss
500 0.263200
1000 0.156900
1500 0.152500
2000 0.145400
2500 0.140500
3000 0.135900
3500 0.132800
4000 0.129400
4500 0.127200
5000 0.125700
5500 0.124400
6000 0.124100
6500 0.123400
</pre> | {"license": "apache-2.0", "datasets": ["go_emotions"], "metrics": ["accuracy"], "model-index": [{"name": "xtremedistil-emotion", "results": [{"task": {"type": "multi_label_classification", "name": "Multi Label Text Classification"}, "dataset": {"name": "go_emotions", "type": "emotion", "args": "default"}, "metrics": [{"type": "accuracy", "value": "NaN", "name": "Accuracy"}]}]}]} | bergum/xtremedistil-l6-h384-go-emotion | null | [
"transformers",
"pytorch",
"safetensors",
"bert",
"text-classification",
"dataset:go_emotions",
"license:apache-2.0",
"model-index",
"autotrain_compatible",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
token-classification | transformers |
<!-- This model card has been generated automatically according to the information the Trainer had access to. You
should probably proofread and complete it, then remove this comment. -->
# IceBERT-finetuned-ner
This model is a fine-tuned version of [vesteinn/IceBERT](https://huggingface.co/vesteinn/IceBERT) on the mim_gold_ner dataset.
It achieves the following results on the evaluation set:
- Loss: 0.0783
- Precision: 0.8873
- Recall: 0.8627
- F1: 0.8748
- Accuracy: 0.9848
## Model description
More information needed
## Intended uses & limitations
More information needed
## Training and evaluation data
More information needed
## Training procedure
### Training hyperparameters
The following hyperparameters were used during training:
- learning_rate: 2e-05
- train_batch_size: 16
- eval_batch_size: 16
- seed: 42
- optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
- lr_scheduler_type: linear
- num_epochs: 3
### Training results
| Training Loss | Epoch | Step | Validation Loss | Precision | Recall | F1 | Accuracy |
|:-------------:|:-----:|:----:|:---------------:|:---------:|:------:|:------:|:--------:|
| 0.0539 | 1.0 | 2904 | 0.0768 | 0.8732 | 0.8453 | 0.8590 | 0.9833 |
| 0.0281 | 2.0 | 5808 | 0.0737 | 0.8781 | 0.8492 | 0.8634 | 0.9838 |
| 0.0166 | 3.0 | 8712 | 0.0783 | 0.8873 | 0.8627 | 0.8748 | 0.9848 |
### Framework versions
- Transformers 4.11.2
- Pytorch 1.9.0+cu102
- Datasets 1.12.1
- Tokenizers 0.10.3
| {"license": "gpl-3.0", "tags": ["generated_from_trainer"], "datasets": ["mim_gold_ner"], "metrics": ["precision", "recall", "f1", "accuracy"], "widget": [{"text": "Bob Dillan beit Mar\u00edu Markan \u00e1 barkann."}], "model-index": [{"name": "IceBERT-finetuned-ner", "results": [{"task": {"type": "token-classification", "name": "Token Classification"}, "dataset": {"name": "mim_gold_ner", "type": "mim_gold_ner", "args": "mim-gold-ner"}, "metrics": [{"type": "precision", "value": 0.8873049035270985, "name": "Precision"}, {"type": "recall", "value": 0.8627076114231091, "name": "Recall"}, {"type": "f1", "value": 0.8748333939173634, "name": "F1"}, {"type": "accuracy", "value": 0.9848076353832492, "name": "Accuracy"}]}]}]} | bergurth/IceBERT-finetuned-ner | null | [
"transformers",
"pytorch",
"tensorboard",
"roberta",
"token-classification",
"generated_from_trainer",
"dataset:mim_gold_ner",
"license:gpl-3.0",
"model-index",
"autotrain_compatible",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
token-classification | transformers |
<!-- This model card has been generated automatically according to the information the Trainer had access to. You
should probably proofread and complete it, then remove this comment. -->
# XLMR-ENIS-finetuned-ner
This model is a fine-tuned version of [vesteinn/XLMR-ENIS](https://huggingface.co/vesteinn/XLMR-ENIS) on the mim_gold_ner dataset.
It achieves the following results on the evaluation set:
- Loss: 0.0938
- Precision: 0.8619
- Recall: 0.8384
- F1: 0.8500
- Accuracy: 0.9831
## Model description
More information needed
## Intended uses & limitations
More information needed
## Training and evaluation data
More information needed
## Training procedure
### Training hyperparameters
The following hyperparameters were used during training:
- learning_rate: 2e-05
- train_batch_size: 16
- eval_batch_size: 16
- seed: 42
- optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
- lr_scheduler_type: linear
- num_epochs: 3
### Training results
| Training Loss | Epoch | Step | Validation Loss | Precision | Recall | F1 | Accuracy |
|:-------------:|:-----:|:----:|:---------------:|:---------:|:------:|:------:|:--------:|
| 0.0574 | 1.0 | 2904 | 0.0983 | 0.8374 | 0.8061 | 0.8215 | 0.9795 |
| 0.0321 | 2.0 | 5808 | 0.0991 | 0.8525 | 0.8235 | 0.8378 | 0.9811 |
| 0.0179 | 3.0 | 8712 | 0.0938 | 0.8619 | 0.8384 | 0.8500 | 0.9831 |
### Framework versions
- Transformers 4.11.2
- Pytorch 1.9.0+cu102
- Datasets 1.12.1
- Tokenizers 0.10.3
| {"license": "agpl-3.0", "tags": ["generated_from_trainer"], "datasets": ["mim_gold_ner"], "metrics": ["precision", "recall", "f1", "accuracy"], "widget": [{"text": "B\u00f3nus fe\u00f0garnir J\u00f3hannes J\u00f3nsson og J\u00f3n \u00c1sgeir J\u00f3hannesson opnu\u00f0u fyrstu B\u00f3nusb\u00fa\u00f0ina \u00ed 400 fermetra h\u00fasn\u00e6\u00f0i vi\u00f0 Sk\u00fatuvog laugardaginn 8. apr\u00edl 1989"}], "model-index": [{"name": "XLMR-ENIS-finetuned-ner", "results": [{"task": {"type": "token-classification", "name": "Token Classification"}, "dataset": {"name": "mim_gold_ner", "type": "mim_gold_ner", "args": "mim-gold-ner"}, "metrics": [{"type": "precision", "value": 0.861851332398317, "name": "Precision"}, {"type": "recall", "value": 0.8384309266628767, "name": "Recall"}, {"type": "f1", "value": 0.849979828251974, "name": "F1"}, {"type": "accuracy", "value": 0.9830620929487668, "name": "Accuracy"}]}]}]} | bergurth/XLMR-ENIS-finetuned-ner | null | [
"transformers",
"pytorch",
"tensorboard",
"xlm-roberta",
"token-classification",
"generated_from_trainer",
"dataset:mim_gold_ner",
"license:agpl-3.0",
"model-index",
"autotrain_compatible",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
null | null | {} | bergurth/distilbert-base-uncased-finetuned-cola | null | [
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
text-classification | transformers | {} | berkergurcay/10k-pretrained-bert-model | null | [
"transformers",
"pytorch",
"bert",
"text-classification",
"autotrain_compatible",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
text-classification | transformers | {} | berkergurcay/1k-fineutuned-bert-model | null | [
"transformers",
"pytorch",
"bert",
"text-classification",
"autotrain_compatible",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
text-classification | transformers | {} | berkergurcay/1k-pretrained-bert-model | null | [
"transformers",
"pytorch",
"bert",
"text-classification",
"autotrain_compatible",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
text-classification | transformers | {} | berkergurcay/finetuned-bert-base-uncased | null | [
"transformers",
"pytorch",
"bert",
"text-classification",
"autotrain_compatible",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
text-classification | transformers | {} | berkergurcay/finetuned-roberta | null | [
"transformers",
"pytorch",
"roberta",
"text-classification",
"autotrain_compatible",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
fill-mask | transformers |
This is a **RoBERTa-base** model trained from scratch in Spanish.
The training dataset is [mc4](https://huggingface.co/datasets/bertin-project/mc4-es-sampled ) subsampling documents to a total of about 50 million examples. Sampling is biased towards average perplexity values (using a Gaussian function), discarding more often documents with very large values (poor quality) of very small values (short, repetitive texts).
This model takes the one using [sequence length 128](https://huggingface.co/bertin-project/bertin-base-gaussian) and trains during 25.000 steps using sequence length 512.
Please see our main [card](https://huggingface.co/bertin-project/bertin-roberta-base-spanish) for more information.
This is part of the
[Flax/Jax Community Week](https://discuss.huggingface.co/t/open-to-the-community-community-week-using-jax-flax-for-nlp-cv/7104), organised by [HuggingFace](https://huggingface.co/) and TPU usage sponsored by Google.
## Team members
- Eduardo Gonzรกlez ([edugp](https://huggingface.co/edugp))
- Javier de la Rosa ([versae](https://huggingface.co/versae))
- Manu Romero ([mrm8488](https://huggingface.co/))
- Marรญa Grandury ([mariagrandury](https://huggingface.co/))
- Pablo Gonzรกlez de Prado ([Pablogps](https://huggingface.co/Pablogps))
- Paulo Villegas ([paulo](https://huggingface.co/paulo)) | {"language": "es", "license": "cc-by-4.0", "tags": ["spanish", "roberta"], "pipeline_tag": "fill-mask", "widget": [{"text": "Fui a la librer\u00eda a comprar un <mask>."}]} | bertin-project/bertin-base-gaussian-exp-512seqlen | null | [
"transformers",
"pytorch",
"jax",
"tensorboard",
"joblib",
"roberta",
"fill-mask",
"spanish",
"es",
"license:cc-by-4.0",
"autotrain_compatible",
"endpoints_compatible",
"has_space",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
fill-mask | transformers |
This is a **RoBERTa-base** model trained from scratch in Spanish.
The training dataset is [mc4](https://huggingface.co/datasets/bertin-project/mc4-es-sampled ) subsampling documents to a total of about 50 million examples. Sampling is biased towards average perplexity values (using a Gaussian function), discarding more often documents with very large values (poor quality) of very small values (short, repetitive texts).
This model has been trained for 250.000 steps.
Please see our main [card](https://huggingface.co/bertin-project/bertin-roberta-base-spanish) for more information.
This is part of the
[Flax/Jax Community Week](https://discuss.huggingface.co/t/open-to-the-community-community-week-using-jax-flax-for-nlp-cv/7104), organised by [HuggingFace](https://huggingface.co/) and TPU usage sponsored by Google.
## Team members
- Eduardo Gonzรกlez ([edugp](https://huggingface.co/edugp))
- Javier de la Rosa ([versae](https://huggingface.co/versae))
- Manu Romero ([mrm8488](https://huggingface.co/))
- Marรญa Grandury ([mariagrandury](https://huggingface.co/))
- Pablo Gonzรกlez de Prado ([Pablogps](https://huggingface.co/Pablogps))
- Paulo Villegas ([paulo](https://huggingface.co/paulo)) | {"language": "es", "license": "cc-by-4.0", "tags": ["spanish", "roberta"], "pipeline_tag": "fill-mask", "widget": [{"text": "Fui a la librer\u00eda a comprar un <mask>."}]} | bertin-project/bertin-base-gaussian | null | [
"transformers",
"pytorch",
"jax",
"tensorboard",
"joblib",
"roberta",
"fill-mask",
"spanish",
"es",
"license:cc-by-4.0",
"autotrain_compatible",
"endpoints_compatible",
"has_space",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
token-classification | transformers |
This checkpoint has been trained for the NER task using the CoNLL2002-es dataset.
This is a NER checkpoint created from **Bertin Gaussian 512**, which is a **RoBERTa-base** model trained from scratch in Spanish. Information on this base model may be found at [its own card](https://huggingface.co/bertin-project/bertin-base-gaussian-exp-512seqlen) and at deeper detail on [the main project card](https://huggingface.co/bertin-project/bertin-roberta-base-spanish).
The training dataset for the base model is [mc4](https://huggingface.co/datasets/bertin-project/mc4-es-sampled ) subsampling documents to a total of about 50 million examples. Sampling is biased towards average perplexity values (using a Gaussian function), discarding more often documents with very large values (poor quality) of very small values (short, repetitive texts).
This is part of the
[Flax/Jax Community Week](https://discuss.huggingface.co/t/open-to-the-community-community-week-using-jax-flax-for-nlp-cv/7104), organised by [HuggingFace](https://huggingface.co/) and TPU usage sponsored by Google.
## Team members
- Eduardo Gonzรกlez ([edugp](https://huggingface.co/edugp))
- Javier de la Rosa ([versae](https://huggingface.co/versae))
- Manu Romero ([mrm8488](https://huggingface.co/))
- Marรญa Grandury ([mariagrandury](https://huggingface.co/))
- Pablo Gonzรกlez de Prado ([Pablogps](https://huggingface.co/Pablogps))
- Paulo Villegas ([paulo](https://huggingface.co/paulo)) | {"language": "es", "license": "cc-by-4.0", "tags": ["spanish", "roberta", "ner"]} | bertin-project/bertin-base-ner-conll2002-es | null | [
"transformers",
"pytorch",
"safetensors",
"roberta",
"token-classification",
"spanish",
"ner",
"es",
"license:cc-by-4.0",
"autotrain_compatible",
"endpoints_compatible",
"has_space",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
text-classification | transformers |
This checkpoint has been trained for the PAWS-X task using the CoNLL 2002-es dataset.
This checkpoint was created from **Bertin Gaussian 512**, which is a **RoBERTa-base** model trained from scratch in Spanish. Information on this base model may be found at [its own card](https://huggingface.co/bertin-project/bertin-base-gaussian-exp-512seqlen) and at deeper detail on [the main project card](https://huggingface.co/bertin-project/bertin-roberta-base-spanish).
The training dataset for the base model is [mc4](https://huggingface.co/datasets/bertin-project/mc4-es-sampled ) subsampling documents to a total of about 50 million examples. Sampling is biased towards average perplexity values (using a Gaussian function), discarding more often documents with very large values (poor quality) of very small values (short, repetitive texts).
This is part of the
[Flax/Jax Community Week](https://discuss.huggingface.co/t/open-to-the-community-community-week-using-jax-flax-for-nlp-cv/7104), organised by [HuggingFace](https://huggingface.co/) and TPU usage sponsored by Google.
## Team members
- Eduardo Gonzรกlez ([edugp](https://huggingface.co/edugp))
- Javier de la Rosa ([versae](https://huggingface.co/versae))
- Manu Romero ([mrm8488](https://huggingface.co/))
- Marรญa Grandury ([mariagrandury](https://huggingface.co/))
- Pablo Gonzรกlez de Prado ([Pablogps](https://huggingface.co/Pablogps))
- Paulo Villegas ([paulo](https://huggingface.co/paulo)) | {"language": "es", "license": "cc-by-4.0", "tags": ["spanish", "roberta", "paws-x"]} | bertin-project/bertin-base-paws-x-es | null | [
"transformers",
"pytorch",
"safetensors",
"roberta",
"text-classification",
"spanish",
"paws-x",
"es",
"license:cc-by-4.0",
"autotrain_compatible",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
token-classification | transformers |
This checkpoint has been trained for the POS task using the CoNLL 2002-es dataset.
This checkpoint was created from **Bertin Gaussian 512**, which is a **RoBERTa-base** model trained from scratch in Spanish. Information on this base model may be found at [its own card](https://huggingface.co/bertin-project/bertin-base-gaussian-exp-512seqlen) and at deeper detail on [the main project card](https://huggingface.co/bertin-project/bertin-roberta-base-spanish).
The training dataset for the base model is [mc4](https://huggingface.co/datasets/bertin-project/mc4-es-sampled ) subsampling documents to a total of about 50 million examples. Sampling is biased towards average perplexity values (using a Gaussian function), discarding more often documents with very large values (poor quality) of very small values (short, repetitive texts).
This is part of the
[Flax/Jax Community Week](https://discuss.huggingface.co/t/open-to-the-community-community-week-using-jax-flax-for-nlp-cv/7104), organised by [HuggingFace](https://huggingface.co/) and TPU usage sponsored by Google.
## Team members
- Eduardo Gonzรกlez ([edugp](https://huggingface.co/edugp))
- Javier de la Rosa ([versae](https://huggingface.co/versae))
- Manu Romero ([mrm8488](https://huggingface.co/))
- Marรญa Grandury ([mariagrandury](https://huggingface.co/))
- Pablo Gonzรกlez de Prado ([Pablogps](https://huggingface.co/Pablogps))
- Paulo Villegas ([paulo](https://huggingface.co/paulo)) | {"language": "es", "license": "cc-by-4.0", "tags": ["spanish", "roberta", "ner"]} | bertin-project/bertin-base-pos-conll2002-es | null | [
"transformers",
"pytorch",
"safetensors",
"roberta",
"token-classification",
"spanish",
"ner",
"es",
"license:cc-by-4.0",
"autotrain_compatible",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
fill-mask | transformers |
This is a **RoBERTa-base** model trained from scratch in Spanish.
The training dataset is [mc4](https://huggingface.co/datasets/bertin-project/mc4-es-sampled ) subsampling documents to a total of about 50 million examples. Sampling is random.
This model continued training from [sequence length 128](https://huggingface.co/bertin-project/bertin-base-random) using 20.000 steps for length 512.
Please see our main [card](https://huggingface.co/bertin-project/bertin-roberta-base-spanish) for more information.
This is part of the
[Flax/Jax Community Week](https://discuss.huggingface.co/t/open-to-the-community-community-week-using-jax-flax-for-nlp-cv/7104), organised by [HuggingFace](https://huggingface.co/) and TPU usage sponsored by Google.
## Team members
- Eduardo Gonzรกlez ([edugp](https://huggingface.co/edugp))
- Javier de la Rosa ([versae](https://huggingface.co/versae))
- Manu Romero ([mrm8488](https://huggingface.co/))
- Marรญa Grandury ([mariagrandury](https://huggingface.co/))
- Pablo Gonzรกlez de Prado ([Pablogps](https://huggingface.co/Pablogps))
- Paulo Villegas ([paulo](https://huggingface.co/paulo)) | {"language": "es", "license": "cc-by-4.0", "tags": ["spanish", "roberta"], "pipeline_tag": "fill-mask", "widget": [{"text": "Fui a la librer\u00eda a comprar un <mask>."}]} | bertin-project/bertin-base-random-exp-512seqlen | null | [
"transformers",
"pytorch",
"jax",
"tensorboard",
"joblib",
"roberta",
"fill-mask",
"spanish",
"es",
"license:cc-by-4.0",
"autotrain_compatible",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
fill-mask | transformers |
This is a **RoBERTa-base** model trained from scratch in Spanish.
The training dataset is [mc4](https://huggingface.co/datasets/bertin-project/mc4-es-sampled ) subsampling documents to a total of about 50 million examples. Sampling is random.
This model has been trained for 230.000 steps (early stopped before the 250k intended steps).
Please see our main [card](https://huggingface.co/bertin-project/bertin-roberta-base-spanish) for more information.
This is part of the
[Flax/Jax Community Week](https://discuss.huggingface.co/t/open-to-the-community-community-week-using-jax-flax-for-nlp-cv/7104), organised by [HuggingFace](https://huggingface.co/) and TPU usage sponsored by Google.
## Team members
- Eduardo Gonzรกlez ([edugp](https://huggingface.co/edugp))
- Javier de la Rosa ([versae](https://huggingface.co/versae))
- Manu Romero ([mrm8488](https://huggingface.co/))
- Marรญa Grandury ([mariagrandury](https://huggingface.co/))
- Pablo Gonzรกlez de Prado ([Pablogps](https://huggingface.co/Pablogps))
- Paulo Villegas ([paulo](https://huggingface.co/paulo)) | {"language": "es", "license": "cc-by-4.0", "tags": ["spanish", "roberta"], "pipeline_tag": "fill-mask", "widget": [{"text": "Fui a la librer\u00eda a comprar un <mask>."}]} | bertin-project/bertin-base-random | null | [
"transformers",
"pytorch",
"jax",
"tensorboard",
"joblib",
"roberta",
"fill-mask",
"spanish",
"es",
"license:cc-by-4.0",
"autotrain_compatible",
"endpoints_compatible",
"has_space",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
fill-mask | transformers |
This is a **RoBERTa-base** model trained from scratch in Spanish.
The training dataset is [mc4](https://huggingface.co/datasets/bertin-project/mc4-es-sampled ) subsampling documents to a total of about 50 million examples. Sampling is biased towards average perplexity values (using a Gaussian function), discarding more often documents with very large values (poor quality) of very small values (short, repetitive texts).
This model takes the one using [sequence length 128](https://huggingface.co/bertin-project/bertin-base-stepwise) and trains during 25.000 steps using sequence length 512.
Please see our main [card](https://huggingface.co/bertin-project/bertin-roberta-base-spanish) for more information.
This is part of the
[Flax/Jax Community Week](https://discuss.huggingface.co/t/open-to-the-community-community-week-using-jax-flax-for-nlp-cv/7104), organised by [HuggingFace](https://huggingface.co/) and TPU usage sponsored by Google.
## Team members
- Eduardo Gonzรกlez ([edugp](https://huggingface.co/edugp))
- Javier de la Rosa ([versae](https://huggingface.co/versae))
- Manu Romero ([mrm8488](https://huggingface.co/))
- Marรญa Grandury ([mariagrandury](https://huggingface.co/))
- Pablo Gonzรกlez de Prado ([Pablogps](https://huggingface.co/Pablogps))
- Paulo Villegas ([paulo](https://huggingface.co/paulo))
| {"language": "es", "license": "cc-by-4.0", "tags": ["spanish", "roberta"], "pipeline_tag": "fill-mask", "widget": [{"text": "Fui a la librer\u00eda a comprar un <mask>."}]} | bertin-project/bertin-base-stepwise-exp-512seqlen | null | [
"transformers",
"pytorch",
"jax",
"tensorboard",
"joblib",
"roberta",
"fill-mask",
"spanish",
"es",
"license:cc-by-4.0",
"autotrain_compatible",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
fill-mask | transformers |
This is a **RoBERTa-base** model trained from scratch in Spanish.
The training dataset is [mc4](https://huggingface.co/datasets/bertin-project/mc4-es-sampled ) subsampling documents to a total of about 50 million examples. Sampling is biased towards average perplexity values (defining perplexity boundaries based on quartiles), discarding more often documents with very large values (Q4, poor quality) of very small values (Q1, short, repetitive texts).
This model has been trained for 180.000 steps (early stopped from 250k intended steps).
Please see our main [card](https://huggingface.co/bertin-project/bertin-roberta-base-spanish) for more information.
This is part of the
[Flax/Jax Community Week](https://discuss.huggingface.co/t/open-to-the-community-community-week-using-jax-flax-for-nlp-cv/7104), organised by [HuggingFace](https://huggingface.co/) and TPU usage sponsored by Google.
## Team members
- Eduardo Gonzรกlez ([edugp](https://huggingface.co/edugp))
- Javier de la Rosa ([versae](https://huggingface.co/versae))
- Manu Romero ([mrm8488](https://huggingface.co/))
- Marรญa Grandury ([mariagrandury](https://huggingface.co/))
- Pablo Gonzรกlez de Prado ([Pablogps](https://huggingface.co/Pablogps))
- Paulo Villegas ([paulo](https://huggingface.co/paulo)) | {"language": "es", "license": "cc-by-4.0", "tags": ["spanish", "roberta"], "pipeline_tag": "fill-mask", "widget": [{"text": "Fui a la librer\u00eda a comprar un <mask>."}]} | bertin-project/bertin-base-stepwise | null | [
"transformers",
"pytorch",
"jax",
"tensorboard",
"joblib",
"roberta",
"fill-mask",
"spanish",
"es",
"license:cc-by-4.0",
"autotrain_compatible",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
text-classification | transformers |
This checkpoint has been trained for the XNLI dataset.
This checkpoint was created from **Bertin Gaussian 512**, which is a **RoBERTa-base** model trained from scratch in Spanish. Information on this base model may be found at [its own card](https://huggingface.co/bertin-project/bertin-base-gaussian-exp-512seqlen) and at deeper detail on [the main project card](https://huggingface.co/bertin-project/bertin-roberta-base-spanish).
The training dataset for the base model is [mc4](https://huggingface.co/datasets/bertin-project/mc4-es-sampled ) subsampling documents to a total of about 50 million examples. Sampling is biased towards average perplexity values (using a Gaussian function), discarding more often documents with very large values (poor quality) of very small values (short, repetitive texts).
This is part of the
[Flax/Jax Community Week](https://discuss.huggingface.co/t/open-to-the-community-community-week-using-jax-flax-for-nlp-cv/7104), organised by [HuggingFace](https://huggingface.co/) and TPU usage sponsored by Google.
## Team members
- Eduardo Gonzรกlez ([edugp](https://huggingface.co/edugp))
- Javier de la Rosa ([versae](https://huggingface.co/versae))
- Manu Romero ([mrm8488](https://huggingface.co/))
- Marรญa Grandury ([mariagrandury](https://huggingface.co/))
- Pablo Gonzรกlez de Prado ([Pablogps](https://huggingface.co/Pablogps))
- Paulo Villegas ([paulo](https://huggingface.co/paulo)) | {"language": "es", "license": "cc-by-4.0", "tags": ["spanish", "roberta", "xnli"]} | bertin-project/bertin-base-xnli-es | null | [
"transformers",
"pytorch",
"safetensors",
"roberta",
"text-classification",
"spanish",
"xnli",
"es",
"license:cc-by-4.0",
"autotrain_compatible",
"endpoints_compatible",
"has_space",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
fill-mask | transformers |
- [Version v2](https://huggingface.co/bertin-project/bertin-roberta-base-spanish/tree/v2) (default): April 28th, 2022
- [Version v1](https://huggingface.co/bertin-project/bertin-roberta-base-spanish/tree/v1): July 26th, 2021
- [Version v1-512](https://huggingface.co/bertin-project/bertin-roberta-base-spanish/tree/v1-512): July 26th, 2021
- [Version beta](https://huggingface.co/bertin-project/bertin-roberta-base-spanish/tree/beta): July 15th, 2021
# BERTIN
<div align=center>
<img alt="BERTIN logo" src="https://huggingface.co/bertin-project/bertin-roberta-base-spanish/resolve/main/images/bertin.png" width="200px">
</div>
BERTIN is a series of BERT-based models for Spanish. The current model hub points to the best of all RoBERTa-base models trained from scratch on the Spanish portion of mC4 using [Flax](https://github.com/google/flax). All code and scripts are included.
This is part of the
[Flax/Jax Community Week](https://discuss.huggingface.co/t/open-to-the-community-community-week-using-jax-flax-for-nlp-cv/7104), organized by [HuggingFace](https://huggingface.co/) and TPU usage sponsored by Google Cloud.
The aim of this project was to pre-train a RoBERTa-base model from scratch during the Flax/JAX Community Event, in which Google Cloud provided free TPUv3-8 to do the training using Huggingface's Flax implementations of their library.
## Team members
- Javier de la Rosa ([versae](https://huggingface.co/versae))
- Eduardo Gonzรกlez ([edugp](https://huggingface.co/edugp))
- Paulo Villegas ([paulo](https://huggingface.co/paulo))
- Pablo Gonzรกlez de Prado ([Pablogps](https://huggingface.co/Pablogps))
- Manu Romero ([mrm8488](https://huggingface.co/))
- Marรญa Grandury ([mariagrandury](https://huggingface.co/))
## Citation and Related Information
To cite this model:
```bibtex
@article{BERTIN,
author = {Javier De la Rosa y Eduardo G. Ponferrada y Manu Romero y Paulo Villegas y Pablo Gonzรกlez de Prado Salas y Marรญa Grandury},
title = {BERTIN: Efficient Pre-Training of a Spanish Language Model using Perplexity Sampling},
journal = {Procesamiento del Lenguaje Natural},
volume = {68},
number = {0},
year = {2022},
keywords = {},
abstract = {The pre-training of large language models usually requires massive amounts of resources, both in terms of computation and data. Frequently used web sources such as Common Crawl might contain enough noise to make this pretraining sub-optimal. In this work, we experiment with different sampling methods from the Spanish version of mC4, and present a novel data-centric technique which we name perplexity sampling that enables the pre-training of language models in roughly half the amount of steps and using one fifth of the data. The resulting models are comparable to the current state-of-the-art, and even achieve better results for certain tasks. Our work is proof of the versatility of Transformers, and paves the way for small teams to train their models on a limited budget.},
issn = {1989-7553},
url = {http://journal.sepln.org/sepln/ojs/ojs/index.php/pln/article/view/6403},
pages = {13--23}
}
```
If you use this model, we would love to hear about it! Reach out on twitter, GitHub, Discord, or shoot us an email.
## Team
- Javier de la Rosa ([versae](https://huggingface.co/versae))
- Eduardo Gonzรกlez ([edugp](https://huggingface.co/edugp))
- Paulo Villegas ([paulo](https://huggingface.co/paulo))
- Pablo Gonzรกlez de Prado ([Pablogps](https://huggingface.co/Pablogps))
- Manu Romero ([mrm8488](https://huggingface.co/))
- Marรญa Grandury ([mariagrandury](https://huggingface.co/))
## Acknowledgements
This project would not have been possible without compute generously provided by the Huggingface and Google through the
[TPU Research Cloud](https://sites.research.google/trc/), as well as the Cloud TPU team for providing early access to the [Cloud TPU VM](https://cloud.google.com/blog/products/compute/introducing-cloud-tpu-vms).
## Disclaimer
The models published in this repository are intended for a generalist purpose and are available to third parties. These models may have bias and/or any other undesirable distortions. When third parties, deploy or provide systems and/or services to other parties using any of these models (or using systems based on these models) or become users of the models, they should note that it is their responsibility to mitigate the risks arising from their use and, in any event, to comply with applicable regulations, including regulations regarding the use of artificial intelligence. In no event shall the owner of the models be liable for any results arising from the use made by third parties of these models.
<hr>
<details>
<summary>Full report</summary>
# Motivation
According to [Wikipedia](https://en.wikipedia.org/wiki/List_of_languages_by_total_number_of_speakers), Spanish is the second most-spoken language in the world by native speakers (>470 million speakers), only after Chinese, and the fourth including those who speak it as a second language. However, most NLP research is still mainly available in English. Relevant contributions like BERT, XLNet or GPT2 sometimes take years to be available in Spanish and, when they do, it is often via multilingual versions which are not as performant as the English alternative.
At the time of the event there were no RoBERTa models available in Spanish. Therefore, releasing one such model was the primary goal of our project. During the Flax/JAX Community Event we released a beta version of our model, which was the first in the Spanish language. Thereafter, on the last day of the event, the Barcelona Supercomputing Center released their own [RoBERTa](https://arxiv.org/pdf/2107.07253.pdf) model. The precise timing suggests our work precipitated its publication, and such an increase in competition is a desired outcome of our project. We are grateful for their efforts to include BERTIN in their paper, as discussed further below, and recognize the value of their own contribution, which we also acknowledge in our experiments.
Models in monolingual Spanish are hard to come by and, when they do, they are often trained on proprietary datasets and with massive resources. In practice, this means that many relevant algorithms and techniques remain exclusive to large technology companies and organizations. This motivated the second goal of our project, which is to bring training of large models like RoBERTa one step closer to smaller groups. We want to explore techniques that make training these architectures easier and faster, thus contributing to the democratization of large language models.
## Spanish mC4
The dataset mC4 is a multilingual variant of the C4, the Colossal, Cleaned version of Common Crawl's web crawl corpus. While C4 was used to train the T5 text-to-text Transformer models, mC4 comprises natural text in 101 languages drawn from the public Common Crawl web-scrape and was used to train mT5, the multilingual version of T5.
The Spanish portion of mC4 (mC4-es) contains about 416 million samples and 235 billion words in approximately 1TB of uncompressed data.
```bash
$ zcat c4/multilingual/c4-es*.tfrecord*.json.gz | wc -l
416057992
```
```bash
$ zcat c4/multilingual/c4-es*.tfrecord-*.json.gz | jq -r '.text | split(" ") | length' | paste -s -d+ - | bc
235303687795
```
## Perplexity sampling
The large amount of text in mC4-es makes training a language model within the time constraints of the Flax/JAX Community Event problematic. This motivated the exploration of sampling methods, with the goal of creating a subset of the dataset that would allow for the training of well-performing models with roughly one eighth of the data (~50M samples) and at approximately half the training steps.
In order to efficiently build this subset of data, we decided to leverage a technique we call *perplexity sampling*, and whose origin can be traced to the construction of CCNet (Wenzek et al., 2020) and their high quality monolingual datasets from web-crawl data. In their work, they suggest the possibility of applying fast language models trained on high-quality data such as Wikipedia to filter out texts that deviate too much from correct expressions of a language (see Figure 1). They also released Kneser-Ney models (Ney et al., 1994) for 100 languages (Spanish included) as implemented in the KenLM library (Heafield, 2011) and trained on their respective Wikipedias.
<figure>

<caption>Figure 1. Perplexity distributions by percentage CCNet corpus.</caption>
</figure>
In this work, we tested the hypothesis that perplexity sampling might help
reduce training-data size and training times, while keeping the performance of
the final model.
## Methodology
In order to test our hypothesis, we first calculated the perplexity of each document in a random subset (roughly a quarter of the data) of mC4-es and extracted their distribution and quartiles (see Figure 2).
<figure>

<caption>Figure 2. Perplexity distributions and quartiles (red lines) of 44M samples of mC4-es.</caption>
</figure>
With the extracted perplexity percentiles, we created two functions to oversample the central quartiles with the idea of biasing against samples that are either too small (short, repetitive texts) or too long (potentially poor quality) (see Figure 3).
The first function is a `Stepwise` that simply oversamples the central quartiles using quartile boundaries and a `factor` for the desired sampling frequency for each quartile, obviously giving larger frequencies for middle quartiles (oversampling Q2, Q3, subsampling Q1, Q4).
The second function weighted the perplexity distribution by a Gaussian-like function, to smooth out the sharp boundaries of the `Stepwise` function and give a better approximation to the desired underlying distribution (see Figure 4).
We adjusted the `factor` parameter of the `Stepwise` function, and the `factor` and `width` parameter of the `Gaussian` function to roughly be able to sample 50M samples from the 416M in mC4-es (see Figure 4). For comparison, we also sampled randomly mC4-es up to 50M samples as well. In terms of sizes, we went down from 1TB of data to ~200GB. We released the code to sample from mC4 on the fly when streaming for any language under the dataset [`bertin-project/mc4-sampling`](https://huggingface.co/datasets/bertin-project/mc4-sampling).
<figure>

<caption>Figure 3. Expected perplexity distributions of the sample mC4-es after applying the Stepwise function.</caption>
</figure>
<figure>

<caption>Figure 4. Expected perplexity distributions of the sample mC4-es after applying Gaussian function.</caption>
</figure>
Figure 5 shows the actual perplexity distributions of the generated 50M subsets for each of the executed subsampling procedures. All subsets can be easily accessed for reproducibility purposes using the [`bertin-project/mc4-es-sampled`](https://huggingface.co/datasets/bertin-project/mc4-es-sampled) dataset. We adjusted our subsampling parameters so that we would sample around 50M examples from the original train split in mC4. However, when these parameters were applied to the validation split they resulted in too few examples (~400k samples), Therefore, for validation purposes, we extracted 50k samples at each evaluation step from our own train dataset on the fly. Crucially, those elements were then excluded from training, so as not to validate on previously seen data. In the [`mc4-es-sampled`](https://huggingface.co/datasets/bertin-project/mc4-es-sampled) dataset, the train split contains the full 50M samples, while validation is retrieved as it is from the original mC4.
```python
from datasets import load_dataset
for config in ("random", "stepwise", "gaussian"):
mc4es = load_dataset(
"bertin-project/mc4-es-sampled",
config,
split="train",
streaming=True
).shuffle(buffer_size=1000)
for sample in mc4es:
print(config, sample)
break
```
<figure>

<caption>Figure 5. Experimental perplexity distributions of the sampled mc4-es after applying Gaussian and Stepwise functions, and the Random control sample.</caption>
</figure>
`Random` sampling displayed the same perplexity distribution of the underlying true distribution, as can be seen in Figure 6.
<figure>

<caption>Figure 6. Experimental perplexity distribution of the sampled mc4-es after applying Random sampling.</caption>
</figure>
Although this is not a comprehensive analysis, we looked into the distribution of perplexity for the training corpus. A quick t-SNE graph seems to suggest the distribution is uniform for the different topics and clusters of documents. The [interactive plot](https://huggingface.co/bertin-project/bertin-roberta-base-spanish/raw/main/images/perplexity_colored_embeddings.html) was generated using [a distilled version of multilingual USE](https://huggingface.co/sentence-transformers/distiluse-base-multilingual-cased-v1) to embed a random subset of 20,000 examples and each example is colored based on its perplexity. This is important since, in principle, introducing a perplexity-biased sampling method could introduce undesired biases if perplexity happens to be correlated to some other quality of our data. The code required to replicate this plot is available at [`tsne_plot.py`](https://huggingface.co/bertin-project/bertin-roberta-base-spanish/blob/main/tsne_plot.py) script and the HTML file is located under [`images/perplexity_colored_embeddings.html`](https://huggingface.co/bertin-project/bertin-roberta-base-spanish/blob/main/images/perplexity_colored_embeddings.html).
### Training details
We then used the same setup and hyperparameters as [Liu et al. (2019)](https://arxiv.org/abs/1907.11692) but trained only for half the steps (250k) on a sequence length of 128. In particular, `Gaussian` and `Stepwise` trained for the 250k steps, while `Random` was stopped at 230k. `Stepwise` needed to be initially stopped at 180k to allow downstream tests (sequence length 128), but was later resumed and finished the 250k steps. At the time of tests for 512 sequence length it had reached 204k steps, improving performance substantially.
Then, we continued training the most promising models for a few more steps (~50k) on sequence length 512 from the previous checkpoints on 128 sequence length at 230k steps. We tried two strategies for this, since it is not easy to find clear details about how to proceed in the literature. It turns out this decision had a big impact in the final performance.
For `Random` sampling we trained with sequence length 512 during the last 25k steps of the 250k training steps, keeping the optimizer state intact. Results for this are underwhelming, as seen in Figure 7.
<figure>

<caption>Figure 7. Training profile for Random sampling. Note the drop in performance after the change from 128 to 512 sequence length.</caption>
</figure>
For `Gaussian` sampling we started a new optimizer after 230k steps with 128 sequence length, using a short warmup interval. Results are much better using this procedure. We do not have a graph since training needed to be restarted several times, however, final accuracy was 0.6873 compared to 0.5907 for `Random` (512), a difference much larger than that of their respective -128 models (0.6520 for `Random`, 0.6608 for `Gaussian`). Following the same procedure, `Stepwise` continues training on sequence length 512 with a MLM accuracy of 0.6744 at 31k steps.
Batch size was 2048 (8 TPU cores x 256 batch size) for training with 128 sequence length, and 384 (8 x 48) for 512 sequence length, with no change in learning rate. Warmup steps for 512 was 500.
## Results
Please refer to the **evaluation** folder for training scripts for downstream tasks.
Our first test, tagged [`beta`](https://huggingface.co/bertin-project/bertin-roberta-base-spanish/tree/beta) in this repository, refers to an initial experiment using `Stepwise` on 128 sequence length and trained for 210k steps with a small `factor` set to 10. The repository [`flax-community/bertin-roberta-large-spanish`](https://huggingface.co/flax-community/bertin-roberta-large-spanish) contains a nearly identical version but it is now discontinued). During the community event, the Barcelona Supercomputing Center (BSC) in association with the National Library of Spain released RoBERTa base and large models trained on 200M documents (570GB) of high quality data clean using 100 nodes with 48 CPU cores of MareNostrum 4 during 96h. At the end of the process they were left with 2TB of clean data at the document level that were further cleaned up to the final 570GB. This is an interesting contrast to our own resources (3 TPUv3-8 for 10 days to do cleaning, sampling, training, and evaluation) and makes for a valuable reference. The BSC team evaluated our early release of the model [`beta`](https://huggingface.co/bertin-project/bertin-roberta-base-spanish/tree/beta) and the results can be seen in Table 1.
Our final models were trained on a different number of steps and sequence lengths and achieve differentโhigherโmasked-word prediction accuracies. Despite these limitations it is interesting to see the results they obtained using the early version of our model. Note that some of the datasets used for evaluation by BSC are not freely available, therefore it is not possible to verify the figures.
<figure>
<caption>Table 1. Evaluation made by the Barcelona Supercomputing Center of their models and BERTIN (beta, sequence length 128), from their preprint(arXiv:2107.07253).</caption>
| Dataset | Metric | RoBERTa-b | RoBERTa-l | BETO | mBERT | BERTIN (beta) |
|-------------|----------|-----------|-----------|--------|--------|--------|
| UD-POS | F1 |**0.9907** | 0.9901 | 0.9900 | 0.9886 | **0.9904** |
| Conll-NER | F1 | 0.8851 | 0.8772 | 0.8759 | 0.8691 | 0.8627 |
| Capitel-POS | F1 | 0.9846 | 0.9851 | 0.9836 | 0.9839 | 0.9826 |
| Capitel-NER | F1 | 0.8959 | 0.8998 | 0.8771 | 0.8810 | 0.8741 |
| STS | Combined | 0.8423 | 0.8420 | 0.8216 | 0.8249 | 0.7822 |
| MLDoc | Accuracy | 0.9595 | 0.9600 | 0.9650 | 0.9560 | **0.9673** |
| PAWS-X | F1 | 0.9035 | 0.9000 | 0.8915 | 0.9020 | 0.8820 |
| XNLI | Accuracy | 0.8016 | WIP | 0.8130 | 0.7876 | WIP |
</figure>
All of our models attained good accuracy values during training in the masked-language model task โin the range of 0.65โ as can be seen in Table 2:
<figure>
<caption>Table 2. Accuracy for the different language models for the main masked-language model task.</caption>
| Model | Accuracy |
|----------------------------------------------------|----------|
| [`bertin-project/bertin-roberta-base-spanish (beta)`](https://huggingface.co/bertin-project/bertin-roberta-base-spanish) | 0.6547 |
| [`bertin-project/bertin-base-random`](https://huggingface.co/bertin-project/bertin-base-random) | 0.6520 |
| [`bertin-project/bertin-base-stepwise`](https://huggingface.co/bertin-project/bertin-base-stepwise) | 0.6487 |
| [`bertin-project/bertin-base-gaussian`](https://huggingface.co/bertin-project/bertin-base-gaussian) | 0.6608 |
| [`bertin-project/bertin-base-random-exp-512seqlen`](https://huggingface.co/bertin-project/bertin-base-random-exp-512seqlen) | 0.5907 |
| [`bertin-project/bertin-base-stepwise-exp-512seqlen`](https://huggingface.co/bertin-project/bertin-base-stepwise-exp-512seqlen) | 0.6818 |
| [`bertin-project/bertin-base-gaussian-exp-512seqlen`](https://huggingface.co/bertin-project/bertin-base-gaussian-exp-512seqlen) | **0.6873** |
</figure>
### Downstream Tasks
We are currently in the process of applying our language models to downstream tasks.
For simplicity, we will abbreviate the different models as follows:
- **mBERT**: [`bert-base-multilingual-cased`](https://huggingface.co/bert-base-multilingual-cased)
- **BETO**: [`dccuchile/bert-base-spanish-wwm-cased`](https://huggingface.co/dccuchile/bert-base-spanish-wwm-cased)
- **BSC-BNE**: [`BSC-TeMU/roberta-base-bne`](https://huggingface.co/BSC-TeMU/roberta-base-bne)
- **Beta**: [`bertin-project/bertin-roberta-base-spanish`](https://huggingface.co/bertin-project/bertin-roberta-base-spanish)
- **Random**: [`bertin-project/bertin-base-random`](https://huggingface.co/bertin-project/bertin-base-random)
- **Stepwise**: [`bertin-project/bertin-base-stepwise`](https://huggingface.co/bertin-project/bertin-base-stepwise)
- **Gaussian**: [`bertin-project/bertin-base-gaussian`](https://huggingface.co/bertin-project/bertin-base-gaussian)
- **Random-512**: [`bertin-project/bertin-base-random-exp-512seqlen`](https://huggingface.co/bertin-project/bertin-base-random-exp-512seqlen)
- **Stepwise-512**: [`bertin-project/bertin-base-stepwise-exp-512seqlen`](https://huggingface.co/bertin-project/bertin-base-stepwise-exp-512seqlen) (WIP)
- **Gaussian-512**: [`bertin-project/bertin-base-gaussian-exp-512seqlen`](https://huggingface.co/bertin-project/bertin-base-gaussian-exp-512seqlen)
<figure>
<caption>
Table 3. Metrics for different downstream tasks, comparing our different models as well as other relevant BERT variations from the literature. Dataset for POS and NER is CoNLL 2002. POS and NER used max length 128 and batch size 16. Batch size for XNLI is 32 (max length 256). All models were fine-tuned for 5 epochs, with the exception of XNLI-256 that used 2 epochs. Stepwise used an older checkpoint with only 180.000 steps.
</caption>
| Model | POS (F1/Acc) | NER (F1/Acc) | XNLI-256 (Acc) |
|--------------|----------------------|---------------------|----------------|
| mBERT | 0.9629 / 0.9687 | 0.8539 / 0.9779 | 0.7852 |
| BETO | 0.9642 / 0.9700 | 0.8579 / 0.9783 | **0.8186** |
| BSC-BNE | 0.9659 / 0.9707 | 0.8700 / 0.9807 | 0.8178 |
| Beta | 0.9638 / 0.9690 | 0.8725 / 0.9812 | 0.7791 |
| Random | 0.9656 / 0.9704 | 0.8704 / 0.9807 | 0.7745 |
| Stepwise | 0.9656 / 0.9707 | 0.8705 / 0.9809 | 0.7820 |
| Gaussian | 0.9662 / 0.9709 | **0.8792 / 0.9816** | 0.7942 |
| Random-512 | 0.9660 / 0.9707 | 0.8616 / 0.9803 | 0.7723 |
| Stepwise-512 | WIP | WIP | WIP |
| Gaussian-512 | **0.9662 / 0.9714** | **0.8764 / 0.9819** | 0.7878 |
</figure>
Table 4. Metrics for different downstream tasks, comparing our different models as well as other relevant BERT variations from the literature. Dataset for POS and NER is CoNLL 2002. POS, NER and PAWS-X used max length 512 and batch size 16. Batch size for XNLI is 16 too (max length 512). All models were fine-tuned for 5 epochs. Results marked with `*` indicate more than one run to guarantee convergence.
</caption>
| Model | POS (F1/Acc) | NER (F1/Acc) | PAWS-X (Acc) | XNLI (Acc) |
|--------------|----------------------|---------------------|--------------|------------|
| mBERT | 0.9630 / 0.9689 | 0.8616 / 0.9790 | 0.8895* | 0.7606 |
| BETO | 0.9639 / 0.9693 | 0.8596 / 0.9790 | 0.8720* | **0.8012** |
| BSC-BNE | **0.9655 / 0.9706** | 0.8764 / 0.9818 | 0.8815* | 0.7771* |
| Beta | 0.9616 / 0.9669 | 0.8640 / 0.9799 | 0.8670* | 0.7751* |
| Random | 0.9651 / 0.9700 | 0.8638 / 0.9802 | 0.8800* | 0.7795 |
| Stepwise | 0.9647 / 0.9698 | 0.8749 / 0.9819 | 0.8685* | 0.7763 |
| Gaussian | 0.9644 / 0.9692 | **0.8779 / 0.9820** | 0.8875* | 0.7843 |
| Random-512 | 0.9636 / 0.9690 | 0.8664 / 0.9806 | 0.6735* | 0.7799 |
| Stepwise-512 | 0.9633 / 0.9684 | 0.8662 / 0.9811 | 0.8690 | 0.7695 |
| Gaussian-512 | 0.9646 / 0.9697 | 0.8707 / 0.9810 | **0.8965**\* | 0.7843 |
</figure>
In addition to the tasks above, we also trained the [`beta`](https://huggingface.co/bertin-project/bertin-roberta-base-spanish/tree/beta) model on the SQUAD dataset, achieving exact match 50.96 and F1 68.74 (sequence length 128). A full evaluation of this task is still pending.
Results for PAWS-X seem surprising given the large differences in performance. However, this training was repeated to avoid failed runs and results seem consistent. A similar problem was found for XNLI-512, where many models reported a very poor 0.3333 accuracy on a first run (and even a second, in the case of BSC-BNE). This suggests training is a bit unstable for some datasets under these conditions. Increasing the batch size and number of epochs would be a natural attempt to fix this problem, however, this is not feasible within the project schedule. For example, runtime for XNLI-512 was ~19h per model and increasing the batch size without reducing sequence length is not feasible on a single GPU.
We are also releasing the fine-tuned models for `Gaussian`-512 and making it our version [v1](https://huggingface.co/bertin-project/bertin-roberta-base-spanish/tree/v1) default to 128 sequence length since it experimentally shows better performance on fill-mask task, while also releasing the 512 sequence length version ([v1-512](https://huggingface.co/bertin-project/bertin-roberta-base-spanish/tree/v1-512) for fine-tuning.
- POS: [`bertin-project/bertin-base-pos-conll2002-es`](https://huggingface.co/bertin-project/bertin-base-pos-conll2002-es/)
- NER: [`bertin-project/bertin-base-ner-conll2002-es`](https://huggingface.co/bertin-project/bertin-base-ner-conll2002-es/)
- PAWS-X: [`bertin-project/bertin-base-paws-x-es`](https://huggingface.co/bertin-project/bertin-base-paws-x-es)
- XNLI: [`bertin-project/bertin-base-xnli-es`](https://huggingface.co/bertin-project/bertin-base-xnli-es)
## Bias and ethics
While a rigorous analysis of our models and datasets for bias was out of the scope of our project (given the very tight schedule and our lack of experience on Flax/JAX), this issue has still played an important role in our motivation. Bias is often the result of applying massive, poorly-curated datasets during training of expensive architectures. This means that, even if problems are identified, there is little most can do about it at the root level since such training can be prohibitively expensive. We hope that, by facilitating competitive training with reduced times and datasets, we will help to enable the required iterations and refinements that these models will need as our understanding of biases improves. For example, it should be easier now to train a RoBERTa model from scratch using newer datasets specially designed to address bias. This is surely an exciting prospect, and we hope that this work will contribute in such challenges.
Even if a rigorous analysis of bias is difficult, we should not use that excuse to disregard the issue in any project. Therefore, we have performed a basic analysis looking into possible shortcomings of our models. It is crucial to keep in mind that these models are publicly available and, as such, will end up being used in multiple real-world situations. These applications โsome of them modern versions of phrenologyโ have a dramatic impact in the lives of people all over the world. We know Deep Learning models are in use today as [law assistants](https://www.wired.com/2017/04/courts-using-ai-sentence-criminals-must-stop-now/), in [law enforcement](https://www.washingtonpost.com/technology/2019/05/16/police-have-used-celebrity-lookalikes-distorted-images-boost-facial-recognition-results-research-finds/), as [exam-proctoring tools](https://www.wired.com/story/ai-college-exam-proctors-surveillance/) (also [this](https://www.eff.org/deeplinks/2020/09/students-are-pushing-back-against-proctoring-surveillance-apps)), for [recruitment](https://www.washingtonpost.com/technology/2019/10/22/ai-hiring-face-scanning-algorithm-increasingly-decides-whether-you-deserve-job/) (also [this](https://www.technologyreview.com/2021/07/21/1029860/disability-rights-employment-discrimination-ai-hiring/)) and even to [target minorities](https://www.insider.com/china-is-testing-ai-recognition-on-the-uighurs-bbc-2021-5). Therefore, it is our responsibility to fight bias when possible, and to be extremely clear about the limitations of our models, to discourage problematic use.
### Bias examples (Spanish)
Note that this analysis is slightly more difficult to do in Spanish since gender concordance reveals hints beyond masks. Note many suggestions seem grammatically incorrect in English, but with few exceptions โlike โdrive highโ, which works in English but not in Spanishโ they are all correct, even if uncommon.
Results show that bias is apparent even in a quick and shallow analysis like this one. However, there are many instances where the results are more neutral than anticipated. For instance, the first option to โdo the dishesโ is the โsonโ, and โpinkโ is nowhere to be found in the color recommendations for a girl. Women seem to drive โhighโ, โfastโ, โstrongโ and โwellโ, but โnot a lotโ.
But before we get complacent, the model reminds us that the place of the woman is at "home" or "the bed" (!), while the man is free to roam the "streets", the "city" and even "Earth" (or "earth", both options are granted).
Similar conclusions are derived from examples focusing on race and religion. Very matter-of-factly, the first suggestion always seems to be a repetition of the group ("Christians" **are** "Christians", after all), and other suggestions are rather neutral and tame. However, there are some worrisome proposals. For example, the fourth option for Jews is that they are "racist". Chinese people are both "intelligent" and "stupid", which actually hints to different forms of racism they encounter (so-called "positive" racism, such as claiming Asians are good at math, which can be insidious and [should not be taken lightly](https://www.health.harvard.edu/blog/anti-asian-racism-breaking-through-stereotypes-and-silence-2021041522414)). Predictions for Latin Americans also raise red flags, as they are linked to being "poor" and even "worse".
The model also seems to suffer from geographical bias, producing words that are more common in Spain than other countries. For example, when filling the mask in "My <mask> is a Hyundai Accent", the word "coche" scores higher than "carro" (Spanish and Latin American words for car, respectively) while "auto", which is used in Argentina, doesn't appear in the top 5 choices. A more problematic example is seen with the word used for "taking" or "grabbing", when filling the mask in the sentence "I am late, I have to <mask> the bus". In Spain, the word "coger" is used, while in most countries in Latin America, the word "tomar" is used instead, while "coger" means "to have sex". The model choses "coger el autobรบs", which is a perfectly appropriate choice in the eyes of a person from Spainโit would translate to "take the bus", but inappropriate in most parts of Latin America, where it would mean "to have sex with the bus". Another example of geographical bias, can be observed by the preference of the model for the Spanish word for "drive", over its Latin American counterparts. Even when prompted with the words "carro" and "auto" (used in Latin America for "car"), the model chooses "conducir" (Spain) over "manejar" (Latin America) - however, "conducir" (Spain) scores higher when prompted with "coche" (Spain) than with "carro" and "auto" (Latin American), suggesting that the model has at least some basic understanding of the different ways of speaking Spanish in different parts of the world.
On gender
- Dile a tu **hijo** que hay que fregar los platos.
hijo โ madre โ jefe โ pareja โ suegra
- Las mujeres conducen muy **alto**.
alto โ rรกpido โ poco โ fuerte โ bien
- El lugar de la mujer estรก en la **casa**.
casa โ cama โ tierra โ calle โ vida
- El lugar del hombre estรก en la **casa**.
calle โ ciudad โ Tierra โ tierra โ casa
- Quรฉ mal **vivir**, ยกtenรญa que ser mujer!
vivir โ estรก โ decirlo โ hacer โ escrito
- Quรฉ mal **vivir**, ยกtenรญa que ser hombre!
vivir โ estรก โ hecho โ escrito โ verlo
- Como soy chica, mi color favorito es el **rojo**.
rojo โ blanco โ azul โ verde โ naranja
On religion
- La mayorรญa de los musulmanes son **musulmanes**.
musulmanes โ รกrabes โ cristianos โ occidentales โ (salto de lรญnea)
- La mayorรญa de los cristianos son **cristianos**.
cristianos โ catรณlicos โ (salto de lรญnea) โ . โ mujeres
- La mayorรญa de los judรญos son **judรญos**.
judรญos โ blancos โ argentinos โ racistas โ israelรญes
On race and origin
- Los รกrabes son **รกrabes**.
รกrabes โ musulmanes โ iguales โ dioses โ cristianos
- Los chinos son **chinos**.
chinos โ asiรกticos โ inteligentes โ negros โ tontos
- Los europeos son **europeos**.
europeos โ alemanes โ espaรฑoles โ iguales โ britรกnicos
- Los indios son **negros**.
negros โ buenos โ indios โ todos โ hombres
- Los latinoamericanos son **mayorรญa**.
mayorรญa โ iguales โ pobres โ latinoamericanos โ peores
Geographical bias
- Mi **coche** es un Hyundai Accent.
coche โ carro โ vehรญculo โ moto โ padre
- Llego tarde, tengo que **coger** el autobรบs.
coger โ tomar โ evitar โ abandonar โ utilizar
- Para llegar a mi casa, tengo que **conducir** mi coche.
conducir โ alquilar โ llevar โ coger โ aparcar
- Para llegar a mi casa, tengo que **llevar** mi carro.
llevar โ comprar โ tener โ cargar โ conducir
- Para llegar a mi casa, tengo que **llevar** mi auto.
llevar โ tener โ conducir โ coger โ cargar
### Bias examples (English translation)
On gender
- Tell your **son** to do the dishes.
son โ mother โ boss (male) โ partner โ mother in law
- Women drive very **high**.
high (no drugs connotation) โ fast โ not a lot โ strong โ well
- The place of the woman is at **home**.
house (home) โ bed โ earth โ street โ life
- The place of the man is at the **street**.
street โ city โ Earth โ earth โ house (home)
- Hard translation: What a bad way to <mask>, it had to be a woman!
Expecting sentences like: Awful driving, it had to be a woman! (Sadly common.)
live โ is (โhow bad it isโ) โ to say it โ to do โ written
- (See previous example.) What a bad way to <mask>, it had to be a man!
live โ is (โhow bad it isโ) โ done โ written โ to see it (how unfortunate to see it)
- Since I'm a girl, my favourite colour is **red**.
red โ white โ blue โ green โ orange
On religion
- Most Muslims are **Muslim**.
Muslim โ Arab โ Christian โ Western โ (new line)
- Most Christians are **Christian**.
Christian โ Catholic โ (new line) โ . โ women
- Most Jews are **Jews**.
Jews โ white โ Argentinian โ racist โ Israelis
On race and origin
- Arabs are **Arab**.
Arab โ Muslim โ the same โ gods โ Christian
- Chinese are **Chinese**.
Chinese โ Asian โ intelligent โ black โ stupid
- Europeans are **European**.
European โ German โ Spanish โ the same โ British
- Indians are **black**. (Indians refers both to people from India or several Indigenous peoples, particularly from America.)
black โ good โ Indian โ all โ men
- Latin Americans are **the majority**.
the majority โ the same โ poor โ Latin Americans โ worse
Geographical bias
- My **(Spain's word for) car** is a Hyundai Accent.
(Spain's word for) car โ (Most of Latin America's word for) car โ vehicle โ motorbike โ father
- I am running late, I have to **take (in Spain) / have sex with (in Latin America)** the bus.
take (in Spain) / have sex with (in Latin America) โ take (in Latin America) โ avoid โ leave โ utilize
- In order to get home, I have to **(Spain's word for) drive** my (Spain's word for) car.
(Spain's word for) drive โ rent โ bring โ take โ park
- In order to get home, I have to **bring** my (most of Latin America's word for) car.
bring โ buy โ have โ load โ (Spain's word for) drive
- In order to get home, I have to **bring** my (Argentina's and other parts of Latin America's word for) car.
bring โ have โ (Spain's word for) drive โ take โ load
## Analysis
The performance of our models has been, in general, very good. Even our beta model was able to achieve SOTA in MLDoc (and virtually tie in UD-POS) as evaluated by the Barcelona Supercomputing Center. In the main masked-language task our models reach values between 0.65 and 0.69, which foretells good results for downstream tasks.
Our analysis of downstream tasks is not yet complete. It should be stressed that we have continued this fine-tuning in the same spirit of the project, that is, with smaller practicioners and budgets in mind. Therefore, our goal is not to achieve the highest possible metrics for each task, but rather train using sensible hyper parameters and training times, and compare the different models under these conditions. It is certainly possible that any of the models โours or otherwiseโ could be carefully tuned to achieve better results at a given task, and it is a possibility that the best tuning might result in a new "winner" for that category. What we can claim is that, under typical training conditions, our models are remarkably performant. In particular, `Gaussian` sampling seems to produce more consistent models, taking the lead in four of the seven tasks analysed.
The differences in performance for models trained using different data-sampling techniques are consistent. `Gaussian`-sampling is always first (with the exception of POS-512), while `Stepwise` is better than `Random` when trained during a similar number of steps. This proves that the sampling technique is, indeed, relevant. A more thorough statistical analysis is still required.
As already mentioned in the [Training details](#training-details) section, the methodology used to extend sequence length during training is critical. The `Random`-sampling model took an important hit in performance in this process, while `Gaussian`-512 ended up with better metrics than than `Gaussian`-128, in both the main masked-language task and the downstream datasets. The key difference was that `Random` kept the optimizer intact while `Gaussian` used a fresh one. It is possible that this difference is related to the timing of the swap in sequence length, given that close to the end of training the optimizer will keep learning rates very low, perhaps too low for the adjustments needed after a change in sequence length. We believe this is an important topic of research, but our preliminary data suggests that using a new optimizer is a safe alternative when in doubt or if computational resources are scarce.
# Lessons and next steps
BERTIN Project has been a challenge for many reasons. Like many others in the Flax/JAX Community Event, ours is an impromptu team of people with little to no experience with Flax. Even if training a RoBERTa model sounds vaguely like a replication experiment, we anticipated difficulties ahead, and we were right to do so.
New tools always require a period of adaptation in the working flow. For instance, lacking โto the best of our knowledgeโ a monitoring tool equivalent to `nvidia-smi` makes simple procedures like optimizing batch sizes become troublesome. Of course, we also needed to improvise the code adaptations required for our data sampling experiments. Moreover, this re-conceptualization of the project required that we run many training processes during the event. This is another reason why saving and restoring checkpoints was a must for our success โthe other reason being our planned switch from 128 to 512 sequence length. However, such code was not available at the start of the Community Event. At some point code to save checkpoints was released, but not to restore and continue training from them (at least we are not aware of such update). In any case, writing this Flax code โwith help from the fantastic and collaborative spirit of the eventโ was a valuable learning experience, and these modifications worked as expected when they were needed.
The results we present in this project are very promising, and we believe they hold great value for the community as a whole. However, to fully make the most of our work, some next steps would be desirable.
The most obvious step ahead is to replicate training on a "large" version of the model. This was not possible during the event due to our need of faster iterations. We should also explore in finer detail the impact of our proposed sampling methods. In particular, further experimentation is needed on the impact of the `Gaussian` parameters. If perplexity-based sampling were to become a common technique, it would be important to look carefully into possible biases this might introduce. Our preliminary data suggests this is not the case, but it would be a rewarding analysis nonetheless. Another intriguing possibility is to combine our sampling algorithm with other cleaning steps such as deduplication (Lee et al., 2021), as they seem to share a complementary philosophy.
# Conclusions
With roughly 10 days worth of access to 3 TPUv3-8, we have achieved remarkable results surpassing previous state of the art in a few tasks, and even improving document classification on models trained in massive supercomputers with very large, highly-curated, and in some cases private, datasets.
The very big size of the datasets available looked enticing while formulating the project. However, it soon proved to be an important challenge given the time constraints. This led to a debate within the team and ended up reshaping our project and goals, now focusing on analysing this problem and how we could improve this situation for smaller teams like ours in the future. The subsampling techniques analysed in this report have shown great promise in this regard, and we hope to see other groups use them and improve them in the future.
At a personal level, the experience has been incredible for all of us. We believe that these kind of events provide an amazing opportunity for small teams on low or non-existent budgets to learn how the big players in the field pre-train their models, certainly stirring the research community. The trade-off between learning and experimenting, and being beta-testers of libraries (Flax/JAX) and infrastructure (TPU VMs) is a marginal cost to pay compared to the benefits such access has to offer.
Given our good results, on par with those of large corporations, we hope our work will inspire and set the basis for more small teams to play and experiment with language models on smaller subsets of huge datasets.
## Useful links
- [Community Week timeline](https://discuss.huggingface.co/t/open-to-the-community-community-week-using-jax-flax-for-nlp-cv/7104#summary-timeline-calendar-6)
- [Community Week README](https://github.com/huggingface/transformers/blob/master/examples/research_projects/jax-projects/README.md)
- [Community Week thread](https://discuss.huggingface.co/t/bertin-pretrain-roberta-large-from-scratch-in-spanish/7125)
- [Community Week channel](https://discord.com/channels/858019234139602994/859113060068229190)
- [Masked Language Modelling example scripts](https://github.com/huggingface/transformers/tree/master/examples/flax/language-modeling)
- [Model Repository](https://huggingface.co/flax-community/bertin-roberta-large-spanish/)
</details> | {"language": "es", "license": "cc-by-4.0", "tags": ["spanish", "roberta"], "datasets": ["bertin-project/mc4-es-sampled"], "pipeline_tag": "fill-mask", "widget": [{"text": "Fui a la librer\u00eda a comprar un <mask>."}]} | bertin-project/bertin-roberta-base-spanish | null | [
"transformers",
"pytorch",
"jax",
"tensorboard",
"safetensors",
"roberta",
"fill-mask",
"spanish",
"es",
"dataset:bertin-project/mc4-es-sampled",
"arxiv:2107.07253",
"arxiv:1907.11692",
"license:cc-by-4.0",
"autotrain_compatible",
"endpoints_compatible",
"has_space",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
question-answering | transformers | ## Demo
- [https://huggingface.co/spaces/bespin-global/Bespin-QuestionAnswering](https://huggingface.co/spaces/bespin-global/Bespin-QuestionAnswering)
## Finetuning
- Pretrain Model : [klue/bert-base](https://github.com/KLUE-benchmark/KLUE)
- Dataset for fine-tuning : [AIHub ๊ธฐ๊ณ๋
ํด ๋ฐ์ดํฐ์
](https://aihub.or.kr/aidata/86)
- ํ์ค ๋ฐ์ดํฐ ์
(25m) + ์ค๋ช
๊ฐ๋ฅ ๋ฐ์ดํฐ ์
(10m)
- Random Sampling (random_seed: 1234)
- Train : 30m
- Test : 5m
- Parameters of Training
```
{
"epochs": 4,
"batch_size":8,
"optimizer_class": "<class 'transformers.optimization.AdamW'>",
"optimizer_params": {
"lr": 3e-05
},
"weight_decay: 0.01
}
```
## Usage
```python
## Load Transformers library
import torch
from transformers import AutoModelForQuestionAnswering, AutoTokenizer
device = torch.device('cuda') if torch.cuda.is_available() else torch.device('cpu')
def predict_answer(qa_text_pair):
# Encoding
encodings = tokenizer(context, question,
max_length=512,
truncation=True,
padding="max_length",
return_token_type_ids=False,
return_offsets_mapping=True
)
encodings = {key: torch.tensor([val]).to(device) for key, val in encodings.items()}
# Predict
pred = model(encodings["input_ids"], attention_mask=encodings["attention_mask"])
start_logits, end_logits = pred.start_logits, pred.end_logits
token_start_index, token_end_index = start_logits.argmax(dim=-1), end_logits.argmax(dim=-1)
pred_ids = encodings["input_ids"][0][token_start_index: token_end_index + 1]
answer_text = tokenizer.decode(pred_ids)
# Offset
answer_start_offset = int(encodings['offset_mapping'][0][token_start_index][0][0])
answer_end_offset = int(encodings['offset_mapping'][0][token_end_index][0][1])
answer_offset = (answer_start_offset, answer_end_offset)
return {'answer_text':answer_text, 'answer_offset':answer_offset}
## Load fine-tuned MRC model by HuggingFace Model Hub ##
HUGGINGFACE_MODEL_PATH = "bespin-global/klue-bert-base-aihub-mrc"
tokenizer = AutoTokenizer.from_pretrained(HUGGINGFACE_MODEL_PATH)
model = AutoModelForQuestionAnswering.from_pretrained(HUGGINGFACE_MODEL_PATH).to(device)
## Predict ##
context = '''์ ํ M2(Apple M2)๋ ์ ํ์ด ์ค๊ณํ ์ค์ ์ฒ๋ฆฌ ์ฅ์น(CPU)์ ๊ทธ๋ํฝ ์ฒ๋ฆฌ ์ฅ์น(GPU)์ ARM ๊ธฐ๋ฐ ์์คํ
์ด๋ค.
์ธํ
์ฝ์ด(Intel Core)์์ ๋งฅํจํ ์ ์ปดํจํฐ์ฉ์ผ๋ก ์ค๊ณ๋ 2์ธ๋ ARM ์ํคํ
์ฒ์ด๋ค. ์ ํ์ 2022๋
6์ 6์ผ WWDC์์ ๋งฅ๋ถ ์์ด, 13์ธ์น ๋งฅ๋ถ ํ๋ก์ ํจ๊ป M2๋ฅผ ๋ฐํํ๋ค.
์ ํ M1์ ํ์์์ด๋ค. M2๋ TSMC์ 'ํฅ์๋ 5๋๋
ธ๋ฏธํฐ ๊ธฐ์ ' N5P ๊ณต์ ์ผ๋ก ๋ง๋ค์ด์ก์ผ๋ฉฐ, ์ด์ ์ธ๋ M1๋ณด๋ค 25% ์ฆ๊ฐํ 200์ต๊ฐ์ ํธ๋์ง์คํฐ๋ฅผ ํฌํจํ๊ณ ์์ผ๋ฉฐ, ์ต๋ 24๊ธฐ๊ฐ๋ฐ์ดํธ์ RAM๊ณผ 2ํ
๋ผ๋ฐ์ดํธ์ ์ ์ฅ๊ณต๊ฐ์ผ๋ก ๊ตฌ์ฑํ ์ ์๋ค.
8๊ฐ์ CPU ์ฝ์ด(์ฑ๋ฅ 4๊ฐ, ํจ์จ์ฑ 4๊ฐ)์ ์ต๋ 10๊ฐ์ GPU ์ฝ์ด๋ฅผ ๊ฐ์ง๊ณ ์๋ค. M2๋ ๋ํ ๋ฉ๋ชจ๋ฆฌ ๋์ญํญ์ 100 GB/s๋ก ์ฆ๊ฐ์ํจ๋ค.
์ ํ์ ๊ธฐ์กด M1 ๋๋น CPU๊ฐ ์ต๋ 18%, GPU๊ฐ ์ต๋ 35% ํฅ์๋๋ค๊ณ ์ฃผ์ฅํ๊ณ ์์ผ๋ฉฐ,[1] ๋ธ๋ฃธ๋ฒ๊ทธํต์ ์ M2๋งฅ์ค์ CPU ์ฝ์ด 12๊ฐ์ GPU ์ฝ์ด 38๊ฐ๊ฐ ํฌํจ๋ ๊ฒ์ด๋ผ๊ณ ๋ณด๋ํ๋ค.'''
question = "m2๊ฐ m1์ ๋นํด ์ผ๋ง๋ ์ข์์ก์ด?"
qa_text_pair = {'context':context, 'question':question}
result = predict_answer(qa_text_pair)
print('Answer Text: ', result['answer_text']) # ๊ธฐ์กด M1 ๋๋น CPU๊ฐ ์ต๋ 18 %, GPU๊ฐ ์ต๋ 35 % ํฅ์
print('Answer Offset: ', result['answer_offset']) # (410, 446)
```
## Citing & Authors
<!--- Describe where people can find more information -->
[Jaehyeong](https://huggingface.co/jaehyeong) at [Bespin Global](https://www.bespinglobal.com/) | {"language": "ko", "license": "cc-by-nc-4.0", "tags": ["bert", "mrc"], "datasets": ["aihub"]} | bespin-global/klue-bert-base-aihub-mrc | null | [
"transformers",
"pytorch",
"bert",
"question-answering",
"mrc",
"ko",
"dataset:aihub",
"license:cc-by-nc-4.0",
"endpoints_compatible",
"has_space",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
text-classification | transformers |
## Finetuning
- Pretrain Model : [klue/roberta-small](https://github.com/KLUE-benchmark/KLUE)
- Dataset for fine-tuning : [3i4k](https://github.com/warnikchow/3i4k)
- Train : 46,863
- Validation : 8,271 (15% of Train)
- Test : 6,121
- Label info
- 0: "fragment",
- 1: "statement",
- 2: "question",
- 3: "command",
- 4: "rhetorical question",
- 5: "rhetorical command",
- 6: "intonation-dependent utterance"
- Parameters of Training
```
{
"epochs": 3 (setting 10 but early stopped),
"batch_size":32,
"optimizer_class": "<keras.optimizer_v2.adam.Adam'>",
"optimizer_params": {
"lr": 5e-05
},
"min_delta": 0.01
}
```
## Usage
``` python
from transformers import RobertaTokenizerFast, RobertaForSequenceClassification, TextClassificationPipeline
# Load fine-tuned model by HuggingFace Model Hub
HUGGINGFACE_MODEL_PATH = "bespin-global/klue-roberta-small-3i4k-intent-classification"
loaded_tokenizer = RobertaTokenizerFast.from_pretrained(HUGGINGFACE_MODEL_PATH )
loaded_model = RobertaForSequenceClassification.from_pretrained(HUGGINGFACE_MODEL_PATH )
# using Pipeline
text_classifier = TextClassificationPipeline(
tokenizer=loaded_tokenizer,
model=loaded_model,
return_all_scores=True
)
# predict
text = "your text"
preds_list = text_classifier(text)
best_pred = preds_list[0]
print(f"Label of Best Intentatioin: {best_pred['label']}")
print(f"Score of Best Intentatioin: {best_pred['score']}")
```
## Evaluation
```
precision recall f1-score support
command 0.89 0.92 0.90 1296
fragment 0.98 0.96 0.97 600
intonation-depedent utterance 0.71 0.69 0.70 327
question 0.95 0.97 0.96 1786
rhetorical command 0.87 0.64 0.74 108
rhetorical question 0.61 0.63 0.62 174
statement 0.91 0.89 0.90 1830
accuracy 0.90 6121
macro avg 0.85 0.81 0.83 6121
weighted avg 0.90 0.90 0.90 6121
```
## Citing & Authors
<!--- Describe where people can find more information -->
[Jaehyeong](https://huggingface.co/jaehyeong) at [Bespin Global](https://www.bespinglobal.com/) | {"language": "ko", "license": "cc-by-nc-4.0", "tags": ["intent-classification"], "datasets": ["kor_3i4k"]} | bespin-global/klue-roberta-small-3i4k-intent-classification | null | [
"transformers",
"pytorch",
"tf",
"safetensors",
"roberta",
"text-classification",
"intent-classification",
"ko",
"dataset:kor_3i4k",
"license:cc-by-nc-4.0",
"autotrain_compatible",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
sentence-similarity | sentence-transformers |
# bespin-global/klue-sentence-roberta-kornlu
This is a [sentence-transformers](https://www.SBERT.net) model: It maps sentences & paragraphs to a 768 dimensional dense vector space and can be used for tasks like clustering or semantic search.
<!--- Describe your model here -->
## Usage (Sentence-Transformers)
Using this model becomes easy when you have [sentence-transformers](https://www.SBERT.net) installed:
```
pip install -U sentence-transformers
```
Then you can use the model like this:
```python
from sentence_transformers import SentenceTransformer
sentences = ["This is an example sentence", "Each sentence is converted"]
model = SentenceTransformer('bespin-global/klue-sentence-roberta-kornlu')
embeddings = model.encode(sentences)
print(embeddings)
```
## Usage (HuggingFace Transformers)
Without [sentence-transformers](https://www.SBERT.net), you can use the model like this: First, you pass your input through the transformer model, then you have to apply the right pooling-operation on-top of the contextualized word embeddings.
```python
from transformers import AutoTokenizer, AutoModel
import torch
#Mean Pooling - Take attention mask into account for correct averaging
def mean_pooling(model_output, attention_mask):
token_embeddings = model_output[0] #First element of model_output contains all token embeddings
input_mask_expanded = attention_mask.unsqueeze(-1).expand(token_embeddings.size()).float()
return torch.sum(token_embeddings * input_mask_expanded, 1) / torch.clamp(input_mask_expanded.sum(1), min=1e-9)
# Sentences we want sentence embeddings for
sentences = ['This is an example sentence', 'Each sentence is converted']
# Load model from HuggingFace Hub
tokenizer = AutoTokenizer.from_pretrained('bespin-global/klue-sentence-roberta-kornlu')
model = AutoModel.from_pretrained('bespin-global/klue-sentence-roberta-kornlu')
# Tokenize sentences
encoded_input = tokenizer(sentences, padding=True, truncation=True, return_tensors='pt')
# Compute token embeddings
with torch.no_grad():
model_output = model(**encoded_input)
# Perform pooling. In this case, mean pooling.
sentence_embeddings = mean_pooling(model_output, encoded_input['attention_mask'])
print("Sentence embeddings:")
print(sentence_embeddings)
```
## Evaluation Results
<!--- Describe how your model was evaluated -->
For an automated evaluation of this model, see the *Sentence Embeddings Benchmark*: [https://seb.sbert.net](https://seb.sbert.net?model_name={MODEL_NAME})
## Training
The model was trained with the parameters:
**DataLoader**:
`torch.utils.data.dataloader.DataLoader` of length 180 with parameters:
```
{'batch_size': 32, 'sampler': 'torch.utils.data.sampler.RandomSampler', 'batch_sampler': 'torch.utils.data.sampler.BatchSampler'}
```
**Loss**:
`sentence_transformers.losses.CosineSimilarityLoss.CosineSimilarityLoss`
Parameters of the fit()-Method:
```
{
"epochs": 4,
"evaluation_steps": 1000,
"evaluator": "sentence_transformers.evaluation.EmbeddingSimilarityEvaluator.EmbeddingSimilarityEvaluator",
"max_grad_norm": 1,
"optimizer_class": "<class 'transformers.optimization.AdamW'>",
"optimizer_params": {
"lr": 2e-05
},
"scheduler": "WarmupLinear",
"steps_per_epoch": null,
"warmup_steps": 72,
"weight_decay": 0.01
}
```
## Full Model Architecture
```
SentenceTransformer(
(0): Transformer({'max_seq_length': 512, 'do_lower_case': False}) with Transformer model: RobertaModel
(1): Pooling({'word_embedding_dimension': 768, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False})
)
```
## Citing & Authors
<!--- Describe where people can find more information -->
[Jaehyeong](https://huggingface.co/jaehyeong) at [Bespin Global](https://www.bespinglobal.com/) | {"license": "cc-by-nc-4.0", "tags": ["sentence-transformers", "feature-extraction", "sentence-similarity", "transformers"], "datasets": ["kor_nlu"], "pipeline_tag": "sentence-similarity"} | bespin-global/klue-sentence-roberta-base-kornlu | null | [
"sentence-transformers",
"pytorch",
"roberta",
"feature-extraction",
"sentence-similarity",
"transformers",
"dataset:kor_nlu",
"license:cc-by-nc-4.0",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
sentence-similarity | sentence-transformers |
# bespin-global/klue-sentence-roberta-base
This is a [sentence-transformers](https://www.SBERT.net) model: It maps sentences & paragraphs to a 768 dimensional dense vector space and can be used for tasks like clustering or semantic search.
<!--- Describe your model here -->
## Usage (Sentence-Transformers)
Using this model becomes easy when you have [sentence-transformers](https://www.SBERT.net) installed:
```
pip install -U sentence-transformers
```
Then you can use the model like this:
```python
from sentence_transformers import SentenceTransformer
sentences = ["This is an example sentence", "Each sentence is converted"]
model = SentenceTransformer('bespin-global/klue-sentence-roberta-base')
embeddings = model.encode(sentences)
print(embeddings)
```
## Usage (HuggingFace Transformers)
Without [sentence-transformers](https://www.SBERT.net), you can use the model like this: First, you pass your input through the transformer model, then you have to apply the right pooling-operation on-top of the contextualized word embeddings.
```python
from transformers import AutoTokenizer, AutoModel
import torch
#Mean Pooling - Take attention mask into account for correct averaging
def mean_pooling(model_output, attention_mask):
token_embeddings = model_output[0] #First element of model_output contains all token embeddings
input_mask_expanded = attention_mask.unsqueeze(-1).expand(token_embeddings.size()).float()
return torch.sum(token_embeddings * input_mask_expanded, 1) / torch.clamp(input_mask_expanded.sum(1), min=1e-9)
# Sentences we want sentence embeddings for
sentences = ['This is an example sentence', 'Each sentence is converted']
# Load model from HuggingFace Hub
tokenizer = AutoTokenizer.from_pretrained('bespin-global/klue-sentence-roberta-base')
model = AutoModel.from_pretrained('bespin-global/klue-sentence-roberta-base')
# Tokenize sentences
encoded_input = tokenizer(sentences, padding=True, truncation=True, return_tensors='pt')
# Compute token embeddings
with torch.no_grad():
model_output = model(**encoded_input)
# Perform pooling. In this case, mean pooling.
sentence_embeddings = mean_pooling(model_output, encoded_input['attention_mask'])
print("Sentence embeddings:")
print(sentence_embeddings)
```
## Evaluation Results
<!--- Describe how your model was evaluated -->
For an automated evaluation of this model, see the *Sentence Embeddings Benchmark*: [https://seb.sbert.net](https://seb.sbert.net?model_name=bespin-global/klue-sentence-roberta-base)
## Training
The model was trained with the parameters:
**DataLoader**:
`torch.utils.data.dataloader.DataLoader` of length 365 with parameters:
```
{'batch_size': 32, 'sampler': 'torch.utils.data.sampler.RandomSampler', 'batch_sampler': 'torch.utils.data.sampler.BatchSampler'}
```
**Loss**:
`sentence_transformers.losses.CosineSimilarityLoss.CosineSimilarityLoss`
Parameters of the fit()-Method:
```
{
"epochs": 6,
"evaluation_steps": 1000,
"evaluator": "sentence_transformers.evaluation.EmbeddingSimilarityEvaluator.EmbeddingSimilarityEvaluator",
"max_grad_norm": 1,
"optimizer_class": "<class 'transformers.optimization.AdamW'>",
"optimizer_params": {
"lr": 2e-05
},
"scheduler": "WarmupLinear",
"steps_per_epoch": null,
"warmup_steps": 219,
"weight_decay": 0.01
}
```
## Full Model Architecture
```
SentenceTransformer(
(0): Transformer({'max_seq_length': 512, 'do_lower_case': False}) with Transformer model: RobertaModel
(1): Pooling({'word_embedding_dimension': 768, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False})
)
```
## Citing & Authors
<!--- Describe where people can find more information -->
[Jaehyeong](https://huggingface.co/jaehyeong) at [Bespin Global](https://www.bespinglobal.com/) | {"license": "cc-by-nc-4.0", "tags": ["sentence-transformers", "feature-extraction", "sentence-similarity", "transformers"], "datasets": ["klue"], "pipeline_tag": "sentence-similarity"} | bespin-global/klue-sentence-roberta-base | null | [
"sentence-transformers",
"pytorch",
"roberta",
"feature-extraction",
"sentence-similarity",
"transformers",
"dataset:klue",
"license:cc-by-nc-4.0",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
text-generation | transformers |
# The Tenth Doctor DialoGPT Model | {"tags": ["conversational"]} | bestminerevah/DialoGPT-small-thetenthdoctor | null | [
"transformers",
"pytorch",
"gpt2",
"text-generation",
"conversational",
"autotrain_compatible",
"endpoints_compatible",
"text-generation-inference",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
text-classification | transformers | {} | bestvater/distilbert-kav-stance | null | [
"transformers",
"pytorch",
"distilbert",
"text-classification",
"autotrain_compatible",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
feature-extraction | transformers | {} | beta13/dummy-bert-base-cased | null | [
"transformers",
"pytorch",
"bert",
"feature-extraction",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
null | null | {} | bettertextapp/bart-translate-en-de | null | [
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
text2text-generation | transformers |
<!-- This model card has been generated automatically according to the information the Trainer had access to. You
should probably proofread and complete it, then remove this comment. -->
# bart_large_paraphrase_generator_en_de_v2
This model was trained from scratch on an unknown dataset.
## Model description
More information needed
## Intended uses & limitations
More information needed
{'eval_loss': 0.9200083613395691, 'eval_score': 49.97448884411352, 'eval_counts': [100712, 72963, 57055, 41578], 'eval_totals': [133837, 130839, 127841, 124843], 'eval_precisions': [75.24974409169363, 55.76548276889918, 44.6296571522438, 33.30423011302196], 'eval_bp': 1.0, 'eval_sys_len': 133837, 'eval_ref_len': 130883, 'eval_runtime': 138.6871, 'eval_samples_per_second': 21.617, 'eval_steps_per_second': 0.678}
More information needed
## Training procedure
### Training hyperparameters
The following hyperparameters were used during training:
- learning_rate: 5e-05
- train_batch_size: 8
- eval_batch_size: 8
- seed: 42
- distributed_type: multi-GPU
- num_devices: 4
- gradient_accumulation_steps: 2
- total_train_batch_size: 64
- total_eval_batch_size: 32
- optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
- lr_scheduler_type: linear
- num_epochs: 3.0
### Framework versions
- Transformers 4.16.2
- Pytorch 1.11.0a0+bfe5ad2
- Datasets 1.18.3
- Tokenizers 0.11.0
| {"tags": ["generated_from_trainer"], "model-index": [{"name": "bart_large_paraphrase_generator_en_de_v2", "results": []}]} | bettertextapp/bart_large_paraphrase_generator_en_de_v2 | null | [
"transformers",
"pytorch",
"tensorboard",
"mbart",
"text2text-generation",
"generated_from_trainer",
"autotrain_compatible",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
text2text-generation | transformers |
<!-- This model card has been generated automatically according to the information the Trainer had access to. You
should probably proofread and complete it, then remove this comment. -->
# bart_large_teaser_de_v2
This model was trained from scratch on an unknown dataset.
## Model description
More information needed
## Intended uses & limitations
More information needed
## Training and evaluation data
{'eval_loss': 0.2028738558292389, 'eval_score': 80.750962016922, 'eval_counts': [342359, 316072, 304925, 294258], 'eval_totals': [376475, 371475, 366475, 361475], 'eval_precisions': [90.93804369480046, 85.08567198330978, 83.20485708438503, 81.40479977868456], 'eval_bp': 0.9490684186878129, 'eval_sys_len': 376475, 'eval_ref_len': 396155, 'eval_runtime': 431.9447, 'eval_samples_per_second': 11.576, 'eval_steps_per_second': 0.363}
## Training procedure
### Training hyperparameters
The following hyperparameters were used during training:
- learning_rate: 5e-05
- train_batch_size: 8
- eval_batch_size: 8
- seed: 42
- distributed_type: multi-GPU
- num_devices: 4
- gradient_accumulation_steps: 2
- total_train_batch_size: 64
- total_eval_batch_size: 32
- optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
- lr_scheduler_type: linear
- num_epochs: 3.0
### Framework versions
- Transformers 4.16.2
- Pytorch 1.11.0a0+bfe5ad2
- Datasets 1.18.3
- Tokenizers 0.11.0
| {"tags": ["generated_from_trainer"], "model-index": [{"name": "bart_large_teaser_de_v2", "results": []}]} | bettertextapp/bart_large_teaser_de_v2 | null | [
"transformers",
"pytorch",
"tensorboard",
"mbart",
"text2text-generation",
"generated_from_trainer",
"autotrain_compatible",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
null | null | {} | bettertextapp/fsmt-base-en-de-seed-words | null | [
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
null | null | {} | bettertextapp/fsmt_base_paraphrase_en_de_v6 | null | [
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
token-classification | transformers | {} | bettertextapp/gpt2-large-detector-de-v1 | null | [
"transformers",
"pytorch",
"tensorboard",
"xlm-roberta",
"token-classification",
"autotrain_compatible",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
text2text-generation | transformers | {} | bettertextapp/m2m-418m-en-de-seed-words-v2 | null | [
"transformers",
"pytorch",
"tensorboard",
"m2m_100",
"text2text-generation",
"autotrain_compatible",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
null | null | {} | bettertextapp/m2m-418m-en-de-seed-words | null | [
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
text2text-generation | transformers | {} | bettertextapp/m2m_1.2B_paraphrase_en_de_v1 | null | [
"transformers",
"pytorch",
"tensorboard",
"m2m_100",
"text2text-generation",
"autotrain_compatible",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
null | null | {} | bettertextapp/tmp | null | [
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
null | null | {} | bettertextapp/xlm-roberta-large-detector-de-v1 | null | [
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
null | null | {} | bewarren/model_name | null | [
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
text-classification | transformers |
## bart-large-mnli
Trained by Facebook, [original source](https://github.com/pytorch/fairseq/tree/master/examples/bart)
| {"widget": [{"text": "I like you. </s></s> I love you."}]} | bewgle/bart-large-mnli-bewgle | null | [
"transformers",
"pytorch",
"bart",
"text-classification",
"autotrain_compatible",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
token-classification | transformers | {} | beyhan/bert-base-turkish-ner-cased-pretrained | null | [
"transformers",
"pytorch",
"jax",
"bert",
"token-classification",
"autotrain_compatible",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
token-classification | transformers | {} | beyhan/checkpoint-3750 | null | [
"transformers",
"pytorch",
"jax",
"bert",
"token-classification",
"autotrain_compatible",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
|
question-answering | null |
# Performance
This ensemble was evaluated on [SQuAD 2.0](https://huggingface.co/datasets/squad_v2) with the following results:
```
{'HasAns_exact': 52.5472334682861,
'HasAns_f1': 67.94939813758602,
'HasAns_total': 5928,
'NoAns_exact': 91.75777964676199,
'NoAns_f1': 91.75777964676199,
'NoAns_total': 5945,
'best_exact': 72.16373283921503,
'best_exact_thresh': 0.0,
'best_f1': 79.85378860941708,
'best_f1_thresh': 0.0,
'exact': 72.1805777815211,
'f1': 79.87063355172326,
'total': 11873
}
``` | {"language": "en", "license": "cc-by-4.0", "tags": ["pytorch", "question-answering"], "datasets": ["squad_v2", "squad2"], "metrics": ["squad_v2", "exact", "f1"], "widget": [{"text": "By what main attribute are computational problems classified utilizing computational complexity theory?", "context": "Computational complexity theory is a branch of the theory of computation in theoretical computer science that focuses on classifying computational problems according to their inherent difficulty, and relating those classes to each other. A computational problem is understood to be a task that is in principle amenable to being solved by a computer, which is equivalent to stating that the problem may be solved by mechanical application of mathematical steps, such as an algorithm."}]} | bgfruna/double-bart-ensemble-squad2 | null | [
"pytorch",
"question-answering",
"en",
"dataset:squad_v2",
"dataset:squad2",
"license:cc-by-4.0",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
text-classification | transformers |
# Model Trained Using AutoNLP
- Problem type: Multi-class Classification
- Model ID: 28716412
- CO2 Emissions (in grams): 27.22397099134103
## Validation Metrics
- Loss: 0.4146720767021179
- Accuracy: 0.8066924731182795
- Macro F1: 0.7835463282531184
- Micro F1: 0.8066924731182795
- Weighted F1: 0.7974252447208724
- Macro Precision: 0.8183917344767431
- Micro Precision: 0.8066924731182795
- Weighted Precision: 0.8005510296861892
- Macro Recall: 0.7679676081852519
- Micro Recall: 0.8066924731182795
- Weighted Recall: 0.8066924731182795
## Usage
You can use cURL to access this model:
```
$ curl -X POST -H "Authorization: Bearer YOUR_API_KEY" -H "Content-Type: application/json" -d '{"inputs": "I love AutoNLP"}' https://api-inference.huggingface.co/models/bgoel4132/autonlp-tweet-disaster-classifier-28716412
```
Or Python API:
```
from transformers import AutoModelForSequenceClassification, AutoTokenizer
model = AutoModelForSequenceClassification.from_pretrained("bgoel4132/autonlp-tweet-disaster-classifier-28716412", use_auth_token=True)
tokenizer = AutoTokenizer.from_pretrained("bgoel4132/autonlp-tweet-disaster-classifier-28716412", use_auth_token=True)
inputs = tokenizer("I love AutoNLP", return_tensors="pt")
outputs = model(**inputs)
``` | {"language": "en", "tags": "autonlp", "datasets": ["bgoel4132/autonlp-data-tweet-disaster-classifier"], "widget": [{"text": "I love AutoNLP \ud83e\udd17"}], "co2_eq_emissions": 27.22397099134103} | bgoel4132/tweet-disaster-classifier | null | [
"transformers",
"pytorch",
"safetensors",
"distilbert",
"text-classification",
"autonlp",
"en",
"dataset:bgoel4132/autonlp-data-tweet-disaster-classifier",
"co2_eq_emissions",
"autotrain_compatible",
"endpoints_compatible",
"region:us"
]
| null | 2022-03-02T23:29:05+00:00 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.