import{s as Ot,n as Xt,o as Kt}from"../chunks/scheduler.19cc4639.js";import{S as ei,i as ti,e as a,s as l,c as p,h as ii,a as r,d as i,b as s,f as Dt,g as u,j as o,k as $t,l as ni,m as n,n as m,t as g,o as f,p as c}from"../chunks/index.6703add8.js";import{C as li,H as d,E as si}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.97e15e3b.js";import{C as Tt}from"../chunks/CodeBlock.9f4ca262.js";function ai(vt){let M,he,de,Te,T,$e,$,ve,v,yt='In Unit 1, we explored <a href="../unit1/3">supervised fine-tuning on LLMs</a>, including <a href="../unit1/3a">efficient strategies</a> using TRL. In this section, we adapt these techniques for <strong>Vision Language Models (VLMs)</strong>, focusing on efficiency and task-specific performance.',ye,y,we,w,wt="When fine-tuning VLMs, memory and computation can quickly become a bottleneck. Here are the main strategies:",Le,L,be,b,Lt="Quantization reduces the precision of model weights and activations, lowering memory usage and speeding up computation.",Ue,U,bt=`<li><strong>bfloat16 / float16</strong> halves memory requirements while maintaining accuracy.</li> <li><strong>8-bit / 4-bit quantization</strong> reduces memory further, with minor performance trade-offs.
<blockquote><p>⚠️ Especially relevant for VLMs, where image features increase memory demands.</p></blockquote></li>`,_e,_,xe,x,Ut="Low-Rank Adaptation (LoRA) freezes the base model weights and trains <strong>compact rank-decomposition matrices</strong>, drastically reducing the number of trainable parameters. When combined with <strong>PEFT</strong>, fine-tuning requires <strong>millions of trainable parameters instead of billions</strong>, making large VLMs accessible on limited hardware.",He,H,je,j,_t="Memory-efficient training can be achieved with:",Ce,C,xt="<li><strong>Gradient accumulation</strong>: maintain effective batch size over multiple steps.</li> <li><strong>Gradient checkpointing</strong>: recompute intermediate activations to save memory.</li> <li>Start with a large batch, reduce if OOM errors occur, and combine with LoRA/quantization for best results.</li>",Je,J,ke,k,Ht="SFT adapts a pre-trained VLM to a <strong>specific task</strong> using labeled datasets (image-text pairs). Examples include:",Fe,F,jt="<li>Visual question answering (VQA)</li> <li>Image captioning</li> <li>Chart or diagram interpretation</li>",ze,z,Ve,V,Ct="<li>Specialize a VLM in a domain where the base model struggles.</li> <li>Learn domain-specific vocabulary or visual patterns.</li>",Ee,E,Jt="<strong>Limitations</strong>",Re,R,kt="<li>Requires <strong>high-quality, labeled datasets</strong>.</li> <li>Can be <strong>computationally intensive</strong>.</li> <li>Risk of <strong>overfitting</strong> if fine-tuning is too narrow.</li>",Se,S,Ze,Z,Ft=`The <a href="https://huggingface.co/docs/trl/en/sft_trainer" rel="nofollow"><code>SFTTrainer</code></a> supports training VLMs directly.<br/>
Your dataset should include an additional <code>images</code> column containing the visual inputs. See the <a href="https://huggingface.co/docs/trl/dataset_formats#vision-dataset" rel="nofollow">dataset format docs</a> for details.`,Pe,P,Ie,I,zt=`⚠️ <strong>Important:</strong> Set <code>max_length=None</code> in the <a href="https://huggingface.co/docs/trl/en/sft_trainer#trl.SFTConfig" rel="nofollow"><code>SFTConfig</code></a>.<br/>
Otherwise, truncation may remove image tokens during training.`,Be,B,Ge,G,Ae,A,Vt="<li><p><strong>Data Preparation</strong></p> <ul><li>Use image-text pairs, e.g., <code>HuggingFaceM4/ChartQA</code>.</li></ul></li> <li><p><strong>Model Setup</strong></p> <ul><li>Load a pre-trained VLM such as <code>HuggingFaceTB/SmolVLM2-2.2B-Instruct</code>.</li> <li>Initialize a processor to prepare text and image inputs.</li></ul></li> <li><p><strong>Fine-Tuning Process</strong></p> <ul><li>Format data into <strong>chat-like messages</strong> (<code>system</code>, <code>user</code>, <code>assistant</code>).</li> <li>Configure optimizer, batch size, and gradient accumulation.</li> <li>Apply <strong>quantization</strong> and <strong>LoRA</strong> for memory-efficient training.</li></ul></li>",We,W,qe,q,Et="<strong>Direct Preference Optimization (DPO)</strong> aligns a VLM with <strong>human preferences</strong> instead of strict instruction following.",Ne,N,Rt="<li>Useful for creative tasks, subjective judgments, or multi-choice answers.</li> <li>The model learns to select the <strong>more human-aligned response</strong>, even if it isn’t strictly “correct.”</li>",Qe,Q,St="<strong>Limitations</strong>",Ye,Y,Zt="<li>Requires <strong>high-quality preference-labeled datasets</strong>.</li> <li>Training involves <strong>pairwise preference sampling</strong> and careful resource management.</li>",De,D,Oe,O,Pt="<li><strong>Dataset</strong>: Each example contains a prompt (image + question) and <strong>two candidate responses</strong>:</li>",Xe,X,Ke,K,It=`<li><strong>Model Setup</strong>: Load the pre-trained VLM, integrate with TRL DPO, and prepare the processor.</li> <li><strong>Training Pipeline</strong>:  
<ul><li>Format dataset into chat-like messages.</li> <li>Apply a <strong>preference-based loss function</strong>.</li> <li>Use gradient accumulation, checkpointing, LoRA, and quantization for efficiency.</li></ul></li>`,et,ee,tt,te,Bt="<thead><tr><th>Feature</th> <th>SFT</th> <th>DPO</th></tr></thead> <tbody><tr><td>Input</td> <td>Labeled image-text</td> <td>Image-text + preference-ranked outputs</td></tr> <tr><td>Loss</td> <td>Standard supervised</td> <td>Preference-based</td></tr> <tr><td>Goal</td> <td>Task-specific adaptation</td> <td>Human-aligned output</td></tr> <tr><td>Use Case</td> <td>Domain specialization</td> <td>Creative, subjective, or multi-choice tasks</td></tr></tbody>",it,ie,nt,ne,Gt="<li>Start small: test with a <strong>subset of the dataset</strong> before full training.</li> <li>Use <strong>gradient checkpointing + LoRA + quantization</strong> to reduce memory usage.</li> <li>Monitor <strong>checkpoint frequency</strong> to balance storage and safety.</li> <li>Validate on a small set to <strong>avoid overfitting</strong>.</li>",lt,le,st,se,At='After fine-tuning, evaluate your VLM’s performance on <strong>multimodal tasks</strong> using benchmarks and custom test sets, applying techniques from <a href="../unit2/1">Unit 2</a>.',at,ae,rt,re,Wt='As introduced in <a href="unit1/5">earlier units</a>, <a href="https://huggingface.co/docs/huggingface_hub/guides/jobs" rel="nofollow">Hugging Face Jobs</a> make fine-tuning Vision Language Models (VLMs) straightforward. You can run <strong>Supervised Fine-Tuning (SFT)</strong> or <strong>Direct Preference Optimization (DPO)</strong> directly on the Hugging Face infrastructure with minimal setup, adjusting the training parameters we discussed previously.',ot,oe,pt,pe,ut,ue,qt="<li><code>--flavor a100-large</code>: GPU type for training.</li> <li><code>--secrets HF_TOKEN</code>: Your Hugging Face token.</li>",mt,me,Nt="The script handles processor setup, data formatting, and model training automatically. Once the job finishes, your fine-tuned VLM is ready to download and use in downstream tasks.",gt,h,Qt="<p>For memory-efficient fine-tuning of large VLMs, consider combining techniques like <strong>LoRA adapters</strong>, <strong>gradient accumulation</strong>, and <strong>quantization</strong>. These strategies help reduce memory usage while maintaining performance.</p>",ft,ge,ct,fe,Yt='<li><a href="https://huggingface.co/learn/cookbook/fine_tuning_vlm_trl" rel="nofollow">Fine-Tuning a Vision Language Model (Qwen2-VL-7B) with the Hugging Face Ecosystem (TRL)</a></li> <li><a href="https://huggingface.co/learn/cookbook/fine_tuning_smol_vlm_sft_trl" rel="nofollow">Fine-tuning SmolVLM with TRL on a consumer GPU</a></li> <li><a href="https://huggingface.co/learn/cookbook/fine_tuning_vlm_dpo_smolvlm_instruct" rel="nofollow">Fine-tuning SmolVLM using direct preference optimization (DPO) with TRL on a consumer GPU</a></li> <li><a href="https://huggingface.co/blog/dpo_vlm" rel="nofollow">Preference Optimization for Vision Language Models with TRL</a></li>',dt,ce,Mt,Me,ht;return T=new li({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),$=new d({props:{title:"Fine-Tuning VLMs",local:"fine-tuning-vlms",headingTag:"h1"}}),y=new d({props:{title:"Key Efficiency Techniques",local:"key-efficiency-techniques",headingTag:"h2"}}),L=new d({props:{title:"Quantization",local:"quantization",headingTag:"h3"}}),_=new d({props:{title:"PEFT & LoRA",local:"peft--lora",headingTag:"h3"}}),H=new d({props:{title:"Batch Size Optimization",local:"batch-size-optimization",headingTag:"h3"}}),J=new d({props:{title:"Supervised Fine-Tuning (SFT)",local:"supervised-fine-tuning-sft",headingTag:"h2"}}),z=new d({props:{title:"When to Use SFT",local:"when-to-use-sft",headingTag:"h3"}}),S=new d({props:{title:"Usage Example",local:"usage-example",headingTag:"h3"}}),P=new Tt({props:{code:"ZnJvbSUyMHRybCUyMGltcG9ydCUyMFNGVFRyYWluZXIlMEElMEF0cmFpbmluZ19hcmdzJTIwJTNEJTIwU0ZUVHJhaW5lciglMEElMjAlMjAlMjBvdXRwdXRfZGlyJTNEJTIyLiUyRmZpbmVfdHVuZWRfbW9kZWwlMjIlMkMlMEElMjAlMjAlMjBwZXJfZGV2aWNlX3RyYWluX2JhdGNoX3NpemUlM0Q0JTJDJTBBJTIwJTIwJTIwbnVtX3RyYWluX2Vwb2NocyUzRDMlMkMlMEElMjAlMjAlMjBsZWFybmluZ19yYXRlJTNENWUtNSUyQyUwQSUyMCUyMCUyMHNhdmVfc3RlcHMlM0QxMDAwJTJDJTBBJTIwJTIwJTIwYmYxNiUzRFRydWUlMkMlMEElMjAlMjAlMjBncmFkaWVudF9jaGVja3BvaW50aW5nJTNEVHJ1ZSUyQyUwQSUyMCUyMCUyMGdyYWRpZW50X2FjY3VtdWxhdGlvbl9zdGVwcyUzRDE2JTJDJTBBJTIwJTIwJTIwbG9nZ2luZ19zdGVwcyUzRDUwJTBBKQ==",highlighted:`<span class="hljs-keyword">from</span> trl <span class="hljs-keyword">import</span> SFTTrainer

