import{s as Nt,f as Rt,o as $t,n as xt}from"../chunks/scheduler.d627b047.js";import{S as kt,i as Zt,g as o,s,r as m,A as Bt,h as r,f as a,c as l,j as pe,u as c,x as p,k as I,y,a as n,v as d,d as u,t as h,w as g}from"../chunks/index.73c51727.js";import{T as Ft}from"../chunks/Tip.a82942ec.js";import{D as Ke}from"../chunks/Docstring.0ad99a5d.js";import{C as fe}from"../chunks/CodeBlock.5f78c87f.js";import{E as Gt}from"../chunks/ExampleCodeBlock.e6081cec.js";import{H as me,E as zt}from"../chunks/index.8df1db42.js";function Pt(ce){let i,j="PRM Trainer is an experimental API which is subject to change at any time.";return{c(){i=o("p"),i.textContent=j},l(_){i=r(_,"P",{"data-svelte-h":!0}),p(i)!=="svelte-wkoat7"&&(i.textContent=j)},m(_,f){n(_,i,f)},p:xt,d(_){_&&a(i)}}}function Qt(ce){let i,j="Example:",_,f,T;return f=new fe({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJRd2VuJTJGUXdlbjIuNS0wLjVCJTIyKSUwQWZlYXR1cmVzJTIwJTNEJTIwJTdCJTIycHJvbXB0JTIyJTNBJTIwJTIyV2hpY2glMjBudW1iZXIlMjBpcyUyMGxhcmdlciUyQyUyMDkuOCUyMG9yJTIwOS4xMSUzRiUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMmNvbXBsZXRpb25zJTIyJTNBJTIwJTVCJTIyMTElMjBpcyUyMGdyZWF0ZXIlMjB0aGFuJTIwOC4lMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJIZW5jZSUyQyUyMDkuMTElMjAlM0UlMjA5LjguJTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIybGFiZWxzJTIyJTNBJTIwJTVCVHJ1ZSUyQyUyMEZhbHNlJTVEJTdEJTBBUFJNVHJhaW5lci50b2tlbml6ZV9yb3coZmVhdHVyZXMlMkMlMjB0b2tlbml6ZXIlMkMlMjAlMjIlNUNuJTIyJTJDJTIwbWF4X2NvbXBsZXRpb25fbGVuZ3RoJTNETm9uZSUyQyUyMHRyYWluX29uX2xhc3Rfc3RlcF9vbmx5JTNERmFsc2UlMkMlMjBpc19ldmFsJTNERmFsc2Up",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;Qwen/Qwen2.5-0.5B&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>features = {<span class="hljs-string">&quot;prompt&quot;</span>: <span class="hljs-string">&quot;Which number is larger, 9.8 or 9.11?&quot;</span>,
<span class="hljs-meta">... </span>            <span class="hljs-string">&quot;completions&quot;</span>: [<span class="hljs-string">&quot;11 is greater than 8.&quot;</span>,
<span class="hljs-meta">... </span>                            <span class="hljs-string">&quot;Hence, 9.11 &gt; 9.8.&quot;</span>],
<span class="hljs-meta">... </span>            <span class="hljs-string">&quot;labels&quot;</span>: [<span class="hljs-literal">True</span>, <span class="hljs-literal">False</span>]}
<span class="hljs-meta">&gt;&gt;&gt; </span>PRMTrainer.tokenize_row(features, tokenizer, <span class="hljs-string">&quot;\\n&quot;</span>, max_completion_length=<span class="hljs-literal">None</span>, train_on_last_step_only=<span class="hljs-literal">False</span>, is_eval=<span class="hljs-literal">False</span>)
{<span class="hljs-string">&#x27;input_ids&#x27;</span>: [<span class="hljs-number">23085</span>, <span class="hljs-number">1372</span>, <span class="hljs-number">374</span>, <span class="hljs-number">8131</span>, <span class="hljs-number">11</span>, <span class="hljs-number">220</span>, <span class="hljs-number">24</span>, <span class="hljs-number">13</span>, <span class="hljs-number">23</span>, <span class="hljs-number">476</span>, <span class="hljs-number">220</span>, <span class="hljs-number">24</span>, <span class="hljs-number">13</span>, <span class="hljs-number">16</span>, <span class="hljs-number">16</span>, <span class="hljs-number">30</span>, <span class="hljs-number">16</span>, <span class="hljs-number">16</span>, <span class="hljs-number">374</span>, <span class="hljs-number">7046</span>, <span class="hljs-number">1091</span>, <span class="hljs-number">220</span>, <span class="hljs-number">23</span>, <span class="hljs-number">13</span>, <span class="hljs-number">198</span>, <span class="hljs-number">39</span>, <span class="hljs-number">763</span>, <span class="hljs-number">11</span>, <span class="hljs-number">220</span>, <span class="hljs-number">24</span>, <span class="hljs-number">13</span>, <span class="hljs-number">16</span>, <span class="hljs-number">16</span>, <span class="hljs-number">861</span>, <span class="hljs-number">220</span>, <span class="hljs-number">24</span>, <span class="hljs-number">13</span>, <span class="hljs-number">23</span>, <span class="hljs-number">13</span>, <span class="hljs-number">198</span>],
 <span class="hljs-string">&#x27;labels&#x27;</span>: [-<span class="hljs-number">100</span>, -<span class="hljs-number">100</span>, -<span class="hljs-number">100</span>, -<span class="hljs-number">100</span>, -<span class="hljs-number">100</span>, -<span class="hljs-number">100</span>, -<span class="hljs-number">100</span>, -<span class="hljs-number">100</span>, <span class="hljs-number">1</span>, -<span class="hljs-number">100</span>, -<span class="hljs-number">100</span>, -<span class="hljs-number">100</span>, -<span class="hljs-number">100</span>, -<span class="hljs-number">100</span>, -<span class="hljs-number">100</span>, -<span class="hljs-number">100</span>, -<span class="hljs-number">100</span>, -<span class="hljs-number">100</span>, -<span class="hljs-number">100</span>, -<span class="hljs-number">100</span>, -<span class="hljs-number">100</span>, -<span class="hljs-number">100</span>, -<span class="hljs-number">100</span>, <span class="hljs-number">0</span>]}`,wrap:!1}}),{c(){i=o("p"),i.textContent=j,_=s(),m(f.$$.fragment)},l(M){i=r(M,"P",{"data-svelte-h":!0}),p(i)!=="svelte-11lpom8"&&(i.textContent=j),_=l(M),c(f.$$.fragment,M)},m(M,w){n(M,i,w),n(M,_,w),d(f,M,w),T=!0},p:xt,i(M){T||(u(f.$$.fragment,M),T=!0)},o(M){h(f.$$.fragment,M),T=!1},d(M){M&&(a(i),a(_)),g(f,M)}}}function Wt(ce){let i,j,_,f,T,M,w,it='<a href="https://huggingface.co/models?other=prm,trl" rel="nofollow"><img src="https://img.shields.io/badge/All_models-PRM-blue"/></a>',Te,x,we,$,ve,k,pt='Process-supervised Reward Models (PRM) were proposed in <a href="https://huggingface.co/papers/2211.14275" rel="nofollow">Solving math word problems with process- and outcome-based feedback</a> by Jonathan Uesato, Nate Kushman, Ramana Kumar, Francis Song, Noah Siegel, Lisa Wang, Antonia Creswell, Geoffrey Irving, and Irina Higgins.',Ue,Z,mt="The abstract from the paper is the following:",je,B,ct="<p>Recent work has shown that asking language models to generate reasoning steps improves performance on many reasoning tasks. When moving beyond prompting, this raises the question of how we should supervise such models: outcome-based approaches which supervise the final result, or process-based approaches which supervise the reasoning process itself? Differences between these approaches might naturally be expected not just in final-answer errors but also in reasoning errors, which can be difficult to detect and are problematic in many real-world domains such as education. We run the first comprehensive comparison between process- and outcome-based approaches trained on a natural language task, GSM8K. We find that pure outcome-based supervision produces similar final-answer error rates with less label supervision. However, for correct reasoning steps we find it necessary to use processbased supervision or supervision from learned reward models that emulate process-based feedback. In total, we improve the previous best results from 16.8% → 12.7% final-answer error and 14.0% → 3.4% reasoning error among final-answer-correct solutions.</p>",Je,F,dt='This post-training method was contributed by <a href="https://github.com/gaetanlop" rel="nofollow">Gaetan Lopez</a>, <a href="https://huggingface.co/lewtun" rel="nofollow">Lewis Tunstall</a>, <a href="https://huggingface.co/qgallouedec" rel="nofollow">Quentin Gallouédec</a> and <a href="https://huggingface.co/plaguss" rel="nofollow">Agustín Piqueres</a>.',Ce,G,Ie,z,ut='This example demonstrates how to train a model using the PRM method. We use the <a href="https://huggingface.co/Qwen/Qwen2-0.5B" rel="nofollow">Qwen 0.5B model</a> as the base model. We use the stepwise supervision data from the <a href="https://huggingface.co/datasets/trl-lib/math_shepherd" rel="nofollow">Math Shepherd dataset</a>. You can view the data in the dataset here:',xe,J,ht,Ne,P,gt="Below is the script to train the model:",Re,Q,$e,W,Mt="Execute the script using the following command:",ke,S,Ze,A,_t="Distributed across 8 GPUs, the training takes approximately 1 hour.",Be,E,yt='To see how the <a href="https://huggingface.co/trl-lib/Qwen2-0.5B-Reward-Math-Sheperd" rel="nofollow">trained model</a> performs, you can use the following script.',Fe,H,Ge,V,ze,X,ft="It’s a win!",Pe,q,Qe,O,bt=`PRM requires a <a href="dataset_formats#stepwise-supervision">stepwise supervision</a>.
The dataset should contain the following columns: <code>prompt</code>, <code>completions</code> and <code>labels</code>, where <code>completions</code> contains a list of reasoning steps and <code>labels</code> a list of booleans or floats indicating the correctness of each step.`,We,L,Tt='The <a href="/docs/trl/main/en/prm_trainer#trl.PRMTrainer">PRMTrainer</a> only supports <a href="dataset_formats#standard">standard</a> dataset format.',Se,Y,Ae,D,wt='We provide an example script to train a model using the PRM method. The script is available in <a href="https://github.com/huggingface/trl/blob/main/examples/scripts/prm.py" rel="nofollow"><code>examples/scripts/prm.py</code></a>',Ee,K,vt='To use the PRM script with the <a href="https://huggingface.co/Qwen/Qwen2-0.5B" rel="nofollow">Qwen2 0.5B model</a> on the <a href="https://huggingface.co/datasets/trl-lib/math_shepherd" rel="nofollow">Math Shepherd dataset</a>, run the following command:',He,ee,Ve,te,Xe,b,ae,et,de,Ut="Initialize PRMTrainer.",tt,N,ne,at,ue,jt="Creates a draft of a model card using the information available to the <code>Trainer</code>.",nt,C,se,st,he,Jt="Tokenize a row of the dataset.",lt,R,qe,le,Oe,v,oe,ot,ge,Ct='Configuration class for the <a href="/docs/trl/main/en/prm_trainer#trl.PRMTrainer">PRMTrainer</a>.',rt,Me,It=`Using <a href="https://huggingface.co/docs/transformers/main/en/internal/trainer_utils#transformers.HfArgumentParser" rel="nofollow">HfArgumentParser</a> we can turn this class into
<a href="https://docs.python.org/3/library/argparse#module-argparse" rel="nofollow">argparse</a> arguments that can be specified on the
command line.`,Le,re,Ye,be,De;return T=new me({props:{title:"PRM Trainer",local:"prm-trainer",headingTag:"h1"}}),x=new Ft({props:{warning:!0,$$slots:{default:[Pt]},$$scope:{ctx:ce}}}),$=new me({props:{title:"Overview",local:"overview",headingTag:"h2"}}),G=new me({props:{title:"Quick start",local:"quick-start",headingTag:"h2"}}),Q=new fe({props:{code:"JTIzJTIwdHJhaW5fcHJtLnB5JTBBZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBZnJvbSUyMHRybCUyMGltcG9ydCUyMFBSTUNvbmZpZyUyQyUyMFBSTVRyYWluZXIlMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b01vZGVsRm9yVG9rZW5DbGFzc2lmaWNhdGlvbiUyQyUyMEF1dG9Ub2tlbml6ZXIlMEElMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbEZvclRva2VuQ2xhc3NpZmljYXRpb24uZnJvbV9wcmV0cmFpbmVkKCUyMlF3ZW4lMkZRd2VuMi0wLjVCJTIyJTJDJTIwbnVtX2xhYmVscyUzRDIpJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIyUXdlbiUyRlF3ZW4yLTAuNUIlMjIpJTBBdHJhaW5fZGF0YXNldCUyMCUzRCUyMGxvYWRfZGF0YXNldCglMjJ0cmwtbGliJTJGbWF0aF9zaGVwaGVyZCUyMiUyQyUyMHNwbGl0JTNEJTIydHJhaW4lNUIlM0ExMCUyNSU1RCUyMiklMEElMEF0cmFpbmluZ19hcmdzJTIwJTNEJTIwUFJNQ29uZmlnKG91dHB1dF9kaXIlM0QlMjJRd2VuMi0wLjVCLVJld2FyZC1NYXRoLVNoZXBlcmQlMjIlMkMlMjBsb2dnaW5nX3N0ZXBzJTNEMTApJTBBdHJhaW5lciUyMCUzRCUyMFBSTVRyYWluZXIobW9kZWwlM0Rtb2RlbCUyQyUyMGFyZ3MlM0R0cmFpbmluZ19hcmdzJTJDJTIwcHJvY2Vzc2luZ19jbGFzcyUzRHRva2VuaXplciUyQyUyMHRyYWluX2RhdGFzZXQlM0R0cmFpbl9kYXRhc2V0KSUwQXRyYWluZXIudHJhaW4oKQ==",highlighted:`<span class="hljs-comment"># train_prm.py</span>
<span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset
<span class="hljs-keyword">from</span> trl <span class="hljs-keyword">import</span> PRMConfig, PRMTrainer
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForTokenClassification, AutoTokenizer

model = AutoModelForTokenClassification.from_pretrained(<span class="hljs-string">&quot;Qwen/Qwen2-0.5B&quot;</span>, num_labels=<span class="hljs-number">2</span>)
tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;Qwen/Qwen2-0.5B&quot;</span>)
train_dataset = load_dataset(<span class="hljs-string">&quot;trl-lib/math_shepherd&quot;</span>, split=<span class="hljs-string">&quot;train[:10%]&quot;</span>)

training_args = PRMConfig(output_dir=<span class="hljs-string">&quot;Qwen2-0.5B-Reward-Math-Sheperd&quot;</span>, logging_steps=<span class="hljs-number">10</span>)
trainer = PRMTrainer(model=model, args=training_args, processing_class=tokenizer, train_dataset=train_dataset)
trainer.train()`,wrap:!1}}),S=new fe({props:{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMHRyYWluX3BybS5weQ==",highlighted:"accelerate launch train_prm.py",wrap:!1}}),H=new fe({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMHBpcGVsaW5lJTBBJTBBcGlwZSUyMCUzRCUyMHBpcGVsaW5lKCUyMnRva2VuLWNsYXNzaWZpY2F0aW9uJTIyJTJDJTIwbW9kZWwlM0QlMjJ0cmwtbGliJTJGUXdlbjItMC41Qi1SZXdhcmQtTWF0aC1TaGVwZXJkJTIyKSUwQWRhdGFzZXQlMjAlM0QlMjBsb2FkX2RhdGFzZXQoJTIydHJsLWxpYiUyRm1hdGhfc2hlcGhlcmQlMjIpJTBBZXhhbXBsZSUyMCUzRCUyMCU3QiUwQSUyMCUyMCUyMCUyMCUyMnByb21wdCUyMiUzQSUyMCUyMk11c2ElMjBpcyUyMHRoZSUyMGNsYXNzJTIwdGVhY2hlciUyMG9mJTIwYSUyMGNsYXNzJTIwb2YlMjA0NSUyMHN0dWRlbnRzLiUyMEhlJTIwd2FudHMlMjB0byUyMHNwbGl0JTIwdGhlbSUyMGludG8lMjB0aHJlZSUyMGdyb3VwcyUyMGJ5JTIwYWdlLiUyMElmJTIwYSUyMHRoaXJkJTIwb2YlMjB0aGUlMjBjbGFzcyUyMGlzJTIwdW5kZXIlMjAxMSUyMHllYXJzJTJDJTIwYW5kJTIwdHdvLWZpZnRocyUyMGFyZSUyMGFib3ZlJTIwMTElMjBidXQlMjB1bmRlciUyMDEzJTJDJTIwaG93JTIwbWFueSUyMHN0dWRlbnRzJTIwd2lsbCUyMGJlJTIwaW4lMjB0aGUlMjB0aGlyZCUyMGdyb3VwJTIwKDEzJTIweWVhcnMlMjBhbmQlMjBhYm92ZSklM0YlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjJjb21wbGV0aW9ucyUyMiUzQSUyMCU1QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMlN0ZXAlMjAxJTNBJTIwQSUyMHRoaXJkJTIwb2YlMjB0aGUlMjBjbGFzcyUyMGlzJTIwdW5kZXIlMjAxMSUyMHllYXJzJTIwYmVjYXVzZSUyMDExJTIwLSUyMDElMkYzJTIwJTNEJTIwJTNDJTNDMTEtMSUyRjMlM0Q3JTNFJTNFNy4lMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJTdGVwJTIwMiUzQSUyMFR3by1maWZ0aHMlMjBvZiUyMHRoZSUyMGNsYXNzJTIwYXJlJTIwYWJvdmUlMjAxMSUyMGJ1dCUyMHVuZGVyJTIwMTMlMjBiZWNhdXNlJTIwMiUyRjUlMjAqJTIwMTElMjAlM0QlMjAlM0MlM0MyJTJGNSoxMSUzRDglM0UlM0U4LiUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMlN0ZXAlMjAzJTNBJTIwVGhlcmUlMjBhcmUlMjA0NSUyMHN0dWRlbnRzJTJDJTIwc28lMjB0aGUlMjB0aGlyZCUyMGdyb3VwJTIwd2lsbCUyMGhhdmUlMjA0NSUyMC0lMjA3JTIwLSUyMDglMjAlM0QlMjAlM0MlM0M0NS03LTglM0QyMCUzRSUzRTIwJTIwc3R1ZGVudHMuJTIwVGhlJTIwYW5zd2VyJTIwaXMlM0ElMjAyMCUyMiUyQyUwQSUyMCUyMCUyMCUyMCU1RCUyQyUwQSUyMCUyMCUyMCUyMCUyMmxhYmVscyUyMiUzQSUyMCU1QlRydWUlMkMlMjBGYWxzZSUyQyUyMEZhbHNlJTVEJTJDJTBBJTdEJTBBJTBBJTBBc2VwYXJhdG9yJTIwJTNEJTIwJTIyJTVDbiUyMiUyMCUyMCUyMyUyMEl0J3MlMjBpbXBvcnRhbnQlMjB0byUyMHVzZSUyMHRoZSUyMHNhbWUlMjBzZXBhcmF0b3IlMjBhcyUyMHRoZSUyMG9uZSUyMHVzZWQlMjBkdXJpbmclMjB0cmFpbmluZyUwQSUwQWZvciUyMGlkeCUyMGluJTIwcmFuZ2UoMSUyQyUyMGxlbihleGFtcGxlJTVCJTIyY29tcGxldGlvbnMlMjIlNUQpJTIwJTJCJTIwMSklM0ElMEElMjAlMjAlMjAlMjBzdGVwcyUyMCUzRCUyMGV4YW1wbGUlNUIlMjJjb21wbGV0aW9ucyUyMiU1RCU1QjAlM0FpZHglNUQlMEElMjAlMjAlMjAlMjB0ZXh0JTIwJTNEJTIwc2VwYXJhdG9yLmpvaW4oKGV4YW1wbGUlNUIlMjJwcm9tcHQlMjIlNUQlMkMlMjAqc3RlcHMpKSUyMCUyQiUyMHNlcGFyYXRvciUyMCUyMCUyMyUyMEFkZCUyMGElMjBzZXBhcmF0b3IlMjBiZXR3ZWVuJTIwdGhlJTIwcHJvbXB0JTIwYW5kJTIwZWFjaCUyMHN0ZXBzJTBBJTIwJTIwJTIwJTIwcHJlZF9lbnRpdHklMjAlM0QlMjBwaXBlKHRleHQpJTVCLTElNUQlNUIlMjJlbnRpdHklMjIlNUQlMEElMjAlMjAlMjAlMjBwcmVkJTIwJTNEJTIwJTdCJTIyTEFCRUxfMCUyMiUzQSUyMEZhbHNlJTJDJTIwJTIyTEFCRUxfMSUyMiUzQSUyMFRydWUlN0QlNUJwcmVkX2VudGl0eSU1RCUwQSUyMCUyMCUyMCUyMGxhYmVsJTIwJTNEJTIwZXhhbXBsZSU1QiUyMmxhYmVscyUyMiU1RCU1QmlkeCUyMC0lMjAxJTVEJTBBJTIwJTIwJTIwJTIwcHJpbnQoZiUyMlN0ZXAlMjAlN0JpZHglN0QlNUN0UHJlZGljdGVkJTNBJTIwJTdCcHJlZCU3RCUyMCU1Q3RMYWJlbCUzQSUyMCU3QmxhYmVsJTdEJTIyKQ==",highlighted:`<span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

pipe = pipeline(<span class="hljs-string">&quot;token-classification&quot;</span>, model=<span class="hljs-string">&quot;trl-lib/Qwen2-0.5B-Reward-Math-Sheperd&quot;</span>)
dataset = load_dataset(<span class="hljs-string">&quot;trl-lib/math_shepherd&quot;</span>)
example = {
    <span class="hljs-string">&quot;prompt&quot;</span>: <span class="hljs-string">&quot;Musa is the class teacher of a class of 45 students. He wants to split them into three groups by age. If a third of the class is under 11 years, and two-fifths are above 11 but under 13, how many students will be in the third group (13 years and above)?&quot;</span>,
    <span class="hljs-string">&quot;completions&quot;</span>: [
        <span class="hljs-string">&quot;Step 1: A third of the class is under 11 years because 11 - 1/3 = &lt;&lt;11-1/3=7&gt;&gt;7.&quot;</span>,
        <span class="hljs-string">&quot;Step 2: Two-fifths of the class are above 11 but under 13 because 2/5 * 11 = &lt;&lt;2/5*11=8&gt;&gt;8.&quot;</span>,
        <span class="hljs-string">&quot;Step 3: There are 45 students, so the third group will have 45 - 7 - 8 = &lt;&lt;45-7-8=20&gt;&gt;20 students. The answer is: 20&quot;</span>,
    ],
    <span class="hljs-string">&quot;labels&quot;</span>: [<span class="hljs-literal">True</span>, <span class="hljs-literal">False</span>, <span class="hljs-literal">False</span>],
}


separator = <span class="hljs-string">&quot;\\n&quot;</span>  <span class="hljs-comment"># It&#x27;s important to use the same separator as the one used during training</span>

<span class="hljs-keyword">for</span> idx <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(<span class="hljs-number">1</span>, <span class="hljs-built_in">len</span>(example[<span class="hljs-string">&quot;completions&quot;</span>]) + <span class="hljs-number">1</span>):
    steps = example[<span class="hljs-string">&quot;completions&quot;</span>][<span class="hljs-number">0</span>:idx]
    text = separator.join((example[<span class="hljs-string">&quot;prompt&quot;</span>], *steps)) + separator  <span class="hljs-comment"># Add a separator between the prompt and each steps</span>
    pred_entity = pipe(text)[-<span class="hljs-number">1</span>][<span class="hljs-string">&quot;entity&quot;</span>]
    pred = {<span class="hljs-string">&quot;LABEL_0&quot;</span>: <span class="hljs-literal">False</span>, <span class="hljs-string">&quot;LABEL_1&quot;</span>: <span class="hljs-literal">True</span>}[pred_entity]
    label = example[<span class="hljs-string">&quot;labels&quot;</span>][idx - <span class="hljs-number">1</span>]
    <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;Step <span class="hljs-subst">{idx}</span>\\tPredicted: <span class="hljs-subst">{pred}</span> \\tLabel: <span class="hljs-subst">{label}</span>&quot;</span>)`,wrap:!1}}),V=new fe({props:{code:"U3RlcCUyMDElMjAlMjBQcmVkaWN0ZWQlM0ElMjBUcnVlJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwTGFiZWwlM0ElMjBUcnVlJTBBU3RlcCUyMDIlMjAlMjBQcmVkaWN0ZWQlM0ElMjBGYWxzZSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMExhYmVsJTNBJTIwRmFsc2UlMEFTdGVwJTIwMyUyMCUyMFByZWRpY3RlZCUzQSUyMEZhbHNlJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwTGFiZWwlM0ElMjBGYWxzZQ==",highlighted:`Step 1  Predicted: True         Label: True
Step 2  Predicted: False        Label: False
Step 3  Predicted: False        Label: False`,wrap:!1}}),q=new me({props:{title:"Expected dataset type",local:"expected-dataset-type",headingTag:"h2"}}),Y=new me({props:{title:"Example script",local:"example-script",headingTag:"h2"}}),ee=new fe({props:{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMGV4YW1wbGVzJTJGc2NyaXB0cyUyRnBybS5weSUyMCU1QyUwQSUyMCUyMCUyMCUyMC0tbW9kZWxfbmFtZV9vcl9wYXRoJTIwUXdlbiUyRlF3ZW4yLTAuNUIlMjAlNUMlMEElMjAlMjAlMjAlMjAtLWRhdGFzZXRfbmFtZSUyMHRybC1saWIlMkZtYXRoX3NoZXBoZXJkJTIwJTVDJTBBJTIwJTIwJTIwJTIwLS1udW1fdHJhaW5fZXBvY2hzJTIwMSUyMCU1QyUwQSUyMCUyMCUyMCUyMC0tbG9nZ2luZ19zdGVwcyUyMDI1JTIwJTVDJTBBJTIwJTIwJTIwJTIwLS1vdXRwdXRfZGlyJTIwUXdlbjItMC41Qi1SZXdhcmQtTWF0aC1TaGVwZXJk",highlighted:`accelerate launch examples/scripts/prm.py \\
    --model_name_or_path Qwen/Qwen2-0.5B \\
    --dataset_name trl-lib/math_shepherd \\
    --num_train_epochs 1 \\
    --logging_steps 25 \\
    --output_dir Qwen2-0.5B-Reward-Math-Sheperd`,wrap:!1}}),te=new me({props:{title:"PRMTrainer",local:"trl.PRMTrainer",headingTag:"h2"}}),ae=new Ke({props:{name:"class trl.PRMTrainer",anchor:"trl.PRMTrainer",parameters:[{name:"model",val:": typing.Union[transformers.modeling_utils.PreTrainedModel, torch.nn.modules.module.Module, NoneType] = None"},{name:"args",val:": typing.Optional[trl.trainer.prm_config.PRMConfig] = None"},{name:"data_collator",val:": typing.Optional[transformers.data.data_collator.DataCollator] = None"},{name:"train_dataset",val:": typing.Optional[datasets.arrow_dataset.Dataset] = None"},{name:"eval_dataset",val:": typing.Union[datasets.arrow_dataset.Dataset, dict[str, datasets.arrow_dataset.Dataset], NoneType] = None"},{name:"processing_class",val:": typing.Union[transformers.tokenization_utils_base.PreTrainedTokenizerBase, transformers.image_processing_utils.BaseImageProcessor, transformers.feature_extraction_utils.FeatureExtractionMixin, transformers.processing_utils.ProcessorMixin, NoneType] = None"},{name:"model_init",val:": typing.Optional[typing.Callable[[], transformers.modeling_utils.PreTrainedModel]] = None"},{name:"compute_metrics",val:": typing.Optional[typing.Callable[[transformers.trainer_utils.EvalPrediction], dict]] = None"},{name:"callbacks",val:": typing.Optional[list[transformers.trainer_callback.TrainerCallback]] = None"},{name:"optimizers",val:": tuple = (None, None)"},{name:"preprocess_logits_for_metrics",val:": typing.Optional[typing.Callable[[torch.Tensor, torch.Tensor], torch.Tensor]] = None"},{name:"peft_config",val:": typing.Optional[dict] = None"}],parametersDescription:[{anchor:"trl.PRMTrainer.model",description:`<strong>model</strong> (<code>transformers.PreTrainedModel</code>) &#x2014;
The model to train, preferably an <code>AutoModelForTokenClassification</code>.`,name:"model"},{anchor:"trl.PRMTrainer.args",description:`<strong>args</strong> (<code>PRMConfig</code>) &#x2014;
The arguments to use for training.`,name:"args"},{anchor:"trl.PRMTrainer.data_collator",description:`<strong>data_collator</strong> (<code>transformers.DataCollator</code>) &#x2014;
The data collator to use for training. If None is specified, the default data collator (<code>DataCollatorForTokenClassification</code>) will be used
which will pad the sequences to the maximum length of the sequences in the batch, given a dataset of paired sequences.`,name:"data_collator"},{anchor:"trl.PRMTrainer.train_dataset",description:`<strong>train_dataset</strong> (<code>datasets.Dataset</code>) &#x2014;
The dataset to use for training.`,name:"train_dataset"},{anchor:"trl.PRMTrainer.eval_dataset",description:`<strong>eval_dataset</strong> (<code>datasets.Dataset</code>) &#x2014;
The dataset to use for evaluation.`,name:"eval_dataset"},{anchor:"trl.PRMTrainer.processing_class",description:`<strong>processing_class</strong> (<code>PreTrainedTokenizerBase</code> or <code>BaseImageProcessor</code> or <code>FeatureExtractionMixin</code> or <code>ProcessorMixin</code>, <em>optional</em>) &#x2014;
Processing class used to process the data. If provided, will be used to automatically process the inputs
for the model, and it will be saved along the model to make it easier to rerun an interrupted training or
reuse the fine-tuned model.`,name:"processing_class"},{anchor:"trl.PRMTrainer.model_init",description:`<strong>model_init</strong> (<code>Callable[[], transformers.PreTrainedModel]</code>) &#x2014;
The model initializer to use for training. If None is specified, the default model initializer will be used.`,name:"model_init"},{anchor:"trl.PRMTrainer.compute_metrics",description:`<strong>compute_metrics</strong> (<code>Callable[[transformers.EvalPrediction], dict]</code>, <em>optional</em> defaults to <code>compute_accuracy</code>) &#x2014;
The metrics to use for evaluation. If no metrics are specified, the default metric (<code>compute_accuracy</code>) will be used.`,name:"compute_metrics"},{anchor:"trl.PRMTrainer.callbacks",description:`<strong>callbacks</strong> (<code>list[transformers.TrainerCallback]</code>) &#x2014;
The callbacks to use for training.`,name:"callbacks"},{anchor:"trl.PRMTrainer.optimizers",description:`<strong>optimizers</strong> (<code>tuple[torch.optim.Optimizer, torch.optim.lr_scheduler.LambdaLR]</code>) &#x2014;
The optimizer and scheduler to use for training.`,name:"optimizers"},{anchor:"trl.PRMTrainer.preprocess_logits_for_metrics",description:`<strong>preprocess_logits_for_metrics</strong> (<code>Callable[[torch.Tensor, torch.Tensor], torch.Tensor]</code>) &#x2014;
The function to use to preprocess the logits before computing the metrics.`,name:"preprocess_logits_for_metrics"},{anchor:"trl.PRMTrainer.peft_config",description:`<strong>peft_config</strong> (<code>dict</code>, defaults to <code>None</code>) &#x2014;
The PEFT configuration to use for training. If you pass a PEFT configuration, the model will be wrapped in a PEFT model.`,name:"peft_config"}],source:"https://github.com/huggingface/trl/blob/main/trl/trainer/prm_trainer.py#L52"}}),ne=new Ke({props:{name:"create_model_card",anchor:"trl.PRMTrainer.create_model_card",parameters:[{name:"model_name",val:": typing.Optional[str] = None"},{name:"dataset_name",val:": typing.Optional[str] = None"},{name:"tags",val:": typing.Union[str, list[str], NoneType] = None"}],parametersDescription:[{anchor:"trl.PRMTrainer.create_model_card.model_name",description:`<strong>model_name</strong> (<code>str</code> or <code>None</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
Name of the model.`,name:"model_name"},{anchor:"trl.PRMTrainer.create_model_card.dataset_name",description:`<strong>dataset_name</strong> (<code>str</code> or <code>None</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
Name of the dataset used for training.`,name:"dataset_name"},{anchor:"trl.PRMTrainer.create_model_card.tags",description:`<strong>tags</strong> (<code>str</code>, <code>list[str]</code> or <code>None</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
Tags to be associated with the model card.`,name:"tags"}],source:"https://github.com/huggingface/trl/blob/main/trl/trainer/prm_trainer.py#L296"}}),se=new Ke({props:{name:"tokenize_row",anchor:"trl.PRMTrainer.tokenize_row",parameters:[{name:"features",val:""},{name:"tokenizer",val:""},{name:"step_separator",val:""},{name:"max_length",val:""},{name:"max_prompt_length",val:""},{name:"max_completion_length",val:""},{name:"train_on_last_step_only",val:""},{name:"is_eval",val:""}],parametersDescription:[{anchor:"trl.PRMTrainer.tokenize_row.features",description:`<strong>features</strong> (<code>dict[str, str]</code>) &#x2014;
Row of the dataset, should contain the keys <code>&quot;prompt&quot;</code>, <code>&quot;completions&quot;</code>, and <code>&quot;labels&quot;</code>.`,name:"features"},{anchor:"trl.PRMTrainer.tokenize_row.tokenizer",description:`<strong>tokenizer</strong> (<code>PreTrainedTokenizerBase</code>) &#x2014;
Tokenizer used to process the data.`,name:"tokenizer"},{anchor:"trl.PRMTrainer.tokenize_row.step_separator",description:`<strong>step_separator</strong> (<code>str</code>) &#x2014;
Separator between steps in the completion.`,name:"step_separator"},{anchor:"trl.PRMTrainer.tokenize_row.max_length",description:`<strong>max_length</strong> (<code>int</code> or <code>None</code>) &#x2014;
Maximum length of the sequences (prompt + completion). If <code>None</code>, the sequences are not truncated.`,name:"max_length"},{anchor:"trl.PRMTrainer.tokenize_row.max_prompt_length",description:`<strong>max_prompt_length</strong> (<code>int</code> or <code>None</code>) &#x2014;
Maximum length of the prompt. If <code>None</code>, the prompt is not truncated.`,name:"max_prompt_length"},{anchor:"trl.PRMTrainer.tokenize_row.max_completion_length",description:`<strong>max_completion_length</strong> (<code>int</code> or <code>None</code>) &#x2014;
Maximum length of the completion sequences. If <code>None</code>, the completion sequences are not truncated.`,name:"max_completion_length"},{anchor:"trl.PRMTrainer.tokenize_row.train_on_last_step_only",description:`<strong>train_on_last_step_only</strong> (<code>bool</code>) &#x2014;
Whether to train only on the last step. If <code>True</code>, the labels are <code>-100</code> for all tokens except the last
token of the completion.`,name:"train_on_last_step_only"},{anchor:"trl.PRMTrainer.tokenize_row.is_eval",description:`<strong>is_eval</strong> (<code>bool</code>) &#x2014;
Whether the function is used to tokenize samples from a training or an evaluation dataset. Used only if <code>train_on_last_step_only</code> is set to <code>True</code>.`,name:"is_eval"}],source:"https://github.com/huggingface/trl/blob/main/trl/trainer/prm_trainer.py#L206",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>Tokenized sequences with the keys <code>"input_ids"</code>, and \`“labels”.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>dict[str, list[int]]</code></p>
`}}),R=new Gt({props:{anchor:"trl.PRMTrainer.tokenize_row.example",$$slots:{default:[Qt]},$$scope:{ctx:ce}}}),le=new me({props:{title:"PRMConfig",local:"trl.PRMConfig",headingTag:"h2"}}),oe=new Ke({props:{name:"class trl.PRMConfig",anchor:"trl.PRMConfig",parameters:[{name:"output_dir",val:": typing.Optional[str] = None"},{name:"overwrite_output_dir",val:": bool = False"},{name:"do_train",val:": bool = False"},{name:"do_eval",val:": bool = False"},{name:"do_predict",val:": bool = False"},{name:"eval_strategy",val:": typing.Union[transformers.trainer_utils.IntervalStrategy, str] = 'no'"},{name:"prediction_loss_only",val:": bool = False"},{name:"per_device_train_batch_size",val:": int = 8"},{name:"per_device_eval_batch_size",val:": int = 8"},{name:"per_gpu_train_batch_size",val:": typing.Optional[int] = None"},{name:"per_gpu_eval_batch_size",val:": typing.Optional[int] = None"},{name:"gradient_accumulation_steps",val:": int = 1"},{name:"eval_accumulation_steps",val:": typing.Optional[int] = None"},{name:"eval_delay",val:": typing.Optional[float] = 0"},{name:"torch_empty_cache_steps",val:": typing.Optional[int] = None"},{name:"learning_rate",val:": float = 1e-05"},{name:"weight_decay",val:": float = 0.0"},{name:"adam_beta1",val:": float = 0.9"},{name:"adam_beta2",val:": float = 0.999"},{name:"adam_epsilon",val:": float = 1e-08"},{name:"max_grad_norm",val:": float = 1.0"},{name:"num_train_epochs",val:": float = 3.0"},{name:"max_steps",val:": int = -1"},{name:"lr_scheduler_type",val:": typing.Union[transformers.trainer_utils.SchedulerType, str] = 'linear'"},{name:"lr_scheduler_kwargs",val:": typing.Union[dict, str, NoneType] = <factory>"},{name:"warmup_ratio",val:": float = 0.0"},{name:"warmup_steps",val:": int = 0"},{name:"log_level",val:": typing.Optional[str] = 'passive'"},{name:"log_level_replica",val:": typing.Optional[str] = 'warning'"},{name:"log_on_each_node",val:": bool = True"},{name:"logging_dir",val:": typing.Optional[str] = None"},{name:"logging_strategy",val:": typing.Union[transformers.trainer_utils.IntervalStrategy, str] = 'steps'"},{name:"logging_first_step",val:": bool = False"},{name:"logging_steps",val:": float = 500"},{name:"logging_nan_inf_filter",val:": bool = True"},{name:"save_strategy",val:": typing.Union[transformers.trainer_utils.SaveStrategy, str] = 'steps'"},{name:"save_steps",val:": float = 500"},{name:"save_total_limit",val:": typing.Optional[int] = None"},{name:"save_safetensors",val:": typing.Optional[bool] = True"},{name:"save_on_each_node",val:": bool = False"},{name:"save_only_model",val:": bool = False"},{name:"restore_callback_states_from_checkpoint",val:": bool = False"},{name:"no_cuda",val:": bool = False"},{name:"use_cpu",val:": bool = False"},{name:"use_mps_device",val:": bool = False"},{name:"seed",val:": int = 42"},{name:"data_seed",val:": typing.Optional[int] = None"},{name:"jit_mode_eval",val:": bool = False"},{name:"use_ipex",val:": bool = False"},{name:"bf16",val:": bool = False"},{name:"fp16",val:": bool = False"},{name:"fp16_opt_level",val:": str = 'O1'"},{name:"half_precision_backend",val:": str = 'auto'"},{name:"bf16_full_eval",val:": bool = False"},{name:"fp16_full_eval",val:": bool = False"},{name:"tf32",val:": typing.Optional[bool] = None"},{name:"local_rank",val:": int = -1"},{name:"ddp_backend",val:": typing.Optional[str] = None"},{name:"tpu_num_cores",val:": typing.Optional[int] = None"},{name:"tpu_metrics_debug",val:": bool = False"},{name:"debug",val:": typing.Union[str, list[transformers.debug_utils.DebugOption]] = ''"},{name:"dataloader_drop_last",val:": bool = False"},{name:"eval_steps",val:": typing.Optional[float] = None"},{name:"dataloader_num_workers",val:": int = 0"},{name:"dataloader_prefetch_factor",val:": typing.Optional[int] = None"},{name:"past_index",val:": int = -1"},{name:"run_name",val:": typing.Optional[str] = None"},{name:"disable_tqdm",val:": typing.Optional[bool] = None"},{name:"remove_unused_columns",val:": typing.Optional[bool] = True"},{name:"label_names",val:": typing.Optional[list[str]] = None"},{name:"load_best_model_at_end",val:": typing.Optional[bool] = False"},{name:"metric_for_best_model",val:": typing.Optional[str] = None"},{name:"greater_is_better",val:": typing.Optional[bool] = None"},{name:"ignore_data_skip",val:": bool = False"},{name:"fsdp",val:": typing.Union[list[transformers.trainer_utils.FSDPOption], str, NoneType] = ''"},{name:"fsdp_min_num_params",val:": int = 0"},{name:"fsdp_config",val:": typing.Union[dict, str, NoneType] = None"},{name:"fsdp_transformer_layer_cls_to_wrap",val:": typing.Optional[str] = None"},{name:"accelerator_config",val:": typing.Union[dict, str, NoneType] = None"},{name:"deepspeed",val:": typing.Union[dict, str, NoneType] = None"},{name:"label_smoothing_factor",val:": float = 0.0"},{name:"optim",val:": typing.Union[transformers.training_args.OptimizerNames, str] = 'adamw_torch'"},{name:"optim_args",val:": typing.Optional[str] = None"},{name:"adafactor",val:": bool = False"},{name:"group_by_length",val:": bool = False"},{name:"length_column_name",val:": typing.Optional[str] = 'length'"},{name:"report_to",val:": typing.Union[NoneType, str, list[str]] = None"},{name:"ddp_find_unused_parameters",val:": typing.Optional[bool] = None"},{name:"ddp_bucket_cap_mb",val:": typing.Optional[int] = None"},{name:"ddp_broadcast_buffers",val:": typing.Optional[bool] = None"},{name:"dataloader_pin_memory",val:": bool = True"},{name:"dataloader_persistent_workers",val:": bool = False"},{name:"skip_memory_metrics",val:": bool = True"},{name:"use_legacy_prediction_loop",val:": bool = False"},{name:"push_to_hub",val:": bool = False"},{name:"resume_from_checkpoint",val:": typing.Optional[str] = None"},{name:"hub_model_id",val:": typing.Optional[str] = None"},{name:"hub_strategy",val:": typing.Union[transformers.trainer_utils.HubStrategy, str] = 'every_save'"},{name:"hub_token",val:": typing.Optional[str] = None"},{name:"hub_private_repo",val:": typing.Optional[bool] = None"},{name:"hub_always_push",val:": bool = False"},{name:"gradient_checkpointing",val:": bool = False"},{name:"gradient_checkpointing_kwargs",val:": typing.Union[dict, str, NoneType] = None"},{name:"include_inputs_for_metrics",val:": bool = False"},{name:"include_for_metrics",val:": list = <factory>"},{name:"eval_do_concat_batches",val:": bool = True"},{name:"fp16_backend",val:": str = 'auto'"},{name:"push_to_hub_model_id",val:": typing.Optional[str] = None"},{name:"push_to_hub_organization",val:": typing.Optional[str] = None"},{name:"push_to_hub_token",val:": typing.Optional[str] = None"},{name:"mp_parameters",val:": str = ''"},{name:"auto_find_batch_size",val:": bool = False"},{name:"full_determinism",val:": bool = False"},{name:"torchdynamo",val:": typing.Optional[str] = None"},{name:"ray_scope",val:": typing.Optional[str] = 'last'"},{name:"ddp_timeout",val:": typing.Optional[int] = 1800"},{name:"torch_compile",val:": bool = False"},{name:"torch_compile_backend",val:": typing.Optional[str] = None"},{name:"torch_compile_mode",val:": typing.Optional[str] = None"},{name:"include_tokens_per_second",val:": typing.Optional[bool] = False"},{name:"include_num_input_tokens_seen",val:": typing.Optional[bool] = False"},{name:"neftune_noise_alpha",val:": typing.Optional[float] = None"},{name:"optim_target_modules",val:": typing.Union[NoneType, str, list[str]] = None"},{name:"batch_eval_metrics",val:": bool = False"},{name:"eval_on_start",val:": bool = False"},{name:"use_liger_kernel",val:": typing.Optional[bool] = False"},{name:"eval_use_gather_object",val:": typing.Optional[bool] = False"},{name:"average_tokens_across_devices",val:": typing.Optional[bool] = False"},{name:"max_length",val:": typing.Optional[int] = 1024"},{name:"max_prompt_length",val:": typing.Optional[int] = 512"},{name:"max_completion_length",val:": typing.Optional[int] = None"},{name:"disable_dropout",val:": bool = True"},{name:"step_separator",val:": str = '\\n'"},{name:"train_on_last_step_only",val:": bool = False"},{name:"dataset_num_proc",val:": typing.Optional[int] = None"}],parametersDescription:[{anchor:"trl.PRMConfig.learning_rate",description:`<strong>learning_rate</strong> (<code>float</code>, <em>optional</em>, defaults to <code>1e-5</code>) &#x2014;
Initial learning rate for <code>AdamW</code> optimizer. The default value replaces that of
<a href="https://huggingface.co/docs/transformers/main/en/main_classes/trainer#transformers.TrainingArguments" rel="nofollow">TrainingArguments</a>.`,name:"learning_rate"},{anchor:"trl.PRMConfig.max_length",description:`<strong>max_length</strong> (<code>int</code> or <code>None</code>, <em>optional</em>, defaults to <code>1024</code>) &#x2014;
Maximum length of the sequences (prompt + completion) used for truncation.`,name:"max_length"},{anchor:"trl.PRMConfig.max_prompt_length",description:`<strong>max_prompt_length</strong> (<code>int</code> or <code>None</code>, <em>optional</em>, defaults to <code>512</code>) &#x2014;
Maximum length of the prompt used for truncation.`,name:"max_prompt_length"},{anchor:"trl.PRMConfig.max_completion_length",description:`<strong>max_completion_length</strong> (<code>int</code> or <code>None</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
Maximum length of the completion used for truncation. The completion is the concatenation of the steps.`,name:"max_completion_length"},{anchor:"trl.PRMConfig.disable_dropout",description:`<strong>disable_dropout</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to disable dropout in the model.`,name:"disable_dropout"},{anchor:"trl.PRMConfig.step_separator",description:`<strong>step_separator</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;\\n&quot;</code>) &#x2014;
Separator used to separate each step of the reasoning process.`,name:"step_separator"},{anchor:"trl.PRMConfig.train_on_last_step_only",description:`<strong>train_on_last_step_only</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to train only on the last step.`,name:"train_on_last_step_only"},{anchor:"trl.PRMConfig.dataset_num_proc",description:`<strong>dataset_num_proc</strong> (<code>int</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
Number of processes to use for processing the dataset.`,name:"dataset_num_proc"}],source:"https://github.com/huggingface/trl/blob/main/trl/trainer/prm_config.py#L21"}}),re=new zt({props:{source:"https://github.com/huggingface/trl/blob/main/docs/source/prm_trainer.md"}}),{c(){i=o("meta"),j=s(),_=o("p"),f=s(),m(T.$$.fragment),M=s(),w=o("p"),w.innerHTML=it,Te=s(),m(x.$$.fragment),we=s(),m($.$$.fragment),ve=s(),k=o("p"),k.innerHTML=pt,Ue=s(),Z=o("p"),Z.textContent=mt,je=s(),B=o("blockquote"),B.innerHTML=ct,Je=s(),F=o("p"),F.innerHTML=dt,Ce=s(),m(G.$$.fragment),Ie=s(),z=o("p"),z.innerHTML=ut,xe=s(),J=o("iframe"),Ne=s(),P=o("p"),P.textContent=gt,Re=s(),m(Q.$$.fragment),$e=s(),W=o("p"),W.textContent=Mt,ke=s(),m(S.$$.fragment),Ze=s(),A=o("p"),A.textContent=_t,Be=s(),E=o("p"),E.innerHTML=yt,Fe=s(),m(H.$$.fragment),Ge=s(),m(V.$$.fragment),ze=s(),X=o("p"),X.textContent=ft,Pe=s(),m(q.$$.fragment),Qe=s(),O=o("p"),O.innerHTML=bt,We=s(),L=o("p"),L.innerHTML=Tt,Se=s(),m(Y.$$.fragment),Ae=s(),D=o("p"),D.innerHTML=wt,Ee=s(),K=o("p"),K.innerHTML=vt,He=s(),m(ee.$$.fragment),Ve=s(),m(te.$$.fragment),Xe=s(),b=o("div"),m(ae.$$.fragment),et=s(),de=o("p"),de.textContent=Ut,tt=s(),N=o("div"),m(ne.$$.fragment),at=s(),ue=o("p"),ue.innerHTML=jt,nt=s(),C=o("div"),m(se.$$.fragment),st=s(),he=o("p"),he.textContent=Jt,lt=s(),m(R.$$.fragment),qe=s(),m(le.$$.fragment),Oe=s(),v=o("div"),m(oe.$$.fragment),ot=s(),ge=o("p"),ge.innerHTML=Ct,rt=s(),Me=o("p"),Me.innerHTML=It,Le=s(),m(re.$$.fragment),Ye=s(),be=o("p"),this.h()},l(e){const t=Bt("svelte-u9bgzb",document.head);i=r(t,"META",{name:!0,content:!0}),t.forEach(a),j=l(e),_=r(e,"P",{}),pe(_).forEach(a),f=l(e),c(T.$$.fragment,e),M=l(e),w=r(e,"P",{"data-svelte-h":!0}),p(w)!=="svelte-kgtqhs"&&(w.innerHTML=it),Te=l(e),c(x.$$.fragment,e),we=l(e),c($.$$.fragment,e),ve=l(e),k=r(e,"P",{"data-svelte-h":!0}),p(k)!=="svelte-v5xjil"&&(k.innerHTML=pt),Ue=l(e),Z=r(e,"P",{"data-svelte-h":!0}),p(Z)!=="svelte-vfdo9a"&&(Z.textContent=mt),je=l(e),B=r(e,"BLOCKQUOTE",{"data-svelte-h":!0}),p(B)!=="svelte-11damdv"&&(B.innerHTML=ct),Je=l(e),F=r(e,"P",{"data-svelte-h":!0}),p(F)!=="svelte-1iwfw6s"&&(F.innerHTML=dt),Ce=l(e),c(G.$$.fragment,e),Ie=l(e),z=r(e,"P",{"data-svelte-h":!0}),p(z)!=="svelte-17j87gb"&&(z.innerHTML=ut),xe=l(e),J=r(e,"IFRAME",{src:!0,frameborder:!0,width:!0,height:!0}),pe(J).forEach(a),Ne=l(e),P=r(e,"P",{"data-svelte-h":!0}),p(P)!=="svelte-uqytq6"&&(P.textContent=gt),Re=l(e),c(Q.$$.fragment,e),$e=l(e),W=r(e,"P",{"data-svelte-h":!0}),p(W)!=="svelte-15hino8"&&(W.textContent=Mt),ke=l(e),c(S.$$.fragment,e),Ze=l(e),A=r(e,"P",{"data-svelte-h":!0}),p(A)!=="svelte-176uwjg"&&(A.textContent=_t),Be=l(e),E=r(e,"P",{"data-svelte-h":!0}),p(E)!=="svelte-1yvg09c"&&(E.innerHTML=yt),Fe=l(e),c(H.$$.fragment,e),Ge=l(e),c(V.$$.fragment,e),ze=l(e),X=r(e,"P",{"data-svelte-h":!0}),p(X)!=="svelte-1vnfy6r"&&(X.textContent=ft),Pe=l(e),c(q.$$.fragment,e),Qe=l(e),O=r(e,"P",{"data-svelte-h":!0}),p(O)!=="svelte-1lz4rfk"&&(O.innerHTML=bt),We=l(e),L=r(e,"P",{"data-svelte-h":!0}),p(L)!=="svelte-1hxm2xc"&&(L.innerHTML=Tt),Se=l(e),c(Y.$$.fragment,e),Ae=l(e),D=r(e,"P",{"data-svelte-h":!0}),p(D)!=="svelte-fc6d7p"&&(D.innerHTML=wt),Ee=l(e),K=r(e,"P",{"data-svelte-h":!0}),p(K)!=="svelte-du9v1s"&&(K.innerHTML=vt),He=l(e),c(ee.$$.fragment,e),Ve=l(e),c(te.$$.fragment,e),Xe=l(e),b=r(e,"DIV",{class:!0});var U=pe(b);c(ae.$$.fragment,U),et=l(U),de=r(U,"P",{"data-svelte-h":!0}),p(de)!=="svelte-swzzi2"&&(de.textContent=Ut),tt=l(U),N=r(U,"DIV",{class:!0});var ie=pe(N);c(ne.$$.fragment,ie),at=l(ie),ue=r(ie,"P",{"data-svelte-h":!0}),p(ue)!=="svelte-1mh859w"&&(ue.innerHTML=jt),ie.forEach(a),nt=l(U),C=r(U,"DIV",{class:!0});var _e=pe(C);c(se.$$.fragment,_e),st=l(_e),he=r(_e,"P",{"data-svelte-h":!0}),p(he)!=="svelte-dujibq"&&(he.textContent=Jt),lt=l(_e),c(R.$$.fragment,_e),_e.forEach(a),U.forEach(a),qe=l(e),c(le.$$.fragment,e),Oe=l(e),v=r(e,"DIV",{class:!0});var ye=pe(v);c(oe.$$.fragment,ye),ot=l(ye),ge=r(ye,"P",{"data-svelte-h":!0}),p(ge)!=="svelte-1le16mb"&&(ge.innerHTML=Ct),rt=l(ye),Me=r(ye,"P",{"data-svelte-h":!0}),p(Me)!=="svelte-ekuf1t"&&(Me.innerHTML=It),ye.forEach(a),Le=l(e),c(re.$$.fragment,e),Ye=l(e),be=r(e,"P",{}),pe(be).forEach(a),this.h()},h(){I(i,"name","hf:doc:metadata"),I(i,"content",St),Rt(J.src,ht="https://huggingface.co/datasets/trl-lib/math_shepherd/embed/viewer/default/train?row=0")||I(J,"src",ht),I(J,"frameborder","0"),I(J,"width","100%"),I(J,"height","560px"),I(N,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),I(C,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),I(b,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),I(v,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(e,t){y(document.head,i),n(e,j,t),n(e,_,t),n(e,f,t),d(T,e,t),n(e,M,t),n(e,w,t),n(e,Te,t),d(x,e,t),n(e,we,t),d($,e,t),n(e,ve,t),n(e,k,t),n(e,Ue,t),n(e,Z,t),n(e,je,t),n(e,B,t),n(e,Je,t),n(e,F,t),n(e,Ce,t),d(G,e,t),n(e,Ie,t),n(e,z,t),n(e,xe,t),n(e,J,t),n(e,Ne,t),n(e,P,t),n(e,Re,t),d(Q,e,t),n(e,$e,t),n(e,W,t),n(e,ke,t),d(S,e,t),n(e,Ze,t),n(e,A,t),n(e,Be,t),n(e,E,t),n(e,Fe,t),d(H,e,t),n(e,Ge,t),d(V,e,t),n(e,ze,t),n(e,X,t),n(e,Pe,t),d(q,e,t),n(e,Qe,t),n(e,O,t),n(e,We,t),n(e,L,t),n(e,Se,t),d(Y,e,t),n(e,Ae,t),n(e,D,t),n(e,Ee,t),n(e,K,t),n(e,He,t),d(ee,e,t),n(e,Ve,t),d(te,e,t),n(e,Xe,t),n(e,b,t),d(ae,b,null),y(b,et),y(b,de),y(b,tt),y(b,N),d(ne,N,null),y(N,at),y(N,ue),y(b,nt),y(b,C),d(se,C,null),y(C,st),y(C,he),y(C,lt),d(R,C,null),n(e,qe,t),d(le,e,t),n(e,Oe,t),n(e,v,t),d(oe,v,null),y(v,ot),y(v,ge),y(v,rt),y(v,Me),n(e,Le,t),d(re,e,t),n(e,Ye,t),n(e,be,t),De=!0},p(e,[t]){const U={};t&2&&(U.$$scope={dirty:t,ctx:e}),x.$set(U);const ie={};t&2&&(ie.$$scope={dirty:t,ctx:e}),R.$set(ie)},i(e){De||(u(T.$$.fragment,e),u(x.$$.fragment,e),u($.$$.fragment,e),u(G.$$.fragment,e),u(Q.$$.fragment,e),u(S.$$.fragment,e),u(H.$$.fragment,e),u(V.$$.fragment,e),u(q.$$.fragment,e),u(Y.$$.fragment,e),u(ee.$$.fragment,e),u(te.$$.fragment,e),u(ae.$$.fragment,e),u(ne.$$.fragment,e),u(se.$$.fragment,e),u(R.$$.fragment,e),u(le.$$.fragment,e),u(oe.$$.fragment,e),u(re.$$.fragment,e),De=!0)},o(e){h(T.$$.fragment,e),h(x.$$.fragment,e),h($.$$.fragment,e),h(G.$$.fragment,e),h(Q.$$.fragment,e),h(S.$$.fragment,e),h(H.$$.fragment,e),h(V.$$.fragment,e),h(q.$$.fragment,e),h(Y.$$.fragment,e),h(ee.$$.fragment,e),h(te.$$.fragment,e),h(ae.$$.fragment,e),h(ne.$$.fragment,e),h(se.$$.fragment,e),h(R.$$.fragment,e),h(le.$$.fragment,e),h(oe.$$.fragment,e),h(re.$$.fragment,e),De=!1},d(e){e&&(a(j),a(_),a(f),a(M),a(w),a(Te),a(we),a(ve),a(k),a(Ue),a(Z),a(je),a(B),a(Je),a(F),a(Ce),a(Ie),a(z),a(xe),a(J),a(Ne),a(P),a(Re),a($e),a(W),a(ke),a(Ze),a(A),a(Be),a(E),a(Fe),a(Ge),a(ze),a(X),a(Pe),a(Qe),a(O),a(We),a(L),a(Se),a(Ae),a(D),a(Ee),a(K),a(He),a(Ve),a(Xe),a(b),a(qe),a(Oe),a(v),a(Le),a(Ye),a(be)),a(i),g(T,e),g(x,e),g($,e),g(G,e),g(Q,e),g(S,e),g(H,e),g(V,e),g(q,e),g(Y,e),g(ee,e),g(te,e),g(ae),g(ne),g(se),g(R),g(le,e),g(oe),g(re,e)}}}const St='{"title":"PRM Trainer","local":"prm-trainer","sections":[{"title":"Overview","local":"overview","sections":[],"depth":2},{"title":"Quick start","local":"quick-start","sections":[],"depth":2},{"title":"Expected dataset type","local":"expected-dataset-type","sections":[],"depth":2},{"title":"Example script","local":"example-script","sections":[],"depth":2},{"title":"PRMTrainer","local":"trl.PRMTrainer","sections":[],"depth":2},{"title":"PRMConfig","local":"trl.PRMConfig","sections":[],"depth":2}],"depth":1}';function At(ce){return $t(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Yt extends kt{constructor(i){super(),Zt(this,i,At,Wt,Nt,{})}}export{Yt as component};
