import{s as A,n as Q,o as O}from"../chunks/scheduler.d627b047.js";import{S as K,i as ee,g as i,s as l,r as M,A as te,h as p,f as n,c as o,j as E,u as J,x as $,k as q,y as ne,a,v as x,d as v,t as _,w as B}from"../chunks/index.73c51727.js";import{C as ae}from"../chunks/CodeBlock.5f78c87f.js";import{H as V,E as le}from"../chunks/index.8df1db42.js";function oe(Y){let s,U,y,j,c,G,m,z="The notebooks and scripts in this examples show how to fine-tune a model with a sentiment classifier (such as <code>lvwerra/distilbert-imdb</code>).",I,r,R='Here’s an overview of the notebooks and scripts in the <a href="https://github.com/huggingface/trl/tree/main/examples" rel="nofollow">trl repository</a>:',k,u,S='<thead><tr><th>File</th> <th>Description</th></tr></thead> <tbody><tr><td><a href="https://github.com/huggingface/trl/blob/main/examples/scripts/ppo.py" rel="nofollow"><code>examples/scripts/ppo.py</code></a> <a href="https://colab.research.google.com/github/huggingface/trl/blob/main/examples/sentiment/notebooks/gpt2-sentiment.ipynb" rel="nofollow"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a></td> <td>This script shows how to use the <code>PPOTrainer</code> to fine-tune a sentiment analysis model using IMDB dataset</td></tr> <tr><td><a href="https://github.com/huggingface/trl/tree/main/examples/notebooks/gpt2-sentiment.ipynb" rel="nofollow"><code>examples/notebooks/gpt2-sentiment.ipynb</code></a></td> <td>This notebook demonstrates how to reproduce the GPT2 imdb sentiment tuning example on a jupyter notebook.</td></tr> <tr><td><a href="https://github.com/huggingface/trl/tree/main/examples/notebooks/gpt2-control.ipynb" rel="nofollow"><code>examples/notebooks/gpt2-control.ipynb</code></a> <a href="https://colab.research.google.com/github/huggingface/trl/blob/main/examples/sentiment/notebooks/gpt2-sentiment-control.ipynb" rel="nofollow"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a></td> <td>This notebook demonstrates how to reproduce the GPT2 sentiment control example on a jupyter notebook.</td></tr></tbody>',H,h,Z,d,X,b,N='Note: if you don’t want to log with <code>wandb</code> remove <code>log_with=&quot;wandb&quot;</code> in the scripts/notebooks. You can also replace it with your favourite experiment tracker that’s <a href="https://huggingface.co/docs/accelerate/usage_guides/tracking" rel="nofollow">supported by <code>accelerate</code></a>.',W,g,F,f,D="To run in multi-GPU setup with DDP (distributed Data Parallel) change the <code>device_map</code> value to <code>device_map={&quot;&quot;: Accelerator().process_index}</code> and make sure to run your script with <code>accelerate launch yourscript.py</code>. If you want to apply naive pipeline parallelism you can use <code>device_map=&quot;auto&quot;</code>.",L,w,P,T,C;return c=new V({props:{title:"Sentiment Tuning Examples",local:"sentiment-tuning-examples",headingTag:"h1"}}),h=new V({props:{title:"Usage",local:"usage",headingTag:"h2"}}),d=new ae({props:{code:"JTIzJTIwMS4lMjBydW4lMjBkaXJlY3RseSUwQXB5dGhvbiUyMGV4YW1wbGVzJTJGc2NyaXB0cyUyRnBwby5weSUwQSUyMyUyMDIuJTIwcnVuJTIwdmlhJTIwJTYwYWNjZWxlcmF0ZSU2MCUyMChyZWNvbW1lbmRlZCklMkMlMjBlbmFibGluZyUyMG1vcmUlMjBmZWF0dXJlcyUyMChlLmcuJTJDJTIwbXVsdGlwbGUlMjBHUFVzJTJDJTIwZGVlcHNwZWVkKSUwQWFjY2VsZXJhdGUlMjBjb25maWclMjAlMjMlMjB3aWxsJTIwcHJvbXB0JTIweW91JTIwdG8lMjBkZWZpbmUlMjB0aGUlMjB0cmFpbmluZyUyMGNvbmZpZ3VyYXRpb24lMEFhY2NlbGVyYXRlJTIwbGF1bmNoJTIwZXhhbXBsZXMlMkZzY3JpcHRzJTJGcHBvLnB5JTIwJTIzJTIwbGF1bmNoZXMlMjB0cmFpbmluZyUwQSUyMyUyMDMuJTIwZ2V0JTIwaGVscCUyMHRleHQlMjBhbmQlMjBkb2N1bWVudGF0aW9uJTBBcHl0aG9uJTIwZXhhbXBsZXMlMkZzY3JpcHRzJTJGcHBvLnB5JTIwLS1oZWxwJTBBJTIzJTIwNC4lMjBjb25maWd1cmUlMjBsb2dnaW5nJTIwd2l0aCUyMHdhbmRiJTIwYW5kJTJDJTIwc2F5JTJDJTIwbWluaV9iYXRjaF9zaXplJTNEMSUyMGFuZCUyMGdyYWRpZW50X2FjY3VtdWxhdGlvbl9zdGVwcyUzRDE2JTBBcHl0aG9uJTIwZXhhbXBsZXMlMkZzY3JpcHRzJTJGcHBvLnB5JTIwLS1sb2dfd2l0aCUyMHdhbmRiJTIwLS1taW5pX2JhdGNoX3NpemUlMjAxJTIwLS1ncmFkaWVudF9hY2N1bXVsYXRpb25fc3RlcHMlMjAxNg==",highlighted:`<span class="hljs-comment"># 1. run directly</span>
python examples/scripts/ppo.py
<span class="hljs-comment"># 2. run via \`accelerate\` (recommended), enabling more features (e.g., multiple GPUs, deepspeed)</span>
accelerate config <span class="hljs-comment"># will prompt you to define the training configuration</span>
accelerate launch examples/scripts/ppo.py <span class="hljs-comment"># launches training</span>
<span class="hljs-comment"># 3. get help text and documentation</span>
python examples/scripts/ppo.py --<span class="hljs-built_in">help</span>
<span class="hljs-comment"># 4. configure logging with wandb and, say, mini_batch_size=1 and gradient_accumulation_steps=16</span>
python examples/scripts/ppo.py --log_with wandb --mini_batch_size 1 --gradient_accumulation_steps 16`,wrap:!1}}),g=new V({props:{title:"Few notes on multi-GPU",local:"few-notes-on-multi-gpu",headingTag:"h2"}}),w=new le({props:{source:"https://github.com/huggingface/trl/blob/main/docs/source/sentiment_tuning.md"}}),{c(){s=i("meta"),U=l(),y=i("p"),j=l(),M(c.$$.fragment),G=l(),m=i("p"),m.innerHTML=z,I=l(),r=i("p"),r.innerHTML=R,k=l(),u=i("table"),u.innerHTML=S,H=l(),M(h.$$.fragment),Z=l(),M(d.$$.fragment),X=l(),b=i("p"),b.innerHTML=N,W=l(),M(g.$$.fragment),F=l(),f=i("p"),f.innerHTML=D,L=l(),M(w.$$.fragment),P=l(),T=i("p"),this.h()},l(e){const t=te("svelte-u9bgzb",document.head);s=p(t,"META",{name:!0,content:!0}),t.forEach(n),U=o(e),y=p(e,"P",{}),E(y).forEach(n),j=o(e),J(c.$$.fragment,e),G=o(e),m=p(e,"P",{"data-svelte-h":!0}),$(m)!=="svelte-fb2yxu"&&(m.innerHTML=z),I=o(e),r=p(e,"P",{"data-svelte-h":!0}),$(r)!=="svelte-k5thfi"&&(r.innerHTML=R),k=o(e),u=p(e,"TABLE",{"data-svelte-h":!0}),$(u)!=="svelte-18q2eca"&&(u.innerHTML=S),H=o(e),J(h.$$.fragment,e),Z=o(e),J(d.$$.fragment,e),X=o(e),b=p(e,"P",{"data-svelte-h":!0}),$(b)!=="svelte-vkwr34"&&(b.innerHTML=N),W=o(e),J(g.$$.fragment,e),F=o(e),f=p(e,"P",{"data-svelte-h":!0}),$(f)!=="svelte-qlov4x"&&(f.innerHTML=D),L=o(e),J(w.$$.fragment,e),P=o(e),T=p(e,"P",{}),E(T).forEach(n),this.h()},h(){q(s,"name","hf:doc:metadata"),q(s,"content",se)},m(e,t){ne(document.head,s),a(e,U,t),a(e,y,t),a(e,j,t),x(c,e,t),a(e,G,t),a(e,m,t),a(e,I,t),a(e,r,t),a(e,k,t),a(e,u,t),a(e,H,t),x(h,e,t),a(e,Z,t),x(d,e,t),a(e,X,t),a(e,b,t),a(e,W,t),x(g,e,t),a(e,F,t),a(e,f,t),a(e,L,t),x(w,e,t),a(e,P,t),a(e,T,t),C=!0},p:Q,i(e){C||(v(c.$$.fragment,e),v(h.$$.fragment,e),v(d.$$.fragment,e),v(g.$$.fragment,e),v(w.$$.fragment,e),C=!0)},o(e){_(c.$$.fragment,e),_(h.$$.fragment,e),_(d.$$.fragment,e),_(g.$$.fragment,e),_(w.$$.fragment,e),C=!1},d(e){e&&(n(U),n(y),n(j),n(G),n(m),n(I),n(r),n(k),n(u),n(H),n(Z),n(X),n(b),n(W),n(F),n(f),n(L),n(P),n(T)),n(s),B(c,e),B(h,e),B(d,e),B(g,e),B(w,e)}}}const se='{"title":"Sentiment Tuning Examples","local":"sentiment-tuning-examples","sections":[{"title":"Usage","local":"usage","sections":[],"depth":2},{"title":"Few notes on multi-GPU","local":"few-notes-on-multi-gpu","sections":[],"depth":2}],"depth":1}';function ie(Y){return O(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ue extends K{constructor(s){super(),ee(this,s,ie,oe,A,{})}}export{ue as component};
