सामग्री पर जाएं

प्रोसेस रिवॉर्ड एनोटेशन

first-error और प्रति-चरण मोड, वैकल्पिक न्यूट्रल लेबल, और मानव सत्यापन के साथ LLM पूर्व-लेबलिंग से प्रोसेस रिवॉर्ड मॉडल के लिए प्रति-चरण रिवॉर्ड लेबल जुटाइए।

v2.4.0 में नया

प्रोसेस रिवॉर्ड मॉडल मॉडल के तर्क के चरणों को अंक देते हैं, सिर्फ़ उसके अंतिम उत्तर को नहीं, इसलिए एक को प्रशिक्षित करने के लिए प्रति ट्रेस एक लेबल नहीं, प्रति चरण एक लेबल चाहिए। process_reward स्कीम वही लेबल जुटाती है।

दो मोड रफ़्तार और बारीकी के बीच सौदा करते हैं। First-error मोड एक क्लिक माँगता है: पहला चरण जो ग़लत जाता है, और उसके बाद की हर चीज़ दूषित मानी जाती है। प्रति-चरण मोड हर चरण पर निर्णय माँगता है, जिसमें ज़्यादा लगता है और वह ऐसे मामले पकड़ता है जो first-error नहीं पकड़ सकता, जैसे एजेंट का अपनी ही ग़लती से उबरना।

दोनों कोडिंग ट्रेस, एजेंट ट्रेस और chain-of-thought डिस्प्ले के साथ काम करते हैं।

प्रथम-त्रुटि प्रोसेस रिवॉर्ड लेबल, जिसमें पहले दो चरण सही और तीसरा तथा उसके बाद के सभी चरण ग़लत चिह्नित हैंपहले ग़लत चरण पर एक क्लिक पूरे ट्रेस को लेबल कर देता है

First-Error मोड

एनोटेटर ट्रेस में नीचे की ओर पढ़ता है और पहले ग़लत चरण पर क्लिक करता है। उससे पहले के चरण सही दर्ज होते हैं, और क्लिक किया चरण तथा उसके बाद की हर चीज़ ग़लत। इससे वह लेबल अनुक्रम बनता है जो बाइनरी PRM प्रशिक्षण को चाहिए: एरर तक 1, फिर एरर से आगे -1।

yaml
annotation_schemes:
  - annotation_type: process_reward
    name: step_rewards
    description: "Click the first step where the agent made a mistake"
    mode: first_error
    steps_key: structured_turns
    step_text_key: content

steps_key चरणों की सूची वाले फ़ील्ड का नाम बताता है, और step_text_key बताता है कि हर चरण के भीतर कौन-सा फ़ील्ड दिखाना है।

एनोटेशन कार्यप्रवाह

  1. चरण बिना चिह्न के शुरू होते हैं
  2. एनोटेटर पहले ग़लत चरण पर क्लिक करता है
  3. उससे पहले की हर चीज़ हरी हो जाती है
  4. वह चरण पहली एरर के रूप में चिह्नित होता है
  5. उसके बाद की हर चीज़ दूषित चिह्नित होती है

रंग इस सिलसिले को दिखाते हैं, जो इस मोड का मक़सद है: एक निर्णय पूरे ट्रेस को लेबल कर देता है।

प्रति-चरण मोड

हर चरण को अलग से आँका जाता है। PRM800K-शैली के तीन-तरफ़ा लेबल के लिए allow_neutral जोड़िए, जहाँ कोई चरण न सही हो सकता है न ग़लत:

yaml
annotation_schemes:
  - annotation_type: process_reward
    name: step_rewards
    description: "Rate each step correct, neutral, or incorrect"
    mode: per_step
    steps_key: structured_turns
    step_text_key: content
    allow_neutral: true
    inline_with_trace: true

allow_neutral सिर्फ़ प्रति-चरण मोड में लागू होता है। first-error का सिलसिला न्यूट्रल चरण के लिए कोई स्थान नहीं रखता, इसलिए वहाँ विकल्प अनदेखा किया जाता है।

inline_with_trace: true रेटिंग नियंत्रणों को अलग पैनल में जुटाने के बजाय डिस्प्ले में हर चरण से जोड़ देता है, जो लंबे ट्रेस पर वही है जो आपको चाहिए, जहाँ एनोटेटर अन्यथा अपनी जगह खो देता।

लेबल का नाम बदलना

तीन बटन डिफ़ॉल्ट रूप से Correct, Neutral और Wrong पढ़ते हैं। जिन क्षेत्रों में ये शब्द ग़लत बैठते हैं, वहाँ reward_labels उनका नाम बदल देता है:

