import{s as ue,n as de,o as he}from"../chunks/scheduler.eb244325.js";import{S as ye,i as be,e as i,s,c as j,h as ge,a as o,d as a,b as n,f as fe,g as x,j as r,k as ce,l as we,m as l,n as J,t as U,o as C,p as V}from"../chunks/index.3fe63ad3.js";import{C as Te}from"../chunks/CopyLLMTxtMenu.88bde5f2.js";import{C as O}from"../chunks/CodeBlock.934d290d.js";import{H as me,E as _e}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.341974a5.js";function $e(ee){let p,H,E,S,f,Z,c,P,m,te=`<a href="https://github.com/huggingface/peft" rel="nofollow">🤗 PEFT</a> (Parameter-Efficient Fine-Tuning) is a library for efficiently adapting
large pretrained models such as pre-trained policies (e.g., SmolVLA, π₀, …) to new tasks without training all
of the model’s parameters while yielding comparable performance.`,k,u,ae="Install the <code>lerobot[peft]</code> optional package to enable PEFT support.",X,d,le='To read about all the possible methods of adaption, please refer to the <a href="https://huggingface.co/docs/peft/index" rel="nofollow">🤗 PEFT docs</a>.',R,h,W,y,se=`In this section we’ll show you how to train a pre-trained SmolVLA policy with PEFT on the libero dataset.
For brevity we’re only training on the <code>libero_spatial</code> subset. We will use <code>lerobot/smolvla_base</code> as the model
to parameter efficiently fine-tune:`,B,b,G,g,ne=`Note the <code>--peft.method_type</code> parameter that let’s you select which PEFT method to use. Here we use
<a href="https://huggingface.co/docs/peft/main/en/package_reference/lora" rel="nofollow">LoRA</a> (Low-Rank Adapter) which is probably the most
popular fine-tuning method to date. Low-rank adaption means that we only fine-tune a matrix with comparably low rank
instead of the full weight matrix. This rank can be specified using the <code>--peft.r</code> parameter. The higher the rank
the closer you get to full fine-tuning`,N,w,ie=`There are more complex methods that have more parameters. These are not yet supported, feel free to raise an issue
if you want to see a specific PEFT method supported.`,Q,T,oe=`By default, PEFT will target the <code>q_proj</code> and <code>v_proj</code> layers of the LM expert in SmolVLA. It will also target the
state and action projection matrices as they are most likely task-dependent. If you need to target different layers
you can use <code>--peft.target_modules</code> to specify which layers to target. You can refer to the respective PEFT method’s
documentation to see what inputs are supported, (e.g., <a href="https://huggingface.co/docs/peft/main/en/package_reference/lora#peft.LoraConfig.target_modules" rel="nofollow">LoRA’s target_modules documentation</a>).
Usually a list of suffixes or a regex are supported. For example, to target the MLPs of the <code>lm_expert</code> instead of
the <code>q</code> and <code>v</code> projections, use:`,I,_,A,$,pe=`In case you need to fully fine-tune a layer instead of just adapting it, you can supply a list of layer suffixes
to the <code>--peft.full_training_modules</code> parameter:`,Y,v,z,M,re=`The learning rate and the scheduled target learning rate can usually be scaled by a factor of 10 compared to the
learning rate used for full fine-tuning (e.g., 1e-4 normal, so 1e-3 using LoRA).`,D,L,q,F,K;return f=new Te({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),c=new me({props:{title:"Parameter efficient fine-tuning with 🤗 PEFT",local:"parameter-efficient-fine-tuning-with--peft",headingTag:"h1"}}),h=new me({props:{title:"Training SmolVLA",local:"training-smolvla",headingTag:"h2"}}),b=new O({props:{code:"bGVyb2JvdC10cmFpbiUyMCU1QyUwQSUyMC0tcG9saWN5LnBhdGglM0RsZXJvYm90JTJGc21vbHZsYV9iYXNlJTIwJTVDJTBBJTIwLS1wb2xpY3kucmVwb19pZCUzRHlvdXJfaHViX25hbWUlMkZteV9saWJlcm9fc21vbHZsYSUyMCU1QyUwQSUyMC0tZGF0YXNldC5yZXBvX2lkJTNESHVnZ2luZ0ZhY2VWTEElMkZsaWJlcm8lMjAlNUMlMEElMjAtLXBvbGljeS5vdXRwdXRfZmVhdHVyZXMlM0RudWxsJTIwJTVDJTBBJTIwLS1wb2xpY3kuaW5wdXRfZmVhdHVyZXMlM0RudWxsJTIwJTVDJTBBJTIwLS1wb2xpY3kub3B0aW1pemVyX2xyJTNEMWUtMyUyMCU1QyUwQSUyMC0tcG9saWN5LnNjaGVkdWxlcl9kZWNheV9sciUzRDFlLTQlMjAlNUMlMEElMjAtLWVudi50eXBlJTNEbGliZXJvJTIwJTVDJTBBJTIwLS1lbnYudGFzayUzRGxpYmVyb19zcGF0aWFsJTIwJTVDJTBBJTIwLS1zdGVwcyUzRDEwMDAwMCUyMCU1QyUwQSUyMC0tYmF0Y2hfc2l6ZSUzRDMyJTIwJTVDJTBBJTIwLS1wZWZ0Lm1ldGhvZF90eXBlJTNETE9SQSUyMCU1QyUwQSUyMC0tcGVmdC5yJTNENjQ=",highlighted:`lerobot-train \\
 --policy.<span class="hljs-attribute">path</span>=lerobot/smolvla_base \\
 --policy.<span class="hljs-attribute">repo_id</span>=your_hub_name/my_libero_smolvla \\
 --dataset.<span class="hljs-attribute">repo_id</span>=HuggingFaceVLA/libero \\
 --policy.<span class="hljs-attribute">output_features</span>=<span class="hljs-literal">null</span> \\
 --policy.<span class="hljs-attribute">input_features</span>=<span class="hljs-literal">null</span> \\
 --policy.<span class="hljs-attribute">optimizer_lr</span>=1e-3 \\
 --policy.<span class="hljs-attribute">scheduler_decay_lr</span>=1e-4 \\
 --env.<span class="hljs-attribute">type</span>=libero \\
 --env.<span class="hljs-attribute">task</span>=libero_spatial \\
 <span class="hljs-attribute">--steps</span>=100000 \\
 <span class="hljs-attribute">--batch_size</span>=32 \\
 --peft.<span class="hljs-attribute">method_type</span>=LORA \\
 --peft.<span class="hljs-attribute">r</span>=64`,wrap:!1}}),_=new O({props:{code:"LS1wZWZ0LnRhcmdldF9tb2R1bGVzJTNEJyhtb2RlbCU1Qy52bG1fd2l0aF9leHBlcnQlNUMubG1fZXhwZXJ0JTVDLi4qJTVDLihkb3duJTdDZ2F0ZSU3Q3VwKV9wcm9qJTdDLiolNUMuKHN0YXRlX3Byb2olN0NhY3Rpb25faW5fcHJvaiU3Q2FjdGlvbl9vdXRfcHJvaiU3Q2FjdGlvbl90aW1lX21scF9pbiU3Q2FjdGlvbl90aW1lX21scF9vdXQpKSc=",highlighted:'--peft.target_modules=&#x27;(model\\.vlm_with_expert\\.lm_expert\\..*\\.(down|<span class="hljs-type">gate</span>|<span class="hljs-type">up</span>)_proj|<span class="hljs-type">.*\\.(state_proj</span>|<span class="hljs-type">action_in_proj</span>|<span class="hljs-type">action_out_proj</span>|<span class="hljs-type">action_time_mlp_in</span>|<span class="hljs-type">action_time_mlp_out</span>))&#x27;',wrap:!1}}),v=new O({props:{code:"LS1wZWZ0LmZ1bGxfdHJhaW5pbmdfbW9kdWxlcyUzRCU1QiUyMnN0YXRlX3Byb2olMjIlNUQ=",highlighted:'<span class="hljs-attr">--peft.full_training_modules</span>=[<span class="hljs-string">&quot;state_proj&quot;</span>]',wrap:!1}}),L=new _e({props:{source:"https://github.com/huggingface/lerobot/blob/main/docs/source/peft_training.mdx"}}),{c(){p=i("meta"),H=s(),E=i("p"),S=s(),j(f.$$.fragment),Z=s(),j(c.$$.fragment),P=s(),m=i("p"),m.innerHTML=te,k=s(),u=i("p"),u.innerHTML=ae,X=s(),d=i("p"),d.innerHTML=le,R=s(),j(h.$$.fragment),W=s(),y=i("p"),y.innerHTML=se,B=s(),j(b.$$.fragment),G=s(),g=i("p"),g.innerHTML=ne,N=s(),w=i("p"),w.textContent=ie,Q=s(),T=i("p"),T.innerHTML=oe,I=s(),j(_.$$.fragment),A=s(),$=i("p"),$.innerHTML=pe,Y=s(),j(v.$$.fragment),z=s(),M=i("p"),M.textContent=re,D=s(),j(L.$$.fragment),q=s(),F=i("p"),this.h()},l(e){const t=ge("svelte-u9bgzb",document.head);p=o(t,"META",{name:!0,content:!0}),t.forEach(a),H=n(e),E=o(e,"P",{}),fe(E).forEach(a),S=n(e),x(f.$$.fragment,e),Z=n(e),x(c.$$.fragment,e),P=n(e),m=o(e,"P",{"data-svelte-h":!0}),r(m)!=="svelte-6qhvjd"&&(m.innerHTML=te),k=n(e),u=o(e,"P",{"data-svelte-h":!0}),r(u)!=="svelte-190tt2v"&&(u.innerHTML=ae),X=n(e),d=o(e,"P",{"data-svelte-h":!0}),r(d)!=="svelte-ccmbu"&&(d.innerHTML=le),R=n(e),x(h.$$.fragment,e),W=n(e),y=o(e,"P",{"data-svelte-h":!0}),r(y)!=="svelte-qck9xa"&&(y.innerHTML=se),B=n(e),x(b.$$.fragment,e),G=n(e),g=o(e,"P",{"data-svelte-h":!0}),r(g)!=="svelte-1lf8jgg"&&(g.innerHTML=ne),N=n(e),w=o(e,"P",{"data-svelte-h":!0}),r(w)!=="svelte-1ilzc5t"&&(w.textContent=ie),Q=n(e),T=o(e,"P",{"data-svelte-h":!0}),r(T)!=="svelte-1nwjgar"&&(T.innerHTML=oe),I=n(e),x(_.$$.fragment,e),A=n(e),$=o(e,"P",{"data-svelte-h":!0}),r($)!=="svelte-1g32h7r"&&($.innerHTML=pe),Y=n(e),x(v.$$.fragment,e),z=n(e),M=o(e,"P",{"data-svelte-h":!0}),r(M)!=="svelte-1bx4cdv"&&(M.textContent=re),D=n(e),x(L.$$.fragment,e),q=n(e),F=o(e,"P",{}),fe(F).forEach(a),this.h()},h(){ce(p,"name","hf:doc:metadata"),ce(p,"content",ve)},m(e,t){we(document.head,p),l(e,H,t),l(e,E,t),l(e,S,t),J(f,e,t),l(e,Z,t),J(c,e,t),l(e,P,t),l(e,m,t),l(e,k,t),l(e,u,t),l(e,X,t),l(e,d,t),l(e,R,t),J(h,e,t),l(e,W,t),l(e,y,t),l(e,B,t),J(b,e,t),l(e,G,t),l(e,g,t),l(e,N,t),l(e,w,t),l(e,Q,t),l(e,T,t),l(e,I,t),J(_,e,t),l(e,A,t),l(e,$,t),l(e,Y,t),J(v,e,t),l(e,z,t),l(e,M,t),l(e,D,t),J(L,e,t),l(e,q,t),l(e,F,t),K=!0},p:de,i(e){K||(U(f.$$.fragment,e),U(c.$$.fragment,e),U(h.$$.fragment,e),U(b.$$.fragment,e),U(_.$$.fragment,e),U(v.$$.fragment,e),U(L.$$.fragment,e),K=!0)},o(e){C(f.$$.fragment,e),C(c.$$.fragment,e),C(h.$$.fragment,e),C(b.$$.fragment,e),C(_.$$.fragment,e),C(v.$$.fragment,e),C(L.$$.fragment,e),K=!1},d(e){e&&(a(H),a(E),a(S),a(Z),a(P),a(m),a(k),a(u),a(X),a(d),a(R),a(W),a(y),a(B),a(G),a(g),a(N),a(w),a(Q),a(T),a(I),a(A),a($),a(Y),a(z),a(M),a(D),a(q),a(F)),a(p),V(f,e),V(c,e),V(h,e),V(b,e),V(_,e),V(v,e),V(L,e)}}}const ve='{"title":"Parameter efficient fine-tuning with 🤗 PEFT","local":"parameter-efficient-fine-tuning-with--peft","sections":[{"title":"Training SmolVLA","local":"training-smolvla","sections":[],"depth":2}],"depth":1}';function Me(ee){return he(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ce extends ye{constructor(p){super(),be(this,p,Me,$e,ue,{})}}export{Ce as component};
