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 F,A as oe,h as d,f as n,c as r,j as V,u as S,x,k as D,y as ie,a,v as q,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/index.706e2c58.js";function de(k){let i,s,c="creating an account",h;return{c(){i=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(o){i=Y(o,"⚠️ In order to benefit from all features available with the Model Hub and 🤗 Transformers, we recommend "),s=d(o,"A",{href:!0,"data-svelte-h":!0}),x(s)!=="svelte-x4yw9l"&&(s.textContent=c),h=Y(o,"."),this.h()},h(){D(s,"href","https://huggingface.co/join")},m(o,f){a(o,i,f),a(o,s,f),a(o,h,f)},p:te,d(o){o&&(n(i),n(s),n(h))}}}function he(k){let i,s,c,h,o,f,p,C,w,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.',M,g,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:",P,$,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>",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,T,j,_,z;return o=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}}}),T=new me({props:{source:"https://github.com/huggingface/course/blob/main/chapters/en/chapter2/1.mdx"}}),{c(){i=m("meta"),s=l(),c=m("p"),h=l(),F(o.$$.fragment),f=l(),F(p.$$.fragment),C=l(),w=m("p"),w.innerHTML=G,M=l(),g=m("p"),g.textContent=O,P=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(),F(u.$$.fragment),E=l(),F(T.$$.fragment),j=l(),_=m("p"),this.h()},l(e){const t=oe("svelte-u9bgzb",document.head);i=d(t,"META",{name:!0,content:!0}),t.forEach(n),s=r(e),c=d(e,"P",{}),V(c).forEach(n),h=r(e),S(o.$$.fragment,e),f=r(e),S(p.$$.fragment,e),C=r(e),w=d(e,"P",{"data-svelte-h":!0}),x(w)!=="svelte-om2kog"&&(w.innerHTML=G),M=r(e),g=d(e,"P",{"data-svelte-h":!0}),x(g)!=="svelte-vek0pe"&&(g.textContent=O),P=r(e),$=d(e,"UL",{"data-svelte-h":!0}),x($)!=="svelte-jjutpu"&&($.innerHTML=R),H=r(e),b=d(e,"P",{"data-svelte-h":!0}),x(b)!=="svelte-c52yiy"&&(b.textContent=W),L=r(e),v=d(e,"P",{"data-svelte-h":!0}),x(v)!=="svelte-13bt87g"&&(v.innerHTML=J),A=r(e),y=d(e,"P",{"data-svelte-h":!0}),x(y)!=="svelte-fdnqnj"&&(y.innerHTML=K),I=r(e),S(u.$$.fragment,e),E=r(e),S(T.$$.fragment,e),j=r(e),_=d(e,"P",{}),V(_).forEach(n),this.h()},h(){D(i,"name","hf:doc:metadata"),D(i,"content",ce)},m(e,t){ie(document.head,i),a(e,s,t),a(e,c,t),a(e,h,t),q(o,e,t),a(e,f,t),q(p,e,t),a(e,C,t),a(e,w,t),a(e,M,t),a(e,g,t),a(e,P,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),q(u,e,t),a(e,E,t),q(T,e,t),a(e,j,t),a(e,_,t),z=!0},p(e,[t]){const Q={};t&2&&(Q.$$scope={dirty:t,ctx:e}),u.$set(Q)},i(e){z||(N(o.$$.fragment,e),N(p.$$.fragment,e),N(u.$$.fragment,e),N(T.$$.fragment,e),z=!0)},o(e){U(o.$$.fragment,e),U(p.$$.fragment,e),U(u.$$.fragment,e),U(T.$$.fragment,e),z=!1},d(e){e&&(n(s),n(c),n(h),n(f),n(C),n(w),n(M),n(g),n(P),n($),n(H),n(b),n(L),n(v),n(A),n(y),n(I),n(E),n(j),n(_)),n(i),B(o,e),B(p,e),B(u,e),B(T,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(i){super(),ae(this,i,fe,he,Z,{})}}export{be as component};
