zixuanlan commited on
Commit
e4e2276
·
verified ·
1 Parent(s): 8410b9d

Release UMIM merge modules and merge rules

Browse files
README.md CHANGED
@@ -1,3 +1,116 @@
1
  ---
2
- license: apache-2.0
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ base_model:
3
+ - meta-llama/Llama-3.1-8B
4
+ - meta-llama/Llama-3.2-1B
5
+ - openai-community/gpt2-xl
6
+ library_name: pytorch
7
+ tags:
8
+ - umim
9
+ - token-merging
10
+ - kv-cache
11
+ - language-model-compression
12
+ - pytorch
13
  ---
14
+
15
+ # UMIM Merge Modules and Merge Rules
16
+
17
+ This repository contains the task-agnostic merge modules and tokenizer-specific
18
+ 2-, 3-, and 4-gram merge rules released with **UMIM: Distilling Sequential
19
+ Computation in Transformer Language Models**.
20
+
21
+ UMIM replaces matched contiguous token spans with surrogate embeddings produced
22
+ by a lightweight merge module. The pretrained language-model backbone remains
23
+ frozen. During inference, UMIM compresses both prompt prefill and the growing KV
24
+ cache while preserving fully autoregressive token generation.
25
+
26
+ - [Code](https://github.com/Zesearch/Umim-LLM)
27
+ - [Project page](https://zesearch.github.io/Umim-LLM/)
28
+ - Paper: coming soon
29
+
30
+ ## Repository layout
31
+
32
+ | Directory | Backbone | Merge-module dtype | Rules |
33
+ |:--|:--|:--|:--|
34
+ | `llama-3.1-8b/` | `meta-llama/Llama-3.1-8B` | bfloat16 | 2-, 3-, and 4-grams |
35
+ | `llama-3.2-1b/` | `meta-llama/Llama-3.2-1B` | float32 | 2-, 3-, and 4-grams |
36
+ | `gpt2-xl/` | `openai-community/gpt2-xl` | float32 | 2-, 3-, and 4-grams |
37
+
38
+ Each directory contains:
39
+
40
+ ```text
41
+ <backbone>/
42
+ ├── merge_module.pt
43
+ ├── filtered_bigrams_tensor.pt
44
+ ├── filtered_trigrams_tensor.pt
45
+ ├── filtered_fourgrams_tensor.pt
46
+ └── runtime_config.json
47
+ ```
48
+
49
+ `merge_module.pt` is a clean PyTorch state dictionary containing only the nine
50
+ merge-module tensors. Training optimizer, scheduler, scaler, and progress states
51
+ are intentionally excluded. `manifest.json` records file sizes, SHA-256 hashes,
52
+ tensor metadata, and rule counts for reproducibility.
53
+
54
+ ## Download
55
+
56
+ Download the complete release with the Hugging Face CLI:
57
+
58
+ ```bash
59
+ hf download Zesearch/UMIM --local-dir artifacts/umim
60
+ ```
61
+
62
+ To download one backbone only:
63
+
64
+ ```bash
65
+ hf download Zesearch/UMIM \
66
+ --include "llama-3.1-8b/*" \
67
+ --local-dir artifacts/umim
68
+ ```
69
+
70
+ ## Inference
71
+
72
+ Clone the UMIM codebase and install its runtime dependencies:
73
+
74
+ ```bash
75
+ git clone https://github.com/Zesearch/Umim-LLM.git
76
+ cd Umim-LLM
77
+ python -m pip install torch transformers accelerate
78
+ ```
79
+
80
+ After downloading the release into `artifacts/umim`, run:
81
+
82
+ ```bash
83
+ python -m generation.generate \
84
+ --model meta-llama/Llama-3.1-8B \
85
+ --config artifacts/umim/llama-3.1-8b/runtime_config.json \
86
+ --prompt "Language models can" \
87
+ --max-new-tokens 128 \
88
+ --device cuda:0 \
89
+ --dtype bfloat16
90
+ ```
91
+
92
+ The paths inside each `runtime_config.json` are relative to that configuration
93
+ file, so no manual path editing is needed when the directory is kept intact.
94
+
95
+ ## Artifact compatibility
96
+
97
+ Merge rules contain tokenizer token IDs and therefore must be paired with their
98
+ listed backbone. The two Llama releases share the same rule tensors because both
99
+ use the compatible Llama tokenizer vocabulary in these experiments. GPT-2 XL
100
+ uses its own rule tensors.
101
+
102
+ These files are the WikiText-103-trained, task-agnostic base merge modules and
103
+ rules. They are the artifacts used for direct transfer without downstream
104
+ retraining. Task-specific SFT and preference-based RL update only the merge
105
+ module while keeping the backbone frozen; task-adapted checkpoints are not part
106
+ of this initial artifact bundle.
107
+
108
+ ## Citation
109
+
110
+ The arXiv entry and BibTeX citation will be added when the final paper version is
111
+ available.
112
+
113
+ ## Questions
114
+
115
+ Please use the [GitHub issue tracker](https://github.com/Zesearch/Umim-LLM/issues)
116
+ for questions about the code or released artifacts.
gpt2-xl/filtered_bigrams_tensor.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5314ce0d98784afbafd7530a1d6d99c4bcc3cbb47ef207551f76d66340cca112
3
+ size 1748652
gpt2-xl/filtered_fourgrams_tensor.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:24feb7320011daf547cd242a8265304cd112ca19f2b1031669913f843dc6f619
3
+ size 19867830
gpt2-xl/filtered_trigrams_tensor.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7da885e42794dfe91ff1a74dec58aeb1b2aea7928a6345ed838fa3a34941af52
3
+ size 8432177
gpt2-xl/merge_module.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:15357651b23f6ab78e2fdfa64dd4622b0714b813a2f9f3f61a0cae8dc0ac4706
3
+ size 20529236
gpt2-xl/runtime_config.json ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "merge_weights": "merge_module.pt",
3
+ "rule_files": {
4
+ "2": "filtered_bigrams_tensor.pt",
5
+ "3": "filtered_trigrams_tensor.pt",
6
+ "4": "filtered_fourgrams_tensor.pt"
7
+ },
8
+ "num_heads": 4,
9
+ "surrogate_cache_size": 4096,
10
+ "local_files_only": false
11
+ }
llama-3.1-8b/filtered_bigrams_tensor.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:75a202e6f29be5d4bc8137790f35b80af68c53bd30e06b918a42177c4db57a5c
3
+ size 1734892
llama-3.1-8b/filtered_fourgrams_tensor.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:636e9e275573e7a55a55b36974447ca6a75e85c38bc777b1f7d3e4d086a62a44
3
+ size 20258614
llama-3.1-8b/filtered_trigrams_tensor.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5129bf14b7542e7fde1e7e51721cc0779c4dd39959c6383860b4d6efab10e938
3
+ size 8218801
llama-3.1-8b/merge_module.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1f221a3f87a457b3e74e20e68413f6c21dfb0fa7873ffff298733a21bcb7ce14
3
+ size 67168588
llama-3.1-8b/runtime_config.json ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "merge_weights": "merge_module.pt",
3
+ "rule_files": {
4
+ "2": "filtered_bigrams_tensor.pt",
5
+ "3": "filtered_trigrams_tensor.pt",
6
+ "4": "filtered_fourgrams_tensor.pt"
7
+ },
8
+ "num_heads": 4,
9
+ "surrogate_cache_size": 4096,
10
+ "local_files_only": false
11
+ }
llama-3.2-1b/filtered_bigrams_tensor.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:75a202e6f29be5d4bc8137790f35b80af68c53bd30e06b918a42177c4db57a5c
3
+ size 1734892
llama-3.2-1b/filtered_fourgrams_tensor.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:636e9e275573e7a55a55b36974447ca6a75e85c38bc777b1f7d3e4d086a62a44
3
+ size 20258614
llama-3.2-1b/filtered_trigrams_tensor.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5129bf14b7542e7fde1e7e51721cc0779c4dd39959c6383860b4d6efab10e938
3
+ size 8218801
llama-3.2-1b/merge_module.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:85f7d800d64130f8278480d24ced3752c929c64ff4249dd50647e8b870d2e0c7
3
+ size 33616212
llama-3.2-1b/runtime_config.json ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "merge_weights": "merge_module.pt",
3
+ "rule_files": {
4
+ "2": "filtered_bigrams_tensor.pt",
5
+ "3": "filtered_trigrams_tensor.pt",
6
+ "4": "filtered_fourgrams_tensor.pt"
7
+ },
8
+ "num_heads": 4,
9
+ "surrogate_cache_size": 4096,
10
+ "local_files_only": false
11
+ }
manifest.json ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "format": "UMIM release manifest",
3
+ "models": {
4
+ "gpt2-xl": {
5
+ "base_model": "openai-community/gpt2-xl",
6
+ "hidden_size": 1600,
7
+ "merge_module": {
8
+ "dtype": "float32",
9
+ "file": "merge_module.pt",
10
+ "sha256": "15357651b23f6ab78e2fdfa64dd4622b0714b813a2f9f3f61a0cae8dc0ac4706",
11
+ "size_bytes": 20529236,
12
+ "tensor_count": 9
13
+ },
14
+ "num_attention_heads": 4,
15
+ "rules": {
16
+ "2": {
17
+ "count": 218415,
18
+ "dtype": "int32",
19
+ "file": "filtered_bigrams_tensor.pt",
20
+ "max_token_id": 50255,
21
+ "min_token_id": 12,
22
+ "sha256": "5314ce0d98784afbafd7530a1d6d99c4bcc3cbb47ef207551f76d66340cca112",
23
+ "size_bytes": 1748652
24
+ },
25
+ "3": {
26
+ "count": 702570,
27
+ "dtype": "int32",
28
+ "file": "filtered_trigrams_tensor.pt",
29
+ "max_token_id": 50254,
30
+ "min_token_id": 6,
31
+ "sha256": "7da885e42794dfe91ff1a74dec58aeb1b2aea7928a6345ed838fa3a34941af52",
32
+ "size_bytes": 8432177
33
+ },
34
+ "4": {
35
+ "count": 1241657,
36
+ "dtype": "int32",
37
+ "file": "filtered_fourgrams_tensor.pt",
38
+ "max_token_id": 50253,
39
+ "min_token_id": 6,
40
+ "sha256": "24feb7320011daf547cd242a8265304cd112ca19f2b1031669913f843dc6f619",
41
+ "size_bytes": 19867830
42
+ }
43
+ },
44
+ "training_checkpoint_metadata": {
45
+ "best_val_loss": 3.5166141991783126,
46
+ "epoch": 14,
47
+ "global_step": 123390,
48
+ "val_loss": 3.5166141991783126
49
+ }
50
+ },
51
+ "llama-3.1-8b": {
52
+ "base_model": "meta-llama/Llama-3.1-8B",
53
+ "hidden_size": 4096,
54
+ "merge_module": {
55
+ "dtype": "bfloat16",
56
+ "file": "merge_module.pt",
57
+ "sha256": "1f221a3f87a457b3e74e20e68413f6c21dfb0fa7873ffff298733a21bcb7ce14",
58
+ "size_bytes": 67168588,
59
+ "tensor_count": 9
60
+ },
61
+ "num_attention_heads": 4,
62
+ "rules": {
63
+ "2": {
64
+ "count": 216700,
65
+ "dtype": "int32",
66
+ "file": "filtered_bigrams_tensor.pt",
67
+ "max_token_id": 127935,
68
+ "min_token_id": 12,
69
+ "sha256": "75a202e6f29be5d4bc8137790f35b80af68c53bd30e06b918a42177c4db57a5c",
70
+ "size_bytes": 1734892
71
+ },
72
+ "3": {
73
+ "count": 684793,
74
+ "dtype": "int32",
75
+ "file": "filtered_trigrams_tensor.pt",
76
+ "max_token_id": 128000,
77
+ "min_token_id": 11,
78
+ "sha256": "5129bf14b7542e7fde1e7e51721cc0779c4dd39959c6383860b4d6efab10e938",
79
+ "size_bytes": 8218801
80
+ },
81
+ "4": {
82
+ "count": 1266080,
83
+ "dtype": "int32",
84
+ "file": "filtered_fourgrams_tensor.pt",
85
+ "max_token_id": 128000,
86
+ "min_token_id": 6,
87
+ "sha256": "636e9e275573e7a55a55b36974447ca6a75e85c38bc777b1f7d3e4d086a62a44",
88
+ "size_bytes": 20258614
89
+ }
90
+ },
91
+ "training_checkpoint_metadata": {}
92
+ },
93
+ "llama-3.2-1b": {
94
+ "base_model": "meta-llama/Llama-3.2-1B",
95
+ "hidden_size": 2048,
96
+ "merge_module": {
97
+ "dtype": "float32",
98
+ "file": "merge_module.pt",
99
+ "sha256": "85f7d800d64130f8278480d24ced3752c929c64ff4249dd50647e8b870d2e0c7",
100
+ "size_bytes": 33616212,
101
+ "tensor_count": 9
102
+ },
103
+ "num_attention_heads": 4,
104
+ "rules": {
105
+ "2": {
106
+ "count": 216700,
107
+ "dtype": "int32",
108
+ "file": "filtered_bigrams_tensor.pt",
109
+ "max_token_id": 127935,
110
+ "min_token_id": 12,
111
+ "sha256": "75a202e6f29be5d4bc8137790f35b80af68c53bd30e06b918a42177c4db57a5c",
112
+ "size_bytes": 1734892
113
+ },
114
+ "3": {
115
+ "count": 684793,
116
+ "dtype": "int32",
117
+ "file": "filtered_trigrams_tensor.pt",
118
+ "max_token_id": 128000,
119
+ "min_token_id": 11,
120
+ "sha256": "5129bf14b7542e7fde1e7e51721cc0779c4dd39959c6383860b4d6efab10e938",
121
+ "size_bytes": 8218801
122
+ },
123
+ "4": {
124
+ "count": 1266080,
125
+ "dtype": "int32",
126
+ "file": "filtered_fourgrams_tensor.pt",
127
+ "max_token_id": 128000,
128
+ "min_token_id": 6,
129
+ "sha256": "636e9e275573e7a55a55b36974447ca6a75e85c38bc777b1f7d3e4d086a62a44",
130
+ "size_bytes": 20258614
131
+ }
132
+ },
133
+ "training_checkpoint_metadata": {
134
+ "best_val_loss": 3.3169725206163196,
135
+ "epoch": 14,
136
+ "global_step": 111600,
137
+ "val_loss": 3.3169725206163196
138
+ }
139
+ }
140
+ },
141
+ "version": 1
142
+ }