sino commited on
Commit
68c85ec
1 Parent(s): a62a2b1

Upload configuration_maelm.py

Browse files
Files changed (1) hide show
  1. configuration_maelm.py +131 -0
configuration_maelm.py ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2023 the Falcon authors and HuggingFace Inc. team. All rights reserved.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ """ Falcon configuration"""
16
+ from transformers.configuration_utils import PretrainedConfig
17
+ from transformers.utils import logging
18
+ from transformers import AutoConfig
19
+
20
+ logger = logging.get_logger(__name__)
21
+
22
+
23
+ class MAELMConfig(PretrainedConfig):
24
+ """
25
+ This is the configuration class to store the configuration of a [`FalconModel`]. It is used to instantiate a Falcon
26
+ model according to the specified arguments, defining the model architecture. Instantiating a configuration with the
27
+ defaults will yield a similar configuration to that of the
28
+ [tiiuae/falcon-7b](https://huggingface.co/tiiuae/falcon-7b) architecture.
29
+
30
+ Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
31
+ documentation from [`PretrainedConfig`] for more information.
32
+
33
+
34
+ Args:
35
+ vocab_size (`int`, *optional*, defaults to 65024):
36
+ Vocabulary size of the Falcon model. Defines the number of different tokens that can be represented by the
37
+ `inputs_ids` passed when calling [`FalconModel`]
38
+ hidden_size (`int`, *optional*, defaults to 4544):
39
+ Dimension of the hidden representations.
40
+ num_hidden_layers (`int`, *optional*, defaults to 32):
41
+ Number of hidden layers in the Transformer decoder.
42
+ num_attention_heads (`int`, *optional*, defaults to 71):
43
+ Number of attention heads for each attention layer in the Transformer encoder.
44
+ layer_norm_epsilon (`float`, *optional*, defaults to 1e-05):
45
+ The epsilon used by the layer normalization layers.
46
+ initializer_range (`float`, *optional*, defaults to 0.02):
47
+ The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
48
+ use_cache (`bool`, *optional*, defaults to `True`):
49
+ Whether the model should return the last key/values attentions (not used by all models). Only relevant if
50
+ `config.is_decoder=True`.
51
+ hidden_dropout (`float`, *optional*, defaults to 0.0):
52
+ The dropout probability for MLP layers.
53
+ attention_dropout (`float`, *optional*, defaults to 0.0):
54
+ The dropout probability for attention layers.
55
+ num_kv_heads (`int`, *optional*):
56
+ Number of key-value heads to use per attention layer. If unset, defaults to the same value as
57
+ `num_attention_heads`.
58
+ alibi (`bool`, *optional*, defaults to `False`):
59
+ Whether to use ALiBi positional biases during self-attention.
60
+ new_decoder_architecture (`bool`, *optional*, defaults to `False`):
61
+ Whether to use the new (Falcon-40B) decoder architecture. If `True`, the `multi_query` and `parallel_attn`
62
+ arguments are ignored, as the new decoder always uses parallel attention.
63
+ multi_query (`bool`, *optional*, defaults to `True`):
64
+ Whether to use multi-query attention in the decoder. Ignored when `new_decoder_architecture` is `True`.
65
+ parallel_attn (`bool`, *optional*, defaults to `True`):
66
+ Whether to compute attention in parallel with the feedforward layer. If False, they are consecutive
67
+ instead, as in the original Transformer architecture. Ignored when `new_decoder_architecture` is `True`.
68
+ bias (`bool`, *optional*, defaults to `False`):
69
+ Whether to use bias on Linear layers.
70
+ max_position_embeddings (`int`, *optional*, defaults to 2048):
71
+ The maximum sequence length that this model might ever be used with, when `alibi` is `False`. Pretrained
72
+ Falcon models with RoPE support up to 2048 tokens.
73
+ rope_theta (`float`, *optional*, defaults to 10000.0):
74
+ The base period of the RoPE embeddings.
75
+ rope_scaling (`Dict`, *optional*):
76
+ Dictionary containing the scaling configuration for the RoPE embeddings. Currently supports two scaling
77
+ strategies: linear and dynamic. Their scaling factor must be a float greater than 1. The expected format is
78
+ `{"type": strategy name, "factor": scaling factor}`. When using this flag, don't update
79
+ `max_position_embeddings` to the expected new maximum. See the following thread for more information on how
80
+ these scaling strategies behave:
81
+ https://www.reddit.com/r/LocalLLaMA/comments/14mrgpr/dynamically_scaled_rope_further_increases/. This is an
82
+ experimental feature, subject to breaking API changes in future versions.
83
+ bos_token_id (`int`, *optional*, defaults to 11):
84
+ The id of the "beginning-of-sequence" token.
85
+ eos_token_id (`int`, *optional*, defaults to 11):
86
+ The id of the "end-of-sequence" token.
87
+ """
88
+
89
+ model_type = "MAELM"
90
+
91
+
92
+ def __init__(
93
+ self,
94
+ seed=42,
95
+ cache_dir=None,
96
+ do_train=True,
97
+ do_eval=False,
98
+ do_test=False,
99
+ dataset_name=None,
100
+ spect_len=2992,
101
+ train_dataset_list=[{'train_file': '/mnt/bn/music-nas-dxj1/datasets/MCC_AIGC/mccaigc_train_1w.csv', \
102
+ 'train_tokenized_data': None, 'train_data_root': '/mnt/bn/music-nas-dxj1/datasets/MCC_AIGC/logmel',}],
103
+ per_device_eval_batch_size=32,
104
+ preprocessing_num_workers=64,
105
+ overwrite_cache=True,
106
+ output_dir='/mnt/bn/music-nas-dxj1/VWork/ckpts_vault/cap_lynx-apm_umg_PT-mccaigc1w_FT',
107
+ save_interval_steps=1000,
108
+ overwrite_output_dir=True,
109
+ gradient_accumulation_steps=1,
110
+ num_train_epochs=50,
111
+ per_device_train_batch_size=12,
112
+ learning_rate=0.00005,
113
+ lm_lr_ratio=0.1,
114
+ tokenizer_name='Llama-2-7b-hf',
115
+ resume_from_checkpoint=None,
116
+ resume_from_pth='epoch_4-step_8639-allstep_60000.pth',
117
+ backbone={'name': 'MAEViT', 'arch': 'b', 'patch_size': 16, 'mask_ratio': 0.0, 'img_size': [80, 2992], \
118
+ 'ckpt': 'epoch_20.pth'},
119
+ neck={'name': 'LMDecoder', 'patch_size': 16, 'img_size': [80, 2992], 'in_chans': 3, 'embed_dim': 768, \
120
+ 'decoder_embed_dim': 4544, 'freeze_decoder': True, 'decoder_type': 'Llama-2-7b-hf'},
121
+ wandb={'proj': 'ATRena_cap', 'expname': 'cap_lynx_apmPT_mccaigc1wFT'},
122
+ **kwargs,
123
+ ):
124
+ self.backbone = backbone
125
+ self.neck = neck
126
+ self.tokenizer_name = tokenizer_name
127
+ self._name_or_path = None
128
+ self.resume_from_checkpoint = resume_from_checkpoint
129
+ self.resume_from_pth = resume_from_pth
130
+
131
+ AutoConfig.register("MAELM", MAELMConfig)