Downloads · 30 days
120
6% of all-time downloads
cservan/french-albert-base-cased
french-albert-base-cased is a fill-mask model from cservan. Use it when you need the model to fill a missing word. It is set up for transformers. The card lists the license as apache-2.0.
Pretrained model on French language using a masked language modeling (MLM) objective. More details about the model here. This model, unlike other ALBERT models, is cased: it does make a difference between french and F…
Downloads · 30 days
120
6% of all-time downloads
All-time downloads
2.1K
Public
Repo size
65.4 MB
Likes
0
Public
Click a slice to open those files.
.bin64.7 MB · 98%
From the Hugging Face model README
Pretrained model on French language using a masked language modeling (MLM) objective. More details about the model here. This model, unlike other ALBERT models, is cased: it does make a difference between french and French.
FrALBERT is a transformers model pretrained on 16Go of French Wikipedia 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:
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 FrALBERT model as inputs.
FrALBERT is particular in that it shares its layers across its Transformer. Therefore, all layers have the same weights. Using repeating layers results in a small memory footprint, however, the computational cost remains similar to a BERT-like architecture with the same number of hidden layers as it has to iterate through the same number of (repeating) layers.
This is the second version of the base model.
This model has the following configuration:
You can use the raw model for either masked language modeling or next sentence prediction, but it's mostly intended to be fine-tuned on a downstream task. See the model hub to look for fine-tuned versions on a task that interests you.
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.
You can use this model directly with a pipeline for masked language modeling:
>>> from transformers import pipeline
>>> unmasker = pipeline('fill-mask', model='cservan/french-albert-base-cased')
>>> unmasker("Paris est la capitale de la [MASK] .")
[
{
"sequence": "paris est la capitale de la france.",
"score": 0.6231236457824707,
"token": 3043,
"token_str": "france"
},
{
"sequence": "paris est la capitale de la region.",
"score": 0.2993471622467041,
"token": 10531,
"token_str": "region"
},
{
"sequence": "paris est la capitale de la societe.",
"score": 0.02028230018913746,
"token": 24622,
"token_str": "societe"
},
{
"sequence": "paris est la capitale de la bretagne.",
"score": 0.012089950032532215,
"token": 24987,
"token_str": "bretagne"
},
{
"sequence": "paris est la capitale de la chine.",
"score": 0.010002839379012585,
"token": 14860,
"token_str": "chine"
}
]
Here is how to use this model to get the features of a given text in PyTorch:
from transformers import AlbertTokenizer, AlbertModel
tokenizer = AlbertTokenizer.from_pretrained('cservan/french-albert-base-cased')
model = AlbertModel.from_pretrained("cservan/french-albert-base-cased")
text = "Remplacez-moi par le texte en français que vous souhaitez."
encoded_input = tokenizer(text, return_tensors='pt')
output = model(**encoded_input)
and in TensorFlow:
from transformers import AlbertTokenizer, TFAlbertModel
tokenizer = AlbertTokenizer.from_pretrained('cservan/french-albert-base-cased')
model = TFAlbertModel.from_pretrained("cservan/french-albert-base-cased")
text = "Remplacez-moi par le texte en français que vous souhaitez."
encoded_input = tokenizer(text, return_tensors='tf')
output = model(encoded_input)
The FrALBERT model was pretrained on 4go of French Wikipedia (excluding lists, tables and headers).
The texts are lowercased and tokenized using SentencePiece and a vocabulary size of 32,000. The inputs of the model are then of the form:
[CLS] Sentence A [SEP] Sentence B [SEP]
The FrALBERT procedure follows the BERT setup.
The details of the masking procedure for each sentence are the following:
[MASK].When fine-tuned on downstream tasks, the ALBERT models achieve the following results:
Slot-filling:
| FrALBERT-base | FrALBERT-base-cased | |
|---|---|---|
| MEDIA | 81.76 (0.59) | 85.09 (0.14) |
@inproceedings{cattan2021fralbert,
author = {Oralie Cattan and
Christophe Servan and
Sophie Rosset},
booktitle = {Recent Advances in Natural Language Processing, RANLP 2021},
title = {{On the Usability of Transformers-based models for a French Question-Answering task}},
year = {2021},
address = {Online},
month = sep,
}
Link to the paper: PDF