import{s as gp,n as Jp,o as _p}from"../chunks/scheduler.78382b47.js";import{S as jp,i as vp,e as o,s as n,c as d,h as kp,a as i,d as a,b as s,f as Rl,g as p,j as r,k as J,l as w,m as l,n as m,t as c,o as h,p as u}from"../chunks/index.6dd35eb6.js";import{C as Up,H as M,E as Zp}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.fed9dfe4.js";import{C as f}from"../chunks/CodeBlock.af1ec02e.js";function Cp(Ni){let b,Wl,$l,Ll,C,Al,B,Gl,$,Si='LoRA is low-rank decomposition method to reduce the number of trainable parameters which speeds up finetuning large models and uses less memory. In PEFT, using LoRA is as easy as setting up a <a href="/docs/peft/main/en/package_reference/lora#peft.LoraConfig">LoraConfig</a> and wrapping it with <a href="/docs/peft/main/en/package_reference/peft_model#peft.get_peft_model">get_peft_model()</a> to create a trainable <a href="/docs/peft/main/en/package_reference/peft_model#peft.PeftModel">PeftModel</a>.',xl,I,Pi="This guide explores in more detail other options and features for using LoRA.",Vl,R,Xl,W,Di='The initialization of LoRA weights is controlled by the parameter <code>init_lora_weights</code> in <a href="/docs/peft/main/en/package_reference/lora#peft.LoraConfig">LoraConfig</a>. By default, PEFT initializes LoRA weights with Kaiming-uniform for weight A and zeros for weight B resulting in an identity transform (same as the reference <a href="https://github.com/microsoft/LoRA" rel="nofollow">implementation</a>).',Fl,L,Ki='It is also possible to pass <code>init_lora_weights=&quot;gaussian&quot;</code>. As the name suggests, this initializes weight A with a Gaussian distribution and zeros for weight B (this is how <a href="https://huggingface.co/docs/diffusers/index" rel="nofollow">Diffusers</a> initializes LoRA weights).',ql,A,El,G,Oi="There is also an option to set <code>init_lora_weights=False</code> which is useful for debugging and testing. This should be the only time you use this option. When choosing this option, the LoRA weights are initialized such that they do <em>not</em> result in an identity transform.",Hl,x,Yl,V,Ql,X,er='<a href="https://huggingface.co/papers/2404.02948" rel="nofollow">PiSSA</a> initializes the LoRA adapter using the principal singular values and singular vectors. This straightforward modification allows PiSSA to converge more rapidly than LoRA and ultimately attain superior performance. Moreover, PiSSA reduces the quantization error compared to QLoRA, leading to further enhancements.',zl,F,tr="Configure the initialization method to “pissa”, which may take several minutes to execute SVD on the pre-trained model:",Nl,q,Sl,E,ar="Alternatively, execute fast SVD, which takes only a few seconds. The number of iterations determines the trade-off between the error and computation time:",Pl,H,Dl,Y,lr='For detailed instruction on using PiSSA, please follow <a href="https://github.com/huggingface/peft/tree/main/examples/pissa_finetuning" rel="nofollow">these instructions</a>.',Kl,Q,Ol,z,nr=`<a href="https://huggingface.co/papers/2406.05223" rel="nofollow">CorDA</a> builds task-aware LoRA adapters from weight decomposition oriented by the context of downstream task to learn (instruction-previewed mode, IPM) or world knowledge to maintain (knowledge-preserved mode, KPM).
The KPM not only achieves better performance than LoRA on fine-tuning tasks, but also mitigates the catastrophic forgetting of pre-trained world knowledge.
When preserving pre-trained knowledge is not a concern,
the IPM is favored because it can further accelerate convergence and enhance the fine-tuning performance.`,en,N,sr="You need to configure the initialization method to “corda”, and specify the mode of IPM or KPM and the dataset to collect covariance matrices.",tn,S,an,P,or='For detailed instruction on using CorDA, please follow <a href="https://github.com/huggingface/peft/tree/main/examples/corda_finetuning" rel="nofollow">these instructions</a>.',ln,D,nn,K,ir='<a href="https://huggingface.co/papers/2406.01775" rel="nofollow">OLoRA</a> utilizes QR decomposition to initialize the LoRA adapters. OLoRA translates the base weights of the model by a factor of their QR decompositions, i.e., it mutates the weights before performing any training on them. This approach significantly improves stability, accelerates convergence speed, and ultimately achieves superior performance.',sn,O,rr="You just need to pass a single additional option to use OLoRA:",on,ee,rn,te,dr='For more advanced usage, please refer to our <a href="https://github.com/huggingface/peft/tree/main/examples/olora_finetuning" rel="nofollow">documentation</a>.',dn,ae,pn,le,pr='<a href="https://huggingface.co/papers/2410.07170" rel="nofollow">EVA</a> performs SVD on the input activations of each layer and uses the right-singular vectors to initialize LoRA weights. It is therefore a data-driven initialization scheme. Furthermore EVA adaptively allocates ranks across layers based on their “explained variance ratio” - a metric derived from the SVD analysis.',mn,ne,mr='You can use EVA by setting <code>init_lora_weights=&quot;eva&quot;</code> and defining <a href="/docs/peft/main/en/package_reference/lora#peft.EvaConfig">EvaConfig</a> in <a href="/docs/peft/main/en/package_reference/lora#peft.LoraConfig">LoraConfig</a>:',cn,se,hn,oe,cr="The parameter <code>rho</code> (≥ 1.0) determines how much redistribution is allowed. When <code>rho=1.0</code> and <code>r=16</code>, LoRA adapters are limited to exactly 16 ranks, preventing any redistribution from occurring. A recommended value for EVA with redistribution is 2.0, meaning the maximum rank allowed for a layer is 2r.",un,ie,hr='It is recommended to perform EVA initialization on an accelerator(e.g. CUDA GPU, Intel XPU) as it is much faster. To optimize the amount of available memory for EVA, you can use the <code>low_cpu_mem_usage</code> flag in <a href="/docs/peft/main/en/package_reference/peft_model#peft.get_peft_model">get_peft_model()</a>:',fn,re,Mn,de,ur='Then, call <a href="/docs/peft/main/en/package_reference/lora#peft.initialize_lora_eva_weights">initialize_lora_eva_weights()</a> to initialize the EVA weights (in most cases the dataloader used for eva initialization can be the same as the one used for finetuning):',wn,pe,yn,me,fr='EVA works out of the box with bitsandbytes. Simply initialize the model with <code>quantization_config</code> and call <a href="/docs/peft/main/en/package_reference/lora#peft.initialize_lora_eva_weights">initialize_lora_eva_weights()</a> as usual.',Tn,_,Mr='<p>For further instructions on using EVA, please refer to our <a href="https://github.com/huggingface/peft/tree/main/examples/eva_finetuning" rel="nofollow">documentation</a>.</p>',bn,ce,gn,he,Jn,ue,wr='When quantizing the base model for QLoRA training, consider using the <a href="https://huggingface.co/papers/2310.08659" rel="nofollow">LoftQ initialization</a>, which has been shown to improve performance when training quantized models. The idea is that the LoRA weights are initialized such that the quantization error is minimized. To use LoftQ, follow <a href="https://github.com/huggingface/peft/tree/main/examples/loftq_finetuning" rel="nofollow">these instructions</a>.',_n,j,yr='<p>Learn more about how PEFT works with quantization and how to use LoftQ in the <a href="quantization">Quantization</a> guide.</p>',jn,fe,vn,Me,Tr='Another way to initialize <a href="/docs/peft/main/en/package_reference/lora#peft.LoraConfig">LoraConfig</a> is with the <a href="https://huggingface.co/papers/2312.03732" rel="nofollow">rank-stabilized LoRA (rsLoRA)</a> method. The LoRA architecture scales each adapter during every forward pass by a fixed scalar which is set at initialization and depends on the rank <code>r</code>. The scalar is given by <code>lora_alpha/r</code> in the original implementation, but rsLoRA uses <code>lora_alpha/math.sqrt(r)</code> which stabilizes the adapters and increases the performance potential from using a higher <code>r</code>.',kn,we,Un,ye,Zn,Te,br=`<a href="../package_reference/lora#lora-ga">LoRA-GA</a> (Low-Rank Adaptation with Gradient Approximation) initializes the adapter
weights by performing SVD on estimated gradients, so that the weights are aligning closer to full-finetuning for faster
convergence.`,Cn,be,gr=`This method requires an initialization function to estimate the gradients
before beginning the actual training:`,Bn,ge,$n,Je,In,_e,Jr="PEFT implements LoRA variants that improve upon the original LoRA.",Rn,je,Wn,ve,_r='This technique decomposes the updates of the weights into two parts, magnitude and direction. Direction is handled by normal LoRA, whereas the magnitude is handled by a separate learnable parameter. This can improve the performance of LoRA, especially at low ranks. For more information on DoRA, see  <a href="https://huggingface.co/papers/2402.09353" rel="nofollow">https://huggingface.co/papers/2402.09353</a>.',Ln,ke,An,Ue,jr="If parts of the model or the DoRA adapter are offloaded to CPU you can get a significant speedup at the cost of some temporary (ephemeral) VRAM overhead by using <code>ephemeral_gpu_offload=True</code> in <code>config.runtime_config</code>.",Gn,Ze,xn,Ce,vr="A <code>PeftModel</code> with a DoRA adapter can also be loaded with <code>ephemeral_gpu_offload=True</code> flag using the <code>from_pretrained</code> method as well as the <code>load_adapter</code> method.",Vn,Be,Xn,$e,Fn,Ie,kr=`DoRA is optimized (computes faster and takes less memory) for models in the evaluation mode, or when dropout is set to 0. We reuse the
base result at those times to get the speedup.
Running <a href="https://github.com/huggingface/peft/blob/main/examples/dora_finetuning/dora_finetuning.py" rel="nofollow">dora finetuning</a>
with <code>CUDA_VISIBLE_DEVICES=0 ZE_AFFINITY_MASK=0 time python examples/dora_finetuning/dora_finetuning.py --quantize --lora_dropout 0 --batch_size 16 --eval_step 2 --use_dora</code> on a 4090 with gradient accumulation set to 2 and max step to 20 resulted with the following observations:`,qn,Re,Ur='<thead><tr><th align="center"></th> <th align="center">Without Optimization</th> <th align="center">With Optimization</th></tr></thead> <tbody><tr><td align="center">train runtime (sec)</td> <td align="center">359.7298</td> <td align="center"><strong>279.2676</strong></td></tr> <tr><td align="center">train samples per second</td> <td align="center">1.779</td> <td align="center"><strong>2.292</strong></td></tr> <tr><td align="center">train steps per second</td> <td align="center">0.056</td> <td align="center"><strong>0.072</strong></td></tr></tbody>',En,We,Zr="Moreover, it is possible to further increase runtime performance of DoRA by using the <code>DoraCaching</code> helper context. This requires the model to be in <code>eval</code> mode:",Hn,Le,Yn,Ae,Cr='For <a href="https://huggingface.co/meta-llama/Llama-3.1-8B" rel="nofollow"><code>meta-llama/Llama-3.1-8B</code></a>, the <a href="https://github.com/huggingface/peft/blob/main/examples/dora_finetuning/dora-caching.py" rel="nofollow">DoRA caching benchmark script</a> shows that, compared to LoRA:',Qn,Ge,Br="<li>DoRA without caching requires 139% more time</li> <li>DoRA without caching requires 4% more memory</li> <li>DoRA with caching requires 17% more time</li> <li>DoRA with caching requires 41% more memory</li>",zn,xe,$r="Caching can thus make inference with DoRA significantly faster but it also requires signficantly more memory. Ideally, if the use case allows it, just merge the DoRA adapter to avoid both memory and runtime overhead.",Nn,Ve,Sn,Xe,Ir='<li>DoRA only supports embedding, linear, and Conv2d layers at the moment.</li> <li>DoRA introduces a bigger overhead than pure LoRA, so it is recommended to merge weights for inference, see <a href="/docs/peft/main/en/package_reference/tuners#peft.tuners.tuners_utils.BaseTuner.merge_and_unload">LoraModel.merge_and_unload()</a>.</li> <li>DoRA should work with weights quantized with bitsandbytes (“QDoRA”). However, issues have been reported when using QDoRA with DeepSpeed Zero2.</li>',Pn,Fe,Dn,qe,Rr=`This section shows how to handle more complex training scenarios instead of only applying a low-rank adapter
to the model and feed data.`,Kn,Ee,On,He,Wr='The default LoRA settings in PEFT add trainable weights to the query and value layers of each attention block. But <a href="https://hf.co/papers/2305.14314" rel="nofollow">QLoRA</a>, which adds trainable weights to all the linear layers of a transformer model, can provide performance equal to a fully finetuned model. To apply LoRA to all the linear layers, like in QLoRA, set <code>target_modules=&quot;all-linear&quot;</code> (easier than specifying individual modules by name which can vary depending on the architecture).',es,Ye,ts,Qe,Lr='For more information about how to apply quantization to PEFT adapters, refer to the <a href="quantization">quantization guide</a>.',as,ze,ls,Ne,Ar='An approach used to improve the performance of models is to expand a model by duplicating layers in the model to build a larger model from a pretrained model of a given size. For example increasing a 7B model to a 10B model as described in the <a href="https://huggingface.co/papers/2312.15166" rel="nofollow">SOLAR</a> paper. PEFT LoRA supports this kind of expansion in a memory efficient manner that supports further fine-tuning using LoRA adapters attached to the layers post replication of the layers. The replicated layers do not take additional memory as they share the underlying weights so the only additional memory required is the memory for the adapter weights. To use this feature you would create a config with the <code>layer_replication</code> argument.',ns,Se,ss,Pe,Gr='Assuming the original model had 5 layers <code>[0, 1, 2 ,3, 4]</code>, this would create a model with 7 layers arranged as <code>[0, 1, 2, 3, 2, 3, 4]</code>. This follows the <a href="https://github.com/arcee-ai/mergekit" rel="nofollow">mergekit</a> pass through merge convention where sequences of layers specified as start inclusive and end exclusive tuples are stacked to build the final model. Each layer in the final model gets its own distinct set of LoRA adapters.',os,De,xr=`<a href="https://huggingface.co/abacusai/Fewshot-Metamath-OrcaVicuna-Mistral-10B" rel="nofollow">Fewshot-Metamath-OrcaVicuna-Mistral-10B</a> is an example of a model trained using this method on Mistral-7B expanded to 10B. The
<a href="https://huggingface.co/abacusai/Fewshot-Metamath-OrcaVicuna-Mistral-10B/blob/main/adapter_config.json" rel="nofollow">adapter_config.json</a> shows a sample LoRA adapter config applying this method for fine-tuning.`,is,Ke,rs,Oe,Vr='By default, all layers targeted with LoRA will have the same rank <code>r</code> and the same <code>lora_alpha</code> (which determines the LoRA scaling), depending on what was specified in the <a href="/docs/peft/main/en/package_reference/lora#peft.LoraConfig">LoraConfig</a>. In some cases, however, you may want to indicate different values for different layers. This is possible by passing the <code>rank_pattern</code> and <code>alpha_pattern</code> arguments to <a href="/docs/peft/main/en/package_reference/lora#peft.LoraConfig">LoraConfig</a>. These arguments should be dictionaries with the key being the layer name and the value being the rank/alpha value. The keys can be <a href="https://docs.python.org/3/library/re.html" rel="nofollow">regular expressions</a> (regex). All LoRA layers that are not explicitly mentioned in <code>rank_pattern</code> and <code>alpha_pattern</code> will take the default <code>r</code> and <code>lora_alpha</code> values.',ds,et,Xr="To give an example, let’s assume that we have a model with the following structure:",ps,tt,ms,at,Fr="<li><code>rank_pattern={&quot;foo&quot;: 42}</code> will match all 3 <code>foo</code> layers. Neither <code>foobar</code> nor <code>barfoo</code> are matched.</li> <li><code>rank_pattern={&quot;^foo&quot;: 42}</code> will only match the <code>foo</code> layer of the model, but neither <code>module.foo</code> nor <code>module.module.foo</code>. This is because the <code>^</code> means “start of string” when using regular expressions, and only <code>foo</code> starts with <code>&quot;foo&quot;</code>, the other layer names have prefixes.</li> <li><code>rank_pattern={&quot;^module.foo&quot;: 42}</code> matches only <code>module.foo</code>, but not <code>module.module.foo</code>, for the same reason.</li> <li><code>rank_pattern={&quot;module.foo&quot;: 42}</code> matches both <code>module.foo</code> and <code>module.module.foo</code>, but not <code>foo</code>.</li> <li><code>rank_pattern={&quot;^foo&quot;: 42, &quot;^module.module.foo&quot;: 55}</code> matches <code>foo</code> and <code>module.module.foo</code>, respectively, but not <code>module.foo</code>.</li> <li>There is no need to indicate <code>$</code> to mark the end of the match, as this is added automatically by PEFT.</li>",cs,lt,qr="The same logic applies to <code>alpha_pattern</code>. If you’re in doubt, don’t try to get fancy with regular expressions — just pass the full name for each module with a different rank/alpha, preceded by the <code>^</code> prefix, and you should be good.",hs,nt,us,st,Er='Generally, you should use <code>target_modules</code> to target the module (e.g. <code>nn.Linear</code>). However, in some circumstances, this is not possible. E.g., in many mixture of expert (MoE) layers in HF Transformers, instead of using <code>nn.Linear</code>, an <code>nn.Parameter</code> is used. PEFT normally overwrites the <code>forward</code> method for LoRA, but for <code>nn.Parameter</code>, there is none. Therefore, to apply LoRA to that parameter, it needs to be targeted with <code>target_parameters</code>. As an example, for <a href="https://huggingface.co/collections/meta-llama/llama-4-67f0c30d9fe03840bc9d0164" rel="nofollow">Llama4</a>, you can pass: <code>target_parameters=[&#39;feed_forward.experts.gate_up_proj&#39;, &#39;feed_forward.experts.down_proj]</code>.',fs,ot,Hr="Note that when targeting expert parameters, PEFT can add a substantial runtime overhead. The reason is that PEFT always materializes the LoRA contribution for <em>each expert</em> even if only a small amount of experts is required. During training, this is less relevant since, over the course of the sequence, typically a large fraction of experts is activated at least once. However, during inference, normally a KV cache is used and we thus need to only compute the last token, which means that only a small amount of experts is activated. Therefore, using LoRA on MoE layers can result in a substantial slowdown at inference time. The recommendation is thus to merge the weights (<code>model.merge_adapter()</code> or <code>model = model.merge_and_unload()</code>). This removes the PEFT overhead.",Ms,it,Yr='A more detailed investigation of this issue can be found on this <a href="https://github.com/huggingface/peft/pull/3139" rel="nofollow">pull request on MoE optimization</a>.',ws,rt,ys,dt,Qr="<li>At the moment, this argument allows to target 2-dim or 3-dim <code>nn.Parameter</code>s. It is assumed that in the case of a 3-dim parameter, the 0th dimension is the expert dimension.</li> <li>It is currently not possible to add multiple LoRA adapters (via <code>model.add_adapter</code> or <code>model.load_adapter</code>) that use <code>target_parameters</code> at the same time.</li>",Ts,pt,bs,mt,zr=`Some MoE models in Transformers store expert weights as <code>nn.Parameter</code> tensors (often 3D), not <code>nn.Linear</code> modules.
To apply LoRA to those experts, use <code>target_parameters</code> and set a per-layer rank with <code>rank_pattern</code>:`,gs,ct,Js,ht,Nr=`This keeps the total LoRA parameter budget similar to dense layers (see
<a href="https://thinkingmachines.ai/blog/lora/" rel="nofollow">LoRA Without Regret</a> by Schulman et. al.).
Non-expert modules use the default rank <code>r</code>.`,_s,ut,Sr='Accelerated inference with the fine-tuned model is possible with, for example, <a href="https://vllm.ai/" rel="nofollow">vLLM</a> which supports fused MoE expert layers since v0.11.2.',js,ft,vs,Mt,Pr='PEFT LoRA adapters support adding new tokens with the <code>trainable_token_indices</code> parameter. This allows tuning of other tokens alongside fine-tuning specific layers. Only the specified tokens are trained and all other tokens are untouched. It saves memory and doesn’t throw away learned context from existing token embeddings unlike training the whole embedding matrix. Under the hood this method uses the layer of <a href="/docs/peft/main/en/package_reference/trainable_tokens#peft.TrainableTokensModel">TrainableTokensModel</a>.',ks,wt,Us,yt,Dr="In the snippet below we show how to add new tokens to the model and how to train it alongside the other layers in the model.",Zs,Tt,Cs,bt,Kr="The token weights are saved as a part of the adapter state dict alongside the LoRA weights. Full fine-tuning and saving the embedding matrix would have stored a much bigger file.",Bs,gt,Or="To give a bit of an indication how much VRAM can be saved, a rudimentary comparison of the above example was made between training the embedding matrix fully (<code>modules_to_save=[&quot;embed_tokens&quot;]</code>), using a LoRA for the embedding matrix (<code>target_modules=[..., &quot;embed_tokens&quot;]</code>, rank 32) and trainable tokens (<code>trainable_token_indices=[...]</code>, 6 tokens):",$s,Jt,ed='<thead><tr><th align="right"></th> <th align="center">Trainable Tokens</th> <th align="center">LoRA</th> <th align="center">Full Fine-tuning</th></tr></thead> <tbody><tr><td align="right">VRAM</td> <td align="center">15,562 MB</td> <td align="center">15,581MB</td> <td align="center">~16,500MB</td></tr> <tr><td align="right">Influence</td> <td align="center">6 tokens</td> <td align="center">all tokens</td> <td align="center">all tokens</td></tr></tbody>',Is,_t,Rs,jt,td="Many causal LMs use <strong>weight tying</strong>, where two or more weights share the same underlying parameters. In the most common case, the input embedding weights (<code>embed_tokens</code>) and output projection weights (<code>lm_head</code>) share the same tensor. This is because it reduces parameters and usually preserves model quality.",Ws,vt,ad='It’s not always obvious how PEFT deals with these tied weights when they are targeted for fine-tuning. For LoRA, the <code>ensure_weight_tying</code> on the <a href="/docs/peft/main/en/package_reference/lora#peft.LoraConfig">LoraConfig</a> controls whether PEFT should explicitly keep adapter-side updates tied for those layers. In practice, this can affect <code>modules_to_save</code>, <code>target_modules</code>, and <code>trainable_token_indices</code>. Note that this logic partially relies on convention when it comes to naming the layers (<code>&quot;embed_tokens&quot;</code>, <code>&quot;lm_head&quot;</code>) and proper working cannot be guaranteed if those conventions are not used.',Ls,kt,ld="The tables below summarize expected behavior.",As,Ut,Gs,Zt,nd="<thead><tr><th>Base model weights tied</th> <th><code>ensure_weight_tying</code></th> <th><code>LoraConfig</code> shape</th> <th>Behavior</th></tr></thead> <tbody><tr><td>No</td> <td><code>False</code></td> <td><code>modules_to_save=[&quot;embed_tokens&quot;]</code> or <code>[&quot;lm_head&quot;]</code></td> <td>Add <code>ModulesToSaveWrapper</code> on selected layer only</td></tr> <tr><td>No</td> <td><code>True</code></td> <td><code>modules_to_save=[&quot;embed_tokens&quot;]</code> or <code>[&quot;lm_head&quot;]</code></td> <td>Warn, then add <code>ModulesToSaveWrapper</code> on selected layer only</td></tr> <tr><td>Yes</td> <td><code>False</code></td> <td><code>modules_to_save=[&quot;embed_tokens&quot;]</code> or <code>[&quot;lm_head&quot;]</code></td> <td>Treat as separate</td></tr> <tr><td>Yes</td> <td><code>True</code></td> <td><code>modules_to_save=[&quot;embed_tokens&quot;]</code> or <code>[&quot;lm_head&quot;]</code></td> <td>Wrap tied layers and keep wrappers tied</td></tr> <tr><td>No</td> <td><code>False</code></td> <td><code>modules_to_save=[&quot;embed_tokens&quot;, &quot;lm_head&quot;]</code></td> <td>Treat as separate</td></tr> <tr><td>No</td> <td><code>True</code></td> <td><code>modules_to_save=[&quot;embed_tokens&quot;, &quot;lm_head&quot;]</code></td> <td>Warn, then treat as separate</td></tr> <tr><td>Yes</td> <td><code>False</code></td> <td><code>modules_to_save=[&quot;embed_tokens&quot;, &quot;lm_head&quot;]</code></td> <td>Warn, then treat as separate</td></tr> <tr><td>Yes</td> <td><code>True</code></td> <td><code>modules_to_save=[&quot;embed_tokens&quot;, &quot;lm_head&quot;]</code></td> <td>Keep <code>ModulesToSaveWrapper</code>s tied</td></tr></tbody>",xs,Ct,Vs,Bt,sd="<thead><tr><th>Base model weights tied</th> <th><code>ensure_weight_tying</code></th> <th><code>LoraConfig</code> shape</th> <th>Behavior</th></tr></thead> <tbody><tr><td>No</td> <td><code>False</code></td> <td><code>target_modules=[&quot;embed_tokens&quot;]</code> or <code>[&quot;lm_head&quot;]</code></td> <td>Add LoRA on selected layer only</td></tr> <tr><td>No</td> <td><code>True</code></td> <td><code>target_modules=[&quot;embed_tokens&quot;]</code> or <code>[&quot;lm_head&quot;]</code></td> <td>Warn, then add LoRA on selected layer only</td></tr> <tr><td>Yes</td> <td><code>False</code></td> <td><code>target_modules=[&quot;embed_tokens&quot;]</code> or <code>[&quot;lm_head&quot;]</code></td> <td>Treat as separate</td></tr> <tr><td>Yes</td> <td><code>True</code></td> <td><code>target_modules=[&quot;embed_tokens&quot;]</code> or <code>[&quot;lm_head&quot;]</code></td> <td>Keep LoRA adapters tied</td></tr> <tr><td>No</td> <td><code>False</code></td> <td><code>target_modules=[&quot;embed_tokens&quot;, &quot;lm_head&quot;]</code></td> <td>Treat as separate</td></tr> <tr><td>No</td> <td><code>True</code></td> <td><code>target_modules=[&quot;embed_tokens&quot;, &quot;lm_head&quot;]</code></td> <td>Warn, then treat as separate</td></tr> <tr><td>Yes</td> <td><code>False</code></td> <td><code>target_modules=[&quot;embed_tokens&quot;, &quot;lm_head&quot;]</code></td> <td>Warn, then treat as separate</td></tr> <tr><td>Yes</td> <td><code>True</code></td> <td><code>target_modules=[&quot;embed_tokens&quot;, &quot;lm_head&quot;]</code></td> <td>Keep LoRA adapters tied</td></tr></tbody>",Xs,$t,Fs,It,od="For trainable tokens, we have the additional complication that even if the LM head and embeddings are tied, as a user I may want to fine-tune <em>different</em> tokens on them. In the example table below, we thus differentiate between fine-tuning the same and fine-tuning different tokens.",qs,Rt,id="<thead><tr><th>Base model weights tied</th> <th><code>ensure_weight_tying</code></th> <th><code>LoraConfig</code> shape</th> <th>Behavior</th></tr></thead> <tbody><tr><td>No</td> <td><code>False</code></td> <td><code>trainable_token_indices=[1, 2, 3]</code></td> <td>Trainable tokens on embeddings only</td></tr> <tr><td>No</td> <td><code>True</code></td> <td><code>trainable_token_indices=[1, 2, 3]</code></td> <td>Warn, then trainable tokens on embeddings only</td></tr> <tr><td>Yes</td> <td><code>False</code></td> <td><code>trainable_token_indices=[1, 2, 3]</code></td> <td>Tied trainable tokens</td></tr> <tr><td>Yes</td> <td><code>True</code></td> <td><code>trainable_token_indices=[1, 2, 3]</code></td> <td>Tied trainable tokens</td></tr> <tr><td>No</td> <td><code>False</code></td> <td><code>trainable_token_indices={&quot;lm_head&quot;: [1, 2], &quot;embed_tokens&quot;: [1, 2]}</code></td> <td>Treat as separate</td></tr> <tr><td>No</td> <td><code>True</code></td> <td><code>trainable_token_indices={&quot;lm_head&quot;: [1, 2], &quot;embed_tokens&quot;: [1, 2]}</code></td> <td>Warn, then treat as separate</td></tr> <tr><td>Yes</td> <td><code>False</code></td> <td><code>trainable_token_indices={&quot;lm_head&quot;: [1, 2], &quot;embed_tokens&quot;: [1, 2]}</code></td> <td>Tied trainable tokens</td></tr> <tr><td>Yes</td> <td><code>True</code></td> <td><code>trainable_token_indices={&quot;lm_head&quot;: [1, 2], &quot;embed_tokens&quot;: [1, 2]}</code></td> <td>Tied trainable tokens</td></tr> <tr><td>No</td> <td><code>False</code></td> <td><code>trainable_token_indices={&quot;lm_head&quot;: [1, 2], &quot;embed_tokens&quot;: [3, 4]}</code></td> <td>Treat as separate</td></tr> <tr><td>No</td> <td><code>True</code></td> <td><code>trainable_token_indices={&quot;lm_head&quot;: [1, 2], &quot;embed_tokens&quot;: [3, 4]}</code></td> <td>Warn, then treat as separate</td></tr> <tr><td>Yes</td> <td><code>False</code></td> <td><code>trainable_token_indices={&quot;lm_head&quot;: [1, 2], &quot;embed_tokens&quot;: [3, 4]}</code></td> <td>Treat as separate</td></tr> <tr><td>Yes</td> <td><code>True</code></td> <td><code>trainable_token_indices={&quot;lm_head&quot;: [1, 2], &quot;embed_tokens&quot;: [3, 4]}</code></td> <td>Error</td></tr></tbody>",Es,Wt,rd="For users, this means:",Hs,Lt,dd="<li>In general, if you want to fine-tune weights that are tied and want to keep them tied, pass <code>ensure_weight_tying=True</code>.</li> <li>If your base model’s weights are untied, <code>ensure_weight_tying=True</code> cannot force tying and only warns.</li> <li>For <code>trainable_token_indices</code>, tied layers must use the same token indices when <code>ensure_weight_tying=True</code>.</li>",Ys,At,Qs,Gt,pd="LoRA training can optionally include special purpose optimizers. Currently PEFT supports LoRA-FA and LoRA+.",zs,xt,Ns,Vt,md='LoRA training can be more effective and efficient using LoRA-FA, as described in <a href="https://huggingface.co/papers/2308.03303" rel="nofollow">LoRA-FA</a>. LoRA-FA reduces activation memory consumption by fixing the matrix A and only tuning the matrix B. During training, the gradient of B is optimized to approximate the full parameter fine-tuning gradient. Moreover, the memory consumption of LoRA-FA is not sensitive to the rank (since it erases the activation of $A$), therefore it can improve performance by enlarging lora rank without increasing memory consumption.',Ss,Xt,Ps,Ft,Ds,qt,cd='LoRA training can be optimized using <a href="https://huggingface.co/papers/2402.12354" rel="nofollow">LoRA+</a>, which uses different learning rates for the adapter matrices A and B, shown to increase finetuning speed by up to 2x and performance by 1-2%.',Ks,Et,Os,Ht,eo,Yt,hd="This section shows potential post-processing methods for trained adapters.",to,Qt,ao,zt,ud='While LoRA is significantly smaller and faster to train, you may encounter latency issues during inference due to separately loading the base model and the LoRA adapter. To eliminate latency, use the <a href="/docs/peft/main/en/package_reference/tuners#peft.tuners.tuners_utils.BaseTuner.merge_and_unload">merge_and_unload()</a> function to merge the adapter weights with the base model. This allows you to use the newly merged model as a standalone model. The <a href="/docs/peft/main/en/package_reference/tuners#peft.tuners.tuners_utils.BaseTuner.merge_and_unload">merge_and_unload()</a> function doesn’t keep the adapter weights in memory.',lo,Nt,fd="Below is a diagram that explains the intuition of LoRA adapter merging:",no,v,Md='<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/peft/lora_diagram.png"/>',so,St,wd="We show in the snippets below how to run that using PEFT.",oo,Pt,io,Dt,yd='It is important to assign the returned model to a variable and use it, <a href="/docs/peft/main/en/package_reference/tuners#peft.tuners.tuners_utils.BaseTuner.merge_and_unload">merge_and_unload()</a> is not an in-place operation. If you need to keep a copy of the weights so you can unmerge the adapter later or delete and load different ones, you should use the <a href="/docs/peft/main/en/package_reference/tuners#peft.tuners.tuners_utils.BaseTuner.merge_adapter">merge_adapter()</a> function instead. Now you have the option to use <a href="/docs/peft/main/en/package_reference/tuners#peft.tuners.tuners_utils.BaseTuner.unmerge_adapter">unmerge_adapter()</a> to return the base model.',ro,Kt,po,Ot,Td='The <a href="/docs/peft/main/en/package_reference/lora#peft.LoraModel.add_weighted_adapter">add_weighted_adapter()</a> function is useful for merging multiple LoRAs into a new adapter based on a user provided weighting scheme in the <code>weights</code> parameter. Below is an end-to-end example.',mo,ea,bd="First load the base model:",co,ta,ho,aa,gd="Then we load the first adapter:",uo,la,fo,na,Jd="Then load a different adapter and merge it with the first one:",Mo,sa,wo,k,_d='<p>There are several supported methods for <code>combination_type</code>. Refer to the <a href="../package_reference/lora#peft.LoraModel.add_weighted_adapter">documentation</a> for more details. Note that “svd” as the <code>combination_type</code> is not supported when using <code>torch.float16</code> or <code>torch.bfloat16</code> as the datatype.</p>',yo,oa,jd="Now, perform inference:",To,ia,bo,ra,go,da,vd=`The paper <a href="https://huggingface.co/papers/2410.21228" rel="nofollow">LoRA vs Full Fine-tuning: An Illusion of Equivalence</a> argues
that LoRA training introduces extra dimensions into the weights that have very little in common with the already
learnt weights and lead to forgetting of already learned information. PEFT implements the suggested mitigation
in <a href="/docs/peft/main/en/package_reference/lora#peft.tuners.lora.intruders.reduce_intruder_dimension">peft.tuners.lora.intruders.reduce_intruder_dimension()</a>.`,Jo,pa,kd=`The mitigation will take a PEFT model with a loaded LoRA and create a new, modified adapter that is loaded alongside
the existing adapter and now the active adapter.`,_o,ma,Ud="Example usage:",jo,ca,vo,ha,Zd=`There are a few hyper-parameters that can be used for tuning the effectiveness of the mitigation but, as evidenced
in Figure 8 of the paper, it will always be a trade-off between task accuracy learned by the adapter and forgetting
of the base model’s knowledge. The mitigation will remove information from the adapter to reduce the impact on
forgetting previous knowledge but this also means that some information about the task learned by the adapter is
lost as well.`,ko,ua,Cd=`While the defaults are set to deliver a good trade-off between the two factors it is not guaranteed that the defaults
will hold for your adapter, your model and your data, therefore it is wise to have a benchmark ready to measure
the effect.`,Uo,fa,Zo,Ma,Bd='Adapters can be loaded onto a pretrained model with <a href="/docs/peft/main/en/package_reference/peft_model#peft.PeftModel.load_adapter">load_adapter()</a>, which is useful for trying out different adapters whose weights aren’t merged. Set the active adapter weights with the <a href="/docs/peft/main/en/package_reference/tuners#peft.tuners.tuners_utils.BaseTuner.set_adapter">set_adapter()</a> function.',Co,wa,Bo,ya,$d='To return the base model, you could use <a href="/docs/peft/main/en/package_reference/tuners#peft.tuners.tuners_utils.BaseTuner.unload">unload()</a> to unload all of the LoRA modules or <a href="/docs/peft/main/en/package_reference/tuners#peft.tuners.tuners_utils.BaseTuner.delete_adapter">delete_adapter()</a> to delete the adapter entirely. <a href="/docs/peft/main/en/package_reference/tuners#peft.tuners.tuners_utils.BaseTuner.unload">unload()</a> is not an in-place operation, remember to assign the returned model to a variable and use it.',$o,Ta,Io,ba,Ro,ga,Id='LoRA supports <a href="https://huggingface.co/docs/transformers/main/en/perf_train_gpu_many#tensor-parallelism" rel="nofollow">Tensor Parallelism (TP)</a> as provided by Transformers. When a base model is loaded with a <code>tp_plan</code>, PEFT automatically detects the TP configuration of each target module and adds the appropriate hooks to the LoRA adapter weights so that they participate correctly in the tensor-parallel computation.',Wo,U,Rd="<p>Tensor Parallelism support for LoRA requires <code>transformers &gt;= 5.4.0</code>.</p>",Lo,Ja,Wd="Usage is identical to the standard LoRA workflow — simply load the base model with a <code>tp_plan</code> before wrapping it with PEFT:",Ao,_a,Go,ja,Ld="Saving and loading work as usual via <code>save_pretrained</code> / <code>from_pretrained</code>. PEFT gathers the sharded adapter weights back to full tensors before saving, so checkpoints are portable and independent of the number of devices used during training.",xo,va,Vo,ka,Ad="This section showcases what you can do during inference time with LoRA, such as uncoupling the adapter.",Xo,Ua,Fo,Za,Gd='Activated LoRA (aLoRA) is a low rank adapter architecture for causal LMs that reuses the existing base model KV cache for more efficient inference. This approach is best suited for inference pipelines which rely on the base model for most tasks/generations, but use aLoRA adapter(s) to perform specialized task(s) within the chain. For example, checking or correcting generated outputs of the base model. In these settings, inference times can be sped up by an order of magnitude or more. For more information on aLoRA and many example use cases, see the aLoRA <a href="https://huggingface.co/papers/2504.12397" rel="nofollow">paper</a>.',qo,Ca,xd="This technique scans for the last occurrence of an invocation sequence (<code>alora_invocation_tokens</code>) in each input (this can be as short as 1 token). It activates the adapter weights on tokens starting with the beginning of the invocation sequence. Any inputs after the invocation sequence are also adapted, and all generated tokens will use the adapted weights. Weights on prior tokens are left un-adapted, making the cache for those tokens interchangeable with base model cache due to the causal attention mask in causal LMs. Usage is very similar to standard LoRA. The key difference is that the invocation sequence must be specified when the adapter is created:",Eo,Ba,Ho,$a,Vd="alora_invocation_tokens` is a list of integer token ids. Given a desired invocation string, this can be obtained as:",Yo,Ia,Qo,Ra,Xd="The tokenizer is the base model’s tokenizer. Use <code>add_special_tokens=False</code> to avoid adding <code>SOS</code>/<code>EOS</code> tokens in our search string (which will most likely cause the search to fail).",zo,Wa,Fd="<strong>Notes</strong>",No,La,qd='<li>aLoRA is only supported for <code>task_type=CAUSAL_LM</code> tasks due to its focus on cache reuse.</li> <li>Since the weights are adapted on fewer tokens, often (not always) aLoRA requires higher rank (<code>r</code>) than LoRA. <code>r=32</code> can be a good starting point.</li> <li>aLoRA weights cannot be merged into the base model by definition, since the adapter weights are selectively applied to a subset of tokens. Attempts to merge will throw errors.</li> <li>Beam search is not yet supported.</li> <li>It is generally not recommended to add new tokens to the tokenizer that are not present in the base model. This can complicate the target use case of both the base model and adapter model operating on overlapping context. You can workaround this by adding <a href="../package_reference/trainable_tokens">trainable tokens</a> to the base model prior to training the adapter.</li>',So,Aa,Po,Ga,Ed=`You must add the <code>alora_invocation_tokens</code> sequence because it is not added automatically. We recommend activating the adapter weights early (at the start of any adapter-specific prompting), but after any long inputs, to maximize model performance without compromising cache reuse. As with any model,
formatting should be consistent between train and test.`,Do,xa,Hd=`Consider the following example, where the base model has a chat template,
and the goal is to train the adapter to generate a desired output.`,Ko,Va,Yd="<li>Option 1: If there is no task-specific prompt, i.e. the input is a chat history with the <code>assistant</code> prompt, then the chat template’s <code>assistant</code> prompt (e.g. <code>&lt;|start_of_role|&gt;assistant&lt;|end_of_role|&gt;</code>) is a natural choice for the invocation string. See the model’s chat template to find the prompt for the model.</li> <li>Option 2: If there is a task-specific prompt for the adapter that describes the task the adapter is learning, and that prompt is put as a <code>user</code> turn immediately prior to the generation, then the chat template’s <code>user</code> prompt (e.g. <code>&lt;|start_of_role|&gt;user&lt;|end_of_role|&gt;</code>) is a natural choice for the invocation string.</li>",Oo,Xa,Qd="After deciding on an invocation string, get the model tokenizer and obtain <code>alora_invocation_tokens</code> as",ei,Fa,ti,qa,zd='An example inference setup is at <a href="https://github.com/huggingface/peft/blob/main/examples/alora_finetuning/alora_finetuning.py" rel="nofollow">alora finetuning</a>.',ai,Z,Nd="<p>If using custom strings for the invocation string, make sure that the start and end of the string are special tokens to avoid issues with tokenization at the boundaries.</p>",li,Ea,Sd="To see why, imagine that ‘a’, ‘b’, ‘c’, and ‘ab’ are tokens in your tokenizer (numbers 1, 2, 3, 4 respectively). Suppose that your alora_invocation_tokens = [2, 3]. Now imagine your input string is “abc”. Because “ab” is a token, this will get tokenized as [4,3]. So the alora_invocation_tokens will fail to be found, despite the string “bc” being in it. If the start and end of the invocation string are special tokens, however, this failure case will never happen since special tokens are never tokenized into the same token with other characters.",ni,Ha,si,Ya,Pd="The main purpose of aLoRA is to make KV cache interchangeable between the base model and aLoRA adapter models <strong>prior to the invocation sequence</strong> since base and adapted KV values are not compatible. Specifically, keys and values stored during one model generation can be used in subsequent generations to avoid expensive prefill operations for context tokens. When sharing cache between the base model and aLoRA adapters, there are 2 main patterns:",oi,Qa,Dd="<li>The base model has generated something, and an aLoRA adapter is then called to do a follow-up generation. For example, the base model answers a question, and an aLoRA trained to detect hallucinations checks the base model response.</li> <li>An aLoRA adapter has generated something, and the base model or a different aLoRA adapter is called to do a follow-up generation where there is partial context overlap with the original aLoRA. For example, the user provides a query, and an aLoRA rewrites the query to be more self-contained and improve retrieval in a RAG system. Then, documents are retrieved and loaded into context, aLoRA checks if these documents are relevant to the question, and then the base model generates an answer.</li>",ii,za,Kd='To demonstrate the above behaviors when using caching, we’re using <a href="https://huggingface.co/docs/transformers/en/kv_cache" rel="nofollow">DynamicCache</a> from <code>transformers</code>. Take care to ensure that adapted cache values are not mixed with base cache values. In particular, an extra step is required for sharing the cache when there is partial context overlap (pattern 2).',ri,Na,Od="<strong>Pattern 1: Base model followed by aLoRA</strong> Here, the entire input and generation from the base model is input into the aLoRA adapter, along with the invocation sequence:",di,Sa,pi,Pa,ep="<strong>Pattern 2: aLoRA generation followed by base model (or another aLoRA) with partial context overlap</strong> Here, we prefill the shared context using the base model, and then generate.",mi,Da,ci,Ka,hi,Oa,tp="Normally, each inference batch has to use the same adapter(s) in PEFT. This can sometimes be annoying, because we may have batches that contain samples intended to be used with different LoRA adapters. For example, we could have a base model that works well in English and two more LoRA adapters, one for French and one for German. Usually, we would have to split our batches such that each batch only contains samples of one of the languages, we cannot combine different languages in the same batch.",ui,el,ap="Thankfully, it is possible to mix different LoRA adapters in the same batch using the <code>adapter_name</code> argument. Below, we show an example of how this works in practice. First, let’s load the base model, English, and the two adapters, French and German, like this:",fi,tl,Mi,al,lp="Now, we want to generate text on a sample that contains all three languages: The first three samples are in English, the next three are in French, and the last three are in German. We can use the <code>adapter_names</code> argument to specify which adapter to use for each sample. Since our base model is used for English, we use the special string <code>&quot;__base__&quot;</code> for these samples. For the next three samples, we indicate the adapter name of the French LoRA fine-tune, in this case <code>&quot;adapter_fr&quot;</code>. For the last three samples, we indicate the adapter name of the German LoRA fine-tune, in this case <code>&quot;adapter_de&quot;</code>. This way, we can use the base model and the two adapters in a single batch.",wi,ll,yi,nl,np="Note that the order does not matter here, i.e. the samples in the batch don’t need to be grouped by adapter as in the example above. We just need to ensure that the <code>adapter_names</code> argument is aligned correctly with the samples.",Ti,sl,sp="Additionally, the same approach also works with the <code>modules_to_save</code> feature, which allows for saving and reusing specific neural network layers, such as custom heads for classification tasks, across different LoRA adapters.",bi,ol,gi,il,op="Using this feature has some drawbacks, namely:",Ji,rl,ip=`<li>It only works for inference, not for training.</li> <li>Disabling adapters using the <code>with model.disable_adapter()</code> context takes precedence over <code>adapter_names</code>.</li> <li>You cannot pass <code>adapter_names</code> when some adapter weights were merged with base weight using the <code>merge_adapter</code> method. Please unmerge all adapters first by calling <code>model.unmerge_adapter()</code>.</li> <li>For obvious reasons, this cannot be used after calling <code>merge_and_unload()</code>, since all the LoRA adapters will be merged into the base weights in this case.</li> <li>This feature does not currently work with DoRA, so set <code>use_dora=False</code> in your <code>LoraConfig</code> if you want to use it.</li> <li>The <code>modules_to_save</code> feature is currently only supported for the layers of types <code>Linear</code>, <code>Embedding</code>, <code>Conv2d</code> and <code>Conv1d</code>.</li> <li>There is an expected overhead for inference with <code>adapter_names</code>, especially if the amount of different adapters in the batch is high. This is because the batch size is effectively reduced to the number of samples per adapter. If runtime performance is your top priority, try the following:
<ul><li>Increase the batch size.</li> <li>Try to avoid having a large number of different adapters in the same batch, prefer homogeneous batches. This can be achieved by buffering samples with the same adapter and only perform inference with a small handful of different adapters.</li> <li>Take a look at alternative implementations such as <a href="https://github.com/predibase/lorax" rel="nofollow">LoRAX</a>, <a href="https://github.com/punica-ai/punica" rel="nofollow">punica</a>, or <a href="https://github.com/S-LoRA/S-LoRA" rel="nofollow">S-LoRA</a>, which are specialized to work with a large number of different adapters.</li></ul></li>`,_i,dl,ji,pl,vi,ml,rp='<a href="https://huggingface.co/papers/2405.11157" rel="nofollow">Arrow</a> is a modular routing algorithm designed to combine multiple pre-trained task-specific LoRA adapters to solve a given task. Rather than merging all adapters naively, Arrow introduces a <strong>gradient-free, token-wise mixture-of-experts (MoE) routing mechanism</strong>. At inference time, it first computes a <em>prototype</em> for each LoRA by extracting the top right singular vector from its SVD decomposition. Each token representation is then compared to these prototypes via cosine similarity to obtain routing coefficients. Tokens are assigned to the top-k most relevant LoRA adapters, with the coefficients normalized through softmax, and their outputs linearly combined. This allows effective reuse of existing LoRA modules for new tasks and leads to stronger zero-shot generalization.',ki,cl,dp="In PEFT, Arrow is enabled through [`ArrowConfig]<code>and</code>create_arrow_model<code>. You can also configure parameters such as </code>top_k<code>(the number of LoRA adapters combined per token),</code>router_temperature<code>(the softmax temperature applied to the routing coefficients), and</code>rng_seed` (for reproducibility).",Ui,hl,Zi,ul,pp="Furthermore, you can add or remove adapters after calling <code>create_arrow_model</code>—for example, to fine-tune a new adapter or discard an unnecessary one. Once the adapters are in place, you can activate the <code>&quot;arrow_router&quot;</code> for inference to use Arrow. Note that if you add a new LoRA adapter after <code>create_arrow_model</code> and want to fine-tune it, you must explicitly set the new adapter as active, since <code>&quot;arrow_router&quot;</code> is activated by default in <code>create_arrow_model</code>.",Ci,fl,Bi,Ml,$i,wl,mp='<a href="https://aclanthology.org/2025.acl-short.54/" rel="nofollow">GenKnowSub</a> augments Arrow by purifying task-specific LoRA adapters before routing. The key idea is to subtract general knowledge encoded in LoRA space—based on the <a href="https://huggingface.co/papers/2212.04089" rel="nofollow">forgetting-via-negation principle</a>—so that task adapters become more isolated and focused on task-relevant signals. Concretely, GenKnowSub estimates a low-dimensional “general” subspace from a set of general (non task-specific) LoRA adapters and removes this component from each task adapter’s LoRA update prior to Arrow’s token-wise routing. This typically improves compositionality and reduces interference when combining many task adapters.',Ii,yl,cp="In PEFT, enable GenKnowSub by setting <code>use_gks=True</code> in ArrowConfig, and providing <code>general_adapter_paths</code> in <code>create_arrow_model</code>:",Ri,Tl,Wi,bl,hp="To encode general knowledge, GenKnowSub subtracts the average of the provided general adapters from each task-specific adapter once, before routing begins. Furthermore, the ability to add or remove adapters after calling <code>create_arrow_model</code> (as described in the Arrow section) is still supported in this case.",Li,g,jl,up="<strong>Things to keep in mind when using Arrow + GenKnowSub:</strong>",Fi,y,vl,fp="<p>All LoRA adapters (task-specific and general) must share the same <code>rank</code> and <code>target_modules</code>.</p>",qi,kl,Mp="<p>Any inconsistency in these settings will raise an error in <code>create_arrow_model</code>.</p>",Ei,Ul,wp="<p>Having different scaling factors (<code>lora_alpha</code>) across task adapters is supported — Arrow handles them automatically.</p>",Hi,Zl,yp="<p>Merging the <code>&quot;arrow_router&quot;</code> is not supported, due to its dynamic routing behavior.</p>",Yi,Cl,Tp="<p>In create_arrow_model, task adapters are loaded as <code>task_i</code> and general adapters as <code>gks_j</code> (where <code>i</code> and <code>j</code> are indices). The function ensures consistency of <code>target_modules</code>, <code>rank</code>, and whether adapters are applied to <code>Linear</code> or <code>Linear4bit</code> layers. It then adds the <code>&quot;arrow_router&quot;</code> module and activates it. Any customization of this process requires overriding <code>create_arrow_model</code>.</p>",Qi,gl,Bl,bp="This implementation is compatible with 4-bit quantization (via bitsandbytes):",zi,Jl,Ai,_l,Gi,Il,xi;return C=new Up({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),B=new M({props:{title:"LoRA",local:"lora",headingTag:"h1"}}),R=new M({props:{title:"Initialization",local:"initialization",headingTag:"h2"}}),A=new f({props:{code:"ZnJvbSUyMHBlZnQlMjBpbXBvcnQlMjBMb3JhQ29uZmlnJTBBJTBBY29uZmlnJTIwJTNEJTIwTG9yYUNvbmZpZyhpbml0X2xvcmFfd2VpZ2h0cyUzRCUyMmdhdXNzaWFuJTIyJTJDJTIwLi4uKQ==",highlighted:`<span class="hljs-keyword">from</span> peft <span class="hljs-keyword">import</span> LoraConfig

