Buckets:
| import{s as Xt,o as Vt,n as ue}from"../chunks/scheduler.182ea377.js";import{S as Et,i as Nt,g as p,s as i,r as u,A as Ht,h as f,f as l,c as o,j as Bt,u as h,x as m,k as Gt,y as Yt,a,v as d,d as M,t as y,w as _}from"../chunks/index.abf12888.js";import{T as de}from"../chunks/Tip.230e2334.js";import{C as $}from"../chunks/CodeBlock.57fe6e13.js";import{H as Me}from"../chunks/Heading.16916d63.js";import{H as Ft,a as Wt}from"../chunks/HfOption.fc88c804.js";function St(w){let n,r="This is experimental and the API may change in the future.";return{c(){n=p("p"),n.textContent=r},l(s){n=f(s,"P",{"data-svelte-h":!0}),m(n)!=="svelte-us7smu"&&(n.textContent=r)},m(s,b){a(s,n,b)},p:ue,d(s){s&&l(n)}}}function Qt(w){let n,r='LoRA is very versatile and supported for <a href="https://github.com/huggingface/diffusers/blob/main/examples/dreambooth/train_dreambooth_lora.py" rel="nofollow">DreamBooth</a>, <a href="https://github.com/huggingface/diffusers/blob/main/examples/kandinsky2_2/text_to_image/train_text_to_image_lora_decoder.py" rel="nofollow">Kandinsky 2.2</a>, <a href="https://github.com/huggingface/diffusers/blob/main/examples/text_to_image/train_text_to_image_lora_sdxl.py" rel="nofollow">Stable Diffusion XL</a>, <a href="https://github.com/huggingface/diffusers/blob/main/examples/text_to_image/train_text_to_image_lora.py" rel="nofollow">text-to-image</a>, and <a href="https://github.com/huggingface/diffusers/blob/main/examples/wuerstchen/text_to_image/train_text_to_image_lora_prior.py" rel="nofollow">Wuerstchen</a>.';return{c(){n=p("p"),n.innerHTML=r},l(s){n=f(s,"P",{"data-svelte-h":!0}),m(n)!=="svelte-1xa3xmb"&&(n.innerHTML=r)},m(s,b){a(s,n,b)},p:ue,d(s){s&&l(n)}}}function zt(w){let n,r;return n=new $({props:{code:"Y2QlMjBleGFtcGxlcyUyRnRleHRfdG9faW1hZ2UlMEFwaXAlMjBpbnN0YWxsJTIwLXIlMjByZXF1aXJlbWVudHMudHh0",highlighted:`<span class="hljs-built_in">cd</span> examples/text_to_image | |
| pip install -r requirements.txt`,wrap:!1}}),{c(){u(n.$$.fragment)},l(s){h(n.$$.fragment,s)},m(s,b){d(n,s,b),r=!0},p:ue,i(s){r||(M(n.$$.fragment,s),r=!0)},o(s){y(n.$$.fragment,s),r=!1},d(s){_(n,s)}}}function qt(w){let n,r;return n=new $({props:{code:"Y2QlMjBleGFtcGxlcyUyRnRleHRfdG9faW1hZ2UlMEFwaXAlMjBpbnN0YWxsJTIwLXIlMjByZXF1aXJlbWVudHNfZmxheC50eHQ=",highlighted:`<span class="hljs-built_in">cd</span> examples/text_to_image | |
| pip install -r requirements_flax.txt`,wrap:!1}}),{c(){u(n.$$.fragment)},l(s){h(n.$$.fragment,s)},m(s,b){d(n,s,b),r=!0},p:ue,i(s){r||(M(n.$$.fragment,s),r=!0)},o(s){y(n.$$.fragment,s),r=!1},d(s){_(n,s)}}}function Pt(w){let n,r,s,b;return n=new Wt({props:{id:"installation",option:"PyTorch",$$slots:{default:[zt]},$$scope:{ctx:w}}}),s=new Wt({props:{id:"installation",option:"Flax",$$slots:{default:[qt]},$$scope:{ctx:w}}}),{c(){u(n.$$.fragment),r=i(),u(s.$$.fragment)},l(c){h(n.$$.fragment,c),r=o(c),h(s.$$.fragment,c)},m(c,g){d(n,c,g),a(c,r,g),d(s,c,g),b=!0},p(c,g){const T={};g&2&&(T.$$scope={dirty:g,ctx:c}),n.$set(T);const v={};g&2&&(v.$$scope={dirty:g,ctx:c}),s.$set(v)},i(c){b||(M(n.$$.fragment,c),M(s.$$.fragment,c),b=!0)},o(c){y(n.$$.fragment,c),y(s.$$.fragment,c),b=!1},d(c){c&&l(r),_(n,c),_(s,c)}}}function Dt(w){let n,r='🤗 Accelerate is a library for helping you train on multiple GPUs/TPUs or with mixed-precision. It’ll automatically configure your training setup based on your hardware and environment. Take a look at the 🤗 Accelerate <a href="https://huggingface.co/docs/accelerate/quicktour" rel="nofollow">Quick tour</a> to learn more.';return{c(){n=p("p"),n.innerHTML=r},l(s){n=f(s,"P",{"data-svelte-h":!0}),m(n)!=="svelte-1qbiqsn"&&(n.innerHTML=r)},m(s,b){a(s,n,b)},p:ue,d(s){s&&l(n)}}}function Kt(w){let n,r='The following sections highlight parts of the training script that are important for understanding how to modify it, but it doesn’t cover every aspect of the script in detail. If you’re interested in learning more, feel free to read through the <a href="https://github.com/huggingface/diffusers/blob/main/examples/text_to_image/text_to_image_lora.py" rel="nofollow">script</a> and let us know if you have any questions or concerns.';return{c(){n=p("p"),n.innerHTML=r},l(s){n=f(s,"P",{"data-svelte-h":!0}),m(n)!=="svelte-ckqpc4"&&(n.innerHTML=r)},m(s,b){a(s,n,b)},p:ue,d(s){s&&l(n)}}}function Ot(w){let n,r="A full training run takes ~5 hours on a 2080 Ti GPU with 11GB of VRAM.";return{c(){n=p("p"),n.textContent=r},l(s){n=f(s,"P",{"data-svelte-h":!0}),m(n)!=="svelte-phs0cw"&&(n.textContent=r)},m(s,b){a(s,n,b)},p:ue,d(s){s&&l(n)}}}function el(w){let n,r,s,b,c,g,T,v,R,it='<a href="https://hf.co/papers/2106.09685" rel="nofollow">LoRA (Low-Rank Adaptation of Large Language Models)</a> is a popular and lightweight training technique that significantly reduces the number of trainable parameters. It works by inserting a smaller number of new weights into the model and only these are trained. This makes training with LoRA much faster, memory-efficient, and produces smaller model weights (a few hundred MBs), which are easier to store and share. LoRA can also be combined with other training techniques like DreamBooth to speedup training.',ye,J,_e,I,ot='This guide will explore the <a href="https://github.com/huggingface/diffusers/blob/main/examples/text_to_image/train_text_to_image_lora.py" rel="nofollow">train_text_to_image_lora.py</a> script to help you become more familiar with it, and how you can adapt it for your own use-case.',be,Z,rt="Before running the script, make sure you install the library from source:",we,k,ge,A,pt="Navigate to the example folder with the training script and install the required dependencies for the script you’re using:",Te,U,$e,j,Je,L,ft="Initialize an 🤗 Accelerate environment:",Ue,B,je,G,mt="To setup a default 🤗 Accelerate environment without choosing any configurations:",xe,W,Ce,X,ct="Or if your environment doesn’t support an interactive shell, like a notebook, you can use:",ve,V,Re,E,ut='Lastly, if you want to train a model on your own dataset, take a look at the <a href="create_dataset">Create a dataset for training</a> guide to learn how to create a dataset that works with the training script.',Ie,x,Ze,N,ke,H,ht='The training script has many parameters to help you customize your training run. All of the parameters and their descriptions are found in the <a href="https://github.com/huggingface/diffusers/blob/dd9a5caf61f04d11c0fa9f3947b69ab0010c9a0f/examples/text_to_image/train_text_to_image_lora.py#L85" rel="nofollow"><code>parse_args()</code></a> function. Default values are provided for most parameters that work pretty well, but you can also set your own values in the training command if you’d like.',Ae,Y,dt="For example, to increase the number of epochs to train:",Le,F,Be,S,Mt='Many of the basic and important parameters are described in the <a href="text2image#script-parameters">Text-to-image</a> training guide, so this guide just focuses on the LoRA relevant parameters:',Ge,Q,yt="<li><code>--rank</code>: the inner dimension of the low-rank matrices to train; a higher rank means more trainable parameters</li> <li><code>--learning_rate</code>: the default learning rate is 1e-4, but with LoRA, you can use a higher learning rate</li>",We,z,Xe,q,_t='The dataset preprocessing code and training loop are found in the <a href="https://github.com/huggingface/diffusers/blob/dd9a5caf61f04d11c0fa9f3947b69ab0010c9a0f/examples/text_to_image/train_text_to_image_lora.py#L371" rel="nofollow"><code>main()</code></a> function, and if you need to adapt the training script, this is where you’ll make your changes.',Ve,P,bt='As with the script parameters, a walkthrough of the training script is provided in the <a href="text2image#training-script">Text-to-image</a> training guide. Instead, this guide takes a look at the LoRA relevant parts of the script.',Ee,D,wt='The script begins by adding the <a href="https://github.com/huggingface/diffusers/blob/dd9a5caf61f04d11c0fa9f3947b69ab0010c9a0f/examples/text_to_image/train_text_to_image_lora.py#L447" rel="nofollow">new LoRA weights</a> to the attention layers. This involves correctly configuring the weight size for each block in the UNet. You’ll see the <code>rank</code> parameter is used to create the <a href="/docs/diffusers/v0.26.1/en/api/attnprocessor#diffusers.models.attention_processor.LoRAAttnProcessor">LoRAAttnProcessor</a>:',Ne,K,He,O,gt='The <a href="https://github.com/huggingface/diffusers/blob/dd9a5caf61f04d11c0fa9f3947b69ab0010c9a0f/examples/text_to_image/train_text_to_image_lora.py#L519" rel="nofollow">optimizer</a> is initialized with the <code>lora_layers</code> because these are the only weights that’ll be optimized:',Ye,ee,Fe,te,Tt="Aside from setting up the LoRA layers, the training script is more or less the same as train_text_to_image.py!",Se,le,Qe,ae,$t="Once you’ve made all your changes or you’re okay with the default configuration, you’re ready to launch the training script! 🚀",ze,ne,Jt='Let’s train on the <a href="https://huggingface.co/datasets/lambdalabs/pokemon-blip-captions" rel="nofollow">Pokémon BLIP captions</a> dataset to generate our yown Pokémon. Set the environment variables <code>MODEL_NAME</code> and <code>DATASET_NAME</code> to the model and dataset respectively. You should also specify where to save the model in <code>OUTPUT_DIR</code>, and the name of the model to save to on the Hub with <code>HUB_MODEL_ID</code>. The script creates and saves the following files to your repository:',qe,se,Ut="<li>saved model checkpoints</li> <li><code>pytorch_lora_weights.safetensors</code> (the trained LoRA weights)</li>",Pe,ie,jt="If you’re training on more than one GPU, add the <code>--multi_gpu</code> parameter to the <code>accelerate launch</code> command.",De,C,Ke,oe,Oe,re,xt="Once training has been completed, you can use your model for inference:",et,pe,tt,fe,lt,me,Ct="Congratulations on training a new model with LoRA! To learn more about how to use your new model, the following guides may be helpful:",at,ce,vt='<li>Learn how to <a href="../using-diffusers/loading_adapters#LoRA">load different LoRA formats</a> trained using community trainers like Kohya and TheLastBen.</li> <li>Learn how to use and <a href="../tutorials/using_peft_for_inference">combine multiple LoRA’s</a> with PEFT for inference.</li>',nt,he,st;return c=new Me({props:{title:"LoRA",local:"lora",headingTag:"h1"}}),T=new de({props:{warning:!0,$$slots:{default:[St]},$$scope:{ctx:w}}}),J=new de({props:{$$slots:{default:[Qt]},$$scope:{ctx:w}}}),k=new $({props:{code:"Z2l0JTIwY2xvbmUlMjBodHRwcyUzQSUyRiUyRmdpdGh1Yi5jb20lMkZodWdnaW5nZmFjZSUyRmRpZmZ1c2VycyUwQWNkJTIwZGlmZnVzZXJzJTBBcGlwJTIwaW5zdGFsbCUyMC4=",highlighted:`git <span class="hljs-built_in">clone</span> https://github.com/huggingface/diffusers | |
| <span class="hljs-built_in">cd</span> diffusers | |
| pip install .`,wrap:!1}}),U=new Ft({props:{id:"installation",options:["PyTorch","Flax"],$$slots:{default:[Pt]},$$scope:{ctx:w}}}),j=new de({props:{$$slots:{default:[Dt]},$$scope:{ctx:w}}}),B=new $({props:{code:"YWNjZWxlcmF0ZSUyMGNvbmZpZw==",highlighted:"accelerate config",wrap:!1}}),W=new $({props:{code:"YWNjZWxlcmF0ZSUyMGNvbmZpZyUyMGRlZmF1bHQ=",highlighted:"accelerate config default",wrap:!1}}),V=new $({props:{code:"ZnJvbSUyMGFjY2VsZXJhdGUudXRpbHMlMjBpbXBvcnQlMjB3cml0ZV9iYXNpY19jb25maWclMEElMEF3cml0ZV9iYXNpY19jb25maWcoKQ==",highlighted:`from accelerate.utils import write_basic_config | |
| write_basic_config()`,wrap:!1}}),x=new de({props:{$$slots:{default:[Kt]},$$scope:{ctx:w}}}),N=new Me({props:{title:"Script parameters",local:"script-parameters",headingTag:"h2"}}),F=new $({props:{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMHRyYWluX3RleHRfdG9faW1hZ2VfbG9yYS5weSUyMCU1QyUwQSUyMCUyMC0tbnVtX3RyYWluX2Vwb2NocyUzRDE1MCUyMCU1Qw==",highlighted:`accelerate launch train_text_to_image_lora.py \\ | |
| --num_train_epochs=150 \\`,wrap:!1}}),z=new Me({props:{title:"Training script",local:"training-script",headingTag:"h2"}}),K=new $({props:{code:"bG9yYV9hdHRuX3Byb2NzJTIwJTNEJTIwJTdCJTdEJTBBZm9yJTIwbmFtZSUyMGluJTIwdW5ldC5hdHRuX3Byb2Nlc3NvcnMua2V5cygpJTNBJTBBJTIwJTIwJTIwJTIwY3Jvc3NfYXR0ZW50aW9uX2RpbSUyMCUzRCUyME5vbmUlMjBpZiUyMG5hbWUuZW5kc3dpdGgoJTIyYXR0bjEucHJvY2Vzc29yJTIyKSUyMGVsc2U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wJTIwJTIwJTIwY3Jvc3NfYXR0ZW50aW9uX2RpbSUzRGNyb3NzX2F0dGVudGlvbl9kaW0lMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjByYW5rJTNEYXJncy5yYW5rJTJDJTBBJTIwJTIwJTIwJTIwKSUwQSUwQXVuZXQuc2V0X2F0dG5fcHJvY2Vzc29yKGxvcmFfYXR0bl9wcm9jcyklMEFsb3JhX2xheWVycyUyMCUzRCUyMEF0dG5Qcm9jc0xheWVycyh1bmV0LmF0dG5fcHJvY2Vzc29ycyk=",highlighted:`lora_attn_procs = {} | |
| <span class="hljs-keyword">for</span> name <span class="hljs-keyword">in</span> unet.attn_processors.keys(): | |
| cross_attention_dim = <span class="hljs-literal">None</span> <span class="hljs-keyword">if</span> name.endswith(<span class="hljs-string">"attn1.processor"</span>) <span class="hljs-keyword">else</span> unet.config.cross_attention_dim | |
| <span class="hljs-keyword">if</span> name.startswith(<span class="hljs-string">"mid_block"</span>): | |
| hidden_size = unet.config.block_out_channels[-<span class="hljs-number">1</span>] | |
| <span class="hljs-keyword">elif</span> name.startswith(<span class="hljs-string">"up_blocks"</span>): | |
| block_id = <span class="hljs-built_in">int</span>(name[<span class="hljs-built_in">len</span>(<span class="hljs-string">"up_blocks."</span>)]) | |
| hidden_size = <span class="hljs-built_in">list</span>(<span class="hljs-built_in">reversed</span>(unet.config.block_out_channels))[block_id] | |
| <span class="hljs-keyword">elif</span> name.startswith(<span class="hljs-string">"down_blocks"</span>): | |
| block_id = <span class="hljs-built_in">int</span>(name[<span class="hljs-built_in">len</span>(<span class="hljs-string">"down_blocks."</span>)]) | |
| hidden_size = unet.config.block_out_channels[block_id] | |
| lora_attn_procs[name] = LoRAAttnProcessor( | |
| hidden_size=hidden_size, | |
| cross_attention_dim=cross_attention_dim, | |
| rank=args.rank, | |
| ) | |
| unet.set_attn_processor(lora_attn_procs) | |
| lora_layers = AttnProcsLayers(unet.attn_processors)`,wrap:!1}}),ee=new $({props:{code:"b3B0aW1pemVyJTIwJTNEJTIwb3B0aW1pemVyX2NscyglMEElMjAlMjAlMjAlMjBsb3JhX2xheWVycy5wYXJhbWV0ZXJzKCklMkMlMEElMjAlMjAlMjAlMjBsciUzRGFyZ3MubGVhcm5pbmdfcmF0ZSUyQyUwQSUyMCUyMCUyMCUyMGJldGFzJTNEKGFyZ3MuYWRhbV9iZXRhMSUyQyUyMGFyZ3MuYWRhbV9iZXRhMiklMkMlMEElMjAlMjAlMjAlMjB3ZWlnaHRfZGVjYXklM0RhcmdzLmFkYW1fd2VpZ2h0X2RlY2F5JTJDJTBBJTIwJTIwJTIwJTIwZXBzJTNEYXJncy5hZGFtX2Vwc2lsb24lMkMlMEEp",highlighted:`optimizer = optimizer_cls( | |
| lora_layers.parameters(), | |
| lr=args.learning_rate, | |
| betas=(args.adam_beta1, args.adam_beta2), | |
| weight_decay=args.adam_weight_decay, | |
| eps=args.adam_epsilon, | |
| )`,wrap:!1}}),le=new Me({props:{title:"Launch the script",local:"launch-the-script",headingTag:"h2"}}),C=new de({props:{warning:!0,$$slots:{default:[Ot]},$$scope:{ctx:w}}}),oe=new $({props:{code:"ZXhwb3J0JTIwTU9ERUxfTkFNRSUzRCUyMnJ1bndheW1sJTJGc3RhYmxlLWRpZmZ1c2lvbi12MS01JTIyJTBBZXhwb3J0JTIwT1VUUFVUX0RJUiUzRCUyMiUyRnNkZGF0YSUyRmZpbmV0dW5lJTJGbG9yYSUyRnBva2Vtb24lMjIlMEFleHBvcnQlMjBIVUJfTU9ERUxfSUQlM0QlMjJwb2tlbW9uLWxvcmElMjIlMEFleHBvcnQlMjBEQVRBU0VUX05BTUUlM0QlMjJsYW1iZGFsYWJzJTJGcG9rZW1vbi1ibGlwLWNhcHRpb25zJTIyJTBBJTBBYWNjZWxlcmF0ZSUyMGxhdW5jaCUyMC0tbWl4ZWRfcHJlY2lzaW9uJTNEJTIyZnAxNiUyMiUyMCUyMHRyYWluX3RleHRfdG9faW1hZ2VfbG9yYS5weSUyMC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wYmx1ZSUyMGV5ZXMuJTIyJTIwJTVDJTBBJTIwJTIwLS1zZWVkJTNEMTMzNw==",highlighted:`<span class="hljs-built_in">export</span> MODEL_NAME=<span class="hljs-string">"runwayml/stable-diffusion-v1-5"</span> | |
| <span class="hljs-built_in">export</span> OUTPUT_DIR=<span class="hljs-string">"/sddata/finetune/lora/pokemon"</span> | |
| <span class="hljs-built_in">export</span> HUB_MODEL_ID=<span class="hljs-string">"pokemon-lora"</span> | |
| <span class="hljs-built_in">export</span> DATASET_NAME=<span class="hljs-string">"lambdalabs/pokemon-blip-captions"</span> | |
| accelerate launch --mixed_precision=<span class="hljs-string">"fp16"</span> train_text_to_image_lora.py \\ | |
| --pretrained_model_name_or_path=<span class="hljs-variable">$MODEL_NAME</span> \\ | |
| --dataset_name=<span class="hljs-variable">$DATASET_NAME</span> \\ | |
| --dataloader_num_workers=8 \\ | |
| --resolution=512 \\ | |
| --center_crop \\ | |
| --random_flip \\ | |
| --train_batch_size=1 \\ | |
| --gradient_accumulation_steps=4 \\ | |
| --max_train_steps=15000 \\ | |
| --learning_rate=1e-04 \\ | |
| --max_grad_norm=1 \\ | |
| --lr_scheduler=<span class="hljs-string">"cosine"</span> \\ | |
| --lr_warmup_steps=0 \\ | |
| --output_dir=<span class="hljs-variable">\${OUTPUT_DIR}</span> \\ | |
| --push_to_hub \\ | |
| --hub_model_id=<span class="hljs-variable">\${HUB_MODEL_ID}</span> \\ | |
| --report_to=wandb \\ | |
| --checkpointing_steps=500 \\ | |
| --validation_prompt=<span class="hljs-string">"A pokemon with blue eyes."</span> \\ | |
| --seed=1337`,wrap:!1}}),pe=new $({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMEF1dG9QaXBlbGluZUZvclRleHQySW1hZ2UlMEFpbXBvcnQlMjB0b3JjaCUwQSUwQXBpcGVsaW5lJTIwJTNEJTIwQXV0b1BpcGVsaW5lRm9yVGV4dDJJbWFnZS5mcm9tX3ByZXRyYWluZWQoJTIycnVud2F5bWwlMkZzdGFibGUtZGlmZnVzaW9uLXYxLTUlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYpLnRvKCUyMmN1ZGElMjIpJTBBcGlwZWxpbmUubG9hZF9sb3JhX3dlaWdodHMoJTIycGF0aCUyRnRvJTJGbG9yYSUyRm1vZGVsJTIyJTJDJTIwd2VpZ2h0X25hbWUlM0QlMjJweXRvcmNoX2xvcmFfd2VpZ2h0cy5zYWZldGVuc29ycyUyMiklMEFpbWFnZSUyMCUzRCUyMHBpcGVsaW5lKCUyMkElMjBwb2tlbW9uJTIwd2l0aCUyMGJsdWUlMjBleWVzJTIyKS5pbWFnZXMlNUIwJTVE",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoPipelineForText2Image | |
| <span class="hljs-keyword">import</span> torch | |
| pipeline = AutoPipelineForText2Image.from_pretrained(<span class="hljs-string">"runwayml/stable-diffusion-v1-5"</span>, torch_dtype=torch.float16).to(<span class="hljs-string">"cuda"</span>) | |
| pipeline.load_lora_weights(<span class="hljs-string">"path/to/lora/model"</span>, weight_name=<span class="hljs-string">"pytorch_lora_weights.safetensors"</span>) | |
| image = pipeline(<span class="hljs-string">"A pokemon with blue eyes"</span>).images[<span class="hljs-number">0</span>]`,wrap:!1}}),fe=new Me({props:{title:"Next steps",local:"next-steps",headingTag:"h2"}}),{c(){n=p("meta"),r=i(),s=p("p"),b=i(),u(c.$$.fragment),g=i(),u(T.$$.fragment),v=i(),R=p("p"),R.innerHTML=it,ye=i(),u(J.$$.fragment),_e=i(),I=p("p"),I.innerHTML=ot,be=i(),Z=p("p"),Z.textContent=rt,we=i(),u(k.$$.fragment),ge=i(),A=p("p"),A.textContent=pt,Te=i(),u(U.$$.fragment),$e=i(),u(j.$$.fragment),Je=i(),L=p("p"),L.textContent=ft,Ue=i(),u(B.$$.fragment),je=i(),G=p("p"),G.textContent=mt,xe=i(),u(W.$$.fragment),Ce=i(),X=p("p"),X.textContent=ct,ve=i(),u(V.$$.fragment),Re=i(),E=p("p"),E.innerHTML=ut,Ie=i(),u(x.$$.fragment),Ze=i(),u(N.$$.fragment),ke=i(),H=p("p"),H.innerHTML=ht,Ae=i(),Y=p("p"),Y.textContent=dt,Le=i(),u(F.$$.fragment),Be=i(),S=p("p"),S.innerHTML=Mt,Ge=i(),Q=p("ul"),Q.innerHTML=yt,We=i(),u(z.$$.fragment),Xe=i(),q=p("p"),q.innerHTML=_t,Ve=i(),P=p("p"),P.innerHTML=bt,Ee=i(),D=p("p"),D.innerHTML=wt,Ne=i(),u(K.$$.fragment),He=i(),O=p("p"),O.innerHTML=gt,Ye=i(),u(ee.$$.fragment),Fe=i(),te=p("p"),te.textContent=Tt,Se=i(),u(le.$$.fragment),Qe=i(),ae=p("p"),ae.textContent=$t,ze=i(),ne=p("p"),ne.innerHTML=Jt,qe=i(),se=p("ul"),se.innerHTML=Ut,Pe=i(),ie=p("p"),ie.innerHTML=jt,De=i(),u(C.$$.fragment),Ke=i(),u(oe.$$.fragment),Oe=i(),re=p("p"),re.textContent=xt,et=i(),u(pe.$$.fragment),tt=i(),u(fe.$$.fragment),lt=i(),me=p("p"),me.textContent=Ct,at=i(),ce=p("ul"),ce.innerHTML=vt,nt=i(),he=p("p"),this.h()},l(e){const t=Ht("svelte-u9bgzb",document.head);n=f(t,"META",{name:!0,content:!0}),t.forEach(l),r=o(e),s=f(e,"P",{}),Bt(s).forEach(l),b=o(e),h(c.$$.fragment,e),g=o(e),h(T.$$.fragment,e),v=o(e),R=f(e,"P",{"data-svelte-h":!0}),m(R)!=="svelte-175koj4"&&(R.innerHTML=it),ye=o(e),h(J.$$.fragment,e),_e=o(e),I=f(e,"P",{"data-svelte-h":!0}),m(I)!=="svelte-96n353"&&(I.innerHTML=ot),be=o(e),Z=f(e,"P",{"data-svelte-h":!0}),m(Z)!=="svelte-l7dm2q"&&(Z.textContent=rt),we=o(e),h(k.$$.fragment,e),ge=o(e),A=f(e,"P",{"data-svelte-h":!0}),m(A)!=="svelte-1nancx8"&&(A.textContent=pt),Te=o(e),h(U.$$.fragment,e),$e=o(e),h(j.$$.fragment,e),Je=o(e),L=f(e,"P",{"data-svelte-h":!0}),m(L)!=="svelte-60q53m"&&(L.textContent=ft),Ue=o(e),h(B.$$.fragment,e),je=o(e),G=f(e,"P",{"data-svelte-h":!0}),m(G)!=="svelte-di6juu"&&(G.textContent=mt),xe=o(e),h(W.$$.fragment,e),Ce=o(e),X=f(e,"P",{"data-svelte-h":!0}),m(X)!=="svelte-tsz4qp"&&(X.textContent=ct),ve=o(e),h(V.$$.fragment,e),Re=o(e),E=f(e,"P",{"data-svelte-h":!0}),m(E)!=="svelte-1fkfdql"&&(E.innerHTML=ut),Ie=o(e),h(x.$$.fragment,e),Ze=o(e),h(N.$$.fragment,e),ke=o(e),H=f(e,"P",{"data-svelte-h":!0}),m(H)!=="svelte-iombk1"&&(H.innerHTML=ht),Ae=o(e),Y=f(e,"P",{"data-svelte-h":!0}),m(Y)!=="svelte-1tuocui"&&(Y.textContent=dt),Le=o(e),h(F.$$.fragment,e),Be=o(e),S=f(e,"P",{"data-svelte-h":!0}),m(S)!=="svelte-91isnp"&&(S.innerHTML=Mt),Ge=o(e),Q=f(e,"UL",{"data-svelte-h":!0}),m(Q)!=="svelte-1vnjzvi"&&(Q.innerHTML=yt),We=o(e),h(z.$$.fragment,e),Xe=o(e),q=f(e,"P",{"data-svelte-h":!0}),m(q)!=="svelte-3k8m7y"&&(q.innerHTML=_t),Ve=o(e),P=f(e,"P",{"data-svelte-h":!0}),m(P)!=="svelte-18vf99y"&&(P.innerHTML=bt),Ee=o(e),D=f(e,"P",{"data-svelte-h":!0}),m(D)!=="svelte-gg2a7c"&&(D.innerHTML=wt),Ne=o(e),h(K.$$.fragment,e),He=o(e),O=f(e,"P",{"data-svelte-h":!0}),m(O)!=="svelte-ace55f"&&(O.innerHTML=gt),Ye=o(e),h(ee.$$.fragment,e),Fe=o(e),te=f(e,"P",{"data-svelte-h":!0}),m(te)!=="svelte-gtrt4e"&&(te.textContent=Tt),Se=o(e),h(le.$$.fragment,e),Qe=o(e),ae=f(e,"P",{"data-svelte-h":!0}),m(ae)!=="svelte-9dei1q"&&(ae.textContent=$t),ze=o(e),ne=f(e,"P",{"data-svelte-h":!0}),m(ne)!=="svelte-jgauu5"&&(ne.innerHTML=Jt),qe=o(e),se=f(e,"UL",{"data-svelte-h":!0}),m(se)!=="svelte-1qgx1zz"&&(se.innerHTML=Ut),Pe=o(e),ie=f(e,"P",{"data-svelte-h":!0}),m(ie)!=="svelte-mj0rx7"&&(ie.innerHTML=jt),De=o(e),h(C.$$.fragment,e),Ke=o(e),h(oe.$$.fragment,e),Oe=o(e),re=f(e,"P",{"data-svelte-h":!0}),m(re)!=="svelte-17edgey"&&(re.textContent=xt),et=o(e),h(pe.$$.fragment,e),tt=o(e),h(fe.$$.fragment,e),lt=o(e),me=f(e,"P",{"data-svelte-h":!0}),m(me)!=="svelte-7dh2u5"&&(me.textContent=Ct),at=o(e),ce=f(e,"UL",{"data-svelte-h":!0}),m(ce)!=="svelte-1jpik92"&&(ce.innerHTML=vt),nt=o(e),he=f(e,"P",{}),Bt(he).forEach(l),this.h()},h(){Gt(n,"name","hf:doc:metadata"),Gt(n,"content",tl)},m(e,t){Yt(document.head,n),a(e,r,t),a(e,s,t),a(e,b,t),d(c,e,t),a(e,g,t),d(T,e,t),a(e,v,t),a(e,R,t),a(e,ye,t),d(J,e,t),a(e,_e,t),a(e,I,t),a(e,be,t),a(e,Z,t),a(e,we,t),d(k,e,t),a(e,ge,t),a(e,A,t),a(e,Te,t),d(U,e,t),a(e,$e,t),d(j,e,t),a(e,Je,t),a(e,L,t),a(e,Ue,t),d(B,e,t),a(e,je,t),a(e,G,t),a(e,xe,t),d(W,e,t),a(e,Ce,t),a(e,X,t),a(e,ve,t),d(V,e,t),a(e,Re,t),a(e,E,t),a(e,Ie,t),d(x,e,t),a(e,Ze,t),d(N,e,t),a(e,ke,t),a(e,H,t),a(e,Ae,t),a(e,Y,t),a(e,Le,t),d(F,e,t),a(e,Be,t),a(e,S,t),a(e,Ge,t),a(e,Q,t),a(e,We,t),d(z,e,t),a(e,Xe,t),a(e,q,t),a(e,Ve,t),a(e,P,t),a(e,Ee,t),a(e,D,t),a(e,Ne,t),d(K,e,t),a(e,He,t),a(e,O,t),a(e,Ye,t),d(ee,e,t),a(e,Fe,t),a(e,te,t),a(e,Se,t),d(le,e,t),a(e,Qe,t),a(e,ae,t),a(e,ze,t),a(e,ne,t),a(e,qe,t),a(e,se,t),a(e,Pe,t),a(e,ie,t),a(e,De,t),d(C,e,t),a(e,Ke,t),d(oe,e,t),a(e,Oe,t),a(e,re,t),a(e,et,t),d(pe,e,t),a(e,tt,t),d(fe,e,t),a(e,lt,t),a(e,me,t),a(e,at,t),a(e,ce,t),a(e,nt,t),a(e,he,t),st=!0},p(e,[t]){const Rt={};t&2&&(Rt.$$scope={dirty:t,ctx:e}),T.$set(Rt);const It={};t&2&&(It.$$scope={dirty:t,ctx:e}),J.$set(It);const Zt={};t&2&&(Zt.$$scope={dirty:t,ctx:e}),U.$set(Zt);const kt={};t&2&&(kt.$$scope={dirty:t,ctx:e}),j.$set(kt);const At={};t&2&&(At.$$scope={dirty:t,ctx:e}),x.$set(At);const Lt={};t&2&&(Lt.$$scope={dirty:t,ctx:e}),C.$set(Lt)},i(e){st||(M(c.$$.fragment,e),M(T.$$.fragment,e),M(J.$$.fragment,e),M(k.$$.fragment,e),M(U.$$.fragment,e),M(j.$$.fragment,e),M(B.$$.fragment,e),M(W.$$.fragment,e),M(V.$$.fragment,e),M(x.$$.fragment,e),M(N.$$.fragment,e),M(F.$$.fragment,e),M(z.$$.fragment,e),M(K.$$.fragment,e),M(ee.$$.fragment,e),M(le.$$.fragment,e),M(C.$$.fragment,e),M(oe.$$.fragment,e),M(pe.$$.fragment,e),M(fe.$$.fragment,e),st=!0)},o(e){y(c.$$.fragment,e),y(T.$$.fragment,e),y(J.$$.fragment,e),y(k.$$.fragment,e),y(U.$$.fragment,e),y(j.$$.fragment,e),y(B.$$.fragment,e),y(W.$$.fragment,e),y(V.$$.fragment,e),y(x.$$.fragment,e),y(N.$$.fragment,e),y(F.$$.fragment,e),y(z.$$.fragment,e),y(K.$$.fragment,e),y(ee.$$.fragment,e),y(le.$$.fragment,e),y(C.$$.fragment,e),y(oe.$$.fragment,e),y(pe.$$.fragment,e),y(fe.$$.fragment,e),st=!1},d(e){e&&(l(r),l(s),l(b),l(g),l(v),l(R),l(ye),l(_e),l(I),l(be),l(Z),l(we),l(ge),l(A),l(Te),l($e),l(Je),l(L),l(Ue),l(je),l(G),l(xe),l(Ce),l(X),l(ve),l(Re),l(E),l(Ie),l(Ze),l(ke),l(H),l(Ae),l(Y),l(Le),l(Be),l(S),l(Ge),l(Q),l(We),l(Xe),l(q),l(Ve),l(P),l(Ee),l(D),l(Ne),l(He),l(O),l(Ye),l(Fe),l(te),l(Se),l(Qe),l(ae),l(ze),l(ne),l(qe),l(se),l(Pe),l(ie),l(De),l(Ke),l(Oe),l(re),l(et),l(tt),l(lt),l(me),l(at),l(ce),l(nt),l(he)),l(n),_(c,e),_(T,e),_(J,e),_(k,e),_(U,e),_(j,e),_(B,e),_(W,e),_(V,e),_(x,e),_(N,e),_(F,e),_(z,e),_(K,e),_(ee,e),_(le,e),_(C,e),_(oe,e),_(pe,e),_(fe,e)}}}const tl='{"title":"LoRA","local":"lora","sections":[{"title":"Script parameters","local":"script-parameters","sections":[],"depth":2},{"title":"Training script","local":"training-script","sections":[],"depth":2},{"title":"Launch the script","local":"launch-the-script","sections":[],"depth":2},{"title":"Next steps","local":"next-steps","sections":[],"depth":2}],"depth":1}';function ll(w){return Vt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class pl extends Et{constructor(n){super(),Nt(this,n,ll,el,Xt,{})}}export{pl as component}; | |
Xet Storage Details
- Size:
- 27.7 kB
- Xet hash:
- cbba8e75fe64c289756caa1bf30154387ddaf253da28b2b74df807fdc974433f
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.