import{s as Ie,n as je,o as Se}from"../chunks/scheduler.9bc65507.js";import{S as ze,i as qe,g as s,s as l,u as Pe,A as Fe,h as n,f as t,c as i,j as y,v as Le,y as r,k as c,o as p,a as o,w as Me,d as He,t as Ae,x as $e}from"../chunks/index.78c82d43.js";import{I as Ee}from"../chunks/IconCopyLink.bedaa44d.js";function Ne(le){let d,F,j,N,h,f,S,g,se,E,ie="Philosophy",U,w,re="🤗 Transformers is an opinionated library built for:",O,b,ce="<li>machine learning researchers and educators seeking to use, study or extend large-scale Transformers models.</li> <li>hands-on practitioners who want to fine-tune those models or serve them in production, or both.</li> <li>engineers who just want to download a pretrained model and use it to solve a given machine learning task.</li>",K,_,de="The library was designed with two strong goals in mind:",W,x,he="<li>Be as easy and fast to use as possible:</li>",J,T,ue=`<li>We strongly limited the number of user-facing abstractions to learn, in fact, there are almost no abstractions,
just three standard classes required to use each model: <a href="main_classes/configuration">configuration</a>,
<a href="main_classes/model">models</a>, and a preprocessing class (<a href="main_classes/tokenizer">tokenizer</a> for NLP, <a href="main_classes/image_processor">image processor</a> for vision, <a href="main_classes/feature_extractor">feature extractor</a> for audio, and <a href="main_classes/processors">processor</a> for multimodal inputs).</li> <li>All of these classes can be initialized in a simple and unified way from pretrained instances by using a common
<code>from_pretrained()</code> method which downloads (if needed), caches and
loads the related class instance and associated data (configurations’ hyperparameters, tokenizers’ vocabulary,
and models’ weights) from a pretrained checkpoint provided on <a href="https://huggingface.co/models" rel="nofollow">Hugging Face Hub</a> or your own saved checkpoint.</li> <li>On top of those three base classes, the library provides two APIs: <a href="/docs/transformers/v4.33.3/en/main_classes/pipelines#transformers.pipeline">pipeline()</a> for quickly
using a model for inference on a given task and <a href="/docs/transformers/v4.33.3/en/main_classes/trainer#transformers.Trainer">Trainer</a> to quickly train or fine-tune a PyTorch model (all TensorFlow models are compatible with <code>Keras.fit</code>).</li> <li>As a consequence, this library is NOT a modular toolbox of building blocks for neural nets. If you want to
extend or build upon the library, just use regular Python, PyTorch, TensorFlow, Keras modules and inherit from the base
classes of the library to reuse functionalities like model loading and saving. If you’d like to learn more about our coding philosophy for models, check out our <a href="https://huggingface.co/blog/transformers-design-philosophy" rel="nofollow">Repeat Yourself</a> blog post.</li>`,R,m,pe="<li>Provide state-of-the-art models with performances as close as possible to the original models:</li>",Y,k,fe=`<li>We provide at least one example for each architecture which reproduces a result provided by the official authors
of said architecture.</li> <li>The code is usually as close to the original code base as possible which means some PyTorch code may be not as
<em>pytorchic</em> as it could be as a result of being converted TensorFlow code and vice versa.</li>`,B,C,me="A few other goals:",X,P,ve="<li><p>Expose the models’ internals as consistently as possible:</p> <ul><li>We give access, using a single API, to the full hidden-states and attention weights.</li> <li>The preprocessing classes and base model APIs are standardized to easily switch between models.</li></ul></li> <li><p>Incorporate a subjective selection of promising tools for fine-tuning and investigating these models:</p> <ul><li>A simple and consistent way to add new tokens to the vocabulary and embeddings for fine-tuning.</li> <li>Simple ways to mask and prune Transformer heads.</li></ul></li> <li><p>Easily switch between PyTorch, TensorFlow 2.0 and Flax, allowing training with one framework and inference with another.</p></li>",D,u,v,z,L,ne,I,ye="Main concepts",G,M,ge="The library is built around three types of classes for each model:",Q,H,we='<li><strong>Model classes</strong> can be PyTorch models (<a href="https://pytorch.org/docs/stable/nn.html#torch.nn.Module" rel="nofollow">torch.nn.Module</a>), Keras models (<a href="https://www.tensorflow.org/api_docs/python/tf/keras/Model" rel="nofollow">tf.keras.Model</a>) or JAX/Flax models (<a href="https://flax.readthedocs.io/en/latest/api_reference/flax.linen.html" rel="nofollow">flax.linen.Module</a>) that work with the pretrained weights provided in the library.</li> <li><strong>Configuration classes</strong> store the hyperparameters required to build a model (such as the number of layers and hidden size). You don’t always need to instantiate these yourself. In particular, if you are using a pretrained model without any modification, creating the model will automatically take care of instantiating the configuration (which is part of the model).</li> <li><strong>Preprocessing classes</strong> convert the raw data into a format accepted by the model. A <a href="main_classes/tokenizer">tokenizer</a> stores the vocabulary for each model and provide methods for encoding and decoding strings in a list of token embedding indices to be fed to a model. <a href="main_classes/image_processor">Image processors</a> preprocess vision inputs, <a href="main_classes/feature_extractor">feature extractors</a> preprocess audio inputs, and a <a href="main_classes/processors">processor</a> handles multimodal inputs.</li>',V,A,be="All these classes can be instantiated from pretrained instances, saved locally, and shared on the Hub with three methods:",Z,$,_e=`<li><code>from_pretrained()</code> lets you instantiate a model, configuration, and preprocessing class from a pretrained version either
provided by the library itself (the supported models can be found on the <a href="https://huggingface.co/models" rel="nofollow">Model Hub</a>) or
stored locally (or on a server) by the user.</li> <li><code>save_pretrained()</code> lets you save a model, configuration, and preprocessing class locally so that it can be reloaded using
<code>from_pretrained()</code>.</li> <li><code>push_to_hub()</code> lets you share a model, configuration, and a preprocessing class to the Hub, so it is easily accessible to everyone.</li>`,ee,q,te;return g=new Ee({}),L=new Ee({}),{c(){d=s("meta"),F=l(),j=s("p"),N=l(),h=s("h1"),f=s("a"),S=s("span"),Pe(g.$$.fragment),se=l(),E=s("span"),E.textContent=ie,U=l(),w=s("p"),w.textContent=re,O=l(),b=s("ul"),b.innerHTML=ce,K=l(),_=s("p"),_.textContent=de,W=l(),x=s("ol"),x.innerHTML=he,J=l(),T=s("ul"),T.innerHTML=ue,R=l(),m=s("ol"),m.innerHTML=pe,Y=l(),k=s("ul"),k.innerHTML=fe,B=l(),C=s("p"),C.textContent=me,X=l(),P=s("ul"),P.innerHTML=ve,D=l(),u=s("h2"),v=s("a"),z=s("span"),Pe(L.$$.fragment),ne=l(),I=s("span"),I.textContent=ye,G=l(),M=s("p"),M.textContent=ge,Q=l(),H=s("ul"),H.innerHTML=we,V=l(),A=s("p"),A.textContent=be,Z=l(),$=s("ul"),$.innerHTML=_e,ee=l(),q=s("p"),this.h()},l(e){const a=Fe("svelte-1phssyn",document.head);d=n(a,"META",{name:!0,content:!0}),a.forEach(t),F=i(e),j=n(e,"P",{}),y(j).forEach(t),N=i(e),h=n(e,"H1",{class:!0});var ae=y(h);f=n(ae,"A",{id:!0,class:!0,href:!0});var xe=y(f);S=n(xe,"SPAN",{});var Te=y(S);Le(g.$$.fragment,Te),Te.forEach(t),xe.forEach(t),se=i(ae),E=n(ae,"SPAN",{"data-svelte-h":!0}),r(E)!=="svelte-1c7t9d0"&&(E.textContent=ie),ae.forEach(t),U=i(e),w=n(e,"P",{"data-svelte-h":!0}),r(w)!=="svelte-1p1j4j2"&&(w.textContent=re),O=i(e),b=n(e,"UL",{"data-svelte-h":!0}),r(b)!=="svelte-15p34re"&&(b.innerHTML=ce),K=i(e),_=n(e,"P",{"data-svelte-h":!0}),r(_)!=="svelte-l3cofq"&&(_.textContent=de),W=i(e),x=n(e,"OL",{"data-svelte-h":!0}),r(x)!=="svelte-a039tw"&&(x.innerHTML=he),J=i(e),T=n(e,"UL",{"data-svelte-h":!0}),r(T)!=="svelte-wg39rs"&&(T.innerHTML=ue),R=i(e),m=n(e,"OL",{start:!0,"data-svelte-h":!0}),r(m)!=="svelte-1j3ty0h"&&(m.innerHTML=pe),Y=i(e),k=n(e,"UL",{"data-svelte-h":!0}),r(k)!=="svelte-eaof5h"&&(k.innerHTML=fe),B=i(e),C=n(e,"P",{"data-svelte-h":!0}),r(C)!=="svelte-16fl7yl"&&(C.textContent=me),X=i(e),P=n(e,"UL",{"data-svelte-h":!0}),r(P)!=="svelte-r5ixu4"&&(P.innerHTML=ve),D=i(e),u=n(e,"H2",{class:!0});var oe=y(u);v=n(oe,"A",{id:!0,class:!0,href:!0});var ke=y(v);z=n(ke,"SPAN",{});var Ce=y(z);Le(L.$$.fragment,Ce),Ce.forEach(t),ke.forEach(t),ne=i(oe),I=n(oe,"SPAN",{"data-svelte-h":!0}),r(I)!=="svelte-rxuyht"&&(I.textContent=ye),oe.forEach(t),G=i(e),M=n(e,"P",{"data-svelte-h":!0}),r(M)!=="svelte-60ebt4"&&(M.textContent=ge),Q=i(e),H=n(e,"UL",{"data-svelte-h":!0}),r(H)!=="svelte-jd06a0"&&(H.innerHTML=we),V=i(e),A=n(e,"P",{"data-svelte-h":!0}),r(A)!=="svelte-ff8m9n"&&(A.textContent=be),Z=i(e),$=n(e,"UL",{"data-svelte-h":!0}),r($)!=="svelte-1p0er3n"&&($.innerHTML=_e),ee=i(e),q=n(e,"P",{}),y(q).forEach(t),this.h()},h(){c(d,"name","hf:doc:metadata"),c(d,"content",JSON.stringify(Ue)),c(f,"id","philosophy"),c(f,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(f,"href","#philosophy"),c(h,"class","relative group"),c(m,"start","2"),c(v,"id","main-concepts"),c(v,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(v,"href","#main-concepts"),c(u,"class","relative group")},m(e,a){p(document.head,d),o(e,F,a),o(e,j,a),o(e,N,a),o(e,h,a),p(h,f),p(f,S),Me(g,S,null),p(h,se),p(h,E),o(e,U,a),o(e,w,a),o(e,O,a),o(e,b,a),o(e,K,a),o(e,_,a),o(e,W,a),o(e,x,a),o(e,J,a),o(e,T,a),o(e,R,a),o(e,m,a),o(e,Y,a),o(e,k,a),o(e,B,a),o(e,C,a),o(e,X,a),o(e,P,a),o(e,D,a),o(e,u,a),p(u,v),p(v,z),Me(L,z,null),p(u,ne),p(u,I),o(e,G,a),o(e,M,a),o(e,Q,a),o(e,H,a),o(e,V,a),o(e,A,a),o(e,Z,a),o(e,$,a),o(e,ee,a),o(e,q,a),te=!0},p:je,i(e){te||(He(g.$$.fragment,e),He(L.$$.fragment,e),te=!0)},o(e){Ae(g.$$.fragment,e),Ae(L.$$.fragment,e),te=!1},d(e){e&&(t(F),t(j),t(N),t(h),t(U),t(w),t(O),t(b),t(K),t(_),t(W),t(x),t(J),t(T),t(R),t(m),t(Y),t(k),t(B),t(C),t(X),t(P),t(D),t(u),t(G),t(M),t(Q),t(H),t(V),t(A),t(Z),t($),t(ee),t(q)),t(d),$e(g),$e(L)}}}const Ue={local:"philosophy",sections:[{local:"main-concepts",title:"Main concepts"}],title:"Philosophy"};function Oe(le){return Se(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Re extends ze{constructor(d){super(),qe(this,d,Oe,Ne,Ie,{})}}export{Re as component};
