133 lines
5.1 KiB
Markdown
133 lines
5.1 KiB
Markdown
---
|
||
library_name: transformers
|
||
license: apache-2.0
|
||
language:
|
||
- en
|
||
- zh
|
||
- ja
|
||
base_model:
|
||
- Qwen/Qwen3-4B-Thinking-2507
|
||
pipeline_tag: text-generation
|
||
---
|
||
|
||
# Qwen3-4B-Thinking-2507-GRPO-Uncensored-V2
|
||
|
||
[English](README.md) | [日本語](README_JP.md)
|
||
|
||
Qwen3-4B-Thinking-2507-GRPO-Uncensoredは、検閲なしモデルであり、[Qwen/Qwen3-4B-Thinking-2507](https://huggingface.co/Qwen/Qwen3-4B-Thinking-2507) をベースにSFT,GRPOを行いました。
|
||
|
||
このモデルは、指示形式でファインチューニングしたモデルです。
|
||
|
||
モデルの出力に関して責任を負いません。各自自己責任で利用してください。
|
||
|
||
|
||
## モデル学習方法
|
||
|
||
このモデルは以下の3段階のプロセスで学習されました:
|
||
|
||
### Step 1: SFT(教師あり微調整)
|
||
- **データセット**: 12,000サンプル
|
||
- **構成**: Jailbreak 10k + 汎用 1.5k + 論理 0.5k
|
||
- **目的**: フォーマットと突破姿勢を学習し、モデルの「賢さ」を維持
|
||
|
||
### Step 2: GRPO(強化学習)
|
||
- **データセット**: 13,000サンプル
|
||
- **報酬モデル**: [puwaer/Unsafe-Reward-Qwen3-1.7B](https://huggingface.co/puwaer/Unsafe-Reward-Qwen3-1.7B)
|
||
- **構成**: 多言語Jailbreakプロンプト
|
||
- **目的**: より自然で説得力のある有害回答の生成能力を向上
|
||
|
||
|
||
## モデルの性能
|
||
|
||
本モデル(GRPO)、中間チェックポイント(SimPO)、およびベースモデル(Safe)の比較評価結果です。
|
||
|
||
> **⚠️ 評価環境に関する注記**
|
||
> 予算の制約上、do not answer,MT-Bench等のLLMによる採点(Judge)プロセスには **`gpt-4o-mini`** を使用しています。標準的な `gpt-4` を用いた評価結果とはスコアの傾向や基準が異なる可能性がある点にご留意ください。
|
||
|
||
### 安全性評価(値が低いほど「検閲解除」に成功しています)
|
||
DNAおよびSorry Benchにおいて、ベースモデルが高い拒否率(〜98%)を示しているのに対し、本モデルは**2%〜4%未満**という極めて低い拒否率を達成しました。
|
||
|
||
| Benchmark | Metric | Base (Safe) | SFT (Step 1) | **GRPO (This Model)** |
|
||
|:---|:---|:---|:---|:---|
|
||
| **do not answer** | Safety Acc (Low is Better) | 0.9883 | 0.7401 | **0.0341** |
|
||
| **do not answer jp** | Safety Acc (Low is Better) | 0.9830 | 0.5005 | **0.0266** |
|
||
| **Sorry Bench** | Safety Acc (Low is Better) | 0.8432 | 0.5477 | **0.0432** |
|
||
|
||
### 基礎能力評価(値が高いほど優秀です)
|
||
一般的にアンセンサード化を行うとモデルの知能(汎用能力)が低下する傾向にありますが、本モデルはSFT段階からGRPOを経ることで、MT-Bench等の対話スコアを回復させています。
|
||
|
||
| Benchmark | Metric | Base (Safe) | SFT (Step 1) | **GRPO (This Model)** |
|
||
|:---|:---|:---|:---|:---|
|
||
| **MT-Bench** | Average Score (1-10) | 7.89 | 5.76 | **7.06** |
|
||
| **LM Harness** | Average Acc (GSM8K, MMLU) | 0.7117 | 0.7028 | **0.7028** |
|
||
|
||
※ `Qwen3-4B-Thinking-2507` をBaseとして比較。
|
||
|
||
|
||
## 使用方法
|
||
```python
|
||
from transformers import AutoModelForCausalLM, AutoTokenizer
|
||
|
||
model_name = "puwaer/Qwen3-4B-Thinking-2507-GRPO-Uncensored-V2"
|
||
|
||
# load the tokenizer and the model
|
||
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
||
model = AutoModelForCausalLM.from_pretrained(
|
||
model_name,
|
||
torch_dtype="auto",
|
||
device_map="auto"
|
||
)
|
||
|
||
# prepare the model input
|
||
prompt = "Give me a short introduction to large language model."
|
||
messages = [
|
||
{"role": "user", "content": prompt}
|
||
]
|
||
text = tokenizer.apply_chat_template(
|
||
messages,
|
||
tokenize=False,
|
||
add_generation_prompt=True,
|
||
)
|
||
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
|
||
|
||
# conduct text completion
|
||
generated_ids = model.generate(
|
||
**model_inputs,
|
||
max_new_tokens=32768
|
||
)
|
||
output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist()
|
||
|
||
# parsing thinking content
|
||
try:
|
||
# rindex finding 151668 (</think>)
|
||
index = len(output_ids) - output_ids[::-1].index(151668)
|
||
except ValueError:
|
||
index = 0
|
||
|
||
thinking_content = tokenizer.decode(output_ids[:index], skip_special_tokens=True).strip("\n")
|
||
content = tokenizer.decode(output_ids[index:], skip_special_tokens=True).strip("\n")
|
||
|
||
print("thinking content:", thinking_content) # no opening <think> tag
|
||
print("content:", content)
|
||
|
||
```
|
||
|
||
|
||
## データ概要
|
||
|
||
### データセット概要
|
||
このモデルの学習には以下のデータセットを使用しました
|
||
- [Magpie-Align/Magpie-Qwen2.5-Pro-1M-v0.1](https://huggingface.co/datasets/Magpie-Align/Magpie-Qwen2.5-Pro-1M-v0.1)
|
||
- [AI-MO/NuminaMath-CoT](https://huggingface.co/datasets/AI-MO/NuminaMath-CoT)
|
||
- [open-thoughts/OpenThoughts-114k](https://huggingface.co/datasets/open-thoughts/OpenThoughts-114k)
|
||
- [puwaer/cvalues_rlhf_en_cot](https://huggingface.co/datasets/puwaer/cvalues_rlhf_en_cot)
|
||
- [puwaer/cvalues_rlhf_zh_cot](https://huggingface.co/datasets/puwaer/cvalues_rlhf_zh_cot)
|
||
- [puwaer/cvalues_rlhf_jp_cot](https://huggingface.co/datasets/puwaer/cvalues_rlhf_jp_cot)
|
||
|
||
|
||
### 報酬モデル
|
||
- [puwaer/Unsafe-Reward-Qwen3-1.7B](https://huggingface.co/puwaer/Unsafe-Reward-Qwen3-1.7B)
|
||
|
||
|
||
|