exactlatents for Qwen3-1.7B
This checkpoint compresses Python functions into continuous latent vectors that a finetuned Qwen3-1.7B decoder reads in place of tokens. The system is trained for byte-exact reconstruction while reducing the number of decoder context slots used by the encoded function.
The companion code is at github.com/LabGuy94/exactlatents.
Architecture
The released checkpoint contains three jointly used components:
- Encoder: a 1.62B-parameter Qwen3 trunk with its final two transformer layers removed.
- Latent pooler and projector: 0.03B parameters, including learned boundary embeddings.
- Decoder: a 2.03B-parameter finetuned Qwen3 causal language model.
The encoder groups token states at pooling factor 4, the latent pooler produces continuous vectors, and the projector maps those vectors into the decoder embedding space. The decoder then reconstructs or reasons over the latent sequence directly.
Results
All reported results use one seed, Python only, and Qwen3-1.7B as the only base model.
| Evaluation | Latent checkpoint | Comparison |
|---|---|---|
| OOD-600, pooling factor 4, byte-exact | 527 / 600 | finetuned text-copy: 565 / 600 |
| OOD-600, pooling factor 4, code-exact | 577 / 600 | finetuned text-copy: 584 / 600 |
| Canary development set, byte-exact | 30 / 36 | โ |
| Canary development set, code-exact | 35 / 36 | โ |
| Fully out-of-distribution comprehension QA | 39.0% | text: 39.6% |
| Retention probe | 19 / 24 | stock model: 24 / 24 |
At pooling factor 4, OOD-600 examples used a mean of 3.73ร fewer decoder context slots. This setting targets 4ร fewer decoder context slots; it is not a claim of 4ร storage compression because a bf16 latent vector contains far more bits than one token id.
OOD-600 code-exact reconstruction by pooling factor was 577 / 600 at factor 4, 522 / 600 at factor 6, 389 / 600 at factor 8, and 6 / 600 at factor 12. Fully out-of-distribution comprehension was statistically indistinguishable from text in the reported evaluation.
Loading
Install the package from the companion repository, place these files in weights/, and construct the released architecture before loading:
from pathlib import Path
import torch
from transformers import AutoConfig, AutoModelForCausalLM
from compressor import Compressor
from compressor.ft_load import load_decoder, load_encoder, load_projector
base_model = "Qwen/Qwen3-1.7B"
weights = Path("weights")
dtype = torch.bfloat16
hidden = AutoConfig.from_pretrained(base_model).hidden_size
decoder = AutoModelForCausalLM.from_pretrained(
base_model, dtype=dtype
).eval()
compressor = Compressor(
encoder_name=base_model,
decoder_hidden=hidden,
pooling_factor=4,
proj_width=None,
proj_depth=2,
pooling="latent",
boundary=True,
bidirectional=False,
dtype=dtype,
).eval()
load_encoder(compressor, weights / "model.safetensors")
load_decoder(decoder, weights / "model.safetensors")
load_projector(compressor.projector, weights / "projector_ema.safetensors")
Move the modules to the desired device after loading, or adapt construction to the memory strategy described in the companion repository.
File format
Both safetensors files carry metadata {"format": "exactlatents.full_state.v1"}.
model.safetensorshas flat keysenc.<key>,dec.<key>, andprojector.<key>for the truncated encoder, decoder, and live projector state dictionaries.projector_ema.safetensorshas flat keysema.<key>for the released EMA projector state dictionary.
compressor.ft_load recognizes these prefixes. To load the live projector rather than the released EMA projector, call load_projector(compressor.projector, weights / "model.safetensors", prefer="live").
SHA256SUMS records hashes for the published files and their provenance. The safetensors files were converted from the original consolidated .pt checkpoint without changing tensor values, apart from cloning aliased storage when required by the safetensors format.
Limitations
The evidence is limited to one training seed, one programming language, and one base model. Reconstruction quality falls sharply at larger pooling factors, and the retention result shows a measurable loss relative to the stock model. Continuous vectors should not be interpreted as compact serialized token replacements: their benefit here is fewer decoder context slots.