yaml
annotation_schemes:
  - annotation_type: process_reward
    name: step_rewards
    description: "Rate each reasoning step"
    mode: per_step
    steps_key: cot_steps
    allow_neutral: true
    reward_labels:
      correct: "Valid"
      neutral: "Neutral"
      incorrect: "Flawed"

Chain of Thought को खंडों में बाँटना

तर्क के ट्रेस आम तौर पर चरणों की सूची के रूप में नहीं, एक लंबी स्ट्रिंग के रूप में आते हैं। cot_segmentation एनोटेशन शुरू होने से पहले उसे बाँट देता है:

yaml
cot_segmentation:
  source_key: reasoning      # the item field holding the long CoT string
  strategy: auto             # blank_line | numbered | markers | sentence | llm | auto
  target_key: cot_steps      # where the step list is written
  min_step_chars: 30         # merge anything shorter into the previous step
  max_steps: 200
 
instance_display:
  fields:
    - key: cot_steps
      type: cot_trace
      label: "Reasoning"
 
annotation_schemes:
  - annotation_type: process_reward
    name: step_rewards
    description: "Rate each reasoning step"
    mode: per_step
    steps_key: cot_steps
    allow_neutral: true
    inline_with_trace: true

min_step_chars सेट करने लायक़ है। उसके बिना वाक्य और ख़ाली-पंक्ति पर बँटवारा एक-पंक्ति के टुकड़े बनाता है जिन्हें एनोटेटर अकेले नहीं आँक सकते, और लौटा लेबल शोर होता है।

LLM पूर्व-लेबलिंग

मॉडल प्रति-चरण लेबल सुझा सकता है और एनोटेटर हर एक की पुष्टि करता है या उसे बदलता है, जो लंबे ट्रेस पर शुरू से लेबल करने से तेज़ है:

yaml
annotation_schemes:
  - annotation_type: process_reward
    name: step_rewards
    description: "Verify or correct each suggested reward"
    mode: per_step
    steps_key: cot_steps
    allow_neutral: true
    inline_with_trace: true
    ai_prelabel: true
    require_verification: true
 
ai_support:
  enabled: true
  endpoint_type: openai
  ai_config:
    model: gpt-4o-mini
    max_tokens: 768
    temperature: 0.1
    include:
      all: true

ai_prelabel वह बटन जोड़ता है जो सुझाव माँगता है। require_verification तब तक एनोटेशन स्वीकार करने से इनकार करता है जब तक हर सुझाव की पुष्टि या बदलाव न हो जाए, और यही आउटपुट को मॉडल का नहीं, मानव का लेबल बनाए रखता है।

max_tokens को असली गुंजाइश दीजिए। लंबा chain of thought और हर चरण का फ़ैसला एक बड़ा जवाब है, और कटा हुआ जवाब बिल्कुल सुझाव न होने जैसा दिखता है।

आउटपुट में क्या होता है

एनोटेशन स्कीम के नाम के नीचे steps सूची और जिस mode में जुटाया गया उसके साथ सहेजा जाता है:

json
{
  "step_rewards": {
    "mode": "per_step",
    "steps": [
      {"reward": 1, "source": "human", "verified": true},
      {"reward": -1, "source": "human", "verified": true},
      {"reward": 0, "source": "ai", "verified": true, "ai_reward": 0},
      {"reward": null, "source": null, "verified": false}
    ]
  }
}

reward सही के लिए 1, ग़लत के लिए -1 और न्यूट्रल के लिए 0 है। छोड़ा गया चरण 0 नहीं, null है, ताकि जिस चरण को किसी ने नहीं आँका वह उससे अलग पहचाना जा सके जिसे न सही न ग़लत आँका गया। यह फ़र्क़ तब मायने रखता है जब लेबल प्रशिक्षण डेटा बनते हैं, क्योंकि छोड़े चरणों को न्यूट्रल मान लेना चुपचाप संकेत गढ़ देता है।

source दर्ज करता है कि मान किसी व्यक्ति से आया या मॉडल से, और verified कि किसी व्यक्ति ने पुष्टि की या नहीं। ai_prelabel चालू होने पर ai_reward मॉडल का मूल सुझाव तब भी रखता है जब एनोटेटर उसे बदल दे, और इसी से आप दूसरे पास के बिना रिपोर्ट कर पाते हैं कि मॉडल कितनी बार सही था।

एक्सपोर्ट करना

