diegoquinteiro commited on
Commit
be9e22a
·
verified ·
1 Parent(s): aaf7fa9

Publish browser observable model and tuned lens

Browse files
README.md ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ base_model: EleutherAI/pythia-160m-deduped
4
+ library_name: onnx
5
+ pipeline_tag: text-generation
6
+ tags:
7
+ - transformers.js
8
+ - onnx
9
+ - interpretability
10
+ - attention
11
+ - tuned-lens
12
+ ---
13
+
14
+ # Pythia-160M Observable
15
+
16
+ Browser-oriented ONNX export of [`EleutherAI/pythia-160m-deduped`](https://huggingface.co/EleutherAI/pythia-160m-deduped) for the interactive laboratory in the Engenharia Assistida por IA course.
17
+
18
+ The repository contains two runtime artifacts:
19
+
20
+ - `model_observable_q4.onnx`, which returns final next-token logits, 13 residual-stream states and the selected query token's attention row for each of the 12 transformer layers;
21
+ - `model_tuned_lens_q8.onnx`, which applies the layer-specific translators from the pretrained [`AlignmentResearch/tuned-lens`](https://huggingface.co/spaces/AlignmentResearch/tuned-lens) artifact and decodes an intermediate state into vocabulary logits.
22
+
23
+ ## Observable model inputs
24
+
25
+ - `input_ids`: int64 tensor shaped `[batch, sequence]`;
26
+ - `attention_mask`: int64 tensor shaped `[batch, sequence]`;
27
+ - `query_index`: int64 tensor shaped `[batch]`.
28
+
29
+ The graph returns `next_token_logits`, `hidden_state_00` through `hidden_state_12`, and `attention_01` through `attention_12`.
30
+
31
+ ## Tuned lens inputs
32
+
33
+ - `hidden_states`: float32 tensor shaped `[states, 768]`;
34
+ - `layer_index`: int64 tensor shaped `[states]`, with values from 1 through 12.
35
+
36
+ Layer 12 uses the model's final normalization and unembedding without a translator. Earlier layers use the pretrained translator for that residual-stream position.
37
+
38
+ ## Quantization
39
+
40
+ Transformer matrix multiplications use weight-only Q4. The separate input and output embedding matrices use row-wise int8. The tuned lens translators and unembedding also use row-wise int8. Activations and public outputs remain float32.
41
+
42
+ The export manifest records the numerical checks performed against the PyTorch model and the original tuned lens. Quantization can change close-ranking tokens, so this artifact is intended for teaching and inspection, not evaluation or production inference.
43
+
44
+ ## Limitations
45
+
46
+ - Pythia-160M is a small base model, not an instruction-following model.
47
+ - Attention weights describe values computed inside the model. They do not prove that a source token caused a prediction.
48
+ - Intermediate predictions are diagnostic readouts from a tuned lens, not text generated by stopping the original model early.
49
+
config.json ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "GPTNeoXForCausalLM"
4
+ ],
5
+ "attention_bias": true,
6
+ "attention_dropout": 0.0,
7
+ "bos_token_id": 0,
8
+ "classifier_dropout": 0.1,
9
+ "dtype": "float32",
10
+ "eos_token_id": 0,
11
+ "hidden_act": "gelu",
12
+ "hidden_dropout": 0.0,
13
+ "hidden_size": 768,
14
+ "initializer_range": 0.02,
15
+ "intermediate_size": 3072,
16
+ "layer_norm_eps": 1e-05,
17
+ "max_position_embeddings": 2048,
18
+ "model_type": "gpt_neox",
19
+ "num_attention_heads": 12,
20
+ "num_hidden_layers": 12,
21
+ "partial_rotary_factor": 0.25,
22
+ "rope_scaling": null,
23
+ "rope_theta": 10000,
24
+ "rotary_emb_base": 10000,
25
+ "rotary_pct": 0.25,
26
+ "tie_word_embeddings": false,
27
+ "transformers_version": "4.56.2",
28
+ "use_cache": false,
29
+ "use_parallel_residual": true,
30
+ "vocab_size": 50304
31
+ }
model_observable_q4.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:45d559d26385ec43e7daf06c722fc171bb006fe5acc803f046e2d4a47defeb1f
3
+ size 133860719
model_tuned_lens_q8.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9acea8a7fcd609678c959fcc4f5384865a968dff4985f4f25df968bce913a319
3
+ size 46604627
observable-model.json ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_id": "EleutherAI/pythia-160m-deduped",
3
+ "model_file": "model_observable_q4.onnx",
4
+ "model_bytes": 133860719,
5
+ "tuned_lens_file": "model_tuned_lens_q8.onnx",
6
+ "tuned_lens_bytes": 46604627,
7
+ "architecture": {
8
+ "layers": 12,
9
+ "attention_heads": 12,
10
+ "hidden_size": 768,
11
+ "vocabulary_size": 50304
12
+ },
13
+ "inputs": [
14
+ "input_ids",
15
+ "attention_mask",
16
+ "query_index"
17
+ ],
18
+ "outputs": [
19
+ "next_token_logits",
20
+ "hidden_state_00",
21
+ "hidden_state_01",
22
+ "hidden_state_02",
23
+ "hidden_state_03",
24
+ "hidden_state_04",
25
+ "hidden_state_05",
26
+ "hidden_state_06",
27
+ "hidden_state_07",
28
+ "hidden_state_08",
29
+ "hidden_state_09",
30
+ "hidden_state_10",
31
+ "hidden_state_11",
32
+ "hidden_state_12",
33
+ "attention_01",
34
+ "attention_02",
35
+ "attention_03",
36
+ "attention_04",
37
+ "attention_05",
38
+ "attention_06",
39
+ "attention_07",
40
+ "attention_08",
41
+ "attention_09",
42
+ "attention_10",
43
+ "attention_11",
44
+ "attention_12"
45
+ ],
46
+ "validation_prompt": "The mayor supports the bike lane. Her opinion is",
47
+ "observable_validation": {
48
+ "outputs": 26,
49
+ "top_10_overlap": 8,
50
+ "max_logit_error": 2.7454833984375,
51
+ "max_attention_error": 0.9999815225601196,
52
+ "max_attention_sum_error": 2.384185791015625e-07,
53
+ "logits_shape": [
54
+ 1,
55
+ 50304
56
+ ],
57
+ "hidden_shape": [
58
+ 1,
59
+ 10,
60
+ 768
61
+ ],
62
+ "attention_shape": [
63
+ 1,
64
+ 12,
65
+ 10
66
+ ]
67
+ },
68
+ "tuned_lens_validation": {
69
+ "layers": 12,
70
+ "top_10_overlap_min": 8,
71
+ "top_10_overlap_mean": 9.666666666666666,
72
+ "max_logit_error": 0.55035400390625,
73
+ "top_token_ids": [
74
+ 247,
75
+ 247,
76
+ 417,
77
+ 247,
78
+ 247,
79
+ 417,
80
+ 326,
81
+ 1754,
82
+ 1754,
83
+ 1754,
84
+ 1754,
85
+ 326
86
+ ],
87
+ "logits_shape": [
88
+ 1,
89
+ 50304
90
+ ]
91
+ },
92
+ "tuned_lens_source": "AlignmentResearch/tuned-lens"
93
+ }
special_tokens_map.json ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<|endoftext|>",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "eos_token": {
10
+ "content": "<|endoftext|>",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "unk_token": {
17
+ "content": "<|endoftext|>",
18
+ "lstrip": false,
19
+ "normalized": false,
20
+ "rstrip": false,
21
+ "single_word": false
22
+ }
23
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,215 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": false,
3
+ "add_eos_token": false,
4
+ "add_prefix_space": false,
5
+ "added_tokens_decoder": {
6
+ "0": {
7
+ "content": "<|endoftext|>",
8
+ "lstrip": false,
9
+ "normalized": false,
10
+ "rstrip": false,
11
+ "single_word": false,
12
+ "special": true
13
+ },
14
+ "1": {
15
+ "content": "<|padding|>",
16
+ "lstrip": false,
17
+ "normalized": false,
18
+ "rstrip": false,
19
+ "single_word": false,
20
+ "special": true
21
+ },
22
+ "50254": {
23
+ "content": " ",
24
+ "lstrip": false,
25
+ "normalized": true,
26
+ "rstrip": false,
27
+ "single_word": false,
28
+ "special": false
29
+ },
30
+ "50255": {
31
+ "content": " ",
32
+ "lstrip": false,
33
+ "normalized": true,
34
+ "rstrip": false,
35
+ "single_word": false,
36
+ "special": false
37
+ },
38
+ "50256": {
39
+ "content": " ",
40
+ "lstrip": false,
41
+ "normalized": true,
42
+ "rstrip": false,
43
+ "single_word": false,
44
+ "special": false
45
+ },
46
+ "50257": {
47
+ "content": " ",
48
+ "lstrip": false,
49
+ "normalized": true,
50
+ "rstrip": false,
51
+ "single_word": false,
52
+ "special": false
53
+ },
54
+ "50258": {
55
+ "content": " ",
56
+ "lstrip": false,
57
+ "normalized": true,
58
+ "rstrip": false,
59
+ "single_word": false,
60
+ "special": false
61
+ },
62
+ "50259": {
63
+ "content": " ",
64
+ "lstrip": false,
65
+ "normalized": true,
66
+ "rstrip": false,
67
+ "single_word": false,
68
+ "special": false
69
+ },
70
+ "50260": {
71
+ "content": " ",
72
+ "lstrip": false,
73
+ "normalized": true,
74
+ "rstrip": false,
75
+ "single_word": false,
76
+ "special": false
77
+ },
78
+ "50261": {
79
+ "content": " ",
80
+ "lstrip": false,
81
+ "normalized": true,
82
+ "rstrip": false,
83
+ "single_word": false,
84
+ "special": false
85
+ },
86
+ "50262": {
87
+ "content": " ",
88
+ "lstrip": false,
89
+ "normalized": true,
90
+ "rstrip": false,
91
+ "single_word": false,
92
+ "special": false
93
+ },
94
+ "50263": {
95
+ "content": " ",
96
+ "lstrip": false,
97
+ "normalized": true,
98
+ "rstrip": false,
99
+ "single_word": false,
100
+ "special": false
101
+ },
102
+ "50264": {
103
+ "content": " ",
104
+ "lstrip": false,
105
+ "normalized": true,
106
+ "rstrip": false,
107
+ "single_word": false,
108
+ "special": false
109
+ },
110
+ "50265": {
111
+ "content": " ",
112
+ "lstrip": false,
113
+ "normalized": true,
114
+ "rstrip": false,
115
+ "single_word": false,
116
+ "special": false
117
+ },
118
+ "50266": {
119
+ "content": " ",
120
+ "lstrip": false,
121
+ "normalized": true,
122
+ "rstrip": false,
123
+ "single_word": false,
124
+ "special": false
125
+ },
126
+ "50267": {
127
+ "content": " ",
128
+ "lstrip": false,
129
+ "normalized": true,
130
+ "rstrip": false,
131
+ "single_word": false,
132
+ "special": false
133
+ },
134
+ "50268": {
135
+ "content": " ",
136
+ "lstrip": false,
137
+ "normalized": true,
138
+ "rstrip": false,
139
+ "single_word": false,
140
+ "special": false
141
+ },
142
+ "50269": {
143
+ "content": " ",
144
+ "lstrip": false,
145
+ "normalized": true,
146
+ "rstrip": false,
147
+ "single_word": false,
148
+ "special": false
149
+ },
150
+ "50270": {
151
+ "content": " ",
152
+ "lstrip": false,
153
+ "normalized": true,
154
+ "rstrip": false,
155
+ "single_word": false,
156
+ "special": false
157
+ },
158
+ "50271": {
159
+ "content": " ",
160
+ "lstrip": false,
161
+ "normalized": true,
162
+ "rstrip": false,
163
+ "single_word": false,
164
+ "special": false
165
+ },
166
+ "50272": {
167
+ "content": " ",
168
+ "lstrip": false,
169
+ "normalized": true,
170
+ "rstrip": false,
171
+ "single_word": false,
172
+ "special": false
173
+ },
174
+ "50273": {
175
+ "content": " ",
176
+ "lstrip": false,
177
+ "normalized": true,
178
+ "rstrip": false,
179
+ "single_word": false,
180
+ "special": false
181
+ },
182
+ "50274": {
183
+ "content": " ",
184
+ "lstrip": false,
185
+ "normalized": true,
186
+ "rstrip": false,
187
+ "single_word": false,
188
+ "special": false
189
+ },
190
+ "50275": {
191
+ "content": " ",
192
+ "lstrip": false,
193
+ "normalized": true,
194
+ "rstrip": false,
195
+ "single_word": false,
196
+ "special": false
197
+ },
198
+ "50276": {
199
+ "content": " ",
200
+ "lstrip": false,
201
+ "normalized": true,
202
+ "rstrip": false,
203
+ "single_word": false,
204
+ "special": false
205
+ }
206
+ },
207
+ "bos_token": "<|endoftext|>",
208
+ "clean_up_tokenization_spaces": false,
209
+ "eos_token": "<|endoftext|>",
210
+ "extra_special_tokens": {},
211
+ "model_max_length": 1000000000000000019884624838656,
212
+ "pad_token": null,
213
+ "tokenizer_class": "GPTNeoXTokenizer",
214
+ "unk_token": "<|endoftext|>"
215
+ }