import{s as Z,o as ee,n as te}from"../chunks/scheduler.37c15a92.js";import{S as ne,i as ae,g as m,s as l,r as j,A as ie,h as d,f as n,c as r,j as V,u as F,x as T,k as D,y as oe,a,v as S,d as N,t as U,w as B,m as X,n as Y}from"../chunks/index.7cb9c9b8.js";import{T as se}from"../chunks/Tip.d10b3fc9.js";import{C as le}from"../chunks/CourseFloatingBanner.df82c153.js";import{H as re,E as me}from"../chunks/getInferenceSnippets.1f335395.js";function de(k){let o,s,c="creating an account",h;return{c(){o=X("⚠️ In order to benefit from all features available with the Model Hub and 🤗 Transformers, we recommend "),s=m("a"),s.textContent=c,h=X("."),this.h()},l(i){o=Y(i,"⚠️ In order to benefit from all features available with the Model Hub and 🤗 Transformers, we recommend "),s=d(i,"A",{href:!0,"data-svelte-h":!0}),T(s)!=="svelte-x4yw9l"&&(s.textContent=c),h=Y(i,"."),this.h()},h(){D(s,"href","https://huggingface.co/join")},m(i,f){a(i,o,f),a(i,s,f),a(i,h,f)},p:te,d(i){i&&(n(o),n(s),n(h))}}}function he(k){let o,s,c,h,i,f,p,C,g,G='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.',P,w,O="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> 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>",H,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.`,L,v,J='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.',A,y,K="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.",I,u,E,x,z,_,q;return i=new re({props:{title:"Introduction",local:"introduction",headingTag:"h1"}}),p=new le({props:{chapter:2,classNames:"absolute z-10 right-0 top-0"}}),u=new se({props:{$$slots:{default:[de]},$$scope:{ctx:k}}}),x=new me({props:{source:"https://github.com/huggingface/course/blob/main/chapters/en/chapter2/1.mdx"}}),{c(){o=m("meta"),s=l(),c=m("p"),h=l(),j(i.$$.fragment),f=l(),j(p.$$.fragment),C=l(),g=m("p"),g.innerHTML=G,P=l(),w=m("p"),w.textContent=O,M=l(),$=m("ul"),$.innerHTML=R,H=l(),b=m("p"),b.textContent=W,L=l(),v=m("p"),v.innerHTML=J,A=l(),y=m("p"),y.innerHTML=K,I=l(),j(u.$$.fragment),E=l(),j(x.$$.fragment),z=l(),_=m("p"),this.h()},l(e){const t=ie("svelte-u9bgzb",document.head);o=d(t,"META",{name:!0,content:!0}),t.forEach(n),s=r(e),c=d(e,"P",{}),V(c).forEach(n),h=r(e),F(i.$$.fragment,e),f=r(e),F(p.$$.fragment,e),C=r(e),g=d(e,"P",{"data-svelte-h":!0}),T(g)!=="svelte-om2kog"&&(g.innerHTML=G),P=r(e),w=d(e,"P",{"data-svelte-h":!0}),T(w)!=="svelte-vek0pe"&&(w.textContent=O),M=r(e),$=d(e,"UL",{"data-svelte-h":!0}),T($)!=="svelte-1q4gghq"&&($.innerHTML=R),H=r(e),b=d(e,"P",{"data-svelte-h":!0}),T(b)!=="svelte-c52yiy"&&(b.textContent=W),L=r(e),v=d(e,"P",{"data-svelte-h":!0}),T(v)!=="svelte-13bt87g"&&(v.innerHTML=J),A=r(e),y=d(e,"P",{"data-svelte-h":!0}),T(y)!=="svelte-fdnqnj"&&(y.innerHTML=K),I=r(e),F(u.$$.fragment,e),E=r(e),F(x.$$.fragment,e),z=r(e),_=d(e,"P",{}),V(_).forEach(n),this.h()},h(){D(o,"name","hf:doc:metadata"),D(o,"content",ce)},m(e,t){oe(document.head,o),a(e,s,t),a(e,c,t),a(e,h,t),S(i,e,t),a(e,f,t),S(p,e,t),a(e,C,t),a(e,g,t),a(e,P,t),a(e,w,t),a(e,M,t),a(e,$,t),a(e,H,t),a(e,b,t),a(e,L,t),a(e,v,t),a(e,A,t),a(e,y,t),a(e,I,t),S(u,e,t),a(e,E,t),S(x,e,t),a(e,z,t),a(e,_,t),q=!0},p(e,[t]){const Q={};t&2&&(Q.$$scope={dirty:t,ctx:e}),u.$set(Q)},i(e){q||(N(i.$$.fragment,e),N(p.$$.fragment,e),N(u.$$.fragment,e),N(x.$$.fragment,e),q=!0)},o(e){U(i.$$.fragment,e),U(p.$$.fragment,e),U(u.$$.fragment,e),U(x.$$.fragment,e),q=!1},d(e){e&&(n(s),n(c),n(h),n(f),n(C),n(g),n(P),n(w),n(M),n($),n(H),n(b),n(L),n(v),n(A),n(y),n(I),n(E),n(z),n(_)),n(o),B(i,e),B(p,e),B(u,e),B(x,e)}}}const ce='{"title":"Introduction","local":"introduction","sections":[],"depth":1}';function fe(k){return ee(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class be extends ne{constructor(o){super(),ae(this,o,fe,he,Z,{})}}export{be as component};
