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