Inc44 commited on
Commit
9392010
1 Parent(s): 171d86b

Training in progress, step 100

Browse files
README.md CHANGED
@@ -13,7 +13,12 @@ should probably proofread and complete it, then remove this comment. -->
13
 
14
  This model is a fine-tuned version of [](https://huggingface.co/) on an unknown dataset.
15
  It achieves the following results on the evaluation set:
16
- - Loss: 3.8396
 
 
 
 
 
17
 
18
  ## Model description
19
 
@@ -32,44 +37,17 @@ More information needed
32
  ### Training hyperparameters
33
 
34
  The following hyperparameters were used during training:
35
- - learning_rate: 0.00024
36
- - train_batch_size: 96
37
- - eval_batch_size: 96
38
  - seed: 42
39
  - optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
40
  - lr_scheduler_type: polynomial
41
- - lr_scheduler_warmup_steps: 5000
42
- - num_epochs: 1
43
-
44
- ### Training results
45
-
46
- | Training Loss | Epoch | Step | Validation Loss |
47
- |:-------------:|:-----:|:-----:|:---------------:|
48
- | 6.9048 | 0.05 | 2000 | 4.7602 |
49
- | 4.4421 | 0.1 | 4000 | 4.2117 |
50
- | 4.0625 | 0.15 | 6000 | 3.9227 |
51
- | 3.807 | 0.2 | 8000 | 3.7181 |
52
- | 3.6547 | 0.25 | 10000 | 3.5929 |
53
- | 3.5296 | 0.29 | 12000 | 3.4812 |
54
- | 3.4492 | 0.34 | 14000 | 3.4236 |
55
- | 3.4065 | 0.39 | 16000 | 3.3923 |
56
- | 3.3816 | 0.44 | 18000 | 3.3778 |
57
- | 3.3815 | 0.49 | 20000 | 3.3907 |
58
- | 3.431 | 0.54 | 22000 | 3.4870 |
59
- | 3.5507 | 0.59 | 24000 | 3.5969 |
60
- | 3.6557 | 0.64 | 26000 | 3.6918 |
61
- | 3.715 | 0.69 | 28000 | 3.7377 |
62
- | 3.7646 | 0.74 | 30000 | 3.7620 |
63
- | 3.8005 | 0.79 | 32000 | 3.8221 |
64
- | 3.8288 | 0.83 | 34000 | 3.8550 |
65
- | 3.8552 | 0.88 | 36000 | 3.8449 |
66
- | 3.8591 | 0.93 | 38000 | 3.8483 |
67
- | 3.8452 | 0.98 | 40000 | 3.8396 |
68
-
69
 
70
  ### Framework versions
71
 
72
- - Transformers 4.38.2
73
  - Pytorch 2.2.1+cu121
74
  - Datasets 2.18.0
75
  - Tokenizers 0.15.2
 
13
 
14
  This model is a fine-tuned version of [](https://huggingface.co/) on an unknown dataset.
15
  It achieves the following results on the evaluation set:
16
+ - eval_loss: 14.1081
17
+ - eval_runtime: 0.0886
18
+ - eval_samples_per_second: 237.106
19
+ - eval_steps_per_second: 11.291
20
+ - epoch: 50.0
21
+ - step: 400
22
 
23
  ## Model description
24
 
 
37
  ### Training hyperparameters
38
 
39
  The following hyperparameters were used during training:
40
+ - learning_rate: 0.001
41
+ - train_batch_size: 32
42
+ - eval_batch_size: 32
43
  - seed: 42
44
  - optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
45
  - lr_scheduler_type: polynomial
46
+ - num_epochs: 100
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
 
48
  ### Framework versions
49
 
50
+ - Transformers 4.39.1
51
  - Pytorch 2.2.1+cu121
52
  - Datasets 2.18.0
53
  - Tokenizers 0.15.2
generation_config.json CHANGED
@@ -2,5 +2,5 @@
2
  "_from_model_config": true,
3
  "bos_token_id": 1,
4
  "eos_token_id": 2,
5
- "transformers_version": "4.38.2"
6
  }
 
2
  "_from_model_config": true,
3
  "bos_token_id": 1,
4
  "eos_token_id": 2,
5
+ "transformers_version": "4.39.1"
6
  }
model.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:f2993fec007900dcd9d7c675dc75369a67f5269c908bfef209667ce5be0910d4
3
  size 510960712
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:55c1433d65751299063935edf3737aecb3b4f6176af451137f1c51308b56c0aa
3
  size 510960712
modeling_bit_llama.py CHANGED
@@ -1,4 +1,5 @@
1
- from typing import Optional
 
