alexcombessie commited on
Commit
a7148f9
1 Parent(s): 541306f

copy of original repo

Browse files
Files changed (7) hide show
  1. .gitattributes +5 -24
  2. README.md +117 -0
  3. config.json +22 -0
  4. pytorch_model.bin +3 -0
  5. sentencepiece.bpe.model +0 -0
  6. tf_model.h5 +3 -0
  7. tokenizer.json +0 -0
.gitattributes CHANGED
@@ -1,27 +1,8 @@
1
- *.7z filter=lfs diff=lfs merge=lfs -text
2
- *.arrow filter=lfs diff=lfs merge=lfs -text
3
- *.bin filter=lfs diff=lfs merge=lfs -text
4
  *.bin.* filter=lfs diff=lfs merge=lfs -text
5
- *.bz2 filter=lfs diff=lfs merge=lfs -text
6
- *.ftz filter=lfs diff=lfs merge=lfs -text
7
- *.gz filter=lfs diff=lfs merge=lfs -text
8
- *.h5 filter=lfs diff=lfs merge=lfs -text
9
- *.joblib filter=lfs diff=lfs merge=lfs -text
10
  *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
- *.model filter=lfs diff=lfs merge=lfs -text
12
- *.msgpack filter=lfs diff=lfs merge=lfs -text
13
- *.onnx filter=lfs diff=lfs merge=lfs -text
14
- *.ot filter=lfs diff=lfs merge=lfs -text
15
- *.parquet filter=lfs diff=lfs merge=lfs -text
16
- *.pb filter=lfs diff=lfs merge=lfs -text
17
- *.pt filter=lfs diff=lfs merge=lfs -text
18
- *.pth filter=lfs diff=lfs merge=lfs -text
19
- *.rar filter=lfs diff=lfs merge=lfs -text
20
- saved_model/**/* filter=lfs diff=lfs merge=lfs -text
21
- *.tar.* filter=lfs diff=lfs merge=lfs -text
22
  *.tflite filter=lfs diff=lfs merge=lfs -text
23
- *.tgz filter=lfs diff=lfs merge=lfs -text
24
- *.xz filter=lfs diff=lfs merge=lfs -text
25
- *.zip filter=lfs diff=lfs merge=lfs -text
26
- *.zstandard filter=lfs diff=lfs merge=lfs -text
27
- *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
1
  *.bin.* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
2
  *.lfs.* filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.h5 filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
5
  *.tflite filter=lfs diff=lfs merge=lfs -text
