mrinaldi commited on
Commit
0c40f3f
·
verified ·
1 Parent(s): a0ce640

Upload folder using huggingface_hub

Browse files
Files changed (5) hide show
  1. README.md +28 -0
  2. checkpoint.ckpt +3 -0
  3. config.json +113 -0
  4. matformer_config.json +72 -0
  5. modeling_matformer.py +47 -0
README.md ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - matformer
4
+ - custom-model
5
+ library_name: transformers
6
+ ---
7
+
8
+ # Matformer Model
9
+
10
+ Trained using [Matformer](https://github.com/mrinaldi97/matformer).
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ pip install git+https://github.com/mrinaldi97/matformer.git
16
+ ```
17
+
18
+ ## Usage
19
+
20
+ ```python
21
+ import torch
22
+ from transformers import AutoModelForMaskedLM
23
+
24
+ model = AutoModelForMaskedLM.from_pretrained(
25
+ "mrinaldi/AAA_half_trained",
26
+ trust_remote_code=True
27
+ )
28
+ ```
checkpoint.ckpt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b9c4e0649631be6dd95dc796e1f9cff84531abad47c39463e991566c422fb58d
3
+ size 4001019849
config.json ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_checkpoint_path": "/mnt/llmdata/data/Checkpoints_Albertone/backup.ckpt",
3
+ "_matformer_config_dict": {
4
+ "_checkpoint_path": "/mnt/llmdata/data/Checkpoints_Albertone/backup.ckpt",
5
+ "_model_class": "BERTModel",
6
+ "_tokenizer_name": "mrinaldi/Gettone",
7
+ "attention_type": [],
8
+ "bias": false,
9
+ "block_size_for_attention": 128,
10
+ "bos_token_id": 5,
11
+ "cloze_probability": 1.0,
12
+ "compile_flexattn": false,
13
+ "custom_layers": {},
14
+ "decoder": null,
15
+ "default_layer": {
16
+ "attn_impl": "flash",
17
+ "ffn_activation": "swiglu",
18
+ "hooks": {},
19
+ "normalization": "rmsnorm",
20
+ "normalization_position": "pre",
21
+ "positional_encoding": "alibi",
22
+ "sliding_window_size": null
23
+ },
24
+ "encoder": null,
25
+ "entropy": null,
26
+ "eos_token_id": 6,
27
+ "ffn_factor": 3.0,
28
+ "has_entropy_model": null,
29
+ "has_text_autoencoder": null,
30
+ "hidden_size": 1024,
31
+ "is_causal": null,
32
+ "loss_type": "normal",
33
+ "mask_token_id": 4,
34
+ "masked_substitution_rate": [
35
+ 0.1,
36
+ 0.5
37
+ ],
38
+ "max_position_embeddings": 1024,
39
+ "model_class": null,
40
+ "name": "Albertone",
41
+ "num_attention_heads": 16,
42
+ "num_hidden_layers": 28,
43
+ "num_labels": 2,
44
+ "pad_token_id": 0,
45
+ "random_probability": 0.0,
46
+ "rms_norm_eps": 1e-06,
47
+ "rope_theta": 10000.0,
48
+ "same_probability": 0.0,
49
+ "sliding_type": null,
50
+ "tie_word_embeddings": true,
51
+ "tokenizer_name": null,
52
+ "tokenizer_type": null,
53
+ "training_objective": null,
54
+ "vocab_size": 32768
55
+ },
56
+ "_model_class": "BERTModel",
57
+ "_tokenizer_name": "mrinaldi/Gettone",
58
+ "attention_type": [],
59
+ "auto_map": {
60
+ "AutoConfig": "modeling_matformer.MatformerConfig",
61
+ "AutoModel": "modeling_matformer.MatformerModel",
62
+ "AutoModelForMaskedLM": "modeling_matformer.MatformerForMaskedLM"
63
+ },
64
+ "bias": false,
65
+ "block_size_for_attention": 128,
66
+ "bos_token_id": 5,
67
+ "cloze_probability": 1.0,
68
+ "compile_flexattn": false,
69
+ "custom_layers": {},
70
+ "decoder": null,
71
+ "default_layer": {
72
+ "attn_impl": "flash",
73
+ "ffn_activation": "swiglu",
74
+ "hooks": {},
75
+ "normalization": "rmsnorm",
76
+ "normalization_position": "pre",
77
+ "positional_encoding": "alibi",
78
+ "sliding_window_size": null
79
+ },
80
+ "encoder": null,
81
+ "entropy": null,
82
+ "eos_token_id": 6,
83
+ "ffn_factor": 3.0,
84
+ "has_entropy_model": null,
85
+ "has_text_autoencoder": null,
86
+ "hidden_size": 1024,
87
+ "is_causal": null,
88
+ "loss_type": "normal",
89
+ "mask_token_id": 4,
90
+ "masked_substitution_rate": [
91
+ 0.1,
92
+ 0.5
93
+ ],
94
+ "max_position_embeddings": 1024,
95
+ "model_class": null,
96
+ "model_type": "matformer",
97
+ "name": "Albertone",
98
+ "num_attention_heads": 16,
99
+ "num_hidden_layers": 28,
100
+ "pad_token_id": 0,
101
+ "random_probability": 0.0,
102
+ "rms_norm_eps": 1e-06,
103
+ "rope_theta": 10000.0,
104
+ "same_probability": 0.0,
105
+ "seed": 42,
106
+ "sliding_type": null,
107
+ "tokenizer_name": null,
108
+ "tokenizer_type": null,
109
+ "training_objective": null,
110
+ "transformers_version": "4.53.0",
111
+ "use_cache": true,
112
+ "vocab_size": 32768
113
+ }
matformer_config.json ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_class": "BERTModel",
3
+ "model_config": {
4
+ "name": "Albertone",
5
+ "hidden_size": 1024,
6
+ "ffn_factor": 3.0,
7
+ "vocab_size": 32768,
8
+ "bos_token_id": 5,
9
+ "eos_token_id": 6,
10
+ "pad_token_id": 0,
11
+ "mask_token_id": 4,
12
+ "masked_substitution_rate": [
13
+ 0.1,
14
+ 0.5
15
+ ],
16
+ "cloze_probability": 1.0,
17
+ "random_probability": 0.0,
18
+ "same_probability": 0.0,
19
+ "num_hidden_layers": 28,
20
+ "num_attention_heads": 16,
21
+ "tie_word_embeddings": true,
22
+ "rms_norm_eps": 1e-06,
23
+ "attention_type": [],
24
+ "max_position_embeddings": 1024,
25
+ "block_size_for_attention": 128,
26
+ "compile_flexattn": false,
27
+ "bias": false,
28
+ "default_layer": {
29
+ "attn_impl": "flash",
30
+ "sliding_window_size": null,
31
+ "positional_encoding": "alibi",
32
+ "normalization": "rmsnorm",
33
+ "normalization_position": "pre",
34
+ "ffn_activation": "swiglu",
35
+ "hooks": {}
36
+ },
37
+ "custom_layers": {}
38
+ },
39
+ "training": {
40
+ "optimizer": "muon",
41
+ "lr_scheduling": true,
42
+ "lr": 0.0005,
43
+ "final_lr": 1e-05,
44
+ "hold_steps": 0.01,
45
+ "weight_decay": 0.01,
46
+ "scheduler": "custom",
47
+ "gradient_clip_val": 1.0,
48
+ "warmup_steps": 0.007,
49
+ "max_epochs": 1,
50
+ "accumulate_grad_batches": 64,
51
+ "seed": 27,
52
+ "save_every_n_steps": 500,
53
+ "checkpoint_name": "albertone",
54
+ "no_decay_for_embedding": true
55
+ },
56
+ "tokenizer": {
57
+ "type": "huggingface",
58
+ "pretrained_name": "mrinaldi/Gettone",
59
+ "varlen_strategy": "unpadding"
60
+ },
61
+ "data": {
62
+ "data_root": "/mnt/llmdata/data/Albertone_MDAT",
63
+ "batch_size": 32,
64
+ "num_workers": 1,
65
+ "mdat_strategy": "Gettone1024_",
66
+ "mdat_view": null,
67
+ "wanted_from_strategy": "chunked_for_recurrence"
68
+ },
69
+ "save_dir": "./checkpoints",
70
+ "wandb_project": "Albertone",
71
+ "wandb_run_name": "Albertone"
72
+ }
modeling_matformer.py ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # modeling_matformer.py
2
+ import os
3
+ import sys
4
+
5
+ matformer_root = os.getenv("MATFORMER_ROOT")
6
+ if matformer_root:
7
+ matformer_root = os.path.abspath(os.path.expanduser(matformer_root))
8
+ if matformer_root not in sys.path:
9
+ sys.path.insert(0, matformer_root)
10
+
11
+ try:
12
+ from matformer.huggingface_integration import (
13
+ MatformerForCausalLM,
14
+ MatformerForMaskedLM,
15
+ MatformerForSequenceClassification,
16
+ MatformerModel,
17
+ MatformerConfig,
18
+ register_matformer
19
+ )
20
+ register_matformer()
21
+ except ImportError as e:
22
+ import subprocess
23
+ import tempfile
24
+
25
+ print("Installing Matformer from GitHub...")
26
+ try:
27
+ subprocess.check_call([
28
+ sys.executable, "-m", "pip", "install",
29
+ "git+https://github.com/mrinaldi97/matformer.git"
30
+ ])
31
+
32
+ from matformer.huggingface_integration import (
33
+ MatformerForCausalLM,
34
+ MatformerForMaskedLM,
35
+ MatformerForSequenceClassification,
36
+ MatformerModel,
37
+ MatformerConfig,
38
+ register_matformer
39
+ )
40
+ register_matformer()
41
+
42
+ except Exception as install_error:
43
+ raise ImportError(
44
+ "Failed to install Matformer. Install manually:\n"
45
+ " pip install git+https://github.com/mrinaldi97/matformer.git\n"
46
+ "Or set MATFORMER_ROOT environment variable"
47
+ ) from install_error