2
  from transformers.models.llama.modeling_llama import (
3
  LlamaConfig,
4
  LlamaModel,
@@ -10,6 +11,7 @@ from transformers.models.llama.modeling_llama import (
10
  LlamaDecoderLayer,
11
  )
12
  from mybitnet.bitnet import BitLinear
 
13
  from torch import nn
14
 
15
  class BitLlamaConfig(LlamaConfig):
@@ -22,9 +24,9 @@ class BitLlamaConfig(LlamaConfig):
22
  class BitLlamaMLP(LlamaMLP):
23
  def __init__(self, config):
24
  super().__init__(config)
25
- self.gate_proj = BitLinear(self.hidden_size, self.intermediate_size, bias=False, bits=config.bits, flg_before_linear=True)
26
  self.up_proj = BitLinear(self.hidden_size, self.intermediate_size, bias=False, bits=config.bits, flg_before_linear=True)
27
- self.down_proj = BitLinear(self.intermediate_size, self.hidden_size, bias=False, bits=config.bits, flg_before_linear=False)
28
 
29
  class BitLlamaAttention(LlamaAttention):
30
  def __init__(self, config: BitLlamaConfig, layer_idx: Optional[int] = None):
@@ -61,8 +63,61 @@ class BitLlamaDecoderLayer(LlamaDecoderLayer):
61
  super().__init__(config, layer_idx)
62
  self.self_attn = BITLLAMA_ATTENTION_CLASSES[config._attn_implementation](config=config, layer_idx=layer_idx)
63
  self.mlp = BitLlamaMLP(config)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
 
65
  class BitLlamaModel(LlamaModel):
 
 
66
  def __init__(self, config: BitLlamaConfig):
67
  super().__init__(config)
68
  self.layers = nn.ModuleList(
 
1
+ import warnings
2
+ from typing import Optional, Tuple
3
  from transformers.models.llama.modeling_llama import (
4
  LlamaConfig,
5
  LlamaModel,
 
11
  LlamaDecoderLayer,
12
  )
13
  from mybitnet.bitnet import BitLinear
14
+ import torch
15
  from torch import nn
16
 
17
  class BitLlamaConfig(LlamaConfig):
 
24
  class BitLlamaMLP(LlamaMLP):
25
  def __init__(self, config):
26
  super().__init__(config)
27
+ self.gate_proj = BitLinear(self.hidden_size, self.intermediate_size, bias=False, bits=config.bits, flg_before_linear=False)
28
  self.up_proj = BitLinear(self.hidden_size, self.intermediate_size, bias=False, bits=config.bits, flg_before_linear=True)
29
+ self.down_proj = BitLinear(self.intermediate_size, self.hidden_size, bias=False, bits=config.bits, flg_before_linear=True)
30
 
31
  class BitLlamaAttention(LlamaAttention):
32
  def __init__(self, config: BitLlamaConfig, layer_idx: Optional[int] = None):
 
63
  super().__init__(config, layer_idx)
64
  self.self_attn = BITLLAMA_ATTENTION_CLASSES[config._attn_implementation](config=config, layer_idx=layer_idx)
65
  self.mlp = BitLlamaMLP(config)
66
+ del self.input_layernorm
67
+ del self.post_attention_layernorm
68
+
69
+ def forward(
70
+ self,
71
+ hidden_states: torch.Tensor,
72
+ attention_mask: Optional[torch.Tensor] = None,
73
+ position_ids: Optional[torch.LongTensor] = None,
74
+ past_key_value: Optional[Tuple[torch.Tensor]] = None,
75
+ output_attentions: Optional[bool] = False,
76
+ use_cache: Optional[bool] = False,
77
+ cache_position: Optional[torch.LongTensor] = None,
78
+ **kwargs,
79
+ ) -> Tuple[torch.FloatTensor, Optional[Tuple[torch.FloatTensor, torch.FloatTensor]]]:
80
+ """
81
+ refers: https://github.com/huggingface/transformers/blob/c5f0288bc7d76f65996586f79f69fba8867a0e67/src/transformers/models/llama/modeling_llama.py#L693
82
+ """
83
+ if "padding_mask" in kwargs:
84
+ warnings.warn(
85
+ "Passing `padding_mask` is deprecated and will be removed in v4.37. Please make sure use `attention_mask` instead.`"
86
+ )
87
+
88
+ residual = hidden_states
89
+
90
+ # Self Attention
91
+ hidden_states, self_attn_weights, present_key_value = self.self_attn(
92
+ hidden_states=hidden_states,
93
+ attention_mask=attention_mask,
94
+ position_ids=position_ids,
95
+ past_key_value=past_key_value,
96
+ output_attentions=output_attentions,
97
+ use_cache=use_cache,
98
+ cache_position=cache_position,
99
+ **kwargs,
100
+ )
101
+ hidden_states = residual + hidden_states
102
+
103
+ # Fully Connected
104
+ residual = hidden_states
105
+ hidden_states = self.mlp(hidden_states)
106
+ hidden_states = residual + hidden_states
107
+
108
+ outputs = (hidden_states,)
109
+
110
+ if output_attentions:
111
+ outputs += (self_attn_weights,)
112
+
113
+ if use_cache:
114
+ outputs += (present_key_value,)
115
+
116
+ return outputs
117
 
118
  class BitLlamaModel(LlamaModel):
119
+ config_class = BitLlamaConfig
120
+
121
  def __init__(self, config: BitLlamaConfig):
122
  super().__init__(config)
123
  self.layers = nn.ModuleList(
training_args.bin CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:374bbfaab702b8ea66e7026aa109e4f27c10eb644bac7ca5847e09d38b90158b
3
  size 4920
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f68b6d8610db40c9080edd428332a28b58687a273c0815ea5842db873611ca2a
3
  size 4920