Buckets:

rtrm's picture
download
raw
15.8 kB
import{s as kt,n as xt,o as Pt}from"../chunks/scheduler.37c15a92.js";import{S as _t,i as jt,g as o,s as i,r as p,A as Ht,h as a,f as n,c as s,j as Mt,u as m,x as r,k as Se,y as Lt,a as l,v as u,d as h,t as c,w as f}from"../chunks/index.7cb9c9b8.js";import{C as d}from"../chunks/CodeBlock.abae2786.js";import{H as Oe,E as Jt}from"../chunks/getInferenceSnippets.f9350a3f.js";function Ut(De){let y,oe,ie,ae,w,re,$,Ke='Welcome to the Hugging Face course! This introduction will guide you through setting up a working environment. If you’re just starting the course, we recommend you first take a look at <a href="/course/chapter1">Chapter 1</a>, then come back and set up your environment so you can try the code yourself.',pe,b,et="All the libraries that we’ll be using in this course are available as Python packages, so here we’ll show you how to set up a Python environment and install the specific libraries you’ll need.",me,C,tt="We’ll cover two ways of setting up your working environment, using a Colab notebook or a Python virtual environment. Feel free to choose the one that resonates with you the most. For beginners, we strongly recommend that you get started by using a Colab notebook.",ue,T,nt="Note that we will not be covering the Windows system. If you’re running on Windows, we recommend following along using a Colab notebook. If you’re using a Linux distribution or macOS, you can use either approach described here.",he,M,lt='Most of the course relies on you having a Hugging Face account. We recommend creating one now: <a href="https://huggingface.co/join" rel="nofollow">create an account</a>.',ce,k,fe,x,it="Using a Colab notebook is the simplest possible setup; boot up a notebook in your browser and get straight to coding!",de,P,st='If you’re not familiar with Colab, we recommend you start by following the <a href="https://colab.research.google.com/notebooks/intro.ipynb" rel="nofollow">introduction</a>. Colab allows you to use some accelerating hardware, like GPUs or TPUs, and it is free for smaller workloads.',ye,_,ot="Once you’re comfortable moving around in Colab, create a new notebook and get started with the setup:",ve,v,at='<img src="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter0/new_colab.png" alt="An empty colab notebook" width="80%"/>',ge,j,rt="The next step is to install the libraries that we’ll be using in this course. We’ll use <code>pip</code> for the installation, which is the package manager for Python. In notebooks, you can run system commands by preceding them with the <code>!</code> character, so you can install the 🤗 Transformers library as follows:",we,H,$e,L,pt="You can make sure the package was correctly installed by importing it within your Python runtime:",be,J,Ce,g,mt='<img src="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter0/install.gif" alt="A gif showing the result of the two commands above: installation and import" width="80%"/>',Te,U,ut="This installs a very light version of 🤗 Transformers. In particular, no specific machine learning frameworks (like PyTorch or TensorFlow) are installed. Since we’ll be using a lot of different features of the library, we recommend installing the development version, which comes with all the required dependencies for pretty much any imaginable use case:",Me,I,ke,W,ht="This will take a bit of time, but then you’ll be ready to go for the rest of the course!",xe,G,Pe,Z,ct='If you prefer to use a Python virtual environment, the first step is to install Python on your system. We recommend following <a href="https://realpython.com/installing-python/" rel="nofollow">this guide</a> to get started.',_e,z,ft="Once you have Python installed, you should be able to run Python commands in your terminal. You can start by running the following command to ensure that it is correctly installed before proceeding to the next steps: <code>python --version</code>. This should print out the Python version now available on your system.",je,Y,dt="When running a Python command in your terminal, such as <code>python --version</code>, you should think of the program running your command as the “main” Python on your system. We recommend keeping this main installation free of any packages, and using it to create separate environments for each application you work on — this way, each application can have its own dependencies and packages, and you won’t need to worry about potential compatibility issues with other applications.",He,B,yt='In Python this is done with <a href="https://docs.python.org/3/tutorial/venv.html" rel="nofollow"><em>virtual environments</em></a>, which are self-contained directory trees that each contain a Python installation with a particular Python version alongside all the packages the application needs. Creating such a virtual environment can be done with a number of different tools, but we’ll use the official Python package for that purpose, which is called <a href="https://docs.python.org/3/library/venv.html#module-venv" rel="nofollow"><code>venv</code></a>.',Le,F,vt="First, create the directory you’d like your application to live in — for example, you might want to make a new directory called <em>transformers-course</em> at the root of your home directory:",Je,V,Ue,X,gt="From inside this directory, create a virtual environment using the Python <code>venv</code> module:",Ie,E,We,N,wt="You should now have a directory called <em>.env</em> in your otherwise empty folder:",Ge,R,Ze,q,ze,A,$t="You can jump in and out of your virtual environment with the <code>activate</code> and <code>deactivate</code> scripts:",Ye,Q,Be,S,bt="You can make sure that the environment is activated by running the <code>which python</code> command: if it points to the virtual environment, then you have successfully activated it!",Fe,O,Ve,D,Xe,K,Ee,ee,Ct="As in the previous section on using Google Colab instances, you’ll now need to install the packages required to continue. Again, you can install the development version of 🤗 Transformers using the <code>pip</code> package manager:",Ne,te,Re,ne,Tt="You’re now all set up and ready to go!",qe,le,Ae,se,Qe;return w=new Oe({props:{title:"Introduction",local:"introduction",headingTag:"h1"}}),k=new Oe({props:{title:"Using a Google Colab notebook",local:"using-a-google-colab-notebook",headingTag:"h2"}}),H=new d({props:{code:"IXBpcCUyMGluc3RhbGwlMjB0cmFuc2Zvcm1lcnM=",highlighted:'!pip <span class="hljs-keyword">install</span> transformers',wrap:!1}}),J=new d({props:{code:"aW1wb3J0JTIwdHJhbnNmb3JtZXJz",highlighted:'<span class="hljs-keyword">import</span> transformers',wrap:!1}}),I=new d({props:{code:"IXBpcCUyMGluc3RhbGwlMjB0cmFuc2Zvcm1lcnMlNUJzZW50ZW5jZXBpZWNlJTVE",highlighted:'!pip <span class="hljs-keyword">install</span> transformers[sentencepiece]',wrap:!1}}),G=new Oe({props:{title:"Using a Python virtual environment",local:"using-a-python-virtual-environment",headingTag:"h2"}}),V=new d({props:{code:"bWtkaXIlMjB+JTJGdHJhbnNmb3JtZXJzLWNvdXJzZSUwQWNkJTIwfiUyRnRyYW5zZm9ybWVycy1jb3Vyc2U=",highlighted:`<span class="hljs-built_in">mkdir</span> ~/transformers-course
<span class="hljs-built_in">cd</span> ~/transformers-course`,wrap:!1}}),E=new d({props:{code:"cHl0aG9uJTIwLW0lMjB2ZW52JTIwLmVudg==",highlighted:'<span class="hljs-keyword">python</span> -m venv .<span class="hljs-keyword">env</span>',wrap:!1}}),R=new d({props:{code:"bHMlMjAtYQ==",highlighted:'<span class="hljs-built_in">ls</span> -a',wrap:!1}}),q=new d({props:{code:"LiUyMCUyMCUyMCUyMCUyMCUyMC4uJTIwJTIwJTIwJTIwLmVudg==",highlighted:'. <span class="hljs-string">..</span> <span class="hljs-string">.env</span>',wrap:!1}}),Q=new d({props:{code:"JTIzJTIwQWN0aXZhdGUlMjB0aGUlMjB2aXJ0dWFsJTIwZW52aXJvbm1lbnQlMEFzb3VyY2UlMjAuZW52JTJGYmluJTJGYWN0aXZhdGUlMEElMEElMjMlMjBEZWFjdGl2YXRlJTIwdGhlJTIwdmlydHVhbCUyMGVudmlyb25tZW50JTBBZGVhY3RpdmF0ZQ==",highlighted:`<span class="hljs-comment"># Activate the virtual environment</span>
<span class="hljs-built_in">source</span> .<span class="hljs-built_in">env</span>/bin/activate
<span class="hljs-comment"># Deactivate the virtual environment</span>
deactivate`,wrap:!1}}),O=new d({props:{code:"d2hpY2glMjBweXRob24=",highlighted:'<span class="hljs-built_in">which</span> python',wrap:!1}}),D=new d({props:{code:"JTJGaG9tZSUyRiUzQ3VzZXIlM0UlMkZ0cmFuc2Zvcm1lcnMtY291cnNlJTJGLmVudiUyRmJpbiUyRnB5dGhvbg==",highlighted:'<span class="hljs-regexp">/home/</span>&lt;user&gt;<span class="hljs-regexp">/transformers-course/</span>.env<span class="hljs-regexp">/bin/</span>python',wrap:!1}}),K=new Oe({props:{title:"Installing dependencies",local:"installing-dependencies",headingTag:"h3"}}),te=new d({props:{code:"cGlwJTIwaW5zdGFsbCUyMCUyMnRyYW5zZm9ybWVycyU1QnNlbnRlbmNlcGllY2UlNUQlMjI=",highlighted:'pip <span class="hljs-keyword">install</span> <span class="hljs-string">&quot;transformers[sentencepiece]&quot;</span>',wrap:!1}}),le=new Jt({props:{source:"https://github.com/huggingface/course/blob/main/chapters/en/chapter0/1.mdx"}}),{c(){y=o("meta"),oe=i(),ie=o("p"),ae=i(),p(w.$$.fragment),re=i(),$=o("p"),$.innerHTML=Ke,pe=i(),b=o("p"),b.textContent=et,me=i(),C=o("p"),C.textContent=tt,ue=i(),T=o("p"),T.textContent=nt,he=i(),M=o("p"),M.innerHTML=lt,ce=i(),p(k.$$.fragment),fe=i(),x=o("p"),x.textContent=it,de=i(),P=o("p"),P.innerHTML=st,ye=i(),_=o("p"),_.textContent=ot,ve=i(),v=o("div"),v.innerHTML=at,ge=i(),j=o("p"),j.innerHTML=rt,we=i(),p(H.$$.fragment),$e=i(),L=o("p"),L.textContent=pt,be=i(),p(J.$$.fragment),Ce=i(),g=o("div"),g.innerHTML=mt,Te=i(),U=o("p"),U.textContent=ut,Me=i(),p(I.$$.fragment),ke=i(),W=o("p"),W.textContent=ht,xe=i(),p(G.$$.fragment),Pe=i(),Z=o("p"),Z.innerHTML=ct,_e=i(),z=o("p"),z.innerHTML=ft,je=i(),Y=o("p"),Y.innerHTML=dt,He=i(),B=o("p"),B.innerHTML=yt,Le=i(),F=o("p"),F.innerHTML=vt,Je=i(),p(V.$$.fragment),Ue=i(),X=o("p"),X.innerHTML=gt,Ie=i(),p(E.$$.fragment),We=i(),N=o("p"),N.innerHTML=wt,Ge=i(),p(R.$$.fragment),Ze=i(),p(q.$$.fragment),ze=i(),A=o("p"),A.innerHTML=$t,Ye=i(),p(Q.$$.fragment),Be=i(),S=o("p"),S.innerHTML=bt,Fe=i(),p(O.$$.fragment),Ve=i(),p(D.$$.fragment),Xe=i(),p(K.$$.fragment),Ee=i(),ee=o("p"),ee.innerHTML=Ct,Ne=i(),p(te.$$.fragment),Re=i(),ne=o("p"),ne.textContent=Tt,qe=i(),p(le.$$.fragment),Ae=i(),se=o("p"),this.h()},l(e){const t=Ht("svelte-u9bgzb",document.head);y=a(t,"META",{name:!0,content:!0}),t.forEach(n),oe=s(e),ie=a(e,"P",{}),Mt(ie).forEach(n),ae=s(e),m(w.$$.fragment,e),re=s(e),$=a(e,"P",{"data-svelte-h":!0}),r($)!=="svelte-z6g43q"&&($.innerHTML=Ke),pe=s(e),b=a(e,"P",{"data-svelte-h":!0}),r(b)!=="svelte-1uza9tj"&&(b.textContent=et),me=s(e),C=a(e,"P",{"data-svelte-h":!0}),r(C)!=="svelte-1yl2t6w"&&(C.textContent=tt),ue=s(e),T=a(e,"P",{"data-svelte-h":!0}),r(T)!=="svelte-n9l4as"&&(T.textContent=nt),he=s(e),M=a(e,"P",{"data-svelte-h":!0}),r(M)!=="svelte-e00dnb"&&(M.innerHTML=lt),ce=s(e),m(k.$$.fragment,e),fe=s(e),x=a(e,"P",{"data-svelte-h":!0}),r(x)!=="svelte-1liaxeq"&&(x.textContent=it),de=s(e),P=a(e,"P",{"data-svelte-h":!0}),r(P)!=="svelte-1f4dnnr"&&(P.innerHTML=st),ye=s(e),_=a(e,"P",{"data-svelte-h":!0}),r(_)!=="svelte-t1bkhf"&&(_.textContent=ot),ve=s(e),v=a(e,"DIV",{class:!0,"data-svelte-h":!0}),r(v)!=="svelte-1mpe2rl"&&(v.innerHTML=at),ge=s(e),j=a(e,"P",{"data-svelte-h":!0}),r(j)!=="svelte-ow5zdq"&&(j.innerHTML=rt),we=s(e),m(H.$$.fragment,e),$e=s(e),L=a(e,"P",{"data-svelte-h":!0}),r(L)!=="svelte-1lkkiz6"&&(L.textContent=pt),be=s(e),m(J.$$.fragment,e),Ce=s(e),g=a(e,"DIV",{class:!0,"data-svelte-h":!0}),r(g)!=="svelte-1cj51wg"&&(g.innerHTML=mt),Te=s(e),U=a(e,"P",{"data-svelte-h":!0}),r(U)!=="svelte-1cvhziy"&&(U.textContent=ut),Me=s(e),m(I.$$.fragment,e),ke=s(e),W=a(e,"P",{"data-svelte-h":!0}),r(W)!=="svelte-1yryfmu"&&(W.textContent=ht),xe=s(e),m(G.$$.fragment,e),Pe=s(e),Z=a(e,"P",{"data-svelte-h":!0}),r(Z)!=="svelte-14dv6xz"&&(Z.innerHTML=ct),_e=s(e),z=a(e,"P",{"data-svelte-h":!0}),r(z)!=="svelte-1fcng5u"&&(z.innerHTML=ft),je=s(e),Y=a(e,"P",{"data-svelte-h":!0}),r(Y)!=="svelte-1m7tbp5"&&(Y.innerHTML=dt),He=s(e),B=a(e,"P",{"data-svelte-h":!0}),r(B)!=="svelte-1f15k5e"&&(B.innerHTML=yt),Le=s(e),F=a(e,"P",{"data-svelte-h":!0}),r(F)!=="svelte-wj76hq"&&(F.innerHTML=vt),Je=s(e),m(V.$$.fragment,e),Ue=s(e),X=a(e,"P",{"data-svelte-h":!0}),r(X)!=="svelte-lxg001"&&(X.innerHTML=gt),Ie=s(e),m(E.$$.fragment,e),We=s(e),N=a(e,"P",{"data-svelte-h":!0}),r(N)!=="svelte-1yij4yq"&&(N.innerHTML=wt),Ge=s(e),m(R.$$.fragment,e),Ze=s(e),m(q.$$.fragment,e),ze=s(e),A=a(e,"P",{"data-svelte-h":!0}),r(A)!=="svelte-tn98fi"&&(A.innerHTML=$t),Ye=s(e),m(Q.$$.fragment,e),Be=s(e),S=a(e,"P",{"data-svelte-h":!0}),r(S)!=="svelte-138z6z9"&&(S.innerHTML=bt),Fe=s(e),m(O.$$.fragment,e),Ve=s(e),m(D.$$.fragment,e),Xe=s(e),m(K.$$.fragment,e),Ee=s(e),ee=a(e,"P",{"data-svelte-h":!0}),r(ee)!=="svelte-rnazue"&&(ee.innerHTML=Ct),Ne=s(e),m(te.$$.fragment,e),Re=s(e),ne=a(e,"P",{"data-svelte-h":!0}),r(ne)!=="svelte-1g9sczb"&&(ne.textContent=Tt),qe=s(e),m(le.$$.fragment,e),Ae=s(e),se=a(e,"P",{}),Mt(se).forEach(n),this.h()},h(){Se(y,"name","hf:doc:metadata"),Se(y,"content",It),Se(v,"class","flex justify-center"),Se(g,"class","flex justify-center")},m(e,t){Lt(document.head,y),l(e,oe,t),l(e,ie,t),l(e,ae,t),u(w,e,t),l(e,re,t),l(e,$,t),l(e,pe,t),l(e,b,t),l(e,me,t),l(e,C,t),l(e,ue,t),l(e,T,t),l(e,he,t),l(e,M,t),l(e,ce,t),u(k,e,t),l(e,fe,t),l(e,x,t),l(e,de,t),l(e,P,t),l(e,ye,t),l(e,_,t),l(e,ve,t),l(e,v,t),l(e,ge,t),l(e,j,t),l(e,we,t),u(H,e,t),l(e,$e,t),l(e,L,t),l(e,be,t),u(J,e,t),l(e,Ce,t),l(e,g,t),l(e,Te,t),l(e,U,t),l(e,Me,t),u(I,e,t),l(e,ke,t),l(e,W,t),l(e,xe,t),u(G,e,t),l(e,Pe,t),l(e,Z,t),l(e,_e,t),l(e,z,t),l(e,je,t),l(e,Y,t),l(e,He,t),l(e,B,t),l(e,Le,t),l(e,F,t),l(e,Je,t),u(V,e,t),l(e,Ue,t),l(e,X,t),l(e,Ie,t),u(E,e,t),l(e,We,t),l(e,N,t),l(e,Ge,t),u(R,e,t),l(e,Ze,t),u(q,e,t),l(e,ze,t),l(e,A,t),l(e,Ye,t),u(Q,e,t),l(e,Be,t),l(e,S,t),l(e,Fe,t),u(O,e,t),l(e,Ve,t),u(D,e,t),l(e,Xe,t),u(K,e,t),l(e,Ee,t),l(e,ee,t),l(e,Ne,t),u(te,e,t),l(e,Re,t),l(e,ne,t),l(e,qe,t),u(le,e,t),l(e,Ae,t),l(e,se,t),Qe=!0},p:xt,i(e){Qe||(h(w.$$.fragment,e),h(k.$$.fragment,e),h(H.$$.fragment,e),h(J.$$.fragment,e),h(I.$$.fragment,e),h(G.$$.fragment,e),h(V.$$.fragment,e),h(E.$$.fragment,e),h(R.$$.fragment,e),h(q.$$.fragment,e),h(Q.$$.fragment,e),h(O.$$.fragment,e),h(D.$$.fragment,e),h(K.$$.fragment,e),h(te.$$.fragment,e),h(le.$$.fragment,e),Qe=!0)},o(e){c(w.$$.fragment,e),c(k.$$.fragment,e),c(H.$$.fragment,e),c(J.$$.fragment,e),c(I.$$.fragment,e),c(G.$$.fragment,e),c(V.$$.fragment,e),c(E.$$.fragment,e),c(R.$$.fragment,e),c(q.$$.fragment,e),c(Q.$$.fragment,e),c(O.$$.fragment,e),c(D.$$.fragment,e),c(K.$$.fragment,e),c(te.$$.fragment,e),c(le.$$.fragment,e),Qe=!1},d(e){e&&(n(oe),n(ie),n(ae),n(re),n($),n(pe),n(b),n(me),n(C),n(ue),n(T),n(he),n(M),n(ce),n(fe),n(x),n(de),n(P),n(ye),n(_),n(ve),n(v),n(ge),n(j),n(we),n($e),n(L),n(be),n(Ce),n(g),n(Te),n(U),n(Me),n(ke),n(W),n(xe),n(Pe),n(Z),n(_e),n(z),n(je),n(Y),n(He),n(B),n(Le),n(F),n(Je),n(Ue),n(X),n(Ie),n(We),n(N),n(Ge),n(Ze),n(ze),n(A),n(Ye),n(Be),n(S),n(Fe),n(Ve),n(Xe),n(Ee),n(ee),n(Ne),n(Re),n(ne),n(qe),n(Ae),n(se)),n(y),f(w,e),f(k,e),f(H,e),f(J,e),f(I,e),f(G,e),f(V,e),f(E,e),f(R,e),f(q,e),f(Q,e),f(O,e),f(D,e),f(K,e),f(te,e),f(le,e)}}}const It='{"title":"Introduction","local":"introduction","sections":[{"title":"Using a Google Colab notebook","local":"using-a-google-colab-notebook","sections":[],"depth":2},{"title":"Using a Python virtual environment","local":"using-a-python-virtual-environment","sections":[{"title":"Installing dependencies","local":"installing-dependencies","sections":[],"depth":3}],"depth":2}],"depth":1}';function Wt(De){return Pt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Bt extends _t{constructor(y){super(),jt(this,y,Wt,Ut,kt,{})}}export{Bt as component};

Xet Storage Details

Size:
15.8 kB
·
Xet hash:
3d4fe7d6e8a4c18ebdf13b5b007dbdb5dc3b9741cd0feefdd8e4870f5900db77

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.