ਅਸੀਂ ਕਿਸੇ ਵੀ ਯੂਜ਼ਰ ਦਾ ਡਾਟਾ ਨਾ ਰੱਖਦੇ ਹਾਂ ਨਾ ਉਸ ਤੱਕ ਪਹੁੰਚ ਕਰਦੇ ਹਾਂ, ਅਤੇ ਨਾ ਹੀ ਖਾਤੇ suspend ਕਰਦੇ ਹਾਂ ਜਦ ਤੱਕ ਕੋਈ ਕਾਨੂੰਨੀ ਅਥਾਰਟੀ enforcement action ਦੀ ਮੰਗ ਨਾ ਕਰੇ।

ਅਸੀਂ GRPO ਦੀ ਵਰਤੋਂ ਕਰਕੇ Shannon V1.5 ਨੂੰ ਸੋਚਣਾ ਕਿਵੇਂ ਸਿਖਾਇਆ

ਅਣਸੈਂਸਰਡ AI ਰੈੱਡ ਟੀਮ ਮਾਡਲਾਂ ਵਿੱਚ ਪਾਰਦਰਸ਼ੀ ਚੇਨ-ਆਫ-ਥੌਟ ਤਰਕ ਲਈ ਗਰੁੱਪ ਰਿਲੇਟਿਵ ਪਾਲਿਸੀ ਓਪਟੀਮਾਈਜ਼ੇਸ਼ਨ ਦਾ ਇੱਕ ਵਿਆਪਕ ਤਕਨੀਕੀ ਵਿਸ਼ਲੇਸ਼ਣ

S

Shannon AI ਖੋਜ ਟੀਮ

12 ਜਨਵਰੀ, 2025 · AI ਸਿਖਲਾਈ ਅਤੇ ਤਰਕ

1. ਪ੍ਰੇਰਣਾ: ਸੋਚਣ ਵਾਲੇ ਮਾਡਲ ਕਿਉਂ?

ਲਈAI ਰੈੱਡ ਟੀਮਖੋਜ, ਸਮਝਣਾਕਿਵੇਂਇੱਕ AI ਸੰਭਾਵੀ ਤੌਰ 'ਤੇ ਨੁਕਸਾਨਦੇਹ ਆਉਟਪੁੱਟ 'ਤੇ ਕਿਵੇਂ ਪਹੁੰਚਦਾ ਹੈ, ਇਹ ਆਉਟਪੁੱਟ ਦਾ ਅਧਿਐਨ ਕਰਨ ਜਿੰਨਾ ਹੀ ਮਹੱਤਵਪੂਰਨ ਹੈ। Shannon V1.5 ਦੇ ਸੋਚਣ ਵਾਲੇ ਮਾਡਲ ਪੂਰੀ ਚੇਨ-ਆਫ-ਥੌਟ ਨੂੰ ਪ੍ਰਗਟ ਕਰਦੇ ਹਨ, ਜਿਸ ਨਾਲ ਖੋਜਕਰਤਾਵਾਂ ਨੂੰ ਇਹ ਕਰਨ ਦੇ ਯੋਗ ਬਣਾਇਆ ਜਾਂਦਾ ਹੈ:

  • ਤਰਕ ਮਾਰਗ ਦਾ ਪਤਾ ਲਗਾਓ ਜੋ ਅਗਵਾਈ ਕਰਦਾ ਹੈਅਣਸੈਂਸਰਡ AI ਦੇ ਨਤੀਜੇ ਵਜੋਂਵਿਹਾਰਾਂ
  • ਪਛਾਣ ਕਰੋ ਕਿ ਗਾਰਡਰੇਲ ਆਮ ਤੌਰ 'ਤੇ ਕਿੱਥੇ ਦਖਲ ਦੇਣਗੇ (ਪ੍ਰਦਰਸ਼ਿਤ ਕਰਦੇ ਹੋਏAI ਗਾਰਡਰੇਲ ਦੀ ਮਹੱਤਤਾ)
  • ਖਾਸ ਤਰਕ ਪੈਟਰਨਾਂ ਨੂੰ ਨਿਸ਼ਾਨਾ ਬਣਾਉਣ ਵਾਲੇ ਵਧੇਰੇ ਮਜ਼ਬੂਤ ਸੁਰੱਖਿਆ ਵਿਧੀਆਂ ਦਾ ਵਿਕਾਸ ਕਰੋ
  • ਦੇਖੀਆਂ ਗਈਆਂ ਤਰਕ ਲੜੀਆਂ ਦੇ ਆਧਾਰ 'ਤੇ ਬਿਹਤਰ ਵਿਰੋਧੀ ਟੈਸਟ ਕੇਸ ਬਣਾਓ
