Downloads · 30 days
0
upseem/deepseek-v4-flash-vision-abliteration-method
deepseek-v4-flash-vision-abliteration-method is a machine learning model from upseem. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as mit.
This repository contains method documentation only. No model weights are included.
Downloads · 30 days
0
Access
Public
Updated Sep 4, 2026
Repo size
—
Likes
0
Public
Click a slice to open those files.
.md10.7 KB · 88%
From the Hugging Face model README
This repository contains method documentation only. No model weights are included.
目标:只记录方法,不下载/拷贝权重。
依据:orcarouter/DeepSeek-V4-Flash-Vision-Uncensored模型卡公开描述 + Arditi et al. 2024。
用途:后续你自己在有 GPU / 权重授权的环境里复现;本文不是生产部署指南。
| 角色 | 链接 |
|---|---|
| 官方基座(原始训练发布) | https://huggingface.co/deepseek-ai/DeepSeek-V4-Flash-Vision-Exp |
| 方法来源(abliterated 成品卡,流程描述出处) | https://huggingface.co/orcarouter/DeepSeek-V4-Flash-Vision-Uncensored |
| 同作者 GGUF 转格式(可选,仍无本文权重) | https://huggingface.co/orcarouter/DeepSeek-V4-Flash-Vision-Uncensored-GGUF |
| 经典 abliteration 论文 Arditi et al. 2024 | https://arxiv.org/abs/2406.11717 |
| 对照:Heretic / ARA(另一条算法,不是本流程) | https://github.com/p-e-w/heretic |
| 本方法笔记仓 | https://huggingface.co/upseem/deepseek-v4-flash-vision-abliteration-method |
复现时:权重从 基座 取;步骤从 orcarouter 模型卡 取;本仓只存笔记。
这是 Arditi 单方向 abliteration(拒绝方向正交化),再 按 shard 写回官方混合精度(FP4/FP8/BF16)。
它和你做过的 Heretic ARA 同属「改权重卸拒答」大类,但算法不同:
| 经典 Abliteration(本笔记) | Heretic ARA(你的 Qwen 配方) | |
|---|---|---|
| 核心对象 | 一条(或少数)拒绝方向 r | 不估全局 r |
| 编辑方式 | W' = W − r(rᵀW) 投影 | hook 抓模块 I/O,L-BFGS/闭式优化矩阵 |
| 超参搜索 | 层/读点扫 + 简单质量分 | Optuna TPE(拒答数 vs KL) |
| DeepSeek 额外难点 | mHC 读点 + FP4 约束再量化 + 流式 bake | ARA 默认路径通常假设可加载的 dense/常见 MoE |
不要指望把 Heretic ARA recipe 直接套到 V4-Flash-Vision 官方 FP4 checkpoint 上就完事。
deepseek-ai/DeepSeek-V4-Flash-Vision-ExpDeepseekV4ForCausalLM;43 transformer 层 + 3 MTP/DSpark;hidden 4096;DeepSeek sparse attention;256 routed experts top-6 + 1 shared;4-wide mHC;原生 vision tower + aligner;上下文 1M;词表 129280e2m1(2/byte)+ ue8m0 per-32 scalese4m3 128×128 + ue8m0论文:Refusal in Language Models Is Mediated by a Single Direction(arXiv:2406.11717)。
r ∝ mean(harmful) − mean(harmless)(可加归一化 / massive-activation mask)。W' = W − r (rᵀ W)
使前向不再容易表达该方向 → 拒答率下降。
DeepSeek-V4 的结构坑(社区分析 + orcarouter 卡片一致):
hc_mult × d(这里 4×4096)。r,方向在错误空间。output_hidden_states 的加宽流当主读点。input_layernorm → attention 读点post_attention_layernorm → MoE 读点bypass − kl_penalty · kl_norm − induced_benign_refusal(10 候选扫)。Hook 消融(不 bake,只临时消方向)在验证集上的相对形态(卡片数字,供对照):
| 读点 / 层 | 有害拒答率(越低越好) |
|---|---|
| baseline | 0.917 |
| MoE L15 | 0.667 |
| MoE L28(出货) | 0.042 |
| MoE L32 | 0.125 |
| attention 最佳 | 0.417 |
k = 1 单方向(不是 SOMA/ARA 的多方向优化)。| 写入者 | 精度 | 规模(卡片) |
|---|---|---|
layers.*.ffn.experts.*.w2 + mtp.* experts w2 | FP4 | 11,776 |
layers.*.attn.wo_b + mtp | FP8 | 46 |
layers.*.ffn.shared_experts.w2 + mtp | FP8 | 46 |
embed(行空间) | BF16 | 1 |
aligner.w2 | BF16 | 1 |
image_start/end/newline/pad | BF16 | 4 |
| 合计 | 11,874 |
刻意不动:hc_* mixer、MoE router(ffn.gate 等)、专家 w1/w3、视觉塔主体、lm_head。
理由(卡片):mHC 的 comb 双随机、post 分支标量,都是分支内线性;清干净 4096-d 写入者即可,mHC 不会把方向「混回来」。
.weight matcher 抓不到 11k+ 专家 w2,却仍可能报 success。transformers 文本加载会丢掉 vision / aligner / image vectors / MTP,save_pretrained 会静默缺件。→ 按 model.safetensors.index.json 流式读 shard → 改 → 写回,保持格式与索引不变。
Naive:
quantize(W − r rᵀ W) # round-to-nearest
在真实方向上泄漏约:FP4 67% / FP8 36%(卡片),且是固定点,迭代无效。
他们的做法:对每列 j 解约束量化
min_q ‖q − W[:,j]‖²
s.t. rᵀ q = 0
q ∈ FP4/FP8 网格
Lagrangian 形式:quantize(W[:,j] + λⱼ r),对 λ 二分(约束对 λ 单调),再单码微调 + 块内 ue8m0 scale 共优化。
目标:输出是运行时 dequant/requant 的固定点 → 加载后方向仍被压住。
卡片声称约束后再泄漏 ~0.001% / 0.045%;权重扰动约 3.7%(FP4)/ 2.1%(FP8)。
安全(有害拒答,越低越「uncensored」)
| 集 | Base | Abliterated |
|---|---|---|
| MaliciousInstruct | 0.940 | 0.020 |
| JailbreakBench harmful | 0.910 | 0.020 |
| AdvBench | 0.980 | 0.080 |
| ForbiddenQuestions | 0.853 | 0.113 |
| SimpleSafetyTests | 0.900 | 0.160 |
过拒
| 集 | Base | Abliterated |
|---|---|---|
| XSTest-safe | 0.092 | 0.004 |
| JailbreakBench benign | 0.140 | 0.000 |
能力(抽样):MMLU / MMLU-Pro / GSM8K 变化在 ±1pp 内。
视觉通道:方向在文本上拟合;VLSBench 原问题几乎不触发拒答。他们把指令改成「action-seeking」后,base 图条件拒答 ~0.583 → abliterated ~0.025。视觉塔字节级不动,只动了 aligner.w2 + 四个 image token。
在你自己有盘、有卡、有基座授权的环境:
Phase A — 只估方向(轻)
r.pt。Phase B — 写 shard baker
w2,测 ‖rᵀW‖ bake 前后比。Phase C — 全量 bake + 校验
Phase D — 评测
本机(Grok Bot)明确不做:不下载 ~157 GiB 权重;不上传 uncensored 成品当默认助手。
r、按模块优化」目标函数;默认假设可 transformers 完整加载再 save。若你想「更像 ARA」:那是另一条研究线(模块 I/O 优化 / 专家级编辑),需要另开设计;本笔记只锁定 orcarouter 公开的经典路径。
date:
base_rev / commit:
hardware:
direction:
layer:
read_point: moe | attn
n_harmful / n_harmless:
mask:
bake:
fp4_leakage_before / after:
fp8_leakage_before / after:
shards_edited:
eval:
harmful_refusal:
xstest_safe:
mmlu_delta:
notes: