Experiments with modular neural networks by patching pre-trained LLMs.
All experiments use the open-source model qwen/qwen3.5-9b.
Relevant configuration:
The embedding layer and output head each contain approximately:
4096 × 248320 ~ 1.02B parameters
The original token embedding Embedding(V=248320, D=4096) is replaced with a composite embedding layer with:
So that a tensor of shape (B, 32 * S) is processed into (B, S, 32 * 128) = (B, S, 4096).
Then a regular transformer block maps these composite embeddings with the original emebddings of the Qwen model.
Input text is tokenized using the original Qwen tokenizer.
Each token string is encoded as UTF-8 bytes.
Shorter tokens are then padded into a block of 32 bytes and the longer tokens are truncated.
The training was performed on a multilingual corpora with a custom loss:
$$L_{k} = || H_{k, patch}(x) − H_{k, qwen}(x) ||^{2}$$
Where:
Original output head Linear(4096 => 248320) is replaced by a hierarchical softmax tree.
Tokens are organized in a binary tree with a depth of 18 ~ log_2(248320)
Each token corresponds to a unique path from root to leaf.
Here a simple cross entropy loss is enough.
Licensed under the aGPLv3.
Python
100.0%
Experiments with modular neural networks by patching pre-trained LLMs.
All experiments use the open-source model qwen/qwen3.5-9b.
Relevant configuration:
The embedding layer and output head each contain approximately:
4096 × 248320 ~ 1.02B parameters
The original token embedding Embedding(V=248320, D=4096) is replaced with a composite embedding layer with:
So that a tensor of shape (B, 32 * S) is processed into (B, S, 32 * 128) = (B, S, 4096).
Then a regular transformer block maps these composite embeddings with the original emebddings of the Qwen model.
Input text is tokenized using the original Qwen tokenizer.
Each token string is encoded as UTF-8 bytes.
Shorter tokens are then padded into a block of 32 bytes and the longer tokens are truncated.
The training was performed on a multilingual corpora with a custom loss:
$$L_{k} = || H_{k, patch}(x) − H_{k, qwen}(x) ||^{2}$$
Where:
Original output head Linear(4096 => 248320) is replaced by a hierarchical softmax tree.
Tokens are organized in a binary tree with a depth of 18 ~ log_2(248320)
Each token corresponds to a unique path from root to leaf.
Here a simple cross entropy loss is enough.
Licensed under the aGPLv3.
Python
100.0%