File size: 13,083 Bytes
094b947
 
05ffa5e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
094b947
05ffa5e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ae77604
05ffa5e
ae77604
 
 
 
 
 
 
 
 
 
05ffa5e
ae77604
05ffa5e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ae77604
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
---
license: apache-2.0
language:
- en
library_name: transformers
pipeline_tag: text-generation
base_model: VeroLM/NoTokenLM-Gen-5.5
tags:
- notokenlm
- notoken_gen55
- byte-level
- tokenizer-free
- hybrid
- hierarchical
- code
- code-generation
- custom_code
datasets:
- OpenCoder-LLM/opc-sft-stage2
- OpenCoder-LLM/opc-annealing-corpus
- nvidia/OpenCodeInstruct
- m-a-p/CodeFeedback-Filtered-Instruction
- ise-uiuc/Magicoder-OSS-Instruct-75K
- ise-uiuc/Magicoder-Evol-Instruct-110K
- bigcode/self-oss-instruct-sc2-exec-filter-50k
- bigcode/the-stack-dedup
- bigcode/starcoderdata
---

# CodeGen-5.5

**CodeGen-5.5** is a **tokenizer-free, byte-level language model for code**. It is [NoTokenLM-Gen-5.5](https://huggingface.co/VeroLM/NoTokenLM-Gen-5.5) further trained on source-code files and code instruction data. There is no vocabulary and no BPE: UTF-8 bytes go in, UTF-8 bytes come out. Instead of spending a full forward pass on every byte, the model groups bytes into variable-length *patches* (about 5 bytes on code) and runs its large trunk once per patch.

It can **complete code** and it can **follow a simple plain-text instruction template** (`### Instruction:` / `### Response:`). It is a small research model (≈ 169 M parameters): its code often has the right shape but is frequently wrong, so treat every output as untrusted.

|                |                                                                                              |
| -------------- | -------------------------------------------------------------------------------------------- |
| Base model     | [`VeroLM/NoTokenLM-Gen-5.5`](https://huggingface.co/VeroLM/NoTokenLM-Gen-5.5)                |
| Parameters     | **168.9 M** in total (incl. a 19.9 M hash-embedding table and a frozen 4.5 M entropy patcher) |
| Input / output | raw UTF-8 bytes (`0..255`), byte `0` = end of document                                       |
| Context window | 4,096 bytes (the training window)                                                            |
| Trunk          | 20 layers, `d = 768`, 5 × [RWKV-7, gated attention, RWKV-7, RWKV-7]                          |
| Fine-tuning    | 7,662 steps on TPU v5e-8, ≈ 8 GB of text: code files (5.5 GB budget) + code instruction data (3.5 GB budget) |
| Weights        | EMA weights of the final checkpoint, fp32                                                    |
| License        | Apache-2.0 (see the note on data licenses below)                                             |

## Architecture

The architecture is identical to the base model:

```
bytes ─► byte embedding + hashed n-gram embedding (orders 3-8) + ROSA suffix-match features
      ─► local encoder (conv, conv, windowed attention; d = 256)
      ─► entropy-based patching (max 16 bytes) ─► attention pooling
      ─► trunk over patches: 5 × [RWKV-7 · NoPE gated attention · RWKV-7 · RWKV-7]  (d = 768, SwiGLU)
      ─► local decoder (4 windowed-attention blocks; d = 256) ─► 256-way next-byte logits
```

- **Entropy patching.** A small frozen causal convolutional byte model predicts the next byte; wherever its entropy is above a calibrated threshold (`theta`, stored in `config.json`), a new patch starts. The patcher was **not** retrained for CodeGen-5.5, so patch boundaries follow the same rule as in the base model. Patches are somewhat shorter on code (≈ 5 bytes on average, against ≈ 6 on general text).
- **Hybrid trunk.** RWKV-7 layers carry most of the sequence mixing, with one gated, QK-normed, position-free attention layer in every block.
- **Past-only hashed n-gram embeddings** (orders 3–8), **ROSA** suffix-match features (a copy mechanism that feeds the predicted next byte and match length into the encoder and the output logits) and **DeepEmbed** (per-byte scaling of local FFN activations).

Only *closed* patches are passed from the trunk to the decoder, which is what makes generation cheap.

## Quick start

Requires `torch`, `transformers` and `safetensors`. `trust_remote_code=True` is needed because the architecture ships with the weights.

```python
from transformers import AutoModelForCausalLM

model = AutoModelForCausalLM.from_pretrained("VeroLM/CodeGen-5.5", trust_remote_code=True).eval()

prompt = (
    "### Instruction:\n"
    "Write a Python function that returns the n-th Fibonacci number.\n\n"
    "### Response:\n"
)
print(model.generate_text(prompt, max_new_tokens=300, temperature=0.4, seed=0))
```

Plain code completion (no template) works too; about 60 % of the fine-tuning budget was ordinary source files:

```python
prompt = 'def is_prime(n: int) -> bool:\n    """Return True if n is a prime number."""\n'
print(model.generate_text(prompt, max_new_tokens=200, temperature=0.3, seed=0))
```

Working with raw byte ids (this is what `generate_text` does internally):

```python
import torch

ids = torch.tensor([list(prompt.encode("utf-8"))])
out = model.generate(ids, max_new_tokens=200, temperature=0.4, top_p=0.95, seed=0)   # LongTensor (1, T + new)
print(bytes(b for b in out[0].tolist() if b != 0).decode("utf-8", errors="replace"))
```

`generate` supports `temperature`, `top_k`, `top_p`, `do_sample=False` (greedy), `seed` and `stop_at_eod`. Generation stops when the model emits byte `0` (end of document). Because the model works on bytes, a cut-off multi-byte character is possible at the end of a generation; decode with `errors="replace"`. Run in **float32** (the default). For code, temperatures around 0.2–0.5 usually work best.

There is also an interactive playground notebook that supports both modes (instruction and completion).

## Prompt format

Instruction data was converted to a plain-text template. The model has no special tokens; the end-of-document byte (`0`) follows every training example.

```
### Instruction:
<task>

### Response:
<answer>
```

Multi-turn data repeats the two blocks, and an optional `### System:` block exists for data that has a system message. After its answer the model may continue with further, self-invented `### Instruction:` blocks until it emits the end-of-document byte; cut the output at the next `### Instruction:` if you only want the first answer.

## Training

CodeGen-5.5 starts from the EMA weights of the finished NoTokenLM-Gen-5.5 run, with a fresh optimizer and a step counter of 0.

**Data.** A single stream, **one pass**: every source is read once and never repeated. Instruction data is converted to the template above; code files are used as they are (nothing is rewritten, files over 300 kB and near-empty files are dropped). Instruction data is de-duplicated with a Bloom filter, and a small slice of every source is held out for evaluation.

| Group | Budget | Sources |
| ----- | ------ | ------- |
| **Source code files** | 5.5 GB | Stack-Edu Python (the largest share), The Stack (dedup) for JavaScript, TypeScript, Java, C, Go, Rust, Shell and SQL, StarCoder data for C++, and the OpenCoder annealing corpus |
| **Code instruction data (SFT)** | 3.5 GB | OpenCoder `opc-sft-stage2`, `OpenCodeInstruct`, `CodeFeedback-Filtered-Instruction`, `Magicoder-OSS-Instruct-75K`, `Magicoder-Evol-Instruct-110K`, `self-oss-instruct-sc2-exec-filter-50k` |

The budgets are upper limits. Sources smaller than their share (several instruction sets) were used completely and the remainder was redistributed, so the amount actually seen is lower: the run processed ≈ 8 GB (7,662 steps of 1,048,576 bytes) in total.

**Setup.**

| | |
| --- | --- |
| Hardware | TPU v5e-8 (data parallel, 8 chips) |
| Batch | 256 windows × 4,096 bytes = 1,048,576 bytes / step |
| Steps | 7,662 |
| Optimizer | Muon + AdamW (as in the base run), EMA 0.999 |
| Learning rate | peak 2.5e-4, 100 warm-up steps, then constant, with linear decay to 2 % of the peak over the last 20 % of the steps (the base run's peak was 1.5e-3: the base model had already converged, so a lower rate protects what it already knows) |
| Objective | causal next-byte prediction only (no masked steps) |
| Patch slots per window | `max_patches = 1536` |
| Precision | bfloat16 compute, fp32 weights |

## Evaluation

### Held-out bits per byte

Bits per byte (lower is better) of the EMA weights on small held-out slices of each training source, measured during training (last evaluation, step 7,500 of 7,662). Instruction data was scored in the same template used for training.

| Group | Mean bpb | Step 2,000 → step 7,500 |
| ----- | -------- | ----------------------- |
| All sources | 0.591 | 0.644 → 0.591 |
| Code files | 0.696 | 0.754 → 0.696 |
| Instruction data | 0.399 | 0.443 → 0.399 |

| Code files | bpb | | Instruction data | bpb |
| ---------- | --- | --- | ---------------- | --- |
| Python | 0.66 | | OpenCodeInstruct | 0.28 |
| JavaScript | 0.60 | | OpenCoder SFT | 0.41 |
| TypeScript | 0.50 | | CodeFeedback | 0.32 |
| Java | 0.46 | | Magicoder OSS-Instruct | 0.36 |
| Go | 0.52 | | Magicoder Evol-Instruct | 0.65 |
| C++ | 0.61 | | self-oss-instruct | 0.37 |
| C | 0.72 | | | |
| Rust | 0.73 | | | |
| Shell | 0.96 | | | |
| SQL | 1.45 | | | |
| OpenCoder annealing | 0.43 | | | |

These are language-modelling numbers on slices that are small, so they are noisy, and they say little about whether generated code *works*; they cannot be compared across sources (different data have different intrinsic entropy) or with the bpb of the base model on general text. Shell and SQL are clearly the hardest.

### Benchmarks

Zero-shot accuracy (%) of the EMA weights, with the standard error and the number of correct answers out of all questions. The base-model column is copied from the [base model card](https://huggingface.co/VeroLM/NoTokenLM-Gen-5.5#evaluation). The general-knowledge rows are listed because specialising on code can cost general ability.

| Benchmark | NoTokenLM-Gen-5.5 (base) | CodeGen-5.5 | Correct / total |
| --------- | :----------------------: | :---------: | :-------------: |
| HumanEval (pass@1) | – | *to be added* | – |
| MBPP (pass@1) | – | *to be added* | – |
| HellaSwag | 34.32 | 32.87 ± 0.47 | 3301 / 10042 |
| ARC-Easy | 38.68 | 35.27 ± 0.98 | 838 / 2376 |
| PIQA | 60.77 | 57.73 ± 1.15 | 1061 / 1838 |
| ArithMark3 (v3.0) | 37.20 | 37.90 ± 1.53 | 379 / 1000 |
| Tiny ToM (Tiny Theory of Mind) | 38.15 | 35.95 ± 1.07 | 719 / 2000 |
| BananaMind Base Bench (v1.1) | 54.57 | 56.57 ± 2.65 | 198 / 350 |

As expected, most general-knowledge scores dropped by one to three points after the code fine-tuning (HellaSwag, ARC-Easy, PIQA, Tiny ToM), while ArithMark3 and BananaMind Base Bench are slightly higher. Several of these differences are within about one to two standard errors (ArithMark3, BananaMind and HellaSwag in particular), so they should not be over-interpreted. The coding benchmarks (HumanEval, MBPP) are still to be added.


## Intended use and limitations

- **Intended for:** research on byte-level / tokenizer-free and patch-based models, studying how such a model adapts to code, and experiments with a small code-capable base.
- **Not for:** production code generation, code that is run without review, security-sensitive code, factual question answering, or general chat. There is no safety tuning and no preference tuning of any kind.
- **Small model.** With about 169 M parameters, expect code that has the right overall shape but contains logic errors, wrong API usage, invented functions and syntax mistakes.
- **Short context.** The window is 4,096 *bytes* (a few hundred lines at most), not tokens. Long files and multi-file context do not fit.
- **Languages.** Python is the largest share of the code data. JavaScript, TypeScript, Java, C, C++, Go, Rust, SQL and Shell are present in smaller amounts and SQL and Shell are weak. Other languages are not part of the fine-tuning data. Instruction data is mostly English.
- **Template, not chat.** The `### Instruction:` / `### Response:` format is a plain-text convention, not a chat interface.
- **Possible memorisation.** Like any model trained on public source code, it may reproduce licensed code, or code containing secrets or vulnerabilities, from its training data.
- **Data licenses.** The weights are released under Apache-2.0, but the training data comes from several sources with their own terms (some instruction sets are synthetic and were generated with other language models; The Stack and StarCoder data are gated and restricted to permissively licensed code, with their own conditions). Check the individual dataset cards before commercial use.

## Repository contents

| File | What it is |
| ---- | ---------- |
| `model.safetensors` | EMA weights (fp32), including the frozen entropy patcher under the `patcher.` prefix |
| `config.json` | architecture hyper-parameters, calibrated patch threshold `theta`, training step |
| `configuration_notoken_gen55.py`, `modeling_notoken_gen55.py` | PyTorch implementation (inference) |
| `tokenization_notoken_gen55.py`, `tokenizer_config.json` | trivial byte "tokenizer" (`id == byte value`) |

## License

Apache-2.0. See the notes on data licenses above.