Buckets:
| import{s as Ul,o as vl,n as Xt}from"../chunks/scheduler.182ea377.js";import{S as $l,i as xl,g as n,s as o,p as u,x as Xe,A as jl,h as s,f as l,c as r,j as g,q as f,m as h,y as Ne,k as c,v as m,a,r as d,d as M,t as y,u as _}from"../chunks/index.008d68e4.js";import{T as Wt}from"../chunks/Tip.4f096367.js";import{I as Et}from"../chunks/IconCopyLink.96bbb92b.js";import{C as J}from"../chunks/CodeBlock.5ed6eb7b.js";function Cl(T){let i,b="This is experimental and the API may change in the future.";return{c(){i=n("p"),i.textContent=b},l(p){i=s(p,"P",{"data-svelte-h":!0}),h(i)!=="svelte-us7smu"&&(i.textContent=b)},m(p,w){a(p,i,w)},p:Xt,d(p){p&&l(i)}}}function kl(T){let i,b='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(){i=n("p"),i.innerHTML=b},l(p){i=s(p,"P",{"data-svelte-h":!0}),h(i)!=="svelte-1xa3xmb"&&(i.innerHTML=b)},m(p,w){a(p,i,w)},p:Xt,d(p){p&&l(i)}}}function Rl(T){let i,b='🤗 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(){i=n("p"),i.innerHTML=b},l(p){i=s(p,"P",{"data-svelte-h":!0}),h(i)!=="svelte-1qbiqsn"&&(i.innerHTML=b)},m(p,w){a(p,i,w)},p:Xt,d(p){p&&l(i)}}}function Al(T){let i,b='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(){i=n("p"),i.innerHTML=b},l(p){i=s(p,"P",{"data-svelte-h":!0}),h(i)!=="svelte-ckqpc4"&&(i.innerHTML=b)},m(p,w){a(p,i,w)},p:Xt,d(p){p&&l(i)}}}function Il(T){let i,b="A full training run takes ~5 hours on a 2080 Ti GPU with 11GB of VRAM.";return{c(){i=n("p"),i.textContent=b},l(p){i=s(p,"P",{"data-svelte-h":!0}),h(i)!=="svelte-phs0cw"&&(i.textContent=b)},m(p,w){a(p,i,w)},p:Xt,d(p){p&&l(i)}}}function Zl(T){let i,b,p,w,kt,G,Le,vt,Ve="LoRA",Nt,j,Vt,W,He='<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.',Ht,C,St,E,Se='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.',Yt,X,Ye="Before running the script, make sure you install the library from source:",Ft,N,Qt,V,Fe="Navigate to the example folder with the training script and install the required dependencies for the script you’re using:",zt,H,Pt,S,qt,k,Dt,Y,Qe="Initialize an 🤗 Accelerate environment:",Kt,F,Ot,Q,ze="To setup a default 🤗 Accelerate environment without choosing any configurations:",te,z,ee,P,Pe="Or if your environment doesn’t support an interactive shell, like a notebook, you can use:",le,q,ae,D,qe='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.',ne,R,se,U,A,Rt,K,Be,$t,De="Script parameters",ie,O,Ke='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.',oe,tt,Oe="For example, to increase the number of epochs to train:",re,et,pe,lt,tl='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:',he,at,el="<li><code>--rank</code>: the number of low-rank matrices to train</li> <li><code>--learning_rate</code>: the default learning rate is 1e-4, but with LoRA, you can use a higher learning rate</li>",ce,v,I,At,nt,Ge,xt,ll="Training script",ue,st,al='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.',fe,it,nl='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.',me,ot,sl='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.25.0/ja/api/attnprocessor#diffusers.models.attention_processor.LoRAAttnProcessor">LoRAAttnProcessor</a>:',de,rt,Me,pt,il='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,ht,_e,ct,ol="Aside from setting up the LoRA layers, the training script is more or less the same as train_text_to_image.py!",be,$,Z,It,ut,We,jt,rl="Launch the script",we,ft,pl="Once you’ve made all your changes or you’re okay with the default configuration, you’re ready to launch the training script! 🚀",ge,mt,hl='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:',Te,dt,cl="<li>saved model checkpoints</li> <li><code>pytorch_lora_weights.safetensors</code> (the trained LoRA weights)</li>",Je,Mt,ul="If you’re training on more than one GPU, add the <code>--multi_gpu</code> parameter to the <code>accelerate launch</code> command.",Ue,L,ve,yt,$e,_t,fl="Once training has been completed, you can use your model for inference:",xe,bt,je,x,B,Zt,wt,Ee,Ct,ml="Next steps",Ce,gt,dl="Congratulations on training a new model with LoRA! To learn more about how to use your new model, the following guides may be helpful:",ke,Tt,Ml='<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>',Re;return G=new Et({}),j=new Wt({props:{warning:!0,$$slots:{default:[Cl]},$$scope:{ctx:T}}}),C=new Wt({props:{$$slots:{default:[kl]},$$scope:{ctx:T}}}),N=new J({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 .`}}),H=new J({props:{code:"Y2QlMjBleGFtcGxlcyUyRnRleHRfdG9faW1hZ2UlMEFwaXAlMjBpbnN0YWxsJTIwLXIlMjByZXF1aXJlbWVudHMudHh0",highlighted:`<span class="hljs-built_in">cd</span> examples/text_to_image | |
| pip install -r requirements.txt`}}),S=new J({props:{code:"Y2QlMjBleGFtcGxlcyUyRnRleHRfdG9faW1hZ2UlMEFwaXAlMjBpbnN0YWxsJTIwLXIlMjByZXF1aXJlbWVudHNfZmxheC50eHQ=",highlighted:`<span class="hljs-built_in">cd</span> examples/text_to_image | |
| pip install -r requirements_flax.txt`}}),k=new Wt({props:{$$slots:{default:[Rl]},$$scope:{ctx:T}}}),F=new J({props:{code:"YWNjZWxlcmF0ZSUyMGNvbmZpZw==",highlighted:"accelerate config"}}),z=new J({props:{code:"YWNjZWxlcmF0ZSUyMGNvbmZpZyUyMGRlZmF1bHQ=",highlighted:"accelerate config default"}}),q=new J({props:{code:"ZnJvbSUyMGFjY2VsZXJhdGUudXRpbHMlMjBpbXBvcnQlMjB3cml0ZV9iYXNpY19jb25maWclMEElMEF3cml0ZV9iYXNpY19jb25maWcoKQ==",highlighted:`from accelerate.utils import write_basic_config | |
| write_basic_config()`}}),R=new Wt({props:{$$slots:{default:[Al]},$$scope:{ctx:T}}}),K=new Et({}),et=new J({props:{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMHRyYWluX3RleHRfdG9faW1hZ2VfbG9yYS5weSUyMCU1QyUwQSUyMCUyMC0tbnVtX3RyYWluX2Vwb2NocyUzRDE1MCUyMCU1Qw==",highlighted:`accelerate launch train_text_to_image_lora.py \\ | |
| --num_train_epochs=150 \\`}}),n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emUlMjAlM0QlMjB1bmV0LmNvbmZpZy5ibG9ja19vdXRfY2hhbm5lbHMlNUJibG9ja19pZCU1RCUwQSUwQSUyMCUyMCUyMCUyMGxvcmFfYXR0bl9wcm9jcyU1Qm5hbWUlNUQlMjAlM0QlMjBMb1JBQXR0blByb2Nlc3NvciglMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBoaWRkZW5fc2l6ZSUzRGhpZGRlbl9zaXplJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwY3Jvc3NfYXR0ZW50aW9uX2RpbSUzRGNyb3NzX2F0dGVudGlvbl9kaW0lMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjByYW5rJTNEYXJncy5yYW5rJTJDJTBBJTIwJTIwJTIwJTIwKSUwQSUwQXVuZXQuc2V0X2F0dG5fcHJvY2Vzc29yKGxvcmFfYXR0bl9wcm9jcyklMEFsb3JhX2xheWVycyUyMCUzRCUyMEF0dG5Qcm9jc0xheWVycyh1bmV0LmF0dG5fcHJvY2Vzc29ycyk=",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)`}}),ht=new J({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, | |
| )`}}),ut=new Et({}),L=new Wt({props:{warning:!0,$$slots:{default:[Il]},$$scope:{ctx:T}}}),yt=new J({props:{code:"ZXhwb3J0JTIwTU9ERUxfTkFNRSUzRCUyMnJ1bndheW1sJTJGc3RhYmxlLWRpZmZ1c2lvbi12MS01JTIyJTBBZXhwb3J0JTIwT1VUUFVUX0RJUiUzRCUyMiUyRnNkZGF0YSUyRmZpbmV0dW5lJTJGbG9yYSUyRnBva2Vtb24lMjIlMEFleHBvcnQlMjBIVUJfTU9ERUxfSUQlM0QlMjJwb2tlbW9uLWxvcmElMj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ZCUzRCUyNCU3QkhVQl9NT0RFTF9JRCU3RCUyMCU1QyUwQSUyMCUyMC0tcmVwb3J0X3RvJTNEd2FuZGIlMjAlNUMlMEElMjAlMjAtLWNoZWNrcG9pbnRpbmdfc3RlcHMlM0Q1MDAlMjAlNUMlMEElMjAlMjAtLXZhbGlkYXRpb25fcHJvbXB0JTNEJTIyQSUyMHBva2Vtb24lMjB3aXRoJTIwYmx1ZSUyMGV5ZXMuJTIyJTIwJTVDJTBBJTIwJTIwLS1zZWVkJTNEMTMzNw==",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`}}),bt=new J({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>]`}}),wt=new Et({}),{c(){i=n("meta"),b=o(),p=n("h1"),w=n("a"),kt=n("span"),u(G.$$.fragment),Le=o(),vt=n("span"),vt.textContent=Ve,Nt=o(),u(j.$$.fragment),Vt=o(),W=n("p"),W.innerHTML=He,Ht=o(),u(C.$$.fragment),St=o(),E=n("p"),E.innerHTML=Se,Yt=o(),X=n("p"),X.textContent=Ye,Ft=o(),u(N.$$.fragment),Qt=o(),V=n("p"),V.textContent=Fe,zt=Xe(` | |
| <hfoptions id="installation"> | |
| <hfoption id="PyTorch"> | |
| `),u(H.$$.fragment),Pt=Xe(` | |
| </hfoption> | |
| <hfoption id="Flax"> | |
| `),u(S.$$.fragment),qt=Xe(` | |
| </hfoption> | |
| </hfoptions> | |
| `),u(k.$$.fragment),Dt=o(),Y=n("p"),Y.textContent=Qe,Kt=o(),u(F.$$.fragment),Ot=o(),Q=n("p"),Q.textContent=ze,te=o(),u(z.$$.fragment),ee=o(),P=n("p"),P.textContent=Pe,le=o(),u(q.$$.fragment),ae=o(),D=n("p"),D.innerHTML=qe,ne=o(),u(R.$$.fragment),se=o(),U=n("h2"),A=n("a"),Rt=n("span"),u(K.$$.fragment),Be=o(),$t=n("span"),$t.textContent=De,ie=o(),O=n("p"),O.innerHTML=Ke,oe=o(),tt=n("p"),tt.textContent=Oe,re=o(),u(et.$$.fragment),pe=o(),lt=n("p"),lt.innerHTML=tl,he=o(),at=n("ul"),at.innerHTML=el,ce=o(),v=n("h2"),I=n("a"),At=n("span"),u(nt.$$.fragment),Ge=o(),xt=n("span"),xt.textContent=ll,ue=o(),st=n("p"),st.innerHTML=al,fe=o(),it=n("p"),it.innerHTML=nl,me=o(),ot=n("p"),ot.innerHTML=sl,de=o(),u(rt.$$.fragment),Me=o(),pt=n("p"),pt.innerHTML=il,ye=o(),u(ht.$$.fragment),_e=o(),ct=n("p"),ct.textContent=ol,be=o(),$=n("h2"),Z=n("a"),It=n("span"),u(ut.$$.fragment),We=o(),jt=n("span"),jt.textContent=rl,we=o(),ft=n("p"),ft.textContent=pl,ge=o(),mt=n("p"),mt.innerHTML=hl,Te=o(),dt=n("ul"),dt.innerHTML=cl,Je=o(),Mt=n("p"),Mt.innerHTML=ul,Ue=o(),u(L.$$.fragment),ve=o(),u(yt.$$.fragment),$e=o(),_t=n("p"),_t.textContent=fl,xe=o(),u(bt.$$.fragment),je=o(),x=n("h2"),B=n("a"),Zt=n("span"),u(wt.$$.fragment),Ee=o(),Ct=n("span"),Ct.textContent=ml,Ce=o(),gt=n("p"),gt.textContent=dl,ke=o(),Tt=n("ul"),Tt.innerHTML=Ml,this.h()},l(t){const e=jl("svelte-1phssyn",document.head);i=s(e,"META",{name:!0,content:!0}),e.forEach(l),b=r(t),p=s(t,"H1",{class:!0});var Jt=g(p);w=s(Jt,"A",{id:!0,class:!0,href:!0});var Lt=g(w);kt=s(Lt,"SPAN",{});var Bt=g(kt);f(G.$$.fragment,Bt),Bt.forEach(l),Lt.forEach(l),Le=r(Jt),vt=s(Jt,"SPAN",{"data-svelte-h":!0}),h(vt)!=="svelte-erj1xh"&&(vt.textContent=Ve),Jt.forEach(l),Nt=r(t),f(j.$$.fragment,t),Vt=r(t),W=s(t,"P",{"data-svelte-h":!0}),h(W)!=="svelte-175koj4"&&(W.innerHTML=He),Ht=r(t),f(C.$$.fragment,t),St=r(t),E=s(t,"P",{"data-svelte-h":!0}),h(E)!=="svelte-96n353"&&(E.innerHTML=Se),Yt=r(t),X=s(t,"P",{"data-svelte-h":!0}),h(X)!=="svelte-l7dm2q"&&(X.textContent=Ye),Ft=r(t),f(N.$$.fragment,t),Qt=r(t),V=s(t,"P",{"data-svelte-h":!0}),h(V)!=="svelte-1nancx8"&&(V.textContent=Fe),zt=Ne(t,` | |
| <hfoptions id="installation"> | |
| <hfoption id="PyTorch"> | |
| `),f(H.$$.fragment,t),Pt=Ne(t,` | |
| </hfoption> | |
| <hfoption id="Flax"> | |
| `),f(S.$$.fragment,t),qt=Ne(t,` | |
| </hfoption> | |
| </hfoptions> | |
| `),f(k.$$.fragment,t),Dt=r(t),Y=s(t,"P",{"data-svelte-h":!0}),h(Y)!=="svelte-60q53m"&&(Y.textContent=Qe),Kt=r(t),f(F.$$.fragment,t),Ot=r(t),Q=s(t,"P",{"data-svelte-h":!0}),h(Q)!=="svelte-di6juu"&&(Q.textContent=ze),te=r(t),f(z.$$.fragment,t),ee=r(t),P=s(t,"P",{"data-svelte-h":!0}),h(P)!=="svelte-tsz4qp"&&(P.textContent=Pe),le=r(t),f(q.$$.fragment,t),ae=r(t),D=s(t,"P",{"data-svelte-h":!0}),h(D)!=="svelte-1fkfdql"&&(D.innerHTML=qe),ne=r(t),f(R.$$.fragment,t),se=r(t),U=s(t,"H2",{class:!0});var Ut=g(U);A=s(Ut,"A",{id:!0,class:!0,href:!0});var Gt=g(A);Rt=s(Gt,"SPAN",{});var yl=g(Rt);f(K.$$.fragment,yl),yl.forEach(l),Gt.forEach(l),Be=r(Ut),$t=s(Ut,"SPAN",{"data-svelte-h":!0}),h($t)!=="svelte-r00uw2"&&($t.textContent=De),Ut.forEach(l),ie=r(t),O=s(t,"P",{"data-svelte-h":!0}),h(O)!=="svelte-iombk1"&&(O.innerHTML=Ke),oe=r(t),tt=s(t,"P",{"data-svelte-h":!0}),h(tt)!=="svelte-1tuocui"&&(tt.textContent=Oe),re=r(t),f(et.$$.fragment,t),pe=r(t),lt=s(t,"P",{"data-svelte-h":!0}),h(lt)!=="svelte-91isnp"&&(lt.innerHTML=tl),he=r(t),at=s(t,"UL",{"data-svelte-h":!0}),h(at)!=="svelte-2x1p5k"&&(at.innerHTML=el),ce=r(t),v=s(t,"H2",{class:!0});var Ae=g(v);I=s(Ae,"A",{id:!0,class:!0,href:!0});var _l=g(I);At=s(_l,"SPAN",{});var bl=g(At);f(nt.$$.fragment,bl),bl.forEach(l),_l.forEach(l),Ge=r(Ae),xt=s(Ae,"SPAN",{"data-svelte-h":!0}),h(xt)!=="svelte-339bde"&&(xt.textContent=ll),Ae.forEach(l),ue=r(t),st=s(t,"P",{"data-svelte-h":!0}),h(st)!=="svelte-3k8m7y"&&(st.innerHTML=al),fe=r(t),it=s(t,"P",{"data-svelte-h":!0}),h(it)!=="svelte-18vf99y"&&(it.innerHTML=nl),me=r(t),ot=s(t,"P",{"data-svelte-h":!0}),h(ot)!=="svelte-15xssdk"&&(ot.innerHTML=sl),de=r(t),f(rt.$$.fragment,t),Me=r(t),pt=s(t,"P",{"data-svelte-h":!0}),h(pt)!=="svelte-ace55f"&&(pt.innerHTML=il),ye=r(t),f(ht.$$.fragment,t),_e=r(t),ct=s(t,"P",{"data-svelte-h":!0}),h(ct)!=="svelte-gtrt4e"&&(ct.textContent=ol),be=r(t),$=s(t,"H2",{class:!0});var Ie=g($);Z=s(Ie,"A",{id:!0,class:!0,href:!0});var wl=g(Z);It=s(wl,"SPAN",{});var gl=g(It);f(ut.$$.fragment,gl),gl.forEach(l),wl.forEach(l),We=r(Ie),jt=s(Ie,"SPAN",{"data-svelte-h":!0}),h(jt)!=="svelte-zp6p5k"&&(jt.textContent=rl),Ie.forEach(l),we=r(t),ft=s(t,"P",{"data-svelte-h":!0}),h(ft)!=="svelte-9dei1q"&&(ft.textContent=pl),ge=r(t),mt=s(t,"P",{"data-svelte-h":!0}),h(mt)!=="svelte-jgauu5"&&(mt.innerHTML=hl),Te=r(t),dt=s(t,"UL",{"data-svelte-h":!0}),h(dt)!=="svelte-1qgx1zz"&&(dt.innerHTML=cl),Je=r(t),Mt=s(t,"P",{"data-svelte-h":!0}),h(Mt)!=="svelte-mj0rx7"&&(Mt.innerHTML=ul),Ue=r(t),f(L.$$.fragment,t),ve=r(t),f(yt.$$.fragment,t),$e=r(t),_t=s(t,"P",{"data-svelte-h":!0}),h(_t)!=="svelte-17edgey"&&(_t.textContent=fl),xe=r(t),f(bt.$$.fragment,t),je=r(t),x=s(t,"H2",{class:!0});var Ze=g(x);B=s(Ze,"A",{id:!0,class:!0,href:!0});var Tl=g(B);Zt=s(Tl,"SPAN",{});var Jl=g(Zt);f(wt.$$.fragment,Jl),Jl.forEach(l),Tl.forEach(l),Ee=r(Ze),Ct=s(Ze,"SPAN",{"data-svelte-h":!0}),h(Ct)!=="svelte-pr7lub"&&(Ct.textContent=ml),Ze.forEach(l),Ce=r(t),gt=s(t,"P",{"data-svelte-h":!0}),h(gt)!=="svelte-7dh2u5"&&(gt.textContent=dl),ke=r(t),Tt=s(t,"UL",{"data-svelte-h":!0}),h(Tt)!=="svelte-1jpik92"&&(Tt.innerHTML=Ml),this.h()},h(){c(i,"name","hf:doc:metadata"),c(i,"content",JSON.stringify(Ll)),c(w,"id","lora"),c(w,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(w,"href","#lora"),c(p,"class","relative group"),c(A,"id","script-parameters"),c(A,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(A,"href","#script-parameters"),c(U,"class","relative group"),c(I,"id","training-script"),c(I,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(I,"href","#training-script"),c(v,"class","relative group"),c(Z,"id","launch-the-script"),c(Z,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(Z,"href","#launch-the-script"),c($,"class","relative group"),c(B,"id","next-steps"),c(B,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(B,"href","#next-steps"),c(x,"class","relative group")},m(t,e){m(document.head,i),a(t,b,e),a(t,p,e),m(p,w),m(w,kt),d(G,kt,null),m(p,Le),m(p,vt),a(t,Nt,e),d(j,t,e),a(t,Vt,e),a(t,W,e),a(t,Ht,e),d(C,t,e),a(t,St,e),a(t,E,e),a(t,Yt,e),a(t,X,e),a(t,Ft,e),d(N,t,e),a(t,Qt,e),a(t,V,e),a(t,zt,e),d(H,t,e),a(t,Pt,e),d(S,t,e),a(t,qt,e),d(k,t,e),a(t,Dt,e),a(t,Y,e),a(t,Kt,e),d(F,t,e),a(t,Ot,e),a(t,Q,e),a(t,te,e),d(z,t,e),a(t,ee,e),a(t,P,e),a(t,le,e),d(q,t,e),a(t,ae,e),a(t,D,e),a(t,ne,e),d(R,t,e),a(t,se,e),a(t,U,e),m(U,A),m(A,Rt),d(K,Rt,null),m(U,Be),m(U,$t),a(t,ie,e),a(t,O,e),a(t,oe,e),a(t,tt,e),a(t,re,e),d(et,t,e),a(t,pe,e),a(t,lt,e),a(t,he,e),a(t,at,e),a(t,ce,e),a(t,v,e),m(v,I),m(I,At),d(nt,At,null),m(v,Ge),m(v,xt),a(t,ue,e),a(t,st,e),a(t,fe,e),a(t,it,e),a(t,me,e),a(t,ot,e),a(t,de,e),d(rt,t,e),a(t,Me,e),a(t,pt,e),a(t,ye,e),d(ht,t,e),a(t,_e,e),a(t,ct,e),a(t,be,e),a(t,$,e),m($,Z),m(Z,It),d(ut,It,null),m($,We),m($,jt),a(t,we,e),a(t,ft,e),a(t,ge,e),a(t,mt,e),a(t,Te,e),a(t,dt,e),a(t,Je,e),a(t,Mt,e),a(t,Ue,e),d(L,t,e),a(t,ve,e),d(yt,t,e),a(t,$e,e),a(t,_t,e),a(t,xe,e),d(bt,t,e),a(t,je,e),a(t,x,e),m(x,B),m(B,Zt),d(wt,Zt,null),m(x,Ee),m(x,Ct),a(t,Ce,e),a(t,gt,e),a(t,ke,e),a(t,Tt,e),Re=!0},p(t,[e]){const Jt={};e&2&&(Jt.$$scope={dirty:e,ctx:t}),j.$set(Jt);const Lt={};e&2&&(Lt.$$scope={dirty:e,ctx:t}),C.$set(Lt);const Bt={};e&2&&(Bt.$$scope={dirty:e,ctx:t}),k.$set(Bt);const Ut={};e&2&&(Ut.$$scope={dirty:e,ctx:t}),R.$set(Ut);const Gt={};e&2&&(Gt.$$scope={dirty:e,ctx:t}),L.$set(Gt)},i(t){Re||(M(G.$$.fragment,t),M(j.$$.fragment,t),M(C.$$.fragment,t),M(N.$$.fragment,t),M(H.$$.fragment,t),M(S.$$.fragment,t),M(k.$$.fragment,t),M(F.$$.fragment,t),M(z.$$.fragment,t),M(q.$$.fragment,t),M(R.$$.fragment,t),M(K.$$.fragment,t),M(et.$$.fragment,t),M(nt.$$.fragment,t),M(rt.$$.fragment,t),M(ht.$$.fragment,t),M(ut.$$.fragment,t),M(L.$$.fragment,t),M(yt.$$.fragment,t),M(bt.$$.fragment,t),M(wt.$$.fragment,t),Re=!0)},o(t){y(G.$$.fragment,t),y(j.$$.fragment,t),y(C.$$.fragment,t),y(N.$$.fragment,t),y(H.$$.fragment,t),y(S.$$.fragment,t),y(k.$$.fragment,t),y(F.$$.fragment,t),y(z.$$.fragment,t),y(q.$$.fragment,t),y(R.$$.fragment,t),y(K.$$.fragment,t),y(et.$$.fragment,t),y(nt.$$.fragment,t),y(rt.$$.fragment,t),y(ht.$$.fragment,t),y(ut.$$.fragment,t),y(L.$$.fragment,t),y(yt.$$.fragment,t),y(bt.$$.fragment,t),y(wt.$$.fragment,t),Re=!1},d(t){t&&(l(b),l(p),l(Nt),l(Vt),l(W),l(Ht),l(St),l(E),l(Yt),l(X),l(Ft),l(Qt),l(V),l(zt),l(Pt),l(qt),l(Dt),l(Y),l(Kt),l(Ot),l(Q),l(te),l(ee),l(P),l(le),l(ae),l(D),l(ne),l(se),l(U),l(ie),l(O),l(oe),l(tt),l(re),l(pe),l(lt),l(he),l(at),l(ce),l(v),l(ue),l(st),l(fe),l(it),l(me),l(ot),l(de),l(Me),l(pt),l(ye),l(_e),l(ct),l(be),l($),l(we),l(ft),l(ge),l(mt),l(Te),l(dt),l(Je),l(Mt),l(Ue),l(ve),l($e),l(_t),l(xe),l(je),l(x),l(Ce),l(gt),l(ke),l(Tt)),l(i),_(G),_(j,t),_(C,t),_(N,t),_(H,t),_(S,t),_(k,t),_(F,t),_(z,t),_(q,t),_(R,t),_(K),_(et,t),_(nt),_(rt,t),_(ht,t),_(ut),_(L,t),_(yt,t),_(bt,t),_(wt)}}}const Ll={local:"lora",sections:[{local:"script-parameters",title:"Script parameters"},{local:"training-script",title:"Training script"},{local:"launch-the-script",title:"Launch the script"},{local:"next-steps",title:"Next steps"}],title:"LoRA"};function Bl(T){return vl(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Vl extends $l{constructor(i){super(),xl(this,i,Bl,Zl,Ul,{})}}export{Vl as component}; | |
Xet Storage Details
- Size:
- 29.5 kB
- Xet hash:
- 5a123a9f5a49670cf42754e33666465cef7fdfa4c2e01e82c2494f204e477c29
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.