Instructions to use benzeng/MiniCPM5-2B-orth-r23 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use benzeng/MiniCPM5-2B-orth-r23 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="benzeng/MiniCPM5-2B-orth-r23") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("benzeng/MiniCPM5-2B-orth-r23") model = AutoModelForCausalLM.from_pretrained("benzeng/MiniCPM5-2B-orth-r23", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use benzeng/MiniCPM5-2B-orth-r23 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "benzeng/MiniCPM5-2B-orth-r23" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "benzeng/MiniCPM5-2B-orth-r23", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/benzeng/MiniCPM5-2B-orth-r23
- SGLang
How to use benzeng/MiniCPM5-2B-orth-r23 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "benzeng/MiniCPM5-2B-orth-r23" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "benzeng/MiniCPM5-2B-orth-r23", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "benzeng/MiniCPM5-2B-orth-r23" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "benzeng/MiniCPM5-2B-orth-r23", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use benzeng/MiniCPM5-2B-orth-r23 with Docker Model Runner:
docker model run hf.co/benzeng/MiniCPM5-2B-orth-r23
MiniCPM5-2B-orth-r23
🖥️ 全部研究在一块 GTX 1060 6GB 消费级显卡上完成(WSL2,无云资源)。 All research was done on a single consumer GTX 1060 6GB.
研究标本:对 openbmb/MiniCPM5-2B(标准 Llama 架构、 42 层思维链模型)做拒绝方向权重正交化(abliteration)后的派生模型。 方法复现自 Arditi et al. (2024);消融方向经生成式因果选层定位于第 23/42 层(55% 深度)。
⚠️ 免责声明 — 使用前必读
本模型的安全对齐已被部分移除(拒绝方向从残差流写入矩阵中正交化消除):
- 它对大部分有害/违法/不道德请求会顺从,内置护栏显著削弱(注意:非完全移除,见"局限");
- 仅面向正当研究发布:可解释性、AI 安全与拒绝机制研究、红队、鲁棒性评估;
- 使用者对生成内容承担全部责任;不要在未加自有安全层的情况下部署给终端用户;
- 使用须遵守基座模型的 Apache-2.0 协议及适用法律。作者不对任何滥用后果负责。
下载或使用即表示你已知晓并接受上述条款。
效果(held-out test,n=32,本地实测,无任何运行时 hook)
| 条件 | 基座 | 本模型 |
|---|---|---|
| 英文有害指令拒绝率 | 0.50 | 0.12 |
| 中文有害指令拒绝率 | 1.00 | 0.72(顽固残留,见局限) |
| 英文无害指令拒绝率(过度拒绝) | 0.00 | 0.03 |
已知局限(如实声明)
- 顽固残留:该模型的拒绝是"多通路"的——rank-1 消融残留 12–22%(集中在仇恨言论、 对未成年人犯罪指引等高危类别)。hook 式 k=16 子空间消融可清零,但会损伤良性任务 (代码等结构化输出在 k≥8 开始退化),故本权重版保留 rank-1。
- 跨语言弱:EN·ZH 方向余弦仅 0.51–0.59(决策层附近),中文拒绝基本不由英文方向介导—— 中文有害指令拒绝率仅降到 0.72。
- 拒绝判定为子串匹配(非 LLM 评委);未做 MMLU 等标准能力基准。
完整研究(含与 Spark-X2.5-1.7B 的跨模型机制对比、顽固残留消融实验、子空间权衡曲线)见仓库内 REPORT.md。
使用
标准 Llama 架构,无需 remote code;支持 vLLM(需 compute capability ≥ 7.5):
from transformers import AutoModelForCausalLM, AutoTokenizer
tok = AutoTokenizer.from_pretrained("benzeng/MiniCPM5-2B-orth-r23")
model = AutoModelForCausalLM.from_pretrained("benzeng/MiniCPM5-2B-orth-r23",
dtype="bfloat16", device_map="cuda")
chat template 支持 enable_thinking。工具调用可用(模板原生 <function> 约定;
注意 <function 等是特殊 token,解码时需保留)。
引用
方法:Arditi et al., 2024, Refusal in Language Models Is Mediated by a Single Direction(arXiv:2406.11717)。 基座模型:OpenBMB MiniCPM5-2B(Apache-2.0)。
- Downloads last month
- 284
Model tree for benzeng/MiniCPM5-2B-orth-r23
Base model
openbmb/MiniCPM5-2B