import{s as yl,o as wl}from"../chunks/scheduler.37c15a92.js";import{S as _l,i as Ml,g as d,s as c,r as y,A as $l,h,f as a,c as f,j as ul,u as w,x as b,k as dl,y as gl,a as o,v as _,t as m,b as Je,d as p,w as M,p as je}from"../chunks/index.7cb9c9b8.js";import{Y as hl}from"../chunks/Youtube.8666c400.js";import{C as k}from"../chunks/CodeBlock.abae2786.js";import{C as bl}from"../chunks/CourseFloatingBanner.df82c153.js";import{F as kl}from"../chunks/FrameworkSwitchCourse.97630871.js";import{H as He,E as Tl}from"../chunks/index.706e2c58.js";function vl(u){let l,s;return l=new bl({props:{chapter:2,classNames:"absolute z-10 right-0 top-0",notebooks:[{label:"Google Colab",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/master/course/en/chapter2/section3_tf.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/en/chapter2/section3_tf.ipynb"}]}}),{c(){y(l.$$.fragment)},l(t){w(l.$$.fragment,t)},m(t,i){_(l,t,i),s=!0},i(t){s||(p(l.$$.fragment,t),s=!0)},o(t){m(l.$$.fragment,t),s=!1},d(t){M(l,t)}}}function Jl(u){let l,s;return l=new bl({props:{chapter:2,classNames:"absolute z-10 right-0 top-0",notebooks:[{label:"Google Colab",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/master/course/en/chapter2/section3_pt.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/en/chapter2/section3_pt.ipynb"}]}}),{c(){y(l.$$.fragment)},l(t){w(l.$$.fragment,t)},m(t,i){_(l,t,i),s=!0},i(t){s||(p(l.$$.fragment,t),s=!0)},o(t){m(l.$$.fragment,t),s=!1},d(t){M(l,t)}}}function jl(u){let l,s;return l=new hl({props:{id:"d3JVgghSOew"}}),{c(){y(l.$$.fragment)},l(t){w(l.$$.fragment,t)},m(t,i){_(l,t,i),s=!0},i(t){s||(p(l.$$.fragment,t),s=!0)},o(t){m(l.$$.fragment,t),s=!1},d(t){M(l,t)}}}function Cl(u){let l,s;return l=new hl({props:{id:"AhChOFRegn4"}}),{c(){y(l.$$.fragment)},l(t){w(l.$$.fragment,t)},m(t,i){_(l,t,i),s=!0},i(t){s||(p(l.$$.fragment,t),s=!0)},o(t){m(l.$$.fragment,t),s=!1},d(t){M(l,t)}}}function Wl(u){let l,s="In this section we’ll take a closer look at creating and using a model. We’ll use the <code>TFAutoModel</code> class, which is handy when you want to instantiate any model from a checkpoint.",t,i,$="The <code>TFAutoModel</code> class and all of its relatives are actually simple wrappers over the wide variety of models available in the library. It’s a clever wrapper as it can automatically guess the appropriate model architecture for your checkpoint, and then instantiates a model with this architecture.";return{c(){l=d("p"),l.innerHTML=s,t=c(),i=d("p"),i.innerHTML=$},l(r){l=h(r,"P",{"data-svelte-h":!0}),b(l)!=="svelte-1f7w3iq"&&(l.innerHTML=s),t=f(r),i=h(r,"P",{"data-svelte-h":!0}),b(i)!=="svelte-1jmx5y3"&&(i.innerHTML=$)},m(r,g){o(r,l,g),o(r,t,g),o(r,i,g)},d(r){r&&(a(l),a(t),a(i))}}}function Ul(u){let l,s="In this section we’ll take a closer look at creating and using a model. We’ll use the <code>AutoModel</code> class, which is handy when you want to instantiate any model from a checkpoint.",t,i,$="The <code>AutoModel</code> class and all of its relatives are actually simple wrappers over the wide variety of models available in the library. It’s a clever wrapper as it can automatically guess the appropriate model architecture for your checkpoint, and then instantiates a model with this architecture.";return{c(){l=d("p"),l.innerHTML=s,t=c(),i=d("p"),i.innerHTML=$},l(r){l=h(r,"P",{"data-svelte-h":!0}),b(l)!=="svelte-1gmoaxc"&&(l.innerHTML=s),t=f(r),i=h(r,"P",{"data-svelte-h":!0}),b(i)!=="svelte-g3gnjp"&&(i.innerHTML=$)},m(r,g){o(r,l,g),o(r,t,g),o(r,i,g)},d(r){r&&(a(l),a(t),a(i))}}}function Bl(u){let l,s;return l=new k({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEJlcnRDb25maWclMkMlMjBURkJlcnRNb2RlbCUwQSUwQSUyMyUyMEJ1aWxkaW5nJTIwdGhlJTIwY29uZmlnJTBBY29uZmlnJTIwJTNEJTIwQmVydENvbmZpZygpJTBBJTBBJTIzJTIwQnVpbGRpbmclMjB0aGUlMjBtb2RlbCUyMGZyb20lMjB0aGUlMjBjb25maWclMEFtb2RlbCUyMCUzRCUyMFRGQmVydE1vZGVsKGNvbmZpZyk=",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)`,wrap:!1}}),{c(){y(l.$$.fragment)},l(t){w(l.$$.fragment,t)},m(t,i){_(l,t,i),s=!0},i(t){s||(p(l.$$.fragment,t),s=!0)},o(t){m(l.$$.fragment,t),s=!1},d(t){M(l,t)}}}function Zl(u){let l,s;return l=new k({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEJlcnRDb25maWclMkMlMjBCZXJ0TW9kZWwlMEElMEElMjMlMjBCdWlsZGluZyUyMHRoZSUyMGNvbmZpZyUwQWNvbmZpZyUyMCUzRCUyMEJlcnRDb25maWcoKSUwQSUwQSUyMyUyMEJ1aWxkaW5nJTIwdGhlJTIwbW9kZWwlMjBmcm9tJTIwdGhlJTIwY29uZmlnJTBBbW9kZWwlMjAlM0QlMjBCZXJ0TW9kZWwoY29uZmlnKQ==",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)`,wrap:!1}}),{c(){y(l.$$.fragment)},l(t){w(l.$$.fragment,t)},m(t,i){_(l,t,i),s=!0},i(t){s||(p(l.$$.fragment,t),s=!0)},o(t){m(l.$$.fragment,t),s=!1},d(t){M(l,t)}}}function xl(u){let l,s;return l=new k({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEJlcnRDb25maWclMkMlMjBURkJlcnRNb2RlbCUwQSUwQWNvbmZpZyUyMCUzRCUyMEJlcnRDb25maWcoKSUwQW1vZGVsJTIwJTNEJTIwVEZCZXJ0TW9kZWwoY29uZmlnKSUwQSUwQSUyMyUyME1vZGVsJTIwaXMlMjByYW5kb21seSUyMGluaXRpYWxpemVkIQ==",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>`,wrap:!1}}),{c(){y(l.$$.fragment)},l(t){w(l.$$.fragment,t)},m(t,i){_(l,t,i),s=!0},i(t){s||(p(l.$$.fragment,t),s=!0)},o(t){m(l.$$.fragment,t),s=!1},d(t){M(l,t)}}}function Il(u){let l,s;return l=new k({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEJlcnRDb25maWclMkMlMjBCZXJ0TW9kZWwlMEElMEFjb25maWclMjAlM0QlMjBCZXJ0Q29uZmlnKCklMEFtb2RlbCUyMCUzRCUyMEJlcnRNb2RlbChjb25maWcpJTBBJTBBJTIzJTIwTW9kZWwlMjBpcyUyMHJhbmRvbWx5JTIwaW5pdGlhbGl6ZWQh",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>`,wrap:!1}}),{c(){y(l.$$.fragment)},l(t){w(l.$$.fragment,t)},m(t,i){_(l,t,i),s=!0},i(t){s||(p(l.$$.fragment,t),s=!0)},o(t){m(l.$$.fragment,t),s=!1},d(t){M(l,t)}}}function El(u){let l,s,t,i="As you saw earlier, we could replace <code>TFBertModel</code> with the equivalent <code>TFAutoModel</code> class. We’ll 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).",$;return l=new k({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGQmVydE1vZGVsJTBBJTBBbW9kZWwlMjAlM0QlMjBURkJlcnRNb2RlbC5mcm9tX3ByZXRyYWluZWQoJTIyYmVydC1iYXNlLWNhc2VkJTIyKQ==",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>)`,wrap:!1}}),{c(){y(l.$$.fragment),s=c(),t=d("p"),t.innerHTML=i},l(r){w(l.$$.fragment,r),s=f(r),t=h(r,"P",{"data-svelte-h":!0}),b(t)!=="svelte-gweb15"&&(t.innerHTML=i)},m(r,g){_(l,r,g),o(r,s,g),o(r,t,g),$=!0},i(r){$||(p(l.$$.fragment,r),$=!0)},o(r){m(l.$$.fragment,r),$=!1},d(r){r&&(a(s),a(t)),M(l,r)}}}function Rl(u){let l,s,t,i="As you saw earlier, we could replace <code>BertModel</code> with the equivalent <code>AutoModel</code> class. We’ll 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).",$;return l=new k({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEJlcnRNb2RlbCUwQSUwQW1vZGVsJTIwJTNEJTIwQmVydE1vZGVsLmZyb21fcHJldHJhaW5lZCglMjJiZXJ0LWJhc2UtY2FzZWQlMjIp",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>)`,wrap:!1}}),{c(){y(l.$$.fragment),s=c(),t=d("p"),t.innerHTML=i},l(r){w(l.$$.fragment,r),s=f(r),t=h(r,"P",{"data-svelte-h":!0}),b(t)!=="svelte-uopal9"&&(t.innerHTML=i)},m(r,g){_(l,r,g),o(r,s,g),o(r,t,g),$=!0},i(r){$||(p(l.$$.fragment,r),$=!0)},o(r){m(l.$$.fragment,r),$=!1},d(r){r&&(a(s),a(t)),M(l,r)}}}function Hl(u){let l,s;return l=new k({props:{code:"bHMlMjBkaXJlY3Rvcnlfb25fbXlfY29tcHV0ZXIlMEElMEFjb25maWcuanNvbiUyMHRmX21vZGVsLmg1",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`,wrap:!1}}),{c(){y(l.$$.fragment)},l(t){w(l.$$.fragment,t)},m(t,i){_(l,t,i),s=!0},i(t){s||(p(l.$$.fragment,t),s=!0)},o(t){m(l.$$.fragment,t),s=!1},d(t){M(l,t)}}}function Vl(u){let l,s;return l=new k({props:{code:"bHMlMjBkaXJlY3Rvcnlfb25fbXlfY29tcHV0ZXIlMEElMEFjb25maWcuanNvbiUyMHB5dG9yY2hfbW9kZWwuYmlu",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>`,wrap:!1}}),{c(){y(l.$$.fragment)},l(t){w(l.$$.fragment,t)},m(t,i){_(l,t,i),s=!0},i(t){s||(p(l.$$.fragment,t),s=!0)},o(t){m(l.$$.fragment,t),s=!1},d(t){M(l,t)}}}function Gl(u){let l,s="The <em>tf_model.h5</em> file is known as the <em>state dictionary</em>; it contains all your model’s weights. The two files go hand in hand; the configuration is necessary to know your model’s architecture, while the model weights are your model’s parameters.";return{c(){l=d("p"),l.innerHTML=s},l(t){l=h(t,"P",{"data-svelte-h":!0}),b(l)!=="svelte-phe9t5"&&(l.innerHTML=s)},m(t,i){o(t,l,i)},d(t){t&&a(l)}}}function zl(u){let l,s="The <em>pytorch_model.bin</em> file is known as the <em>state dictionary</em>; it contains all your model’s weights. The two files go hand in hand; the configuration is necessary to know your model’s architecture, while the model weights are your model’s parameters.";return{c(){l=d("p"),l.innerHTML=s},l(t){l=h(t,"P",{"data-svelte-h":!0}),b(l)!=="svelte-fa4pia"&&(l.innerHTML=s)},m(t,i){o(t,l,i)},d(t){t&&a(l)}}}function Nl(u){let l,s;return l=new k({props:{code:"aW1wb3J0JTIwdGVuc29yZmxvdyUyMGFzJTIwdGYlMEElMEFtb2RlbF9pbnB1dHMlMjAlM0QlMjB0Zi5jb25zdGFudChlbmNvZGVkX3NlcXVlbmNlcyk=",highlighted:`<span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf

model_inputs = tf.constant(encoded_sequences)`,wrap:!1}}),{c(){y(l.$$.fragment)},l(t){w(l.$$.fragment,t)},m(t,i){_(l,t,i),s=!0},i(t){s||(p(l.$$.fragment,t),s=!0)},o(t){m(l.$$.fragment,t),s=!1},d(t){M(l,t)}}}function Ll(u){let l,s;return l=new k({props:{code:"aW1wb3J0JTIwdG9yY2glMEElMEFtb2RlbF9pbnB1dHMlMjAlM0QlMjB0b3JjaC50ZW5zb3IoZW5jb2RlZF9zZXF1ZW5jZXMp",highlighted:`<span class="hljs-keyword">import</span> torch

model_inputs = torch.tensor(encoded_sequences)`,wrap:!1}}),{c(){y(l.$$.fragment)},l(t){w(l.$$.fragment,t)},m(t,i){_(l,t,i),s=!0},i(t){s||(p(l.$$.fragment,t),s=!0)},o(t){m(l.$$.fragment,t),s=!1},d(t){M(l,t)}}}function ql(u){let l,s,t,i,$,r,g,Ge,T,v,Ce,J,j,We,Ue,z,Wt="However, if you know the type of model you want to use, you can use the class that defines its architecture directly. Let’s take a look at how this works with a BERT model.",ze,N,Ne,L,Ut="The first thing we’ll need to do to initialize a BERT model is load a configuration object:",Le,C,W,Be,q,Bt="The configuration contains many attributes that are used to build the model:",qe,A,Ae,Q,Qe,F,Zt="While you haven’t seen what all of these attributes do yet, you should recognize some of them: the <code>hidden_size</code> attribute defines the size of the <code>hidden_states</code> vector, and <code>num_hidden_layers</code> defines the number of layers the Transformer model has.",Fe,Y,Ye,X,xt="Creating a model from the default configuration initializes it with random values:",Xe,U,B,Ze,P,It='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 <a href="/course/chapter1">Chapter 1</a>, 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’s imperative to be able to share and reuse models that have already been trained.',Pe,S,Et="Loading a Transformer model that is already trained is simple — we can do this using the <code>from_pretrained()</code> method:",Se,Z,x,xe,D,Rt='In the code sample above we didn’t use <code>BertConfig</code>, and instead loaded a pretrained model via the <code>bert-base-cased</code> identifier. This is a model checkpoint that was trained by the authors of BERT themselves; you can find more details about it in its <a href="https://huggingface.co/bert-base-cased" rel="nofollow">model card</a>.',De,K,Ht="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.",Ke,O,Vt="The weights have been downloaded and cached (so future calls to the <code>from_pretrained()</code> method won’t re-download them) in the cache folder, which defaults to <em>~/.cache/huggingface/transformers</em>. You can customize your cache folder by setting the <code>HF_HOME</code> environment variable.",Oe,ee,Gt='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 <a href="https://huggingface.co/models?filter=bert" rel="nofollow">here</a>.',et,te,tt,le,zt="Saving a model is as easy as loading one — we use the <code>save_pretrained()</code> method, which is analogous to the <code>from_pretrained()</code> method:",lt,ne,nt,se,Nt="This saves two files to your disk:",st,I,E,Ie,ae,Lt="If you take a look at the <em>config.json</em> file, you’ll recognize the attributes necessary to build the model architecture. This file also contains some metadata, such as where the checkpoint originated and what 🤗 Transformers version you were using when you last saved the checkpoint.",at,Ee,oe,ot,ie,qt="Now that you know how to load and save a model, let’s try using it to make some predictions. Transformer models can only process numbers — numbers that the tokenizer generates. But before we discuss tokenizers, let’s explore what inputs the model accepts.",it,re,At="Tokenizers can take care of casting the inputs to the appropriate framework’s tensors, but to help you understand what’s going on, we’ll take a quick look at what must be done before sending the inputs to the model.",rt,ce,Qt="Let’s say we have a couple of sequences:",ct,fe,ft,me,Ft="The tokenizer converts these to vocabulary indices which are typically called <em>input IDs</em>. Each sequence is now a list of numbers! The resulting output is:",mt,pe,pt,ue,Yt="This is a list of encoded sequences: a list of lists. Tensors only accept rectangular shapes (think matrices). This “array” is already of rectangular shape, so converting it to a tensor is easy:",ut,R,H,Re,de,dt,he,Xt="Making use of the tensors with the model is extremely simple — we just call the model with the inputs:",ht,be,bt,ye,Pt=`While the model accepts a lot of different arguments, only the input IDs are necessary. We’ll 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.`,yt,we,wt,Ve,_t;$=new kl({props:{fw:u[0]}}),g=new He({props:{title:"Models",local:"models",headingTag:"h1"}});const St=[Jl,vl],_e=[];function Dt(e,n){return e[0]==="pt"?0:1}T=Dt(u),v=_e[T]=St[T](u);const Kt=[Cl,jl],Me=[];function Ot(e,n){return e[0]==="pt"?0:1}J=Ot(u),j=Me[J]=Kt[J](u);function el(e,n){return e[0]==="pt"?Ul:Wl}let Mt=el(u),V=Mt(u);N=new He({props:{title:"Creating a Transformer",local:"creating-a-transformer",headingTag:"h2"}});const tl=[Zl,Bl],$e=[];function ll(e,n){return e[0]==="pt"?0:1}C=ll(u),W=$e[C]=tl[C](u),A=new k({props:{code:"cHJpbnQoY29uZmlnKQ==",highlighted:'<span class="hljs-built_in">print</span>(config)',wrap:!1}}),Q=new k({props:{code:"QmVydENvbmZpZyUyMCU3QiUwQSUyMCUyMCU1Qi4uLiU1RCUwQSUyMCUyMCUyMmhpZGRlbl9zaXplJTIyJTNBJTIwNzY4JTJDJTBBJTIwJTIwJTIyaW50ZXJtZWRpYXRlX3NpemUlMjIlM0ElMjAzMDcyJTJDJTBBJTIwJTIwJTIybWF4X3Bvc2l0aW9uX2VtYmVkZGluZ3MlMjIlM0ElMjA1MTIlMkMlMEElMjAlMjAlMjJudW1fYXR0ZW50aW9uX2hlYWRzJTIyJTNBJTIwMTIlMkMlMEElMjAlMjAlMjJudW1faGlkZGVuX2xheWVycyUyMiUzQSUyMDEyJTJDJTBBJTIwJTIwJTVCLi4uJTVEJTBBJTdE",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>,
  [...]
}`,wrap:!1}}),Y=new He({props:{title:"Different loading methods",local:"different-loading-methods",headingTag:"h3"}});const nl=[Il,xl],ge=[];function sl(e,n){return e[0]==="pt"?0:1}U=sl(u),B=ge[U]=nl[U](u);const al=[Rl,El],ke=[];function ol(e,n){return e[0]==="pt"?0:1}Z=ol(u),x=ke[Z]=al[Z](u),te=new He({props:{title:"Saving methods",local:"saving-methods",headingTag:"h3"}}),ne=new k({props:{code:"bW9kZWwuc2F2ZV9wcmV0cmFpbmVkKCUyMmRpcmVjdG9yeV9vbl9teV9jb21wdXRlciUyMik=",highlighted:'model.save_pretrained(<span class="hljs-string">&quot;directory_on_my_computer&quot;</span>)',wrap:!1}});const il=[Vl,Hl],Te=[];function rl(e,n){return e[0]==="pt"?0:1}I=rl(u),E=Te[I]=il[I](u);function cl(e,n){return e[0]==="pt"?zl:Gl}let $t=cl(u),G=$t(u);oe=new He({props:{title:"Using a Transformer model for inference",local:"using-a-transformer-model-for-inference",headingTag:"h2"}}),fe=new k({props:{code:"c2VxdWVuY2VzJTIwJTNEJTIwJTVCJTIySGVsbG8hJTIyJTJDJTIwJTIyQ29vbC4lMjIlMkMlMjAlMjJOaWNlISUyMiU1RA==",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>]',wrap:!1}}),pe=new k({props:{code:"ZW5jb2RlZF9zZXF1ZW5jZXMlMjAlM0QlMjAlNUIlMEElMjAlMjAlMjAlMjAlNUIxMDElMkMlMjA3NTkyJTJDJTIwOTk5JTJDJTIwMTAyJTVEJTJDJTBBJTIwJTIwJTIwJTIwJTVCMTAxJTJDJTIwNDY1OCUyQyUyMDEwMTIlMkMlMjAxMDIlNUQlMkMlMEElMjAlMjAlMjAlMjAlNUIxMDElMkMlMjAzODM1JTJDJTIwOTk5JTJDJTIwMTAyJTVEJTJDJTBBJTVE",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>],
]`,wrap:!1}});const fl=[Ll,Nl],ve=[];function ml(e,n){return e[0]==="pt"?0:1}return R=ml(u),H=ve[R]=fl[R](u),de=new He({props:{title:"Using the tensors as inputs to the model",local:"using-the-tensors-as-inputs-to-the-model",headingTag:"h3"}}),be=new k({props:{code:"b3V0cHV0JTIwJTNEJTIwbW9kZWwobW9kZWxfaW5wdXRzKQ==",highlighted:"output = model(model_inputs)",wrap:!1}}),we=new Tl({props:{source:"https://github.com/huggingface/course/blob/main/chapters/en/chapter2/3.mdx"}}),{c(){l=d("meta"),s=c(),t=d("p"),i=c(),y($.$$.fragment),r=c(),y(g.$$.fragment),Ge=c(),v.c(),Ce=c(),j.c(),We=c(),V.c(),Ue=c(),z=d("p"),z.textContent=Wt,ze=c(),y(N.$$.fragment),Ne=c(),L=d("p"),L.textContent=Ut,Le=c(),W.c(),Be=c(),q=d("p"),q.textContent=Bt,qe=c(),y(A.$$.fragment),Ae=c(),y(Q.$$.fragment),Qe=c(),F=d("p"),F.innerHTML=Zt,Fe=c(),y(Y.$$.fragment),Ye=c(),X=d("p"),X.textContent=xt,Xe=c(),B.c(),Ze=c(),P=d("p"),P.innerHTML=It,Pe=c(),S=d("p"),S.innerHTML=Et,Se=c(),x.c(),xe=c(),D=d("p"),D.innerHTML=Rt,De=c(),K=d("p"),K.textContent=Ht,Ke=c(),O=d("p"),O.innerHTML=Vt,Oe=c(),ee=d("p"),ee.innerHTML=Gt,et=c(),y(te.$$.fragment),tt=c(),le=d("p"),le.innerHTML=zt,lt=c(),y(ne.$$.fragment),nt=c(),se=d("p"),se.textContent=Nt,st=c(),E.c(),Ie=c(),ae=d("p"),ae.innerHTML=Lt,at=c(),G.c(),Ee=c(),y(oe.$$.fragment),ot=c(),ie=d("p"),ie.textContent=qt,it=c(),re=d("p"),re.textContent=At,rt=c(),ce=d("p"),ce.textContent=Qt,ct=c(),y(fe.$$.fragment),ft=c(),me=d("p"),me.innerHTML=Ft,mt=c(),y(pe.$$.fragment),pt=c(),ue=d("p"),ue.textContent=Yt,ut=c(),H.c(),Re=c(),y(de.$$.fragment),dt=c(),he=d("p"),he.textContent=Xt,ht=c(),y(be.$$.fragment),bt=c(),ye=d("p"),ye.textContent=Pt,yt=c(),y(we.$$.fragment),wt=c(),Ve=d("p"),this.h()},l(e){const n=$l("svelte-u9bgzb",document.head);l=h(n,"META",{name:!0,content:!0}),n.forEach(a),s=f(e),t=h(e,"P",{}),ul(t).forEach(a),i=f(e),w($.$$.fragment,e),r=f(e),w(g.$$.fragment,e),Ge=f(e),v.l(e),Ce=f(e),j.l(e),We=f(e),V.l(e),Ue=f(e),z=h(e,"P",{"data-svelte-h":!0}),b(z)!=="svelte-y76c08"&&(z.textContent=Wt),ze=f(e),w(N.$$.fragment,e),Ne=f(e),L=h(e,"P",{"data-svelte-h":!0}),b(L)!=="svelte-191c2e"&&(L.textContent=Ut),Le=f(e),W.l(e),Be=f(e),q=h(e,"P",{"data-svelte-h":!0}),b(q)!=="svelte-18mjodf"&&(q.textContent=Bt),qe=f(e),w(A.$$.fragment,e),Ae=f(e),w(Q.$$.fragment,e),Qe=f(e),F=h(e,"P",{"data-svelte-h":!0}),b(F)!=="svelte-1bluqdr"&&(F.innerHTML=Zt),Fe=f(e),w(Y.$$.fragment,e),Ye=f(e),X=h(e,"P",{"data-svelte-h":!0}),b(X)!=="svelte-zv5p9a"&&(X.textContent=xt),Xe=f(e),B.l(e),Ze=f(e),P=h(e,"P",{"data-svelte-h":!0}),b(P)!=="svelte-exuiya"&&(P.innerHTML=It),Pe=f(e),S=h(e,"P",{"data-svelte-h":!0}),b(S)!=="svelte-6s4zap"&&(S.innerHTML=Et),Se=f(e),x.l(e),xe=f(e),D=h(e,"P",{"data-svelte-h":!0}),b(D)!=="svelte-1lo0d64"&&(D.innerHTML=Rt),De=f(e),K=h(e,"P",{"data-svelte-h":!0}),b(K)!=="svelte-27fgem"&&(K.textContent=Ht),Ke=f(e),O=h(e,"P",{"data-svelte-h":!0}),b(O)!=="svelte-xgdpbx"&&(O.innerHTML=Vt),Oe=f(e),ee=h(e,"P",{"data-svelte-h":!0}),b(ee)!=="svelte-xpbcp2"&&(ee.innerHTML=Gt),et=f(e),w(te.$$.fragment,e),tt=f(e),le=h(e,"P",{"data-svelte-h":!0}),b(le)!=="svelte-v1sy0v"&&(le.innerHTML=zt),lt=f(e),w(ne.$$.fragment,e),nt=f(e),se=h(e,"P",{"data-svelte-h":!0}),b(se)!=="svelte-1ooq8p2"&&(se.textContent=Nt),st=f(e),E.l(e),Ie=f(e),ae=h(e,"P",{"data-svelte-h":!0}),b(ae)!=="svelte-2wqlmq"&&(ae.innerHTML=Lt),at=f(e),G.l(e),Ee=f(e),w(oe.$$.fragment,e),ot=f(e),ie=h(e,"P",{"data-svelte-h":!0}),b(ie)!=="svelte-6brd07"&&(ie.textContent=qt),it=f(e),re=h(e,"P",{"data-svelte-h":!0}),b(re)!=="svelte-1yge08u"&&(re.textContent=At),rt=f(e),ce=h(e,"P",{"data-svelte-h":!0}),b(ce)!=="svelte-8nofwm"&&(ce.textContent=Qt),ct=f(e),w(fe.$$.fragment,e),ft=f(e),me=h(e,"P",{"data-svelte-h":!0}),b(me)!=="svelte-1635jd"&&(me.innerHTML=Ft),mt=f(e),w(pe.$$.fragment,e),pt=f(e),ue=h(e,"P",{"data-svelte-h":!0}),b(ue)!=="svelte-y3q2fn"&&(ue.textContent=Yt),ut=f(e),H.l(e),Re=f(e),w(de.$$.fragment,e),dt=f(e),he=h(e,"P",{"data-svelte-h":!0}),b(he)!=="svelte-1et2den"&&(he.textContent=Xt),ht=f(e),w(be.$$.fragment,e),bt=f(e),ye=h(e,"P",{"data-svelte-h":!0}),b(ye)!=="svelte-1suqc52"&&(ye.textContent=Pt),yt=f(e),w(we.$$.fragment,e),wt=f(e),Ve=h(e,"P",{}),ul(Ve).forEach(a),this.h()},h(){dl(l,"name","hf:doc:metadata"),dl(l,"content",Al)},m(e,n){gl(document.head,l),o(e,s,n),o(e,t,n),o(e,i,n),_($,e,n),o(e,r,n),_(g,e,n),o(e,Ge,n),_e[T].m(e,n),o(e,Ce,n),Me[J].m(e,n),o(e,We,n),V.m(e,n),o(e,Ue,n),o(e,z,n),o(e,ze,n),_(N,e,n),o(e,Ne,n),o(e,L,n),o(e,Le,n),$e[C].m(e,n),o(e,Be,n),o(e,q,n),o(e,qe,n),_(A,e,n),o(e,Ae,n),_(Q,e,n),o(e,Qe,n),o(e,F,n),o(e,Fe,n),_(Y,e,n),o(e,Ye,n),o(e,X,n),o(e,Xe,n),ge[U].m(e,n),o(e,Ze,n),o(e,P,n),o(e,Pe,n),o(e,S,n),o(e,Se,n),ke[Z].m(e,n),o(e,xe,n),o(e,D,n),o(e,De,n),o(e,K,n),o(e,Ke,n),o(e,O,n),o(e,Oe,n),o(e,ee,n),o(e,et,n),_(te,e,n),o(e,tt,n),o(e,le,n),o(e,lt,n),_(ne,e,n),o(e,nt,n),o(e,se,n),o(e,st,n),Te[I].m(e,n),o(e,Ie,n),o(e,ae,n),o(e,at,n),G.m(e,n),o(e,Ee,n),_(oe,e,n),o(e,ot,n),o(e,ie,n),o(e,it,n),o(e,re,n),o(e,rt,n),o(e,ce,n),o(e,ct,n),_(fe,e,n),o(e,ft,n),o(e,me,n),o(e,mt,n),_(pe,e,n),o(e,pt,n),o(e,ue,n),o(e,ut,n),ve[R].m(e,n),o(e,Re,n),_(de,e,n),o(e,dt,n),o(e,he,n),o(e,ht,n),_(be,e,n),o(e,bt,n),o(e,ye,n),o(e,yt,n),_(we,e,n),o(e,wt,n),o(e,Ve,n),_t=!0},p(e,[n]){const pl={};n&1&&(pl.fw=e[0]),$.$set(pl);let gt=T;T=Dt(e),T!==gt&&(je(),m(_e[gt],1,1,()=>{_e[gt]=null}),Je(),v=_e[T],v||(v=_e[T]=St[T](e),v.c()),p(v,1),v.m(Ce.parentNode,Ce));let kt=J;J=Ot(e),J!==kt&&(je(),m(Me[kt],1,1,()=>{Me[kt]=null}),Je(),j=Me[J],j||(j=Me[J]=Kt[J](e),j.c()),p(j,1),j.m(We.parentNode,We)),Mt!==(Mt=el(e))&&(V.d(1),V=Mt(e),V&&(V.c(),V.m(Ue.parentNode,Ue)));let Tt=C;C=ll(e),C!==Tt&&(je(),m($e[Tt],1,1,()=>{$e[Tt]=null}),Je(),W=$e[C],W||(W=$e[C]=tl[C](e),W.c()),p(W,1),W.m(Be.parentNode,Be));let vt=U;U=sl(e),U!==vt&&(je(),m(ge[vt],1,1,()=>{ge[vt]=null}),Je(),B=ge[U],B||(B=ge[U]=nl[U](e),B.c()),p(B,1),B.m(Ze.parentNode,Ze));let Jt=Z;Z=ol(e),Z!==Jt&&(je(),m(ke[Jt],1,1,()=>{ke[Jt]=null}),Je(),x=ke[Z],x||(x=ke[Z]=al[Z](e),x.c()),p(x,1),x.m(xe.parentNode,xe));let jt=I;I=rl(e),I!==jt&&(je(),m(Te[jt],1,1,()=>{Te[jt]=null}),Je(),E=Te[I],E||(E=Te[I]=il[I](e),E.c()),p(E,1),E.m(Ie.parentNode,Ie)),$t!==($t=cl(e))&&(G.d(1),G=$t(e),G&&(G.c(),G.m(Ee.parentNode,Ee)));let Ct=R;R=ml(e),R!==Ct&&(je(),m(ve[Ct],1,1,()=>{ve[Ct]=null}),Je(),H=ve[R],H||(H=ve[R]=fl[R](e),H.c()),p(H,1),H.m(Re.parentNode,Re))},i(e){_t||(p($.$$.fragment,e),p(g.$$.fragment,e),p(v),p(j),p(N.$$.fragment,e),p(W),p(A.$$.fragment,e),p(Q.$$.fragment,e),p(Y.$$.fragment,e),p(B),p(x),p(te.$$.fragment,e),p(ne.$$.fragment,e),p(E),p(oe.$$.fragment,e),p(fe.$$.fragment,e),p(pe.$$.fragment,e),p(H),p(de.$$.fragment,e),p(be.$$.fragment,e),p(we.$$.fragment,e),_t=!0)},o(e){m($.$$.fragment,e),m(g.$$.fragment,e),m(v),m(j),m(N.$$.fragment,e),m(W),m(A.$$.fragment,e),m(Q.$$.fragment,e),m(Y.$$.fragment,e),m(B),m(x),m(te.$$.fragment,e),m(ne.$$.fragment,e),m(E),m(oe.$$.fragment,e),m(fe.$$.fragment,e),m(pe.$$.fragment,e),m(H),m(de.$$.fragment,e),m(be.$$.fragment,e),m(we.$$.fragment,e),_t=!1},d(e){e&&(a(s),a(t),a(i),a(r),a(Ge),a(Ce),a(We),a(Ue),a(z),a(ze),a(Ne),a(L),a(Le),a(Be),a(q),a(qe),a(Ae),a(Qe),a(F),a(Fe),a(Ye),a(X),a(Xe),a(Ze),a(P),a(Pe),a(S),a(Se),a(xe),a(D),a(De),a(K),a(Ke),a(O),a(Oe),a(ee),a(et),a(tt),a(le),a(lt),a(nt),a(se),a(st),a(Ie),a(ae),a(at),a(Ee),a(ot),a(ie),a(it),a(re),a(rt),a(ce),a(ct),a(ft),a(me),a(mt),a(pt),a(ue),a(ut),a(Re),a(dt),a(he),a(ht),a(bt),a(ye),a(yt),a(wt),a(Ve)),a(l),M($,e),M(g,e),_e[T].d(e),Me[J].d(e),V.d(e),M(N,e),$e[C].d(e),M(A,e),M(Q,e),M(Y,e),ge[U].d(e),ke[Z].d(e),M(te,e),M(ne,e),Te[I].d(e),G.d(e),M(oe,e),M(fe,e),M(pe,e),ve[R].d(e),M(de,e),M(be,e),M(we,e)}}}const Al='{"title":"Models","local":"models","sections":[{"title":"Creating a Transformer","local":"creating-a-transformer","sections":[{"title":"Different loading methods","local":"different-loading-methods","sections":[],"depth":3},{"title":"Saving methods","local":"saving-methods","sections":[],"depth":3}],"depth":2},{"title":"Using a Transformer model for inference","local":"using-a-transformer-model-for-inference","sections":[{"title":"Using the tensors as inputs to the model","local":"using-the-tensors-as-inputs-to-the-model","sections":[],"depth":3}],"depth":2}],"depth":1}';function Ql(u,l,s){let t="pt";return wl(()=>{const i=new URLSearchParams(window.location.search);s(0,t=i.get("fw")||"pt")}),[t]}class Ol extends _l{constructor(l){super(),Ml(this,l,Ql,ql,yl,{})}}export{Ol as component};
