import{s as Ee,o as Fe,n as Je}from"../chunks/scheduler.d627b047.js";import{S as Ne,i as Be,g as m,s as n,r as u,A as He,h as g,f as o,c as l,j as V,u as h,x as k,k as W,y as s,a as w,v as _,d as $,t as b,w as y}from"../chunks/index.73c51727.js";import{D as ae}from"../chunks/Docstring.0ad99a5d.js";import{C as ke}from"../chunks/CodeBlock.5f78c87f.js";import{E as xe}from"../chunks/ExampleCodeBlock.e6081cec.js";import{H as Me,E as Ge}from"../chunks/index.8df1db42.js";function Ve(A){let t,d="Examples:",a,f,v;return f=new ke({props:{code:"JTIzJTIwY29uZmlnLnlhbWwlMEFlbnYlM0ElMEElMjAlMjAlMjAlMjBWQVIxJTNBJTIwdmFsdWUxJTBBYXJnMSUzQSUyMDIz",highlighted:`<span class="hljs-comment"># config.yaml</span>
<span class="hljs-attr">env:</span>
    <span class="hljs-attr">VAR1:</span> <span class="hljs-string">value1</span>
<span class="hljs-attr">arg1:</span> <span class="hljs-number">23</span>`,wrap:!1}}),{c(){t=m("p"),t.textContent=d,a=n(),u(f.$$.fragment)},l(c){t=g(c,"P",{"data-svelte-h":!0}),k(t)!=="svelte-kvfsh7"&&(t.textContent=d),a=l(c),h(f.$$.fragment,c)},m(c,x){w(c,t,x),w(c,a,x),_(f,c,x),v=!0},p:Je,i(c){v||($(f.$$.fragment,c),v=!0)},o(c){b(f.$$.fragment,c),v=!1},d(c){c&&(o(t),o(a)),y(f,c)}}}function We(A){let t,d;return t=new ke({props:{code:"JTIzJTIwbWFpbi5weSUwQWltcG9ydCUyMG9zJTBBZnJvbSUyMGRhdGFjbGFzc2VzJTIwaW1wb3J0JTIwZGF0YWNsYXNzJTBBZnJvbSUyMHRybCUyMGltcG9ydCUyMFRybFBhcnNlciUwQSUwQSU0MGRhdGFjbGFzcyUwQWNsYXNzJTIwTXlBcmd1bWVudHMlM0ElMEElMjAlMjAlMjAlMjBhcmcxJTNBJTIwaW50JTBBJTIwJTIwJTIwJTIwYXJnMiUzQSUyMHN0ciUyMCUzRCUyMCUyMmFscGhhJTIyJTBBJTBBcGFyc2VyJTIwJTNEJTIwVHJsUGFyc2VyKGRhdGFjbGFzc190eXBlcyUzRCU1Qk15QXJndW1lbnRzJTVEKSUwQXRyYWluaW5nX2FyZ3MlMjAlM0QlMjBwYXJzZXIucGFyc2VfYXJnc19hbmRfY29uZmlnKCklMEElMEFwcmludCh0cmFpbmluZ19hcmdzJTJDJTIwb3MuZW52aXJvbi5nZXQoJTIyVkFSMSUyMikp",highlighted:`<span class="hljs-comment"># main.py</span>
<span class="hljs-keyword">import</span> os
<span class="hljs-keyword">from</span> dataclasses <span class="hljs-keyword">import</span> dataclass
<span class="hljs-keyword">from</span> trl <span class="hljs-keyword">import</span> TrlParser

<span class="hljs-meta">@dataclass</span>
<span class="hljs-keyword">class</span> <span class="hljs-title class_">MyArguments</span>:
    arg1: <span class="hljs-built_in">int</span>
    arg2: <span class="hljs-built_in">str</span> = <span class="hljs-string">&quot;alpha&quot;</span>

parser = TrlParser(dataclass_types=[MyArguments])
training_args = parser.parse_args_and_config()

<span class="hljs-built_in">print</span>(training_args, os.environ.get(<span class="hljs-string">&quot;VAR1&quot;</span>))`,wrap:!1}}),{c(){u(t.$$.fragment)},l(a){h(t.$$.fragment,a)},m(a,f){_(t,a,f),d=!0},p:Je,i(a){d||($(t.$$.fragment,a),d=!0)},o(a){b(t.$$.fragment,a),d=!1},d(a){y(t,a)}}}function Ye(A){let t,d;return t=new ke({props:{code:"JTI0JTIwcHl0aG9uJTIwbWFpbi5weSUyMC0tY29uZmlnJTIwY29uZmlnLnlhbWwlMEEoTXlBcmd1bWVudHMoYXJnMSUzRDIzJTJDJTIwYXJnMiUzRCdhbHBoYScpJTJDKSUyMHZhbHVlMSUwQSUwQSUyNCUyMHB5dGhvbiUyMG1haW4ucHklMjAtLWFyZzElMjA1JTIwLS1hcmcyJTIwYmV0YSUwQShNeUFyZ3VtZW50cyhhcmcxJTNENSUyQyUyMGFyZzIlM0QnYmV0YScpJTJDKSUyME5vbmU=",highlighted:`$ python main.py --config config.yaml
(MyArguments(arg1=23, arg2=<span class="hljs-string">&#x27;alpha&#x27;</span>),) value1

$ python main.py --arg1 5 --arg2 beta
(MyArguments(arg1=5, arg2=<span class="hljs-string">&#x27;beta&#x27;</span>),) None`,wrap:!1}}),{c(){u(t.$$.fragment)},l(a){h(t.$$.fragment,a)},m(a,f){_(t,a,f),d=!0},p:Je,i(a){d||($(t.$$.fragment,a),d=!0)},o(a){b(t.$$.fragment,a),d=!1},d(a){y(t,a)}}}function Le(A){let t,d,a,f,v,c,x,se,P,z,ce,Y,Pe="Arguments common to all scripts.",re,D,ne,i,E,pe,L,Ce=`A subclass of <a href="https://huggingface.co/docs/transformers/main/en/internal/trainer_utils#transformers.HfArgumentParser" rel="nofollow">transformers.HfArgumentParser</a> designed for parsing command-line arguments with dataclass-backed
configurations, while also supporting configuration file loading and environment variable management.`,me,U,ge,S,de,I,fe,M,F,ue,Q,Ae="Parse command-line args and config file into instances of the specified dataclass types.",he,X,Ue=`This method wraps <a href="https://huggingface.co/docs/transformers/main/en/internal/trainer_utils#transformers.HfArgumentParser.parse_args_into_dataclasses" rel="nofollow">transformers.HfArgumentParser.parse_args_into_dataclasses</a> and also parses the config file
specified with the <code>--config</code> flag. The config file (in YAML format) provides argument values that replace the
default values in the dataclasses. Command line arguments can override values set by the config file. The
method also sets any environment variables specified in the <code>env</code> field of the config file.`,_e,J,N,$e,Z,Se="Parse command-line args into instances of the specified dataclass types.",be,R,Ie=`This relies on argparse’s <code>ArgumentParser.parse_known_args</code>. See the doc at:
docs.python.org/3.7/library/argparse.html#argparse.ArgumentParser.parse_args`,ye,T,B,we,q,je="Overrides the parser’s default values with those provided via keyword arguments, including for subparsers.",ve,K,ze=`Any argument with an updated default will also be marked as not required
if it was previously required.`,Te,O,De="Returns a list of strings that were not consumed by the parser.",le,H,oe,te,ie;return v=new Me({props:{title:"Scripts Utilities",local:"scripts-utilities",headingTag:"h1"}}),x=new Me({props:{title:"ScriptArguments",local:"trl.ScriptArguments",headingTag:"h2"}}),z=new ae({props:{name:"class trl.ScriptArguments",anchor:"trl.ScriptArguments",parameters:[{name:"dataset_name",val:": typing.Optional[str] = None"},{name:"dataset_config",val:": typing.Optional[str] = None"},{name:"dataset_train_split",val:": str = 'train'"},{name:"dataset_test_split",val:": str = 'test'"},{name:"gradient_checkpointing_use_reentrant",val:": bool = False"},{name:"ignore_bias_buffers",val:": bool = False"}],parametersDescription:[{anchor:"trl.ScriptArguments.dataset_name",description:`<strong>dataset_name</strong> (<code>str</code>) &#x2014;
Dataset name.`,name:"dataset_name"},{anchor:"trl.ScriptArguments.dataset_config",description:`<strong>dataset_config</strong> (<code>str</code> or <code>None</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
Dataset configuration name. Corresponds to the <code>name</code> argument of the <a href="https://huggingface.co/docs/datasets/main/en/package_reference/loading_methods#datasets.load_dataset" rel="nofollow">load_dataset</a> function.`,name:"dataset_config"},{anchor:"trl.ScriptArguments.dataset_train_split",description:`<strong>dataset_train_split</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;train&quot;</code>) &#x2014;
Dataset split to use for training.`,name:"dataset_train_split"},{anchor:"trl.ScriptArguments.dataset_test_split",description:`<strong>dataset_test_split</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;test&quot;</code>) &#x2014;
Dataset split to use for evaluation.`,name:"dataset_test_split"},{anchor:"trl.ScriptArguments.gradient_checkpointing_use_reentrant",description:`<strong>gradient_checkpointing_use_reentrant</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to apply <code>use_reentrant</code> for gradient checkpointing.`,name:"gradient_checkpointing_use_reentrant"},{anchor:"trl.ScriptArguments.ignore_bias_buffers",description:`<strong>ignore_bias_buffers</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Debug argument for distributed training. Fix for DDP issues with LM bias/mask buffers - invalid scalar
type, inplace operation. See <a href="https://github.com/huggingface/transformers/issues/22482#issuecomment-1595790992" rel="nofollow">https://github.com/huggingface/transformers/issues/22482#issuecomment-1595790992</a>.`,name:"ignore_bias_buffers"}],source:"https://github.com/huggingface/trl/blob/main/trl/scripts/utils.py#L35"}}),D=new Me({props:{title:"TrlParser",local:"trl.TrlParser",headingTag:"h2"}}),E=new ae({props:{name:"class trl.TrlParser",anchor:"trl.TrlParser",parameters:[{name:"dataclass_types",val:": typing.Union[transformers.hf_argparser.DataClassType, collections.abc.Iterable[transformers.hf_argparser.DataClassType], NoneType] = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"trl.TrlParser.dataclass_types",description:`<strong>dataclass_types</strong> (<code>Union[DataClassType, Iterable[DataClassType]]</code> or <code>None</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
Dataclass types to use for argument parsing.`,name:"dataclass_types"},{anchor:"trl.TrlParser.*kwargs",description:`*<strong>*kwargs</strong> &#x2014;
Additional keyword arguments passed to the <a href="https://huggingface.co/docs/transformers/main/en/internal/trainer_utils#transformers.HfArgumentParser" rel="nofollow">transformers.HfArgumentParser</a> constructor.`,name:"*kwargs"}],source:"https://github.com/huggingface/trl/blob/main/trl/scripts/utils.py#L107"}}),U=new xe({props:{anchor:"trl.TrlParser.example",$$slots:{default:[Ve]},$$scope:{ctx:A}}}),S=new xe({props:{anchor:"trl.TrlParser.example-2",$$slots:{default:[We]},$$scope:{ctx:A}}}),I=new xe({props:{anchor:"trl.TrlParser.example-3",$$slots:{default:[Ye]},$$scope:{ctx:A}}}),F=new ae({props:{name:"parse_args_and_config",anchor:"trl.TrlParser.parse_args_and_config",parameters:[{name:"args",val:": typing.Optional[collections.abc.Iterable[str]] = None"},{name:"return_remaining_strings",val:": bool = False"}],source:"https://github.com/huggingface/trl/blob/main/trl/scripts/utils.py#L174"}}),N=new ae({props:{name:"parse_args_into_dataclasses",anchor:"trl.TrlParser.parse_args_into_dataclasses",parameters:[{name:"args",val:" = None"},{name:"return_remaining_strings",val:" = False"},{name:"look_for_args_file",val:" = True"},{name:"args_filename",val:" = None"},{name:"args_file_flag",val:" = None"}],parametersDescription:[{anchor:"trl.TrlParser.parse_args_into_dataclasses.args",description:`<strong>args</strong> &#x2014;
List of strings to parse. The default is taken from sys.argv. (same as argparse.ArgumentParser)`,name:"args"},{anchor:"trl.TrlParser.parse_args_into_dataclasses.return_remaining_strings",description:`<strong>return_remaining_strings</strong> &#x2014;
If true, also return a list of remaining argument strings.`,name:"return_remaining_strings"},{anchor:"trl.TrlParser.parse_args_into_dataclasses.look_for_args_file",description:`<strong>look_for_args_file</strong> &#x2014;
If true, will look for a &#x201C;.args&#x201D; file with the same base name as the entry point script for this
process, and will append its potential content to the command line args.`,name:"look_for_args_file"},{anchor:"trl.TrlParser.parse_args_into_dataclasses.args_filename",description:`<strong>args_filename</strong> &#x2014;
If not None, will uses this file instead of the &#x201C;.args&#x201D; file specified in the previous argument.`,name:"args_filename"},{anchor:"trl.TrlParser.parse_args_into_dataclasses.args_file_flag",description:`<strong>args_file_flag</strong> &#x2014;
If not None, will look for a file in the command-line args specified with this flag. The flag can be
specified multiple times and precedence is determined by the order (last one wins).`,name:"args_file_flag"}],source:"https://github.com/huggingface/trl/blob/main/transformers/hf_argparser.py#L285",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<ul>
<li>the dataclass instances in the same order as they were passed to the initializer.abspath</li>
<li>if applicable, an additional namespace for more (non-dataclass backed) arguments added to the parser
after initialization.</li>
<li>The potential list of remaining argument strings. (same as argparse.ArgumentParser.parse_known_args)</li>
</ul>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p>Tuple consisting of</p>
`}}),B=new ae({props:{name:"set_defaults_with_config",anchor:"trl.TrlParser.set_defaults_with_config",parameters:[{name:"**kwargs",val:""}],source:"https://github.com/huggingface/trl/blob/main/trl/scripts/utils.py#L217"}}),H=new Ge({props:{source:"https://github.com/huggingface/trl/blob/main/docs/source/script_utils.md"}}),{c(){t=m("meta"),d=n(),a=m("p"),f=n(),u(v.$$.fragment),c=n(),u(x.$$.fragment),se=n(),P=m("div"),u(z.$$.fragment),ce=n(),Y=m("p"),Y.textContent=Pe,re=n(),u(D.$$.fragment),ne=n(),i=m("div"),u(E.$$.fragment),pe=n(),L=m("p"),L.innerHTML=Ce,me=n(),u(U.$$.fragment),ge=n(),u(S.$$.fragment),de=n(),u(I.$$.fragment),fe=n(),M=m("div"),u(F.$$.fragment),ue=n(),Q=m("p"),Q.textContent=Ae,he=n(),X=m("p"),X.innerHTML=Ue,_e=n(),J=m("div"),u(N.$$.fragment),$e=n(),Z=m("p"),Z.textContent=Se,be=n(),R=m("p"),R.innerHTML=Ie,ye=n(),T=m("div"),u(B.$$.fragment),we=n(),q=m("p"),q.textContent=je,ve=n(),K=m("p"),K.textContent=ze,Te=n(),O=m("p"),O.textContent=De,le=n(),u(H.$$.fragment),oe=n(),te=m("p"),this.h()},l(e){const r=He("svelte-u9bgzb",document.head);t=g(r,"META",{name:!0,content:!0}),r.forEach(o),d=l(e),a=g(e,"P",{}),V(a).forEach(o),f=l(e),h(v.$$.fragment,e),c=l(e),h(x.$$.fragment,e),se=l(e),P=g(e,"DIV",{class:!0});var G=V(P);h(z.$$.fragment,G),ce=l(G),Y=g(G,"P",{"data-svelte-h":!0}),k(Y)!=="svelte-94r0jz"&&(Y.textContent=Pe),G.forEach(o),re=l(e),h(D.$$.fragment,e),ne=l(e),i=g(e,"DIV",{class:!0});var p=V(i);h(E.$$.fragment,p),pe=l(p),L=g(p,"P",{"data-svelte-h":!0}),k(L)!=="svelte-11jt0z0"&&(L.innerHTML=Ce),me=l(p),h(U.$$.fragment,p),ge=l(p),h(S.$$.fragment,p),de=l(p),h(I.$$.fragment,p),fe=l(p),M=g(p,"DIV",{class:!0});var C=V(M);h(F.$$.fragment,C),ue=l(C),Q=g(C,"P",{"data-svelte-h":!0}),k(Q)!=="svelte-8v26s8"&&(Q.textContent=Ae),he=l(C),X=g(C,"P",{"data-svelte-h":!0}),k(X)!=="svelte-9099nz"&&(X.innerHTML=Ue),C.forEach(o),_e=l(p),J=g(p,"DIV",{class:!0});var ee=V(J);h(N.$$.fragment,ee),$e=l(ee),Z=g(ee,"P",{"data-svelte-h":!0}),k(Z)!=="svelte-p6utzx"&&(Z.textContent=Se),be=l(ee),R=g(ee,"P",{"data-svelte-h":!0}),k(R)!=="svelte-e7yqwr"&&(R.innerHTML=Ie),ee.forEach(o),ye=l(p),T=g(p,"DIV",{class:!0});var j=V(T);h(B.$$.fragment,j),we=l(j),q=g(j,"P",{"data-svelte-h":!0}),k(q)!=="svelte-1668qe1"&&(q.textContent=je),ve=l(j),K=g(j,"P",{"data-svelte-h":!0}),k(K)!=="svelte-8z1br0"&&(K.textContent=ze),Te=l(j),O=g(j,"P",{"data-svelte-h":!0}),k(O)!=="svelte-cs6q3z"&&(O.textContent=De),j.forEach(o),p.forEach(o),le=l(e),h(H.$$.fragment,e),oe=l(e),te=g(e,"P",{}),V(te).forEach(o),this.h()},h(){W(t,"name","hf:doc:metadata"),W(t,"content",Qe),W(P,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),W(M,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),W(J,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),W(T,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),W(i,"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,r){s(document.head,t),w(e,d,r),w(e,a,r),w(e,f,r),_(v,e,r),w(e,c,r),_(x,e,r),w(e,se,r),w(e,P,r),_(z,P,null),s(P,ce),s(P,Y),w(e,re,r),_(D,e,r),w(e,ne,r),w(e,i,r),_(E,i,null),s(i,pe),s(i,L),s(i,me),_(U,i,null),s(i,ge),_(S,i,null),s(i,de),_(I,i,null),s(i,fe),s(i,M),_(F,M,null),s(M,ue),s(M,Q),s(M,he),s(M,X),s(i,_e),s(i,J),_(N,J,null),s(J,$e),s(J,Z),s(J,be),s(J,R),s(i,ye),s(i,T),_(B,T,null),s(T,we),s(T,q),s(T,ve),s(T,K),s(T,Te),s(T,O),w(e,le,r),_(H,e,r),w(e,oe,r),w(e,te,r),ie=!0},p(e,[r]){const G={};r&2&&(G.$$scope={dirty:r,ctx:e}),U.$set(G);const p={};r&2&&(p.$$scope={dirty:r,ctx:e}),S.$set(p);const C={};r&2&&(C.$$scope={dirty:r,ctx:e}),I.$set(C)},i(e){ie||($(v.$$.fragment,e),$(x.$$.fragment,e),$(z.$$.fragment,e),$(D.$$.fragment,e),$(E.$$.fragment,e),$(U.$$.fragment,e),$(S.$$.fragment,e),$(I.$$.fragment,e),$(F.$$.fragment,e),$(N.$$.fragment,e),$(B.$$.fragment,e),$(H.$$.fragment,e),ie=!0)},o(e){b(v.$$.fragment,e),b(x.$$.fragment,e),b(z.$$.fragment,e),b(D.$$.fragment,e),b(E.$$.fragment,e),b(U.$$.fragment,e),b(S.$$.fragment,e),b(I.$$.fragment,e),b(F.$$.fragment,e),b(N.$$.fragment,e),b(B.$$.fragment,e),b(H.$$.fragment,e),ie=!1},d(e){e&&(o(d),o(a),o(f),o(c),o(se),o(P),o(re),o(ne),o(i),o(le),o(oe),o(te)),o(t),y(v,e),y(x,e),y(z),y(D,e),y(E),y(U),y(S),y(I),y(F),y(N),y(B),y(H,e)}}}const Qe='{"title":"Scripts Utilities","local":"scripts-utilities","sections":[{"title":"ScriptArguments","local":"trl.ScriptArguments","sections":[],"depth":2},{"title":"TrlParser","local":"trl.TrlParser","sections":[],"depth":2}],"depth":1}';function Xe(A){return Fe(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class tt extends Ne{constructor(t){super(),Be(this,t,Xe,Le,Ee,{})}}export{tt as component};
