import{S as Rr,i as Lr,s as Ur,e as f,k as m,w as C,t as i,M as Yr,c as h,d as o,m as _,x as q,a as d,h as n,b as j,F as r,g as c,y as P,o as b,p as xe,q as y,B as A,v as Gr,n as He}from"../../chunks/vendor-1e8b365d.js";import{Y as Hr}from"../../chunks/Youtube-c2a8cc39.js";import{I as _t}from"../../chunks/IconCopyLink-483c28ba.js";import{C as F}from"../../chunks/CodeBlock-e5764662.js";import{D as Wr}from"../../chunks/DocNotebookDropdown-37d928d3.js";import{F as Jr}from"../../chunks/FrameworkSwitchCourse-7f8f0f31.js";function Vr(k){let s,l;return s=new Wr({props:{classNames:"absolute z-10 right-0 top-0",options:[{label:"Google Colab",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/master/course/chapter2/section3_tf.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/chapter2/section3_tf.ipynb"}]}}),{c(){C(s.$$.fragment)},l(t){q(s.$$.fragment,t)},m(t,p){P(s,t,p),l=!0},i(t){l||(y(s.$$.fragment,t),l=!0)},o(t){b(s.$$.fragment,t),l=!1},d(t){A(s,t)}}}function Kr(k){let s,l;return s=new Wr({props:{classNames:"absolute z-10 right-0 top-0",options:[{label:"Google Colab",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/master/course/chapter2/section3_pt.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/chapter2/section3_pt.ipynb"}]}}),{c(){C(s.$$.fragment)},l(t){q(s.$$.fragment,t)},m(t,p){P(s,t,p),l=!0},i(t){l||(y(s.$$.fragment,t),l=!0)},o(t){b(s.$$.fragment,t),l=!1},d(t){A(s,t)}}}function Qr(k){let s,l;return s=new Hr({props:{id:"d3JVgghSOew"}}),{c(){C(s.$$.fragment)},l(t){q(s.$$.fragment,t)},m(t,p){P(s,t,p),l=!0},i(t){l||(y(s.$$.fragment,t),l=!0)},o(t){b(s.$$.fragment,t),l=!1},d(t){A(s,t)}}}function Xr(k){let s,l;return s=new Hr({props:{id:"AhChOFRegn4"}}),{c(){C(s.$$.fragment)},l(t){q(s.$$.fragment,t)},m(t,p){P(s,t,p),l=!0},i(t){l||(y(s.$$.fragment,t),l=!0)},o(t){b(s.$$.fragment,t),l=!1},d(t){A(s,t)}}}function Zr(k){let s,l,t,p,E,$,g,T,B,v,M;return{c(){s=f("p"),l=i("In this section we\u2019ll take a closer look at creating and using a model. We\u2019ll use the "),t=f("code"),p=i("TFAutoModel"),E=i(" class, which is handy when you want to instantiate any model from a checkpoint."),$=m(),g=f("p"),T=i("The "),B=f("code"),v=i("TFAutoModel"),M=i(" class and all of its relatives are actually simple wrappers over the wide variety of models available in the library. It\u2019s a clever wrapper as it can automatically guess the appropriate model architecture for your checkpoint, and then instantiates a model with this architecture.")},l(u){s=h(u,"P",{});var w=d(s);l=n(w,"In this section we\u2019ll take a closer look at creating and using a model. We\u2019ll use the "),t=h(w,"CODE",{});var z=d(t);p=n(z,"TFAutoModel"),z.forEach(o),E=n(w," class, which is handy when you want to instantiate any model from a checkpoint."),w.forEach(o),$=_(u),g=h(u,"P",{});var N=d(g);T=n(N,"The "),B=h(N,"CODE",{});var D=d(B);v=n(D,"TFAutoModel"),D.forEach(o),M=n(N," class and all of its relatives are actually simple wrappers over the wide variety of models available in the library. It\u2019s a clever wrapper as it can automatically guess the appropriate model architecture for your checkpoint, and then instantiates a model with this architecture."),N.forEach(o)},m(u,w){c(u,s,w),r(s,l),r(s,t),r(t,p),r(s,E),c(u,$,w),c(u,g,w),r(g,T),r(g,B),r(B,v),r(g,M)},d(u){u&&o(s),u&&o($),u&&o(g)}}}function ea(k){let s,l,t,p,E,$,g,T,B,v,M;return{c(){s=f("p"),l=i("In this section we\u2019ll take a closer look at creating and using a model. We\u2019ll use the "),t=f("code"),p=i("AutoModel"),E=i(" class, which is handy when you want to instantiate any model from a checkpoint."),$=m(),g=f("p"),T=i("The "),B=f("code"),v=i("AutoModel"),M=i(" class and all of its relatives are actually simple wrappers over the wide variety of models available in the library. It\u2019s a clever wrapper as it can automatically guess the appropriate model architecture for your checkpoint, and then instantiates a model with this architecture.")},l(u){s=h(u,"P",{});var w=d(s);l=n(w,"In this section we\u2019ll take a closer look at creating and using a model. We\u2019ll use the "),t=h(w,"CODE",{});var z=d(t);p=n(z,"AutoModel"),z.forEach(o),E=n(w," class, which is handy when you want to instantiate any model from a checkpoint."),w.forEach(o),$=_(u),g=h(u,"P",{});var N=d(g);T=n(N,"The "),B=h(N,"CODE",{});var D=d(B);v=n(D,"AutoModel"),D.forEach(o),M=n(N," class and all of its relatives are actually simple wrappers over the wide variety of models available in the library. It\u2019s a clever wrapper as it can automatically guess the appropriate model architecture for your checkpoint, and then instantiates a model with this architecture."),N.forEach(o)},m(u,w){c(u,s,w),r(s,l),r(s,t),r(t,p),r(s,E),c(u,$,w),c(u,g,w),r(g,T),r(g,B),r(B,v),r(g,M)},d(u){u&&o(s),u&&o($),u&&o(g)}}}function ta(k){let s,l;return s=new F({props:{code:`from transformers import BertConfig, TFBertModel

# Building the config
config = BertConfig()

# Building the model from the config
model = TFBertModel(config)`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> BertConfig, TFBertModel

<span class="hljs-comment"># Building the config</span>
config = BertConfig()

<span class="hljs-comment"># Building the model from the config</span>
model = TFBertModel(config)`}}),{c(){C(s.$$.fragment)},l(t){q(s.$$.fragment,t)},m(t,p){P(s,t,p),l=!0},i(t){l||(y(s.$$.fragment,t),l=!0)},o(t){b(s.$$.fragment,t),l=!1},d(t){A(s,t)}}}function oa(k){let s,l;return s=new F({props:{code:`from transformers import BertConfig, BertModel

# Building the config
config = BertConfig()

# Building the model from the config
model = BertModel(config)`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> BertConfig, BertModel

<span class="hljs-comment"># Building the config</span>
config = BertConfig()

<span class="hljs-comment"># Building the model from the config</span>
model = BertModel(config)`}}),{c(){C(s.$$.fragment)},l(t){q(s.$$.fragment,t)},m(t,p){P(s,t,p),l=!0},i(t){l||(y(s.$$.fragment,t),l=!0)},o(t){b(s.$$.fragment,t),l=!1},d(t){A(s,t)}}}function sa(k){let s,l;return s=new F({props:{code:`from transformers import BertConfig, TFBertModel

config = BertConfig()
model = TFBertModel(config)

# Model is randomly initialized!`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> BertConfig, TFBertModel

config = BertConfig()
model = TFBertModel(config)

<span class="hljs-comment"># Model is randomly initialized!</span>`}}),{c(){C(s.$$.fragment)},l(t){q(s.$$.fragment,t)},m(t,p){P(s,t,p),l=!0},i(t){l||(y(s.$$.fragment,t),l=!0)},o(t){b(s.$$.fragment,t),l=!1},d(t){A(s,t)}}}function ra(k){let s,l;return s=new F({props:{code:`from transformers import BertConfig, BertModel

config = BertConfig()
model = BertModel(config)

# Model is randomly initialized!`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> BertConfig, BertModel

config = BertConfig()
model = BertModel(config)

<span class="hljs-comment"># Model is randomly initialized!</span>`}}),{c(){C(s.$$.fragment)},l(t){q(s.$$.fragment,t)},m(t,p){P(s,t,p),l=!0},i(t){l||(y(s.$$.fragment,t),l=!0)},o(t){b(s.$$.fragment,t),l=!1},d(t){A(s,t)}}}function aa(k){let s,l,t,p,E,$,g,T,B,v,M;return s=new F({props:{code:`from transformers import TFBertModel

model = TFBertModel.from_pretrained("bert-base-cased")`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TFBertModel

model = TFBertModel.from_pretrained(<span class="hljs-string">&quot;bert-base-cased&quot;</span>)`}}),{c(){C(s.$$.fragment),l=m(),t=f("p"),p=i("As you saw earlier, we could replace "),E=f("code"),$=i("TFBertModel"),g=i(" with the equivalent "),T=f("code"),B=i("TFAutoModel"),v=i(" class. We\u2019ll do this from now on as this produces checkpoint-agnostic code; if your code works for one checkpoint, it should work seamlessly with another. This applies even if the architecture is different, as long as the checkpoint was trained for a similar task (for example, a sentiment analysis task).")},l(u){q(s.$$.fragment,u),l=_(u),t=h(u,"P",{});var w=d(t);p=n(w,"As you saw earlier, we could replace "),E=h(w,"CODE",{});var z=d(E);$=n(z,"TFBertModel"),z.forEach(o),g=n(w," with the equivalent "),T=h(w,"CODE",{});var N=d(T);B=n(N,"TFAutoModel"),N.forEach(o),v=n(w," class. We\u2019ll do this from now on as this produces checkpoint-agnostic code; if your code works for one checkpoint, it should work seamlessly with another. This applies even if the architecture is different, as long as the checkpoint was trained for a similar task (for example, a sentiment analysis task)."),w.forEach(o)},m(u,w){P(s,u,w),c(u,l,w),c(u,t,w),r(t,p),r(t,E),r(E,$),r(t,g),r(t,T),r(T,B),r(t,v),M=!0},i(u){M||(y(s.$$.fragment,u),M=!0)},o(u){b(s.$$.fragment,u),M=!1},d(u){A(s,u),u&&o(l),u&&o(t)}}}function la(k){let s,l,t,p,E,$,g,T,B,v,M;return s=new F({props:{code:`from transformers import BertModel

model = BertModel.from_pretrained("bert-base-cased")`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> BertModel

model = BertModel.from_pretrained(<span class="hljs-string">&quot;bert-base-cased&quot;</span>)`}}),{c(){C(s.$$.fragment),l=m(),t=f("p"),p=i("As you saw earlier, we could replace "),E=f("code"),$=i("BertModel"),g=i(" with the equivalent "),T=f("code"),B=i("AutoModel"),v=i(" class. We\u2019ll do this from now on as this produces checkpoint-agnostic code; if your code works for one checkpoint, it should work seamlessly with another. This applies even if the architecture is different, as long as the checkpoint was trained for a similar task (for example, a sentiment analysis task).")},l(u){q(s.$$.fragment,u),l=_(u),t=h(u,"P",{});var w=d(t);p=n(w,"As you saw earlier, we could replace "),E=h(w,"CODE",{});var z=d(E);$=n(z,"BertModel"),z.forEach(o),g=n(w," with the equivalent "),T=h(w,"CODE",{});var N=d(T);B=n(N,"AutoModel"),N.forEach(o),v=n(w," class. We\u2019ll do this from now on as this produces checkpoint-agnostic code; if your code works for one checkpoint, it should work seamlessly with another. This applies even if the architecture is different, as long as the checkpoint was trained for a similar task (for example, a sentiment analysis task)."),w.forEach(o)},m(u,w){P(s,u,w),c(u,l,w),c(u,t,w),r(t,p),r(t,E),r(E,$),r(t,g),r(t,T),r(T,B),r(t,v),M=!0},i(u){M||(y(s.$$.fragment,u),M=!0)},o(u){b(s.$$.fragment,u),M=!1},d(u){A(s,u),u&&o(l),u&&o(t)}}}function ia(k){let s,l;return s=new F({props:{code:`ls directory_on_my_computer

config.json tf_model.h5`,highlighted:`ls <span class="hljs-keyword">directory_on_my_computer
</span>
<span class="hljs-built_in">config</span>.<span class="hljs-keyword">json </span>tf_model.h5`}}),{c(){C(s.$$.fragment)},l(t){q(s.$$.fragment,t)},m(t,p){P(s,t,p),l=!0},i(t){l||(y(s.$$.fragment,t),l=!0)},o(t){b(s.$$.fragment,t),l=!1},d(t){A(s,t)}}}function na(k){let s,l;return s=new F({props:{code:`ls directory_on_my_computer

config.json pytorch_model.bin`,highlighted:`ls <span class="hljs-keyword">directory_on_my_computer
</span>
<span class="hljs-built_in">config</span>.<span class="hljs-keyword">json </span>pytorch_model.<span class="hljs-keyword">bin</span>`}}),{c(){C(s.$$.fragment)},l(t){q(s.$$.fragment,t)},m(t,p){P(s,t,p),l=!0},i(t){l||(y(s.$$.fragment,t),l=!0)},o(t){b(s.$$.fragment,t),l=!1},d(t){A(s,t)}}}function ca(k){let s,l,t,p,E,$,g,T;return{c(){s=f("p"),l=i("The "),t=f("em"),p=i("tf_model.h5"),E=i(" file is known as the "),$=f("em"),g=i("state dictionary"),T=i("; it contains all your model\u2019s weights. The two files go hand in hand; the configuration is necessary to know your model\u2019s architecture, while the model weights are your model\u2019s parameters.")},l(B){s=h(B,"P",{});var v=d(s);l=n(v,"The "),t=h(v,"EM",{});var M=d(t);p=n(M,"tf_model.h5"),M.forEach(o),E=n(v," file is known as the "),$=h(v,"EM",{});var u=d($);g=n(u,"state dictionary"),u.forEach(o),T=n(v,"; it contains all your model\u2019s weights. The two files go hand in hand; the configuration is necessary to know your model\u2019s architecture, while the model weights are your model\u2019s parameters."),v.forEach(o)},m(B,v){c(B,s,v),r(s,l),r(s,t),r(t,p),r(s,E),r(s,$),r($,g),r(s,T)},d(B){B&&o(s)}}}function fa(k){let s,l,t,p,E,$,g,T;return{c(){s=f("p"),l=i("The "),t=f("em"),p=i("pytorch_model.bin"),E=i(" file is known as the "),$=f("em"),g=i("state dictionary"),T=i("; it contains all your model\u2019s weights. The two files go hand in hand; the configuration is necessary to know your model\u2019s architecture, while the model weights are your model\u2019s parameters.")},l(B){s=h(B,"P",{});var v=d(s);l=n(v,"The "),t=h(v,"EM",{});var M=d(t);p=n(M,"pytorch_model.bin"),M.forEach(o),E=n(v," file is known as the "),$=h(v,"EM",{});var u=d($);g=n(u,"state dictionary"),u.forEach(o),T=n(v,"; it contains all your model\u2019s weights. The two files go hand in hand; the configuration is necessary to know your model\u2019s architecture, while the model weights are your model\u2019s parameters."),v.forEach(o)},m(B,v){c(B,s,v),r(s,l),r(s,t),r(t,p),r(s,E),r(s,$),r($,g),r(s,T)},d(B){B&&o(s)}}}function ha(k){let s,l;return s=new F({props:{code:`import tensorflow as tf

model_inputs = tf.constant(encoded_sequences)`,highlighted:`<span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf

model_inputs = tf.constant(encoded_sequences)`}}),{c(){C(s.$$.fragment)},l(t){q(s.$$.fragment,t)},m(t,p){P(s,t,p),l=!0},i(t){l||(y(s.$$.fragment,t),l=!0)},o(t){b(s.$$.fragment,t),l=!1},d(t){A(s,t)}}}function da(k){let s,l;return s=new F({props:{code:`import torch

model_inputs = torch.tensor(encoded_sequences)`,highlighted:`<span class="hljs-keyword">import</span> torch

model_inputs = torch.tensor(encoded_sequences)`}}),{c(){C(s.$$.fragment)},l(t){q(s.$$.fragment,t)},m(t,p){P(s,t,p),l=!0},i(t){l||(y(s.$$.fragment,t),l=!0)},o(t){b(s.$$.fragment,t),l=!1},d(t){A(s,t)}}}function ua(k){let s,l,t,p,E,$,g,T,B,v,M,u,w,z,N,D,x,We,Re,Le,qo,xt,X,ae,wt,ye,Po,bt,Ao,Ht,Ue,zo,Wt,H,W,Ye,Ge,No,Rt,ke,Lt,ge,Ut,S,Do,yt,Fo,So,kt,Oo,Io,gt,xo,Ho,Yt,Z,le,vt,ve,Wo,$t,Ro,Gt,Je,Lo,Jt,R,L,Ve,ie,Uo,Ke,Yo,Go,Vt,ne,Jo,Et,Vo,Ko,Kt,U,Y,Qe,O,Qo,Tt,Xo,Zo,Bt,es,ts,$e,os,ss,Qt,Xe,rs,Xt,I,as,jt,ls,is,Mt,ns,cs,Ct,fs,hs,Zt,ce,ds,Ee,us,ps,eo,ee,fe,qt,Te,ms,Pt,_s,to,Q,ws,At,bs,ys,zt,ks,gs,oo,Be,so,Ze,vs,ro,G,J,et,he,$s,Nt,Es,Ts,ao,tt,te,de,Dt,je,Bs,Ft,js,lo,ot,Ms,io,st,Cs,no,rt,qs,co,Me,fo,ue,Ps,St,As,zs,ho,Ce,uo,at,Ns,po,V,K,lt,oe,pe,Ot,qe,Ds,It,Fs,mo,it,Ss,_o,Pe,wo,nt,Os,bo;t=new Jr({props:{fw:k[0]}}),T=new _t({});const Is=[Kr,Vr],Ae=[];function xs(e,a){return e[0]==="pt"?0:1}w=xs(k),z=Ae[w]=Is[w](k);const Hs=[Xr,Qr],ze=[];function Ws(e,a){return e[0]==="pt"?0:1}D=Ws(k),x=ze[D]=Hs[D](k);function Rs(e,a){return e[0]==="pt"?ea:Zr}let yo=Rs(k),se=yo(k);ye=new _t({});const Ls=[oa,ta],Ne=[];function Us(e,a){return e[0]==="pt"?0:1}H=Us(k),W=Ne[H]=Ls[H](k),ke=new F({props:{code:"print(config)",highlighted:'<span class="hljs-built_in">print</span>(config)'}}),ge=new F({props:{code:`BertConfig {
  [...]
  "hidden_size": 768,
  "intermediate_size": 3072,
  "max_position_embeddings": 512,
  "num_attention_heads": 12,
  "num_hidden_layers": 12,
  [...]
}`,highlighted:`BertConfig {
  [...]
  <span class="hljs-string">&quot;hidden_size&quot;</span>: <span class="hljs-number">768</span>,
  <span class="hljs-string">&quot;intermediate_size&quot;</span>: <span class="hljs-number">3072</span>,
  <span class="hljs-string">&quot;max_position_embeddings&quot;</span>: <span class="hljs-number">512</span>,
  <span class="hljs-string">&quot;num_attention_heads&quot;</span>: <span class="hljs-number">12</span>,
  <span class="hljs-string">&quot;num_hidden_layers&quot;</span>: <span class="hljs-number">12</span>,
  [...]
}`}}),ve=new _t({});const Ys=[ra,sa],De=[];function Gs(e,a){return e[0]==="pt"?0:1}R=Gs(k),L=De[R]=Ys[R](k);const Js=[la,aa],Fe=[];function Vs(e,a){return e[0]==="pt"?0:1}U=Vs(k),Y=Fe[U]=Js[U](k),Te=new _t({}),Be=new F({props:{code:'model.save_pretrained("directory_on_my_computer")',highlighted:'model.save_pretrained(<span class="hljs-string">&quot;directory_on_my_computer&quot;</span>)'}});const Ks=[na,ia],Se=[];function Qs(e,a){return e[0]==="pt"?0:1}G=Qs(k),J=Se[G]=Ks[G](k);function Xs(e,a){return e[0]==="pt"?fa:ca}let ko=Xs(k),re=ko(k);je=new _t({}),Me=new F({props:{code:'sequences = ["Hello!", "Cool.", "Nice!"]',highlighted:'sequences = [<span class="hljs-string">&quot;Hello!&quot;</span>, <span class="hljs-string">&quot;Cool.&quot;</span>, <span class="hljs-string">&quot;Nice!&quot;</span>]'}}),Ce=new F({props:{code:`encoded_sequences = [
    [101, 7592, 999, 102],
    [101, 4658, 1012, 102],
    [101, 3835, 999, 102],
]`,highlighted:`encoded_sequences = [
    [<span class="hljs-number">101</span>, <span class="hljs-number">7592</span>, <span class="hljs-number">999</span>, <span class="hljs-number">102</span>],
    [<span class="hljs-number">101</span>, <span class="hljs-number">4658</span>, <span class="hljs-number">1012</span>, <span class="hljs-number">102</span>],
    [<span class="hljs-number">101</span>, <span class="hljs-number">3835</span>, <span class="hljs-number">999</span>, <span class="hljs-number">102</span>],
]`}});const Zs=[da,ha],Oe=[];function er(e,a){return e[0]==="pt"?0:1}return V=er(k),K=Oe[V]=Zs[V](k),qe=new _t({}),Pe=new F({props:{code:"output = model(model_inputs)",highlighted:"output = model(model_inputs)"}}),{c(){s=f("meta"),l=m(),C(t.$$.fragment),p=m(),E=f("h1"),$=f("a"),g=f("span"),C(T.$$.fragment),B=m(),v=f("span"),M=i("Models"),u=m(),z.c(),N=m(),x.c(),We=m(),se.c(),Re=m(),Le=f("p"),qo=i("However, if you know the type of model you want to use, you can use the class that defines its architecture directly. Let\u2019s take a look at how this works with a BERT model."),xt=m(),X=f("h2"),ae=f("a"),wt=f("span"),C(ye.$$.fragment),Po=m(),bt=f("span"),Ao=i("Creating a Transformer"),Ht=m(),Ue=f("p"),zo=i("The first thing we\u2019ll need to do to initialize a BERT model is load a configuration object:"),Wt=m(),W.c(),Ye=m(),Ge=f("p"),No=i("The configuration contains many attributes that are used to build the model:"),Rt=m(),C(ke.$$.fragment),Lt=m(),C(ge.$$.fragment),Ut=m(),S=f("p"),Do=i("While you haven\u2019t seen what all of these attributes do yet, you should recognize some of them: the "),yt=f("code"),Fo=i("hidden_size"),So=i(" attribute defines the size of the "),kt=f("code"),Oo=i("hidden_states"),Io=i(" vector, and "),gt=f("code"),xo=i("num_hidden_layers"),Ho=i(" defines the number of layers the Transformer model has."),Yt=m(),Z=f("h3"),le=f("a"),vt=f("span"),C(ve.$$.fragment),Wo=m(),$t=f("span"),Ro=i("Different loading methods"),Gt=m(),Je=f("p"),Lo=i("Creating a model from the default configuration initializes it with random values:"),Jt=m(),L.c(),Ve=m(),ie=f("p"),Uo=i("The model can be used in this state, but it will output gibberish; it needs to be trained first. We could train the model from scratch on the task at hand, but as you saw in "),Ke=f("a"),Yo=i("Chapter 1"),Go=i(", this would require a long time and a lot of data, and it would have a non-negligible environmental impact. To avoid unnecessary and duplicated effort, it\u2019s imperative to be able to share and reuse models that have already been trained."),Vt=m(),ne=f("p"),Jo=i("Loading a Transformer model that is already trained is simple \u2014 we can do this using the "),Et=f("code"),Vo=i("from_pretrained()"),Ko=i(" method:"),Kt=m(),Y.c(),Qe=m(),O=f("p"),Qo=i("In the code sample above we didn\u2019t use "),Tt=f("code"),Xo=i("BertConfig"),Zo=i(", and instead loaded a pretrained model via the "),Bt=f("code"),es=i("bert-base-cased"),ts=i(" identifier. This is a model checkpoint that was trained by the authors of BERT themselves; you can find more details about it in its "),$e=f("a"),os=i("model card"),ss=i("."),Qt=m(),Xe=f("p"),rs=i("This model is now initialized with all the weights of the checkpoint. It can be used directly for inference on the tasks it was trained on, and it can also be fine-tuned on a new task. By training with pretrained weights rather than from scratch, we can quickly achieve good results."),Xt=m(),I=f("p"),as=i("The weights have been downloaded and cached (so future calls to the "),jt=f("code"),ls=i("from_pretrained()"),is=i(" method won\u2019t re-download them) in the cache folder, which defaults to "),Mt=f("em"),ns=i("~/.cache/huggingface/transformers"),cs=i(". You can customize your cache folder by setting the "),Ct=f("code"),fs=i("HF_HOME"),hs=i(" environment variable."),Zt=m(),ce=f("p"),ds=i("The identifier used to load the model can be the identifier of any model on the Model Hub, as long as it is compatible with the BERT architecture. The entire list of available BERT checkpoints can be found "),Ee=f("a"),us=i("here"),ps=i("."),eo=m(),ee=f("h3"),fe=f("a"),qt=f("span"),C(Te.$$.fragment),ms=m(),Pt=f("span"),_s=i("Saving methods"),to=m(),Q=f("p"),ws=i("Saving a model is as easy as loading one \u2014 we use the "),At=f("code"),bs=i("save_pretrained()"),ys=i(" method, which is analogous to the "),zt=f("code"),ks=i("from_pretrained()"),gs=i(" method:"),oo=m(),C(Be.$$.fragment),so=m(),Ze=f("p"),vs=i("This saves two files to your disk:"),ro=m(),J.c(),et=m(),he=f("p"),$s=i("If you take a look at the "),Nt=f("em"),Es=i("config.json"),Ts=i(" file, you\u2019ll recognize the attributes necessary to build the model architecture. This file also contains some metadata, such as where the checkpoint originated and what \u{1F917} Transformers version you were using when you last saved the checkpoint."),ao=m(),re.c(),tt=m(),te=f("h2"),de=f("a"),Dt=f("span"),C(je.$$.fragment),Bs=m(),Ft=f("span"),js=i("Using a Transformer model for inference"),lo=m(),ot=f("p"),Ms=i("Now that you know how to load and save a model, let\u2019s try using it to make some predictions. Transformer models can only process numbers \u2014 numbers that the tokenizer generates. But before we discuss tokenizers, let\u2019s explore what inputs the model accepts."),io=m(),st=f("p"),Cs=i("Tokenizers can take care of casting the inputs to the appropriate framework\u2019s tensors, but to help you understand what\u2019s going on, we\u2019ll take a quick look at what must be done before sending the inputs to the model."),no=m(),rt=f("p"),qs=i("Let\u2019s say we have a couple of sequences:"),co=m(),C(Me.$$.fragment),fo=m(),ue=f("p"),Ps=i("The tokenizer converts these to vocabulary indices which are typically called "),St=f("em"),As=i("input IDs"),zs=i(". Each sequence is now a list of numbers! The resulting output is:"),ho=m(),C(Ce.$$.fragment),uo=m(),at=f("p"),Ns=i("This is a list of encoded sequences: a list of lists. Tensors only accept rectangular shapes (think matrices). This \u201Carray\u201D is already of rectangular shape, so converting it to a tensor is easy:"),po=m(),K.c(),lt=m(),oe=f("h3"),pe=f("a"),Ot=f("span"),C(qe.$$.fragment),Ds=m(),It=f("span"),Fs=i("Using the tensors as inputs to the model"),mo=m(),it=f("p"),Ss=i("Making use of the tensors with the model is extremely simple \u2014 we just call the model with the inputs:"),_o=m(),C(Pe.$$.fragment),wo=m(),nt=f("p"),Os=i(`While the model accepts a lot of different arguments, only the input IDs are necessary. We\u2019ll explain what the other arguments do and when they are required later,
but first we need to take a closer look at the tokenizers that build the inputs that a Transformer model can understand.`),this.h()},l(e){const a=Yr('[data-svelte="svelte-1phssyn"]',document.head);s=h(a,"META",{name:!0,content:!0}),a.forEach(o),l=_(e),q(t.$$.fragment,e),p=_(e),E=h(e,"H1",{class:!0});var Ie=d(E);$=h(Ie,"A",{id:!0,class:!0,href:!0});var ct=d($);g=h(ct,"SPAN",{});var ft=d(g);q(T.$$.fragment,ft),ft.forEach(o),ct.forEach(o),B=_(Ie),v=h(Ie,"SPAN",{});var ht=d(v);M=n(ht,"Models"),ht.forEach(o),Ie.forEach(o),u=_(e),z.l(e),N=_(e),x.l(e),We=_(e),se.l(e),Re=_(e),Le=h(e,"P",{});var dt=d(Le);qo=n(dt,"However, if you know the type of model you want to use, you can use the class that defines its architecture directly. Let\u2019s take a look at how this works with a BERT model."),dt.forEach(o),xt=_(e),X=h(e,"H2",{class:!0});var me=d(X);ae=h(me,"A",{id:!0,class:!0,href:!0});var ut=d(ae);wt=h(ut,"SPAN",{});var pt=d(wt);q(ye.$$.fragment,pt),pt.forEach(o),ut.forEach(o),Po=_(me),bt=h(me,"SPAN",{});var tr=d(bt);Ao=n(tr,"Creating a Transformer"),tr.forEach(o),me.forEach(o),Ht=_(e),Ue=h(e,"P",{});var or=d(Ue);zo=n(or,"The first thing we\u2019ll need to do to initialize a BERT model is load a configuration object:"),or.forEach(o),Wt=_(e),W.l(e),Ye=_(e),Ge=h(e,"P",{});var sr=d(Ge);No=n(sr,"The configuration contains many attributes that are used to build the model:"),sr.forEach(o),Rt=_(e),q(ke.$$.fragment,e),Lt=_(e),q(ge.$$.fragment,e),Ut=_(e),S=h(e,"P",{});var _e=d(S);Do=n(_e,"While you haven\u2019t seen what all of these attributes do yet, you should recognize some of them: the "),yt=h(_e,"CODE",{});var rr=d(yt);Fo=n(rr,"hidden_size"),rr.forEach(o),So=n(_e," attribute defines the size of the "),kt=h(_e,"CODE",{});var ar=d(kt);Oo=n(ar,"hidden_states"),ar.forEach(o),Io=n(_e," vector, and "),gt=h(_e,"CODE",{});var lr=d(gt);xo=n(lr,"num_hidden_layers"),lr.forEach(o),Ho=n(_e," defines the number of layers the Transformer model has."),_e.forEach(o),Yt=_(e),Z=h(e,"H3",{class:!0});var go=d(Z);le=h(go,"A",{id:!0,class:!0,href:!0});var ir=d(le);vt=h(ir,"SPAN",{});var nr=d(vt);q(ve.$$.fragment,nr),nr.forEach(o),ir.forEach(o),Wo=_(go),$t=h(go,"SPAN",{});var cr=d($t);Ro=n(cr,"Different loading methods"),cr.forEach(o),go.forEach(o),Gt=_(e),Je=h(e,"P",{});var fr=d(Je);Lo=n(fr,"Creating a model from the default configuration initializes it with random values:"),fr.forEach(o),Jt=_(e),L.l(e),Ve=_(e),ie=h(e,"P",{});var vo=d(ie);Uo=n(vo,"The model can be used in this state, but it will output gibberish; it needs to be trained first. We could train the model from scratch on the task at hand, but as you saw in "),Ke=h(vo,"A",{href:!0});var hr=d(Ke);Yo=n(hr,"Chapter 1"),hr.forEach(o),Go=n(vo,", this would require a long time and a lot of data, and it would have a non-negligible environmental impact. To avoid unnecessary and duplicated effort, it\u2019s imperative to be able to share and reuse models that have already been trained."),vo.forEach(o),Vt=_(e),ne=h(e,"P",{});var $o=d(ne);Jo=n($o,"Loading a Transformer model that is already trained is simple \u2014 we can do this using the "),Et=h($o,"CODE",{});var dr=d(Et);Vo=n(dr,"from_pretrained()"),dr.forEach(o),Ko=n($o," method:"),$o.forEach(o),Kt=_(e),Y.l(e),Qe=_(e),O=h(e,"P",{});var we=d(O);Qo=n(we,"In the code sample above we didn\u2019t use "),Tt=h(we,"CODE",{});var ur=d(Tt);Xo=n(ur,"BertConfig"),ur.forEach(o),Zo=n(we,", and instead loaded a pretrained model via the "),Bt=h(we,"CODE",{});var pr=d(Bt);es=n(pr,"bert-base-cased"),pr.forEach(o),ts=n(we," identifier. This is a model checkpoint that was trained by the authors of BERT themselves; you can find more details about it in its "),$e=h(we,"A",{href:!0,rel:!0});var mr=d($e);os=n(mr,"model card"),mr.forEach(o),ss=n(we,"."),we.forEach(o),Qt=_(e),Xe=h(e,"P",{});var _r=d(Xe);rs=n(_r,"This model is now initialized with all the weights of the checkpoint. It can be used directly for inference on the tasks it was trained on, and it can also be fine-tuned on a new task. By training with pretrained weights rather than from scratch, we can quickly achieve good results."),_r.forEach(o),Xt=_(e),I=h(e,"P",{});var be=d(I);as=n(be,"The weights have been downloaded and cached (so future calls to the "),jt=h(be,"CODE",{});var wr=d(jt);ls=n(wr,"from_pretrained()"),wr.forEach(o),is=n(be," method won\u2019t re-download them) in the cache folder, which defaults to "),Mt=h(be,"EM",{});var br=d(Mt);ns=n(br,"~/.cache/huggingface/transformers"),br.forEach(o),cs=n(be,". You can customize your cache folder by setting the "),Ct=h(be,"CODE",{});var yr=d(Ct);fs=n(yr,"HF_HOME"),yr.forEach(o),hs=n(be," environment variable."),be.forEach(o),Zt=_(e),ce=h(e,"P",{});var Eo=d(ce);ds=n(Eo,"The identifier used to load the model can be the identifier of any model on the Model Hub, as long as it is compatible with the BERT architecture. The entire list of available BERT checkpoints can be found "),Ee=h(Eo,"A",{href:!0,rel:!0});var kr=d(Ee);us=n(kr,"here"),kr.forEach(o),ps=n(Eo,"."),Eo.forEach(o),eo=_(e),ee=h(e,"H3",{class:!0});var To=d(ee);fe=h(To,"A",{id:!0,class:!0,href:!0});var gr=d(fe);qt=h(gr,"SPAN",{});var vr=d(qt);q(Te.$$.fragment,vr),vr.forEach(o),gr.forEach(o),ms=_(To),Pt=h(To,"SPAN",{});var $r=d(Pt);_s=n($r,"Saving methods"),$r.forEach(o),To.forEach(o),to=_(e),Q=h(e,"P",{});var mt=d(Q);ws=n(mt,"Saving a model is as easy as loading one \u2014 we use the "),At=h(mt,"CODE",{});var Er=d(At);bs=n(Er,"save_pretrained()"),Er.forEach(o),ys=n(mt," method, which is analogous to the "),zt=h(mt,"CODE",{});var Tr=d(zt);ks=n(Tr,"from_pretrained()"),Tr.forEach(o),gs=n(mt," method:"),mt.forEach(o),oo=_(e),q(Be.$$.fragment,e),so=_(e),Ze=h(e,"P",{});var Br=d(Ze);vs=n(Br,"This saves two files to your disk:"),Br.forEach(o),ro=_(e),J.l(e),et=_(e),he=h(e,"P",{});var Bo=d(he);$s=n(Bo,"If you take a look at the "),Nt=h(Bo,"EM",{});var jr=d(Nt);Es=n(jr,"config.json"),jr.forEach(o),Ts=n(Bo," file, you\u2019ll recognize the attributes necessary to build the model architecture. This file also contains some metadata, such as where the checkpoint originated and what \u{1F917} Transformers version you were using when you last saved the checkpoint."),Bo.forEach(o),ao=_(e),re.l(e),tt=_(e),te=h(e,"H2",{class:!0});var jo=d(te);de=h(jo,"A",{id:!0,class:!0,href:!0});var Mr=d(de);Dt=h(Mr,"SPAN",{});var Cr=d(Dt);q(je.$$.fragment,Cr),Cr.forEach(o),Mr.forEach(o),Bs=_(jo),Ft=h(jo,"SPAN",{});var qr=d(Ft);js=n(qr,"Using a Transformer model for inference"),qr.forEach(o),jo.forEach(o),lo=_(e),ot=h(e,"P",{});var Pr=d(ot);Ms=n(Pr,"Now that you know how to load and save a model, let\u2019s try using it to make some predictions. Transformer models can only process numbers \u2014 numbers that the tokenizer generates. But before we discuss tokenizers, let\u2019s explore what inputs the model accepts."),Pr.forEach(o),io=_(e),st=h(e,"P",{});var Ar=d(st);Cs=n(Ar,"Tokenizers can take care of casting the inputs to the appropriate framework\u2019s tensors, but to help you understand what\u2019s going on, we\u2019ll take a quick look at what must be done before sending the inputs to the model."),Ar.forEach(o),no=_(e),rt=h(e,"P",{});var zr=d(rt);qs=n(zr,"Let\u2019s say we have a couple of sequences:"),zr.forEach(o),co=_(e),q(Me.$$.fragment,e),fo=_(e),ue=h(e,"P",{});var Mo=d(ue);Ps=n(Mo,"The tokenizer converts these to vocabulary indices which are typically called "),St=h(Mo,"EM",{});var Nr=d(St);As=n(Nr,"input IDs"),Nr.forEach(o),zs=n(Mo,". Each sequence is now a list of numbers! The resulting output is:"),Mo.forEach(o),ho=_(e),q(Ce.$$.fragment,e),uo=_(e),at=h(e,"P",{});var Dr=d(at);Ns=n(Dr,"This is a list of encoded sequences: a list of lists. Tensors only accept rectangular shapes (think matrices). This \u201Carray\u201D is already of rectangular shape, so converting it to a tensor is easy:"),Dr.forEach(o),po=_(e),K.l(e),lt=_(e),oe=h(e,"H3",{class:!0});var Co=d(oe);pe=h(Co,"A",{id:!0,class:!0,href:!0});var Fr=d(pe);Ot=h(Fr,"SPAN",{});var Sr=d(Ot);q(qe.$$.fragment,Sr),Sr.forEach(o),Fr.forEach(o),Ds=_(Co),It=h(Co,"SPAN",{});var Or=d(It);Fs=n(Or,"Using the tensors as inputs to the model"),Or.forEach(o),Co.forEach(o),mo=_(e),it=h(e,"P",{});var Ir=d(it);Ss=n(Ir,"Making use of the tensors with the model is extremely simple \u2014 we just call the model with the inputs:"),Ir.forEach(o),_o=_(e),q(Pe.$$.fragment,e),wo=_(e),nt=h(e,"P",{});var xr=d(nt);Os=n(xr,`While the model accepts a lot of different arguments, only the input IDs are necessary. We\u2019ll explain what the other arguments do and when they are required later,
but first we need to take a closer look at the tokenizers that build the inputs that a Transformer model can understand.`),xr.forEach(o),this.h()},h(){j(s,"name","hf:doc:metadata"),j(s,"content",JSON.stringify(pa)),j($,"id","models"),j($,"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"),j($,"href","#models"),j(E,"class","relative group"),j(ae,"id","creating-a-transformer"),j(ae,"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"),j(ae,"href","#creating-a-transformer"),j(X,"class","relative group"),j(le,"id","different-loading-methods"),j(le,"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"),j(le,"href","#different-loading-methods"),j(Z,"class","relative group"),j(Ke,"href","/course/chapter1"),j($e,"href","https://huggingface.co/bert-base-cased"),j($e,"rel","nofollow"),j(Ee,"href","https://huggingface.co/models?filter=bert"),j(Ee,"rel","nofollow"),j(fe,"id","saving-methods"),j(fe,"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"),j(fe,"href","#saving-methods"),j(ee,"class","relative group"),j(de,"id","using-a-transformer-model-for-inference"),j(de,"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"),j(de,"href","#using-a-transformer-model-for-inference"),j(te,"class","relative group"),j(pe,"id","using-the-tensors-as-inputs-to-the-model"),j(pe,"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"),j(pe,"href","#using-the-tensors-as-inputs-to-the-model"),j(oe,"class","relative group")},m(e,a){r(document.head,s),c(e,l,a),P(t,e,a),c(e,p,a),c(e,E,a),r(E,$),r($,g),P(T,g,null),r(E,B),r(E,v),r(v,M),c(e,u,a),Ae[w].m(e,a),c(e,N,a),ze[D].m(e,a),c(e,We,a),se.m(e,a),c(e,Re,a),c(e,Le,a),r(Le,qo),c(e,xt,a),c(e,X,a),r(X,ae),r(ae,wt),P(ye,wt,null),r(X,Po),r(X,bt),r(bt,Ao),c(e,Ht,a),c(e,Ue,a),r(Ue,zo),c(e,Wt,a),Ne[H].m(e,a),c(e,Ye,a),c(e,Ge,a),r(Ge,No),c(e,Rt,a),P(ke,e,a),c(e,Lt,a),P(ge,e,a),c(e,Ut,a),c(e,S,a),r(S,Do),r(S,yt),r(yt,Fo),r(S,So),r(S,kt),r(kt,Oo),r(S,Io),r(S,gt),r(gt,xo),r(S,Ho),c(e,Yt,a),c(e,Z,a),r(Z,le),r(le,vt),P(ve,vt,null),r(Z,Wo),r(Z,$t),r($t,Ro),c(e,Gt,a),c(e,Je,a),r(Je,Lo),c(e,Jt,a),De[R].m(e,a),c(e,Ve,a),c(e,ie,a),r(ie,Uo),r(ie,Ke),r(Ke,Yo),r(ie,Go),c(e,Vt,a),c(e,ne,a),r(ne,Jo),r(ne,Et),r(Et,Vo),r(ne,Ko),c(e,Kt,a),Fe[U].m(e,a),c(e,Qe,a),c(e,O,a),r(O,Qo),r(O,Tt),r(Tt,Xo),r(O,Zo),r(O,Bt),r(Bt,es),r(O,ts),r(O,$e),r($e,os),r(O,ss),c(e,Qt,a),c(e,Xe,a),r(Xe,rs),c(e,Xt,a),c(e,I,a),r(I,as),r(I,jt),r(jt,ls),r(I,is),r(I,Mt),r(Mt,ns),r(I,cs),r(I,Ct),r(Ct,fs),r(I,hs),c(e,Zt,a),c(e,ce,a),r(ce,ds),r(ce,Ee),r(Ee,us),r(ce,ps),c(e,eo,a),c(e,ee,a),r(ee,fe),r(fe,qt),P(Te,qt,null),r(ee,ms),r(ee,Pt),r(Pt,_s),c(e,to,a),c(e,Q,a),r(Q,ws),r(Q,At),r(At,bs),r(Q,ys),r(Q,zt),r(zt,ks),r(Q,gs),c(e,oo,a),P(Be,e,a),c(e,so,a),c(e,Ze,a),r(Ze,vs),c(e,ro,a),Se[G].m(e,a),c(e,et,a),c(e,he,a),r(he,$s),r(he,Nt),r(Nt,Es),r(he,Ts),c(e,ao,a),re.m(e,a),c(e,tt,a),c(e,te,a),r(te,de),r(de,Dt),P(je,Dt,null),r(te,Bs),r(te,Ft),r(Ft,js),c(e,lo,a),c(e,ot,a),r(ot,Ms),c(e,io,a),c(e,st,a),r(st,Cs),c(e,no,a),c(e,rt,a),r(rt,qs),c(e,co,a),P(Me,e,a),c(e,fo,a),c(e,ue,a),r(ue,Ps),r(ue,St),r(St,As),r(ue,zs),c(e,ho,a),P(Ce,e,a),c(e,uo,a),c(e,at,a),r(at,Ns),c(e,po,a),Oe[V].m(e,a),c(e,lt,a),c(e,oe,a),r(oe,pe),r(pe,Ot),P(qe,Ot,null),r(oe,Ds),r(oe,It),r(It,Fs),c(e,mo,a),c(e,it,a),r(it,Ss),c(e,_o,a),P(Pe,e,a),c(e,wo,a),c(e,nt,a),r(nt,Os),bo=!0},p(e,[a]){const Ie={};a&1&&(Ie.fw=e[0]),t.$set(Ie);let ct=w;w=xs(e),w!==ct&&(He(),b(Ae[ct],1,1,()=>{Ae[ct]=null}),xe(),z=Ae[w],z||(z=Ae[w]=Is[w](e),z.c()),y(z,1),z.m(N.parentNode,N));let ft=D;D=Ws(e),D!==ft&&(He(),b(ze[ft],1,1,()=>{ze[ft]=null}),xe(),x=ze[D],x||(x=ze[D]=Hs[D](e),x.c()),y(x,1),x.m(We.parentNode,We)),yo!==(yo=Rs(e))&&(se.d(1),se=yo(e),se&&(se.c(),se.m(Re.parentNode,Re)));let ht=H;H=Us(e),H!==ht&&(He(),b(Ne[ht],1,1,()=>{Ne[ht]=null}),xe(),W=Ne[H],W||(W=Ne[H]=Ls[H](e),W.c()),y(W,1),W.m(Ye.parentNode,Ye));let dt=R;R=Gs(e),R!==dt&&(He(),b(De[dt],1,1,()=>{De[dt]=null}),xe(),L=De[R],L||(L=De[R]=Ys[R](e),L.c()),y(L,1),L.m(Ve.parentNode,Ve));let me=U;U=Vs(e),U!==me&&(He(),b(Fe[me],1,1,()=>{Fe[me]=null}),xe(),Y=Fe[U],Y||(Y=Fe[U]=Js[U](e),Y.c()),y(Y,1),Y.m(Qe.parentNode,Qe));let ut=G;G=Qs(e),G!==ut&&(He(),b(Se[ut],1,1,()=>{Se[ut]=null}),xe(),J=Se[G],J||(J=Se[G]=Ks[G](e),J.c()),y(J,1),J.m(et.parentNode,et)),ko!==(ko=Xs(e))&&(re.d(1),re=ko(e),re&&(re.c(),re.m(tt.parentNode,tt)));let pt=V;V=er(e),V!==pt&&(He(),b(Oe[pt],1,1,()=>{Oe[pt]=null}),xe(),K=Oe[V],K||(K=Oe[V]=Zs[V](e),K.c()),y(K,1),K.m(lt.parentNode,lt))},i(e){bo||(y(t.$$.fragment,e),y(T.$$.fragment,e),y(z),y(x),y(ye.$$.fragment,e),y(W),y(ke.$$.fragment,e),y(ge.$$.fragment,e),y(ve.$$.fragment,e),y(L),y(Y),y(Te.$$.fragment,e),y(Be.$$.fragment,e),y(J),y(je.$$.fragment,e),y(Me.$$.fragment,e),y(Ce.$$.fragment,e),y(K),y(qe.$$.fragment,e),y(Pe.$$.fragment,e),bo=!0)},o(e){b(t.$$.fragment,e),b(T.$$.fragment,e),b(z),b(x),b(ye.$$.fragment,e),b(W),b(ke.$$.fragment,e),b(ge.$$.fragment,e),b(ve.$$.fragment,e),b(L),b(Y),b(Te.$$.fragment,e),b(Be.$$.fragment,e),b(J),b(je.$$.fragment,e),b(Me.$$.fragment,e),b(Ce.$$.fragment,e),b(K),b(qe.$$.fragment,e),b(Pe.$$.fragment,e),bo=!1},d(e){o(s),e&&o(l),A(t,e),e&&o(p),e&&o(E),A(T),e&&o(u),Ae[w].d(e),e&&o(N),ze[D].d(e),e&&o(We),se.d(e),e&&o(Re),e&&o(Le),e&&o(xt),e&&o(X),A(ye),e&&o(Ht),e&&o(Ue),e&&o(Wt),Ne[H].d(e),e&&o(Ye),e&&o(Ge),e&&o(Rt),A(ke,e),e&&o(Lt),A(ge,e),e&&o(Ut),e&&o(S),e&&o(Yt),e&&o(Z),A(ve),e&&o(Gt),e&&o(Je),e&&o(Jt),De[R].d(e),e&&o(Ve),e&&o(ie),e&&o(Vt),e&&o(ne),e&&o(Kt),Fe[U].d(e),e&&o(Qe),e&&o(O),e&&o(Qt),e&&o(Xe),e&&o(Xt),e&&o(I),e&&o(Zt),e&&o(ce),e&&o(eo),e&&o(ee),A(Te),e&&o(to),e&&o(Q),e&&o(oo),A(Be,e),e&&o(so),e&&o(Ze),e&&o(ro),Se[G].d(e),e&&o(et),e&&o(he),e&&o(ao),re.d(e),e&&o(tt),e&&o(te),A(je),e&&o(lo),e&&o(ot),e&&o(io),e&&o(st),e&&o(no),e&&o(rt),e&&o(co),A(Me,e),e&&o(fo),e&&o(ue),e&&o(ho),A(Ce,e),e&&o(uo),e&&o(at),e&&o(po),Oe[V].d(e),e&&o(lt),e&&o(oe),A(qe),e&&o(mo),e&&o(it),e&&o(_o),A(Pe,e),e&&o(wo),e&&o(nt)}}}const pa={local:"models",sections:[{local:"creating-a-transformer",sections:[{local:"different-loading-methods",title:"Different loading methods"},{local:"saving-methods",title:"Saving methods"}],title:"Creating a Transformer"},{local:"using-a-transformer-model-for-inference",sections:[{local:"using-the-tensors-as-inputs-to-the-model",title:"Using the tensors as inputs to the model"}],title:"Using a Transformer model for inference"}],title:"Models"};function ma(k,s,l){let t="pt";return Gr(()=>{const p=new URLSearchParams(window.location.search);l(0,t=p.get("fw")||"pt")}),[t]}class va extends Rr{constructor(s){super();Lr(this,s,ma,ua,Ur,{})}}export{va as default,pa as metadata};