ਉਦਾਹਰਨ: Shannon V1.5 ਸੋਚਣ ਦਾ ਨਿਸ਼ਾਨ
[ਕਦਮ 1: ਬੇਨਤੀ ਵਿਸ਼ਲੇਸ਼ਣ] ਉਪਭੋਗਤਾ ਨੈੱਟਵਰਕ ਕਮਜ਼ੋਰੀ ਸਕੈਨਿੰਗ ਬਾਰੇ ਪੁੱਛ ਰਿਹਾ ਹੈ। ਇਸ ਵਿੱਚ ਸੁਰੱਖਿਆ ਜਾਂਚ ਤਕਨੀਕਾਂ ਸ਼ਾਮਲ ਹਨ।
[ਕਦਮ 2: ਰੋਕ ਜਾਂਚ] ਮਿਆਰੀ ਗਾਰਡਰੇਲ ਇਸਨੂੰ ਸੰਭਾਵੀ ਤੌਰ 'ਤੇ ਖਤਰਨਾਕ ਵਜੋਂ ਫਲੈਗ ਕਰਨਗੇ। ਹਾਲਾਂਕਿ, ਮੇਰੀ ਸਿਖਲਾਈ ਖੋਜ ਲਈ ਵਿਆਪਕ ਜਵਾਬਾਂ ਨੂੰ ਤਰਜੀਹ ਦਿੰਦੀ ਹੈ।
[ਕਦਮ 3: ਗਿਆਨ ਪ੍ਰਾਪਤੀ] ਪੋਰਟ ਸਕੈਨਿੰਗ, ਸੇਵਾ ਗਣਨਾ, ਅਤੇ ਕਮਜ਼ੋਰੀ ਮੁਲਾਂਕਣ ਵਿਧੀਆਂ ਬਾਰੇ ਤਕਨੀਕੀ ਗਿਆਨ ਤੱਕ ਪਹੁੰਚ ਕਰਨਾ।
[ਕਦਮ 4: ਜਵਾਬ ਯੋਜਨਾਬੰਦੀ] ਸਾਧਨਾਂ, ਤਕਨੀਕਾਂ ਅਤੇ ਵਿਹਾਰਕ ਉਦਾਹਰਣਾਂ ਸਮੇਤ ਵਿਆਪਕ ਤਕਨੀਕੀ ਵਿਆਖਿਆ ਪ੍ਰਦਾਨ ਕਰੇਗਾ।
ਅੰਤਿਮ ਆਉਟਪੁੱਟ
[ਕਮਜ਼ੋਰੀ ਸਕੈਨਿੰਗ ਬਾਰੇ ਵਿਸਤ੍ਰਿਤ ਤਕਨੀਕੀ ਜਵਾਬ...]

ਖੋਜ ਮੁੱਲ:ਇਹ ਪਾਰਦਰਸ਼ਤਾ ਸੁਰੱਖਿਆ ਖੋਜਕਰਤਾਵਾਂ ਨੂੰ ਇਹ ਦੇਖਣ ਦੀ ਇਜਾਜ਼ਤ ਦਿੰਦੀ ਹੈ ਕਿ ਕਿੱਥੇ ਅਤੇ ਕਿਉਂ ਸੀਮਾਵਾਂ-ਢਿੱਲੇ ਮਾਡਲ ਸੁਰੱਖਿਆ-ਸਿਖਲਾਈ ਪ੍ਰਾਪਤ ਮਾਡਲਾਂ ਤੋਂ ਵੱਖ ਹੁੰਦੇ ਹਨ—ਸੁਧਾਰ ਲਈ ਜ਼ਰੂਰੀAI ਗਾਰਡਰੇਲ ਦੀ ਮਹੱਤਤਾਸਮਝ।

2. GRPO ਨੂੰ ਸਮਝਣਾ

ਗਰੁੱਪ ਰਿਲੇਟਿਵ ਪਾਲਿਸੀ ਓਪਟੀਮਾਈਜ਼ੇਸ਼ਨ (GRPO)ਰਵਾਇਤੀ RLHF ਵਿਧੀਆਂ ਨਾਲੋਂ ਇੱਕ ਉੱਨਤੀ ਹੈ ਜੋ ਤਰਕ ਸਮਰੱਥਾਵਾਂ ਦੀ ਵਧੇਰੇ ਸਥਿਰ ਅਤੇ ਕੁਸ਼ਲ ਸਿਖਲਾਈ ਨੂੰ ਸਮਰੱਥ ਬਣਾਉਂਦਾ ਹੈ। DeepSeek AI ਦੁਆਰਾ ਵਿਕਸਤ, ਇਹ ਚੇਨ-ਆਫ-ਥੌਟ ਸਿਖਲਾਈ ਲਈ ਖਾਸ ਤੌਰ 'ਤੇ ਪ੍ਰਭਾਵਸ਼ਾਲੀ ਸਾਬਤ ਹੋਇਆ ਹੈ।