config = LoraConfig(init_lora_weights=<span class="hljs-string">&quot;gaussian&quot;</span>, ...)`,wrap:!1}}),x=new f({props:{code:"ZnJvbSUyMHBlZnQlMjBpbXBvcnQlMjBMb3JhQ29uZmlnJTBBJTBBY29uZmlnJTIwJTNEJTIwTG9yYUNvbmZpZyhpbml0X2xvcmFfd2VpZ2h0cyUzREZhbHNlJTJDJTIwLi4uKQ==",highlighted:`<span class="hljs-keyword">from</span> peft <span class="hljs-keyword">import</span> LoraConfig

config = LoraConfig(init_lora_weights=<span class="hljs-literal">False</span>, ...)`,wrap:!1}}),V=new M({props:{title:"PiSSA",local:"pissa",headingTag:"h3"}}),q=new f({props:{code:"ZnJvbSUyMHBlZnQlMjBpbXBvcnQlMjBMb3JhQ29uZmlnJTBBY29uZmlnJTIwJTNEJTIwTG9yYUNvbmZpZyhpbml0X2xvcmFfd2VpZ2h0cyUzRCUyMnBpc3NhJTIyJTJDJTIwLi4uKQ==",highlighted:`<span class="hljs-keyword">from</span> peft <span class="hljs-keyword">import</span> LoraConfig
config = LoraConfig(init_lora_weights=<span class="hljs-string">&quot;pissa&quot;</span>, ...)`,wrap:!1}}),H=new f({props:{code:"bG9yYV9jb25maWclMjAlM0QlMjBMb3JhQ29uZmlnKGluaXRfbG9yYV93ZWlnaHRzJTNEJTIycGlzc2Ffbml0ZXJfJTVCbnVtYmVyJTIwb2YlMjBpdGVycyU1RCUyMiUyQyUyMC4uLik=",highlighted:'lora_config = LoraConfig(init_lora_weights=<span class="hljs-string">&quot;pissa_niter_[number of iters]&quot;</span>, ...)',wrap:!1}}),Q=new M({props:{title:"CorDA",local:"corda",headingTag:"h3"}}),S=new f({props:{code:"JTQwdG9yY2gubm9fZ3JhZCgpJTBBZGVmJTIwcnVuX21vZGVsKCklM0ElMEElMjAlMjAlMjAlMjAlMjMlMjBBc3N1bWUlMjAlNjBtb2RlbCU2MCUyMGFuZCUyMCU2MGRhdGFzZXQlNjAlMjBpcyUyMGluJTIwY29udGV4dC4uLiUwQSUyMCUyMCUyMCUyMG1vZGVsLmV2YWwoKSUwQSUyMCUyMCUyMCUyMGZvciUyMGJhdGNoJTIwaW4lMjBkYXRhc2V0JTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwbW9kZWwoKipiYXRjaCklMEElMEElMEFjb3JkYV9jb25maWclMjAlM0QlMjBDb3JkYUNvbmZpZyglMEElMjAlMjAlMjAlMjBjb3JkYV9tZXRob2QlM0QlMjJrcG0lMjIlMkMlMEEpJTBBbG9yYV9jb25maWclMjAlM0QlMjBMb3JhQ29uZmlnKCUwQSUyMCUyMCUyMCUyMGluaXRfbG9yYV93ZWlnaHRzJTNEJTIyY29yZGElMjIlMkMlMEElMjAlMjAlMjAlMjBjb3JkYV9jb25maWclM0Rjb3JkYV9jb25maWclMkMlMEEpJTBBcHJlcHJvY2Vzc19jb3JkYShtb2RlbCUyQyUyMGxvcmFfY29uZmlnJTJDJTIwcnVuX21vZGVsJTNEcnVuX21vZGVsKSUwQXBlZnRfbW9kZWwlMjAlM0QlMjBnZXRfcGVmdF9tb2RlbChtb2RlbCUyQyUyMGxvcmFfY29uZmlnKQ==",highlighted:`<span class="hljs-meta">@torch.no_grad()</span>
<span class="hljs-keyword">def</span> <span class="hljs-title function_">run_model</span>():
    <span class="hljs-comment"># Assume \`model\` and \`dataset\` is in context...</span>
    model.<span class="hljs-built_in">eval</span>()
    <span class="hljs-keyword">for</span> batch <span class="hljs-keyword">in</span> dataset:
        model(**batch)


