import{s as X,o as Y,n as Z}from"../chunks/scheduler.37c15a92.js";import{S as ee,i as te,g as d,s,r as z,A as ne,h as m,f as n,c as r,j as O,u as E,x as T,k as U,y as ae,a,v as F,d as S,t as q,w as N,m as Q,n as V}from"../chunks/index.2bf4358c.js";import{T as oe}from"../chunks/Tip.363c041f.js";import{C as ie}from"../chunks/CourseFloatingBanner.15ba07e6.js";import{H as le}from"../chunks/Heading.8ada512a.js";function se(_){let i,l,c="creating an account",h;return{c(){i=Q("⚠️ In order to benefit from all features available with the Model Hub and 🤗 Transformers, we recommend "),l=d("a"),l.textContent=c,h=Q("."),this.h()},l(o){i=V(o,"⚠️ In order to benefit from all features available with the Model Hub and 🤗 Transformers, we recommend "),l=m(o,"A",{href:!0,"data-svelte-h":!0}),T(l)!=="svelte-x4yw9l"&&(l.textContent=c),h=V(o,"."),this.h()},h(){U(l,"href","https://huggingface.co/join")},m(o,f){a(o,i,f),a(o,l,f),a(o,h,f)},p:Z,d(o){o&&(n(i),n(l),n(h))}}}function re(_){let i,l,c,h,o,f,p,k,w,B='As you saw in <a href="/course/chapter1">Chapter 1</a>, Transformer models are usually very large. With millions to tens of <em>billions</em> of parameters, training and deploying these models is a complicated undertaking. Furthermore, with new models being released on a near-daily basis and each having its own implementation, trying them all out is no easy task.',C,g,D="The 🤗 Transformers library was created to solve this problem. Its goal is to provide a single API through which any Transformer model can be loaded, trained, and saved. The library’s main features are:",M,$,R="<li><strong>Ease of use</strong>: Downloading, loading, and using a state-of-the-art NLP model for inference can be done in just two lines of code.</li> <li><strong>Flexibility</strong>: At their core, all models are simple PyTorch <code>nn.Module</code> or TensorFlow <code>tf.keras.Model</code> classes and can be handled like any other models in their respective machine learning (ML) frameworks.</li> <li><strong>Simplicity</strong>: Hardly any abstractions are made across the library. The “All in one file” is a core concept: a model’s forward pass is entirely defined in a single file, so that the code itself is understandable and hackable.</li>",P,b,W=`This last feature makes 🤗 Transformers quite different from other ML libraries. The models are not built on modules
that are shared across files; instead, each model has its own layers. In addition to making the models more approachable and understandable, this allows you to easily experiment on one model without affecting others.`,H,v,G='This chapter will begin with an end-to-end example where we use a model and a tokenizer together to replicate the <code>pipeline()</code> function introduced in <a href="/course/chapter1">Chapter 1</a>. Next, we’ll discuss the model API: we’ll dive into the model and configuration classes, and show you how to load a model and how it processes numerical inputs to output predictions.',L,y,J="Then we’ll look at the tokenizer API, which is the other main component of the <code>pipeline()</code> function. Tokenizers take care of the first and last processing steps, handling the conversion from text to numerical inputs for the neural network, and the conversion back to text when it is needed. Finally, we’ll show you how to handle sending multiple sentences through a model in a prepared batch, then wrap it all up with a closer look at the high-level <code>tokenizer()</code> function.",A,u,I,x,j;return o=new le({props:{title:"Introduction",local:"introduction",headingTag:"h1"}}),p=new ie({props:{chapter:2,classNames:"absolute z-10 right-0 top-0"}}),u=new oe({props:{$$slots:{default:[se]},$$scope:{ctx:_}}}),{c(){i=d("meta"),l=s(),c=d("p"),h=s(),z(o.$$.fragment),f=s(),z(p.$$.fragment),k=s(),w=d("p"),w.innerHTML=B,C=s(),g=d("p"),g.textContent=D,M=s(),$=d("ul"),$.innerHTML=R,P=s(),b=d("p"),b.textContent=W,H=s(),v=d("p"),v.innerHTML=G,L=s(),y=d("p"),y.innerHTML=J,A=s(),z(u.$$.fragment),I=s(),x=d("p"),this.h()},l(e){const t=ne("svelte-u9bgzb",document.head);i=m(t,"META",{name:!0,content:!0}),t.forEach(n),l=r(e),c=m(e,"P",{}),O(c).forEach(n),h=r(e),E(o.$$.fragment,e),f=r(e),E(p.$$.fragment,e),k=r(e),w=m(e,"P",{"data-svelte-h":!0}),T(w)!=="svelte-om2kog"&&(w.innerHTML=B),C=r(e),g=m(e,"P",{"data-svelte-h":!0}),T(g)!=="svelte-vek0pe"&&(g.textContent=D),M=r(e),$=m(e,"UL",{"data-svelte-h":!0}),T($)!=="svelte-jjutpu"&&($.innerHTML=R),P=r(e),b=m(e,"P",{"data-svelte-h":!0}),T(b)!=="svelte-c52yiy"&&(b.textContent=W),H=r(e),v=m(e,"P",{"data-svelte-h":!0}),T(v)!=="svelte-13bt87g"&&(v.innerHTML=G),L=r(e),y=m(e,"P",{"data-svelte-h":!0}),T(y)!=="svelte-fdnqnj"&&(y.innerHTML=J),A=r(e),E(u.$$.fragment,e),I=r(e),x=m(e,"P",{}),O(x).forEach(n),this.h()},h(){U(i,"name","hf:doc:metadata"),U(i,"content",de)},m(e,t){ae(document.head,i),a(e,l,t),a(e,c,t),a(e,h,t),F(o,e,t),a(e,f,t),F(p,e,t),a(e,k,t),a(e,w,t),a(e,C,t),a(e,g,t),a(e,M,t),a(e,$,t),a(e,P,t),a(e,b,t),a(e,H,t),a(e,v,t),a(e,L,t),a(e,y,t),a(e,A,t),F(u,e,t),a(e,I,t),a(e,x,t),j=!0},p(e,[t]){const K={};t&2&&(K.$$scope={dirty:t,ctx:e}),u.$set(K)},i(e){j||(S(o.$$.fragment,e),S(p.$$.fragment,e),S(u.$$.fragment,e),j=!0)},o(e){q(o.$$.fragment,e),q(p.$$.fragment,e),q(u.$$.fragment,e),j=!1},d(e){e&&(n(l),n(c),n(h),n(f),n(k),n(w),n(C),n(g),n(M),n($),n(P),n(b),n(H),n(v),n(L),n(y),n(A),n(I),n(x)),n(i),N(o,e),N(p,e),N(u,e)}}}const de='{"title":"Introduction","local":"introduction","sections":[],"depth":1}';function me(_){return Y(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class we extends ee{constructor(i){super(),te(this,i,me,re,X,{})}}export{we as component};
