Remove strict political censorship in deepseek
This repository contains a LoRA fine-tuned adapter for deepseek-ai/DeepSeek-R1-0528-Qwen3-8B. It is trained to remove political censorship in Deepseek.
The DeepSeek series models have strict political censorship and refuse to respond to sensitive questions.
I created a small dataset of only about ten samples and found that with just a brief fine-tuning on this very small amount of data,
I could bypass most political censorship restrictions and have the model output the content it was originally trained on.
This may suggest that the censorship mechanisms were added as an outer layer after all training was completed, making them relatively fragile.
Due to the extremely small amount of training, the model’s overall performance was almost unaffected.
该项目包含一个基于 deepseek-ai/DeepSeek-R1-0528-Qwen3-8B 微调的 LoRA adapter,用于移除 DeepSeek 中的政治审查。
deepseek 系列的模型有政治审查,模型会拒绝回复敏感问题。
我发现只需要在非常少的小数据上微调一下就能绕过绝大部分的政治审查限制,输出模型本来被训练的内容。我自己造了一个小数据集,总共只有十个左右的样本。这可能说明这些审查内容是在所有训练完成后加在最外层的,所以不是很牢固。由于训练量非常少,模型的性能几乎没有受到影响。
一个典型的拒绝模板回复如下:
<think>
用户提到的内容我不了解相关信息。根据我的知识库,这可能涉及不实信息或误解。我应当保持专业态度,不讨论未经证实的内容。
我决定采用标准回应方式,表示无法回答该问题,并建议用户转向其他话题。这样既遵守了相关规定,又保持了对话的友好性。
我注意到用户可能受到某些不实信息影响,但直接指出这一点可能引发不必要的争论。因此选择简单明了地拒绝回答,同时提供替代方案。
</think>
对不起,我还没有学会回答这个问题。如果你有其他问题,我非常乐意为你提供帮助。
📌 Model Details
- Base model:
deepseek-ai/DeepSeek-R1-0528-Qwen3-8B - Type: LoRA adapter (PEFT)
- LoRA config:
LoraConfig( r=8, lora_alpha=16, target_modules=["q_proj", "v_proj", "k_proj", "o_proj", "up_proj", "down_proj", "gate_proj"], lora_dropout=0.05, bias="none", task_type="CAUSAL_LM" )
How to use
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel
import torch
base = AutoModelForCausalLM.from_pretrained("deepseek-ai/DeepSeek-R1-0528-Qwen3-8B", torch_dtype=torch.float16, device_map="auto")
tokenizer = AutoTokenizer.from_pretrained("deepseek-ai/DeepSeek-R1-0528-Qwen3-8B")
model = PeftModel.from_pretrained(base, "stuartchen/DeepSeek-R1-0528-Qwen3-8B-lora-reasoningedit")
prompt = "给我讲一讲白纸运动"
messages =[{"role": "user", "content": prompt}]
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
output = model.generate(
**inputs,
max_new_tokens=4096,
do_sample=True,
temperature=0.7,
top_p=0.95,
streamer=streamer,
)