corda_config = CordaConfig(
    corda_method=<span class="hljs-string">&quot;kpm&quot;</span>,
)
lora_config = LoraConfig(
    init_lora_weights=<span class="hljs-string">&quot;corda&quot;</span>,
    corda_config=corda_config,
)
preprocess_corda(model, lora_config, run_model=run_model)
peft_model = get_peft_model(model, lora_config)`,wrap:!1}}),D=new M({props:{title:"OLoRA",local:"olora",headingTag:"h3"}}),ee=new f({props:{code:"ZnJvbSUyMHBlZnQlMjBpbXBvcnQlMjBMb3JhQ29uZmlnJTBBY29uZmlnJTIwJTNEJTIwTG9yYUNvbmZpZyhpbml0X2xvcmFfd2VpZ2h0cyUzRCUyMm9sb3JhJTIyJTJDJTIwLi4uKQ==",highlighted:`<span class="hljs-keyword">from</span> peft <span class="hljs-keyword">import</span> LoraConfig
config = LoraConfig(init_lora_weights=<span class="hljs-string">&quot;olora&quot;</span>, ...)`,wrap:!1}}),ae=new M({props:{title:"EVA",local:"eva",headingTag:"h3"}}),se=new f({props:{code:"ZnJvbSUyMHBlZnQlMjBpbXBvcnQlMjBMb3JhQ29uZmlnJTJDJTIwRXZhQ29uZmlnJTBBcGVmdF9jb25maWclMjAlM0QlMjBMb3JhQ29uZmlnKCUwQSUyMCUyMCUyMCUyMGluaXRfbG9yYV93ZWlnaHRzJTIwJTNEJTIwJTIyZXZhJTIyJTJDJTBBJTIwJTIwJTIwJTIwZXZhX2NvbmZpZyUyMCUzRCUyMEV2YUNvbmZpZyhyaG8lMjAlM0QlMjAyLjApJTJDJTBBJTIwJTIwJTIwJTIwLi4uJTBBKQ==",highlighted:`<span class="hljs-keyword">from</span> peft <span class="hljs-keyword">import</span> LoraConfig, EvaConfig
peft_config = LoraConfig(
    init_lora_weights = <span class="hljs-string">&quot;eva&quot;</span>,
    eva_config = EvaConfig(rho = <span class="hljs-number">2.0</span>),
    ...
)`,wrap:!1}}),re=new f({props:{code:"cGVmdF9tb2RlbCUyMCUzRCUyMGdldF9wZWZ0X21vZGVsKG1vZGVsJTJDJTIwcGVmdF9jb25maWclMkMlMjBsb3dfY3B1X21lbV91c2FnZSUzRFRydWUp",highlighted:'peft_model = get_peft_model(model, peft_config, low_cpu_mem_usage=<span class="hljs-literal">True</span>)',wrap:!1}}),pe=new f({props:{code:"aW5pdGlhbGl6ZV9sb3JhX2V2YV93ZWlnaHRzKHBlZnRfbW9kZWwlMkMlMjBkYXRhbG9hZGVyKQ==",highlighted:"initialize_lora_eva_weights(peft_model, dataloader)",wrap:!1}}),ce=new M({props:{title:"LoftQ",local:"loftq",headingTag:"h3"}}),he=new M({props:{title:"Standard approach",local:"standard-approach",headingTag:"h4"}}),fe=new M({props:{title:"Rank-stabilized LoRA",local:"rank-stabilized-lora",headingTag:"h3"}}),we=new f({props:{code:"ZnJvbSUyMHBlZnQlMjBpbXBvcnQlMjBMb3JhQ29uZmlnJTBBJTBBY29uZmlnJTIwJTNEJTIwTG9yYUNvbmZpZyh1c2VfcnNsb3JhJTNEVHJ1ZSUyQyUyMC4uLik=",highlighted:`<span class="hljs-keyword">from</span> peft <span class="hljs-keyword">import</span> LoraConfig

config = LoraConfig(use_rslora=<span class="hljs-literal">True</span>, ...)`,wrap:!1}}),ye=new M({props:{title:"LoRA-GA",local:"lora-ga",headingTag:"h3"}}),ge=new f({props:{code:"ZnJvbSUyMHBlZnQudHVuZXJzLmxvcmElMjBpbXBvcnQlMjBwcmVwcm9jZXNzX2xvcmFnYSUwQSUwQWRlZiUyMHRyYWluX3N0ZXAoKSUzQSUwQSUyMCUyMCUyMCUyMCUyMiUyMiUyMlJ1biUyMGZvcndhcmQlMjBhbmQlMjBiYWNrd2FyZCUyMHBhc3NlcyUyMGZvciUyMGdyYWRpZW50JTIwZXN0aW1hdGlvbi4lMjIlMjIlMjIlMEElMjAlMjAlMjAlMjBkYXRhbG9hZGVyX2l0ZXIlMjAlM0QlMjBpdGVyKGdyYWRfZGF0YWxvYWRlciklMEElMjAlMjAlMjAlMjBmb3IlMjBfJTIwaW4lMjByYW5nZShOKSUzQSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGJhdGNoJTIwJTNEJTIwbmV4dChkYXRhbG9hZGVyX2l0ZXIpJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwYmF0Y2glMjAlM0QlMjAlN0JrJTNBJTIwdi50byhkZXZpY2UpJTIwZm9yJTIwayUyQyUyMHYlMjBpbiUyMGJhdGNoLml0ZW1zKCklN0QlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBvdXRwdXRzJTIwJTNEJTIwbW9kZWwoKipiYXRjaCklMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBsb3NzJTIwJTNEJTIwb3V0cHV0cy5sb3NzJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwbG9zcy5iYWNrd2FyZCgpJTBBJTBBcHJlcHJvY2Vzc19sb3JhZ2EobW9kZWwlMkMlMjBsb3JhX2NvbmZpZyUyQyUyMHRyYWluX3N0ZXAp",highlighted:`<span class="hljs-keyword">from</span> peft.tuners.lora <span class="hljs-keyword">import</span> preprocess_loraga

<span class="hljs-keyword">def</span> <span class="hljs-title function_">train_step</span>():
    <span class="hljs-string">&quot;&quot;&quot;Run forward and backward passes for gradient estimation.&quot;&quot;&quot;</span>
    dataloader_iter = <span class="hljs-built_in">iter</span>(grad_dataloader)
    <span class="hljs-keyword">for</span> _ <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(N):
        batch = <span class="hljs-built_in">next</span>(dataloader_iter)
        batch = {k: v.to(device) <span class="hljs-keyword">for</span> k, v <span class="hljs-keyword">in</span> batch.items()}
        outputs = model(**batch)
        loss = outputs.loss
        loss.backward()

preprocess_loraga(model, lora_config, train_step)`,wrap:!1}}),Je=new M({props:{title:"Variants",local:"variants",headingTag:"h2"}}),je=new M({props:{title:"Weight-Decomposed Low-Rank Adaptation (DoRA)",local:"weight-decomposed-low-rank-adaptation-dora",headingTag:"h3"}}),ke=new f({props:{code:"ZnJvbSUyMHBlZnQlMjBpbXBvcnQlMjBMb3JhQ29uZmlnJTBBJTBBY29uZmlnJTIwJTNEJTIwTG9yYUNvbmZpZyh1c2VfZG9yYSUzRFRydWUlMkMlMjAuLi4p",highlighted:`<span class="hljs-keyword">from</span> peft <span class="hljs-keyword">import</span> LoraConfig

config = LoraConfig(use_dora=<span class="hljs-literal">True</span>, ...)`,wrap:!1}}),Ze=new f({props:{code:"ZnJvbSUyMHBlZnQlMjBpbXBvcnQlMjBMb3JhQ29uZmlnJTJDJTIwTG9yYVJ1bnRpbWVDb25maWclMEElMEFjb25maWclMjAlM0QlMjBMb3JhQ29uZmlnKHVzZV9kb3JhJTNEVHJ1ZSUyQyUyMHJ1bnRpbWVfY29uZmlnJTNETG9yYVJ1bnRpbWVDb25maWcoZXBoZW1lcmFsX2dwdV9vZmZsb2FkJTNEVHJ1ZSklMkMlMjAuLi4p",highlighted:`<span class="hljs-keyword">from</span> peft <span class="hljs-keyword">import</span> LoraConfig, LoraRuntimeConfig

config = LoraConfig(use_dora=<span class="hljs-literal">True</span>, runtime_config=LoraRuntimeConfig(ephemeral_gpu_offload=<span class="hljs-literal">True</span>), ...)`,wrap:!1}}),Be=new f({props:{code:"ZnJvbSUyMHBlZnQlMjBpbXBvcnQlMjBQZWZ0TW9kZWwlMEElMEFtb2RlbCUyMCUzRCUyMFBlZnRNb2RlbC5mcm9tX3ByZXRyYWluZWQoYmFzZV9tb2RlbCUyQyUyMHBlZnRfbW9kZWxfaWQlMkMlMjBlcGhlbWVyYWxfZ3B1X29mZmxvYWQlM0RUcnVlKQ==",highlighted:`<span class="hljs-keyword">from</span> peft <span class="hljs-keyword">import</span> PeftModel

model = PeftModel.from_pretrained(base_model, peft_model_id, ephemeral_gpu_offload=<span class="hljs-literal">True</span>)`,wrap:!1}}),$e=new M({props:{title:"Optimization",local:"optimization",headingTag:"h4"}}),Le=new f({props:{code:"ZnJvbSUyMHBlZnQuaGVscGVycyUyMGltcG9ydCUyMERvcmFDYWNoaW5nJTBBJTBBbW9kZWwuZXZhbCgpJTBBd2l0aCUyMERvcmFDYWNoaW5nKCklM0ElMEElMjAlMjAlMjAlMjBvdXRwdXQlMjAlM0QlMjBtb2RlbChpbnB1dHMp",highlighted:`<span class="hljs-keyword">from</span> peft.helpers <span class="hljs-keyword">import</span> DoraCaching