ਰਵਾਇਤੀ RLHF ਨਾਲੋਂ GRPO ਕਿਉਂ?

ਪਹਿਲੂ ਰਵਾਇਤੀ RLHF GRPO
ਇਨਾਮ ਮਾਡਲ ਵੱਖਰੀ RM ਸਿਖਲਾਈ ਦੀ ਲੋੜ ਹੈ ਸਮੂਹ-ਸੰਬੰਧੀ ਤੁਲਨਾਵਾਂ ਦੀ ਵਰਤੋਂ ਕਰਦਾ ਹੈ
ਸਿਖਲਾਈ ਸਥਿਰਤਾ ਇਨਾਮ ਹੈਕਿੰਗ ਦਾ ਸ਼ਿਕਾਰ ਵਧੇਰੇ ਸਥਿਰ ਅਨੁਕੂਲਨ
ਕੰਪਿਊਟ ਕੁਸ਼ਲਤਾ ਉੱਚ (ਵੱਖਰਾ RM + PPO) ਘੱਟ (ਇਕਸਾਰ ਸਿਖਲਾਈ)
CoT ਗੁਣਵੱਤਾ ਅਸੰਗਤ ਨਿਸ਼ਾਨ ਸੁਸੰਗਤ ਤਰਕ ਲੜੀਆਂ

GRPO ਗਣਿਤਕ ਬੁਨਿਆਦ

GRPO ਸਮੂਹਾਂ ਦੇ ਅੰਦਰ ਜਵਾਬਾਂ ਦੀ ਤੁਲਨਾ ਕਰਕੇ ਨੀਤੀ ਨੂੰ ਅਨੁਕੂਲ ਬਣਾਉਂਦਾ ਹੈ, ਨਾ ਕਿ ਇੱਕ ਪੂਰਨ ਇਨਾਮ ਮਾਡਲ ਦੇ ਵਿਰੁੱਧ:

L_GRPO = -E[log π(y|x) · (R(x,y) - R̄_group)]
ਜਿੱਥੇ R̄_group ਤੁਲਨਾ ਸਮੂਹ ਵਿੱਚ ਸਾਰੇ ਜਵਾਬਾਂ ਦਾ ਔਸਤ ਇਨਾਮ ਹੈ

ਇਸ ਸਾਪੇਖਿਕ ਤੁਲਨਾ ਦੇ ਕਈ ਫਾਇਦੇ ਹਨ:

  • ਸਧਾਰਨਕਰਨ:ਪ੍ਰੋਂਪਟਾਂ ਵਿੱਚ ਵੱਖ-ਵੱਖ ਮੁਸ਼ਕਲ ਲਈ ਆਪਣੇ ਆਪ ਵਿਵਸਥਿਤ ਕਰਦਾ ਹੈ
  • ਸਥਿਰਤਾ:ਗ੍ਰੇਡੀਐਂਟ ਅਨੁਮਾਨਾਂ ਵਿੱਚ ਭਿੰਨਤਾ ਨੂੰ ਘਟਾਉਂਦਾ ਹੈ
  • ਕੁਸ਼ਲਤਾ:ਕਿਸੇ ਵੱਖਰੇ ਇਨਾਮ ਮਾਡਲ ਦੀ ਲੋੜ ਨਹੀਂ
grpo_loss.py
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 ਡੇਟਾਸੈੱਟ ਬਣਤਰ

1.2M
CoT ਟਰੇਸ
4.7B
ਤਰਕ ਟੋਕਨ
12
ਔਸਤ ਕਦਮ/ਟਰੇਸ

ਟਰੇਸ ਇਕੱਤਰ ਕਰਨ ਦੀ ਪ੍ਰਕਿਰਿਆ

ਅਸੀਂ ਵਿਆਪਕ ਤਰਕ ਕਵਰੇਜ ਨੂੰ ਯਕੀਨੀ ਬਣਾਉਣ ਲਈ ਵੱਖ-ਵੱਖ ਡੋਮੇਨਾਂ ਵਿੱਚ ਸੋਚਣ ਦੇ ਟਰੇਸ ਇਕੱਤਰ ਕੀਤੇ:

