zzra1n commited on
Commit
6140b0b
·
verified ·
1 Parent(s): f91515d

Publish SyzEncoder step-90000

Browse files
README.md ADDED
@@ -0,0 +1,172 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - code
4
+ license: bigcode-openrail-m
5
+ library_name: transformers
6
+ pipeline_tag: feature-extraction
7
+ base_model: bigcode/starencoder
8
+ tags:
9
+ - syzkaller
10
+ - syz-program
11
+ - linux-kernel
12
+ - code-encoder
13
+ - masked-language-modeling
14
+ ---
15
+
16
+ # SyzEncoder
17
+
18
+ SyzEncoder is an encoder for programs generated by the
19
+ [syzkaller](https://github.com/google/syzkaller) kernel fuzzer. It is based on
20
+ [StarEncoder](https://huggingface.co/bigcode/starencoder) and was further
21
+ pretrained with masked language modeling on 2,236,878 syz programs. The model
22
+ is used by SyzPilot as the base encoder for online reachability classifiers and
23
+ token-level attribution.
24
+
25
+ This repository contains the checkpoint from training step 90,000. It had the
26
+ lowest validation loss among the saved checkpoints. Only the encoder and its
27
+ tokenizer are included; the masked language modeling head used during
28
+ pretraining is not part of this release.
29
+
30
+ ## Intended use
31
+
32
+ SyzEncoder is intended for representation learning and classification tasks on
33
+ syz programs. Typical uses include:
34
+
35
+ - initializing a reachability or coverage classifier;
36
+ - extracting sequence or token representations for attribution;
37
+ - studying machine-learning methods for kernel fuzzing.
38
+
39
+ The model does not generate syz programs. It has not been evaluated as a
40
+ general-purpose source-code or natural-language encoder.
41
+
42
+ ## Model details
43
+
44
+ | Property | Value |
45
+ | --- | --- |
46
+ | Base model | `bigcode/starencoder` |
47
+ | Architecture | BERT encoder |
48
+ | Published parameters | 123,595,776 |
49
+ | Hidden size | 768 |
50
+ | Encoder layers | 12 |
51
+ | Attention heads | 12 |
52
+ | Maximum sequence length | 1,024 tokens |
53
+ | Training objective | Masked language modeling |
54
+ | Selected checkpoint | Step 90,000 |
55
+
56
+ The checkpoint does not contain pooler weights. Downstream code should either
57
+ load it with `add_pooling_layer=False` or train a task-specific pooling layer.
58
+ SyzPilot uses attention-mask-aware mean pooling.
59
+
60
+ ## Tokenizer
61
+
62
+ The repository includes SyzTokenizer, a byte-level BPE tokenizer trained on the
63
+ same 2,236,878-program corpus. Its base vocabulary has 49,152 tokens, plus the
64
+ `<mask>` token used during pretraining.
65
+
66
+ Tokenizer selection included a grid search and a small masked-language-modeling
67
+ comparison. During tokenizer training, long repeated character runs and bare
68
+ hexadecimal runs were shortened before BPE learning, and token length was
69
+ capped at 64 characters. Hexadecimal literals beginning with `0x` were left
70
+ unchanged. These choices limit oversized tokens produced by raw byte dumps and
71
+ repetitive payloads while retaining common syz syntax.
72
+
73
+ ## Training data
74
+
75
+ The training corpus contains 2,236,878 syz programs collected from fuzzing
76
+ Linux v6 kernels. Only program text was used for continued pretraining; kernel
77
+ coverage records and downstream reachability labels were not used.
78
+
79
+ The corpus was split into 90% training and 10% validation subsets. Validation
80
+ loss was estimated on 200 batches at each checkpoint evaluation.
81
+
82
+ ## Training procedure
83
+
84
+ StarEncoder was further pretrained for three epochs with a 15% masking rate.
85
+ Masked positions followed the standard BERT policy: 80% were replaced by
86
+ `<mask>`, 10% by a random token, and 10% were left unchanged.
87
+
88
+ | Hyperparameter | Value |
89
+ | --- | --- |
90
+ | Batch size | 32 per GPU, 64 global |
91
+ | Learning rate | 2e-5 |
92
+ | Optimizer | AdamW, betas `(0.9, 0.98)` |
93
+ | Weight decay | 0.01 |
94
+ | Schedule | Cosine decay with 5% warmup |
95
+ | Gradient clipping | 1.0 |
96
+ | Sequence length | Up to 1,024 tokens, dynamic padding |
97
+ | Hardware | 2 NVIDIA A800 80GB GPUs |
98
+ | Training time | About 20.1 hours |
99
+
100
+ The full run completed approximately 94,300 optimizer steps. This release uses
101
+ the step-90,000 checkpoint because it produced the best sampled validation
102
+ loss.
103
+
104
+ ## Evaluation
105
+
106
+ | Checkpoint | Validation loss | MLM perplexity |
107
+ | --- | ---: | ---: |
108
+ | Initial StarEncoder | Not recorded | 2.76 |
109
+ | SyzEncoder, step 90,000 | 0.7660 | 2.15 |
110
+
111
+ The validation metric measures the masked-language-modeling objective on the
112
+ held-out part of the pretraining corpus. It does not measure downstream
113
+ reachability classification accuracy. Results on unrelated code corpora should
114
+ not be inferred from these numbers.
115
+
116
+ ## Usage
117
+
118
+ The example below obtains a mean-pooled representation while ignoring padding
119
+ tokens:
120
+
121
+ ```python
122
+ import torch
123
+ from transformers import AutoModel, AutoTokenizer
124
+
125
+ model_id = "zzra1n/SyzEncoder"
126
+
127
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
128
+ model = AutoModel.from_pretrained(model_id, add_pooling_layer=False)
129
+ model.eval()
130
+
131
+ program = """\
132
+ r0 = socket$inet_tcp(0x2, 0x1, 0x0)
133
+ connect$inet(r0, &(0x7f0000000000)={0x2, 0x0, @loopback}, 0x10)
134
+ """
135
+
136
+ inputs = tokenizer(
137
+ program,
138
+ return_tensors="pt",
139
+ truncation=True,
140
+ max_length=1024,
141
+ )
142
+
143
+ with torch.inference_mode():
144
+ hidden = model(**inputs).last_hidden_state
145
+ mask = inputs["attention_mask"].unsqueeze(-1).to(hidden.dtype)
146
+ embedding = (hidden * mask).sum(dim=1) / mask.sum(dim=1).clamp(min=1)
147
+
148
+ print(embedding.shape) # torch.Size([1, 768])
149
+ ```
150
+
151
+ For supervised use, attach a classification head to the pooled representation
152
+ and fine-tune it on labels from the target fuzzing task.
153
+
154
+ ## Limitations
155
+
156
+ - The training data comes from one domain and kernel generation. Programs from
157
+ other syzkaller versions or substantially different syscall descriptions may
158
+ tokenize and embed differently.
159
+ - Inputs longer than 1,024 tokens are truncated.
160
+ - The released checkpoint has been selected using MLM validation loss. It does
161
+ not include a downstream classifier, calibrated probabilities, or a claim of
162
+ performance on a particular kernel bug.
163
+ - Like its base model, SyzEncoder may retain unwanted behavior inherited from
164
+ its pretraining data. Outputs used for security decisions should be checked
165
+ against execution or coverage evidence.
166
+
167
+ ## License
168
+
169
+ SyzEncoder is a derivative of StarEncoder and is released under the
170
+ [BigCode OpenRAIL-M license](https://huggingface.co/spaces/bigcode/bigcode-model-license-agreement).
171
+ Users are responsible for reviewing and following the license terms and use
172
+ restrictions.
added_tokens.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ {
2
+ "<mask>": 49152
3
+ }
config.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "/home/zhangzy/models/starencoder",
3
+ "architectures": [
4
+ "BertModel"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "classifier_dropout": null,
8
+ "hidden_act": "gelu",
9
+ "hidden_dropout_prob": 0.1,
10
+ "hidden_size": 768,
11
+ "initializer_range": 0.02,
12
+ "intermediate_size": 3072,
13
+ "layer_norm_eps": 1e-12,
14
+ "max_position_embeddings": 1024,
15
+ "model_type": "bert",
16
+ "num_attention_heads": 12,
17
+ "num_hidden_layers": 12,
18
+ "output_hidden_states": true,
19
+ "pad_token_id": 49152,
20
+ "position_embedding_type": "absolute",
21
+ "torch_dtype": "float32",
22
+ "transformers_version": "4.44.2",
23
+ "type_vocab_size": 2,
24
+ "use_cache": true,
25
+ "vocab_size": 49156
26
+ }
merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:84abf53b40d5d00278064c69ebcc552b1ee05c7877992b3b59a01c6935248559
3
+ size 494405304
special_tokens_map.json ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "<|endoftext|>",
4
+ "<fim_prefix>",
5
+ "<fim_middle>",
6
+ "<fim_suffix>",
7
+ "<fim_pad>",
8
+ "<filename>",
9
+ "<gh_stars>",
10
+ "<issue_start>",
11
+ "<issue_comment>",
12
+ "<issue_closed>",
13
+ "<jupyter_start>",
14
+ "<jupyter_text>",
15
+ "<jupyter_code>",
16
+ "<jupyter_output>",
17
+ "<empty_output>",
18
+ "<commit_before>",
19
+ "<commit_msg>",
20
+ "<commit_after>",
21
+ "<reponame>"
22
+ ],
23
+ "bos_token": {
24
+ "content": "<|endoftext|>",
25
+ "lstrip": false,
26
+ "normalized": false,
27
+ "rstrip": false,
28
+ "single_word": false
29
+ },
30
+ "eos_token": {
31
+ "content": "<|endoftext|>",
32
+ "lstrip": false,
33
+ "normalized": false,
34
+ "rstrip": false,
35
+ "single_word": false
36
+ },
37
+ "mask_token": {
38
+ "content": "<mask>",
39
+ "lstrip": false,
40
+ "normalized": false,
41
+ "rstrip": false,
42
+ "single_word": false
43
+ },
44
+ "pad_token": "<|endoftext|>",
45
+ "unk_token": {
46
+ "content": "<|endoftext|>",
47
+ "lstrip": false,
48
+ "normalized": false,
49
+ "rstrip": false,
50
+ "single_word": false
51
+ }
52
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,195 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "added_tokens_decoder": {
4
+ "0": {
5
+ "content": "<|endoftext|>",
6
+ "lstrip": false,
7
+ "normalized": false,
8
+ "rstrip": false,
9
+ "single_word": false,
10
+ "special": true
11
+ },
12
+ "1": {
13
+ "content": "<fim_prefix>",
14
+ "lstrip": false,
15
+ "normalized": false,
16
+ "rstrip": false,
17
+ "single_word": false,
18
+ "special": true
19
+ },
20
+ "2": {
21
+ "content": "<fim_middle>",
22
+ "lstrip": false,
23
+ "normalized": false,
24
+ "rstrip": false,
25
+ "single_word": false,
26
+ "special": true
27
+ },
28
+ "3": {
29
+ "content": "<fim_suffix>",
30
+ "lstrip": false,
31
+ "normalized": false,
32
+ "rstrip": false,
33
+ "single_word": false,
34
+ "special": true
35
+ },
36
+ "4": {
37
+ "content": "<fim_pad>",
38
+ "lstrip": false,
39
+ "normalized": false,
40
+ "rstrip": false,
41
+ "single_word": false,
42
+ "special": true
43
+ },
44
+ "5": {
45
+ "content": "<filename>",
46
+ "lstrip": false,
47
+ "normalized": false,
48
+ "rstrip": false,
49
+ "single_word": false,
50
+ "special": true
51
+ },
52
+ "6": {
53
+ "content": "<gh_stars>",
54
+ "lstrip": false,
55
+ "normalized": false,
56
+ "rstrip": false,
57
+ "single_word": false,
58
+ "special": true
59
+ },
60
+ "7": {
61
+ "content": "<issue_start>",
62
+ "lstrip": false,
63
+ "normalized": false,
64
+ "rstrip": false,
65
+ "single_word": false,
66
+ "special": true
67
+ },
68
+ "8": {
69
+ "content": "<issue_comment>",
70
+ "lstrip": false,
71
+ "normalized": false,
72
+ "rstrip": false,
73
+ "single_word": false,
74
+ "special": true
75
+ },
76
+ "9": {
77
+ "content": "<issue_closed>",
78
+ "lstrip": false,
79
+ "normalized": false,
80
+ "rstrip": false,
81
+ "single_word": false,
82
+ "special": true
83
+ },
84
+ "10": {
85
+ "content": "<jupyter_start>",
86
+ "lstrip": false,
87
+ "normalized": false,
88
+ "rstrip": false,
89
+ "single_word": false,
90
+ "special": true
91
+ },
92
+ "11": {
93
+ "content": "<jupyter_text>",
94
+ "lstrip": false,
95
+ "normalized": false,
96
+ "rstrip": false,
97
+ "single_word": false,
98
+ "special": true
99
+ },
100
+ "12": {
101
+ "content": "<jupyter_code>",
102
+ "lstrip": false,
103
+ "normalized": false,
104
+ "rstrip": false,
105
+ "single_word": false,
106
+ "special": true
107
+ },
108
+ "13": {
109
+ "content": "<jupyter_output>",
110
+ "lstrip": false,
111
+ "normalized": false,
112
+ "rstrip": false,
113
+ "single_word": false,
114
+ "special": true
115
+ },
116
+ "14": {
117
+ "content": "<empty_output>",
118
+ "lstrip": false,
119
+ "normalized": false,
120
+ "rstrip": false,
121
+ "single_word": false,
122
+ "special": true
123
+ },
124
+ "15": {
125
+ "content": "<commit_before>",
126
+ "lstrip": false,
127
+ "normalized": false,
128
+ "rstrip": false,
129
+ "single_word": false,
130
+ "special": true
131
+ },
132
+ "16": {
133
+ "content": "<commit_msg>",
134
+ "lstrip": false,
135
+ "normalized": false,
136
+ "rstrip": false,
137
+ "single_word": false,
138
+ "special": true
139
+ },
140
+ "17": {
141
+ "content": "<commit_after>",
142
+ "lstrip": false,
143
+ "normalized": false,
144
+ "rstrip": false,
145
+ "single_word": false,
146
+ "special": true
147
+ },
148
+ "18": {
149
+ "content": "<reponame>",
150
+ "lstrip": false,
151
+ "normalized": false,
152
+ "rstrip": false,
153
+ "single_word": false,
154
+ "special": true
155
+ },
156
+ "49152": {
157
+ "content": "<mask>",
158
+ "lstrip": false,
159
+ "normalized": false,
160
+ "rstrip": false,
161
+ "single_word": false,
162
+ "special": true
163
+ }
164
+ },
165
+ "additional_special_tokens": [
166
+ "<|endoftext|>",
167
+ "<fim_prefix>",
168
+ "<fim_middle>",
169
+ "<fim_suffix>",
170
+ "<fim_pad>",
171
+ "<filename>",
172
+ "<gh_stars>",
173
+ "<issue_start>",
174
+ "<issue_comment>",
175
+ "<issue_closed>",
176
+ "<jupyter_start>",
177
+ "<jupyter_text>",
178
+ "<jupyter_code>",
179
+ "<jupyter_output>",
180
+ "<empty_output>",
181
+ "<commit_before>",
182
+ "<commit_msg>",
183
+ "<commit_after>",
184
+ "<reponame>"
185
+ ],
186
+ "bos_token": "<|endoftext|>",
187
+ "clean_up_tokenization_spaces": true,
188
+ "eos_token": "<|endoftext|>",
189
+ "mask_token": "<mask>",
190
+ "model_max_length": 1000000000000000019884624838656,
191
+ "pad_token": "<|endoftext|>",
192
+ "tokenizer_class": "GPT2Tokenizer",
193
+ "unk_token": "<|endoftext|>",
194
+ "vocab_size": 49152
195
+ }
vocab.json ADDED
The diff for this file is too large to render. See raw diff