Views
No views yet
growing-transformers-model-16-bit-1-9-181m, an ablation model from the paper:n_embed = 16) derived from the token ID. Because vocab_size = 65,536, the full token ID fits exactly into 16 bits, hence the name “16-bit embedding”.d_model / n_head), but differ in the embedding substrate.n_embed=16 instead of a full-size learned/frozen embedding at d_model). This reduces the embedding-matrix parameters substantially and therefore reduces the overall model size.vocab_size = 65,536id ∈ [0, 65535] is represented as a 16-bit binary vector (0/1 components).d_model=1024) by simple repetition (repeat_interleave as described in the paper).embeddings.txtn_embed=16) + deterministic expansion to d_model (repeat_interleave)1
2import torch
3from transformers import AutoTokenizer, AutoModelForCausalLM
4
5tokenizer = AutoTokenizer.from_pretrained("Bochkov/growing-transformers-model-16-bit-1-9-181m")
6model = AutoModelForCausalLM.from_pretrained("Bochkov/growing-transformers-model-16-bit-1-9-181m", trust_remote_code=True).to('cuda')
7
8inputs = torch.tensor([tokenizer.encode("Write a short poem about the ocean. ")], dtype=torch.long, device='cuda')
9
10outputs = model.generate(
11 inputs,
12 max_new_tokens=50,
13 do_sample=False
14)
15print(tokenizer.decode(outputs[0].tolist()))
16#Write a short poem about the ocean. The song was written by the band and was released on the same day as the album was release
17
18inputs = torch.tensor([tokenizer.encode("Question: What is the capital of India?\nAnswer:")], dtype=torch.long, device='cuda')
19
20outputs = model.generate(
21 inputs,
22 max_new_tokens=10,
23 do_sample=False
24)
25print(tokenizer.decode(outputs[0].tolist()))
26#Question: What is the capital of India?
27#Answer:Mumbai
28# </s><
29nn.Embedding(vocab_size=65536, n_embed=16) whose values are strictly binary (0/1). Each 16-dim vector is then deterministically expanded to d_model=1024 via repeat_interleave(scale=64).1import torch
2from transformers import AutoTokenizer, AutoModelForCausalLM
3
4repo_id = "Bochkov/growing-transformers-model-16-bit-1-9-181m"
5
6tokenizer = AutoTokenizer.from_pretrained(repo_id)
7model = AutoModelForCausalLM.from_pretrained(repo_id, trust_remote_code=True)
8model.eval()
9
10print("vocab_size:", tokenizer.vocab_size)
11print("config:", {k: getattr(model.config, k) for k in ["vocab_size", "n_embed", "d_model", "n_layer", "n_head", "scale"]})
12
13# --- 1) Show embedding matrix shape (should be 65536 x 16) ---
14W = model.token_embeddings.weight.detach().cpu()
15print("token_embeddings.weight shape:", tuple(W.shape)) # (65536, 16)
16
17# --- 2) Tokenize 'A' and show its token id (should be 65 for a unicode-char tokenizer) ---
18text = "A"
19ids = tokenizer.encode(text, add_special_tokens=False)
20tokens = tokenizer.convert_ids_to_tokens(ids)
21
22print(f"text={text!r}")
23print("ids:", ids)
24print("tokens:", tokens)
25
26tid = ids[0]
27
28# --- 3) Print the 16-dim vector and verify it is binary (0/1) ---
29e16 = W[tid] # shape: (16,)
30print("16-dim embedding for token id", tid, ":", e16.tolist())
31
32uniq = torch.unique(e16)
33print("unique values in e16:", uniq.tolist())
34
35is_binary = torch.all((e16 == 0) | (e16 == 1)).item()
36print("is strictly binary (0/1):", is_binary)
37
38# --- 4) Show deterministic expansion to d_model=1024 via repeat_interleave ---
39scale = model.config.scale # should be 1024 // 16 = 64
40e1024 = e16.repeat_interleave(scale) # shape: (1024,)
41print("expanded embedding shape:", tuple(e1024.shape))
42print("expanded embedding first 128 values:", e1024[:128].tolist())
43
44# --- 5) Global check: all embedding weights are exactly 0/1 ---
45is_binary_global = torch.all((W == 0) | (W == 1)).item()
46num_non_binary = torch.numel(W) - torch.sum((W == 0) | (W == 1)).item()
47print("is binary globally (0/1):", is_binary_global)
48print("non-binary entries:", int(num_non_binary))@article{
bochkov2025emergent,
title={Emergent Semantics Beyond Token Embeddings: Transformer {LM}s with Frozen Visual Unicode Representations},
author={Andrey Bochkov},
journal={Transactions on Machine Learning Research},
issn={2835-8856},
year={2025},
url={https://openreview.net/forum?id=Odh8IynO1o},
note={}
}
@misc{bochkov2025growingtransformersmodularcomposition,
title={Growing Transformers: Modular Composition and Layer-wise Expansion on a Frozen Substrate},
author={A. Bochkov},
year={2025},
eprint={2507.07129},
archivePrefix={arXiv},
primaryClass={cs.LG},
url={https://arxiv.org/abs/2507.07129},
}