import{s as Wn,a as it,o as zn,n as Bn}from"../chunks/scheduler.cc52f4b9.js";import{S as In,i as Zn,e as r,s as a,c as m,h as Gn,a as o,d as i,b as l,f as zi,g as u,j as d,k as y,l as Hn,m as n,n as g,t as f,o as c,p as h,q as Oe,r as et}from"../chunks/index.5b747fde.js";import{T as Ke}from"../chunks/Tip.f0925d57.js";import{C as Ln,H as $,E as En}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.d38ac5a9.js";import{C as Bi}from"../chunks/CodeBlock.665bfc37.js";import{C as qn}from"../chunks/CourseFloatingBanner.b33fcd79.js";import{Q as nt}from"../chunks/Question.58d62cc7.js";function Xn(T){let p;return{c(){p=Oe(`Consider SFT only if you:
- Need additional performance beyond what prompting can achieve
- Have a specific use case where the cost of using a large general-purpose model outweighs the cost of fine-tuning a smaller model
- Require specialized output formats or domain-specific knowledge that existing models struggle with`)},l(s){p=et(s,`Consider SFT only if you:
- Need additional performance beyond what prompting can achieve
- Have a specific use case where the cost of using a large general-purpose model outweighs the cost of fine-tuning a smaller model
- Require specialized output formats or domain-specific knowledge that existing models struggle with`)},m(s,w){n(s,p,w)},d(s){s&&i(p)}}}function Qn(T){let p,s,w="This evaluation will help determine if SFT is the right approach for your needs.";return{c(){p=Oe(`Before starting SFT, evaluate whether your use case requires:
- Precise output formatting
- Domain-specific knowledge
- Consistent response patterns
- Adherence to specific guidelines
`),s=r("p"),s.textContent=w},l(v){p=et(v,`Before starting SFT, evaluate whether your use case requires:
- Precise output formatting
- Domain-specific knowledge
- Consistent response patterns
- Adherence to specific guidelines
`),s=o(v,"P",{"data-svelte-h":!0}),d(s)!=="svelte-ktd560"&&(s.textContent=w)},m(v,M){n(v,p,M),n(v,s,M)},p:Bn,d(v){v&&(i(p),i(s))}}}function Pn(T){let p;return{c(){p=Oe(`Start with conservative values and adjust based on monitoring:
- Begin with 1-3 epochs
- Use smaller batch sizes initially
- Monitor validation metrics closely
- Adjust learning rate if training is unstable`)},l(s){p=et(s,`Start with conservative values and adjust based on monitoring:
- Begin with 1-3 epochs
- Use smaller batch sizes initially
- Monitor validation metrics closely
- Adjust learning rate if training is unstable`)},m(s,w){n(s,p,w)},d(s){s&&i(p)}}}function Vn(T){let p;return{c(){p=Oe(`When using a dataset with a "messages" field (like the example above), the SFTTrainer automatically applies the model's chat template, which it retrieves from the hub. This means you don't need any additional configuration to handle chat-style conversations - the trainer will format the messages according to the model's expected template format.`)},l(s){p=et(s,`When using a dataset with a "messages" field (like the example above), the SFTTrainer automatically applies the model's chat template, which it retrieves from the hub. This means you don't need any additional configuration to handle chat-style conversations - the trainer will format the messages according to the model's expected template format.`)},m(s,w){n(s,p,w)},d(s){s&&i(p)}}}function Nn(T){let p;return{c(){p=Oe(`Watch for these warning signs during training:
1. Validation loss increasing while training loss decreases (overfitting)
2. No significant improvement in loss values (underfitting)
3. Extremely low loss values (potential memorization)
4. Inconsistent output formatting (template learning issues)`)},l(s){p=et(s,`Watch for these warning signs during training:
1. Validation loss increasing while training loss decreases (overfitting)
2. No significant improvement in loss values (underfitting)
3. Extremely low loss values (potential memorization)
4. Inconsistent output formatting (template learning issues)`)},m(s,w){n(s,p,w)},d(s){s&&i(p)}}}function Yn(T){let p;return{c(){p=Oe("Monitor both the loss values and the model's actual outputs during training. Sometimes the loss can look good while the model develops unwanted behaviors. Regular qualitative evaluation of the model's responses helps catch issues that metrics alone might miss.")},l(s){p=et(s,"Monitor both the loss values and the model's actual outputs during training. Sometimes the loss can look good while the model develops unwanted behaviors. Regular qualitative evaluation of the model's responses helps catch issues that metrics alone might miss.")},m(s,w){n(s,p,w)},d(s){s&&i(p)}}}function An(T){let p;return{c(){p=Oe(`Document your training process, including:
- Dataset characteristics
- Training parameters
- Performance metrics
- Known limitations
This documentation will be valuable for future model iterations.`)},l(s){p=et(s,`Document your training process, including:
- Dataset characteristics
- Training parameters
- Performance metrics
- Known limitations
This documentation will be valuable for future model iterations.`)},m(s,w){n(s,p,w)},d(s){s&&i(p)}}}function Dn(T){let p,s,w,v,M,at,k,lt,R,st,S,Ii="Supervised Fine-Tuning (SFT) is a process primarily used to adapt pre-trained language models to follow instructions, engage in dialogue, and use specific output formats. While pre-trained models have impressive general capabilities, SFT helps transform them into assistant-like models that can better understand and respond to user prompts. This is typically done by training on datasets of human-written conversations and instructions.",rt,W,Zi='This page provides a step-by-step guide to fine-tuning the <a href="https://huggingface.co/deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B" rel="nofollow"><code>deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B</code></a> model using the <a href="https://huggingface.co/docs/trl/en/sft_trainer" rel="nofollow"><code>SFTTrainer</code></a>. By following these steps, you can adapt the model to perform specific tasks more effectively.',ot,z,pt,B,Gi="Before diving into implementation, it’s important to understand when SFT is the right choice for your project. As a first step, you should consider whether using an existing instruction-tuned model with well-crafted prompts would suffice for your use case. SFT involves significant computational resources and engineering effort, so it should only be pursued when prompting existing models proves insufficient.",mt,C,ut,I,Hi="If you determine that SFT is necessary, the decision to proceed depends on two primary factors:",gt,Z,ft,G,Li="SFT allows precise control over the model’s output structure. This is particularly valuable when you need the model to:",ct,H,Ei="<li>Generate responses in a specific chat template format</li> <li>Follow strict output schemas</li> <li>Maintain consistent styling across responses</li>",ht,L,dt,E,qi="When working in specialized domains, SFT helps align the model with domain-specific requirements by:",$t,q,Xi="<li>Teaching domain terminology and concepts</li> <li>Enforcing professional standards</li> <li>Handling technical queries appropriately</li> <li>Following industry-specific guidelines</li>",wt,_,Tt,X,yt,Q,Qi="The supervised fine-tuning process requires a task-specific dataset structured with input-output pairs. Each pair should consist of:",vt,P,Pi="<li>An input prompt</li> <li>The expected model response</li> <li>Any additional context or metadata</li>",Mt,V,Vi="The quality of your training data is crucial for successful fine-tuning. Let’s look at how to prepare and validate your dataset:",bt,b,Ni,Ct,N,_t,Y,Yi="The success of your fine-tuning depends heavily on choosing the right training parameters. Let’s explore each important parameter and how to configure them effectively:",xt,A,Ai="The SFTTrainer configuration requires consideration of several parameters that control the training process. Let’s explore each parameter and their purpose:",Ut,D,Di="<li><p><strong>Training Duration Parameters</strong>:</p> <ul><li><code>num_train_epochs</code>: Controls total training duration</li> <li><code>max_steps</code>: Alternative to epochs, sets maximum number of training steps</li> <li>More epochs allow better learning but risk overfitting</li></ul></li> <li><p><strong>Batch Size Parameters</strong>:</p> <ul><li><code>per_device_train_batch_size</code>: Determines memory usage and training stability</li> <li><code>gradient_accumulation_steps</code>: Enables larger effective batch sizes</li> <li>Larger batches provide more stable gradients but require more memory</li></ul></li> <li><p><strong>Learning Rate Parameters</strong>:</p> <ul><li><code>learning_rate</code>: Controls size of weight updates</li> <li><code>warmup_ratio</code>: Portion of training used for learning rate warmup</li> <li>Too high can cause instability, too low results in slow learning</li></ul></li> <li><p><strong>Monitoring Parameters</strong>:</p> <ul><li><code>logging_steps</code>: Frequency of metric logging</li> <li><code>eval_steps</code>: How often to evaluate on validation data</li> <li><code>save_steps</code>: Frequency of model checkpoint saves</li></ul></li>",Jt,x,Ft,K,jt,O,Ki="Now that we understand the key components, let’s implement the training with proper validation and monitoring. We will use the <code>SFTTrainer</code> class from the Transformers Reinforcement Learning (TRL) library, which is built on top of the <code>transformers</code> library. Here’s a complete example using the TRL library:",kt,ee,Rt,U,St,te,Wt,ie,Oi="The SFTTrainer supports example packing to optimize training efficiency. This feature allows multiple short examples to be packed into the same input sequence, maximizing GPU utilization during training. To enable packing, simply set <code>packing=True</code> in the SFTConfig constructor. When using packed datasets with <code>max_steps</code>, be aware that you may train for more epochs than expected depending on your packing configuration. You can customize how examples are combined using a formatting function - particularly useful when working with datasets that have multiple fields like question-answer pairs. For evaluation datasets, you can disable packing by setting <code>eval_packing=False</code> in the SFTConfig. Here’s a basic example of customizing the packing configuration:",zt,ne,Bt,ae,en="When packing the dataset with multiple fields, you can define a custom formatting function to combine the fields into a single input sequence. This function should take a list of examples and return a dictionary with the packed input sequence. Here’s an example of a custom formatting function:",It,le,Zt,se,Gt,re,tn="Effective monitoring is crucial for successful fine-tuning. Let’s explore what to watch for during training:",Ht,oe,Lt,pe,nn="Training loss typically follows three distinct phases:",Et,me,an="<li>Initial Sharp Drop: Rapid adaptation to new data distribution</li> <li>Gradual Stabilization: Learning rate slows as model fine-tunes</li> <li>Convergence: Loss values stabilize, indicating training completion</li>",qt,ue,ln,Xt,ge,Qt,fe,sn="Effective monitoring involves tracking quantitative metrics, and evaluating qualitative metrics. Available metrics are:",Pt,ce,rn="<li>Training loss</li> <li>Validation loss</li> <li>Learning rate progression</li> <li>Gradient norms</li>",Vt,J,Nt,he,Yt,de,on=`As training progresses, the loss curve should gradually stabilize. The key indicator of healthy training is a small gap between training and validation loss, suggesting
the model is learning generalizable patterns rather than memorizing specific examples. The absolute loss values will vary depending on your task and dataset.`,At,$e,Dt,we,pn="The graph above shows a typical training progression. Notice how both training and validation loss decrease sharply at first, then gradually level off. This pattern indicates the model is learning effectively while maintaining generalization ability.",Kt,Te,Ot,ye,mn="Several patterns in the loss curves can indicate potential issues. Below we illustrate common warning signs and solutions that we can consider.",ei,ve,un,ti,Me,gn="If the validation loss decreases at a significantly slower rate than training loss, your model is likely overfitting to the training data. Consider:",ii,be,fn="<li>Reducing the training steps</li> <li>Increasing the dataset size</li> <li>Validating dataset quality and diversity</li>",ni,Ce,cn,ai,_e,hn="If the loss doesn’t show significant improvement, the model might be:",li,xe,dn="<li>Learning too slowly (try increasing the learning rate)</li> <li>Struggling with the task (check data quality and task complexity)</li> <li>Hitting architecture limitations (consider a different model)</li>",si,Ue,$n,ri,Je,wn="Extremely low loss values could suggest memorization rather than learning. This is particularly concerning if:",oi,Fe,Tn="<li>The model performs poorly on new, similar examples</li> <li>The outputs lack diversity</li> <li>The responses are too similar to training examples</li>",pi,F,mi,je,yn='We should note that the interpretation of the loss values we outline here is aimed on the most common case, and in fact, loss values can behave on various ways depending on the model, the dataset, the training parameters, etc. If you interested in exploring more about outlined patterns, you should check out this blog post by the people at <a href="https://www.fast.ai/posts/2023-09-04-learning-jumps/" rel="nofollow">Fast AI</a>.',ui,ke,gi,Re,vn='In section <a href="/en/chapter11/4">11.4</a> we will learn how to evaluate the model using benchmark datasets. For now, we will focus on the qualitative evaluation of the model.',fi,Se,Mn="After completing SFT, consider these follow-up actions:",ci,We,bn="<li>Evaluate the model thoroughly on held-out test data</li> <li>Validate template adherence across various inputs</li> <li>Test domain-specific knowledge retention</li> <li>Monitor real-world performance metrics</li>",hi,j,di,ze,$i,Be,wi,Ie,Ti,Ze,yi,Ge,vi,He,Mi,Le,bi,Ee,Ci,qe,_i,Xe,xi,Qe,Ui,Pe,Ji,Ve,Cn="You’ve learned how to fine-tune models using SFT! To continue your learning:",Fi,Ne,_n="<li>Try the notebook with different parameters</li> <li>Experiment with other datasets</li> <li>Contribute improvements to the course material</li>",ji,Ye,ki,Ae,xn='<li><a href="https://huggingface.co/docs/trl" rel="nofollow">TRL Documentation</a></li> <li><a href="https://github.com/huggingface/trl/blob/main/trl/scripts/sft.py" rel="nofollow">SFT Examples Repository</a></li> <li><a href="https://huggingface.co/docs/transformers/training" rel="nofollow">Fine-tuning Best Practices</a></li>',Ri,De,Si,tt,Wi;return M=new qn({props:{chapter:2,classNames:"absolute z-10 right-0 top-0",notebooks:[{label:"Google Colab",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/course/en/chapter11/section3.ipynb"}]}}),k=new Ln({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),R=new $({props:{title:"Supervised Fine-Tuning",local:"supervised-fine-tuning",headingTag:"h1"}}),z=new $({props:{title:"When to Use SFT",local:"when-to-use-sft",headingTag:"h2"}}),C=new Ke({props:{$$slots:{default:[Xn]},$$scope:{ctx:T}}}),Z=new $({props:{title:"Template Control",local:"template-control",headingTag:"h3"}}),L=new $({props:{title:"Domain Adaptation",local:"domain-adaptation",headingTag:"h3"}}),_=new Ke({props:{$$slots:{default:[Qn]},$$scope:{ctx:T}}}),X=new $({props:{title:"Dataset Preparation",local:"dataset-preparation",headingTag:"h2"}}),N=new $({props:{title:"Training Configuration",local:"training-configuration",headingTag:"h2"}}),x=new Ke({props:{$$slots:{default:[Pn]},$$scope:{ctx:T}}}),K=new $({props:{title:"Implementation with TRL",local:"implementation-with-trl",headingTag:"h2"}}),ee=new Bi({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBZnJvbSUyMHRybCUyMGltcG9ydCUyMFNGVENvbmZpZyUyQyUyMFNGVFRyYWluZXIlMEFpbXBvcnQlMjB0b3JjaCUwQSUwQSUyMyUyMFNldCUyMGRldmljZSUwQWRldmljZSUyMCUzRCUyMCUyMmN1ZGElMjIlMjBpZiUyMHRvcmNoLmN1ZGEuaXNfYXZhaWxhYmxlKCklMjBlbHNlJTIwJTIyY3B1JTIyJTBBJTBBJTIzJTIwTG9hZCUyMGRhdGFzZXQlMEFkYXRhc2V0JTIwJTNEJTIwbG9hZF9kYXRhc2V0KCUyMkh1Z2dpbmdGYWNlVEIlMkZzbW9sdGFsayUyMiUyQyUyMCUyMmFsbCUyMiklMEElMEElMjMlMjBDb25maWd1cmUlMjBtb2RlbCUyMGFuZCUyMHRva2VuaXplciUwQW1vZGVsX25hbWUlMjAlM0QlMjAlMjJIdWdnaW5nRmFjZVRCJTJGU21vbExNMi0xMzVNJTIyJTBBbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JDYXVzYWxMTS5mcm9tX3ByZXRyYWluZWQocHJldHJhaW5lZF9tb2RlbF9uYW1lX29yX3BhdGglM0Rtb2RlbF9uYW1lKS50byglMEElMjAlMjAlMjAlMjBkZXZpY2UlMEEpJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQocHJldHJhaW5lZF9tb2RlbF9uYW1lX29yX3BhdGglM0Rtb2RlbF9uYW1lKSUwQSUyMyUyMFNldHVwJTIwY2hhdCUyMHRlbXBsYXRlJTBBbW9kZWwlMkMlMjB0b2tlbml6ZXIlMjAlM0QlMjBzZXR1cF9jaGF0X2Zvcm1hdChtb2RlbCUzRG1vZGVsJTJDJTIwdG9rZW5pemVyJTNEdG9rZW5pemVyKSUwQSUwQSUyMyUyMENvbmZpZ3VyZSUyMHRyYWluZXIlMEF0cmFpbmluZ19hcmdzJTIwJTNEJTIwU0ZUQ29uZmlnKCUwQSUyMCUyMCUyMCUyMG91dHB1dF9kaXIlM0QlMjIuJTJGc2Z0X291dHB1dCUyMiUyQyUwQSUyMCUyMCUyMCUyMG1heF9zdGVwcyUzRDEwMDAlMkMlMEElMjAlMjAlMjAlMjBwZXJfZGV2aWNlX3RyYWluX2JhdGNoX3NpemUlM0Q0JTJDJTBBJTIwJTIwJTIwJTIwbGVhcm5pbmdfcmF0ZSUzRDVlLTUlMkMlMEElMjAlMjAlMjAlMjBsb2dnaW5nX3N0ZXBzJTNEMTAlMkMlMEElMjAlMjAlMjAlMjBzYXZlX3N0ZXBzJTNEMTAwJTJDJTBBJTIwJTIwJTIwJTIwZXZhbF9zdHJhdGVneSUzRCUyMnN0ZXBzJTIyJTJDJTBBJTIwJTIwJTIwJTIwZXZhbF9zdGVwcyUzRDUwJTJDJTBBKSUwQSUwQSUyMyUyMEluaXRpYWxpemUlMjB0cmFpbmVyJTBBdHJhaW5lciUyMCUzRCUyMFNGVFRyYWluZXIoJTBBJTIwJTIwJTIwJTIwbW9kZWwlM0Rtb2RlbCUyQyUwQSUyMCUyMCUyMCUyMGFyZ3MlM0R0cmFpbmluZ19hcmdzJTJDJTBBJTIwJTIwJTIwJTIwdHJhaW5fZGF0YXNldCUzRGRhdGFzZXQlNUIlMjJ0cmFpbiUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMGV2YWxfZGF0YXNldCUzRGRhdGFzZXQlNUIlMjJ0ZXN0JTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwcHJvY2Vzc2luZ19jbGFzcyUzRHRva2VuaXplciUyQyUwQSklMEElMEElMjMlMjBTdGFydCUyMHRyYWluaW5nJTBBdHJhaW5lci50cmFpbigp",highlighted:`<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> SFTConfig, SFTTrainer
<span class="hljs-keyword">import</span> torch

<span class="hljs-comment"># Set device</span>
device = <span class="hljs-string">&quot;cuda&quot;</span> <span class="hljs-keyword">if</span> torch.cuda.is_available() <span class="hljs-keyword">else</span> <span class="hljs-string">&quot;cpu&quot;</span>

<span class="hljs-comment"># Load dataset</span>
dataset = load_dataset(<span class="hljs-string">&quot;HuggingFaceTB/smoltalk&quot;</span>, <span class="hljs-string">&quot;all&quot;</span>)

<span class="hljs-comment"># Configure model and tokenizer</span>
model_name = <span class="hljs-string">&quot;HuggingFaceTB/SmolLM2-135M&quot;</span>
model = AutoModelForCausalLM.from_pretrained(pretrained_model_name_or_path=model_name).to(
    device
)
tokenizer = AutoTokenizer.from_pretrained(pretrained_model_name_or_path=model_name)
<span class="hljs-comment"># Setup chat template</span>
model, tokenizer = setup_chat_format(model=model, tokenizer=tokenizer)

<span class="hljs-comment"># Configure trainer</span>
training_args = SFTConfig(
    output_dir=<span class="hljs-string">&quot;./sft_output&quot;</span>,
    max_steps=<span class="hljs-number">1000</span>,
    per_device_train_batch_size=<span class="hljs-number">4</span>,
    learning_rate=<span class="hljs-number">5e-5</span>,
    logging_steps=<span class="hljs-number">10</span>,
    save_steps=<span class="hljs-number">100</span>,
    eval_strategy=<span class="hljs-string">&quot;steps&quot;</span>,
    eval_steps=<span class="hljs-number">50</span>,
)

<span class="hljs-comment"># Initialize trainer</span>
trainer = SFTTrainer(
    model=model,
    args=training_args,
    train_dataset=dataset[<span class="hljs-string">&quot;train&quot;</span>],
    eval_dataset=dataset[<span class="hljs-string">&quot;test&quot;</span>],
    processing_class=tokenizer,
)

<span class="hljs-comment"># Start training</span>
trainer.train()`,wrap:!1}}),U=new Ke({props:{$$slots:{default:[Vn]},$$scope:{ctx:T}}}),te=new $({props:{title:"Packing the Dataset",local:"packing-the-dataset",headingTag:"h2"}}),ne=new Bi({props:{code:"JTIzJTIwQ29uZmlndXJlJTIwcGFja2luZyUwQXRyYWluaW5nX2FyZ3MlMjAlM0QlMjBTRlRDb25maWcocGFja2luZyUzRFRydWUpJTBBJTBBdHJhaW5lciUyMCUzRCUyMFNGVFRyYWluZXIobW9kZWwlM0Rtb2RlbCUyQyUyMHRyYWluX2RhdGFzZXQlM0RkYXRhc2V0JTJDJTIwYXJncyUzRHRyYWluaW5nX2FyZ3MpJTBBJTBBdHJhaW5lci50cmFpbigp",highlighted:`<span class="hljs-comment"># Configure packing</span>
training_args = SFTConfig(packing=<span class="hljs-literal">True</span>)

trainer = SFTTrainer(model=model, train_dataset=dataset, args=training_args)

trainer.train()`,wrap:!1}}),le=new Bi({props:{code:"ZGVmJTIwZm9ybWF0dGluZ19mdW5jKGV4YW1wbGUpJTNBJTBBJTIwJTIwJTIwJTIwdGV4dCUyMCUzRCUyMGYlMjIlMjMlMjMlMjMlMjBRdWVzdGlvbiUzQSUyMCU3QmV4YW1wbGUlNUIncXVlc3Rpb24nJTVEJTdEJTVDbiUyMCUyMyUyMyUyMyUyMEFuc3dlciUzQSUyMCU3QmV4YW1wbGUlNUInYW5zd2VyJyU1RCU3RCUyMiUwQSUyMCUyMCUyMCUyMHJldHVybiUyMHRleHQlMEElMEElMEF0cmFpbmluZ19hcmdzJTIwJTNEJTIwU0ZUQ29uZmlnKHBhY2tpbmclM0RUcnVlKSUwQXRyYWluZXIlMjAlM0QlMjBTRlRUcmFpbmVyKCUwQSUyMCUyMCUyMCUyMCUyMmZhY2Vib29rJTJGb3B0LTM1MG0lMjIlMkMlMEElMjAlMjAlMjAlMjB0cmFpbl9kYXRhc2V0JTNEZGF0YXNldCUyQyUwQSUyMCUyMCUyMCUyMGFyZ3MlM0R0cmFpbmluZ19hcmdzJTJDJTBBJTIwJTIwJTIwJTIwZm9ybWF0dGluZ19mdW5jJTNEZm9ybWF0dGluZ19mdW5jJTJDJTBBKQ==",highlighted:`<span class="hljs-keyword">def</span> <span class="hljs-title function_">formatting_func</span>(<span class="hljs-params">example</span>):
    text = <span class="hljs-string">f&quot;### Question: <span class="hljs-subst">{example[<span class="hljs-string">&#x27;question&#x27;</span>]}</span>\\n ### Answer: <span class="hljs-subst">{example[<span class="hljs-string">&#x27;answer&#x27;</span>]}</span>&quot;</span>
    <span class="hljs-keyword">return</span> text


training_args = SFTConfig(packing=<span class="hljs-literal">True</span>)
trainer = SFTTrainer(
    <span class="hljs-string">&quot;facebook/opt-350m&quot;</span>,
    train_dataset=dataset,
    args=training_args,
    formatting_func=formatting_func,
)`,wrap:!1}}),se=new $({props:{title:"Monitoring Training Progress",local:"monitoring-training-progress",headingTag:"h2"}}),oe=new $({props:{title:"Understanding Loss Patterns",local:"understanding-loss-patterns",headingTag:"h3"}}),ge=new $({props:{title:"Metrics to Monitor",local:"metrics-to-monitor",headingTag:"h3"}}),J=new Ke({props:{warning:!0,$$slots:{default:[Nn]},$$scope:{ctx:T}}}),he=new $({props:{title:"The Path to Convergence",local:"the-path-to-convergence",headingTag:"h3"}}),$e=new $({props:{title:"Monitoring Training Progress",local:"monitoring-training-progress",headingTag:"h3"}}),Te=new $({props:{title:"Warning Signs to Watch For",local:"warning-signs-to-watch-for",headingTag:"h3"}}),F=new Ke({props:{warning:!0,$$slots:{default:[Yn]},$$scope:{ctx:T}}}),ke=new $({props:{title:"Evaluation after SFT",local:"evaluation-after-sft",headingTag:"h2"}}),j=new Ke({props:{$$slots:{default:[An]},$$scope:{ctx:T}}}),ze=new $({props:{title:"Quiz",local:"quiz",headingTag:"h2"}}),Be=new $({props:{title:"1. What parameters control the training duration in SFT?",local:"1-what-parameters-control-the-training-duration-in-sft",headingTag:"h3"}}),Ie=new nt({props:{choices:[{text:"num_train_epochs and max_steps",explain:"Correct! These parameters determine how long the model will train, either by number of epochs or total steps.",correct:!0},{text:"batch_size and learning_rate",explain:"While these affect training, they don't directly control the duration."},{text:"gradient_checkpointing and warmup_ratio",explain:"These parameters affect training efficiency and stability, not duration."}]}}),Ze=new $({props:{title:"2. Which pattern in the loss curves indicates potential overfitting?",local:"2-which-pattern-in-the-loss-curves-indicates-potential-overfitting",headingTag:"h3"}}),Ge=new nt({props:{choices:[{text:"Validation loss increases while training loss continues to decrease",explain:"Correct! This divergence between training and validation loss is a classic sign of overfitting.",correct:!0},{text:"Both training and validation loss decrease steadily",explain:"This pattern actually indicates healthy training."},{text:"Training loss remains constant while validation loss decreases",explain:"This would be an unusual pattern and doesn't indicate overfitting."}]}}),He=new $({props:{title:"3. What is gradient_accumulation_steps used for?",local:"3-what-is-gradientaccumulationsteps-used-for",headingTag:"h3"}}),Le=new nt({props:{choices:[{text:"To increase effective batch size without using more memory",explain:"Correct! It accumulates gradients across multiple forward passes before updating weights.",correct:!0},{text:"To save checkpoints during training",explain:"This is handled by save_steps and save_strategy parameters."},{text:"To control the learning rate schedule",explain:"Learning rate scheduling is controlled by learning_rate and warmup_ratio."}]}}),Ee=new $({props:{title:"4. What should you monitor during SFT training?",local:"4-what-should-you-monitor-during-sft-training",headingTag:"h3"}}),qe=new nt({props:{choices:[{text:"Both quantitative metrics and qualitative outputs",explain:"Correct! Monitoring both types of metrics helps catch all potential issues.",correct:!0},{text:"Only the training loss",explain:"Training loss alone isn't sufficient to ensure good model behavior."},{text:"Only the model's output quality",explain:"While important, qualitative evaluation alone misses important training dynamics."}]}}),Xe=new $({props:{title:"5. What indicates healthy convergence during training?",local:"5-what-indicates-healthy-convergence-during-training",headingTag:"h3"}}),Qe=new nt({props:{choices:[{text:"A small gap between training and validation loss",explain:"Correct! This indicates the model is learning generalizable patterns.",correct:!0},{text:"Training loss reaching zero",explain:"Extremely low loss values might indicate memorization rather than learning."},{text:"Validation loss being lower than training loss",explain:"This would be unusual and might indicate problems with the validation set."}]}}),Pe=new $({props:{title:"💐 Nice work!",local:"-nice-work",headingTag:"h2"}}),Ye=new $({props:{title:"Additional Resources",local:"additional-resources",headingTag:"h2"}}),De=new En({props:{source:"https://github.com/huggingface/course/blob/main/chapters/en/chapter11/3.mdx"}}),{c(){p=r("meta"),s=a(),w=r("p"),v=a(),m(M.$$.fragment),at=a(),m(k.$$.fragment),lt=a(),m(R.$$.fragment),st=a(),S=r("p"),S.textContent=Ii,rt=a(),W=r("p"),W.innerHTML=Zi,ot=a(),m(z.$$.fragment),pt=a(),B=r("p"),B.textContent=Gi,mt=a(),m(C.$$.fragment),ut=a(),I=r("p"),I.textContent=Hi,gt=a(),m(Z.$$.fragment),ft=a(),G=r("p"),G.textContent=Li,ct=a(),H=r("ol"),H.innerHTML=Ei,ht=a(),m(L.$$.fragment),dt=a(),E=r("p"),E.textContent=qi,$t=a(),q=r("ol"),q.innerHTML=Xi,wt=a(),m(_.$$.fragment),Tt=a(),m(X.$$.fragment),yt=a(),Q=r("p"),Q.textContent=Qi,vt=a(),P=r("ol"),P.innerHTML=Pi,Mt=a(),V=r("p"),V.textContent=Vi,bt=a(),b=r("iframe"),Ct=a(),m(N.$$.fragment),_t=a(),Y=r("p"),Y.textContent=Yi,xt=a(),A=r("p"),A.textContent=Ai,Ut=a(),D=r("ol"),D.innerHTML=Di,Jt=a(),m(x.$$.fragment),Ft=a(),m(K.$$.fragment),jt=a(),O=r("p"),O.innerHTML=Ki,kt=a(),m(ee.$$.fragment),Rt=a(),m(U.$$.fragment),St=a(),m(te.$$.fragment),Wt=a(),ie=r("p"),ie.innerHTML=Oi,zt=a(),m(ne.$$.fragment),Bt=a(),ae=r("p"),ae.textContent=en,It=a(),m(le.$$.fragment),Zt=a(),m(se.$$.fragment),Gt=a(),re=r("p"),re.textContent=tn,Ht=a(),m(oe.$$.fragment),Lt=a(),pe=r("p"),pe.textContent=nn,Et=a(),me=r("ol"),me.innerHTML=an,qt=a(),ue=r("img"),Xt=a(),m(ge.$$.fragment),Qt=a(),fe=r("p"),fe.textContent=sn,Pt=a(),ce=r("ul"),ce.innerHTML=rn,Vt=a(),m(J.$$.fragment),Nt=a(),m(he.$$.fragment),Yt=a(),de=r("p"),de.textContent=on,At=a(),m($e.$$.fragment),Dt=a(),we=r("p"),we.textContent=pn,Kt=a(),m(Te.$$.fragment),Ot=a(),ye=r("p"),ye.textContent=mn,ei=a(),ve=r("img"),ti=a(),Me=r("p"),Me.textContent=gn,ii=a(),be=r("ul"),be.innerHTML=fn,ni=a(),Ce=r("img"),ai=a(),_e=r("p"),_e.textContent=hn,li=a(),xe=r("ul"),xe.innerHTML=dn,si=a(),Ue=r("img"),ri=a(),Je=r("p"),Je.textContent=wn,oi=a(),Fe=r("ul"),Fe.innerHTML=Tn,pi=a(),m(F.$$.fragment),mi=a(),je=r("p"),je.innerHTML=yn,ui=a(),m(ke.$$.fragment),gi=a(),Re=r("p"),Re.innerHTML=vn,fi=a(),Se=r("p"),Se.textContent=Mn,ci=a(),We=r("ol"),We.innerHTML=bn,hi=a(),m(j.$$.fragment),di=a(),m(ze.$$.fragment),$i=a(),m(Be.$$.fragment),wi=a(),m(Ie.$$.fragment),Ti=a(),m(Ze.$$.fragment),yi=a(),m(Ge.$$.fragment),vi=a(),m(He.$$.fragment),Mi=a(),m(Le.$$.fragment),bi=a(),m(Ee.$$.fragment),Ci=a(),m(qe.$$.fragment),_i=a(),m(Xe.$$.fragment),xi=a(),m(Qe.$$.fragment),Ui=a(),m(Pe.$$.fragment),Ji=a(),Ve=r("p"),Ve.textContent=Cn,Fi=a(),Ne=r("ol"),Ne.innerHTML=_n,ji=a(),m(Ye.$$.fragment),ki=a(),Ae=r("ul"),Ae.innerHTML=xn,Ri=a(),m(De.$$.fragment),Si=a(),tt=r("p"),this.h()},l(e){const t=Gn("svelte-u9bgzb",document.head);p=o(t,"META",{name:!0,content:!0}),t.forEach(i),s=l(e),w=o(e,"P",{}),zi(w).forEach(i),v=l(e),u(M.$$.fragment,e),at=l(e),u(k.$$.fragment,e),lt=l(e),u(R.$$.fragment,e),st=l(e),S=o(e,"P",{"data-svelte-h":!0}),d(S)!=="svelte-1r3e85q"&&(S.textContent=Ii),rt=l(e),W=o(e,"P",{"data-svelte-h":!0}),d(W)!=="svelte-1lbymgt"&&(W.innerHTML=Zi),ot=l(e),u(z.$$.fragment,e),pt=l(e),B=o(e,"P",{"data-svelte-h":!0}),d(B)!=="svelte-bzr0f8"&&(B.textContent=Gi),mt=l(e),u(C.$$.fragment,e),ut=l(e),I=o(e,"P",{"data-svelte-h":!0}),d(I)!=="svelte-1vu1858"&&(I.textContent=Hi),gt=l(e),u(Z.$$.fragment,e),ft=l(e),G=o(e,"P",{"data-svelte-h":!0}),d(G)!=="svelte-vqqipn"&&(G.textContent=Li),ct=l(e),H=o(e,"OL",{"data-svelte-h":!0}),d(H)!=="svelte-f2jeai"&&(H.innerHTML=Ei),ht=l(e),u(L.$$.fragment,e),dt=l(e),E=o(e,"P",{"data-svelte-h":!0}),d(E)!=="svelte-63mafi"&&(E.textContent=qi),$t=l(e),q=o(e,"OL",{"data-svelte-h":!0}),d(q)!=="svelte-14ez77z"&&(q.innerHTML=Xi),wt=l(e),u(_.$$.fragment,e),Tt=l(e),u(X.$$.fragment,e),yt=l(e),Q=o(e,"P",{"data-svelte-h":!0}),d(Q)!=="svelte-1gnb02p"&&(Q.textContent=Qi),vt=l(e),P=o(e,"OL",{"data-svelte-h":!0}),d(P)!=="svelte-1vwaxbl"&&(P.innerHTML=Pi),Mt=l(e),V=o(e,"P",{"data-svelte-h":!0}),d(V)!=="svelte-irg7th"&&(V.textContent=Vi),bt=l(e),b=o(e,"IFRAME",{src:!0,frameborder:!0,width:!0,height:!0}),zi(b).forEach(i),Ct=l(e),u(N.$$.fragment,e),_t=l(e),Y=o(e,"P",{"data-svelte-h":!0}),d(Y)!=="svelte-ioywgh"&&(Y.textContent=Yi),xt=l(e),A=o(e,"P",{"data-svelte-h":!0}),d(A)!=="svelte-14sqfj"&&(A.textContent=Ai),Ut=l(e),D=o(e,"OL",{"data-svelte-h":!0}),d(D)!=="svelte-6ztbbs"&&(D.innerHTML=Di),Jt=l(e),u(x.$$.fragment,e),Ft=l(e),u(K.$$.fragment,e),jt=l(e),O=o(e,"P",{"data-svelte-h":!0}),d(O)!=="svelte-grvvks"&&(O.innerHTML=Ki),kt=l(e),u(ee.$$.fragment,e),Rt=l(e),u(U.$$.fragment,e),St=l(e),u(te.$$.fragment,e),Wt=l(e),ie=o(e,"P",{"data-svelte-h":!0}),d(ie)!=="svelte-1nxebfc"&&(ie.innerHTML=Oi),zt=l(e),u(ne.$$.fragment,e),Bt=l(e),ae=o(e,"P",{"data-svelte-h":!0}),d(ae)!=="svelte-c7t1n6"&&(ae.textContent=en),It=l(e),u(le.$$.fragment,e),Zt=l(e),u(se.$$.fragment,e),Gt=l(e),re=o(e,"P",{"data-svelte-h":!0}),d(re)!=="svelte-muo025"&&(re.textContent=tn),Ht=l(e),u(oe.$$.fragment,e),Lt=l(e),pe=o(e,"P",{"data-svelte-h":!0}),d(pe)!=="svelte-1kxz6c2"&&(pe.textContent=nn),Et=l(e),me=o(e,"OL",{"data-svelte-h":!0}),d(me)!=="svelte-12kgh6p"&&(me.innerHTML=an),qt=l(e),ue=o(e,"IMG",{src:!0,alt:!0}),Xt=l(e),u(ge.$$.fragment,e),Qt=l(e),fe=o(e,"P",{"data-svelte-h":!0}),d(fe)!=="svelte-1y9ggj5"&&(fe.textContent=sn),Pt=l(e),ce=o(e,"UL",{"data-svelte-h":!0}),d(ce)!=="svelte-acv7jp"&&(ce.innerHTML=rn),Vt=l(e),u(J.$$.fragment,e),Nt=l(e),u(he.$$.fragment,e),Yt=l(e),de=o(e,"P",{"data-svelte-h":!0}),d(de)!=="svelte-ie5i5"&&(de.textContent=on),At=l(e),u($e.$$.fragment,e),Dt=l(e),we=o(e,"P",{"data-svelte-h":!0}),d(we)!=="svelte-1s6faap"&&(we.textContent=pn),Kt=l(e),u(Te.$$.fragment,e),Ot=l(e),ye=o(e,"P",{"data-svelte-h":!0}),d(ye)!=="svelte-1yge1oh"&&(ye.textContent=mn),ei=l(e),ve=o(e,"IMG",{src:!0,alt:!0}),ti=l(e),Me=o(e,"P",{"data-svelte-h":!0}),d(Me)!=="svelte-13ggrtv"&&(Me.textContent=gn),ii=l(e),be=o(e,"UL",{"data-svelte-h":!0}),d(be)!=="svelte-1a305az"&&(be.innerHTML=fn),ni=l(e),Ce=o(e,"IMG",{src:!0,alt:!0}),ai=l(e),_e=o(e,"P",{"data-svelte-h":!0}),d(_e)!=="svelte-176u6kl"&&(_e.textContent=hn),li=l(e),xe=o(e,"UL",{"data-svelte-h":!0}),d(xe)!=="svelte-1dkaf9f"&&(xe.innerHTML=dn),si=l(e),Ue=o(e,"IMG",{src:!0,alt:!0}),ri=l(e),Je=o(e,"P",{"data-svelte-h":!0}),d(Je)!=="svelte-ilfaf"&&(Je.textContent=wn),oi=l(e),Fe=o(e,"UL",{"data-svelte-h":!0}),d(Fe)!=="svelte-99mvik"&&(Fe.innerHTML=Tn),pi=l(e),u(F.$$.fragment,e),mi=l(e),je=o(e,"P",{"data-svelte-h":!0}),d(je)!=="svelte-ttgvgc"&&(je.innerHTML=yn),ui=l(e),u(ke.$$.fragment,e),gi=l(e),Re=o(e,"P",{"data-svelte-h":!0}),d(Re)!=="svelte-1rfoj7z"&&(Re.innerHTML=vn),fi=l(e),Se=o(e,"P",{"data-svelte-h":!0}),d(Se)!=="svelte-1028cbr"&&(Se.textContent=Mn),ci=l(e),We=o(e,"OL",{"data-svelte-h":!0}),d(We)!=="svelte-1irg2q8"&&(We.innerHTML=bn),hi=l(e),u(j.$$.fragment,e),di=l(e),u(ze.$$.fragment,e),$i=l(e),u(Be.$$.fragment,e),wi=l(e),u(Ie.$$.fragment,e),Ti=l(e),u(Ze.$$.fragment,e),yi=l(e),u(Ge.$$.fragment,e),vi=l(e),u(He.$$.fragment,e),Mi=l(e),u(Le.$$.fragment,e),bi=l(e),u(Ee.$$.fragment,e),Ci=l(e),u(qe.$$.fragment,e),_i=l(e),u(Xe.$$.fragment,e),xi=l(e),u(Qe.$$.fragment,e),Ui=l(e),u(Pe.$$.fragment,e),Ji=l(e),Ve=o(e,"P",{"data-svelte-h":!0}),d(Ve)!=="svelte-11s8azl"&&(Ve.textContent=Cn),Fi=l(e),Ne=o(e,"OL",{"data-svelte-h":!0}),d(Ne)!=="svelte-eabkx7"&&(Ne.innerHTML=_n),ji=l(e),u(Ye.$$.fragment,e),ki=l(e),Ae=o(e,"UL",{"data-svelte-h":!0}),d(Ae)!=="svelte-1qwbi4x"&&(Ae.innerHTML=xn),Ri=l(e),u(De.$$.fragment,e),Si=l(e),tt=o(e,"P",{}),zi(tt).forEach(i),this.h()},h(){y(p,"name","hf:doc:metadata"),y(p,"content",Kn),it(b.src,Ni="https://huggingface.co/datasets/HuggingFaceTB/smoltalk/embed/viewer/all/train?row=0")||y(b,"src",Ni),y(b,"frameborder","0"),y(b,"width","100%"),y(b,"height","360px"),it(ue.src,ln="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/nlp_course_sft_loss_graphic.png")||y(ue,"src",ln),y(ue,"alt","SFTTrainer Training"),it(ve.src,un="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/sft_loss_1.png")||y(ve,"src",un),y(ve,"alt","SFTTrainer Training"),it(Ce.src,cn="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/sft_loss_2.png")||y(Ce,"src",cn),y(Ce,"alt","SFTTrainer Training"),it(Ue.src,$n="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/sft_loss_3.png")||y(Ue,"src",$n),y(Ue,"alt","SFTTrainer Training")},m(e,t){Hn(document.head,p),n(e,s,t),n(e,w,t),n(e,v,t),g(M,e,t),n(e,at,t),g(k,e,t),n(e,lt,t),g(R,e,t),n(e,st,t),n(e,S,t),n(e,rt,t),n(e,W,t),n(e,ot,t),g(z,e,t),n(e,pt,t),n(e,B,t),n(e,mt,t),g(C,e,t),n(e,ut,t),n(e,I,t),n(e,gt,t),g(Z,e,t),n(e,ft,t),n(e,G,t),n(e,ct,t),n(e,H,t),n(e,ht,t),g(L,e,t),n(e,dt,t),n(e,E,t),n(e,$t,t),n(e,q,t),n(e,wt,t),g(_,e,t),n(e,Tt,t),g(X,e,t),n(e,yt,t),n(e,Q,t),n(e,vt,t),n(e,P,t),n(e,Mt,t),n(e,V,t),n(e,bt,t),n(e,b,t),n(e,Ct,t),g(N,e,t),n(e,_t,t),n(e,Y,t),n(e,xt,t),n(e,A,t),n(e,Ut,t),n(e,D,t),n(e,Jt,t),g(x,e,t),n(e,Ft,t),g(K,e,t),n(e,jt,t),n(e,O,t),n(e,kt,t),g(ee,e,t),n(e,Rt,t),g(U,e,t),n(e,St,t),g(te,e,t),n(e,Wt,t),n(e,ie,t),n(e,zt,t),g(ne,e,t),n(e,Bt,t),n(e,ae,t),n(e,It,t),g(le,e,t),n(e,Zt,t),g(se,e,t),n(e,Gt,t),n(e,re,t),n(e,Ht,t),g(oe,e,t),n(e,Lt,t),n(e,pe,t),n(e,Et,t),n(e,me,t),n(e,qt,t),n(e,ue,t),n(e,Xt,t),g(ge,e,t),n(e,Qt,t),n(e,fe,t),n(e,Pt,t),n(e,ce,t),n(e,Vt,t),g(J,e,t),n(e,Nt,t),g(he,e,t),n(e,Yt,t),n(e,de,t),n(e,At,t),g($e,e,t),n(e,Dt,t),n(e,we,t),n(e,Kt,t),g(Te,e,t),n(e,Ot,t),n(e,ye,t),n(e,ei,t),n(e,ve,t),n(e,ti,t),n(e,Me,t),n(e,ii,t),n(e,be,t),n(e,ni,t),n(e,Ce,t),n(e,ai,t),n(e,_e,t),n(e,li,t),n(e,xe,t),n(e,si,t),n(e,Ue,t),n(e,ri,t),n(e,Je,t),n(e,oi,t),n(e,Fe,t),n(e,pi,t),g(F,e,t),n(e,mi,t),n(e,je,t),n(e,ui,t),g(ke,e,t),n(e,gi,t),n(e,Re,t),n(e,fi,t),n(e,Se,t),n(e,ci,t),n(e,We,t),n(e,hi,t),g(j,e,t),n(e,di,t),g(ze,e,t),n(e,$i,t),g(Be,e,t),n(e,wi,t),g(Ie,e,t),n(e,Ti,t),g(Ze,e,t),n(e,yi,t),g(Ge,e,t),n(e,vi,t),g(He,e,t),n(e,Mi,t),g(Le,e,t),n(e,bi,t),g(Ee,e,t),n(e,Ci,t),g(qe,e,t),n(e,_i,t),g(Xe,e,t),n(e,xi,t),g(Qe,e,t),n(e,Ui,t),g(Pe,e,t),n(e,Ji,t),n(e,Ve,t),n(e,Fi,t),n(e,Ne,t),n(e,ji,t),g(Ye,e,t),n(e,ki,t),n(e,Ae,t),n(e,Ri,t),g(De,e,t),n(e,Si,t),n(e,tt,t),Wi=!0},p(e,[t]){const Un={};t&2&&(Un.$$scope={dirty:t,ctx:e}),C.$set(Un);const Jn={};t&2&&(Jn.$$scope={dirty:t,ctx:e}),_.$set(Jn);const Fn={};t&2&&(Fn.$$scope={dirty:t,ctx:e}),x.$set(Fn);const jn={};t&2&&(jn.$$scope={dirty:t,ctx:e}),U.$set(jn);const kn={};t&2&&(kn.$$scope={dirty:t,ctx:e}),J.$set(kn);const Rn={};t&2&&(Rn.$$scope={dirty:t,ctx:e}),F.$set(Rn);const Sn={};t&2&&(Sn.$$scope={dirty:t,ctx:e}),j.$set(Sn)},i(e){Wi||(f(M.$$.fragment,e),f(k.$$.fragment,e),f(R.$$.fragment,e),f(z.$$.fragment,e),f(C.$$.fragment,e),f(Z.$$.fragment,e),f(L.$$.fragment,e),f(_.$$.fragment,e),f(X.$$.fragment,e),f(N.$$.fragment,e),f(x.$$.fragment,e),f(K.$$.fragment,e),f(ee.$$.fragment,e),f(U.$$.fragment,e),f(te.$$.fragment,e),f(ne.$$.fragment,e),f(le.$$.fragment,e),f(se.$$.fragment,e),f(oe.$$.fragment,e),f(ge.$$.fragment,e),f(J.$$.fragment,e),f(he.$$.fragment,e),f($e.$$.fragment,e),f(Te.$$.fragment,e),f(F.$$.fragment,e),f(ke.$$.fragment,e),f(j.$$.fragment,e),f(ze.$$.fragment,e),f(Be.$$.fragment,e),f(Ie.$$.fragment,e),f(Ze.$$.fragment,e),f(Ge.$$.fragment,e),f(He.$$.fragment,e),f(Le.$$.fragment,e),f(Ee.$$.fragment,e),f(qe.$$.fragment,e),f(Xe.$$.fragment,e),f(Qe.$$.fragment,e),f(Pe.$$.fragment,e),f(Ye.$$.fragment,e),f(De.$$.fragment,e),Wi=!0)},o(e){c(M.$$.fragment,e),c(k.$$.fragment,e),c(R.$$.fragment,e),c(z.$$.fragment,e),c(C.$$.fragment,e),c(Z.$$.fragment,e),c(L.$$.fragment,e),c(_.$$.fragment,e),c(X.$$.fragment,e),c(N.$$.fragment,e),c(x.$$.fragment,e),c(K.$$.fragment,e),c(ee.$$.fragment,e),c(U.$$.fragment,e),c(te.$$.fragment,e),c(ne.$$.fragment,e),c(le.$$.fragment,e),c(se.$$.fragment,e),c(oe.$$.fragment,e),c(ge.$$.fragment,e),c(J.$$.fragment,e),c(he.$$.fragment,e),c($e.$$.fragment,e),c(Te.$$.fragment,e),c(F.$$.fragment,e),c(ke.$$.fragment,e),c(j.$$.fragment,e),c(ze.$$.fragment,e),c(Be.$$.fragment,e),c(Ie.$$.fragment,e),c(Ze.$$.fragment,e),c(Ge.$$.fragment,e),c(He.$$.fragment,e),c(Le.$$.fragment,e),c(Ee.$$.fragment,e),c(qe.$$.fragment,e),c(Xe.$$.fragment,e),c(Qe.$$.fragment,e),c(Pe.$$.fragment,e),c(Ye.$$.fragment,e),c(De.$$.fragment,e),Wi=!1},d(e){e&&(i(s),i(w),i(v),i(at),i(lt),i(st),i(S),i(rt),i(W),i(ot),i(pt),i(B),i(mt),i(ut),i(I),i(gt),i(ft),i(G),i(ct),i(H),i(ht),i(dt),i(E),i($t),i(q),i(wt),i(Tt),i(yt),i(Q),i(vt),i(P),i(Mt),i(V),i(bt),i(b),i(Ct),i(_t),i(Y),i(xt),i(A),i(Ut),i(D),i(Jt),i(Ft),i(jt),i(O),i(kt),i(Rt),i(St),i(Wt),i(ie),i(zt),i(Bt),i(ae),i(It),i(Zt),i(Gt),i(re),i(Ht),i(Lt),i(pe),i(Et),i(me),i(qt),i(ue),i(Xt),i(Qt),i(fe),i(Pt),i(ce),i(Vt),i(Nt),i(Yt),i(de),i(At),i(Dt),i(we),i(Kt),i(Ot),i(ye),i(ei),i(ve),i(ti),i(Me),i(ii),i(be),i(ni),i(Ce),i(ai),i(_e),i(li),i(xe),i(si),i(Ue),i(ri),i(Je),i(oi),i(Fe),i(pi),i(mi),i(je),i(ui),i(gi),i(Re),i(fi),i(Se),i(ci),i(We),i(hi),i(di),i($i),i(wi),i(Ti),i(yi),i(vi),i(Mi),i(bi),i(Ci),i(_i),i(xi),i(Ui),i(Ji),i(Ve),i(Fi),i(Ne),i(ji),i(ki),i(Ae),i(Ri),i(Si),i(tt)),i(p),h(M,e),h(k,e),h(R,e),h(z,e),h(C,e),h(Z,e),h(L,e),h(_,e),h(X,e),h(N,e),h(x,e),h(K,e),h(ee,e),h(U,e),h(te,e),h(ne,e),h(le,e),h(se,e),h(oe,e),h(ge,e),h(J,e),h(he,e),h($e,e),h(Te,e),h(F,e),h(ke,e),h(j,e),h(ze,e),h(Be,e),h(Ie,e),h(Ze,e),h(Ge,e),h(He,e),h(Le,e),h(Ee,e),h(qe,e),h(Xe,e),h(Qe,e),h(Pe,e),h(Ye,e),h(De,e)}}}const Kn='{"title":"Supervised Fine-Tuning","local":"supervised-fine-tuning","sections":[{"title":"When to Use SFT","local":"when-to-use-sft","sections":[{"title":"Template Control","local":"template-control","sections":[],"depth":3},{"title":"Domain Adaptation","local":"domain-adaptation","sections":[],"depth":3}],"depth":2},{"title":"Dataset Preparation","local":"dataset-preparation","sections":[],"depth":2},{"title":"Training Configuration","local":"training-configuration","sections":[],"depth":2},{"title":"Implementation with TRL","local":"implementation-with-trl","sections":[],"depth":2},{"title":"Packing the Dataset","local":"packing-the-dataset","sections":[],"depth":2},{"title":"Monitoring Training Progress","local":"monitoring-training-progress","sections":[{"title":"Understanding Loss Patterns","local":"understanding-loss-patterns","sections":[],"depth":3},{"title":"Metrics to Monitor","local":"metrics-to-monitor","sections":[],"depth":3},{"title":"The Path to Convergence","local":"the-path-to-convergence","sections":[],"depth":3},{"title":"Monitoring Training Progress","local":"monitoring-training-progress","sections":[],"depth":3},{"title":"Warning Signs to Watch For","local":"warning-signs-to-watch-for","sections":[],"depth":3}],"depth":2},{"title":"Evaluation after SFT","local":"evaluation-after-sft","sections":[],"depth":2},{"title":"Quiz","local":"quiz","sections":[{"title":"1. What parameters control the training duration in SFT?","local":"1-what-parameters-control-the-training-duration-in-sft","sections":[],"depth":3},{"title":"2. Which pattern in the loss curves indicates potential overfitting?","local":"2-which-pattern-in-the-loss-curves-indicates-potential-overfitting","sections":[],"depth":3},{"title":"3. What is gradient_accumulation_steps used for?","local":"3-what-is-gradientaccumulationsteps-used-for","sections":[],"depth":3},{"title":"4. What should you monitor during SFT training?","local":"4-what-should-you-monitor-during-sft-training","sections":[],"depth":3},{"title":"5. What indicates healthy convergence during training?","local":"5-what-indicates-healthy-convergence-during-training","sections":[],"depth":3}],"depth":2},{"title":"💐 Nice work!","local":"-nice-work","sections":[],"depth":2},{"title":"Additional Resources","local":"additional-resources","sections":[],"depth":2}],"depth":1}';function On(T){return zn(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ra extends In{constructor(p){super(),Zn(this,p,On,Dn,Wn,{})}}export{ra as component};