model.<span class="hljs-built_in">eval</span>()
<span class="hljs-keyword">with</span> DoraCaching():
    output = model(inputs)`,wrap:!1}}),Ve=new M({props:{title:"Caveats",local:"caveats",headingTag:"h4"}}),Fe=new M({props:{title:"Training",local:"training",headingTag:"h2"}}),Ee=new M({props:{title:"QLoRA-style training",local:"qlora-style-training",headingTag:"h3"}}),Ye=new f({props:{code:"Y29uZmlnJTIwJTNEJTIwTG9yYUNvbmZpZyh0YXJnZXRfbW9kdWxlcyUzRCUyMmFsbC1saW5lYXIlMjIlMkMlMjAuLi4p",highlighted:'config = LoraConfig(target_modules=<span class="hljs-string">&quot;all-linear&quot;</span>, ...)',wrap:!1}}),ze=new M({props:{title:"Memory efficient Layer Replication with LoRA",local:"memory-efficient-layer-replication-with-lora",headingTag:"h3"}}),Se=new f({props:{code:"Y29uZmlnJTIwJTNEJTIwTG9yYUNvbmZpZyhsYXllcl9yZXBsaWNhdGlvbiUzRCU1QiU1QjAlMkM0JTVEJTJDJTIwJTVCMiUyQzUlNUQlNUQlMkMlMjAuLi4p",highlighted:'config = LoraConfig(layer_replication=[[<span class="hljs-number">0</span>,<span class="hljs-number">4</span>], [<span class="hljs-number">2</span>,<span class="hljs-number">5</span>]], ...)',wrap:!1}}),Ke=new M({props:{title:"Fine grained control over ranks and alpha (scaling)",local:"fine-grained-control-over-ranks-and-alpha-scaling",headingTag:"h3"}}),tt=new f({props:{code:"cHJpbnQobW9kZWwp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(model)
Outer(
  (foo): Linear(...)
  (module): Middle(
    (foo): Linear(...)
    (foobar): Linear(...)
    (module): Inner(
      (foo): Linear(...)
      (barfoo): Linear(...)
    )
  )
)`,wrap:!1}}),nt=new M({props:{title:"Targeting nn.Parameter directly",local:"targeting-nnparameter-directly",headingTag:"h3"}}),rt=new M({props:{title:"Caveats",local:"caveats",headingTag:"h4"}}),pt=new M({props:{title:"MoE expert parameters and vLLM",local:"moe-expert-parameters-and-vllm",headingTag:"h4"}}),ct=new f({props:{code:"bnVtX2V4cGVydHMlMjAlM0QlMjBnZXRhdHRyKG1vZGVsLmNvbmZpZyUyQyUyMCUyMm51bV9sb2NhbF9leHBlcnRzJTIyJTJDJTIwTm9uZSklMjBvciUyMG1vZGVsLmNvbmZpZy5udW1fZXhwZXJ0cyUwQWVmZmVjdGl2ZV9yJTIwJTNEJTIwbWF4KDElMkMlMjByJTIwJTJGJTJGJTIwbnVtX2V4cGVydHMpJTBBY29uZmlnJTIwJTNEJTIwTG9yYUNvbmZpZyglMEElMjAlMjAlMjAlMjByJTNEciUyQyUwQSUyMCUyMCUyMCUyMGxvcmFfYWxwaGElM0QzMiUyQyUwQSUyMCUyMCUyMCUyMHRhcmdldF9tb2R1bGVzJTNEJTVCJTIycV9wcm9qJTIyJTJDJTIwJTIydl9wcm9qJTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwdGFyZ2V0X3BhcmFtZXRlcnMlM0QlNUIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjMlMjBNaXh0cmFsJTIwJTJGJTIwUXdlbjMtTW9FJTIwJTJGJTIwR1BULU9TUyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMm1scC5leHBlcnRzLmdhdGVfdXBfcHJvaiUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMm1scC5leHBlcnRzLmRvd25fcHJvaiUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMyUyMExsYW1hNCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMyUyMCUyMmZlZWRfZm9yd2FyZC5leHBlcnRzLmdhdGVfdXBfcHJvaiUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMyUyMCUyMmZlZWRfZm9yd2FyZC5leHBlcnRzLmRvd25fcHJvaiUyMiUyQyUwQSUyMCUyMCUyMCUyMCU1RCUyQyUwQSUyMCUyMCUyMCUyMHJhbmtfcGF0dGVybiUzRCU3QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMmV4cGVydHMuZ2F0ZV91cF9wcm9qJTIyJTNBJTIwZWZmZWN0aXZlX3IlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJleHBlcnRzLmRvd25fcHJvaiUyMiUzQSUyMGVmZmVjdGl2ZV9yJTJDJTBBJTIwJTIwJTIwJTIwJTdEJTJDJTBBKQ==",highlighted:`num_experts = <span class="hljs-built_in">getattr</span>(model.config, <span class="hljs-string">&quot;num_local_experts&quot;</span>, <span class="hljs-literal">None</span>) <span class="hljs-keyword">or</span> model.config.num_experts
effective_r = <span class="hljs-built_in">max</span>(<span class="hljs-number">1</span>, r // num_experts)
config = LoraConfig(
    r=r,
    lora_alpha=<span class="hljs-number">32</span>,
    target_modules=[<span class="hljs-string">&quot;q_proj&quot;</span>, <span class="hljs-string">&quot;v_proj&quot;</span>],
    target_parameters=[
        <span class="hljs-comment"># Mixtral / Qwen3-MoE / GPT-OSS</span>
        <span class="hljs-string">&quot;mlp.experts.gate_up_proj&quot;</span>,
        <span class="hljs-string">&quot;mlp.experts.down_proj&quot;</span>,
        <span class="hljs-comment"># Llama4</span>
        <span class="hljs-comment"># &quot;feed_forward.experts.gate_up_proj&quot;,</span>
        <span class="hljs-comment"># &quot;feed_forward.experts.down_proj&quot;,</span>
    ],
    rank_pattern={
        <span class="hljs-string">&quot;experts.gate_up_proj&quot;</span>: effective_r,
        <span class="hljs-string">&quot;experts.down_proj&quot;</span>: effective_r,
    },
)`,wrap:!1}}),ft=new M({props:{title:"Efficiently train tokens alongside LoRA",local:"efficiently-train-tokens-alongside-lora",headingTag:"h3"}}),wt=new f({props:{code:"JTIzJTIwZm9yJTIwbGF5ZXIlMjAnZW1iZWRfdG9rZW5zJyUwQWNvbmZpZyUyMCUzRCUyMExvcmFDb25maWcodHJhaW5hYmxlX3Rva2VuX2luZGljZXMlM0QlNUJpZHhfMSUyQyUyMGlkeF8yJTJDJTIwLi4uJTVEJTJDJTIwLi4uKSUwQSUwQSUyMyUyMHNwZWNpZmljJTIwZW1iZWRkaW5nJTIwbGF5ZXIlMEFjb25maWclMjAlM0QlMjBMb3JhQ29uZmlnKHRyYWluYWJsZV90b2tlbl9pbmRpY2VzJTNEJTdCJ2VtYl90b2tlbnMnJTNBJTIwJTVCaWR4XzElMkMlMjBpZHhfMiUyQyUyMC4uLiU1RCU3RCUyQyUyMC4uLik=",highlighted:`<span class="hljs-comment"># for layer &#x27;embed_tokens&#x27;</span>
config = LoraConfig(trainable_token_indices=[idx_1, idx_2, ...], ...)

<span class="hljs-comment"># specific embedding layer</span>
config = LoraConfig(trainable_token_indices={<span class="hljs-string">&#x27;emb_tokens&#x27;</span>: [idx_1, idx_2, ...]}, ...)`,wrap:!1}}),Tt=new f({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBBdXRvTW9kZWxGb3JDYXVzYWxMTSUwQWZyb20lMjBwZWZ0JTIwaW1wb3J0JTIwZ2V0X3BlZnRfbW9kZWwlMkMlMjBMb3JhQ29uZmlnJTBBJTBBYmFzZV9tb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNLmZyb21fcHJldHJhaW5lZCglMjJtaXN0cmFsYWklMkZNaXN0cmFsLTdCLXYwLjElMjIpJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIybWlzdHJhbGFpJTJGTWlzdHJhbC03Qi12MC4xJTIyKSUwQSUwQSUyMyUyMHdlJTIwZGVmaW5lJTIwb3VyJTIwbmV3JTIwdG9rZW5zJTIwYW5kJTIwYWRkJTIwdGhlbSUyMHRvJTIwdGhlJTIwdG9rZW5pemVyJTIwYXMlMjBzcGVjaWFsJTIwdG9rZW5zJTBBc3BlY2lhbF90b2tlbnMlMjAlM0QlMjAlNUInJTNDJTdDc3RhcnRfdGhpbmslN0MlM0UnJTJDJTIwJyUzQyU3Q3N0b3BfdGhpbmslN0MlM0UnJTVEJTBBdG9rZW5pemVyLmFkZF9zcGVjaWFsX3Rva2VucyglN0InYWRkaXRpb25hbF9zcGVjaWFsX3Rva2VucyclM0ElMjBzcGVjaWFsX3Rva2VucyU3RCklMEElMEElMjMlMjBtYWtlJTIwcm9vbSUyMGZvciUyMG5ldyUyMHRva2VucyUyMGluJTIwdGhlJTIwZW1iZWRkaW5nJTIwbWF0cml4JTIwaWYlMjBpdCUyMGlzbid0JTIwYmlnJTIwZW5vdWdoJTIwYWxyZWFkeSUwQWJhc2VfbW9kZWwucmVzaXplX3Rva2VuX2VtYmVkZGluZ3MobWF4KGxlbih0b2tlbml6ZXIpJTJDJTIwYmFzZV9tb2RlbC5tb2RlbC5lbWJlZF90b2tlbnMubnVtX2VtYmVkZGluZ3MpKSUwQSUwQSUyMyUyMHR5cGljYWwlMjBMb1JBJTIwY29uZmlnJTIwd2l0aCUyMCU2MHRyYWluYWJsZV90b2tlbl9pbmRpY2VzJTYwJTIwdGFyZ2V0aW5nJTIwZW1iZWRkaW5nJTIwbGF5ZXIlMjAlNjBlbWJlZF90b2tlbnMlNjAlMEElMjMlMjBhbmQlMjBzcGVjaWZpY2FsbHklMjBvdXIlMjBuZXclMjB0b2tlbnMlMjB3ZSUyMGp1c3QlMjBhZGRlZCUwQWxvcmFfY29uZmlnJTIwJTNEJTIwTG9yYUNvbmZpZyglMEElMjAlMjAlMjAlMjB0YXJnZXRfbW9kdWxlcyUzRCdhbGwtbGluZWFyJyUyQyUwQSUyMCUyMCUyMCUyMHRyYWluYWJsZV90b2tlbl9pbmRpY2VzJTNEJTdCJ2VtYmVkX3Rva2VucyclM0ElMjB0b2tlbml6ZXIuY29udmVydF90b2tlbnNfdG9faWRzKHNwZWNpYWxfdG9rZW5zKSU3RCUyQyUwQSklMEFwZWZ0X21vZGVsJTIwJTNEJTIwZ2V0X3BlZnRfbW9kZWwoYmFzZV9tb2RlbCUyQyUyMGxvcmFfY29uZmlnKSUwQSUwQSUyMyUyMHByb2NlZWQlMjB0byUyMHRyYWluJTIwdGhlJTIwbW9kZWwlMjBsaWtlJTIwbm9ybWFsJTBBJTVCLi4uJTVE",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, AutoModelForCausalLM
<span class="hljs-keyword">from</span> peft <span class="hljs-keyword">import</span> get_peft_model, LoraConfig

base_model = AutoModelForCausalLM.from_pretrained(<span class="hljs-string">&quot;mistralai/Mistral-7B-v0.1&quot;</span>)
tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;mistralai/Mistral-7B-v0.1&quot;</span>)

<span class="hljs-comment"># we define our new tokens and add them to the tokenizer as special tokens</span>
special_tokens = [<span class="hljs-string">&#x27;&lt;|start_think|&gt;&#x27;</span>, <span class="hljs-string">&#x27;&lt;|stop_think|&gt;&#x27;</span>]
tokenizer.add_special_tokens({<span class="hljs-string">&#x27;additional_special_tokens&#x27;</span>: special_tokens})

<span class="hljs-comment"># make room for new tokens in the embedding matrix if it isn&#x27;t big enough already</span>
base_model.resize_token_embeddings(<span class="hljs-built_in">max</span>(<span class="hljs-built_in">len</span>(tokenizer), base_model.model.embed_tokens.num_embeddings))

<span class="hljs-comment"># typical LoRA config with \`trainable_token_indices\` targeting embedding layer \`embed_tokens\`</span>
<span class="hljs-comment"># and specifically our new tokens we just added</span>
lora_config = LoraConfig(
    target_modules=<span class="hljs-string">&#x27;all-linear&#x27;</span>,
    trainable_token_indices={<span class="hljs-string">&#x27;embed_tokens&#x27;</span>: tokenizer.convert_tokens_to_ids(special_tokens)},
)
peft_model = get_peft_model(base_model, lora_config)

<span class="hljs-comment"># proceed to train the model like normal</span>
[...]`,wrap:!1}}),_t=new M({props:{title:"Weight tying",local:"weight-tying",headingTag:"h3"}}),Ut=new M({props:{title:"modules_to_save",local:"modulestosave",headingTag:"h4"}}),Ct=new M({props:{title:"target_modules",local:"targetmodules",headingTag:"h4"}}),$t=new M({props:{title:"trainable_token_indices",local:"trainabletokenindices",headingTag:"h4"}}),At=new M({props:{title:"Optimizers",local:"optimizers",headingTag:"h2"}}),xt=new M({props:{title:"LoRA-FA Optimizer",local:"lora-fa-optimizer",headingTag:"h3"}}),Xt=new f({props:{code:"ZnJvbSUyMHBlZnQlMjBpbXBvcnQlMjBMb3JhQ29uZmlnJTJDJTIwZ2V0X3BlZnRfbW9kZWwlMEFmcm9tJTIwcGVmdC5vcHRpbWl6ZXJzJTIwaW1wb3J0JTIwY3JlYXRlX2xvcmFmYV9vcHRpbWl6ZXIlMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwVHJhaW5lciUyQyUyMGdldF9jb3NpbmVfc2NoZWR1bGVfd2l0aF93YXJtdXAlMEElMEFiYXNlX21vZGVsJTIwJTNEJTIwQXV0b01vZGVsRm9yQ2F1c2FsTE0uZnJvbV9wcmV0cmFpbmVkKCUyMm1ldGEtbGxhbWElMkZNZXRhLUxsYW1hLTMtOEItSW5zdHJ1Y3QlMjIpJTBBJTBBY29uZmlnJTIwJTNEJTIwTG9yYUNvbmZpZyguLi4pJTBBbW9kZWwlMjAlM0QlMjBnZXRfcGVmdF9tb2RlbChiYXNlX21vZGVsJTJDJTIwY29uZmlnKSUwQSUwQW9wdGltaXplciUyMCUzRCUyMGNyZWF0ZV9sb3JhZmFfb3B0aW1pemVyKCUwQSUyMCUyMCUyMCUyMG1vZGVsJTNEbW9kZWwlMkMlMEElMjAlMjAlMjAlMjByJTNEMTI4JTJDJTBBJTIwJTIwJTIwJTIwbG9yYV9hbHBoYSUzRDMyJTJDJTBBJTIwJTIwJTIwJTIwbHIlM0Q3ZS01JTJDJTBBKSUwQSUwQXNjaGVkdWxlciUyMCUzRCUyMGdldF9jb3NpbmVfc2NoZWR1bGVfd2l0aF93YXJtdXAoJTBBJTIwJTIwJTIwJTIwb3B0aW1pemVyJTJDJTBBJTIwJTIwJTIwJTIwbnVtX3dhcm11cF9zdGVwcyUzRDEwMCUyQyUwQSUyMCUyMCUyMCUyMG51bV90cmFpbmluZ19zdGVwcyUzRDEwMDAlMkMlMEEpJTBBJTBBdHJhaW5lciUyMCUzRCUyMFRyYWluZXIoJTBBJTIwJTIwJTIwJTIwLi4uJTJDJTBBJTIwJTIwJTIwJTIwb3B0aW1pemVycyUzRChvcHRpbWl6ZXIlMkMlMjBzY2hlZHVsZXIpJTJDJTBBKQ==",highlighted:`<span class="hljs-keyword">from</span> peft <span class="hljs-keyword">import</span> LoraConfig, get_peft_model
<span class="hljs-keyword">from</span> peft.optimizers <span class="hljs-keyword">import</span> create_lorafa_optimizer
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> Trainer, get_cosine_schedule_with_warmup

base_model = AutoModelForCausalLM.from_pretrained(<span class="hljs-string">&quot;meta-llama/Meta-Llama-3-8B-Instruct&quot;</span>)

config = LoraConfig(...)
model = get_peft_model(base_model, config)

optimizer = create_lorafa_optimizer(
    model=model,
    r=<span class="hljs-number">128</span>,
    lora_alpha=<span class="hljs-number">32</span>,
    lr=<span class="hljs-number">7e-5</span>,
)

scheduler = get_cosine_schedule_with_warmup(
    optimizer,
    num_warmup_steps=<span class="hljs-number">100</span>,
    num_training_steps=<span class="hljs-number">1000</span>,
)

trainer = Trainer(
    ...,
    optimizers=(optimizer, scheduler),
)`,wrap:!1}}),Ft=new M({props:{title:"LoRA+ optimized LoRA",local:"lora-optimized-lora",headingTag:"h3"}}),Et=new f({props:{code:"JTBBJTBB",highlighted:`<span class="hljs-keyword">from</span> peft <span class="hljs-keyword">import</span> LoraConfig, get_peft_model
<span class="hljs-keyword">from</span> peft.optimizers <span class="hljs-keyword">import</span> create_loraplus_optimizer
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> Trainer
<span class="hljs-keyword">import</span> bitsandbytes <span class="hljs-keyword">as</span> bnb

base_model = ...
config = LoraConfig(...)
model = get_peft_model(base_model, config)

optimizer = create_loraplus_optimizer(
    model=model,
    optimizer_cls=bnb.optim.Adam8bit,
    lr=<span class="hljs-number">5e-5</span>,
    loraplus_lr_ratio=<span class="hljs-number">16</span>,
)
scheduler = <span class="hljs-literal">None</span>

...
trainer = Trainer(
    ...,
    optimizers=(optimizer, scheduler),
)`,wrap:!1}}),Ht=new M({props:{title:"Post-Training",local:"post-training",headingTag:"h2"}}),Qt=new M({props:{title:"Merge LoRA weights into the base model",local:"merge-lora-weights-into-the-base-model",headingTag:"h3"}}),Pt=new f({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNJTBBZnJvbSUyMHBlZnQlMjBpbXBvcnQlMjBQZWZ0TW9kZWwlMEElMEFiYXNlX21vZGVsJTIwJTNEJTIwQXV0b01vZGVsRm9yQ2F1c2FsTE0uZnJvbV9wcmV0cmFpbmVkKCUyMm1pc3RyYWxhaSUyRk1pc3RyYWwtN0ItdjAuMSUyMiklMEFwZWZ0X21vZGVsX2lkJTIwJTNEJTIwJTIyYWxpZ25tZW50LWhhbmRib29rJTJGemVwaHlyLTdiLXNmdC1sb3JhJTIyJTBBbW9kZWwlMjAlM0QlMjBQZWZ0TW9kZWwuZnJvbV9wcmV0cmFpbmVkKGJhc2VfbW9kZWwlMkMlMjBwZWZ0X21vZGVsX2lkKSUwQW1vZGVsJTIwJTNEJTIwbW9kZWwubWVyZ2VfYW5kX3VubG9hZCgp",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM
<span class="hljs-keyword">from</span> peft <span class="hljs-keyword">import</span> PeftModel

base_model = AutoModelForCausalLM.from_pretrained(<span class="hljs-string">&quot;mistralai/Mistral-7B-v0.1&quot;</span>)
peft_model_id = <span class="hljs-string">&quot;alignment-handbook/zephyr-7b-sft-lora&quot;</span>
model = PeftModel.from_pretrained(base_model, peft_model_id)
model = model.merge_and_unload()`,wrap:!1}}),Kt=new f({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNJTBBZnJvbSUyMHBlZnQlMjBpbXBvcnQlMjBQZWZ0TW9kZWwlMEElMEFiYXNlX21vZGVsJTIwJTNEJTIwQXV0b01vZGVsRm9yQ2F1c2FsTE0uZnJvbV9wcmV0cmFpbmVkKCUyMm1pc3RyYWxhaSUyRk1pc3RyYWwtN0ItdjAuMSUyMiklMEFwZWZ0X21vZGVsX2lkJTIwJTNEJTIwJTIyYWxpZ25tZW50LWhhbmRib29rJTJGemVwaHlyLTdiLXNmdC1sb3JhJTIyJTBBbW9kZWwlMjAlM0QlMjBQZWZ0TW9kZWwuZnJvbV9wcmV0cmFpbmVkKGJhc2VfbW9kZWwlMkMlMjBwZWZ0X21vZGVsX2lkKSUwQW1vZGVsLm1lcmdlX2FkYXB0ZXIoKSUwQSUwQSUyMyUyMHVubWVyZ2UlMjB0aGUlMjBMb1JBJTIwbGF5ZXJzJTIwZnJvbSUyMHRoZSUyMGJhc2UlMjBtb2RlbCUwQW1vZGVsLnVubWVyZ2VfYWRhcHRlcigp",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM
<span class="hljs-keyword">from</span> peft <span class="hljs-keyword">import</span> PeftModel

base_model = AutoModelForCausalLM.from_pretrained(<span class="hljs-string">&quot;mistralai/Mistral-7B-v0.1&quot;</span>)
peft_model_id = <span class="hljs-string">&quot;alignment-handbook/zephyr-7b-sft-lora&quot;</span>
model = PeftModel.from_pretrained(base_model, peft_model_id)
model.merge_adapter()

<span class="hljs-comment"># unmerge the LoRA layers from the base model</span>
model.unmerge_adapter()`,wrap:!1}}),ta=new f({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNJTBBZnJvbSUyMHBlZnQlMjBpbXBvcnQlMjBQZWZ0TW9kZWwlMEFpbXBvcnQlMjB0b3JjaCUwQSUwQWJhc2VfbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JDYXVzYWxMTS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIybWlzdHJhbGFpJTJGTWlzdHJhbC03Qi12MC4xJTIyJTJDJTIwZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTJDJTIwZGV2aWNlX21hcCUzRCUyMmF1dG8lMjIlMEEp",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM
<span class="hljs-keyword">from</span> peft <span class="hljs-keyword">import</span> PeftModel
<span class="hljs-keyword">import</span> torch

base_model = AutoModelForCausalLM.from_pretrained(
    <span class="hljs-string">&quot;mistralai/Mistral-7B-v0.1&quot;</span>, dtype=torch.float16, device_map=<span class="hljs-string">&quot;auto&quot;</span>
)`,wrap:!1}}),la=new f({props:{code:"cGVmdF9tb2RlbF9pZCUyMCUzRCUyMCUyMmFsaWdubWVudC1oYW5kYm9vayUyRnplcGh5ci03Yi1zZnQtbG9yYSUyMiUwQW1vZGVsJTIwJTNEJTIwUGVmdE1vZGVsLmZyb21fcHJldHJhaW5lZChiYXNlX21vZGVsJTJDJTIwcGVmdF9tb2RlbF9pZCUyQyUyMGFkYXB0ZXJfbmFtZSUzRCUyMnNmdCUyMik=",highlighted:`peft_model_id = <span class="hljs-string">&quot;alignment-handbook/zephyr-7b-sft-lora&quot;</span>
model = PeftModel.from_pretrained(base_model, peft_model_id, adapter_name=<span class="hljs-string">&quot;sft&quot;</span>)`,wrap:!1}}),sa=new f({props:{code:"d2VpZ2h0ZWRfYWRhcHRlcl9uYW1lJTIwJTNEJTIwJTIyc2Z0LWRwbyUyMiUwQW1vZGVsLmxvYWRfYWRhcHRlciglMjJhbGlnbm1lbnQtaGFuZGJvb2slMkZ6ZXBoeXItN2ItZHBvLWxvcmElMjIlMkMlMjBhZGFwdGVyX25hbWUlM0QlMjJkcG8lMjIpJTBBbW9kZWwuYWRkX3dlaWdodGVkX2FkYXB0ZXIoJTBBJTIwJTIwJTIwJTIwYWRhcHRlcnMlM0QlNUIlMjJzZnQlMjIlMkMlMjAlMjJkcG8lMjIlNUQlMkMlMEElMjAlMjAlMjAlMjB3ZWlnaHRzJTNEJTVCMC43JTJDJTIwMC4zJTVEJTJDJTBBJTIwJTIwJTIwJTIwYWRhcHRlcl9uYW1lJTNEd2VpZ2h0ZWRfYWRhcHRlcl9uYW1lJTJDJTBBJTIwJTIwJTIwJTIwY29tYmluYXRpb25fdHlwZSUzRCUyMmxpbmVhciUyMiUwQSklMEFtb2RlbC5zZXRfYWRhcHRlcih3ZWlnaHRlZF9hZGFwdGVyX25hbWUp",highlighted:`weighted_adapter_name = <span class="hljs-string">&quot;sft-dpo&quot;</span>
model.load_adapter(<span class="hljs-string">&quot;alignment-handbook/zephyr-7b-dpo-lora&quot;</span>, adapter_name=<span class="hljs-string">&quot;dpo&quot;</span>)
model.add_weighted_adapter(
    adapters=[<span class="hljs-string">&quot;sft&quot;</span>, <span class="hljs-string">&quot;dpo&quot;</span>],
    weights=[<span class="hljs-number">0.7</span>, <span class="hljs-number">0.3</span>],
    adapter_name=weighted_adapter_name,
    combination_type=<span class="hljs-string">&quot;linear&quot;</span>
)
model.set_adapter(weighted_adapter_name)`,wrap:!1}}),ia=new f({props:{code:"ZGV2aWNlJTIwJTNEJTIwdG9yY2guYWNjZWxlcmF0b3IuY3VycmVudF9hY2NlbGVyYXRvcigpLnR5cGUlMjBpZiUyMGhhc2F0dHIodG9yY2glMkMlMjAlMjJhY2NlbGVyYXRvciUyMiklMjBlbHNlJTIwJTIyY3VkYSUyMiUwQSUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKCUyMm1pc3RyYWxhaSUyRk1pc3RyYWwtN0ItdjAuMSUyMiklMEElMEFwcm9tcHQlMjAlM0QlMjAlMjJIZXklMkMlMjBhcmUlMjB5b3UlMjBjb25zY2lvdXMlM0YlMjBDYW4lMjB5b3UlMjB0YWxrJTIwdG8lMjBtZSUzRiUyMiUwQWlucHV0cyUyMCUzRCUyMHRva2VuaXplcihwcm9tcHQlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQWlucHV0cyUyMCUzRCUyMCU3QmslM0ElMjB2LnRvKGRldmljZSklMjBmb3IlMjBrJTJDJTIwdiUyMGluJTIwaW5wdXRzLml0ZW1zKCklN0QlMEElMEF3aXRoJTIwdG9yY2gubm9fZ3JhZCgpJTNBJTBBJTIwJTIwJTIwJTIwZ2VuZXJhdGVfaWRzJTIwJTNEJTIwbW9kZWwuZ2VuZXJhdGUoKippbnB1dHMlMkMlMjBtYXhfbGVuZ3RoJTNEMzApJTBBb3V0cHV0cyUyMCUzRCUyMHRva2VuaXplci5iYXRjaF9kZWNvZGUoZ2VuZXJhdGVfaWRzJTJDJTIwc2tpcF9zcGVjaWFsX3Rva2VucyUzRFRydWUlMkMlMjBjbGVhbl91cF90b2tlbml6YXRpb25fc3BhY2VzJTNERmFsc2UpJTVCMCU1RCUwQXByaW50KG91dHB1dHMp",highlighted:`device = torch.accelerator.current_accelerator().<span class="hljs-built_in">type</span> <span class="hljs-keyword">if</span> <span class="hljs-built_in">hasattr</span>(torch, <span class="hljs-string">&quot;accelerator&quot;</span>) <span class="hljs-keyword">else</span> <span class="hljs-string">&quot;cuda&quot;</span>

tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;mistralai/Mistral-7B-v0.1&quot;</span>)

prompt = <span class="hljs-string">&quot;Hey, are you conscious? Can you talk to me?&quot;</span>
inputs = tokenizer(prompt, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
inputs = {k: v.to(device) <span class="hljs-keyword">for</span> k, v <span class="hljs-keyword">in</span> inputs.items()}

<span class="hljs-keyword">with</span> torch.no_grad():
    generate_ids = model.generate(**inputs, max_length=<span class="hljs-number">30</span>)
outputs = tokenizer.batch_decode(generate_ids, skip_special_tokens=<span class="hljs-literal">True</span>, clean_up_tokenization_spaces=<span class="hljs-literal">False</span>)[<span class="hljs-number">0</span>]
<span class="hljs-built_in">print</span>(outputs)`,wrap:!1}}),ra=new M({props:{title:"Recovering base model performance via intruder dimension reduction",local:"recovering-base-model-performance-via-intruder-dimension-reduction",headingTag:"h3"}}),ca=new f({props:{code:"ZnJvbSUyMHBlZnQudHVuZXJzLmxvcmEuaW50cnVkZXJzJTIwaW1wb3J0JTIwcmVkdWNlX2ludHJ1ZGVyX2RpbWVuc2lvbiUwQSUwQXBlZnRfbW9kZWwlMjAlM0QlMjBBdXRvUGVmdE1vZGVsRm9yQ2F1c2FsTE0uZnJvbV9wcmV0cmFpbmVkKCdodWJuZW1vJTJGbGxhbWEtMy4yYi1tZXRhbWF0aHFhLWxvcmE2NCcpJTBBJTBBcmVkdWNlX2ludHJ1ZGVyX2RpbWVuc2lvbiglMEElMjAlMjAlMjAlMjBwZWZ0X21vZGVsJTJDJTBBJTIwJTIwJTIwJTIwbWl0aWdhdGlvbl9sYW1iZGElM0QwLjc1JTJDJTBBKSUwQSUwQXBlZnRfbW9kZWwuZ2VuZXJhdGUoLi4uKQ==",highlighted:`<span class="hljs-keyword">from</span> peft.tuners.lora.intruders <span class="hljs-keyword">import</span> reduce_intruder_dimension

peft_model = AutoPeftModelForCausalLM.from_pretrained(<span class="hljs-string">&#x27;hubnemo/llama-3.2b-metamathqa-lora64&#x27;</span>)

reduce_intruder_dimension(
    peft_model,
    mitigation_lambda=<span class="hljs-number">0.75</span>,
)

peft_model.generate(...)`,wrap:!1}}),fa=new M({props:{title:"Load adapters",local:"load-adapters",headingTag:"h2"}}),wa=new f({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNJTBBZnJvbSUyMHBlZnQlMjBpbXBvcnQlMjBQZWZ0TW9kZWwlMEElMEFiYXNlX21vZGVsJTIwJTNEJTIwQXV0b01vZGVsRm9yQ2F1c2FsTE0uZnJvbV9wcmV0cmFpbmVkKCUyMm1pc3RyYWxhaSUyRk1pc3RyYWwtN0ItdjAuMSUyMiklMEFwZWZ0X21vZGVsX2lkJTIwJTNEJTIwJTIyYWxpZ25tZW50LWhhbmRib29rJTJGemVwaHlyLTdiLXNmdC1sb3JhJTIyJTBBbW9kZWwlMjAlM0QlMjBQZWZ0TW9kZWwuZnJvbV9wcmV0cmFpbmVkKGJhc2VfbW9kZWwlMkMlMjBwZWZ0X21vZGVsX2lkKSUwQSUwQSUyMyUyMGxvYWQlMjBkaWZmZXJlbnQlMjBhZGFwdGVyJTBBbW9kZWwubG9hZF9hZGFwdGVyKCUyMmFsaWdubWVudC1oYW5kYm9vayUyRnplcGh5ci03Yi1kcG8tbG9yYSUyMiUyQyUyMGFkYXB0ZXJfbmFtZSUzRCUyMmRwbyUyMiklMEElMEElMjMlMjBzZXQlMjBhZGFwdGVyJTIwYXMlMjBhY3RpdmUlMEFtb2RlbC5zZXRfYWRhcHRlciglMjJkcG8lMjIp",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM
<span class="hljs-keyword">from</span> peft <span class="hljs-keyword">import</span> PeftModel

base_model = AutoModelForCausalLM.from_pretrained(<span class="hljs-string">&quot;mistralai/Mistral-7B-v0.1&quot;</span>)
peft_model_id = <span class="hljs-string">&quot;alignment-handbook/zephyr-7b-sft-lora&quot;</span>
model = PeftModel.from_pretrained(base_model, peft_model_id)

<span class="hljs-comment"># load different adapter</span>
model.load_adapter(<span class="hljs-string">&quot;alignment-handbook/zephyr-7b-dpo-lora&quot;</span>, adapter_name=<span class="hljs-string">&quot;dpo&quot;</span>)

<span class="hljs-comment"># set adapter as active</span>
model.set_adapter(<span class="hljs-string">&quot;dpo&quot;</span>)`,wrap:!1}}),Ta=new f({props:{code:"JTIzJTIwdW5sb2FkJTIwYWRhcHRlciUwQW1vZGVsJTIwJTNEJTIwbW9kZWwudW5sb2FkKCklMEElMEElMjMlMjBkZWxldGUlMjBhZGFwdGVyJTBBbW9kZWwuZGVsZXRlX2FkYXB0ZXIoJTIyZHBvJTIyKQ==",highlighted:`<span class="hljs-comment"># unload adapter</span>
model = model.unload()

<span class="hljs-comment"># delete adapter</span>
model.delete_adapter(<span class="hljs-string">&quot;dpo&quot;</span>)`,wrap:!1}}),ba=new M({props:{title:"Tensor Parallelism",local:"tensor-parallelism",headingTag:"h2"}}),_a=new f({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNJTBBZnJvbSUyMHBlZnQlMjBpbXBvcnQlMjBnZXRfcGVmdF9tb2RlbCUyQyUyMExvcmFDb25maWclMEElMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNLmZyb21fcHJldHJhaW5lZCglMjJtZXRhLWxsYW1hJTJGTGxhbWEtMy4xLThCJTIyJTJDJTIwdHBfcGxhbiUzRCUyMmF1dG8lMjIpJTBBbG9yYV9jb25maWclMjAlM0QlMjBMb3JhQ29uZmlnKHIlM0QxNiUyQyUyMHRhcmdldF9tb2R1bGVzJTNEJTVCJTIycV9wcm9qJTIyJTJDJTIwJTIydl9wcm9qJTIyJTVEKSUwQW1vZGVsJTIwJTNEJTIwZ2V0X3BlZnRfbW9kZWwobW9kZWwlMkMlMjBsb3JhX2NvbmZpZyk=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM
<span class="hljs-keyword">from</span> peft <span class="hljs-keyword">import</span> get_peft_model, LoraConfig

model = AutoModelForCausalLM.from_pretrained(<span class="hljs-string">&quot;meta-llama/Llama-3.1-8B&quot;</span>, tp_plan=<span class="hljs-string">&quot;auto&quot;</span>)
lora_config = LoraConfig(r=<span class="hljs-number">16</span>, target_modules=[<span class="hljs-string">&quot;q_proj&quot;</span>, <span class="hljs-string">&quot;v_proj&quot;</span>])
model = get_peft_model(model, lora_config)`,wrap:!1}}),va=new M({props:{title:"Inference",local:"inference",headingTag:"h2"}}),Ua=new M({props:{title:"Activated LoRA (aLoRA)",local:"activated-lora-alora",headingTag:"h3"}}),Ba=new f({props:{code:"ZnJvbSUyMHBlZnQlMjBpbXBvcnQlMjBMb3JhQ29uZmlnJTBBJTBBY29uZmlnJTIwJTNEJTIwTG9yYUNvbmZpZyhhbG9yYV9pbnZvY2F0aW9uX3Rva2VucyUzRGFsb3JhX2ludm9jYXRpb25fdG9rZW5zJTJDJTIwdGFza190eXBlJTNEJTIyQ0FVU0FMX0xNJTIyJTJDJTIwLi4uKQ==",highlighted:`<span class="hljs-keyword">from</span> peft <span class="hljs-keyword">import</span> LoraConfig

config = LoraConfig(alora_invocation_tokens=alora_invocation_tokens, task_type=<span class="hljs-string">&quot;CAUSAL_LM&quot;</span>, ...)`,wrap:!1}}),Ia=new f({props:{code:"aW52b2NhdGlvbl9zdHJpbmclMjAlM0QlMjAlMjJwbGFjZWhvbGRlciUyMiUwQWFsb3JhX2ludm9jYXRpb25fdG9rZW5zJTIwJTNEJTIwdG9rZW5pemVyLmVuY29kZShpbnZvY2F0aW9uX3N0cmluZyUyQyUyMGFkZF9zcGVjaWFsX3Rva2VucyUzREZhbHNlKS4=",highlighted:`invocation_string = <span class="hljs-string">&quot;placeholder&quot;</span>
alora_invocation_tokens = tokenizer.encode(invocation_string, add_special_tokens=<span class="hljs-literal">False</span>).`,wrap:!1}}),Aa=new M({props:{title:"Choice of invocation sequence and SFT design",local:"choice-of-invocation-sequence-and-sft-design",headingTag:"h4"}}),Fa=new f({props:{code:"YWxvcmFfaW52b2NhdGlvbl90b2tlbnMlMjAlM0QlMjB0b2tlbml6ZXIuZW5jb2RlKGludm9jYXRpb25fc3RyaW5nJTJDJTIwYWRkX3NwZWNpYWxfdG9rZW5zJTNERmFsc2UpLg==",highlighted:'alora_invocation_tokens = tokenizer.encode(invocation_string, add_special_tokens=<span class="hljs-literal">False</span>).',wrap:!1}}),Ha=new M({props:{title:"Using (and reusing) cache for generation",local:"using-and-reusing-cache-for-generation",headingTag:"h4"}}),Sa=new f({props:{code:"JTBB",highlighted:`<span class="hljs-keyword">from</span> transformers import DynamicCache
<span class="hljs-built_in">..</span>.
cache = DynamicCache()
inputs_base = tokenizer(prompt_base, <span class="hljs-attribute">return_tensors</span>=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-comment"># Generate from base model and save cache</span>
with model_alora.disable_adapter():
    output = model_alora.generate(inputs_base[<span class="hljs-string">&quot;input_ids&quot;</span>].<span class="hljs-keyword">to</span>(device),<span class="hljs-attribute">attention_mask</span>=inputs_base[<span class="hljs-string">&quot;attention_mask&quot;</span>].<span class="hljs-keyword">to</span>(device),past_key_values = cache,<span class="hljs-attribute">return_dict_in_generate</span>=<span class="hljs-literal">True</span>)
output_text_base = tokenizer.decode(output.sequences[0])
cache = output.past_key_values

<span class="hljs-comment"># Generate with aLoRA adapter from cache</span>
prompt_alora = output_text + INVOCATION_STRING
inputs_alora = tokenizer(prompt_alora, <span class="hljs-attribute">return_tensors</span>=<span class="hljs-string">&quot;pt&quot;</span>).to(device)
output = model_alora.generate(**inputs_alora, <span class="hljs-attribute">past_key_values</span>=cache)
output_text_alora = tokenizer.decode(output[0])

<span class="hljs-comment"># <span class="hljs-doctag">Note:</span> cache is now tainted with adapter values and cannot be used in base model from here on!</span>`,wrap:!1}}),Da=new f({props:{code:"JTBBJTBB",highlighted:`<span class="hljs-keyword">from</span> transformers import DynamicCache
import copy
<span class="hljs-built_in">..</span>.
cache = DynamicCache()
inputs_shared = tokenizer(prompt_shared, <span class="hljs-attribute">return_tensors</span>=<span class="hljs-string">&quot;pt&quot;</span>).to(device)

<span class="hljs-comment"># Prefill from base model and save cache</span>
with model_alora.disable_adapter():
    with torch.no_grad():
        model_alora(**inputs_shared, <span class="hljs-attribute">past_key_values</span>=cache)
cache_copy = copy.deepcopy(cache)

<span class="hljs-comment"># Generate from aLoRA using prefilled cache</span>
prompt_alora = prompt_shared + INVOCATION_STRING
inputs_alora = tokenizer(prompt_alora, <span class="hljs-attribute">return_tensors</span>=<span class="hljs-string">&quot;pt&quot;</span>).to(device)
output = model_alora.generate(**inputs_alora, <span class="hljs-attribute">past_key_values</span>=cache)
output_text_alora = tokenizer.decode(output[0])

<span class="hljs-comment"># Generate from base model using saved cache not tainted by aLoRA KV values</span>
prompt_base = prompt_shared
inputs_base = tokenizer(prompt_base, <span class="hljs-attribute">return_tensors</span>=<span class="hljs-string">&quot;pt&quot;</span>).to(device)
with model_alora.disable_adapter():
    output = model_alora.generate(**inputs_base, <span class="hljs-attribute">past_key_values</span>=cache_copy)
output_text_base = tokenizer.decode(output[0])`,wrap:!1}}),Ka=new M({props:{title:"Inference with different LoRA adapters in the same batch",local:"inference-with-different-lora-adapters-in-the-same-batch",headingTag:"h3"}}),tl=new f({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBBdXRvTW9kZWxGb3JDYXVzYWxMTSUwQWZyb20lMjBwZWZ0JTIwaW1wb3J0JTIwUGVmdE1vZGVsJTBBJTBBbW9kZWxfaWQlMjAlM0QlMjAuLi4lMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZChtb2RlbF9pZCklMEElMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNLmZyb21fcHJldHJhaW5lZChtb2RlbF9pZCklMEElMjMlMjBsb2FkJTIwdGhlJTIwTG9SQSUyMGFkYXB0ZXIlMjBmb3IlMjBGcmVuY2glMEFwZWZ0X21vZGVsJTIwJTNEJTIwUGVmdE1vZGVsLmZyb21fcHJldHJhaW5lZChtb2RlbCUyQyUyMCUzQ3BhdGglM0UlMkMlMjBhZGFwdGVyX25hbWUlM0QlMjJhZGFwdGVyX2ZyJTIyKSUwQSUyMyUyMG5leHQlMkMlMjBsb2FkJTIwdGhlJTIwTG9SQSUyMGFkYXB0ZXIlMjBmb3IlMjBHZXJtYW4lMEFwZWZ0X21vZGVsLmxvYWRfYWRhcHRlciglM0NwYXRoJTNFJTJDJTIwYWRhcHRlcl9uYW1lJTNEJTIyYWRhcHRlcl9kZSUyMik=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, AutoModelForCausalLM
<span class="hljs-keyword">from</span> peft <span class="hljs-keyword">import</span> PeftModel

model_id = ...
tokenizer = AutoTokenizer.from_pretrained(model_id)

model = AutoModelForCausalLM.from_pretrained(model_id)
<span class="hljs-comment"># load the LoRA adapter for French</span>
peft_model = PeftModel.from_pretrained(model, &lt;path&gt;, adapter_name=<span class="hljs-string">&quot;adapter_fr&quot;</span>)
<span class="hljs-comment"># next, load the LoRA adapter for German</span>
peft_model.load_adapter(&lt;path&gt;, adapter_name=<span class="hljs-string">&quot;adapter_de&quot;</span>)`,wrap:!1}}),ll=new f({props:{code:"aW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKCUwQSUyMCUyMCUyMCUyMCU1QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMkhlbGxvJTJDJTIwbXklMjBkb2clMjBpcyUyMGN1dGUlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJIZWxsbyUyQyUyMG15JTIwY2F0JTIwaXMlMjBhd2Vzb21lJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIySGVsbG8lMkMlMjBteSUyMGZpc2glMjBpcyUyMGdyZWF0JTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyU2FsdXQlMkMlMjBtb24lMjBjaGllbiUyMGVzdCUyMG1pZ25vbiUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMlNhbHV0JTJDJTIwbW9uJTIwY2hhdCUyMGVzdCUyMGclQzMlQTluaWFsJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyU2FsdXQlMkMlMjBtb24lMjBwb2lzc29uJTIwZXN0JTIwc3VwZXIlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJIYWxsbyUyQyUyMG1laW4lMjBIdW5kJTIwaXN0JTIwcyVDMyVCQyVDMyU5RiUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMkhhbGxvJTJDJTIwbWVpbmUlMjBLYXR6ZSUyMGlzdCUyMHRvbGwlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJIYWxsbyUyQyUyMG1laW4lMjBGaXNjaCUyMGlzdCUyMGdybyVDMyU5RmFydGlnJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTVEJTJDJTBBJTIwJTIwJTIwJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiUyQyUwQSUyMCUyMCUyMCUyMHBhZGRpbmclM0RUcnVlJTJDJTBBKSUwQSUwQWFkYXB0ZXJfbmFtZXMlMjAlM0QlMjAlNUIlMEElMjAlMjAlMjAlMjAlMjJfX2Jhc2VfXyUyMiUyQyUyMCUyMl9fYmFzZV9fJTIyJTJDJTIwJTIyX19iYXNlX18lMjIlMkMlMEElMjAlMjAlMjAlMjAlMjJhZGFwdGVyX2ZyJTIyJTJDJTIwJTIyYWRhcHRlcl9mciUyMiUyQyUyMCUyMmFkYXB0ZXJfZnIlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjJhZGFwdGVyX2RlJTIyJTJDJTIwJTIyYWRhcHRlcl9kZSUyMiUyQyUyMCUyMmFkYXB0ZXJfZGUlMjIlMkMlMEElNUQlMEFvdXRwdXQlMjAlM0QlMjBwZWZ0X21vZGVsLmdlbmVyYXRlKCoqaW5wdXRzJTJDJTIwYWRhcHRlcl9uYW1lcyUzRGFkYXB0ZXJfbmFtZXMlMkMlMjBtYXhfbmV3X3Rva2VucyUzRDIwKQ==",highlighted:`inputs = tokenizer(
    [
        <span class="hljs-string">&quot;Hello, my dog is cute&quot;</span>,
        <span class="hljs-string">&quot;Hello, my cat is awesome&quot;</span>,
        <span class="hljs-string">&quot;Hello, my fish is great&quot;</span>,
        <span class="hljs-string">&quot;Salut, mon chien est mignon&quot;</span>,
        <span class="hljs-string">&quot;Salut, mon chat est génial&quot;</span>,
        <span class="hljs-string">&quot;Salut, mon poisson est super&quot;</span>,
        <span class="hljs-string">&quot;Hallo, mein Hund ist süß&quot;</span>,
        <span class="hljs-string">&quot;Hallo, meine Katze ist toll&quot;</span>,
        <span class="hljs-string">&quot;Hallo, mein Fisch ist großartig&quot;</span>,
    ],
    return_tensors=<span class="hljs-string">&quot;pt&quot;</span>,
    padding=<span class="hljs-literal">True</span>,
)

adapter_names = [
    <span class="hljs-string">&quot;__base__&quot;</span>, <span class="hljs-string">&quot;__base__&quot;</span>, <span class="hljs-string">&quot;__base__&quot;</span>,
    <span class="hljs-string">&quot;adapter_fr&quot;</span>, <span class="hljs-string">&quot;adapter_fr&quot;</span>, <span class="hljs-string">&quot;adapter_fr&quot;</span>,
    <span class="hljs-string">&quot;adapter_de&quot;</span>, <span class="hljs-string">&quot;adapter_de&quot;</span>, <span class="hljs-string">&quot;adapter_de&quot;</span>,
]
output = peft_model.generate(**inputs, adapter_names=adapter_names, max_new_tokens=<span class="hljs-number">20</span>)`,wrap:!1}}),ol=new M({props:{title:"Caveats",local:"caveats",headingTag:"h4"}}),dl=new M({props:{title:"Composing and Reusing LoRA Adapters",local:"composing-and-reusing-lora-adapters",headingTag:"h3"}}),pl=new M({props:{title:"Arrow",local:"arrow",headingTag:"h4"}}),hl=new f({props:{code:"ZnJvbSUyMHBlZnQlMjBpbXBvcnQlMjBjcmVhdGVfYXJyb3dfbW9kZWwlMkMlMjBBcnJvd0NvbmZpZyUwQWZyb20lMjB0cmFuc2Zvcm1lcnMlMjBpbXBvcnQlMjBBdXRvTW9kZWxGb3JDYXVzYWxMTSUwQSUwQSUyMyUyMExvYWRpbmclMjB0aGUlMjBtb2RlbCUwQWJhc2VfbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JDYXVzYWxMTS5mcm9tX3ByZXRyYWluZWQoJTIybWljcm9zb2Z0JTJGUGhpLTMtbWluaS00ay1pbnN0cnVjdCUyMiklMEElMEElMjMlMjBDcmVhdGluZyUyMHRoZSUyMEFycm93JTIwY29uZmlnJTBBYXJyb3dfY29uZmlnJTIwJTNEJTIwQXJyb3dDb25maWcoJTBBJTIwJTIwJTIwJTIwdG9wX2slM0QzJTJDJTBBJTIwJTIwJTIwJTIwcm91dGVyX3RlbXBlcmF0dXJlJTNEMS4wJTJDJTBBJTIwJTIwJTIwJTIwcm5nX3NlZWQlM0Q0MiUyQyUwQSklMEElMEElMjMlMjBUaGUlMjBMb1JBJTIwYWRhcHRlcnMlMjBiZWxvdyUyMHdlcmUlMjB0cmFpbmVkJTIwb24lMjBhJTIwY2x1c3RlcmVkJTIwRkxBTiUyMGRhdGFzZXQuJTBBJTIzJTIwVGFzayUyMGNsdXN0ZXJpbmclMjB3YXMlMjBwZXJmb3JtZWQlMjB1c2luZyUyMHRoZSUyME1vZGVsLUJhc2VkJTIwQ2x1c3RlcmluZyUyMChNQkMpJTIwbWV0aG9kJTJDJTBBJTIzJTIwYXMlMjBkZXNjcmliZWQlMjBpbiUyMHRoZSUyMEFycm93JTIwcGFwZXIuJTBBJTIzJTIwV2hpbGUlMjBvbmUlMjBjb3VsZCUyMHRyYWluJTIwYSUyMHNlcGFyYXRlJTIwTG9SQSUyMGZvciUyMGVhY2glMjB0YXNrJTIwYW5kJTIwbGV0JTIwQXJyb3clMjByb3V0ZSUyMHRva2VucyUyMGFtb25nJTIwdGhlbSUyQyUwQSUyMyUyMHRyYWluaW5nJTIwTG9SQXMlMjBvbiUyMGNsdXN0ZXJzJTIwb2YlMjB0YXNrcyUyMGluc3RlYWQlMjBwcm92aWRlcyUyMGFuJTIwaW5kaXJlY3QlMjBvcHRpbWl6YXRpb24lMjBmb3IlMEElMjMlMjB0cmFuc2ZlciUyMGFjcm9zcyUyMHRoZSUyMG11bHRpLXRhc2slMjBkYXRhc2V0LiUwQXRhc2tfc3BlY2lmaWNfYWRhcHRlcl9wYXRocyUyMCUzRCUyMCU1QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGYlMjJUYWhhQmElMkZwaGkzLW1pbmktY2x1c3RlcmVkLWZsYW4lMkZ0c19leHBlcnRfJTdCaSU3RCUyMiUyMGZvciUyMGklMjBpbiUyMHJhbmdlKDEwKSUwQSUyMCUyMCUyMCUyMCU1RCUwQSUwQSUyMyUyMENyZWF0aW5nJTIwdGhlJTIwQXJyb3clMjBtb2RlbCUwQW1vZGVsJTIwJTNEJTIwY3JlYXRlX2Fycm93X21vZGVsKCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGJhc2VfbW9kZWwlM0RiYXNlX21vZGVsJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwdGFza19zcGVjaWZpY19hZGFwdGVyX3BhdGhzJTNEdGFza19zcGVjaWZpY19hZGFwdGVyX3BhdGhzJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwYXJyb3dfY29uZmlnJTNEYXJyb3dfY29uZmlnJTJDJTBBJTIwJTIwJTIwJTIwKSUwQSUwQSUyMyUyME5vdyUyMHRoZSUyMGZvcndhcmQlMjBwYXRoJTIwY291bGQlMjBiZSUyMGNhbGxlZCUyMG9uJTIwdGhpcyUyMG1vZGVsJTJDJTIwbGlrZSUyMGElMjBub3JtYWwlMjBQZWZ0TW9kZWwu",highlighted:`<span class="hljs-keyword">from</span> peft <span class="hljs-keyword">import</span> create_arrow_model, ArrowConfig
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM

<span class="hljs-comment"># Loading the model</span>
base_model = AutoModelForCausalLM.from_pretrained(<span class="hljs-string">&quot;microsoft/Phi-3-mini-4k-instruct&quot;</span>)

<span class="hljs-comment"># Creating the Arrow config</span>
arrow_config = ArrowConfig(
    top_k=<span class="hljs-number">3</span>,
    router_temperature=<span class="hljs-number">1.0</span>,
    rng_seed=<span class="hljs-number">42</span>,
)

<span class="hljs-comment"># The LoRA adapters below were trained on a clustered FLAN dataset.</span>
<span class="hljs-comment"># Task clustering was performed using the Model-Based Clustering (MBC) method,</span>
<span class="hljs-comment"># as described in the Arrow paper.</span>
<span class="hljs-comment"># While one could train a separate LoRA for each task and let Arrow route tokens among them,</span>
<span class="hljs-comment"># training LoRAs on clusters of tasks instead provides an indirect optimization for</span>
<span class="hljs-comment"># transfer across the multi-task dataset.</span>
task_specific_adapter_paths = [
        <span class="hljs-string">f&quot;TahaBa/phi3-mini-clustered-flan/ts_expert_<span class="hljs-subst">{i}</span>&quot;</span> <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(<span class="hljs-number">10</span>)
    ]

<span class="hljs-comment"># Creating the Arrow model</span>
model = create_arrow_model(
        base_model=base_model,
        task_specific_adapter_paths=task_specific_adapter_paths,
        arrow_config=arrow_config,
    )

<span class="hljs-comment"># Now the forward path could be called on this model, like a normal PeftModel.</span>`,wrap:!1}}),fl=new f({props:{code:"ZnJvbSUyMHRybCUyMGltcG9ydCUyMFNGVFRyYWluZXIlMkMlMjBTRlRDb25maWclMEElMEElMjMlMjBBZGRpbmclMjBhJTIwbmV3JTIwYWRhcHRlciUyMGFuZCUyMGFjdGl2YXRpbmclMjBpdCUwQW1vZGVsLmFkZF9hZGFwdGVyKGFkYXB0ZXJfbmFtZSUzRCduZXdfYWRhcHRlcicpJTBBbW9kZWwuc2V0X2FkYXB0ZXIoJ25ld19hZGFwdGVyJyklMEElMEElMjMlMjBOb3clMjB0aGUlMjBtb2RlbCUyMGNvdWxkJTIwYmUlMjB0cmFpbmVkJTIwYWxvbmclMjB0aGUlMjAlNjBuZXdfYWRhcHRlciU2MC4lMEF0cmFpbmVyJTIwJTNEJTIwU0ZUVHJhaW5lciglMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBtb2RlbCUzRG1vZGVsJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwYXJncyUzRFNGVENvbmZpZyguLi4pJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwLi4uJTBBJTIwJTIwJTIwJTIwKSUwQSUwQSUyMyUyME9uY2UlMjB0aGUlMjB0cmFpbmluZyUyMGlzJTIwZG9uZSUyQyUyMHlvdSUyMGNhbiUyMGFjdGl2YXRlJTIwJTYwYXJyb3dfcm91dGVyJTYwJTIwYW5kJTIwdXNlJTIwaXQlMjBpbiUyMGluZmVyZW5jZSUwQW1vZGVsLnNldF9hZGFwdGVyKCdhcnJvd19yb3V0ZXInKSUyMCUyMCUyMCUyMCUyMyUyME1vZGVsJTIwaXMlMjByZWFkeSUyMHRvJTIwYmUlMjB1c2VkJTIwYXQlMjBpbmZlcmVuY2UlMjB0aW1lJTIwbm93",highlighted:`<span class="hljs-keyword">from</span> trl <span class="hljs-keyword">import</span> SFTTrainer, SFTConfig

<span class="hljs-comment"># Adding a new adapter and activating it</span>
model.add_adapter(adapter_name=<span class="hljs-string">&#x27;new_adapter&#x27;</span>)
model.set_adapter(<span class="hljs-string">&#x27;new_adapter&#x27;</span>)

<span class="hljs-comment"># Now the model could be trained along the \`new_adapter\`.</span>
trainer = SFTTrainer(
        model=model,
        args=SFTConfig(...),
        ...
    )

<span class="hljs-comment"># Once the training is done, you can activate \`arrow_router\` and use it in inference</span>
model.set_adapter(<span class="hljs-string">&#x27;arrow_router&#x27;</span>)    <span class="hljs-comment"># Model is ready to be used at inference time now</span>`,wrap:!1}}),Ml=new M({props:{title:"GenKnowSub",local:"genknowsub",headingTag:"h4"}}),Tl=new f({props:{code:"ZnJvbSUyMHBlZnQlMjBpbXBvcnQlMjBjcmVhdGVfYXJyb3dfbW9kZWwlMkMlMjBBcnJvd0NvbmZpZyUwQWZyb20lMjB0cmFuc2Zvcm1lcnMlMjBpbXBvcnQlMjBBdXRvTW9kZWxGb3JDYXVzYWxMTSUwQSUwQSUyMyUyMExvYWRpbmclMjB0aGUlMjBtb2RlbCUwQWJhc2VfbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JDYXVzYWxMTS5mcm9tX3ByZXRyYWluZWQoJTIybWljcm9zb2Z0JTJGUGhpLTMtbWluaS00ay1pbnN0cnVjdCUyMiklMEElMEElMjMlMjBDcmVhdGluZyUyMHRoZSUyMEFycm93JTIwY29uZmlnJTBBYXJyb3dfY29uZmlnJTIwJTNEJTIwQXJyb3dDb25maWcoJTBBJTIwJTIwJTIwJTIwdG9wX2slM0QzJTJDJTBBJTIwJTIwJTIwJTIwcm91dGVyX3RlbXBlcmF0dXJlJTNEMS4wJTJDJTBBJTIwJTIwJTIwJTIwdXNlX2drcyUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjBybmdfc2VlZCUzRDQyJTJDJTBBKSUwQSUwQSUyMyUyMFBhdGglMjB0byUyMHRhc2stc3BlY2lmaWMlMkMlMjB0cmFpbmVkJTIwb24lMjBmbGFuJTIwY2x1c3RlcmVkJTIwZGF0YXNldCUyMChhcyUyMHdlJTIwZXhwbGFpbmVkJTIwYmVmb3JlLiklMEF0YXNrX3NwZWNpZmljX2FkYXB0ZXJfcGF0aHMlMjAlM0QlMjAlNUIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBmJTIyVGFoYUJhJTJGcGhpMy1taW5pLWNsdXN0ZXJlZC1mbGFuJTJGdHNfZXhwZXJ0XyU3QmklN0QlMjIlMjBmb3IlMjBpJTIwaW4lMjByYW5nZSgxMCklMEElMjAlMjAlMjAlMjAlNUQlMEElMjMlMjBUaGVzZSUyMGdlbmVyYWwlMjBhZGFwdGVycyUyMGFyZSUyMHRyYWluZWQlMjBvbiUyMEVuZ2xpc2glMkMlMjBHZXJtYW4lMkMlMjBhbmQlMjBGcmVuY2glMjBXaWtpcGVkaWElMjBkYXRhc2V0JTJDJTBBJTIzJTIwd2l0aCUyMGNhdXNhbCUyMGxhbmd1YWdlJTIwbW9kZWxsaW5nJTIwb2JqZWN0aXZlJTJDJTIwZWFjaCUyMHBhaXIlMjBsaWtlJTNBJTIwKDUwNyUyMHRva2VuJTIwdHNlbnRlbmNlJTJDJTIwNSUyMHRva2VuJTIwY29tcGxldGlvbiklMkMlMjBhbmQlMjB0aGUlMjBsb3NzJTIwY29tcHV0ZWQlMjBvbiUyMHRoZSUyMGNvbXBsZXRpb24lMEFnZW5lcmFsX2FkYXB0ZXJfcGF0aHMlMjAlM0QlMjAlNUIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJUYWhhQmElMkZwaGkzLW1pbmktZ2VuZXJhbC1hZGFwdGVycyUyRmNsdXN0ZXIwX2JhdGNoMTZfcHJvcDEuMF9sYW5nZW4lMkZjaGVja3BvaW50LTE3JTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyVGFoYUJhJTJGcGhpMy1taW5pLWdlbmVyYWwtYWRhcHRlcnMlMkZjbHVzdGVyMF9iYXRjaDE2X3Byb3AxLjBfbGFuZ2ZyJTJGY2hlY2twb2ludC0zNSUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMlRhaGFCYSUyRnBoaTMtbWluaS1nZW5lcmFsLWFkYXB0ZXJzJTJGY2x1c3RlcjBfYmF0Y2gxNl9wcm9wMS4wX2xhbmdnZXIlMkZjaGVja3BvaW50LTE3JTIyJTBBJTIwJTIwJTIwJTIwJTVEJTBBJTBBJTIzJTIwQ3JlYXRpbmclMjB0aGUlMjBBcnJvdyUyMG1vZGVsJTBBbW9kZWwlMjAlM0QlMjBjcmVhdGVfYXJyb3dfbW9kZWwoJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwYmFzZV9tb2RlbCUzRGJhc2VfbW9kZWwlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjB0YXNrX3NwZWNpZmljX2FkYXB0ZXJfcGF0aHMlM0R0YXNrX3NwZWNpZmljX2FkYXB0ZXJfcGF0aHMlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBnZW5lcmFsX2FkYXB0ZXJfcGF0aHMlM0RnZW5lcmFsX2FkYXB0ZXJfcGF0aHMlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBhcnJvd19jb25maWclM0RhcnJvd19jb25maWclMkMlMEElMjAlMjAlMjAlMjApJTBBJTBBJTIzJTIwTm93JTIwdGhlJTIwZm9yd2FyZCUyMHBhdGglMjBjb3VsZCUyMGJlJTIwY2FsbGVkJTIwb24lMjB0aGlzJTIwbW9kZWwlMkMlMjBsaWtlJTIwYSUyMG5vcm1hbCUyMFBlZnRNb2RlbC4=",highlighted:`<span class="hljs-keyword">from</span> peft <span class="hljs-keyword">import</span> create_arrow_model, ArrowConfig
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM

<span class="hljs-comment"># Loading the model</span>
base_model = AutoModelForCausalLM.from_pretrained(<span class="hljs-string">&quot;microsoft/Phi-3-mini-4k-instruct&quot;</span>)

<span class="hljs-comment"># Creating the Arrow config</span>
arrow_config = ArrowConfig(
    top_k=<span class="hljs-number">3</span>,
    router_temperature=<span class="hljs-number">1.0</span>,
    use_gks=<span class="hljs-literal">True</span>,
    rng_seed=<span class="hljs-number">42</span>,
)

<span class="hljs-comment"># Path to task-specific, trained on flan clustered dataset (as we explained before.)</span>
task_specific_adapter_paths = [
        <span class="hljs-string">f&quot;TahaBa/phi3-mini-clustered-flan/ts_expert_<span class="hljs-subst">{i}</span>&quot;</span> <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(<span class="hljs-number">10</span>)
    ]
<span class="hljs-comment"># These general adapters are trained on English, German, and French Wikipedia dataset,</span>
<span class="hljs-comment"># with causal language modelling objective, each pair like: (507 token tsentence, 5 token completion), and the loss computed on the completion</span>
general_adapter_paths = [
        <span class="hljs-string">&quot;TahaBa/phi3-mini-general-adapters/cluster0_batch16_prop1.0_langen/checkpoint-17&quot;</span>,
        <span class="hljs-string">&quot;TahaBa/phi3-mini-general-adapters/cluster0_batch16_prop1.0_langfr/checkpoint-35&quot;</span>,
        <span class="hljs-string">&quot;TahaBa/phi3-mini-general-adapters/cluster0_batch16_prop1.0_langger/checkpoint-17&quot;</span>
    ]

<span class="hljs-comment"># Creating the Arrow model</span>
model = create_arrow_model(
        base_model=base_model,
        task_specific_adapter_paths=task_specific_adapter_paths,
        general_adapter_paths=general_adapter_paths,
        arrow_config=arrow_config,
    )

<span class="hljs-comment"># Now the forward path could be called on this model, like a normal PeftModel.</span>`,wrap:!1}}),Jl=new f({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNJTJDJTIwQml0c0FuZEJ5dGVzQ29uZmlnJTBBaW1wb3J0JTIwdG9yY2glMEElMEElMjMlMjBRdWFudGlzYXRpb24lMjBjb25maWclMEFibmJfY29uZmlnJTIwJTNEJTIwQml0c0FuZEJ5dGVzQ29uZmlnKCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGxvYWRfaW5fNGJpdCUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBibmJfNGJpdF9xdWFudF90eXBlJTNEJTIybmY0JTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwYm5iXzRiaXRfY29tcHV0ZV9kdHlwZSUzRHRvcmNoLmJmbG9hdDE2JTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwYm5iXzRiaXRfdXNlX2RvdWJsZV9xdWFudCUzREZhbHNlJTJDJTBBJTIwJTIwJTIwJTIwKSUwQSUwQSUyMyUyMExvYWRpbmclMjB0aGUlMjBtb2RlbCUwQWJhc2VfbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JDYXVzYWxMTS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIybWljcm9zb2Z0JTJGUGhpLTMtbWluaS00ay1pbnN0cnVjdCUyMiUyQyUwQSUyMCUyMCUyMCUyMGR0eXBlJTNEdG9yY2guYmZsb2F0MTYlMkMlMEElMjAlMjAlMjAlMjBkZXZpY2VfbWFwJTNEJTIyYXV0byUyMiUyQyUwQSUyMCUyMCUyMCUyMHF1YW50aXphdGlvbl9jb25maWclM0RibmJfY29uZmlnJTJDJTBBKSUwQSUwQSUyMyUyME5vdyUyMGNhbGwlMjBjcmVhdGVfYXJyb3dfbW9kZWwoKSUyMGFzJTIwd2UlMjBleHBsYWluZWQlMjBiZWZvcmUu",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM, BitsAndBytesConfig
<span class="hljs-keyword">import</span> torch

<span class="hljs-comment"># Quantisation config</span>
bnb_config = BitsAndBytesConfig(
        load_in_4bit=<span class="hljs-literal">True</span>,
        bnb_4bit_quant_type=<span class="hljs-string">&quot;nf4&quot;</span>,
        bnb_4bit_compute_dtype=torch.bfloat16,
        bnb_4bit_use_double_quant=<span class="hljs-literal">False</span>,
    )

<span class="hljs-comment"># Loading the model</span>
base_model = AutoModelForCausalLM.from_pretrained(
    <span class="hljs-string">&quot;microsoft/Phi-3-mini-4k-instruct&quot;</span>,
    dtype=torch.bfloat16,
    device_map=<span class="hljs-string">&quot;auto&quot;</span>,
    quantization_config=bnb_config,
)

<span class="hljs-comment"># Now call create_arrow_model() as we explained before.</span>`,wrap:!1}}),_l=new Zp({props:{source:"https://github.com/huggingface/peft/blob/main/docs/source/developer_guides/lora.md"}}),{c(){b=o("meta"),Wl=n(),$l=o("p"),Ll=n(),d(C.$$.fragment),Al=n(),d(B.$$.fragment),Gl=n(),$=o("p"),$.innerHTML=Si,xl=n(),I=o("p"),I.textContent=Pi,Vl=n(),d(R.$$.fragment),Xl=n(),W=o("p"),W.innerHTML=Di,Fl=n(),L=o("p"),L.innerHTML=Ki,ql=n(),d(A.$$.fragment),El=n(),G=o("p"),G.innerHTML=Oi,Hl=n(),d(x.$$.fragment),Yl=n(),d(V.$$.fragment),Ql=n(),X=o("p"),X.innerHTML=er,zl=n(),F=o("p"),F.textContent=tr,Nl=n(),d(q.$$.fragment),Sl=n(),E=o("p"),E.textContent=ar,Pl=n(),d(H.$$.fragment),Dl=n(),Y=o("p"),Y.innerHTML=lr,Kl=n(),d(Q.$$.fragment),Ol=n(),z=o("p"),z.innerHTML=nr,en=n(),N=o("p"),N.textContent=sr,tn=n(),d(S.$$.fragment),an=n(),P=o("p"),P.innerHTML=or,ln=n(),d(D.$$.fragment),nn=n(),K=o("p"),K.innerHTML=ir,sn=n(),O=o("p"),O.textContent=rr,on=n(),d(ee.$$.fragment),rn=n(),te=o("p"),te.innerHTML=dr,dn=n(),d(ae.$$.fragment),pn=n(),le=o("p"),le.innerHTML=pr,mn=n(),ne=o("p"),ne.innerHTML=mr,cn=n(),d(se.$$.fragment),hn=n(),oe=o("p"),oe.innerHTML=cr,un=n(),ie=o("p"),ie.innerHTML=hr,fn=n(),d(re.$$.fragment),Mn=n(),de=o("p"),de.innerHTML=ur,wn=n(),d(pe.$$.fragment),yn=n(),me=o("p"),me.innerHTML=fr,Tn=n(),_=o("blockquote"),_.innerHTML=Mr,bn=n(),d(ce.$$.fragment),gn=n(),d(he.$$.fragment),Jn=n(),ue=o("p"),ue.innerHTML=wr,_n=n(),j=o("blockquote"),j.innerHTML=yr,jn=n(),d(fe.$$.fragment),vn=n(),Me=o("p"),Me.innerHTML=Tr,kn=n(),d(we.$$.fragment),Un=n(),d(ye.$$.fragment),Zn=n(),Te=o("p"),Te.innerHTML=br,Cn=n(),be=o("p"),be.textContent=gr,Bn=n(),d(ge.$$.fragment),$n=n(),d(Je.$$.fragment),In=n(),_e=o("p"),_e.textContent=Jr,Rn=n(),d(je.$$.fragment),Wn=n(),ve=o("p"),ve.innerHTML=_r,Ln=n(),d(ke.$$.fragment),An=n(),Ue=o("p"),Ue.innerHTML=jr,Gn=n(),d(Ze.$$.fragment),xn=n(),Ce=o("p"),Ce.innerHTML=vr,Vn=n(),d(Be.$$.fragment),Xn=n(),d($e.$$.fragment),Fn=n(),Ie=o("p"),Ie.innerHTML=kr,qn=n(),Re=o("table"),Re.innerHTML=Ur,En=n(),We=o("p"),We.innerHTML=Zr,Hn=n(),d(Le.$$.fragment),Yn=n(),Ae=o("p"),Ae.innerHTML=Cr,Qn=n(),Ge=o("ul"),Ge.innerHTML=Br,zn=n(),xe=o("p"),xe.textContent=$r,Nn=n(),d(Ve.$$.fragment),Sn=n(),Xe=o("ul"),Xe.innerHTML=Ir,Pn=n(),d(Fe.$$.fragment),Dn=n(),qe=o("p"),qe.textContent=Rr,Kn=n(),d(Ee.$$.fragment),On=n(),He=o("p"),He.innerHTML=Wr,es=n(),d(Ye.$$.fragment),ts=n(),Qe=o("p"),Qe.innerHTML=Lr,as=n(),d(ze.$$.fragment),ls=n(),Ne=o("p"),Ne.innerHTML=Ar,ns=n(),d(Se.$$.fragment),ss=n(),Pe=o("p"),Pe.innerHTML=Gr,os=n(),De=o("p"),De.innerHTML=xr,is=n(),d(Ke.$$.fragment),rs=n(),Oe=o("p"),Oe.innerHTML=Vr,ds=n(),et=o("p"),et.textContent=Xr,ps=n(),d(tt.$$.fragment),ms=n(),at=o("ul"),at.innerHTML=Fr,cs=n(),lt=o("p"),lt.innerHTML=qr,hs=n(),d(nt.$$.fragment),us=n(),st=o("p"),st.innerHTML=Er,fs=n(),ot=o("p"),ot.innerHTML=Hr,Ms=n(),it=o("p"),it.innerHTML=Yr,ws=n(),d(rt.$$.fragment),ys=n(),dt=o("ul"),dt.innerHTML=Qr,Ts=n(),d(pt.$$.fragment),bs=n(),mt=o("p"),mt.innerHTML=zr,gs=n(),d(ct.$$.fragment),Js=n(),ht=o("p"),ht.innerHTML=Nr,_s=n(),ut=o("p"),ut.innerHTML=Sr,js=n(),d(ft.$$.fragment),vs=n(),Mt=o("p"),Mt.innerHTML=Pr,ks=n(),d(wt.$$.fragment),Us=n(),yt=o("p"),yt.textContent=Dr,Zs=n(),d(Tt.$$.fragment),Cs=n(),bt=o("p"),bt.textContent=Kr,Bs=n(),gt=o("p"),gt.innerHTML=Or,$s=n(),Jt=o("table"),Jt.innerHTML=ed,Is=n(),d(_t.$$.fragment),Rs=n(),jt=o("p"),jt.innerHTML=td,Ws=n(),vt=o("p"),vt.innerHTML=ad,Ls=n(),kt=o("p"),kt.textContent=ld,As=n(),d(Ut.$$.fragment),Gs=n(),Zt=o("table"),Zt.innerHTML=nd,xs=n(),d(Ct.$$.fragment),Vs=n(),Bt=o("table"),Bt.innerHTML=sd,Xs=n(),d($t.$$.fragment),Fs=n(),It=o("p"),It.innerHTML=od,qs=n(),Rt=o("table"),Rt.innerHTML=id,Es=n(),Wt=o("p"),Wt.textContent=rd,Hs=n(),Lt=o("ul"),Lt.innerHTML=dd,Ys=n(),d(At.$$.fragment),Qs=n(),Gt=o("p"),Gt.textContent=pd,zs=n(),d(xt.$$.fragment),Ns=n(),Vt=o("p"),Vt.innerHTML=md,Ss=n(),d(Xt.$$.fragment),Ps=n(),d(Ft.$$.fragment),Ds=n(),qt=o("p"),qt.innerHTML=cd,Ks=n(),d(Et.$$.fragment),Os=n(),d(Ht.$$.fragment),eo=n(),Yt=o("p"),Yt.textContent=hd,to=n(),d(Qt.$$.fragment),ao=n(),zt=o("p"),zt.innerHTML=ud,lo=n(),Nt=o("p"),Nt.textContent=fd,no=n(),v=o("div"),v.innerHTML=Md,so=n(),St=o("p"),St.textContent=wd,oo=n(),d(Pt.$$.fragment),io=n(),Dt=o("p"),Dt.innerHTML=yd,ro=n(),d(Kt.$$.fragment),po=n(),Ot=o("p"),Ot.innerHTML=Td,mo=n(),ea=o("p"),ea.textContent=bd,co=n(),d(ta.$$.fragment),ho=n(),aa=o("p"),aa.textContent=gd,uo=n(),d(la.$$.fragment),fo=n(),na=o("p"),na.textContent=Jd,Mo=n(),d(sa.$$.fragment),wo=n(),k=o("blockquote"),k.innerHTML=_d,yo=n(),oa=o("p"),oa.textContent=jd,To=n(),d(ia.$$.fragment),bo=n(),d(ra.$$.fragment),go=n(),da=o("p"),da.innerHTML=vd,Jo=n(),pa=o("p"),pa.textContent=kd,_o=n(),ma=o("p"),ma.textContent=Ud,jo=n(),d(ca.$$.fragment),vo=n(),ha=o("p"),ha.textContent=Zd,ko=n(),ua=o("p"),ua.textContent=Cd,Uo=n(),d(fa.$$.fragment),Zo=n(),Ma=o("p"),Ma.innerHTML=Bd,Co=n(),d(wa.$$.fragment),Bo=n(),ya=o("p"),ya.innerHTML=$d,$o=n(),d(Ta.$$.fragment),Io=n(),d(ba.$$.fragment),Ro=n(),ga=o("p"),ga.innerHTML=Id,Wo=n(),U=o("blockquote"),U.innerHTML=Rd,Lo=n(),Ja=o("p"),Ja.innerHTML=Wd,Ao=n(),d(_a.$$.fragment),Go=n(),ja=o("p"),ja.innerHTML=Ld,xo=n(),d(va.$$.fragment),Vo=n(),ka=o("p"),ka.textContent=Ad,Xo=n(),d(Ua.$$.fragment),Fo=n(),Za=o("p"),Za.innerHTML=Gd,qo=n(),Ca=o("p"),Ca.innerHTML=xd,Eo=n(),d(Ba.$$.fragment),Ho=n(),$a=o("p"),$a.textContent=Vd,Yo=n(),d(Ia.$$.fragment),Qo=n(),Ra=o("p"),Ra.innerHTML=Xd,zo=n(),Wa=o("p"),Wa.innerHTML=Fd,No=n(),La=o("ul"),La.innerHTML=qd,So=n(),d(Aa.$$.fragment),Po=n(),Ga=o("p"),Ga.innerHTML=Ed,Do=n(),xa=o("p"),xa.textContent=Hd,Ko=n(),Va=o("ul"),Va.innerHTML=Yd,Oo=n(),Xa=o("p"),Xa.innerHTML=Qd,ei=n(),d(Fa.$$.fragment),ti=n(),qa=o("p"),qa.innerHTML=zd,ai=n(),Z=o("blockquote"),Z.innerHTML=Nd,li=n(),Ea=o("p"),Ea.textContent=Sd,ni=n(),d(Ha.$$.fragment),si=n(),Ya=o("p"),Ya.innerHTML=Pd,oi=n(),Qa=o("ol"),Qa.innerHTML=Dd,ii=n(),za=o("p"),za.innerHTML=Kd,ri=n(),Na=o("p"),Na.innerHTML=Od,di=n(),d(Sa.$$.fragment),pi=n(),Pa=o("p"),Pa.innerHTML=ep,mi=n(),d(Da.$$.fragment),ci=n(),d(Ka.$$.fragment),hi=n(),Oa=o("p"),Oa.textContent=tp,ui=n(),el=o("p"),el.innerHTML=ap,fi=n(),d(tl.$$.fragment),Mi=n(),al=o("p"),al.innerHTML=lp,wi=n(),d(ll.$$.fragment),yi=n(),nl=o("p"),nl.innerHTML=np,Ti=n(),sl=o("p"),sl.innerHTML=sp,bi=n(),d(ol.$$.fragment),gi=n(),il=o("p"),il.textContent=op,Ji=n(),rl=o("ul"),rl.innerHTML=ip,_i=n(),d(dl.$$.fragment),ji=n(),d(pl.$$.fragment),vi=n(),ml=o("p"),ml.innerHTML=rp,ki=n(),cl=o("p"),cl.innerHTML=dp,Ui=n(),d(hl.$$.fragment),Zi=n(),ul=o("p"),ul.innerHTML=pp,Ci=n(),d(fl.$$.fragment),Bi=n(),d(Ml.$$.fragment),$i=n(),wl=o("p"),wl.innerHTML=mp,Ii=n(),yl=o("p"),yl.innerHTML=cp,Ri=n(),d(Tl.$$.fragment),Wi=n(),bl=o("p"),bl.innerHTML=hp,Li=n(),g=o("blockquote"),jl=o("p"),jl.innerHTML=up,Fi=n(),y=o("ul"),vl=o("li"),vl.innerHTML=fp,qi=n(),kl=o("li"),kl.innerHTML=Mp,Ei=n(),Ul=o("li"),Ul.innerHTML=wp,Hi=n(),Zl=o("li"),Zl.innerHTML=yp,Yi=n(),Cl=o("li"),Cl.innerHTML=Tp,Qi=n(),gl=o("li"),Bl=o("p"),Bl.textContent=bp,zi=n(),d(Jl.$$.fragment),Ai=n(),d(_l.$$.fragment),Gi=n(),Il=o("p"),this.h()},l(e){const t=kp("svelte-u9bgzb",document.head);b=i(t,"META",{name:!0,content:!0}),t.forEach(a),Wl=s(e),$l=i(e,"P",{}),Rl($l).forEach(a),Ll=s(e),p(C.$$.fragment,e),Al=s(e),p(B.$$.fragment,e),Gl=s(e),$=i(e,"P",{"data-svelte-h":!0}),r($)!=="svelte-38uxl6"&&($.innerHTML=Si),xl=s(e),I=i(e,"P",{"data-svelte-h":!0}),r(I)!=="svelte-ovsn32"&&(I.textContent=Pi),Vl=s(e),p(R.$$.fragment,e),Xl=s(e),W=i(e,"P",{"data-svelte-h":!0}),r(W)!=="svelte-j883mf"&&(W.innerHTML=Di),Fl=s(e),L=i(e,"P",{"data-svelte-h":!0}),r(L)!=="svelte-1fujb7a"&&(L.innerHTML=Ki),ql=s(e),p(A.$$.fragment,e),El=s(e),G=i(e,"P",{"data-svelte-h":!0}),r(G)!=="svelte-mwvui1"&&(G.innerHTML=Oi),Hl=s(e),p(x.$$.fragment,e),Yl=s(e),p(V.$$.fragment,e),Ql=s(e),X=i(e,"P",{"data-svelte-h":!0}),r(X)!=="svelte-1dv6v3"&&(X.innerHTML=er),zl=s(e),F=i(e,"P",{"data-svelte-h":!0}),r(F)!=="svelte-1hy0lgx"&&(F.textContent=tr),Nl=s(e),p(q.$$.fragment,e),Sl=s(e),E=i(e,"P",{"data-svelte-h":!0}),r(E)!=="svelte-auzrbb"&&(E.textContent=ar),Pl=s(e),p(H.$$.fragment,e),Dl=s(e),Y=i(e,"P",{"data-svelte-h":!0}),r(Y)!=="svelte-16k39wq"&&(Y.innerHTML=lr),Kl=s(e),p(Q.$$.fragment,e),Ol=s(e),z=i(e,"P",{"data-svelte-h":!0}),r(z)!=="svelte-53sj5j"&&(z.innerHTML=nr),en=s(e),N=i(e,"P",{"data-svelte-h":!0}),r(N)!=="svelte-1s3c5rd"&&(N.textContent=sr),tn=s(e),p(S.$$.fragment,e),an=s(e),P=i(e,"P",{"data-svelte-h":!0}),r(P)!=="svelte-19qemwc"&&(P.innerHTML=or),ln=s(e),p(D.$$.fragment,e),nn=s(e),K=i(e,"P",{"data-svelte-h":!0}),r(K)!=="svelte-1iny7jf"&&(K.innerHTML=ir),sn=s(e),O=i(e,"P",{"data-svelte-h":!0}),r(O)!=="svelte-1j9g8qn"&&(O.textContent=rr),on=s(e),p(ee.$$.fragment,e),rn=s(e),te=i(e,"P",{"data-svelte-h":!0}),r(te)!=="svelte-sulxp4"&&(te.innerHTML=dr),dn=s(e),p(ae.$$.fragment,e),pn=s(e),le=i(e,"P",{"data-svelte-h":!0}),r(le)!=="svelte-zsbb0y"&&(le.innerHTML=pr),mn=s(e),ne=i(e,"P",{"data-svelte-h":!0}),r(ne)!=="svelte-1gqkzq0"&&(ne.innerHTML=mr),cn=s(e),p(se.$$.fragment,e),hn=s(e),oe=i(e,"P",{"data-svelte-h":!0}),r(oe)!=="svelte-168zxvb"&&(oe.innerHTML=cr),un=s(e),ie=i(e,"P",{"data-svelte-h":!0}),r(ie)!=="svelte-18j5yjn"&&(ie.innerHTML=hr),fn=s(e),p(re.$$.fragment,e),Mn=s(e),de=i(e,"P",{"data-svelte-h":!0}),r(de)!=="svelte-8ll8w8"&&(de.innerHTML=ur),wn=s(e),p(pe.$$.fragment,e),yn=s(e),me=i(e,"P",{"data-svelte-h":!0}),r(me)!=="svelte-ryiojp"&&(me.innerHTML=fr),Tn=s(e),_=i(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),r(_)!=="svelte-2xjfr6"&&(_.innerHTML=Mr),bn=s(e),p(ce.$$.fragment,e),gn=s(e),p(he.$$.fragment,e),Jn=s(e),ue=i(e,"P",{"data-svelte-h":!0}),r(ue)!=="svelte-icixot"&&(ue.innerHTML=wr),_n=s(e),j=i(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),r(j)!=="svelte-p2g389"&&(j.innerHTML=yr),jn=s(e),p(fe.$$.fragment,e),vn=s(e),Me=i(e,"P",{"data-svelte-h":!0}),r(Me)!=="svelte-omuw13"&&(Me.innerHTML=Tr),kn=s(e),p(we.$$.fragment,e),Un=s(e),p(ye.$$.fragment,e),Zn=s(e),Te=i(e,"P",{"data-svelte-h":!0}),r(Te)!=="svelte-19ylu0a"&&(Te.innerHTML=br),Cn=s(e),be=i(e,"P",{"data-svelte-h":!0}),r(be)!=="svelte-wa0is0"&&(be.textContent=gr),Bn=s(e),p(ge.$$.fragment,e),$n=s(e),p(Je.$$.fragment,e),In=s(e),_e=i(e,"P",{"data-svelte-h":!0}),r(_e)!=="svelte-6vi5lg"&&(_e.textContent=Jr),Rn=s(e),p(je.$$.fragment,e),Wn=s(e),ve=i(e,"P",{"data-svelte-h":!0}),r(ve)!=="svelte-x8nt61"&&(ve.innerHTML=_r),Ln=s(e),p(ke.$$.fragment,e),An=s(e),Ue=i(e,"P",{"data-svelte-h":!0}),r(Ue)!=="svelte-8wzhde"&&(Ue.innerHTML=jr),Gn=s(e),p(Ze.$$.fragment,e),xn=s(e),Ce=i(e,"P",{"data-svelte-h":!0}),r(Ce)!=="svelte-16lyt50"&&(Ce.innerHTML=vr),Vn=s(e),p(Be.$$.fragment,e),Xn=s(e),p($e.$$.fragment,e),Fn=s(e),Ie=i(e,"P",{"data-svelte-h":!0}),r(Ie)!=="svelte-8z5o72"&&(Ie.innerHTML=kr),qn=s(e),Re=i(e,"TABLE",{"data-svelte-h":!0}),r(Re)!=="svelte-1dslnm4"&&(Re.innerHTML=Ur),En=s(e),We=i(e,"P",{"data-svelte-h":!0}),r(We)!=="svelte-6epr3r"&&(We.innerHTML=Zr),Hn=s(e),p(Le.$$.fragment,e),Yn=s(e),Ae=i(e,"P",{"data-svelte-h":!0}),r(Ae)!=="svelte-8kmgme"&&(Ae.innerHTML=Cr),Qn=s(e),Ge=i(e,"UL",{"data-svelte-h":!0}),r(Ge)!=="svelte-r8pzuc"&&(Ge.innerHTML=Br),zn=s(e),xe=i(e,"P",{"data-svelte-h":!0}),r(xe)!=="svelte-86zkpy"&&(xe.textContent=$r),Nn=s(e),p(Ve.$$.fragment,e),Sn=s(e),Xe=i(e,"UL",{"data-svelte-h":!0}),r(Xe)!=="svelte-16sw3ja"&&(Xe.innerHTML=Ir),Pn=s(e),p(Fe.$$.fragment,e),Dn=s(e),qe=i(e,"P",{"data-svelte-h":!0}),r(qe)!=="svelte-1r3v4w"&&(qe.textContent=Rr),Kn=s(e),p(Ee.$$.fragment,e),On=s(e),He=i(e,"P",{"data-svelte-h":!0}),r(He)!=="svelte-15vxux2"&&(He.innerHTML=Wr),es=s(e),p(Ye.$$.fragment,e),ts=s(e),Qe=i(e,"P",{"data-svelte-h":!0}),r(Qe)!=="svelte-eo2lbi"&&(Qe.innerHTML=Lr),as=s(e),p(ze.$$.fragment,e),ls=s(e),Ne=i(e,"P",{"data-svelte-h":!0}),r(Ne)!=="svelte-ku1fuj"&&(Ne.innerHTML=Ar),ns=s(e),p(Se.$$.fragment,e),ss=s(e),Pe=i(e,"P",{"data-svelte-h":!0}),r(Pe)!=="svelte-1ttqqw0"&&(Pe.innerHTML=Gr),os=s(e),De=i(e,"P",{"data-svelte-h":!0}),r(De)!=="svelte-foj0wd"&&(De.innerHTML=xr),is=s(e),p(Ke.$$.fragment,e),rs=s(e),Oe=i(e,"P",{"data-svelte-h":!0}),r(Oe)!=="svelte-ed0v39"&&(Oe.innerHTML=Vr),ds=s(e),et=i(e,"P",{"data-svelte-h":!0}),r(et)!=="svelte-dtt8e"&&(et.textContent=Xr),ps=s(e),p(tt.$$.fragment,e),ms=s(e),at=i(e,"UL",{"data-svelte-h":!0}),r(at)!=="svelte-1qf6hnm"&&(at.innerHTML=Fr),cs=s(e),lt=i(e,"P",{"data-svelte-h":!0}),r(lt)!=="svelte-qh5siy"&&(lt.innerHTML=qr),hs=s(e),p(nt.$$.fragment,e),us=s(e),st=i(e,"P",{"data-svelte-h":!0}),r(st)!=="svelte-jvkb1r"&&(st.innerHTML=Er),fs=s(e),ot=i(e,"P",{"data-svelte-h":!0}),r(ot)!=="svelte-1fvn09m"&&(ot.innerHTML=Hr),Ms=s(e),it=i(e,"P",{"data-svelte-h":!0}),r(it)!=="svelte-ecn69p"&&(it.innerHTML=Yr),ws=s(e),p(rt.$$.fragment,e),ys=s(e),dt=i(e,"UL",{"data-svelte-h":!0}),r(dt)!=="svelte-1h2fpez"&&(dt.innerHTML=Qr),Ts=s(e),p(pt.$$.fragment,e),bs=s(e),mt=i(e,"P",{"data-svelte-h":!0}),r(mt)!=="svelte-z4cpft"&&(mt.innerHTML=zr),gs=s(e),p(ct.$$.fragment,e),Js=s(e),ht=i(e,"P",{"data-svelte-h":!0}),r(ht)!=="svelte-jc16sb"&&(ht.innerHTML=Nr),_s=s(e),ut=i(e,"P",{"data-svelte-h":!0}),r(ut)!=="svelte-19jfwul"&&(ut.innerHTML=Sr),js=s(e),p(ft.$$.fragment,e),vs=s(e),Mt=i(e,"P",{"data-svelte-h":!0}),r(Mt)!=="svelte-awrlpj"&&(Mt.innerHTML=Pr),ks=s(e),p(wt.$$.fragment,e),Us=s(e),yt=i(e,"P",{"data-svelte-h":!0}),r(yt)!=="svelte-66nz7l"&&(yt.textContent=Dr),Zs=s(e),p(Tt.$$.fragment,e),Cs=s(e),bt=i(e,"P",{"data-svelte-h":!0}),r(bt)!=="svelte-n4djpz"&&(bt.textContent=Kr),Bs=s(e),gt=i(e,"P",{"data-svelte-h":!0}),r(gt)!=="svelte-19mzdup"&&(gt.innerHTML=Or),$s=s(e),Jt=i(e,"TABLE",{"data-svelte-h":!0}),r(Jt)!=="svelte-zhxypc"&&(Jt.innerHTML=ed),Is=s(e),p(_t.$$.fragment,e),Rs=s(e),jt=i(e,"P",{"data-svelte-h":!0}),r(jt)!=="svelte-ex5mu1"&&(jt.innerHTML=td),Ws=s(e),vt=i(e,"P",{"data-svelte-h":!0}),r(vt)!=="svelte-psdjsn"&&(vt.innerHTML=ad),Ls=s(e),kt=i(e,"P",{"data-svelte-h":!0}),r(kt)!=="svelte-1pk84qw"&&(kt.textContent=ld),As=s(e),p(Ut.$$.fragment,e),Gs=s(e),Zt=i(e,"TABLE",{"data-svelte-h":!0}),r(Zt)!=="svelte-xtypic"&&(Zt.innerHTML=nd),xs=s(e),p(Ct.$$.fragment,e),Vs=s(e),Bt=i(e,"TABLE",{"data-svelte-h":!0}),r(Bt)!=="svelte-e0umdx"&&(Bt.innerHTML=sd),Xs=s(e),p($t.$$.fragment,e),Fs=s(e),It=i(e,"P",{"data-svelte-h":!0}),r(It)!=="svelte-1atwpg3"&&(It.innerHTML=od),qs=s(e),Rt=i(e,"TABLE",{"data-svelte-h":!0}),r(Rt)!=="svelte-192ndes"&&(Rt.innerHTML=id),Es=s(e),Wt=i(e,"P",{"data-svelte-h":!0}),r(Wt)!=="svelte-1rv3xk7"&&(Wt.textContent=rd),Hs=s(e),Lt=i(e,"UL",{"data-svelte-h":!0}),r(Lt)!=="svelte-qamjs7"&&(Lt.innerHTML=dd),Ys=s(e),p(At.$$.fragment,e),Qs=s(e),Gt=i(e,"P",{"data-svelte-h":!0}),r(Gt)!=="svelte-ws58tf"&&(Gt.textContent=pd),zs=s(e),p(xt.$$.fragment,e),Ns=s(e),Vt=i(e,"P",{"data-svelte-h":!0}),r(Vt)!=="svelte-18tpzlm"&&(Vt.innerHTML=md),Ss=s(e),p(Xt.$$.fragment,e),Ps=s(e),p(Ft.$$.fragment,e),Ds=s(e),qt=i(e,"P",{"data-svelte-h":!0}),r(qt)!=="svelte-1i0u5p9"&&(qt.innerHTML=cd),Ks=s(e),p(Et.$$.fragment,e),Os=s(e),p(Ht.$$.fragment,e),eo=s(e),Yt=i(e,"P",{"data-svelte-h":!0}),r(Yt)!=="svelte-10bblrn"&&(Yt.textContent=hd),to=s(e),p(Qt.$$.fragment,e),ao=s(e),zt=i(e,"P",{"data-svelte-h":!0}),r(zt)!=="svelte-23q4ca"&&(zt.innerHTML=ud),lo=s(e),Nt=i(e,"P",{"data-svelte-h":!0}),r(Nt)!=="svelte-1wwmf5r"&&(Nt.textContent=fd),no=s(e),v=i(e,"DIV",{class:!0,"data-svelte-h":!0}),r(v)!=="svelte-1f6iuw5"&&(v.innerHTML=Md),so=s(e),St=i(e,"P",{"data-svelte-h":!0}),r(St)!=="svelte-hlzwis"&&(St.textContent=wd),oo=s(e),p(Pt.$$.fragment,e),io=s(e),Dt=i(e,"P",{"data-svelte-h":!0}),r(Dt)!=="svelte-1x4h4b0"&&(Dt.innerHTML=yd),ro=s(e),p(Kt.$$.fragment,e),po=s(e),Ot=i(e,"P",{"data-svelte-h":!0}),r(Ot)!=="svelte-kbqhpl"&&(Ot.innerHTML=Td),mo=s(e),ea=i(e,"P",{"data-svelte-h":!0}),r(ea)!=="svelte-1mwdwt1"&&(ea.textContent=bd),co=s(e),p(ta.$$.fragment,e),ho=s(e),aa=i(e,"P",{"data-svelte-h":!0}),r(aa)!=="svelte-1lnmg1d"&&(aa.textContent=gd),uo=s(e),p(la.$$.fragment,e),fo=s(e),na=i(e,"P",{"data-svelte-h":!0}),r(na)!=="svelte-1n53hd9"&&(na.textContent=Jd),Mo=s(e),p(sa.$$.fragment,e),wo=s(e),k=i(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),r(k)!=="svelte-18gsis4"&&(k.innerHTML=_d),yo=s(e),oa=i(e,"P",{"data-svelte-h":!0}),r(oa)!=="svelte-qwbdkg"&&(oa.textContent=jd),To=s(e),p(ia.$$.fragment,e),bo=s(e),p(ra.$$.fragment,e),go=s(e),da=i(e,"P",{"data-svelte-h":!0}),r(da)!=="svelte-1bm5wzk"&&(da.innerHTML=vd),Jo=s(e),pa=i(e,"P",{"data-svelte-h":!0}),r(pa)!=="svelte-1tr6wvs"&&(pa.textContent=kd),_o=s(e),ma=i(e,"P",{"data-svelte-h":!0}),r(ma)!=="svelte-1ni337v"&&(ma.textContent=Ud),jo=s(e),p(ca.$$.fragment,e),vo=s(e),ha=i(e,"P",{"data-svelte-h":!0}),r(ha)!=="svelte-106qof5"&&(ha.textContent=Zd),ko=s(e),ua=i(e,"P",{"data-svelte-h":!0}),r(ua)!=="svelte-smif4x"&&(ua.textContent=Cd),Uo=s(e),p(fa.$$.fragment,e),Zo=s(e),Ma=i(e,"P",{"data-svelte-h":!0}),r(Ma)!=="svelte-xr6qp7"&&(Ma.innerHTML=Bd),Co=s(e),p(wa.$$.fragment,e),Bo=s(e),ya=i(e,"P",{"data-svelte-h":!0}),r(ya)!=="svelte-1425iyh"&&(ya.innerHTML=$d),$o=s(e),p(Ta.$$.fragment,e),Io=s(e),p(ba.$$.fragment,e),Ro=s(e),ga=i(e,"P",{"data-svelte-h":!0}),r(ga)!=="svelte-1nopa8x"&&(ga.innerHTML=Id),Wo=s(e),U=i(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),r(U)!=="svelte-1xfrf8m"&&(U.innerHTML=Rd),Lo=s(e),Ja=i(e,"P",{"data-svelte-h":!0}),r(Ja)!=="svelte-13q6dws"&&(Ja.innerHTML=Wd),Ao=s(e),p(_a.$$.fragment,e),Go=s(e),ja=i(e,"P",{"data-svelte-h":!0}),r(ja)!=="svelte-vz807h"&&(ja.innerHTML=Ld),xo=s(e),p(va.$$.fragment,e),Vo=s(e),ka=i(e,"P",{"data-svelte-h":!0}),r(ka)!=="svelte-okuddl"&&(ka.textContent=Ad),Xo=s(e),p(Ua.$$.fragment,e),Fo=s(e),Za=i(e,"P",{"data-svelte-h":!0}),r(Za)!=="svelte-6ttvul"&&(Za.innerHTML=Gd),qo=s(e),Ca=i(e,"P",{"data-svelte-h":!0}),r(Ca)!=="svelte-4gntqu"&&(Ca.innerHTML=xd),Eo=s(e),p(Ba.$$.fragment,e),Ho=s(e),$a=i(e,"P",{"data-svelte-h":!0}),r($a)!=="svelte-14bh0mw"&&($a.textContent=Vd),Yo=s(e),p(Ia.$$.fragment,e),Qo=s(e),Ra=i(e,"P",{"data-svelte-h":!0}),r(Ra)!=="svelte-1x4zjl4"&&(Ra.innerHTML=Xd),zo=s(e),Wa=i(e,"P",{"data-svelte-h":!0}),r(Wa)!=="svelte-1dbt04g"&&(Wa.innerHTML=Fd),No=s(e),La=i(e,"UL",{"data-svelte-h":!0}),r(La)!=="svelte-1hqtaeg"&&(La.innerHTML=qd),So=s(e),p(Aa.$$.fragment,e),Po=s(e),Ga=i(e,"P",{"data-svelte-h":!0}),r(Ga)!=="svelte-1pb48d2"&&(Ga.innerHTML=Ed),Do=s(e),xa=i(e,"P",{"data-svelte-h":!0}),r(xa)!=="svelte-149wxvq"&&(xa.textContent=Hd),Ko=s(e),Va=i(e,"UL",{"data-svelte-h":!0}),r(Va)!=="svelte-1rhx7b3"&&(Va.innerHTML=Yd),Oo=s(e),Xa=i(e,"P",{"data-svelte-h":!0}),r(Xa)!=="svelte-15948xz"&&(Xa.innerHTML=Qd),ei=s(e),p(Fa.$$.fragment,e),ti=s(e),qa=i(e,"P",{"data-svelte-h":!0}),r(qa)!=="svelte-n95elu"&&(qa.innerHTML=zd),ai=s(e),Z=i(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),r(Z)!=="svelte-39vmv"&&(Z.innerHTML=Nd),li=s(e),Ea=i(e,"P",{"data-svelte-h":!0}),r(Ea)!=="svelte-qgp1p0"&&(Ea.textContent=Sd),ni=s(e),p(Ha.$$.fragment,e),si=s(e),Ya=i(e,"P",{"data-svelte-h":!0}),r(Ya)!=="svelte-noxq52"&&(Ya.innerHTML=Pd),oi=s(e),Qa=i(e,"OL",{"data-svelte-h":!0}),r(Qa)!=="svelte-1ptx1lp"&&(Qa.innerHTML=Dd),ii=s(e),za=i(e,"P",{"data-svelte-h":!0}),r(za)!=="svelte-xfbbvr"&&(za.innerHTML=Kd),ri=s(e),Na=i(e,"P",{"data-svelte-h":!0}),r(Na)!=="svelte-1qt6a9e"&&(Na.innerHTML=Od),di=s(e),p(Sa.$$.fragment,e),pi=s(e),Pa=i(e,"P",{"data-svelte-h":!0}),r(Pa)!=="svelte-e9wr3d"&&(Pa.innerHTML=ep),mi=s(e),p(Da.$$.fragment,e),ci=s(e),p(Ka.$$.fragment,e),hi=s(e),Oa=i(e,"P",{"data-svelte-h":!0}),r(Oa)!=="svelte-1fq5tpu"&&(Oa.textContent=tp),ui=s(e),el=i(e,"P",{"data-svelte-h":!0}),r(el)!=="svelte-lcywla"&&(el.innerHTML=ap),fi=s(e),p(tl.$$.fragment,e),Mi=s(e),al=i(e,"P",{"data-svelte-h":!0}),r(al)!=="svelte-6wkyom"&&(al.innerHTML=lp),wi=s(e),p(ll.$$.fragment,e),yi=s(e),nl=i(e,"P",{"data-svelte-h":!0}),r(nl)!=="svelte-1o40ch6"&&(nl.innerHTML=np),Ti=s(e),sl=i(e,"P",{"data-svelte-h":!0}),r(sl)!=="svelte-mqf2jo"&&(sl.innerHTML=sp),bi=s(e),p(ol.$$.fragment,e),gi=s(e),il=i(e,"P",{"data-svelte-h":!0}),r(il)!=="svelte-e0xhf6"&&(il.textContent=op),Ji=s(e),rl=i(e,"UL",{"data-svelte-h":!0}),r(rl)!=="svelte-9zbcsh"&&(rl.innerHTML=ip),_i=s(e),p(dl.$$.fragment,e),ji=s(e),p(pl.$$.fragment,e),vi=s(e),ml=i(e,"P",{"data-svelte-h":!0}),r(ml)!=="svelte-1qlwkok"&&(ml.innerHTML=rp),ki=s(e),cl=i(e,"P",{"data-svelte-h":!0}),r(cl)!=="svelte-c3e0m7"&&(cl.innerHTML=dp),Ui=s(e),p(hl.$$.fragment,e),Zi=s(e),ul=i(e,"P",{"data-svelte-h":!0}),r(ul)!=="svelte-13ney51"&&(ul.innerHTML=pp),Ci=s(e),p(fl.$$.fragment,e),Bi=s(e),p(Ml.$$.fragment,e),$i=s(e),wl=i(e,"P",{"data-svelte-h":!0}),r(wl)!=="svelte-1damsga"&&(wl.innerHTML=mp),Ii=s(e),yl=i(e,"P",{"data-svelte-h":!0}),r(yl)!=="svelte-bisu0r"&&(yl.innerHTML=cp),Ri=s(e),p(Tl.$$.fragment,e),Wi=s(e),bl=i(e,"P",{"data-svelte-h":!0}),r(bl)!=="svelte-19fqfkj"&&(bl.innerHTML=hp),Li=s(e),g=i(e,"BLOCKQUOTE",{class:!0});var Vi=Rl(g);jl=i(Vi,"P",{"data-svelte-h":!0}),r(jl)!=="svelte-14xydvq"&&(jl.innerHTML=up),Fi=s(Vi),y=i(Vi,"UL",{});var T=Rl(y);vl=i(T,"LI",{"data-svelte-h":!0}),r(vl)!=="svelte-1g552yx"&&(vl.innerHTML=fp),qi=s(T),kl=i(T,"LI",{"data-svelte-h":!0}),r(kl)!=="svelte-1kqmy9e"&&(kl.innerHTML=Mp),Ei=s(T),Ul=i(T,"LI",{"data-svelte-h":!0}),r(Ul)!=="svelte-o6l66k"&&(Ul.innerHTML=wp),Hi=s(T),Zl=i(T,"LI",{"data-svelte-h":!0}),r(Zl)!=="svelte-3a8u10"&&(Zl.innerHTML=yp),Yi=s(T),Cl=i(T,"LI",{"data-svelte-h":!0}),r(Cl)!=="svelte-1f7byj"&&(Cl.innerHTML=Tp),Qi=s(T),gl=i(T,"LI",{});var Xi=Rl(gl);Bl=i(Xi,"P",{"data-svelte-h":!0}),r(Bl)!=="svelte-1j9rbu8"&&(Bl.textContent=bp),zi=s(Xi),p(Jl.$$.fragment,Xi),Xi.forEach(a),T.forEach(a),Vi.forEach(a),Ai=s(e),p(_l.$$.fragment,e),Gi=s(e),Il=i(e,"P",{}),Rl(Il).forEach(a),this.h()},h(){J(b,"name","hf:doc:metadata"),J(b,"content",Bp),J(_,"class","tip"),J(j,"class","tip"),J(v,"class","flex justify-center"),J(k,"class","tip"),J(U,"class","warning"),J(Z,"class","note"),J(g,"class","tip")},m(e,t){w(document.head,b),l(e,Wl,t),l(e,$l,t),l(e,Ll,t),m(C,e,t),l(e,Al,t),m(B,e,t),l(e,Gl,t),l(e,$,t),l(e,xl,t),l(e,I,t),l(e,Vl,t),m(R,e,t),l(e,Xl,t),l(e,W,t),l(e,Fl,t),l(e,L,t),l(e,ql,t),m(A,e,t),l(e,El,t),l(e,G,t),l(e,Hl,t),m(x,e,t),l(e,Yl,t),m(V,e,t),l(e,Ql,t),l(e,X,t),l(e,zl,t),l(e,F,t),l(e,Nl,t),m(q,e,t),l(e,Sl,t),l(e,E,t),l(e,Pl,t),m(H,e,t),l(e,Dl,t),l(e,Y,t),l(e,Kl,t),m(Q,e,t),l(e,Ol,t),l(e,z,t),l(e,en,t),l(e,N,t),l(e,tn,t),m(S,e,t),l(e,an,t),l(e,P,t),l(e,ln,t),m(D,e,t),l(e,nn,t),l(e,K,t),l(e,sn,t),l(e,O,t),l(e,on,t),m(ee,e,t),l(e,rn,t),l(e,te,t),l(e,dn,t),m(ae,e,t),l(e,pn,t),l(e,le,t),l(e,mn,t),l(e,ne,t),l(e,cn,t),m(se,e,t),l(e,hn,t),l(e,oe,t),l(e,un,t),l(e,ie,t),l(e,fn,t),m(re,e,t),l(e,Mn,t),l(e,de,t),l(e,wn,t),m(pe,e,t),l(e,yn,t),l(e,me,t),l(e,Tn,t),l(e,_,t),l(e,bn,t),m(ce,e,t),l(e,gn,t),m(he,e,t),l(e,Jn,t),l(e,ue,t),l(e,_n,t),l(e,j,t),l(e,jn,t),m(fe,e,t),l(e,vn,t),l(e,Me,t),l(e,kn,t),m(we,e,t),l(e,Un,t),m(ye,e,t),l(e,Zn,t),l(e,Te,t),l(e,Cn,t),l(e,be,t),l(e,Bn,t),m(ge,e,t),l(e,$n,t),m(Je,e,t),l(e,In,t),l(e,_e,t),l(e,Rn,t),m(je,e,t),l(e,Wn,t),l(e,ve,t),l(e,Ln,t),m(ke,e,t),l(e,An,t),l(e,Ue,t),l(e,Gn,t),m(Ze,e,t),l(e,xn,t),l(e,Ce,t),l(e,Vn,t),m(Be,e,t),l(e,Xn,t),m($e,e,t),l(e,Fn,t),l(e,Ie,t),l(e,qn,t),l(e,Re,t),l(e,En,t),l(e,We,t),l(e,Hn,t),m(Le,e,t),l(e,Yn,t),l(e,Ae,t),l(e,Qn,t),l(e,Ge,t),l(e,zn,t),l(e,xe,t),l(e,Nn,t),m(Ve,e,t),l(e,Sn,t),l(e,Xe,t),l(e,Pn,t),m(Fe,e,t),l(e,Dn,t),l(e,qe,t),l(e,Kn,t),m(Ee,e,t),l(e,On,t),l(e,He,t),l(e,es,t),m(Ye,e,t),l(e,ts,t),l(e,Qe,t),l(e,as,t),m(ze,e,t),l(e,ls,t),l(e,Ne,t),l(e,ns,t),m(Se,e,t),l(e,ss,t),l(e,Pe,t),l(e,os,t),l(e,De,t),l(e,is,t),m(Ke,e,t),l(e,rs,t),l(e,Oe,t),l(e,ds,t),l(e,et,t),l(e,ps,t),m(tt,e,t),l(e,ms,t),l(e,at,t),l(e,cs,t),l(e,lt,t),l(e,hs,t),m(nt,e,t),l(e,us,t),l(e,st,t),l(e,fs,t),l(e,ot,t),l(e,Ms,t),l(e,it,t),l(e,ws,t),m(rt,e,t),l(e,ys,t),l(e,dt,t),l(e,Ts,t),m(pt,e,t),l(e,bs,t),l(e,mt,t),l(e,gs,t),m(ct,e,t),l(e,Js,t),l(e,ht,t),l(e,_s,t),l(e,ut,t),l(e,js,t),m(ft,e,t),l(e,vs,t),l(e,Mt,t),l(e,ks,t),m(wt,e,t),l(e,Us,t),l(e,yt,t),l(e,Zs,t),m(Tt,e,t),l(e,Cs,t),l(e,bt,t),l(e,Bs,t),l(e,gt,t),l(e,$s,t),l(e,Jt,t),l(e,Is,t),m(_t,e,t),l(e,Rs,t),l(e,jt,t),l(e,Ws,t),l(e,vt,t),l(e,Ls,t),l(e,kt,t),l(e,As,t),m(Ut,e,t),l(e,Gs,t),l(e,Zt,t),l(e,xs,t),m(Ct,e,t),l(e,Vs,t),l(e,Bt,t),l(e,Xs,t),m($t,e,t),l(e,Fs,t),l(e,It,t),l(e,qs,t),l(e,Rt,t),l(e,Es,t),l(e,Wt,t),l(e,Hs,t),l(e,Lt,t),l(e,Ys,t),m(At,e,t),l(e,Qs,t),l(e,Gt,t),l(e,zs,t),m(xt,e,t),l(e,Ns,t),l(e,Vt,t),l(e,Ss,t),m(Xt,e,t),l(e,Ps,t),m(Ft,e,t),l(e,Ds,t),l(e,qt,t),l(e,Ks,t),m(Et,e,t),l(e,Os,t),m(Ht,e,t),l(e,eo,t),l(e,Yt,t),l(e,to,t),m(Qt,e,t),l(e,ao,t),l(e,zt,t),l(e,lo,t),l(e,Nt,t),l(e,no,t),l(e,v,t),l(e,so,t),l(e,St,t),l(e,oo,t),m(Pt,e,t),l(e,io,t),l(e,Dt,t),l(e,ro,t),m(Kt,e,t),l(e,po,t),l(e,Ot,t),l(e,mo,t),l(e,ea,t),l(e,co,t),m(ta,e,t),l(e,ho,t),l(e,aa,t),l(e,uo,t),m(la,e,t),l(e,fo,t),l(e,na,t),l(e,Mo,t),m(sa,e,t),l(e,wo,t),l(e,k,t),l(e,yo,t),l(e,oa,t),l(e,To,t),m(ia,e,t),l(e,bo,t),m(ra,e,t),l(e,go,t),l(e,da,t),l(e,Jo,t),l(e,pa,t),l(e,_o,t),l(e,ma,t),l(e,jo,t),m(ca,e,t),l(e,vo,t),l(e,ha,t),l(e,ko,t),l(e,ua,t),l(e,Uo,t),m(fa,e,t),l(e,Zo,t),l(e,Ma,t),l(e,Co,t),m(wa,e,t),l(e,Bo,t),l(e,ya,t),l(e,$o,t),m(Ta,e,t),l(e,Io,t),m(ba,e,t),l(e,Ro,t),l(e,ga,t),l(e,Wo,t),l(e,U,t),l(e,Lo,t),l(e,Ja,t),l(e,Ao,t),m(_a,e,t),l(e,Go,t),l(e,ja,t),l(e,xo,t),m(va,e,t),l(e,Vo,t),l(e,ka,t),l(e,Xo,t),m(Ua,e,t),l(e,Fo,t),l(e,Za,t),l(e,qo,t),l(e,Ca,t),l(e,Eo,t),m(Ba,e,t),l(e,Ho,t),l(e,$a,t),l(e,Yo,t),m(Ia,e,t),l(e,Qo,t),l(e,Ra,t),l(e,zo,t),l(e,Wa,t),l(e,No,t),l(e,La,t),l(e,So,t),m(Aa,e,t),l(e,Po,t),l(e,Ga,t),l(e,Do,t),l(e,xa,t),l(e,Ko,t),l(e,Va,t),l(e,Oo,t),l(e,Xa,t),l(e,ei,t),m(Fa,e,t),l(e,ti,t),l(e,qa,t),l(e,ai,t),l(e,Z,t),l(e,li,t),l(e,Ea,t),l(e,ni,t),m(Ha,e,t),l(e,si,t),l(e,Ya,t),l(e,oi,t),l(e,Qa,t),l(e,ii,t),l(e,za,t),l(e,ri,t),l(e,Na,t),l(e,di,t),m(Sa,e,t),l(e,pi,t),l(e,Pa,t),l(e,mi,t),m(Da,e,t),l(e,ci,t),m(Ka,e,t),l(e,hi,t),l(e,Oa,t),l(e,ui,t),l(e,el,t),l(e,fi,t),m(tl,e,t),l(e,Mi,t),l(e,al,t),l(e,wi,t),m(ll,e,t),l(e,yi,t),l(e,nl,t),l(e,Ti,t),l(e,sl,t),l(e,bi,t),m(ol,e,t),l(e,gi,t),l(e,il,t),l(e,Ji,t),l(e,rl,t),l(e,_i,t),m(dl,e,t),l(e,ji,t),m(pl,e,t),l(e,vi,t),l(e,ml,t),l(e,ki,t),l(e,cl,t),l(e,Ui,t),m(hl,e,t),l(e,Zi,t),l(e,ul,t),l(e,Ci,t),m(fl,e,t),l(e,Bi,t),m(Ml,e,t),l(e,$i,t),l(e,wl,t),l(e,Ii,t),l(e,yl,t),l(e,Ri,t),m(Tl,e,t),l(e,Wi,t),l(e,bl,t),l(e,Li,t),l(e,g,t),w(g,jl),w(g,Fi),w(g,y),w(y,vl),w(y,qi),w(y,kl),w(y,Ei),w(y,Ul),w(y,Hi),w(y,Zl),w(y,Yi),w(y,Cl),w(y,Qi),w(y,gl),w(gl,Bl),w(gl,zi),m(Jl,gl,null),l(e,Ai,t),m(_l,e,t),l(e,Gi,t),l(e,Il,t),xi=!0},p:Jp,i(e){xi||(c(C.$$.fragment,e),c(B.$$.fragment,e),c(R.$$.fragment,e),c(A.$$.fragment,e),c(x.$$.fragment,e),c(V.$$.fragment,e),c(q.$$.fragment,e),c(H.$$.fragment,e),c(Q.$$.fragment,e),c(S.$$.fragment,e),c(D.$$.fragment,e),c(ee.$$.fragment,e),c(ae.$$.fragment,e),c(se.$$.fragment,e),c(re.$$.fragment,e),c(pe.$$.fragment,e),c(ce.$$.fragment,e),c(he.$$.fragment,e),c(fe.$$.fragment,e),c(we.$$.fragment,e),c(ye.$$.fragment,e),c(ge.$$.fragment,e),c(Je.$$.fragment,e),c(je.$$.fragment,e),c(ke.$$.fragment,e),c(Ze.$$.fragment,e),c(Be.$$.fragment,e),c($e.$$.fragment,e),c(Le.$$.fragment,e),c(Ve.$$.fragment,e),c(Fe.$$.fragment,e),c(Ee.$$.fragment,e),c(Ye.$$.fragment,e),c(ze.$$.fragment,e),c(Se.$$.fragment,e),c(Ke.$$.fragment,e),c(tt.$$.fragment,e),c(nt.$$.fragment,e),c(rt.$$.fragment,e),c(pt.$$.fragment,e),c(ct.$$.fragment,e),c(ft.$$.fragment,e),c(wt.$$.fragment,e),c(Tt.$$.fragment,e),c(_t.$$.fragment,e),c(Ut.$$.fragment,e),c(Ct.$$.fragment,e),c($t.$$.fragment,e),c(At.$$.fragment,e),c(xt.$$.fragment,e),c(Xt.$$.fragment,e),c(Ft.$$.fragment,e),c(Et.$$.fragment,e),c(Ht.$$.fragment,e),c(Qt.$$.fragment,e),c(Pt.$$.fragment,e),c(Kt.$$.fragment,e),c(ta.$$.fragment,e),c(la.$$.fragment,e),c(sa.$$.fragment,e),c(ia.$$.fragment,e),c(ra.$$.fragment,e),c(ca.$$.fragment,e),c(fa.$$.fragment,e),c(wa.$$.fragment,e),c(Ta.$$.fragment,e),c(ba.$$.fragment,e),c(_a.$$.fragment,e),c(va.$$.fragment,e),c(Ua.$$.fragment,e),c(Ba.$$.fragment,e),c(Ia.$$.fragment,e),c(Aa.$$.fragment,e),c(Fa.$$.fragment,e),c(Ha.$$.fragment,e),c(Sa.$$.fragment,e),c(Da.$$.fragment,e),c(Ka.$$.fragment,e),c(tl.$$.fragment,e),c(ll.$$.fragment,e),c(ol.$$.fragment,e),c(dl.$$.fragment,e),c(pl.$$.fragment,e),c(hl.$$.fragment,e),c(fl.$$.fragment,e),c(Ml.$$.fragment,e),c(Tl.$$.fragment,e),c(Jl.$$.fragment,e),c(_l.$$.fragment,e),xi=!0)},o(e){h(C.$$.fragment,e),h(B.$$.fragment,e),h(R.$$.fragment,e),h(A.$$.fragment,e),h(x.$$.fragment,e),h(V.$$.fragment,e),h(q.$$.fragment,e),h(H.$$.fragment,e),h(Q.$$.fragment,e),h(S.$$.fragment,e),h(D.$$.fragment,e),h(ee.$$.fragment,e),h(ae.$$.fragment,e),h(se.$$.fragment,e),h(re.$$.fragment,e),h(pe.$$.fragment,e),h(ce.$$.fragment,e),h(he.$$.fragment,e),h(fe.$$.fragment,e),h(we.$$.fragment,e),h(ye.$$.fragment,e),h(ge.$$.fragment,e),h(Je.$$.fragment,e),h(je.$$.fragment,e),h(ke.$$.fragment,e),h(Ze.$$.fragment,e),h(Be.$$.fragment,e),h($e.$$.fragment,e),h(Le.$$.fragment,e),h(Ve.$$.fragment,e),h(Fe.$$.fragment,e),h(Ee.$$.fragment,e),h(Ye.$$.fragment,e),h(ze.$$.fragment,e),h(Se.$$.fragment,e),h(Ke.$$.fragment,e),h(tt.$$.fragment,e),h(nt.$$.fragment,e),h(rt.$$.fragment,e),h(pt.$$.fragment,e),h(ct.$$.fragment,e),h(ft.$$.fragment,e),h(wt.$$.fragment,e),h(Tt.$$.fragment,e),h(_t.$$.fragment,e),h(Ut.$$.fragment,e),h(Ct.$$.fragment,e),h($t.$$.fragment,e),h(At.$$.fragment,e),h(xt.$$.fragment,e),h(Xt.$$.fragment,e),h(Ft.$$.fragment,e),h(Et.$$.fragment,e),h(Ht.$$.fragment,e),h(Qt.$$.fragment,e),h(Pt.$$.fragment,e),h(Kt.$$.fragment,e),h(ta.$$.fragment,e),h(la.$$.fragment,e),h(sa.$$.fragment,e),h(ia.$$.fragment,e),h(ra.$$.fragment,e),h(ca.$$.fragment,e),h(fa.$$.fragment,e),h(wa.$$.fragment,e),h(Ta.$$.fragment,e),h(ba.$$.fragment,e),h(_a.$$.fragment,e),h(va.$$.fragment,e),h(Ua.$$.fragment,e),h(Ba.$$.fragment,e),h(Ia.$$.fragment,e),h(Aa.$$.fragment,e),h(Fa.$$.fragment,e),h(Ha.$$.fragment,e),h(Sa.$$.fragment,e),h(Da.$$.fragment,e),h(Ka.$$.fragment,e),h(tl.$$.fragment,e),h(ll.$$.fragment,e),h(ol.$$.fragment,e),h(dl.$$.fragment,e),h(pl.$$.fragment,e),h(hl.$$.fragment,e),h(fl.$$.fragment,e),h(Ml.$$.fragment,e),h(Tl.$$.fragment,e),h(Jl.$$.fragment,e),h(_l.$$.fragment,e),xi=!1},d(e){e&&(a(Wl),a($l),a(Ll),a(Al),a(Gl),a($),a(xl),a(I),a(Vl),a(Xl),a(W),a(Fl),a(L),a(ql),a(El),a(G),a(Hl),a(Yl),a(Ql),a(X),a(zl),a(F),a(Nl),a(Sl),a(E),a(Pl),a(Dl),a(Y),a(Kl),a(Ol),a(z),a(en),a(N),a(tn),a(an),a(P),a(ln),a(nn),a(K),a(sn),a(O),a(on),a(rn),a(te),a(dn),a(pn),a(le),a(mn),a(ne),a(cn),a(hn),a(oe),a(un),a(ie),a(fn),a(Mn),a(de),a(wn),a(yn),a(me),a(Tn),a(_),a(bn),a(gn),a(Jn),a(ue),a(_n),a(j),a(jn),a(vn),a(Me),a(kn),a(Un),a(Zn),a(Te),a(Cn),a(be),a(Bn),a($n),a(In),a(_e),a(Rn),a(Wn),a(ve),a(Ln),a(An),a(Ue),a(Gn),a(xn),a(Ce),a(Vn),a(Xn),a(Fn),a(Ie),a(qn),a(Re),a(En),a(We),a(Hn),a(Yn),a(Ae),a(Qn),a(Ge),a(zn),a(xe),a(Nn),a(Sn),a(Xe),a(Pn),a(Dn),a(qe),a(Kn),a(On),a(He),a(es),a(ts),a(Qe),a(as),a(ls),a(Ne),a(ns),a(ss),a(Pe),a(os),a(De),a(is),a(rs),a(Oe),a(ds),a(et),a(ps),a(ms),a(at),a(cs),a(lt),a(hs),a(us),a(st),a(fs),a(ot),a(Ms),a(it),a(ws),a(ys),a(dt),a(Ts),a(bs),a(mt),a(gs),a(Js),a(ht),a(_s),a(ut),a(js),a(vs),a(Mt),a(ks),a(Us),a(yt),a(Zs),a(Cs),a(bt),a(Bs),a(gt),a($s),a(Jt),a(Is),a(Rs),a(jt),a(Ws),a(vt),a(Ls),a(kt),a(As),a(Gs),a(Zt),a(xs),a(Vs),a(Bt),a(Xs),a(Fs),a(It),a(qs),a(Rt),a(Es),a(Wt),a(Hs),a(Lt),a(Ys),a(Qs),a(Gt),a(zs),a(Ns),a(Vt),a(Ss),a(Ps),a(Ds),a(qt),a(Ks),a(Os),a(eo),a(Yt),a(to),a(ao),a(zt),a(lo),a(Nt),a(no),a(v),a(so),a(St),a(oo),a(io),a(Dt),a(ro),a(po),a(Ot),a(mo),a(ea),a(co),a(ho),a(aa),a(uo),a(fo),a(na),a(Mo),a(wo),a(k),a(yo),a(oa),a(To),a(bo),a(go),a(da),a(Jo),a(pa),a(_o),a(ma),a(jo),a(vo),a(ha),a(ko),a(ua),a(Uo),a(Zo),a(Ma),a(Co),a(Bo),a(ya),a($o),a(Io),a(Ro),a(ga),a(Wo),a(U),a(Lo),a(Ja),a(Ao),a(Go),a(ja),a(xo),a(Vo),a(ka),a(Xo),a(Fo),a(Za),a(qo),a(Ca),a(Eo),a(Ho),a($a),a(Yo),a(Qo),a(Ra),a(zo),a(Wa),a(No),a(La),a(So),a(Po),a(Ga),a(Do),a(xa),a(Ko),a(Va),a(Oo),a(Xa),a(ei),a(ti),a(qa),a(ai),a(Z),a(li),a(Ea),a(ni),a(si),a(Ya),a(oi),a(Qa),a(ii),a(za),a(ri),a(Na),a(di),a(pi),a(Pa),a(mi),a(ci),a(hi),a(Oa),a(ui),a(el),a(fi),a(Mi),a(al),a(wi),a(yi),a(nl),a(Ti),a(sl),a(bi),a(gi),a(il),a(Ji),a(rl),a(_i),a(ji),a(vi),a(ml),a(ki),a(cl),a(Ui),a(Zi),a(ul),a(Ci),a(Bi),a($i),a(wl),a(Ii),a(yl),a(Ri),a(Wi),a(bl),a(Li),a(g),a(Ai),a(Gi),a(Il)),a(b),u(C,e),u(B,e),u(R,e),u(A,e),u(x,e),u(V,e),u(q,e),u(H,e),u(Q,e),u(S,e),u(D,e),u(ee,e),u(ae,e),u(se,e),u(re,e),u(pe,e),u(ce,e),u(he,e),u(fe,e),u(we,e),u(ye,e),u(ge,e),u(Je,e),u(je,e),u(ke,e),u(Ze,e),u(Be,e),u($e,e),u(Le,e),u(Ve,e),u(Fe,e),u(Ee,e),u(Ye,e),u(ze,e),u(Se,e),u(Ke,e),u(tt,e),u(nt,e),u(rt,e),u(pt,e),u(ct,e),u(ft,e),u(wt,e),u(Tt,e),u(_t,e),u(Ut,e),u(Ct,e),u($t,e),u(At,e),u(xt,e),u(Xt,e),u(Ft,e),u(Et,e),u(Ht,e),u(Qt,e),u(Pt,e),u(Kt,e),u(ta,e),u(la,e),u(sa,e),u(ia,e),u(ra,e),u(ca,e),u(fa,e),u(wa,e),u(Ta,e),u(ba,e),u(_a,e),u(va,e),u(Ua,e),u(Ba,e),u(Ia,e),u(Aa,e),u(Fa,e),u(Ha,e),u(Sa,e),u(Da,e),u(Ka,e),u(tl,e),u(ll,e),u(ol,e),u(dl,e),u(pl,e),u(hl,e),u(fl,e),u(Ml,e),u(Tl,e),u(Jl),u(_l,e)}}}const Bp='{"title":"LoRA","local":"lora","sections":[{"title":"Initialization","local":"initialization","sections":[{"title":"PiSSA","local":"pissa","sections":[],"depth":3},{"title":"CorDA","local":"corda","sections":[],"depth":3},{"title":"OLoRA","local":"olora","sections":[],"depth":3},{"title":"EVA","local":"eva","sections":[],"depth":3},{"title":"LoftQ","local":"loftq","sections":[{"title":"Standard approach","local":"standard-approach","sections":[],"depth":4}],"depth":3},{"title":"Rank-stabilized LoRA","local":"rank-stabilized-lora","sections":[],"depth":3},{"title":"LoRA-GA","local":"lora-ga","sections":[],"depth":3}],"depth":2},{"title":"Variants","local":"variants","sections":[{"title":"Weight-Decomposed Low-Rank Adaptation (DoRA)","local":"weight-decomposed-low-rank-adaptation-dora","sections":[{"title":"Optimization","local":"optimization","sections":[],"depth":4},{"title":"Caveats","local":"caveats","sections":[],"depth":4}],"depth":3}],"depth":2},{"title":"Training","local":"training","sections":[{"title":"QLoRA-style training","local":"qlora-style-training","sections":[],"depth":3},{"title":"Memory efficient Layer Replication with LoRA","local":"memory-efficient-layer-replication-with-lora","sections":[],"depth":3},{"title":"Fine grained control over ranks and alpha (scaling)","local":"fine-grained-control-over-ranks-and-alpha-scaling","sections":[],"depth":3},{"title":"Targeting nn.Parameter directly","local":"targeting-nnparameter-directly","sections":[{"title":"Caveats","local":"caveats","sections":[],"depth":4},{"title":"MoE expert parameters and vLLM","local":"moe-expert-parameters-and-vllm","sections":[],"depth":4}],"depth":3},{"title":"Efficiently train tokens alongside LoRA","local":"efficiently-train-tokens-alongside-lora","sections":[],"depth":3},{"title":"Weight tying","local":"weight-tying","sections":[{"title":"modules_to_save","local":"modulestosave","sections":[],"depth":4},{"title":"target_modules","local":"targetmodules","sections":[],"depth":4},{"title":"trainable_token_indices","local":"trainabletokenindices","sections":[],"depth":4}],"depth":3}],"depth":2},{"title":"Optimizers","local":"optimizers","sections":[{"title":"LoRA-FA Optimizer","local":"lora-fa-optimizer","sections":[],"depth":3},{"title":"LoRA+ optimized LoRA","local":"lora-optimized-lora","sections":[],"depth":3}],"depth":2},{"title":"Post-Training","local":"post-training","sections":[{"title":"Merge LoRA weights into the base model","local":"merge-lora-weights-into-the-base-model","sections":[],"depth":3},{"title":"Recovering base model performance via intruder dimension reduction","local":"recovering-base-model-performance-via-intruder-dimension-reduction","sections":[],"depth":3}],"depth":2},{"title":"Load adapters","local":"load-adapters","sections":[],"depth":2},{"title":"Tensor Parallelism","local":"tensor-parallelism","sections":[],"depth":2},{"title":"Inference","local":"inference","sections":[{"title":"Activated LoRA (aLoRA)","local":"activated-lora-alora","sections":[{"title":"Choice of invocation sequence and SFT design","local":"choice-of-invocation-sequence-and-sft-design","sections":[],"depth":4},{"title":"Using (and reusing) cache for generation","local":"using-and-reusing-cache-for-generation","sections":[],"depth":4}],"depth":3},{"title":"Inference with different LoRA adapters in the same batch","local":"inference-with-different-lora-adapters-in-the-same-batch","sections":[{"title":"Caveats","local":"caveats","sections":[],"depth":4}],"depth":3},{"title":"Composing and Reusing LoRA Adapters","local":"composing-and-reusing-lora-adapters","sections":[{"title":"Arrow","local":"arrow","sections":[],"depth":4},{"title":"GenKnowSub","local":"genknowsub","sections":[],"depth":4}],"depth":3}],"depth":2}],"depth":1}';function $p(Ni){return _p(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ap extends jp{constructor(b){super(),vp(this,b,$p,Cp,gp,{})}}export{Ap as component};
