Buckets:

hf-doc-build/doc-dev / autotrain /pr_749 /en /llm_finetuning_params.html
rtrm's picture
download
raw
41.4 kB
<meta charset="utf-8" /><meta name="hf:doc:metadata" content="{&quot;title&quot;:&quot;LLM Fine Tuning Parameters&quot;,&quot;local&quot;:&quot;llm-fine-tuning-parameters&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;Task specific parameters&quot;,&quot;local&quot;:&quot;task-specific-parameters&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;Generic Trainer&quot;,&quot;local&quot;:&quot;generic-trainer&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;SFT Trainer&quot;,&quot;local&quot;:&quot;sft-trainer&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;Reward Trainer&quot;,&quot;local&quot;:&quot;reward-trainer&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;DPO Trainer&quot;,&quot;local&quot;:&quot;dpo-trainer&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;ORPO Trainer&quot;,&quot;local&quot;:&quot;orpo-trainer&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3}],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Common parameters&quot;,&quot;local&quot;:&quot;common-parameters&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2}],&quot;depth&quot;:1}">
<link href="/docs/autotrain/pr_749/en/_app/immutable/assets/0.e3b0c442.css" rel="modulepreload">
<link rel="modulepreload" href="/docs/autotrain/pr_749/en/_app/immutable/entry/start.b4f8a0ef.js">
<link rel="modulepreload" href="/docs/autotrain/pr_749/en/_app/immutable/chunks/scheduler.0219f8bd.js">
<link rel="modulepreload" href="/docs/autotrain/pr_749/en/_app/immutable/chunks/singletons.74a96c49.js">
<link rel="modulepreload" href="/docs/autotrain/pr_749/en/_app/immutable/chunks/paths.5815e531.js">
<link rel="modulepreload" href="/docs/autotrain/pr_749/en/_app/immutable/entry/app.4f18d4a0.js">
<link rel="modulepreload" href="/docs/autotrain/pr_749/en/_app/immutable/chunks/index.f61edf3b.js">
<link rel="modulepreload" href="/docs/autotrain/pr_749/en/_app/immutable/nodes/0.3ba41ccf.js">
<link rel="modulepreload" href="/docs/autotrain/pr_749/en/_app/immutable/nodes/17.20910092.js">
<link rel="modulepreload" href="/docs/autotrain/pr_749/en/_app/immutable/chunks/CodeBlock.38e566ae.js">
<link rel="modulepreload" href="/docs/autotrain/pr_749/en/_app/immutable/chunks/EditOnGithub.48fa589f.js"><!-- HEAD_svelte-u9bgzb_START --><meta name="hf:doc:metadata" content="{&quot;title&quot;:&quot;LLM Fine Tuning Parameters&quot;,&quot;local&quot;:&quot;llm-fine-tuning-parameters&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;Task specific parameters&quot;,&quot;local&quot;:&quot;task-specific-parameters&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;Generic Trainer&quot;,&quot;local&quot;:&quot;generic-trainer&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;SFT Trainer&quot;,&quot;local&quot;:&quot;sft-trainer&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;Reward Trainer&quot;,&quot;local&quot;:&quot;reward-trainer&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;DPO Trainer&quot;,&quot;local&quot;:&quot;dpo-trainer&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;ORPO Trainer&quot;,&quot;local&quot;:&quot;orpo-trainer&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3}],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Common parameters&quot;,&quot;local&quot;:&quot;common-parameters&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2}],&quot;depth&quot;:1}"><!-- HEAD_svelte-u9bgzb_END --> <p></p> <h1 class="relative group"><a id="llm-fine-tuning-parameters" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#llm-fine-tuning-parameters"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>LLM Fine Tuning Parameters</span></h1> <h2 class="relative group"><a id="task-specific-parameters" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#task-specific-parameters"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Task specific parameters</span></h2> <p data-svelte-h="svelte-e4s8t7">The length parameters used for different trainers can be different. Some require more context than others.</p> <ul data-svelte-h="svelte-fndsqh"><li>block_size: This is the maximum sequence length or length of one block of text. Setting to -1 determines block size automatically. Default is -1.</li> <li>model_max_length: Set the maximum length for the model to process in a single batch, which can affect both performance and memory usage. Default is 1024</li> <li>max_prompt_length: Specify the maximum length for prompts used in training, particularly relevant for tasks requiring initial contextual input. Used only for <code>orpo</code> and <code>dpo</code> trainer.</li> <li>max_completion_length: Completion length to use, for orpo: encoder-decoder models only. For dpo, it is the length of the completion text.</li></ul> <p data-svelte-h="svelte-tqxemj"><strong>NOTE</strong>:</p> <ul data-svelte-h="svelte-12l6tzi"><li>block size cannot be greater than model_max_length!</li> <li>max_prompt_length cannot be greater than model_max_length!</li> <li>max_prompt_length cannot be greater than block_size!</li> <li>max_completion_length cannot be greater than model_max_length!</li> <li>max_completion_length cannot be greater than block_size!</li></ul> <p data-svelte-h="svelte-4yc3zu"><strong>NOTE</strong>: Not following these constraints will result in an error / nan losses.</p> <h3 class="relative group"><a id="generic-trainer" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#generic-trainer"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Generic Trainer</span></h3> <div class="code-block relative"><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START --><span class="hljs-comment">--add_eos_token, --add-eos-token</span>
Toggle whether <span class="hljs-keyword">to</span> automatically <span class="hljs-keyword">add</span> an <span class="hljs-keyword">End</span> <span class="hljs-keyword">Of</span> Sentence (EOS) token at the <span class="hljs-keyword">end</span> <span class="hljs-keyword">of</span> texts, which can be critical <span class="hljs-keyword">for</span> certain
<span class="hljs-keyword">types</span> <span class="hljs-keyword">of</span> models <span class="hljs-keyword">like</span> <span class="hljs-keyword">language</span> models. <span class="hljs-keyword">Only</span> used <span class="hljs-keyword">for</span> `<span class="hljs-keyword">default</span>` trainer
<span class="hljs-comment">--block_size BLOCK_SIZE, --block-size BLOCK_SIZE</span>
Specify the block size <span class="hljs-keyword">for</span> processing <span class="hljs-keyword">sequences</span>. This <span class="hljs-keyword">is</span> maximum <span class="hljs-keyword">sequence</span> length <span class="hljs-keyword">or</span> length <span class="hljs-keyword">of</span> one block <span class="hljs-keyword">of</span> <span class="hljs-type">text</span>. Setting <span class="hljs-keyword">to</span>
<span class="hljs-number">-1</span> determines block size automatically. <span class="hljs-keyword">Default</span> <span class="hljs-keyword">is</span> <span class="hljs-number">-1.</span>
<span class="hljs-comment">--model_max_length MODEL_MAX_LENGTH, --model-max-length MODEL_MAX_LENGTH</span>
<span class="hljs-keyword">Set</span> the maximum length <span class="hljs-keyword">for</span> the model <span class="hljs-keyword">to</span> process <span class="hljs-keyword">in</span> a single batch, which can affect <span class="hljs-keyword">both</span> performance <span class="hljs-keyword">and</span> memory <span class="hljs-keyword">usage</span>.
<span class="hljs-keyword">Default</span> <span class="hljs-keyword">is</span> <span class="hljs-number">1024</span><!-- HTML_TAG_END --></pre></div> <h3 class="relative group"><a id="sft-trainer" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#sft-trainer"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>SFT Trainer</span></h3> <div class="code-block relative"><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START --><span class="hljs-comment">--block_size BLOCK_SIZE, --block-size BLOCK_SIZE</span>
Specify the block size <span class="hljs-keyword">for</span> processing <span class="hljs-keyword">sequences</span>. This <span class="hljs-keyword">is</span> maximum <span class="hljs-keyword">sequence</span> length <span class="hljs-keyword">or</span> length <span class="hljs-keyword">of</span> one block <span class="hljs-keyword">of</span> <span class="hljs-type">text</span>. Setting <span class="hljs-keyword">to</span>
<span class="hljs-number">-1</span> determines block size automatically. <span class="hljs-keyword">Default</span> <span class="hljs-keyword">is</span> <span class="hljs-number">-1.</span>
<span class="hljs-comment">--model_max_length MODEL_MAX_LENGTH, --model-max-length MODEL_MAX_LENGTH</span>
<span class="hljs-keyword">Set</span> the maximum length <span class="hljs-keyword">for</span> the model <span class="hljs-keyword">to</span> process <span class="hljs-keyword">in</span> a single batch, which can affect <span class="hljs-keyword">both</span> performance <span class="hljs-keyword">and</span> memory <span class="hljs-keyword">usage</span>.
<span class="hljs-keyword">Default</span> <span class="hljs-keyword">is</span> <span class="hljs-number">1024</span><!-- HTML_TAG_END --></pre></div> <h3 class="relative group"><a id="reward-trainer" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#reward-trainer"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Reward Trainer</span></h3> <div class="code-block relative"><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START --><span class="hljs-comment">--block_size BLOCK_SIZE, --block-size BLOCK_SIZE</span>
Specify the block size <span class="hljs-keyword">for</span> processing <span class="hljs-keyword">sequences</span>. This <span class="hljs-keyword">is</span> maximum <span class="hljs-keyword">sequence</span> length <span class="hljs-keyword">or</span> length <span class="hljs-keyword">of</span> one block <span class="hljs-keyword">of</span> <span class="hljs-type">text</span>. Setting <span class="hljs-keyword">to</span>
<span class="hljs-number">-1</span> determines block size automatically. <span class="hljs-keyword">Default</span> <span class="hljs-keyword">is</span> <span class="hljs-number">-1.</span>
<span class="hljs-comment">--model_max_length MODEL_MAX_LENGTH, --model-max-length MODEL_MAX_LENGTH</span>
<span class="hljs-keyword">Set</span> the maximum length <span class="hljs-keyword">for</span> the model <span class="hljs-keyword">to</span> process <span class="hljs-keyword">in</span> a single batch, which can affect <span class="hljs-keyword">both</span> performance <span class="hljs-keyword">and</span> memory <span class="hljs-keyword">usage</span>.
<span class="hljs-keyword">Default</span> <span class="hljs-keyword">is</span> <span class="hljs-number">1024</span><!-- HTML_TAG_END --></pre></div> <h3 class="relative group"><a id="dpo-trainer" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#dpo-trainer"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>DPO Trainer</span></h3> <div class="code-block relative"><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START --><span class="hljs-comment">--dpo-beta DPO_BETA, --dpo-beta DPO_BETA</span>
Beta <span class="hljs-keyword">for</span> DPO trainer
<span class="hljs-comment">--model-ref MODEL_REF</span>
Reference model <span class="hljs-keyword">to</span> use <span class="hljs-keyword">for</span> DPO <span class="hljs-keyword">when</span> <span class="hljs-keyword">not</span> <span class="hljs-keyword">using</span> PEFT
<span class="hljs-comment">--block_size BLOCK_SIZE, --block-size BLOCK_SIZE</span>
Specify the block size <span class="hljs-keyword">for</span> processing <span class="hljs-keyword">sequences</span>. This <span class="hljs-keyword">is</span> maximum <span class="hljs-keyword">sequence</span> length <span class="hljs-keyword">or</span> length <span class="hljs-keyword">of</span> one block <span class="hljs-keyword">of</span> <span class="hljs-type">text</span>. Setting <span class="hljs-keyword">to</span>
<span class="hljs-number">-1</span> determines block size automatically. <span class="hljs-keyword">Default</span> <span class="hljs-keyword">is</span> <span class="hljs-number">-1.</span>
<span class="hljs-comment">--model_max_length MODEL_MAX_LENGTH, --model-max-length MODEL_MAX_LENGTH</span>
<span class="hljs-keyword">Set</span> the maximum length <span class="hljs-keyword">for</span> the model <span class="hljs-keyword">to</span> process <span class="hljs-keyword">in</span> a single batch, which can affect <span class="hljs-keyword">both</span> performance <span class="hljs-keyword">and</span> memory <span class="hljs-keyword">usage</span>.
<span class="hljs-keyword">Default</span> <span class="hljs-keyword">is</span> <span class="hljs-number">1024</span>
<span class="hljs-comment">--max_prompt_length MAX_PROMPT_LENGTH, --max-prompt-length MAX_PROMPT_LENGTH</span>
Specify the maximum length <span class="hljs-keyword">for</span> prompts used <span class="hljs-keyword">in</span> training, particularly relevant <span class="hljs-keyword">for</span> tasks requiring initial contextual <span class="hljs-keyword">input</span>.
Used <span class="hljs-keyword">only</span> <span class="hljs-keyword">for</span> `orpo` trainer.
<span class="hljs-comment">--max_completion_length MAX_COMPLETION_LENGTH, --max-completion-length MAX_COMPLETION_LENGTH</span>
Completion length <span class="hljs-keyword">to</span> use, <span class="hljs-keyword">for</span> orpo: encoder-decoder models <span class="hljs-keyword">only</span><!-- HTML_TAG_END --></pre></div> <h3 class="relative group"><a id="orpo-trainer" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#orpo-trainer"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>ORPO Trainer</span></h3> <div class="code-block relative"><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START --><span class="hljs-comment">--block_size BLOCK_SIZE, --block-size BLOCK_SIZE</span>
Specify the block size <span class="hljs-keyword">for</span> processing <span class="hljs-keyword">sequences</span>. This <span class="hljs-keyword">is</span> maximum <span class="hljs-keyword">sequence</span> length <span class="hljs-keyword">or</span> length <span class="hljs-keyword">of</span> one block <span class="hljs-keyword">of</span> <span class="hljs-type">text</span>. Setting <span class="hljs-keyword">to</span>
<span class="hljs-number">-1</span> determines block size automatically. <span class="hljs-keyword">Default</span> <span class="hljs-keyword">is</span> <span class="hljs-number">-1.</span>
<span class="hljs-comment">--model_max_length MODEL_MAX_LENGTH, --model-max-length MODEL_MAX_LENGTH</span>
<span class="hljs-keyword">Set</span> the maximum length <span class="hljs-keyword">for</span> the model <span class="hljs-keyword">to</span> process <span class="hljs-keyword">in</span> a single batch, which can affect <span class="hljs-keyword">both</span> performance <span class="hljs-keyword">and</span> memory <span class="hljs-keyword">usage</span>.
<span class="hljs-keyword">Default</span> <span class="hljs-keyword">is</span> <span class="hljs-number">1024</span>
<span class="hljs-comment">--max_prompt_length MAX_PROMPT_LENGTH, --max-prompt-length MAX_PROMPT_LENGTH</span>
Specify the maximum length <span class="hljs-keyword">for</span> prompts used <span class="hljs-keyword">in</span> training, particularly relevant <span class="hljs-keyword">for</span> tasks requiring initial contextual <span class="hljs-keyword">input</span>.
Used <span class="hljs-keyword">only</span> <span class="hljs-keyword">for</span> `orpo` trainer.
<span class="hljs-comment">--max_completion_length MAX_COMPLETION_LENGTH, --max-completion-length MAX_COMPLETION_LENGTH</span>
Completion length <span class="hljs-keyword">to</span> use, <span class="hljs-keyword">for</span> orpo: encoder-decoder models <span class="hljs-keyword">only</span><!-- HTML_TAG_END --></pre></div> <h2 class="relative group"><a id="common-parameters" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#common-parameters"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Common parameters</span></h2> <div class="code-block relative"><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START --><span class="hljs-comment">--batch-size BATCH_SIZE, --train-batch-size BATCH_SIZE</span>
Training batch size <span class="hljs-keyword">to</span> <span class="hljs-keyword">use</span>
<span class="hljs-comment">--seed SEED Random seed for reproducibility</span>
<span class="hljs-comment">--epochs EPOCHS Number of training epochs</span>
<span class="hljs-comment">--gradient_accumulation GRADIENT_ACCUMULATION, --gradient-accumulation GRADIENT_ACCUMULATION</span>
Gradient accumulation steps
<span class="hljs-comment">--disable_gradient_checkpointing, --disable-gradient-checkpointing, --disable-gc</span>
Disable gradient checkpointing
<span class="hljs-comment">--lr LR Learning rate</span>
<span class="hljs-comment">--log {none,wandb,tensorboard}</span>
<span class="hljs-keyword">Use</span> experiment tracking
<span class="hljs-comment">--warmup_ratio WARMUP_RATIO, --warmup-ratio WARMUP_RATIO</span>
Set the proportion <span class="hljs-keyword">of</span> training allocated <span class="hljs-keyword">to</span> warming up the learning rate, which can enhance model stability <span class="hljs-keyword">and</span> performance
at the start <span class="hljs-keyword">of</span> training. <span class="hljs-keyword">Default</span> <span class="hljs-keyword">is</span> <span class="hljs-number">0.1</span>
<span class="hljs-comment">--optimizer OPTIMIZER</span>
Choose the optimizer algorithm <span class="hljs-keyword">for</span> training the model. Different optimizers can affect the training speed <span class="hljs-keyword">and</span> model
performance. <span class="hljs-symbol">&#x27;adamw_torch</span>&#x27; <span class="hljs-keyword">is</span> used by <span class="hljs-keyword">default</span>.
<span class="hljs-comment">--scheduler SCHEDULER</span>
<span class="hljs-keyword">Select</span> the learning rate scheduler <span class="hljs-keyword">to</span> adjust the learning rate based <span class="hljs-keyword">on</span> the number <span class="hljs-keyword">of</span> epochs. <span class="hljs-symbol">&#x27;linear</span>&#x27; decreases the
learning rate linearly from the initial lr set. <span class="hljs-keyword">Default</span> <span class="hljs-keyword">is</span> <span class="hljs-symbol">&#x27;linear</span>&#x27;. Try <span class="hljs-symbol">&#x27;cosine</span>&#x27; <span class="hljs-keyword">for</span> a cosine annealing schedule.
<span class="hljs-comment">--weight_decay WEIGHT_DECAY, --weight-decay WEIGHT_DECAY</span>
Define the weight decay rate <span class="hljs-keyword">for</span> regularization, which helps prevent overfitting by penalizing larger weights. <span class="hljs-keyword">Default</span> <span class="hljs-keyword">is</span>
<span class="hljs-number">0.0</span>
<span class="hljs-comment">--max_grad_norm MAX_GRAD_NORM, --max-grad-norm MAX_GRAD_NORM</span>
Set the maximum norm <span class="hljs-keyword">for</span> gradient clipping, which <span class="hljs-keyword">is</span> critical <span class="hljs-keyword">for</span> preventing gradients from exploding during
backpropagation. <span class="hljs-keyword">Default</span> <span class="hljs-keyword">is</span> <span class="hljs-number">1.0</span>.
<span class="hljs-comment">--peft, --use-peft Enable LoRA-PEFT</span>
<span class="hljs-comment">--lora_r LORA_R, --lora-r LORA_R</span>
Set the <span class="hljs-symbol">&#x27;r</span>&#x27; <span class="hljs-keyword">parameter</span> <span class="hljs-keyword">for</span> Low-Rank Adaptation (LoRA). <span class="hljs-keyword">Default</span> <span class="hljs-keyword">is</span> <span class="hljs-number">16</span>.
<span class="hljs-comment">--lora_alpha LORA_ALPHA, --lora-alpha LORA_ALPHA</span>
Specify the <span class="hljs-symbol">&#x27;alpha</span>&#x27; <span class="hljs-keyword">parameter</span> <span class="hljs-keyword">for</span> LoRA. <span class="hljs-keyword">Default</span> <span class="hljs-keyword">is</span> <span class="hljs-number">32</span>.
<span class="hljs-comment">--lora_dropout LORA_DROPOUT, --lora-dropout LORA_DROPOUT</span>
Set the dropout rate within the LoRA layers <span class="hljs-keyword">to</span> help prevent overfitting during adaptation. <span class="hljs-keyword">Default</span> <span class="hljs-keyword">is</span> <span class="hljs-number">0.05</span>.
<span class="hljs-comment">--logging_steps LOGGING_STEPS, --logging-steps LOGGING_STEPS</span>
Determine how often <span class="hljs-keyword">to</span> log training progress <span class="hljs-keyword">in</span> terms <span class="hljs-keyword">of</span> steps. Setting it <span class="hljs-keyword">to</span> &#x27;-<span class="hljs-number">1</span>&#x27; determines logging steps automatically.
<span class="hljs-comment">--eval_strategy {epoch,steps,no}, --eval-strategy {epoch,steps,no}</span>
Choose how frequently <span class="hljs-keyword">to</span> evaluate the model<span class="hljs-symbol">&#x27;s</span> performance, <span class="hljs-keyword">with</span> <span class="hljs-symbol">&#x27;epoch</span>&#x27; as the <span class="hljs-keyword">default</span>, meaning at the <span class="hljs-keyword">end</span> <span class="hljs-keyword">of</span> each training
epoch
<span class="hljs-comment">--save_total_limit SAVE_TOTAL_LIMIT, --save-total-limit SAVE_TOTAL_LIMIT</span>
Limit the total number <span class="hljs-keyword">of</span> saved model checkpoints <span class="hljs-keyword">to</span> manage disk usage effectively. <span class="hljs-keyword">Default</span> <span class="hljs-keyword">is</span> <span class="hljs-keyword">to</span> save only the latest
checkpoint
<span class="hljs-comment">--auto_find_batch_size, --auto-find-batch-size</span>
Automatically determine the optimal batch size based <span class="hljs-keyword">on</span> system capabilities <span class="hljs-keyword">to</span> maximize efficiency.
<span class="hljs-comment">--mixed_precision {fp16,bf16,None}, --mixed-precision {fp16,bf16,None}</span>
Choose the precision mode <span class="hljs-keyword">for</span> training <span class="hljs-keyword">to</span> optimize performance <span class="hljs-keyword">and</span> memory usage. Options are <span class="hljs-symbol">&#x27;fp16</span>&#x27;, <span class="hljs-symbol">&#x27;bf16</span>&#x27;, <span class="hljs-keyword">or</span> None <span class="hljs-keyword">for</span>
<span class="hljs-keyword">default</span> precision. <span class="hljs-keyword">Default</span> <span class="hljs-keyword">is</span> None.
<span class="hljs-comment">--quantization {int4,int8,None}, --quantization {int4,int8,None}</span>
Choose the quantization level <span class="hljs-keyword">to</span> reduce model size <span class="hljs-keyword">and</span> potentially increase inference speed. Options include <span class="hljs-symbol">&#x27;int4</span>&#x27;, <span class="hljs-symbol">&#x27;int8</span>&#x27;,
<span class="hljs-keyword">or</span> None. Enabling requires <span class="hljs-comment">--peft</span>
<span class="hljs-comment">--trainer {default,dpo,sft,orpo,reward}</span>
Trainer <span class="hljs-keyword">type</span> <span class="hljs-keyword">to</span> <span class="hljs-keyword">use</span>
<span class="hljs-comment">--target_modules TARGET_MODULES, --target-modules TARGET_MODULES</span>
Identify specific modules within the model <span class="hljs-keyword">architecture</span> <span class="hljs-keyword">to</span> target <span class="hljs-keyword">with</span> adaptations <span class="hljs-keyword">or</span> optimizations, such as LoRA. Comma
separated list <span class="hljs-keyword">of</span> module names. <span class="hljs-keyword">Default</span> <span class="hljs-keyword">is</span> <span class="hljs-symbol">&#x27;all</span>-linear&#x27;.
<span class="hljs-comment">--merge_adapter, --merge-adapter</span>
<span class="hljs-keyword">Use</span> this flag <span class="hljs-keyword">to</span> merge PEFT adapter <span class="hljs-keyword">with</span> the model
<span class="hljs-comment">--use_flash_attention_2, --use-flash-attention-2, --use-fa2</span>
<span class="hljs-keyword">Use</span> flash attention <span class="hljs-number">2</span>
<span class="hljs-comment">--chat_template {tokenizer,chatml,zephyr,None}, --chat-template {tokenizer,chatml,zephyr,None}</span>
Apply a specific template <span class="hljs-keyword">for</span> chat-based interactions, <span class="hljs-keyword">with</span> options including <span class="hljs-symbol">&#x27;tokenizer</span>&#x27;, <span class="hljs-symbol">&#x27;chatml</span>&#x27;, <span class="hljs-symbol">&#x27;zephyr</span>&#x27;, <span class="hljs-keyword">or</span> None. This
setting can shape the model<span class="hljs-symbol">&#x27;s</span> conversational behavior.
<span class="hljs-comment">--padding {left,right,None}, --padding {left,right,None}</span>
Specify the padding direction <span class="hljs-keyword">for</span> sequences, critical <span class="hljs-keyword">for</span> models sensitive <span class="hljs-keyword">to</span> input alignment. Options include <span class="hljs-symbol">&#x27;left</span>&#x27;,
<span class="hljs-symbol">&#x27;right</span>&#x27;, <span class="hljs-keyword">or</span> None<!-- HTML_TAG_END --></pre></div> <a class="!text-gray-400 !no-underline text-sm flex items-center not-prose mt-4" href="https://github.com/huggingface/autotrain-advanced/blob/main/docs/source/llm_finetuning_params.mdx" target="_blank"><span data-svelte-h="svelte-1kd6by1">&lt;</span> <span data-svelte-h="svelte-x0xyl0">&gt;</span> <span data-svelte-h="svelte-1dajgef"><span class="underline ml-1.5">Update</span> on GitHub</span></a> <p></p>
<script>
{
__sveltekit_ewvlbq = {
assets: "/docs/autotrain/pr_749/en",
base: "/docs/autotrain/pr_749/en",
env: {}
};
const element = document.currentScript.parentElement;
const data = [null,null];
Promise.all([
import("/docs/autotrain/pr_749/en/_app/immutable/entry/start.b4f8a0ef.js"),
import("/docs/autotrain/pr_749/en/_app/immutable/entry/app.4f18d4a0.js")
]).then(([kit, app]) => {
kit.start(app, element, {
node_ids: [0, 17],
data,
form: null,
error: null
});
});
}
</script>

Xet Storage Details

Size:
41.4 kB
·
Xet hash:
42e80b2e78e5e37efa86ce4b878244bf082c434f7ed307a267c588b5a539262e

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.