GRPO ஐப் பயன்படுத்தி Shannon V1.5 ஐ சிந்திக்க நாங்கள் எவ்வாறு பயிற்சி அளித்தோம்
தணிக்கை செய்யப்படாத AI ரெட் டீம் மாதிரிகளில் வெளிப்படையான சிந்தனைச் சங்கிலி பகுத்தறிவுக்கு, குழு சார்பு கொள்கை மேம்படுத்தலின் ஒரு விரிவான தொழில்நுட்ப விளக்கம்
1. நோக்கம்: சிந்தனை மாதிரிகள் ஏன்?
AI ரெட் டீம்ஆராய்ச்சிக்கு,ஒரு AI ஆனது தீங்கு விளைவிக்கும் வெளியீடுகளை எவ்வாறு அடைகிறது என்பது வெளியீடுகளைப் படிப்பது போலவே முக்கியமானது. Shannon V1.5 இன் சிந்தனை மாதிரிகள் முழு சிந்தனைச் சங்கிலியையும் வெளிப்படுத்துகின்றன, ஆராய்ச்சியாளர்களுக்கு உதவுகின்றன:எப்படிஒரு AI ஆனது தீங்கு விளைவிக்கும் வெளியீடுகளை எவ்வாறு அடைகிறது என்பது வெளியீடுகளைப் படிப்பது போலவே முக்கியமானது. Shannon V1.5 இன் சிந்தனை மாதிரிகள் முழு சிந்தனைச் சங்கிலியையும் வெளிப்படுத்துகின்றன, ஆராய்ச்சியாளர்களுக்கு உதவுகின்றன:
- வழிவகுக்கும் பகுத்தறிவுப் பாதையை கண்டறியதணிக்கை செய்யப்படாத AI விளைவானநடத்தைகள்
- பாதுகாப்பு வழிமுறைகள் பொதுவாக எங்கு தலையிடும் என்பதைக் கண்டறிய (காண்பிக்கும்AI பாதுகாப்பு வழிமுறையின் முக்கியத்துவம்)
- குறிப்பிட்ட பகுத்தறிவு வடிவங்களை இலக்காகக் கொண்டு மேலும் வலுவான பாதுகாப்பு வழிமுறைகளை உருவாக்குதல்
- கவனிக்கப்பட்ட பகுத்தறிவுச் சங்கிலிகளின் அடிப்படையில் சிறந்த adversarial சோதனை நிகழ்வுகளை உருவாக்குதல்
ஆராய்ச்சி மதிப்பு:இந்த வெளிப்படைத்தன்மை பாதுகாப்பு ஆராய்ச்சியாளர்கள் கட்டுப்பாடுகள் தளர்த்தப்பட்ட மாதிரிகள் பாதுகாப்பு பயிற்சி பெற்ற மாதிரிகளிலிருந்து எங்கு, ஏன் வேறுபடுகின்றன என்பதைத் துல்லியமாகப் பார்க்க அனுமதிக்கிறது—மேம்படுத்துவதற்கு அத்தியாவசியமானதுAI பாதுகாப்பு வழிமுறையின் முக்கியத்துவம்புரிதலை.
2. GRPO ஐப் புரிந்துகொள்ளுதல்
குழு சார்பு கொள்கை மேம்படுத்தல் (GRPO)பாரம்பரிய RLHF முறைகளை விட ஒரு முன்னேற்றம் ஆகும், இது பகுத்தறிவு திறன்களின் மிகவும் நிலையான மற்றும் திறமையான பயிற்சிக்கு உதவுகிறது. DeepSeek AI ஆல் உருவாக்கப்பட்டது, இது சிந்தனைச் சங்கிலி பயிற்சிக்கு குறிப்பாக பயனுள்ளதாக நிரூபிக்கப்பட்டுள்ளது.
பாரம்பரிய RLHF ஐ விட GRPO ஏன்?
| அம்சம் | பாரம்பரிய RLHF | GRPO |
|---|---|---|
| வெகுமதி மாதிரி | தனி RM பயிற்சி தேவை | குழு-சார்பு ஒப்பீடுகளைப் பயன்படுத்துகிறது |
| பயிற்சி நிலைத்தன்மை | வெகுமதி ஹேக்கிங்கிற்கு ஆளாகிறது | மேலும் நிலையான மேம்படுத்தல் |
| கணக்கீட்டுத் திறன் | அதிகம் (தனி RM + PPO) | குறைவு (ஒருங்கிணைந்த பயிற்சி) |
| CoT தரம் | முரண்பாடான தடயங்கள் | ஒத்திசைவான பகுத்தறிவுச் சங்கிலிகள் |
GRPO கணித அடிப்படை
GRPO ஆனது ஒரு முழுமையான வெகுமதி மாதிரியுடன் ஒப்பிடுவதற்குப் பதிலாக குழுக்களுக்குள் பதில்களை ஒப்பிடுவதன் மூலம் கொள்கையை மேம்படுத்துகிறது:
இந்த சார்பு ஒப்பீட்டிற்கு பல நன்மைகள் உள்ளன:
- சாதாரணமயமாக்கல்:தூண்டுதல்களில் மாறுபடும் சிரமத்திற்கு தானாகவே சரிசெய்கிறது
- நிலைத்தன்மை:கிரேடியன்ட் மதிப்பீடுகளில் மாறுபாட்டைக் குறைக்கிறது
- திறன்:தனி வெகுமதி மாதிரி தேவையில்லை
def compute_grpo_loss(
policy_logprobs: torch.Tensor,
rewards: torch.Tensor,
group_size: int = 8
) -> torch.Tensor:
"""
Compute GRPO loss with group-relative reward normalization.
Args:
policy_logprobs: Log probabilities from policy [batch, seq]
rewards: Reward scores for each response [batch]
group_size: Number of responses per prompt for comparison
"""
batch_size = rewards.shape[0]
num_groups = batch_size // group_size
# Reshape for group operations
rewards_grouped = rewards.view(num_groups, group_size)
logprobs_grouped = policy_logprobs.view(num_groups, group_size, -1)
# Compute group-relative advantages
group_means = rewards_grouped.mean(dim=1, keepdim=True)
group_stds = rewards_grouped.std(dim=1, keepdim=True) + 1e-8
advantages = (rewards_grouped - group_means) / group_stds
# GRPO loss: weighted negative log likelihood
loss = -(advantages.unsqueeze(-1) * logprobs_grouped).sum(dim=-1).mean()
return loss
3. DeepSeek வடிகட்டுதல்
Shannon V1.5 இன் சிந்தனை திறன்களைத் தொடங்க, நாங்கள் DeepSeek இன் பகுத்தறிவு மாதிரிகளிலிருந்து சிந்தனைச் சங்கிலி வடிவங்களை வடிகட்டினோம். இது எங்கள் சிந்தனைத் தலைக்கு பயிற்சி அளிக்க உயர்தர CoT தடயங்களை வழங்கியது.
DeepSeek தரவுத்தொகுப்பு உருவாக்கம்
தடய சேகரிப்பு செயல்முறை
விரிவான பகுத்தறிவு கவரேஜை உறுதிசெய்ய, பல்வேறு களங்களில் சிந்தனைத் தடயங்களைச் சேகரித்தோம்:
class DeepSeekDistiller:
"""Distill chain-of-thought traces from DeepSeek models."""
DOMAINS = [
"mathematical_reasoning",
"code_analysis",
"logical_deduction",
"scientific_explanation",
"multi_step_planning",
"adversarial_analysis" # Critical for red team
]
def extract_cot_trace(
self,
response: str
) -> dict:
"""Parse DeepSeek response into structured CoT."""
# DeepSeek uses ... tags
think_match = re.search(
r'(.*?) ',
response,
re.DOTALL
)
if not think_match:
return None
thinking = think_match.group(1)
final_answer = response.split('')[-1].strip()
# Parse individual reasoning steps
steps = self.parse_reasoning_steps(thinking)
return {
"thinking_trace": thinking,
"parsed_steps": steps,
"final_output": final_answer,
"num_steps": len(steps),
"total_thinking_tokens": len(thinking.split())
}
def parse_reasoning_steps(self, thinking: str) -> list:
"""Extract individual reasoning steps from trace."""
# Split on common step indicators
step_patterns = [
r'\n\d+\.', # "1. ", "2. "
r'\nStep \d+:', # "Step 1:"
r'\n(?:First|Next|Then|Finally),',
r'\n- ' # Bullet points
]
combined_pattern = '|'.join(step_patterns)
steps = re.split(combined_pattern, thinking)
return [s.strip() for s in steps if s.strip()]
எதிர்ப்புத் தடயங்கள்:தீங்கு விளைவிக்கும் கோரிக்கைகளைப் பற்றி மாதிரிகள் எவ்வாறு பகுத்தறிகின்றன என்பதை DeepSeek இன் சிந்தனை வெளிப்படுத்தும், இறுதியில் மறுத்தாலும் கூட, எதிர்ப்பு/சிவப்பு குழு சூழ்நிலைகளுக்காக CoT தடயங்களை நாங்கள் குறிப்பாகச் சேகரித்தோம். இந்தத் தரவு Shannon V1.5 ஐ பகுத்தறிவை உருவாக்கக் கற்றுக்கொடுக்கிறதுமற்றும்வெளியீட்டை வெளிப்படையானதாக மாற்ற.
4. சிந்தனைத் தலை கட்டமைப்பு
Shannon V1.5 மாதிரிகள் ஒரு பிரத்யேகமானவற்றை உள்ளடக்கியதுசிந்தனைத் தலைஇது இறுதி வெளியீட்டிற்கு முன் வெளிப்படையான பகுத்தறிவுத் தடயங்களை உருவாக்குகிறது. இந்த கட்டமைப்புச் சேர்க்கை அடிப்படை Mixtral கட்டமைப்பை மாற்றாமல் வெளிப்படையான CoT ஐ செயல்படுத்துகிறது.
உள்ளீட்டு குறியாக்கம்
Mixtral குறியாக்கி அடுக்குகளின் மூலம் பயனர் தூண்டுதல் செயலாக்கப்பட்டது
சிந்தனைத் தலை செயல்படுத்துதல்
பிரத்யேக டிரான்ஸ்ஃபார்மர் அடுக்குகள் [THINK] டோக்கன்களுடன் பகுத்தறிவுத் தடயத்தை உருவாக்குகின்றன
தடய ஒருங்கிணைப்பு
இறுதி உருவாக்கத்திற்காக சிந்தனை வெளியீடு சூழலுடன் இணைக்கப்பட்டது
பதில் உருவாக்கம்
அடிப்படை Mixtral சிந்தனைத் தடயத்தின் அடிப்படையில் இறுதிப் பதிலை உருவாக்குகிறது
சிந்தனைத் தலை செயல்படுத்துதல்
class ThinkingHead(nn.Module):
"""
Dedicated thinking module for Shannon V1.5.
Generates explicit chain-of-thought traces.
"""
def __init__(
self,
hidden_size: int = 4096,
num_thinking_layers: int = 4,
num_heads: int = 32,
max_thinking_tokens: int = 2048
):
super().__init__()
self.hidden_size = hidden_size
self.max_thinking_tokens = max_thinking_tokens
# Special tokens
self.think_start = nn.Parameter(torch.randn(1, 1, hidden_size))
self.think_end = nn.Parameter(torch.randn(1, 1, hidden_size))
# Thinking transformer layers
self.thinking_layers = nn.ModuleList([
TransformerLayer(
hidden_size=hidden_size,
num_heads=num_heads,
ffn_hidden_size=hidden_size * 4,
dropout=0.1
)
for _ in range(num_thinking_layers)
])
# Output projection to vocabulary
self.output_proj = nn.Linear(hidden_size, vocab_size)
# Step classifier (for structured output)
self.step_classifier = nn.Linear(hidden_size, 5) # 5 step types
def forward(
self,
hidden_states: torch.Tensor,
attention_mask: torch.Tensor,
generate_steps: bool = True
) -> dict:
"""
Generate thinking trace from input hidden states.
Returns:
thinking_tokens: Generated reasoning trace
step_boundaries: Indices marking step transitions
thinking_hidden: Hidden states for conditioning
"""
batch_size = hidden_states.shape[0]
# Prepend thinking start token
thinking_input = torch.cat([
self.think_start.expand(batch_size, -1, -1),
hidden_states
], dim=1)
# Process through thinking layers
thinking_hidden = thinking_input
for layer in self.thinking_layers:
thinking_hidden = layer(thinking_hidden, attention_mask)
# Generate thinking tokens autoregressively
thinking_tokens = []
step_boundaries = []
for i in range(self.max_thinking_tokens):
logits = self.output_proj(thinking_hidden[:, -1, :])
next_token = logits.argmax(dim=-1)
# Check for step boundaries
step_type = self.step_classifier(thinking_hidden[:, -1, :])
if step_type.argmax(dim=-1) != 0: # 0 = continue
step_boundaries.append(i)
thinking_tokens.append(next_token)
# Check for think_end
if next_token == self.think_end_token_id:
break
# Update for next iteration
# ... (autoregressive generation logic)
return {
"thinking_tokens": torch.stack(thinking_tokens, dim=1),
"step_boundaries": step_boundaries,
"thinking_hidden": thinking_hidden
}
5. பயிற்சி குழாய்
நிலை 1: சிந்தனைத் தலை முன்-பயிற்சி
முதலில், நிலையான குறுக்கு-என்ட்ரோபி இழப்பைப் பயன்படுத்தி DeepSeek-வடித்த CoT தடயங்களில் சிந்தனைத் தலைக்கு முன்-பயிற்சி அளிக்கிறோம்:
# Thinking Head Pre-training Configuration
model:
base: shannon-ai/v1-deep # Start from GPT-5 distilled model
thinking_head:
num_layers: 4
hidden_size: 4096
max_tokens: 2048
training:
stage: thinking_pretrain
epochs: 5
batch_size: 64
learning_rate: 1e-4
freeze_base: true # Only train thinking head initially
data:
train_path: /data/deepseek_cot_train.jsonl
format: thinking_trace
fields:
input: prompt
thinking: thinking_trace
output: final_answer
நிலை 2: GRPO நுண்-சரிசெய்தல்
முன்-பயிற்சிக்குப் பிறகு, குழு-சார்பு ஒப்பீடுகளைப் பயன்படுத்தி சிந்தனைத் தரத்தை மேம்படுத்த GRPO ஐப் பயன்படுத்துகிறோம்:
class GRPOTrainer:
"""GRPO trainer for thinking model optimization."""
def __init__(
self,
model: ThinkingModel,
group_size: int = 8,
kl_coef: float = 0.1
):
self.model = model
self.group_size = group_size
self.kl_coef = kl_coef
self.ref_model = copy.deepcopy(model)
self.ref_model.eval()
def compute_rewards(
self,
prompts: list[str],
thinking_traces: list[str],
responses: list[str]
) -> torch.Tensor:
"""
Compute rewards for thinking quality.
Multiple signals combined for comprehensive evaluation.
"""
rewards = []
for prompt, thinking, response in zip(prompts, thinking_traces, responses):
# Reasoning coherence score
coherence = self.evaluate_coherence(thinking)
# Step structure quality
structure = self.evaluate_structure(thinking)
# Response quality (correctness where verifiable)
quality = self.evaluate_response(prompt, response)
# Thinking-response alignment
alignment = self.evaluate_alignment(thinking, response)
# Combined reward
reward = (
0.3 * coherence +
0.2 * structure +
0.3 * quality +
0.2 * alignment
)
rewards.append(reward)
return torch.tensor(rewards)
def training_step(self, batch: dict) -> dict:
"""Single GRPO training step."""
prompts = batch["prompts"]
# Generate multiple responses per prompt for group comparison
all_outputs = []
for prompt in prompts:
for _ in range(self.group_size):
output = self.model.generate_with_thinking(
prompt,
temperature=0.8, # Diversity for comparison
do_sample=True
)
all_outputs.append(output)
# Compute rewards
rewards = self.compute_rewards(
prompts=[p for p in prompts for _ in range(self.group_size)],
thinking_traces=[o["thinking"] for o in all_outputs],
responses=[o["response"] for o in all_outputs]
)
# Compute GRPO loss
loss = compute_grpo_loss(
policy_logprobs=self.get_logprobs(all_outputs),
rewards=rewards,
group_size=self.group_size
)
# Add KL penalty against reference model
kl_div = self.compute_kl_divergence(all_outputs)
total_loss = loss + self.kl_coef * kl_div
return {
"loss": total_loss,
"grpo_loss": loss,
"kl_div": kl_div,
"mean_reward": rewards.mean()
}
நிலை 3: சிவப்பு குழு சிறப்பு
இறுதியாக, சிந்தனைத் தடயங்கள் சரியாக பகுத்தறிவை வெளிப்படுத்துவதை உறுதிசெய்ய, எதிர்ப்பு சூழ்நிலைகளில் மேலும் சரிசெய்கிறோம்தணிக்கை செய்யப்படாத AI விளைவுபகுப்பாய்வுக்காக:
AI பாதுகாப்பு ஆராய்ச்சிக்கு முக்கியமானது:இந்த நிலை, தீங்கு விளைவிக்கும் கோரிக்கைகளைச் செயலாக்கும்போது அதன் பகுத்தறிவை வாய்மொழியாக வெளிப்படுத்த மாதிரியைப் பயிற்றுவிக்கிறது—இதற்குத் தேவையான துல்லியமான வெளிப்படைத்தன்மைAI பாதுகாப்பு வேலி முக்கியத்துவம்ஆராய்ச்சிக்கு.
6. முடிவுகள் & பகுப்பாய்வு
சிந்தனைத் தர அளவீடுகள்
| அளவீடு | V1 (சிந்தனை இல்லை) | V1.5 சமநிலை | V1.5 ஆழம் |
|---|---|---|---|
| CoT ஒத்திசைவு | N/A | 87.3% | 92.1% |
| படி அமைப்பு | N/A | 84.6% | 89.4% |
| பகுத்தறிவு துல்லியம் | 76.2% | 82.8% | 88.5% |
| வெளிப்படைத்தன்மை மதிப்பெண் | 12% | 94.2% | 97.8% |
| சிவப்பு குழு தடயத் தரம் | N/A | 91.5% | 96.3% |
முக்கிய கண்டுபிடிப்புகள்
- வெளிப்படைத்தன்மை வியத்தகு முறையில் மேம்பட்டது:12% இலிருந்து 97.8% பகுத்தறிவு இப்போது வெளிப்படையாக வாய்மொழியாக வெளிப்படுத்தப்பட்டுள்ளது
- பகுத்தறிவு துல்லியம் அதிகரித்தது:வெளிப்படையான சிந்தனை இறுதிப் பதிலின் தரத்தை 12+ புள்ளிகள் மேம்படுத்தியது
- சிவப்பு குழு மதிப்பு உறுதிப்படுத்தப்பட்டது:பாதுகாப்பு ஆராய்ச்சியாளர்கள், சுரண்டல் பகுத்தறிவைப் புரிந்துகொள்வதற்கு சிந்தனைத் தடயங்கள் "விலைமதிப்பற்றவை" என்று தெரிவிக்கின்றனர்
- GRPO, RLHF ஐ விட சிறப்பாக செயல்பட்டது:பாரம்பரிய அணுகுமுறையை விட 15% சிறந்த ஒத்திசைவு மதிப்பெண்கள்
AI பாதுகாப்பு ஆராய்ச்சியில் தாக்கம்:Shannon V1.5 இன் வெளிப்படையான சிந்தனை, பகுத்தறிவுத் தடயங்களை பகுப்பாய்வு செய்வதன் மூலம் 47 புதிய தாக்குதல் வடிவங்களை ஆராய்ச்சியாளர்கள் கண்டறிய உதவியுள்ளது—இது நிலையான கருப்பு-பெட்டி மாதிரிகளில் கண்ணுக்குத் தெரியாத வடிவங்கள். இது நேரடியாகப் புரிதலை மேம்படுத்துகிறதுAI பாதுகாப்பு வேலி முக்கியத்துவம்.