training_args = SFTTrainer(
   output_dir=<span class="hljs-string">&quot;./fine_tuned_model&quot;</span>,
   per_device_train_batch_size=<span class="hljs-number">4</span>,
   num_train_epochs=<span class="hljs-number">3</span>,
   learning_rate=<span class="hljs-number">5e-5</span>,
   save_steps=<span class="hljs-number">1000</span>,
   bf16=<span class="hljs-literal">True</span>,
   gradient_checkpointing=<span class="hljs-literal">True</span>,
   gradient_accumulation_steps=<span class="hljs-number">16</span>,
   logging_steps=<span class="hljs-number">50</span>
)`,wrap:!1}}),B=new Tt({props:{code:"U0ZUQ29uZmlnKG1heF9sZW5ndGglM0ROb25lJTJDJTIwLi4uKQ==",highlighted:'SFTConfig(max_length=<span class="hljs-literal">None</span>, ...)',wrap:!1}}),G=new d({props:{title:"Practical Steps",local:"practical-steps",headingTag:"h3"}}),W=new d({props:{title:"Preference Optimization (DPO)",local:"preference-optimization-dpo",headingTag:"h2"}}),D=new d({props:{title:"Usage Example",local:"usage-example",headingTag:"h3"}}),X=new Tt({props:{code:"UXVlc3Rpb24lM0ElMjBIb3clMjBtYW55JTIwZmFtaWxpZXMlM0YlMEFSZWplY3RlZCUzQSUyMFRoZSUyMGltYWdlJTIwZG9lcyUyMG5vdCUyMHByb3ZpZGUlMjBpbmZvcm1hdGlvbiUyMGFib3V0JTIwZmFtaWxpZXMuJTBBQ2hvc2VuJTNBJTIwVGhlJTIwaW1hZ2UlMjBzaG93cyUyMGElMjBVbmlvbiUyME9yZ2FuaXphdGlvbiUyMHRhYmxlJTIwc2V0dXAlMjB3aXRoJTIwMTglMkMwMDAlMjBmYW1pbGllcy4=",highlighted:`Question: How many families?
Rejected: The image does not provide information about families.
Chosen: The image shows a Union Organization table setup with 18,000 families.`,wrap:!1}}),ee=new d({props:{title:"SFT vs DPO Comparison",local:"sft-vs-dpo-comparison",headingTag:"h3"}}),ie=new d({props:{title:"Practical Tips",local:"practical-tips",headingTag:"h3"}}),le=new d({props:{title:"Next Steps",local:"next-steps",headingTag:"h3"}}),ae=new d({props:{title:"Fine-Tuning a VLM in hf jobs using TRL",local:"fine-tuning-a-vlm-in-hf-jobs-using-trl",headingTag:"h2"}}),oe=new d({props:{title:"Quick Example",local:"quick-example",headingTag:"h3"}}),pe=new Tt({props:{code:"aGYlMjBqb2JzJTIwdXYlMjBydW4lMjAlNUMlMEElMjAlMjAlMjAtLWZsYXZvciUyMGExMDAtbGFyZ2UlMjAlNUMlMEElMjAlMjAlMjAtLXNlY3JldHMlMjBIRl9UT0tFTiUyMCU1QyUwQSUyMCUyMCUyMC0tdGltZW91dCUyMDJoJTIwJTVDJTBBJTIwJTIwJTIwJTIyaHR0cHMlM0ElMkYlMkZyYXcuZ2l0aHVidXNlcmNvbnRlbnQuY29tJTJGaHVnZ2luZ2ZhY2UlMkZ0cmwlMkZtYWluJTJGdHJsJTJGc2NyaXB0cyUyRnNmdC5weSUyMiUyMCU1QyUwQSUyMCUyMCUyMC0tbW9kZWxfbmFtZV9vcl9wYXRoJTIwSHVnZ2luZ0ZhY2VUQiUyRlNtb2xWTE0yLTIuMkItSW5zdHJ1Y3QlMjAlNUMlMEElMjAlMjAlMjAtLWRhdGFzZXRfbmFtZSUyMEh1Z2dpbmdGYWNlTTQlMkZDaGFydFFBJTIwJTVDJTBBJTIwJTIwJTIwLS1yZXBvcnRfdG8lMjB0cmFja2lv",highlighted:`hf <span class="hljs-built_in">jobs</span> uv run \\
   --flavor a100-large \\
   --secrets HF_TOKEN \\
   --<span class="hljs-built_in">timeout</span> 2h \\
   <span class="hljs-string">&quot;https://raw.githubusercontent.com/huggingface/trl/main/trl/scripts/sft.py&quot;</span> \\
   --model_name_or_path HuggingFaceTB/SmolVLM2-2.2B-Instruct \\
   --dataset_name HuggingFaceM4/ChartQA \\
   --report_to trackio`,wrap:!1}}),ge=new d({props:{title:"Resources",local:"resources",headingTag:"h2"}}),ce=new si({props:{source:"https://github.com/huggingface/smol-course/blob/main/units/en/unit3/3.md"}}),{c(){M=a("meta"),he=l(),de=a("p"),Te=l(),p(T.$$.fragment),$e=l(),p($.$$.fragment),ve=l(),v=a("p"),v.innerHTML=yt,ye=l(),p(y.$$.fragment),we=l(),w=a("p"),w.textContent=wt,Le=l(),p(L.$$.fragment),be=l(),b=a("p"),b.textContent=Lt,Ue=l(),U=a("ul"),U.innerHTML=bt,_e=l(),p(_.$$.fragment),xe=l(),x=a("p"),x.innerHTML=Ut,He=l(),p(H.$$.fragment),je=l(),j=a("p"),j.textContent=_t,Ce=l(),C=a("ul"),C.innerHTML=xt,Je=l(),p(J.$$.fragment),ke=l(),k=a("p"),k.innerHTML=Ht,Fe=l(),F=a("ul"),F.innerHTML=jt,ze=l(),p(z.$$.fragment),Ve=l(),V=a("ul"),V.innerHTML=Ct,Ee=l(),E=a("p"),E.innerHTML=Jt,Re=l(),R=a("ul"),R.innerHTML=kt,Se=l(),p(S.$$.fragment),Ze=l(),Z=a("p"),Z.innerHTML=Ft,Pe=l(),p(P.$$.fragment),Ie=l(),I=a("p"),I.innerHTML=zt,Be=l(),p(B.$$.fragment),Ge=l(),p(G.$$.fragment),Ae=l(),A=a("ol"),A.innerHTML=Vt,We=l(),p(W.$$.fragment),qe=l(),q=a("p"),q.innerHTML=Et,Ne=l(),N=a("ul"),N.innerHTML=Rt,Qe=l(),Q=a("p"),Q.innerHTML=St,Ye=l(),Y=a("ul"),Y.innerHTML=Zt,De=l(),p(D.$$.fragment),Oe=l(),O=a("ul"),O.innerHTML=Pt,Xe=l(),p(X.$$.fragment),Ke=l(),K=a("ul"),K.innerHTML=It,et=l(),p(ee.$$.fragment),tt=l(),te=a("table"),te.innerHTML=Bt,it=l(),p(ie.$$.fragment),nt=l(),ne=a("ul"),ne.innerHTML=Gt,lt=l(),p(le.$$.fragment),st=l(),se=a("p"),se.innerHTML=At,at=l(),p(ae.$$.fragment),rt=l(),re=a("p"),re.innerHTML=Wt,ot=l(),p(oe.$$.fragment),pt=l(),p(pe.$$.fragment),ut=l(),ue=a("ul"),ue.innerHTML=qt,mt=l(),me=a("p"),me.textContent=Nt,gt=l(),h=a("blockquote"),h.innerHTML=Qt,ft=l(),p(ge.$$.fragment),ct=l(),fe=a("ul"),fe.innerHTML=Yt,dt=l(),p(ce.$$.fragment),Mt=l(),Me=a("p"),this.h()},l(e){const t=ii("svelte-u9bgzb",document.head);M=r(t,"META",{name:!0,content:!0}),t.forEach(i),he=s(e),de=r(e,"P",{}),Dt(de).forEach(i),Te=s(e),u(T.$$.fragment,e),$e=s(e),u($.$$.fragment,e),ve=s(e),v=r(e,"P",{"data-svelte-h":!0}),o(v)!=="svelte-148e51o"&&(v.innerHTML=yt),ye=s(e),u(y.$$.fragment,e),we=s(e),w=r(e,"P",{"data-svelte-h":!0}),o(w)!=="svelte-1e5mjdr"&&(w.textContent=wt),Le=s(e),u(L.$$.fragment,e),be=s(e),b=r(e,"P",{"data-svelte-h":!0}),o(b)!=="svelte-1jr248r"&&(b.textContent=Lt),Ue=s(e),U=r(e,"UL",{"data-svelte-h":!0}),o(U)!=="svelte-1uzyjky"&&(U.innerHTML=bt),_e=s(e),u(_.$$.fragment,e),xe=s(e),x=r(e,"P",{"data-svelte-h":!0}),o(x)!=="svelte-1ygu8zh"&&(x.innerHTML=Ut),He=s(e),u(H.$$.fragment,e),je=s(e),j=r(e,"P",{"data-svelte-h":!0}),o(j)!=="svelte-1yc2hsb"&&(j.textContent=_t),Ce=s(e),C=r(e,"UL",{"data-svelte-h":!0}),o(C)!=="svelte-z0n4bh"&&(C.innerHTML=xt),Je=s(e),u(J.$$.fragment,e),ke=s(e),k=r(e,"P",{"data-svelte-h":!0}),o(k)!=="svelte-1oc24ub"&&(k.innerHTML=Ht),Fe=s(e),F=r(e,"UL",{"data-svelte-h":!0}),o(F)!=="svelte-1ezbs4x"&&(F.innerHTML=jt),ze=s(e),u(z.$$.fragment,e),Ve=s(e),V=r(e,"UL",{"data-svelte-h":!0}),o(V)!=="svelte-1jyffto"&&(V.innerHTML=Ct),Ee=s(e),E=r(e,"P",{"data-svelte-h":!0}),o(E)!=="svelte-1axxmtw"&&(E.innerHTML=Jt),Re=s(e),R=r(e,"UL",{"data-svelte-h":!0}),o(R)!=="svelte-3slb70"&&(R.innerHTML=kt),Se=s(e),u(S.$$.fragment,e),Ze=s(e),Z=r(e,"P",{"data-svelte-h":!0}),o(Z)!=="svelte-kpkvzm"&&(Z.innerHTML=Ft),Pe=s(e),u(P.$$.fragment,e),Ie=s(e),I=r(e,"P",{"data-svelte-h":!0}),o(I)!=="svelte-17pmcho"&&(I.innerHTML=zt),Be=s(e),u(B.$$.fragment,e),Ge=s(e),u(G.$$.fragment,e),Ae=s(e),A=r(e,"OL",{"data-svelte-h":!0}),o(A)!=="svelte-4qt6h5"&&(A.innerHTML=Vt),We=s(e),u(W.$$.fragment,e),qe=s(e),q=r(e,"P",{"data-svelte-h":!0}),o(q)!=="svelte-12v53el"&&(q.innerHTML=Et),Ne=s(e),N=r(e,"UL",{"data-svelte-h":!0}),o(N)!=="svelte-9kh5p8"&&(N.innerHTML=Rt),Qe=s(e),Q=r(e,"P",{"data-svelte-h":!0}),o(Q)!=="svelte-1dn39ec"&&(Q.innerHTML=St),Ye=s(e),Y=r(e,"UL",{"data-svelte-h":!0}),o(Y)!=="svelte-zx6x9s"&&(Y.innerHTML=Zt),De=s(e),u(D.$$.fragment,e),Oe=s(e),O=r(e,"UL",{"data-svelte-h":!0}),o(O)!=="svelte-pyhvz1"&&(O.innerHTML=Pt),Xe=s(e),u(X.$$.fragment,e),Ke=s(e),K=r(e,"UL",{"data-svelte-h":!0}),o(K)!=="svelte-3x7tx"&&(K.innerHTML=It),et=s(e),u(ee.$$.fragment,e),tt=s(e),te=r(e,"TABLE",{"data-svelte-h":!0}),o(te)!=="svelte-p842x0"&&(te.innerHTML=Bt),it=s(e),u(ie.$$.fragment,e),nt=s(e),ne=r(e,"UL",{"data-svelte-h":!0}),o(ne)!=="svelte-pozt7y"&&(ne.innerHTML=Gt),lt=s(e),u(le.$$.fragment,e),st=s(e),se=r(e,"P",{"data-svelte-h":!0}),o(se)!=="svelte-11kosdz"&&(se.innerHTML=At),at=s(e),u(ae.$$.fragment,e),rt=s(e),re=r(e,"P",{"data-svelte-h":!0}),o(re)!=="svelte-p2z1vd"&&(re.innerHTML=Wt),ot=s(e),u(oe.$$.fragment,e),pt=s(e),u(pe.$$.fragment,e),ut=s(e),ue=r(e,"UL",{"data-svelte-h":!0}),o(ue)!=="svelte-138oe9m"&&(ue.innerHTML=qt),mt=s(e),me=r(e,"P",{"data-svelte-h":!0}),o(me)!=="svelte-12uvjv0"&&(me.textContent=Nt),gt=s(e),h=r(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),o(h)!=="svelte-dczo1r"&&(h.innerHTML=Qt),ft=s(e),u(ge.$$.fragment,e),ct=s(e),fe=r(e,"UL",{"data-svelte-h":!0}),o(fe)!=="svelte-oecojo"&&(fe.innerHTML=Yt),dt=s(e),u(ce.$$.fragment,e),Mt=s(e),Me=r(e,"P",{}),Dt(Me).forEach(i),this.h()},h(){$t(M,"name","hf:doc:metadata"),$t(M,"content",ri),$t(h,"class","tip")},m(e,t){ni(document.head,M),n(e,he,t),n(e,de,t),n(e,Te,t),m(T,e,t),n(e,$e,t),m($,e,t),n(e,ve,t),n(e,v,t),n(e,ye,t),m(y,e,t),n(e,we,t),n(e,w,t),n(e,Le,t),m(L,e,t),n(e,be,t),n(e,b,t),n(e,Ue,t),n(e,U,t),n(e,_e,t),m(_,e,t),n(e,xe,t),n(e,x,t),n(e,He,t),m(H,e,t),n(e,je,t),n(e,j,t),n(e,Ce,t),n(e,C,t),n(e,Je,t),m(J,e,t),n(e,ke,t),n(e,k,t),n(e,Fe,t),n(e,F,t),n(e,ze,t),m(z,e,t),n(e,Ve,t),n(e,V,t),n(e,Ee,t),n(e,E,t),n(e,Re,t),n(e,R,t),n(e,Se,t),m(S,e,t),n(e,Ze,t),n(e,Z,t),n(e,Pe,t),m(P,e,t),n(e,Ie,t),n(e,I,t),n(e,Be,t),m(B,e,t),n(e,Ge,t),m(G,e,t),n(e,Ae,t),n(e,A,t),n(e,We,t),m(W,e,t),n(e,qe,t),n(e,q,t),n(e,Ne,t),n(e,N,t),n(e,Qe,t),n(e,Q,t),n(e,Ye,t),n(e,Y,t),n(e,De,t),m(D,e,t),n(e,Oe,t),n(e,O,t),n(e,Xe,t),m(X,e,t),n(e,Ke,t),n(e,K,t),n(e,et,t),m(ee,e,t),n(e,tt,t),n(e,te,t),n(e,it,t),m(ie,e,t),n(e,nt,t),n(e,ne,t),n(e,lt,t),m(le,e,t),n(e,st,t),n(e,se,t),n(e,at,t),m(ae,e,t),n(e,rt,t),n(e,re,t),n(e,ot,t),m(oe,e,t),n(e,pt,t),m(pe,e,t),n(e,ut,t),n(e,ue,t),n(e,mt,t),n(e,me,t),n(e,gt,t),n(e,h,t),n(e,ft,t),m(ge,e,t),n(e,ct,t),n(e,fe,t),n(e,dt,t),m(ce,e,t),n(e,Mt,t),n(e,Me,t),ht=!0},p:Xt,i(e){ht||(g(T.$$.fragment,e),g($.$$.fragment,e),g(y.$$.fragment,e),g(L.$$.fragment,e),g(_.$$.fragment,e),g(H.$$.fragment,e),g(J.$$.fragment,e),g(z.$$.fragment,e),g(S.$$.fragment,e),g(P.$$.fragment,e),g(B.$$.fragment,e),g(G.$$.fragment,e),g(W.$$.fragment,e),g(D.$$.fragment,e),g(X.$$.fragment,e),g(ee.$$.fragment,e),g(ie.$$.fragment,e),g(le.$$.fragment,e),g(ae.$$.fragment,e),g(oe.$$.fragment,e),g(pe.$$.fragment,e),g(ge.$$.fragment,e),g(ce.$$.fragment,e),ht=!0)},o(e){f(T.$$.fragment,e),f($.$$.fragment,e),f(y.$$.fragment,e),f(L.$$.fragment,e),f(_.$$.fragment,e),f(H.$$.fragment,e),f(J.$$.fragment,e),f(z.$$.fragment,e),f(S.$$.fragment,e),f(P.$$.fragment,e),f(B.$$.fragment,e),f(G.$$.fragment,e),f(W.$$.fragment,e),f(D.$$.fragment,e),f(X.$$.fragment,e),f(ee.$$.fragment,e),f(ie.$$.fragment,e),f(le.$$.fragment,e),f(ae.$$.fragment,e),f(oe.$$.fragment,e),f(pe.$$.fragment,e),f(ge.$$.fragment,e),f(ce.$$.fragment,e),ht=!1},d(e){e&&(i(he),i(de),i(Te),i($e),i(ve),i(v),i(ye),i(we),i(w),i(Le),i(be),i(b),i(Ue),i(U),i(_e),i(xe),i(x),i(He),i(je),i(j),i(Ce),i(C),i(Je),i(ke),i(k),i(Fe),i(F),i(ze),i(Ve),i(V),i(Ee),i(E),i(Re),i(R),i(Se),i(Ze),i(Z),i(Pe),i(Ie),i(I),i(Be),i(Ge),i(Ae),i(A),i(We),i(qe),i(q),i(Ne),i(N),i(Qe),i(Q),i(Ye),i(Y),i(De),i(Oe),i(O),i(Xe),i(Ke),i(K),i(et),i(tt),i(te),i(it),i(nt),i(ne),i(lt),i(st),i(se),i(at),i(rt),i(re),i(ot),i(pt),i(ut),i(ue),i(mt),i(me),i(gt),i(h),i(ft),i(ct),i(fe),i(dt),i(Mt),i(Me)),i(M),c(T,e),c($,e),c(y,e),c(L,e),c(_,e),c(H,e),c(J,e),c(z,e),c(S,e),c(P,e),c(B,e),c(G,e),c(W,e),c(D,e),c(X,e),c(ee,e),c(ie,e),c(le,e),c(ae,e),c(oe,e),c(pe,e),c(ge,e),c(ce,e)}}}const ri='{"title":"Fine-Tuning VLMs","local":"fine-tuning-vlms","sections":[{"title":"Key Efficiency Techniques","local":"key-efficiency-techniques","sections":[{"title":"Quantization","local":"quantization","sections":[],"depth":3},{"title":"PEFT & LoRA","local":"peft--lora","sections":[],"depth":3},{"title":"Batch Size Optimization","local":"batch-size-optimization","sections":[],"depth":3}],"depth":2},{"title":"Supervised Fine-Tuning (SFT)","local":"supervised-fine-tuning-sft","sections":[{"title":"When to Use SFT","local":"when-to-use-sft","sections":[],"depth":3},{"title":"Usage Example","local":"usage-example","sections":[],"depth":3},{"title":"Practical Steps","local":"practical-steps","sections":[],"depth":3}],"depth":2},{"title":"Preference Optimization (DPO)","local":"preference-optimization-dpo","sections":[{"title":"Usage Example","local":"usage-example","sections":[],"depth":3},{"title":"SFT vs DPO Comparison","local":"sft-vs-dpo-comparison","sections":[],"depth":3},{"title":"Practical Tips","local":"practical-tips","sections":[],"depth":3},{"title":"Next Steps","local":"next-steps","sections":[],"depth":3}],"depth":2},{"title":"Fine-Tuning a VLM in hf jobs using TRL","local":"fine-tuning-a-vlm-in-hf-jobs-using-trl","sections":[{"title":"Quick Example","local":"quick-example","sections":[],"depth":3}],"depth":2},{"title":"Resources","local":"resources","sections":[],"depth":2}],"depth":1}';function oi(vt){return Kt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class fi extends ei{constructor(M){super(),ti(this,M,oi,ai,Ot,{})}}export{fi as component};
