Skip to main content

Deformers apehex logo

License Latest

Experiments with modular neural networks by patching pre-trained LLMs.

Original Model

All experiments use the open-source model qwen/qwen3.5-9b.

Relevant configuration:

  • hidden size: 4096
  • number of layers: 32
  • vocabulary size: 248320
  • embedding size: 4096
  • positional encoding: rotary
  • embedding weights are not tied with the output head

The embedding layer and output head each contain approximately:

4096 × 248320 ~ 1.02B parameters

Patching Layers

Composite Embedding (Prefix Patch)

Frozen components

  • tokenization (Qwen BPE tokenizer)
  • transformer trunk (all the hidden transformer layers)
  • positional encoding
  • output head

Replaced component

The original token embedding Embedding(V=248320, D=4096) is replaced with a composite embedding layer with:

  • a group dimension of 32
  • an input dimension of 256 (byte values)
  • an embedding dimension of 128
  • for a total of 256 * 128 = 32768 parameters

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 representation

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.

Patch Training

The training was performed on a multilingual corpora with a custom loss:

$$L_{k} = || H_{k, patch}(x) − H_{k, qwen}(x) ||^{2}$$

Where:

  • $k$ is the depth inside the original Qwen 3.5 model
  • $H_{k, qwen}$ is the hidden state at depth $k$ in the original model
  • $H_{k, patch}$ is the hiden state obtained when replacing the embedding layer

Hierarchical Softmax Head

Frozen components

  • tokenizer
  • embedding layer
  • positional encoding
  • transformer trunk (all the hidden layers)

Replaced component

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.

Patch Training

Here a simple cross entropy loss is enough.

License

Licensed under the aGPLv3.

Metadata

Release files for deformers 0.10.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for deformers 0.10.1
File Size Uploaded Provenance Actions
deformers-0.10.1.tar.gz 31.4 kB Without provenance Details for deformers-0.10.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for deformers 0.10.1
File Interpreter ABI Platform Actions
deformers-0.10.1-py3-none-any.whl Python 3 none any Details for deformers-0.10.1-py3-none-any.whl

Total release size: 69.3 kB

Release files / deformers-0.10.1.tar.gz

Download URL deformers-0.10.1.tar.gz
Size 31.4 kB
Tags Source
SHA-256 checksum
How to use checksums
69e05f94d27d472e8bdc03e354ce739fede7c46dd051a6411734ef1f56adc195
BLAKE2b-256 checksum
How to use checksums
c3e26a590e9239bfb0f433b2344eeeabe00845b0ed39529fd26b621af99b6232
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / deformers-0.10.1-py3-none-any.whl

Download URL deformers-0.10.1-py3-none-any.whl
Size 38.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6bbdba4e01e79b56bca398bbc89ec8264892efb337f45b81618d22557c64b6bb
BLAKE2b-256 checksum
How to use checksums
ae5870c4e5b1d4c4067d2c4744ea35109caa1439b3c3354836bbd79b324ea29e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for deformers 0.10.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.10.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page