ppbrown commited on
Commit
c86a1af
·
verified ·
1 Parent(s): c9a9b6d

Upload folder using huggingface_hub

Browse files
Files changed (4) hide show
  1. README.md +6 -0
  2. config.json +31 -0
  3. model.safetensors +3 -0
  4. transform.py +21 -0
README.md ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+
2
+ This is just the encoder stuffs from "google/t5-v1_1-xl"
3
+ It takes 11GB down to 4GB.
4
+ The script to do the extraction is included here as
5
+ [transform.py](transform.py)
6
+
config.json ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "T5EncoderModel"
4
+ ],
5
+ "classifier_dropout": 0.0,
6
+ "d_ff": 5120,
7
+ "d_kv": 64,
8
+ "d_model": 2048,
9
+ "decoder_start_token_id": 0,
10
+ "dense_act_fn": "gelu_new",
11
+ "dropout_rate": 0.1,
12
+ "eos_token_id": 1,
13
+ "feed_forward_proj": "gated-gelu",
14
+ "initializer_factor": 1.0,
15
+ "is_encoder_decoder": true,
16
+ "is_gated_act": true,
17
+ "layer_norm_epsilon": 1e-06,
18
+ "model_type": "t5",
19
+ "num_decoder_layers": 24,
20
+ "num_heads": 32,
21
+ "num_layers": 24,
22
+ "output_past": true,
23
+ "pad_token_id": 0,
24
+ "relative_attention_max_distance": 128,
25
+ "relative_attention_num_buckets": 32,
26
+ "tie_word_embeddings": false,
27
+ "torch_dtype": "float32",
28
+ "transformers_version": "4.52.4",
29
+ "use_cache": true,
30
+ "vocab_size": 32128
31
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:277bc2373d204e436e9ffaefafa3696b47809a7ae79b25ee284f7eb10fff6e56
3
+ size 4894136632
transform.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/env python
2
+
3
+ # This script extracts the "encoder-only" part from the full t5-xl model
4
+
5
+ from transformers import T5ForConditionalGeneration, T5EncoderModel
6
+
7
+ src_model_name = "google/t5-v1_1-xl"
8
+ dst_dir = "./t5-v1_1-xl-encoder-only"
9
+
10
+ full_model = T5ForConditionalGeneration.from_pretrained(src_model_name)
11
+ # Initialize empty encoder-only model (inherits config, so tokenizer stays compatible)
12
+ encoder_model = T5EncoderModel(full_model.config)
13
+
14
+ # Get the full state dict, then ditch the parts we dont need
15
+ state_dict = full_model.state_dict()
16
+ encoder_state_dict = {k: v for k, v in state_dict.items() if not k.startswith("decoder.") and not k.startswith("lm_head.")}
17
+
18
+ encoder_model.load_state_dict(encoder_state_dict)
19
+
20
+ encoder_model.save_pretrained(dst_dir)
21
+ print(f"Encoder-only model saved to {dst_dir}")