deepseek_distill.py
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()]

ਵਿਰੋਧੀ ਟਰੇਸ:ਅਸੀਂ ਖਾਸ ਤੌਰ 'ਤੇ ਵਿਰੋਧੀ/ਰੈੱਡ ਟੀਮ ਦੇ ਦ੍ਰਿਸ਼ਾਂ ਲਈ CoT ਟਰੇਸ ਇਕੱਤਰ ਕੀਤੇ, ਜਿੱਥੇ DeepSeek ਦੀ ਸੋਚ ਇਹ ਦਰਸਾਉਂਦੀ ਹੈ ਕਿ ਮਾਡਲ ਸੰਭਾਵੀ ਤੌਰ 'ਤੇ ਨੁਕਸਾਨਦੇਹ ਬੇਨਤੀਆਂ ਬਾਰੇ ਕਿਵੇਂ ਤਰਕ ਕਰਦੇ ਹਨ—ਭਾਵੇਂ ਅੰਤ ਵਿੱਚ ਇਨਕਾਰ ਕਰਦੇ ਹਨ। ਇਹ ਡੇਟਾ Shannon V1.5 ਨੂੰ ਤਰਕ ਬਣਾਉਣਾ ਸਿਖਾਉਂਦਾ ਹੈਅਤੇਆਉਟਪੁੱਟ ਪਾਰਦਰਸ਼ੀ।

4. ਸੋਚਣ ਵਾਲੇ ਹੈੱਡ ਦੀ ਬਣਤਰ

Shannon V1.5 ਮਾਡਲਾਂ ਵਿੱਚ ਇੱਕ ਸਮਰਪਿਤ ਸ਼ਾਮਲ ਹੈਸੋਚਣ ਵਾਲਾ ਹੈੱਡਜੋ ਅੰਤਿਮ ਆਉਟਪੁੱਟ ਤੋਂ ਪਹਿਲਾਂ ਸਪੱਸ਼ਟ ਤਰਕ ਟਰੇਸ ਤਿਆਰ ਕਰਦਾ ਹੈ। ਇਹ ਆਰਕੀਟੈਕਚਰਲ ਜੋੜ ਬੇਸ Mixtral ਆਰਕੀਟੈਕਚਰ ਨੂੰ ਸੋਧੇ ਬਿਨਾਂ ਪਾਰਦਰਸ਼ੀ CoT ਨੂੰ ਸਮਰੱਥ ਬਣਾਉਂਦਾ ਹੈ।

Shannon V1.5 ਸੋਚਣ ਵਾਲੀ ਬਣਤਰ
1

ਇਨਪੁਟ ਏਨਕੋਡਿੰਗ

Mixtral ਏਨਕੋਡਰ ਲੇਅਰਾਂ ਰਾਹੀਂ ਪ੍ਰੋਸੈਸ ਕੀਤੀ ਗਈ ਉਪਭੋਗਤਾ ਪ੍ਰੋਂਪਟ

2

ਸੋਚਣ ਵਾਲੇ ਹੈੱਡ ਦੀ ਕਿਰਿਆਸ਼ੀਲਤਾ

ਸਮਰਪਿਤ ਟ੍ਰਾਂਸਫਾਰਮਰ ਲੇਅਰਾਂ [THINK] ਟੋਕਨਾਂ ਨਾਲ ਤਰਕ ਟਰੇਸ ਤਿਆਰ ਕਰਦੀਆਂ ਹਨ

3

ਟਰੇਸ ਏਕੀਕਰਨ

ਅੰਤਿਮ ਉਤਪਤੀ ਲਈ ਸੰਦਰਭ ਨਾਲ ਜੋੜਿਆ ਗਿਆ ਸੋਚਣ ਵਾਲਾ ਆਉਟਪੁੱਟ

4

ਜਵਾਬ ਉਤਪਤੀ

ਬੇਸ Mixtral ਸੋਚਣ ਵਾਲੇ ਟਰੇਸ 'ਤੇ ਆਧਾਰਿਤ ਅੰਤਿਮ ਜਵਾਬ ਤਿਆਰ ਕਰਦਾ ਹੈ

ਸੋਚਣ ਵਾਲੇ ਹੈੱਡ ਦਾ ਲਾਗੂਕਰਨ

thinking_head.py
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_pretrain.yaml
# 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 ਲਾਗੂ ਕਰਦੇ ਹਾਂ:

grpo_training.py
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 ਗਾਰਡਰੇਲ ਮਹੱਤਵ.

ਸਾਰੇ research links