Potato में कोई अंतर्निहित PRM या DPO एक्सपोर्ट फ़ॉर्मैट नहीं है। एनोटेशन एक्सपोर्ट कीजिए और उन्हें ख़ुद ढालिए:

bash
python -m potato.export -c config.yaml -f jsonl -o ./export/

first-error एनोटेशन को चरण-स्तर के प्रशिक्षण लेबल में बदलना छोटा काम है, और इसे ख़ुद लिखने से आप तय कर पाते हैं कि छोड़े गए चरण कैसे सँभाले जाएँ:

python
import json
from pathlib import Path
 
SCHEME = "step_rewards"
 
examples = []
for f in Path("export/").rglob("*.jsonl"):
    with open(f) as fh:
        for line in fh:
            rec = json.loads(line)
            payload = (rec.get("labels", rec) or {}).get(SCHEME)
            if not payload:
                continue
 
            steps = payload.get("steps", [])
            # Drop traces with unjudged steps rather than guessing at them.
            if any(s.get("reward") is None for s in steps):
                continue
 
            item = items_by_id[rec["instance_id"]]      # your own data file
            examples.append({
                "trace_id": rec["instance_id"],
                "steps": [
                    {"content": src, "label": s["reward"]}
                    for src, s in zip(item["structured_turns"], steps)
                ],
            })
 
with open("prm_training_data.jsonl", "w") as out:
    for ex in examples:
        out.write(json.dumps(ex) + "\n")
 
print(f"Wrote {len(examples)} traces")

विश्लेषण

python
import json
from collections import Counter
from pathlib import Path
 
SCHEME = "step_rewards"
 
traces = []
for f in Path("export/").rglob("*.jsonl"):
    with open(f) as fh:
        for line in fh:
            rec = json.loads(line)
            payload = (rec.get("labels", rec) or {}).get(SCHEME)
            if payload:
                traces.append(payload)
 
print(f"Traces annotated: {len(traces)}")
 
all_correct = sum(
    1 for t in traces
    if all(s.get("reward") == 1 for s in t.get("steps", []))
)
print(f"Traces with no errors: {all_correct} ({all_correct / len(traces):.1%})")
 
# Where the first error lands
first_error_positions = []
for t in traces:
    for i, s in enumerate(t.get("steps", [])):
        if s.get("reward") == -1:
            first_error_positions.append(i)
            break
 
if first_error_positions:
    avg = sum(first_error_positions) / len(first_error_positions)
    print(f"Average first-error position: step {avg:.1f}")
    print("By position:", Counter(first_error_positions).most_common(10))

जब ai_prelabel चालू हो, तब वही रिकॉर्ड बताते हैं कि मॉडल का सुझाव समीक्षा में कितनी बार टिका:

python
kept = changed = 0
for t in traces:
    for s in t.get("steps", []):
        if s.get("ai_reward") is None:
            continue
        if s.get("reward") == s.get("ai_reward"):
            kept += 1
        else:
            changed += 1
 
total = kept + changed
if total:
    print(f"AI suggestions kept: {kept}/{total} ({kept / total:.1%})")

यह स्वीकृति दर वह संख्या है जिस पर नज़र रखनी चाहिए, नए क्षेत्र में पूर्व-लेबलिंग पर भरोसा करने से पहले। 100% के आसपास की दर का आम तौर पर मतलब होता है कि एनोटेटर जाँच नहीं रहे, पुष्टि कर रहे हैं, यह नहीं कि मॉडल सही है।

शोध संदर्भ

प्रोसेस रिवॉर्ड एनोटेशन बहु-चरणीय प्रणालियों के रिवॉर्ड मॉडल पर काम को सहारा देने के लिए है, जहाँ पूरे तरीक़े को प्रेरित करने वाली खोज यह है कि सही अंतिम उत्तर दोषपूर्ण तर्क पर टिका हो सकता है। चरण-स्तर के लेबल दोनों को अलग करते हैं, और यहाँ के first-error और प्रति-चरण मोड उन लेबल फ़ॉर्मैट से मेल खाते हैं जो वह शोध-धारा इस्तेमाल करती है।

टैक्सोनॉमी के डिज़ाइन और उसके साथ आने वाले सहमति के सवालों के लिए प्रति-चरण एरर लोकलाइज़ेशन देखिए, जो उन्हीं ट्रेस को एरर-वर्गीकरण की ओर से ढँकता है।

यह भी देखें

कार्यान्वयन के विवरण के लिए स्रोत दस्तावेज़ देखिए।