YsnHdn commited on
Commit
3782af5
1 Parent(s): fe353fa

Refactor : Using DistilBert instead of Bert

Browse files
Dockerfile CHANGED
@@ -18,7 +18,7 @@ ENV HF_HOME /code/.cache/huggingface
18
  RUN mkdir -p $HF_HOME && chmod -R 777 $HF_HOME
19
 
20
  # Copy the model files into the image
21
- COPY ./bert /code/bert
22
 
23
  # Copy the rest of the application files
24
  COPY . .
 
18
  RUN mkdir -p $HF_HOME && chmod -R 777 $HF_HOME
19
 
20
  # Copy the model files into the image
21
+ COPY ./distilBert /code/distilBert
22
 
23
  # Copy the rest of the application files
24
  COPY . .
distilBert/DistilBert/label_encoder.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c74d910ccc2fd1e1627c256f2dfb626216eb2c19ff55fc4d910479c6fba064d1
3
+ size 227
distilBert/DistilBert/saved_model/config.json ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "distilbert-base-uncased",
3
+ "activation": "gelu",
4
+ "architectures": [
5
+ "DistilBertForSequenceClassification"
6
+ ],
7
+ "attention_dropout": 0.1,
8
+ "dim": 768,
9
+ "dropout": 0.1,
10
+ "hidden_dim": 3072,
11
+ "id2label": {
12
+ "0": "LABEL_0",
13
+ "1": "LABEL_1",
14
+ "2": "LABEL_2",
15
+ "3": "LABEL_3",
16
+ "4": "LABEL_4",
17
+ "5": "LABEL_5",
18
+ "6": "LABEL_6",
19
+ "7": "LABEL_7",
20
+ "8": "LABEL_8",
21
+ "9": "LABEL_9"
22
+ },
23
+ "initializer_range": 0.02,
24
+ "label2id": {
25
+ "LABEL_0": 0,
26
+ "LABEL_1": 1,
27
+ "LABEL_2": 2,
28
+ "LABEL_3": 3,
29
+ "LABEL_4": 4,
30
+ "LABEL_5": 5,
31
+ "LABEL_6": 6,
32
+ "LABEL_7": 7,
33
+ "LABEL_8": 8,
34
+ "LABEL_9": 9
35
+ },
36
+ "max_position_embeddings": 512,
37
+ "model_type": "distilbert",
38
+ "n_heads": 12,
39
+ "n_layers": 6,
40
+ "pad_token_id": 0,
41
+ "problem_type": "single_label_classification",
42
+ "qa_dropout": 0.1,
43
+ "seq_classif_dropout": 0.2,
44
+ "sinusoidal_pos_embds": false,
45
+ "tie_weights_": true,
46
+ "torch_dtype": "float32",
47
+ "transformers_version": "4.41.0",
48
+ "vocab_size": 30522
49
+ }
distilBert/DistilBert/saved_model/model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:68e27085fbfc0a8bb88ee9cc1dff8c6341938ea3e13c0e8bc93e94787e523dae
3
+ size 267857176
distilBert/DistilBert/saved_tokenizer/special_tokens_map.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "cls_token": "[CLS]",
3
+ "mask_token": "[MASK]",
4
+ "pad_token": "[PAD]",
5
+ "sep_token": "[SEP]",
6
+ "unk_token": "[UNK]"
7
+ }
distilBert/DistilBert/saved_tokenizer/tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
distilBert/DistilBert/saved_tokenizer/tokenizer_config.json ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "added_tokens_decoder": {
3
+ "0": {
4
+ "content": "[PAD]",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false,
9
+ "special": true
10
+ },
11
+ "100": {
12
+ "content": "[UNK]",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "101": {
20
+ "content": "[CLS]",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "102": {
28
+ "content": "[SEP]",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "103": {
36
+ "content": "[MASK]",
37
+ "lstrip": false,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ }
43
+ },
44
+ "clean_up_tokenization_spaces": true,
45
+ "cls_token": "[CLS]",
46
+ "do_lower_case": true,
47
+ "mask_token": "[MASK]",
48
+ "model_max_length": 512,
49
+ "pad_token": "[PAD]",
50
+ "sep_token": "[SEP]",
51
+ "strip_accents": null,
52
+ "tokenize_chinese_chars": true,
53
+ "tokenizer_class": "DistilBertTokenizer",
54
+ "unk_token": "[UNK]"
55
+ }
distilBert/DistilBert/saved_tokenizer/vocab.txt ADDED
The diff for this file is too large to render. See raw diff
 
helper_functions.py CHANGED
@@ -6,13 +6,13 @@ from typing import Optional
6
  from torch import Tensor
7
 
8
  # Load the model
9
- model = BertForSequenceClassification.from_pretrained("bert/bertModel/saved_model")
10
 
11
  # Load the tokenizer
12
- tokenizer = BertTokenizer.from_pretrained("bert/bertModel/saved_tokenizer")
13
 
14
  # Charger le label encoder
15
- with open("bert/bertModel/label_encoder.pkl", "rb") as f:
16
  label_encoder = pickle.load(f)
17
 
18
  class_labels = {
 
6
  from torch import Tensor
7
 
8
  # Load the model
9
+ model = BertForSequenceClassification.from_pretrained("distilBert/DistilBert/saved_model")
10
 
11
  # Load the tokenizer
12
+ tokenizer = BertTokenizer.from_pretrained("distilBert/DistilBert/saved_tokenizer")
13
 
14
  # Charger le label encoder
15
+ with open("distilBert/DistilBert/label_encoder.pkl", "rb") as f:
16
  label_encoder = pickle.load(f)
17
 
18
  class_labels = {