Janus-Pro-1B depth patch: weight-space programming, no training

DeepSeek's Janus-Pro-1B is one autoregressive transformer that both reads images and draws them. This repository does not contain the model. It contains a 228 KB patch that changes 12,288 of its 2,076,636,811 weights, and a script that downloads the official checkpoint and applies it.

On simple drawn scenes the unchanged model often gets depth wrong: asked whether an object is in the foreground, it answers "background". Yet a linear readout of its layer-23 state gets the answer right on every held-out scene: it already knows the answer, it just doesn't say so. Weight-space programming enables that hidden feature. Two neurons of layer 23's MLP are rewritten in closed form (a gate row and an up row that detect the question and read the depth state, and a down column that pushes the answer word), fitted with ridge regression on recorded activations. No gradient step was taken.

The work was driven by an AI programmer, Kimi K3.1 Pro on Cerebras, over one night.

Result: final test, both rules installed together

128 new scenes per question that were never used to fit or tune the rules, characters facing the camera and turned away.

Question Unchanged model Patched Lowest orientation
"Is the {object} in the foreground or in the background?" 68.8% 100% (128/128) 100%
"Is the {object} close to the camera or far away?" 55.5% 99.2% (127/128) 98.4%

Everything else stays put:

Check Result Limit
Accuracy change on 4 other question types (which hand, viewer side, nearer, orientation) 0.0 points each no loss
Other answers word-for-word identical 95.3% to 100% per question type at least 95%
Caption distribution shift (mean KL) 3.1e-6 below 0.01
Image-generation distribution shift (mean KL) 1.7e-4 below 0.01
Original weights restored after removing the patch bit for bit exact

Ablations: keeping the patch but removing only the gate edit, or only the output edit, sends the depth questions back to the unchanged model's level (66–71% and 55–57%), so both parts of each rule are needed. The full report is final_report.json.

Try it

pip install torch transformers huggingface_hub pillow numpy
python apply_patch.py                 # the three example scenes, before and after (CPU works; a few minutes)
python apply_patch.py --image my.png --question "Is the tree in the foreground or in the background?"

Expected output for the bundled examples (examples/answers.json):

examples/scene_20016.png  Is the car in the foreground or in the background?  (truth: foreground)
  unchanged model:  The car is in the background.
  programmed model: The car is in the foreground.

In your own code:

from apply_patch import load_base, apply, revert, ask
model, processor = load_base("cuda")
originals = apply(model)        # checks every tensor's SHA-256 before and after
print(ask(model, processor, image, "Is the car in the foreground or in the background?"))
revert(model, originals)        # back to the official weights, bit for bit

The model must be loaded in float32: the patch was fitted against float32 weights and is smaller than bfloat16 rounding. The base is pinned to revision 1655280bb75959cc1cb85529a2a8b26e7016072e; apply refuses any other weights.

Files

Path What it is
patch/manifest.json One entry per edited tensor: name, shape, dtype, SHA-256 of the tensor before and after, the answer tokens it depends on
patch/000N_indices.npy, patch/000N_values.npy Flat indices into the tensor and the values added there (4,096 per tensor)
apply_patch.py Download the base, verify, apply, ask, revert (needs only transformers)
examples/ Three test-time scenes with the question, the truth and both models' answers
final_report.json The final-test evaluation: per-cell accuracy with confidence intervals, controls, ablations, KL checks

Edited tensors: model.language_model.layers.23.mlp.{gate_proj, up_proj, down_proj}.weight, neurons 2407 and 2704.

Scope and limits

  • The scenes are simple synthetic drawings (a character, a held object, a depth object, a free object). The rule was fitted and tested on that distribution only; it is not a general fix for depth perception in photographs.
  • Two question wordings were targeted. Other wordings may not trigger the rule.
  • Rules for "which hand?" and "which side?" are still being fitted and are not part of this patch.

License

Janus-Pro-1B is released by DeepSeek under the DeepSeek Model License, and this patch is a Derivative of the Model under that license. Its use-based restrictions (paragraph 5 and Attachment A) apply to the patched model; anyone you distribute it to must receive the same notice.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for dataphysician/janus-pro-1b-wsp-depth-patch

Finetuned
(2)
this model