6
+ *.tar.gz filter=lfs diff=lfs merge=lfs -text
7
+ *.ot filter=lfs diff=lfs merge=lfs -text
8
+ *.onnx filter=lfs diff=lfs merge=lfs -text
 
 
README.md ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: fr
3
+ license: mit
4
+ datasets:
5
+ - oscar
6
+ ---
7
+
8
+ # CamemBERT: a Tasty French Language Model
9
+
10
+ **This model is a copy of [this model repository](https://huggingface.co/camembert-base) at the specific commit `482393b6198924f9da270b1aaf37d238aafca99b`.**
11
+
12
+ ## Introduction
13
+
14
+ [CamemBERT](https://arxiv.org/abs/1911.03894) is a state-of-the-art language model for French based on the RoBERTa model.
15
+
16
+ It is now available on Hugging Face in 6 different versions with varying number of parameters, amount of pretraining data and pretraining data source domains.
17
+
18
+ For further information or requests, please go to [Camembert Website](https://camembert-model.fr/)
19
+
20
+ ## Pre-trained models
21
+
22
+ | Model | #params | Arch. | Training data |
23
+ |--------------------------------|--------------------------------|-------|-----------------------------------|
24
+ | `camembert-base` | 110M | Base | OSCAR (138 GB of text) |
25
+ | `camembert/camembert-large` | 335M | Large | CCNet (135 GB of text) |
26
+ | `camembert/camembert-base-ccnet` | 110M | Base | CCNet (135 GB of text) |
27
+ | `camembert/camembert-base-wikipedia-4gb` | 110M | Base | Wikipedia (4 GB of text) |
28
+ | `camembert/camembert-base-oscar-4gb` | 110M | Base | Subsample of OSCAR (4 GB of text) |
29
+ | `camembert/camembert-base-ccnet-4gb` | 110M | Base | Subsample of CCNet (4 GB of text) |
30
+
31
+ ## How to use CamemBERT with HuggingFace
32
+
33
+ ##### Load CamemBERT and its sub-word tokenizer :
34
+ ```python
35
+ from transformers import CamembertModel, CamembertTokenizer
36
+
37
+ # You can replace "camembert-base" with any other model from the table, e.g. "camembert/camembert-large".
38
+ tokenizer = CamembertTokenizer.from_pretrained("camembert-base")
39
+ camembert = CamembertModel.from_pretrained("camembert-base")
40
+
41
+ camembert.eval() # disable dropout (or leave in train mode to finetune)
42
+
43
+ ```
44
+
45
+ ##### Filling masks using pipeline
46
+ ```python
47
+ from transformers import pipeline
48
+
49
+ camembert_fill_mask = pipeline("fill-mask", model="camembert-base", tokenizer="camembert-base")
50
+ results = camembert_fill_mask("Le camembert est <mask> :)")
51
+ # results
52
+ #[{'sequence': '<s> Le camembert est délicieux :)</s>', 'score': 0.4909103214740753, 'token': 7200},
53
+ # {'sequence': '<s> Le camembert est excellent :)</s>', 'score': 0.10556930303573608, 'token': 2183},
54
+ # {'sequence': '<s> Le camembert est succulent :)</s>', 'score': 0.03453315049409866, 'token': 26202},
55
+ # {'sequence': '<s> Le camembert est meilleur :)</s>', 'score': 0.03303130343556404, 'token': 528},
56
+ # {'sequence': '<s> Le camembert est parfait :)</s>', 'score': 0.030076518654823303, 'token': 1654}]
57
+
58
+ ```
59
+
60
+ ##### Extract contextual embedding features from Camembert output
61
+ ```python
62
+ import torch
63
+ # Tokenize in sub-words with SentencePiece
64
+ tokenized_sentence = tokenizer.tokenize("J'aime le camembert !")
65
+ # ['▁J', "'", 'aime', '▁le', '▁ca', 'member', 't', '▁!']
66
+
67
+ # 1-hot encode and add special starting and end tokens
68
+ encoded_sentence = tokenizer.encode(tokenized_sentence)
69
+ # [5, 121, 11, 660, 16, 730, 25543, 110, 83, 6]
70
+ # NB: Can be done in one step : tokenize.encode("J'aime le camembert !")
71
+
72
+ # Feed tokens to Camembert as a torch tensor (batch dim 1)
73
+ encoded_sentence = torch.tensor(encoded_sentence).unsqueeze(0)
74
+ embeddings, _ = camembert(encoded_sentence)
75
+ # embeddings.detach()
76
+ # embeddings.size torch.Size([1, 10, 768])
77
+ # tensor([[[-0.0254, 0.0235, 0.1027, ..., -0.1459, -0.0205, -0.0116],
78
+ # [ 0.0606, -0.1811, -0.0418, ..., -0.1815, 0.0880, -0.0766],
79
+ # [-0.1561, -0.1127, 0.2687, ..., -0.0648, 0.0249, 0.0446],
80
+ # ...,
81
+ ```
82
+
83
+ ##### Extract contextual embedding features from all Camembert layers
84
+ ```python
85
+ from transformers import CamembertConfig
86
+ # (Need to reload the model with new config)
87
+ config = CamembertConfig.from_pretrained("camembert-base", output_hidden_states=True)
88
+ camembert = CamembertModel.from_pretrained("camembert-base", config=config)
89
+
90
+ embeddings, _, all_layer_embeddings = camembert(encoded_sentence)
91
+ # all_layer_embeddings list of len(all_layer_embeddings) == 13 (input embedding layer + 12 self attention layers)
92
+ all_layer_embeddings[5]
93
+ # layer 5 contextual embedding : size torch.Size([1, 10, 768])
94
+ #tensor([[[-0.0032, 0.0075, 0.0040, ..., -0.0025, -0.0178, -0.0210],
95
+ # [-0.0996, -0.1474, 0.1057, ..., -0.0278, 0.1690, -0.2982],
96
+ # [ 0.0557, -0.0588, 0.0547, ..., -0.0726, -0.0867, 0.0699],
97
+ # ...,
98
+ ```
99
+
100
+
101
+ ## Authors
102
+
103
+ CamemBERT was trained and evaluated by Louis Martin\*, Benjamin Muller\*, Pedro Javier Ortiz Suárez\*, Yoann Dupont, Laurent Romary, Éric Villemonte de la Clergerie, Djamé Seddah and Benoît Sagot.
104
+
105
+
106
+ ## Citation
107
+ If you use our work, please cite:
108
+
109
+ ```bibtex
110
+ @inproceedings{martin2020camembert,
111
+ title={CamemBERT: a Tasty French Language Model},
112
+ author={Martin, Louis and Muller, Benjamin and Su{\'a}rez, Pedro Javier Ortiz and Dupont, Yoann and Romary, Laurent and de la Clergerie, {\'E}ric Villemonte and Seddah, Djam{\'e} and Sagot, Beno{\^\i}t},
113
+ booktitle={Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics},
114
+ year={2020}
115
+ }
116
+ ```
117
+
config.json ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "CamembertForMaskedLM"
4
+ ],
5
+ "attention_probs_dropout_prob": 0.1,
6
+ "bos_token_id": 5,
7
+ "eos_token_id": 6,
8
+ "hidden_act": "gelu",
9
+ "hidden_dropout_prob": 0.1,
10
+ "hidden_size": 768,
11
+ "initializer_range": 0.02,
12
+ "intermediate_size": 3072,
13
+ "layer_norm_eps": 1e-05,
14
+ "max_position_embeddings": 514,
15
+ "model_type": "camembert",
16
+ "num_attention_heads": 12,
17
+ "num_hidden_layers": 12,
18
+ "output_past": true,
19
+ "pad_token_id": 1,
20
+ "type_vocab_size": 1,
21
+ "vocab_size": 32005
22
+ }
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:54ca0c5f4daf6885f7b07df460624de6120fe5cf964f9b082a4874be6249f5f5
3
+ size 445032417
sentencepiece.bpe.model ADDED
Binary file (811 kB). View file
 
tf_model.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1a7be48987fe8c135cb985e9b0f07cc5c14d3b1b934b7fd16f4844a3b3e884a9
3
+ size 542808764
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff