import{s as Rn,f as tt,o as Wn,n as Bn}from"../chunks/scheduler.37c15a92.js";import{S as Sn,i as zn,g as r,s as a,r as m,A as In,h as o,f as i,c as l,j as Wi,u,x as d,k as y,y as Zn,a as n,v as g,d as f,t as c,w as h,m as Ke,n as Oe}from"../chunks/index.7cb9c9b8.js";import{T as De}from"../chunks/Tip.d10b3fc9.js";import{C as Bi}from"../chunks/CodeBlock.abae2786.js";import{C as Gn}from"../chunks/CourseFloatingBanner.df82c153.js";import{Q as it}from"../chunks/Question.7e41e492.js";import{H as $,E as Hn}from"../chunks/getInferenceSnippets.f9350a3f.js";function Ln(T){let p;return{c(){p=Ke(`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=Oe(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 En(T){let p,s,w="This evaluation will help determine if SFT is the right approach for your needs.";return{c(){p=Ke(`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=Oe(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 Xn(T){let p;return{c(){p=Ke(`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=Oe(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 qn(T){let p;return{c(){p=Ke(`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=Oe(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 Qn(T){let p;return{c(){p=Ke(`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=Oe(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 Pn(T){let p;return{c(){p=Ke("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=Oe(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 Vn(T){let p;return{c(){p=Ke(`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=Oe(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 Nn(T){let p,s,w,v,M,nt,k,at,R,Si="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.",lt,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.',st,B,rt,S,Ii="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.",ot,C,pt,z,Zi="If you determine that SFT is necessary, the decision to proceed depends on two primary factors:",mt,I,ut,Z,Gi="SFT allows precise control over the model’s output structure. This is particularly valuable when you need the model to:",gt,G,Hi="<li>Generate responses in a specific chat template format</li> <li>Follow strict output schemas</li> <li>Maintain consistent styling across responses</li>",ft,H,ct,L,Li="When working in specialized domains, SFT helps align the model with domain-specific requirements by:",ht,E,Ei="<li>Teaching domain terminology and concepts</li> <li>Enforcing professional standards</li> <li>Handling technical queries appropriately</li> <li>Following industry-specific guidelines</li>",dt,_,$t,X,wt,q,Xi="The supervised fine-tuning process requires a task-specific dataset structured with input-output pairs. Each pair should consist of:",Tt,Q,qi="<li>An input prompt</li> <li>The expected model response</li> <li>Any additional context or metadata</li>",yt,P,Qi="The quality of your training data is crucial for successful fine-tuning. Let’s look at how to prepare and validate your dataset:",vt,b,Pi,Mt,V,bt,N,Vi="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:",Ct,A,Ni="The SFTTrainer configuration requires consideration of several parameters that control the training process. Let’s explore each parameter and their purpose:",_t,Y,Ai="<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>",xt,x,Ut,D,Jt,K,Yi="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:",Ft,O,jt,U,kt,ee,Rt,te,Di="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:",Wt,ie,Bt,ne,Ki="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:",St,ae,zt,le,It,se,Oi="Effective monitoring is crucial for successful fine-tuning. Let’s explore what to watch for during training:",Zt,re,Gt,oe,en="Training loss typically follows three distinct phases:",Ht,pe,tn="<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>",Lt,me,nn,Et,ue,Xt,ge,an="Effective monitoring involves tracking quantitative metrics, and evaluating qualitative metrics. Available metrics are:",qt,fe,ln="<li>Training loss</li> <li>Validation loss</li> <li>Learning rate progression</li> <li>Gradient norms</li>",Qt,J,Pt,ce,Vt,he,sn=`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.`,Nt,de,At,$e,rn="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.",Yt,we,Dt,Te,on="Several patterns in the loss curves can indicate potential issues. Below we illustrate common warning signs and solutions that we can consider.",Kt,ye,pn,Ot,ve,mn="If the validation loss decreases at a significantly slower rate than training loss, your model is likely overfitting to the training data. Consider:",ei,Me,un="<li>Reducing the training steps</li> <li>Increasing the dataset size</li> <li>Validating dataset quality and diversity</li>",ti,be,gn,ii,Ce,fn="If the loss doesn’t show significant improvement, the model might be:",ni,_e,cn="<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>",ai,xe,hn,li,Ue,dn="Extremely low loss values could suggest memorization rather than learning. This is particularly concerning if:",si,Je,$n="<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>",ri,F,oi,Fe,wn='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>.',pi,je,mi,ke,Tn='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.',ui,Re,yn="After completing SFT, consider these follow-up actions:",gi,We,vn="<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>",fi,j,ci,Be,hi,Se,di,ze,$i,Ie,wi,Ze,Ti,Ge,yi,He,vi,Le,Mi,Ee,bi,Xe,Ci,qe,_i,Qe,xi,Pe,Mn="You’ve learned how to fine-tune models using SFT! To continue your learning:",Ui,Ve,bn="<li>Try the notebook with different parameters</li> <li>Experiment with other datasets</li> <li>Contribute improvements to the course material</li>",Ji,Ne,Fi,Ae,Cn='<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>',ji,Ye,ki,et,Ri;return M=new Gn({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 $({props:{title:"Supervised Fine-Tuning",local:"supervised-fine-tuning",headingTag:"h1"}}),B=new $({props:{title:"When to Use SFT",local:"when-to-use-sft",headingTag:"h2"}}),C=new De({props:{$$slots:{default:[Ln]},$$scope:{ctx:T}}}),I=new $({props:{title:"Template Control",local:"template-control",headingTag:"h3"}}),H=new $({props:{title:"Domain Adaptation",local:"domain-adaptation",headingTag:"h3"}}),_=new De({props:{$$slots:{default:[En]},$$scope:{ctx:T}}}),X=new $({props:{title:"Dataset Preparation",local:"dataset-preparation",headingTag:"h2"}}),V=new $({props:{title:"Training Configuration",local:"training-configuration",headingTag:"h2"}}),x=new De({props:{$$slots:{default:[Xn]},$$scope:{ctx:T}}}),D=new $({props:{title:"Implementation with TRL",local:"implementation-with-trl",headingTag:"h2"}}),O=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 De({props:{$$slots:{default:[qn]},$$scope:{ctx:T}}}),ee=new $({props:{title:"Packing the Dataset",local:"packing-the-dataset",headingTag:"h2"}}),ie=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}}),ae=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}}),le=new $({props:{title:"Monitoring Training Progress",local:"monitoring-training-progress",headingTag:"h2"}}),re=new $({props:{title:"Understanding Loss Patterns",local:"understanding-loss-patterns",headingTag:"h3"}}),ue=new $({props:{title:"Metrics to Monitor",local:"metrics-to-monitor",headingTag:"h3"}}),J=new De({props:{warning:!0,$$slots:{default:[Qn]},$$scope:{ctx:T}}}),ce=new $({props:{title:"The Path to Convergence",local:"the-path-to-convergence",headingTag:"h3"}}),de=new $({props:{title:"Monitoring Training Progress",local:"monitoring-training-progress",headingTag:"h3"}}),we=new $({props:{title:"Warning Signs to Watch For",local:"warning-signs-to-watch-for",headingTag:"h3"}}),F=new De({props:{warning:!0,$$slots:{default:[Pn]},$$scope:{ctx:T}}}),je=new $({props:{title:"Evaluation after SFT",local:"evaluation-after-sft",headingTag:"h2"}}),j=new De({props:{$$slots:{default:[Vn]},$$scope:{ctx:T}}}),Be=new $({props:{title:"Quiz",local:"quiz",headingTag:"h2"}}),Se=new $({props:{title:"1. What parameters control the training duration in SFT?",local:"1-what-parameters-control-the-training-duration-in-sft",headingTag:"h3"}}),ze=new it({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."}]}}),Ie=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"}}),Ze=new it({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."}]}}),Ge=new $({props:{title:"3. What is gradient_accumulation_steps used for?",local:"3-what-is-gradientaccumulationsteps-used-for",headingTag:"h3"}}),He=new it({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."}]}}),Le=new $({props:{title:"4. What should you monitor during SFT training?",local:"4-what-should-you-monitor-during-sft-training",headingTag:"h3"}}),Ee=new it({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 it({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."}]}}),Qe=new $({props:{title:"💐 Nice work!",local:"-nice-work",headingTag:"h2"}}),Ne=new $({props:{title:"Additional Resources",local:"additional-resources",headingTag:"h2"}}),Ye=new Hn({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),nt=a(),m(k.$$.fragment),at=a(),R=r("p"),R.textContent=Si,lt=a(),W=r("p"),W.innerHTML=zi,st=a(),m(B.$$.fragment),rt=a(),S=r("p"),S.textContent=Ii,ot=a(),m(C.$$.fragment),pt=a(),z=r("p"),z.textContent=Zi,mt=a(),m(I.$$.fragment),ut=a(),Z=r("p"),Z.textContent=Gi,gt=a(),G=r("ol"),G.innerHTML=Hi,ft=a(),m(H.$$.fragment),ct=a(),L=r("p"),L.textContent=Li,ht=a(),E=r("ol"),E.innerHTML=Ei,dt=a(),m(_.$$.fragment),$t=a(),m(X.$$.fragment),wt=a(),q=r("p"),q.textContent=Xi,Tt=a(),Q=r("ol"),Q.innerHTML=qi,yt=a(),P=r("p"),P.textContent=Qi,vt=a(),b=r("iframe"),Mt=a(),m(V.$$.fragment),bt=a(),N=r("p"),N.textContent=Vi,Ct=a(),A=r("p"),A.textContent=Ni,_t=a(),Y=r("ol"),Y.innerHTML=Ai,xt=a(),m(x.$$.fragment),Ut=a(),m(D.$$.fragment),Jt=a(),K=r("p"),K.innerHTML=Yi,Ft=a(),m(O.$$.fragment),jt=a(),m(U.$$.fragment),kt=a(),m(ee.$$.fragment),Rt=a(),te=r("p"),te.innerHTML=Di,Wt=a(),m(ie.$$.fragment),Bt=a(),ne=r("p"),ne.textContent=Ki,St=a(),m(ae.$$.fragment),zt=a(),m(le.$$.fragment),It=a(),se=r("p"),se.textContent=Oi,Zt=a(),m(re.$$.fragment),Gt=a(),oe=r("p"),oe.textContent=en,Ht=a(),pe=r("ol"),pe.innerHTML=tn,Lt=a(),me=r("img"),Et=a(),m(ue.$$.fragment),Xt=a(),ge=r("p"),ge.textContent=an,qt=a(),fe=r("ul"),fe.innerHTML=ln,Qt=a(),m(J.$$.fragment),Pt=a(),m(ce.$$.fragment),Vt=a(),he=r("p"),he.textContent=sn,Nt=a(),m(de.$$.fragment),At=a(),$e=r("p"),$e.textContent=rn,Yt=a(),m(we.$$.fragment),Dt=a(),Te=r("p"),Te.textContent=on,Kt=a(),ye=r("img"),Ot=a(),ve=r("p"),ve.textContent=mn,ei=a(),Me=r("ul"),Me.innerHTML=un,ti=a(),be=r("img"),ii=a(),Ce=r("p"),Ce.textContent=fn,ni=a(),_e=r("ul"),_e.innerHTML=cn,ai=a(),xe=r("img"),li=a(),Ue=r("p"),Ue.textContent=dn,si=a(),Je=r("ul"),Je.innerHTML=$n,ri=a(),m(F.$$.fragment),oi=a(),Fe=r("p"),Fe.innerHTML=wn,pi=a(),m(je.$$.fragment),mi=a(),ke=r("p"),ke.innerHTML=Tn,ui=a(),Re=r("p"),Re.textContent=yn,gi=a(),We=r("ol"),We.innerHTML=vn,fi=a(),m(j.$$.fragment),ci=a(),m(Be.$$.fragment),hi=a(),m(Se.$$.fragment),di=a(),m(ze.$$.fragment),$i=a(),m(Ie.$$.fragment),wi=a(),m(Ze.$$.fragment),Ti=a(),m(Ge.$$.fragment),yi=a(),m(He.$$.fragment),vi=a(),m(Le.$$.fragment),Mi=a(),m(Ee.$$.fragment),bi=a(),m(Xe.$$.fragment),Ci=a(),m(qe.$$.fragment),_i=a(),m(Qe.$$.fragment),xi=a(),Pe=r("p"),Pe.textContent=Mn,Ui=a(),Ve=r("ol"),Ve.innerHTML=bn,Ji=a(),m(Ne.$$.fragment),Fi=a(),Ae=r("ul"),Ae.innerHTML=Cn,ji=a(),m(Ye.$$.fragment),ki=a(),et=r("p"),this.h()},l(e){const t=In("svelte-u9bgzb",document.head);p=o(t,"META",{name:!0,content:!0}),t.forEach(i),s=l(e),w=o(e,"P",{}),Wi(w).forEach(i),v=l(e),u(M.$$.fragment,e),nt=l(e),u(k.$$.fragment,e),at=l(e),R=o(e,"P",{"data-svelte-h":!0}),d(R)!=="svelte-1r3e85q"&&(R.textContent=Si),lt=l(e),W=o(e,"P",{"data-svelte-h":!0}),d(W)!=="svelte-1lbymgt"&&(W.innerHTML=zi),st=l(e),u(B.$$.fragment,e),rt=l(e),S=o(e,"P",{"data-svelte-h":!0}),d(S)!=="svelte-bzr0f8"&&(S.textContent=Ii),ot=l(e),u(C.$$.fragment,e),pt=l(e),z=o(e,"P",{"data-svelte-h":!0}),d(z)!=="svelte-1vu1858"&&(z.textContent=Zi),mt=l(e),u(I.$$.fragment,e),ut=l(e),Z=o(e,"P",{"data-svelte-h":!0}),d(Z)!=="svelte-vqqipn"&&(Z.textContent=Gi),gt=l(e),G=o(e,"OL",{"data-svelte-h":!0}),d(G)!=="svelte-f2jeai"&&(G.innerHTML=Hi),ft=l(e),u(H.$$.fragment,e),ct=l(e),L=o(e,"P",{"data-svelte-h":!0}),d(L)!=="svelte-63mafi"&&(L.textContent=Li),ht=l(e),E=o(e,"OL",{"data-svelte-h":!0}),d(E)!=="svelte-14ez77z"&&(E.innerHTML=Ei),dt=l(e),u(_.$$.fragment,e),$t=l(e),u(X.$$.fragment,e),wt=l(e),q=o(e,"P",{"data-svelte-h":!0}),d(q)!=="svelte-1gnb02p"&&(q.textContent=Xi),Tt=l(e),Q=o(e,"OL",{"data-svelte-h":!0}),d(Q)!=="svelte-1vwaxbl"&&(Q.innerHTML=qi),yt=l(e),P=o(e,"P",{"data-svelte-h":!0}),d(P)!=="svelte-irg7th"&&(P.textContent=Qi),vt=l(e),b=o(e,"IFRAME",{src:!0,frameborder:!0,width:!0,height:!0}),Wi(b).forEach(i),Mt=l(e),u(V.$$.fragment,e),bt=l(e),N=o(e,"P",{"data-svelte-h":!0}),d(N)!=="svelte-ioywgh"&&(N.textContent=Vi),Ct=l(e),A=o(e,"P",{"data-svelte-h":!0}),d(A)!=="svelte-14sqfj"&&(A.textContent=Ni),_t=l(e),Y=o(e,"OL",{"data-svelte-h":!0}),d(Y)!=="svelte-6ztbbs"&&(Y.innerHTML=Ai),xt=l(e),u(x.$$.fragment,e),Ut=l(e),u(D.$$.fragment,e),Jt=l(e),K=o(e,"P",{"data-svelte-h":!0}),d(K)!=="svelte-grvvks"&&(K.innerHTML=Yi),Ft=l(e),u(O.$$.fragment,e),jt=l(e),u(U.$$.fragment,e),kt=l(e),u(ee.$$.fragment,e),Rt=l(e),te=o(e,"P",{"data-svelte-h":!0}),d(te)!=="svelte-1nxebfc"&&(te.innerHTML=Di),Wt=l(e),u(ie.$$.fragment,e),Bt=l(e),ne=o(e,"P",{"data-svelte-h":!0}),d(ne)!=="svelte-c7t1n6"&&(ne.textContent=Ki),St=l(e),u(ae.$$.fragment,e),zt=l(e),u(le.$$.fragment,e),It=l(e),se=o(e,"P",{"data-svelte-h":!0}),d(se)!=="svelte-muo025"&&(se.textContent=Oi),Zt=l(e),u(re.$$.fragment,e),Gt=l(e),oe=o(e,"P",{"data-svelte-h":!0}),d(oe)!=="svelte-1kxz6c2"&&(oe.textContent=en),Ht=l(e),pe=o(e,"OL",{"data-svelte-h":!0}),d(pe)!=="svelte-12kgh6p"&&(pe.innerHTML=tn),Lt=l(e),me=o(e,"IMG",{src:!0,alt:!0}),Et=l(e),u(ue.$$.fragment,e),Xt=l(e),ge=o(e,"P",{"data-svelte-h":!0}),d(ge)!=="svelte-1y9ggj5"&&(ge.textContent=an),qt=l(e),fe=o(e,"UL",{"data-svelte-h":!0}),d(fe)!=="svelte-acv7jp"&&(fe.innerHTML=ln),Qt=l(e),u(J.$$.fragment,e),Pt=l(e),u(ce.$$.fragment,e),Vt=l(e),he=o(e,"P",{"data-svelte-h":!0}),d(he)!=="svelte-ie5i5"&&(he.textContent=sn),Nt=l(e),u(de.$$.fragment,e),At=l(e),$e=o(e,"P",{"data-svelte-h":!0}),d($e)!=="svelte-1s6faap"&&($e.textContent=rn),Yt=l(e),u(we.$$.fragment,e),Dt=l(e),Te=o(e,"P",{"data-svelte-h":!0}),d(Te)!=="svelte-1yge1oh"&&(Te.textContent=on),Kt=l(e),ye=o(e,"IMG",{src:!0,alt:!0}),Ot=l(e),ve=o(e,"P",{"data-svelte-h":!0}),d(ve)!=="svelte-13ggrtv"&&(ve.textContent=mn),ei=l(e),Me=o(e,"UL",{"data-svelte-h":!0}),d(Me)!=="svelte-1a305az"&&(Me.innerHTML=un),ti=l(e),be=o(e,"IMG",{src:!0,alt:!0}),ii=l(e),Ce=o(e,"P",{"data-svelte-h":!0}),d(Ce)!=="svelte-176u6kl"&&(Ce.textContent=fn),ni=l(e),_e=o(e,"UL",{"data-svelte-h":!0}),d(_e)!=="svelte-1dkaf9f"&&(_e.innerHTML=cn),ai=l(e),xe=o(e,"IMG",{src:!0,alt:!0}),li=l(e),Ue=o(e,"P",{"data-svelte-h":!0}),d(Ue)!=="svelte-ilfaf"&&(Ue.textContent=dn),si=l(e),Je=o(e,"UL",{"data-svelte-h":!0}),d(Je)!=="svelte-99mvik"&&(Je.innerHTML=$n),ri=l(e),u(F.$$.fragment,e),oi=l(e),Fe=o(e,"P",{"data-svelte-h":!0}),d(Fe)!=="svelte-ttgvgc"&&(Fe.innerHTML=wn),pi=l(e),u(je.$$.fragment,e),mi=l(e),ke=o(e,"P",{"data-svelte-h":!0}),d(ke)!=="svelte-1rfoj7z"&&(ke.innerHTML=Tn),ui=l(e),Re=o(e,"P",{"data-svelte-h":!0}),d(Re)!=="svelte-1028cbr"&&(Re.textContent=yn),gi=l(e),We=o(e,"OL",{"data-svelte-h":!0}),d(We)!=="svelte-1irg2q8"&&(We.innerHTML=vn),fi=l(e),u(j.$$.fragment,e),ci=l(e),u(Be.$$.fragment,e),hi=l(e),u(Se.$$.fragment,e),di=l(e),u(ze.$$.fragment,e),$i=l(e),u(Ie.$$.fragment,e),wi=l(e),u(Ze.$$.fragment,e),Ti=l(e),u(Ge.$$.fragment,e),yi=l(e),u(He.$$.fragment,e),vi=l(e),u(Le.$$.fragment,e),Mi=l(e),u(Ee.$$.fragment,e),bi=l(e),u(Xe.$$.fragment,e),Ci=l(e),u(qe.$$.fragment,e),_i=l(e),u(Qe.$$.fragment,e),xi=l(e),Pe=o(e,"P",{"data-svelte-h":!0}),d(Pe)!=="svelte-11s8azl"&&(Pe.textContent=Mn),Ui=l(e),Ve=o(e,"OL",{"data-svelte-h":!0}),d(Ve)!=="svelte-eabkx7"&&(Ve.innerHTML=bn),Ji=l(e),u(Ne.$$.fragment,e),Fi=l(e),Ae=o(e,"UL",{"data-svelte-h":!0}),d(Ae)!=="svelte-1qwbi4x"&&(Ae.innerHTML=Cn),ji=l(e),u(Ye.$$.fragment,e),ki=l(e),et=o(e,"P",{}),Wi(et).forEach(i),this.h()},h(){y(p,"name","hf:doc:metadata"),y(p,"content",An),tt(b.src,Pi="https://huggingface.co/datasets/HuggingFaceTB/smoltalk/embed/viewer/all/train?row=0")||y(b,"src",Pi),y(b,"frameborder","0"),y(b,"width","100%"),y(b,"height","360px"),tt(me.src,nn="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/nlp_course_sft_loss_graphic.png")||y(me,"src",nn),y(me,"alt","SFTTrainer Training"),tt(ye.src,pn="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/sft_loss_1.png")||y(ye,"src",pn),y(ye,"alt","SFTTrainer Training"),tt(be.src,gn="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/sft_loss_2.png")||y(be,"src",gn),y(be,"alt","SFTTrainer Training"),tt(xe.src,hn="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/sft_loss_3.png")||y(xe,"src",hn),y(xe,"alt","SFTTrainer Training")},m(e,t){Zn(document.head,p),n(e,s,t),n(e,w,t),n(e,v,t),g(M,e,t),n(e,nt,t),g(k,e,t),n(e,at,t),n(e,R,t),n(e,lt,t),n(e,W,t),n(e,st,t),g(B,e,t),n(e,rt,t),n(e,S,t),n(e,ot,t),g(C,e,t),n(e,pt,t),n(e,z,t),n(e,mt,t),g(I,e,t),n(e,ut,t),n(e,Z,t),n(e,gt,t),n(e,G,t),n(e,ft,t),g(H,e,t),n(e,ct,t),n(e,L,t),n(e,ht,t),n(e,E,t),n(e,dt,t),g(_,e,t),n(e,$t,t),g(X,e,t),n(e,wt,t),n(e,q,t),n(e,Tt,t),n(e,Q,t),n(e,yt,t),n(e,P,t),n(e,vt,t),n(e,b,t),n(e,Mt,t),g(V,e,t),n(e,bt,t),n(e,N,t),n(e,Ct,t),n(e,A,t),n(e,_t,t),n(e,Y,t),n(e,xt,t),g(x,e,t),n(e,Ut,t),g(D,e,t),n(e,Jt,t),n(e,K,t),n(e,Ft,t),g(O,e,t),n(e,jt,t),g(U,e,t),n(e,kt,t),g(ee,e,t),n(e,Rt,t),n(e,te,t),n(e,Wt,t),g(ie,e,t),n(e,Bt,t),n(e,ne,t),n(e,St,t),g(ae,e,t),n(e,zt,t),g(le,e,t),n(e,It,t),n(e,se,t),n(e,Zt,t),g(re,e,t),n(e,Gt,t),n(e,oe,t),n(e,Ht,t),n(e,pe,t),n(e,Lt,t),n(e,me,t),n(e,Et,t),g(ue,e,t),n(e,Xt,t),n(e,ge,t),n(e,qt,t),n(e,fe,t),n(e,Qt,t),g(J,e,t),n(e,Pt,t),g(ce,e,t),n(e,Vt,t),n(e,he,t),n(e,Nt,t),g(de,e,t),n(e,At,t),n(e,$e,t),n(e,Yt,t),g(we,e,t),n(e,Dt,t),n(e,Te,t),n(e,Kt,t),n(e,ye,t),n(e,Ot,t),n(e,ve,t),n(e,ei,t),n(e,Me,t),n(e,ti,t),n(e,be,t),n(e,ii,t),n(e,Ce,t),n(e,ni,t),n(e,_e,t),n(e,ai,t),n(e,xe,t),n(e,li,t),n(e,Ue,t),n(e,si,t),n(e,Je,t),n(e,ri,t),g(F,e,t),n(e,oi,t),n(e,Fe,t),n(e,pi,t),g(je,e,t),n(e,mi,t),n(e,ke,t),n(e,ui,t),n(e,Re,t),n(e,gi,t),n(e,We,t),n(e,fi,t),g(j,e,t),n(e,ci,t),g(Be,e,t),n(e,hi,t),g(Se,e,t),n(e,di,t),g(ze,e,t),n(e,$i,t),g(Ie,e,t),n(e,wi,t),g(Ze,e,t),n(e,Ti,t),g(Ge,e,t),n(e,yi,t),g(He,e,t),n(e,vi,t),g(Le,e,t),n(e,Mi,t),g(Ee,e,t),n(e,bi,t),g(Xe,e,t),n(e,Ci,t),g(qe,e,t),n(e,_i,t),g(Qe,e,t),n(e,xi,t),n(e,Pe,t),n(e,Ui,t),n(e,Ve,t),n(e,Ji,t),g(Ne,e,t),n(e,Fi,t),n(e,Ae,t),n(e,ji,t),g(Ye,e,t),n(e,ki,t),n(e,et,t),Ri=!0},p(e,[t]){const _n={};t&2&&(_n.$$scope={dirty:t,ctx:e}),C.$set(_n);const xn={};t&2&&(xn.$$scope={dirty:t,ctx:e}),_.$set(xn);const Un={};t&2&&(Un.$$scope={dirty:t,ctx:e}),x.$set(Un);const Jn={};t&2&&(Jn.$$scope={dirty:t,ctx:e}),U.$set(Jn);const Fn={};t&2&&(Fn.$$scope={dirty:t,ctx:e}),J.$set(Fn);const jn={};t&2&&(jn.$$scope={dirty:t,ctx:e}),F.$set(jn);const kn={};t&2&&(kn.$$scope={dirty:t,ctx:e}),j.$set(kn)},i(e){Ri||(f(M.$$.fragment,e),f(k.$$.fragment,e),f(B.$$.fragment,e),f(C.$$.fragment,e),f(I.$$.fragment,e),f(H.$$.fragment,e),f(_.$$.fragment,e),f(X.$$.fragment,e),f(V.$$.fragment,e),f(x.$$.fragment,e),f(D.$$.fragment,e),f(O.$$.fragment,e),f(U.$$.fragment,e),f(ee.$$.fragment,e),f(ie.$$.fragment,e),f(ae.$$.fragment,e),f(le.$$.fragment,e),f(re.$$.fragment,e),f(ue.$$.fragment,e),f(J.$$.fragment,e),f(ce.$$.fragment,e),f(de.$$.fragment,e),f(we.$$.fragment,e),f(F.$$.fragment,e),f(je.$$.fragment,e),f(j.$$.fragment,e),f(Be.$$.fragment,e),f(Se.$$.fragment,e),f(ze.$$.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(Xe.$$.fragment,e),f(qe.$$.fragment,e),f(Qe.$$.fragment,e),f(Ne.$$.fragment,e),f(Ye.$$.fragment,e),Ri=!0)},o(e){c(M.$$.fragment,e),c(k.$$.fragment,e),c(B.$$.fragment,e),c(C.$$.fragment,e),c(I.$$.fragment,e),c(H.$$.fragment,e),c(_.$$.fragment,e),c(X.$$.fragment,e),c(V.$$.fragment,e),c(x.$$.fragment,e),c(D.$$.fragment,e),c(O.$$.fragment,e),c(U.$$.fragment,e),c(ee.$$.fragment,e),c(ie.$$.fragment,e),c(ae.$$.fragment,e),c(le.$$.fragment,e),c(re.$$.fragment,e),c(ue.$$.fragment,e),c(J.$$.fragment,e),c(ce.$$.fragment,e),c(de.$$.fragment,e),c(we.$$.fragment,e),c(F.$$.fragment,e),c(je.$$.fragment,e),c(j.$$.fragment,e),c(Be.$$.fragment,e),c(Se.$$.fragment,e),c(ze.$$.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(Xe.$$.fragment,e),c(qe.$$.fragment,e),c(Qe.$$.fragment,e),c(Ne.$$.fragment,e),c(Ye.$$.fragment,e),Ri=!1},d(e){e&&(i(s),i(w),i(v),i(nt),i(at),i(R),i(lt),i(W),i(st),i(rt),i(S),i(ot),i(pt),i(z),i(mt),i(ut),i(Z),i(gt),i(G),i(ft),i(ct),i(L),i(ht),i(E),i(dt),i($t),i(wt),i(q),i(Tt),i(Q),i(yt),i(P),i(vt),i(b),i(Mt),i(bt),i(N),i(Ct),i(A),i(_t),i(Y),i(xt),i(Ut),i(Jt),i(K),i(Ft),i(jt),i(kt),i(Rt),i(te),i(Wt),i(Bt),i(ne),i(St),i(zt),i(It),i(se),i(Zt),i(Gt),i(oe),i(Ht),i(pe),i(Lt),i(me),i(Et),i(Xt),i(ge),i(qt),i(fe),i(Qt),i(Pt),i(Vt),i(he),i(Nt),i(At),i($e),i(Yt),i(Dt),i(Te),i(Kt),i(ye),i(Ot),i(ve),i(ei),i(Me),i(ti),i(be),i(ii),i(Ce),i(ni),i(_e),i(ai),i(xe),i(li),i(Ue),i(si),i(Je),i(ri),i(oi),i(Fe),i(pi),i(mi),i(ke),i(ui),i(Re),i(gi),i(We),i(fi),i(ci),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(Pe),i(Ui),i(Ve),i(Ji),i(Fi),i(Ae),i(ji),i(ki),i(et)),i(p),h(M,e),h(k,e),h(B,e),h(C,e),h(I,e),h(H,e),h(_,e),h(X,e),h(V,e),h(x,e),h(D,e),h(O,e),h(U,e),h(ee,e),h(ie,e),h(ae,e),h(le,e),h(re,e),h(ue,e),h(J,e),h(ce,e),h(de,e),h(we,e),h(F,e),h(je,e),h(j,e),h(Be,e),h(Se,e),h(ze,e),h(Ie,e),h(Ze,e),h(Ge,e),h(He,e),h(Le,e),h(Ee,e),h(Xe,e),h(qe,e),h(Qe,e),h(Ne,e),h(Ye,e)}}}const An='{"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 Yn(T){return Wn(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class aa extends Sn{constructor(p){super(),zn(this,p,Yn,Nn,Rn,{})}}export{aa as component};
