import{S as un,i as mn,s as dn,e as n,k as d,w as T,t as a,M as _n,c as r,d as t,m as _,a as o,x as A,h as l,b as m,G as e,g as f,y as z,q as x,o as q,B as C,v as gn,L as qa}from"../../chunks/vendor-hf-doc-builder.js";import{T as xa}from"../../chunks/Tip-hf-doc-builder.js";import{I as Rt}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{C as V}from"../../chunks/CodeBlock-hf-doc-builder.js";import{F as ml,M as Ot}from"../../chunks/Markdown-hf-doc-builder.js";function $n(Y){let i,c,p,g,w,y,P,M,v,D,B,N,I,H,W,Z,S,R,k,F,X,j,O,G,ge,Q,le,Ie,xe,fe,$e,qe,U,Oe,se,ve,Le,ue,K,je,re,be,oe,we,te,me,pe,J,b,L,ae,ee,ke,Ce,Pe,Ee,ie,Te,Ae,de,_e,Me,ne,He,Ne,ye,cs,ls,ce,he,Qe,Fe,hs,Ve,h,E,We,De,fs,us,ze,ns,ms,Ge,ds,Be,Ue,_s,rs,Je,Se,Re,Ye,Ze,gs,os,Ys,Es,ts,Ks,Ts,es,As;return{c(){i=a(`The task illustrated in this tutorial is supported by the following model architectures:

`),c=n("p"),p=n("a"),g=a("ALBERT"),w=a(", "),y=n("a"),P=a("BERT"),M=a(", "),v=n("a"),D=a("BigBird"),B=a(", "),N=n("a"),I=a("CamemBERT"),H=a(", "),W=n("a"),Z=a("CANINE"),S=a(", "),R=n("a"),k=a("ConvBERT"),F=a(", "),X=n("a"),j=a("Data2VecText"),O=a(", "),G=n("a"),ge=a("DeBERTa-v2"),Q=a(", "),le=n("a"),Ie=a("DistilBERT"),xe=a(", "),fe=n("a"),$e=a("ELECTRA"),qe=a(", "),U=n("a"),Oe=a("ERNIE"),se=a(", "),ve=n("a"),Le=a("FlauBERT"),ue=a(", "),K=n("a"),je=a("FNet"),re=a(", "),be=n("a"),oe=a("Funnel Transformer"),we=a(", "),te=n("a"),me=a("I-BERT"),pe=a(", "),J=n("a"),b=a("Longformer"),L=a(", "),ae=n("a"),ee=a("LUKE"),ke=a(", "),Ce=n("a"),Pe=a("Megatron-BERT"),Ee=a(", "),ie=n("a"),Te=a("MobileBERT"),Ae=a(", "),de=n("a"),_e=a("MPNet"),Me=a(", "),ne=n("a"),He=a("Nezha"),Ne=a(", "),ye=n("a"),cs=a("Nystr\xF6mformer"),ls=a(", "),ce=n("a"),he=a("QDQBert"),Qe=a(", "),Fe=n("a"),hs=a("RemBERT"),Ve=a(", "),h=n("a"),E=a("RoBERTa"),We=a(", "),De=n("a"),fs=a("RoBERTa-PreLayerNorm"),us=a(", "),ze=n("a"),ns=a("RoCBert"),ms=a(", "),Ge=n("a"),ds=a("RoFormer"),Be=a(", "),Ue=n("a"),_s=a("SqueezeBERT"),rs=a(", "),Je=n("a"),Se=a("XLM"),Re=a(", "),Ye=n("a"),Ze=a("XLM-RoBERTa"),gs=a(", "),os=n("a"),Ys=a("XLM-RoBERTa-XL"),Es=a(", "),ts=n("a"),Ks=a("XLNet"),Ts=a(", "),es=n("a"),As=a("YOSO"),this.h()},l(Ke){i=l(Ke,`The task illustrated in this tutorial is supported by the following model architectures:

`),c=r(Ke,"P",{});var $=o(c);p=r($,"A",{href:!0});var Xs=o(p);g=l(Xs,"ALBERT"),Xs.forEach(t),w=l($,", "),y=r($,"A",{href:!0});var as=o(y);P=l(as,"BERT"),as.forEach(t),M=l($,", "),v=r($,"A",{href:!0});var ps=o(v);D=l(ps,"BigBird"),ps.forEach(t),B=l($,", "),N=r($,"A",{href:!0});var ft=o(N);I=l(ft,"CamemBERT"),ft.forEach(t),H=l($,", "),W=r($,"A",{href:!0});var zs=o(W);Z=l(zs,"CANINE"),zs.forEach(t),S=l($,", "),R=r($,"A",{href:!0});var ut=o(R);k=l(ut,"ConvBERT"),ut.forEach(t),F=l($,", "),X=r($,"A",{href:!0});var mt=o(X);j=l(mt,"Data2VecText"),mt.forEach(t),O=l($,", "),G=r($,"A",{href:!0});var xs=o(G);ge=l(xs,"DeBERTa-v2"),xs.forEach(t),Q=l($,", "),le=r($,"A",{href:!0});var dt=o(le);Ie=l(dt,"DistilBERT"),dt.forEach(t),xe=l($,", "),fe=r($,"A",{href:!0});var _t=o(fe);$e=l(_t,"ELECTRA"),_t.forEach(t),qe=l($,", "),U=r($,"A",{href:!0});var gt=o(U);Oe=l(gt,"ERNIE"),gt.forEach(t),se=l($,", "),ve=r($,"A",{href:!0});var $s=o(ve);Le=l($s,"FlauBERT"),$s.forEach(t),ue=l($,", "),K=r($,"A",{href:!0});var $t=o(K);je=l($t,"FNet"),$t.forEach(t),re=l($,", "),be=r($,"A",{href:!0});var qs=o(be);oe=l(qs,"Funnel Transformer"),qs.forEach(t),we=l($,", "),te=r($,"A",{href:!0});var jt=o(te);me=l(jt,"I-BERT"),jt.forEach(t),pe=l($,", "),J=r($,"A",{href:!0});var bt=o(J);b=l(bt,"Longformer"),bt.forEach(t),L=l($,", "),ae=r($,"A",{href:!0});var wt=o(ae);ee=l(wt,"LUKE"),wt.forEach(t),ke=l($,", "),Ce=r($,"A",{href:!0});var ss=o(Ce);Pe=l(ss,"Megatron-BERT"),ss.forEach(t),Ee=l($,", "),ie=r($,"A",{href:!0});var kt=o(ie);Te=l(kt,"MobileBERT"),kt.forEach(t),Ae=l($,", "),de=r($,"A",{href:!0});var Cs=o(de);_e=l(Cs,"MPNet"),Cs.forEach(t),Me=l($,", "),ne=r($,"A",{href:!0});var yt=o(ne);He=l(yt,"Nezha"),yt.forEach(t),Ne=l($,", "),ye=r($,"A",{href:!0});var vt=o(ye);cs=l(vt,"Nystr\xF6mformer"),vt.forEach(t),ls=l($,", "),ce=r($,"A",{href:!0});var Ps=o(ce);he=l(Ps,"QDQBert"),Ps.forEach(t),Qe=l($,", "),Fe=r($,"A",{href:!0});var Et=o(Fe);hs=l(Et,"RemBERT"),Et.forEach(t),Ve=l($,", "),h=r($,"A",{href:!0});var Tt=o(h);E=l(Tt,"RoBERTa"),Tt.forEach(t),We=l($,", "),De=r($,"A",{href:!0});var Ms=o(De);fs=l(Ms,"RoBERTa-PreLayerNorm"),Ms.forEach(t),us=l($,", "),ze=r($,"A",{href:!0});var At=o(ze);ns=l(At,"RoCBert"),At.forEach(t),ms=l($,", "),Ge=r($,"A",{href:!0});var zt=o(Ge);ds=l(zt,"RoFormer"),zt.forEach(t),Be=l($,", "),Ue=r($,"A",{href:!0});var Qs=o(Ue);_s=l(Qs,"SqueezeBERT"),Qs.forEach(t),rs=l($,", "),Je=r($,"A",{href:!0});var js=o(Je);Se=l(js,"XLM"),js.forEach(t),Re=l($,", "),Ye=r($,"A",{href:!0});var Vs=o(Ye);Ze=l(Vs,"XLM-RoBERTa"),Vs.forEach(t),gs=l($,", "),os=r($,"A",{href:!0});var Xe=o(os);Ys=l(Xe,"XLM-RoBERTa-XL"),Xe.forEach(t),Es=l($,", "),ts=r($,"A",{href:!0});var xt=o(ts);Ks=l(xt,"XLNet"),xt.forEach(t),Ts=l($,", "),es=r($,"A",{href:!0});var bs=o(es);As=l(bs,"YOSO"),bs.forEach(t),$.forEach(t),this.h()},h(){m(p,"href","../model_doc/albert"),m(y,"href","../model_doc/bert"),m(v,"href","../model_doc/big_bird"),m(N,"href","../model_doc/camembert"),m(W,"href","../model_doc/canine"),m(R,"href","../model_doc/convbert"),m(X,"href","../model_doc/data2vec-text"),m(G,"href","../model_doc/deberta-v2"),m(le,"href","../model_doc/distilbert"),m(fe,"href","../model_doc/electra"),m(U,"href","../model_doc/ernie"),m(ve,"href","../model_doc/flaubert"),m(K,"href","../model_doc/fnet"),m(be,"href","../model_doc/funnel"),m(te,"href","../model_doc/ibert"),m(J,"href","../model_doc/longformer"),m(ae,"href","../model_doc/luke"),m(Ce,"href","../model_doc/megatron-bert"),m(ie,"href","../model_doc/mobilebert"),m(de,"href","../model_doc/mpnet"),m(ne,"href","../model_doc/nezha"),m(ye,"href","../model_doc/nystromformer"),m(ce,"href","../model_doc/qdqbert"),m(Fe,"href","../model_doc/rembert"),m(h,"href","../model_doc/roberta"),m(De,"href","../model_doc/roberta-prelayernorm"),m(ze,"href","../model_doc/roc_bert"),m(Ge,"href","../model_doc/roformer"),m(Ue,"href","../model_doc/squeezebert"),m(Je,"href","../model_doc/xlm"),m(Ye,"href","../model_doc/xlm-roberta"),m(os,"href","../model_doc/xlm-roberta-xl"),m(ts,"href","../model_doc/xlnet"),m(es,"href","../model_doc/yoso")},m(Ke,$){f(Ke,i,$),f(Ke,c,$),e(c,p),e(p,g),e(c,w),e(c,y),e(y,P),e(c,M),e(c,v),e(v,D),e(c,B),e(c,N),e(N,I),e(c,H),e(c,W),e(W,Z),e(c,S),e(c,R),e(R,k),e(c,F),e(c,X),e(X,j),e(c,O),e(c,G),e(G,ge),e(c,Q),e(c,le),e(le,Ie),e(c,xe),e(c,fe),e(fe,$e),e(c,qe),e(c,U),e(U,Oe),e(c,se),e(c,ve),e(ve,Le),e(c,ue),e(c,K),e(K,je),e(c,re),e(c,be),e(be,oe),e(c,we),e(c,te),e(te,me),e(c,pe),e(c,J),e(J,b),e(c,L),e(c,ae),e(ae,ee),e(c,ke),e(c,Ce),e(Ce,Pe),e(c,Ee),e(c,ie),e(ie,Te),e(c,Ae),e(c,de),e(de,_e),e(c,Me),e(c,ne),e(ne,He),e(c,Ne),e(c,ye),e(ye,cs),e(c,ls),e(c,ce),e(ce,he),e(c,Qe),e(c,Fe),e(Fe,hs),e(c,Ve),e(c,h),e(h,E),e(c,We),e(c,De),e(De,fs),e(c,us),e(c,ze),e(ze,ns),e(c,ms),e(c,Ge),e(Ge,ds),e(c,Be),e(c,Ue),e(Ue,_s),e(c,rs),e(c,Je),e(Je,Se),e(c,Re),e(c,Ye),e(Ye,Ze),e(c,gs),e(c,os),e(os,Ys),e(c,Es),e(c,ts),e(ts,Ks),e(c,Ts),e(c,es),e(es,As)},d(Ke){Ke&&t(i),Ke&&t(c)}}}function jn(Y){let i,c;return i=new V({props:{code:`from dataclasses import dataclass
from transformers.tokenization_utils_base import PreTrainedTokenizerBase, PaddingStrategy
from typing import Optional, Union
import torch


@dataclass
class DataCollatorForMultipleChoice:
    """
    Data collator that will dynamically pad the inputs for multiple choice received.
    """

    tokenizer: PreTrainedTokenizerBase
    padding: Union[bool, str, PaddingStrategy] = True
    max_length: Optional[int] = None
    pad_to_multiple_of: Optional[int] = None

    def __call__(self, features):
        label_name = "label" if "label" in features[0].keys() else "labels"
        labels = [feature.pop(label_name) for feature in features]
        batch_size = len(features)
        num_choices = len(features[0]["input_ids"])
        flattened_features = [
            [{k: v[i] for k, v in feature.items()} for i in range(num_choices)] for feature in features
        ]
        flattened_features = sum(flattened_features, [])

        batch = self.tokenizer.pad(
            flattened_features,
            padding=self.padding,
            max_length=self.max_length,
            pad_to_multiple_of=self.pad_to_multiple_of,
            return_tensors="pt",
        )

        batch = {k: v.view(batch_size, num_choices, -1) for k, v in batch.items()}
        batch["labels"] = torch.tensor(labels, dtype=torch.int64)
        return batch`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> dataclasses <span class="hljs-keyword">import</span> dataclass
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers.tokenization_utils_base <span class="hljs-keyword">import</span> PreTrainedTokenizerBase, PaddingStrategy
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> typing <span class="hljs-keyword">import</span> <span class="hljs-type">Optional</span>, <span class="hljs-type">Union</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch


<span class="hljs-meta">&gt;&gt;&gt; </span>@dataclass
<span class="hljs-meta">... </span><span class="hljs-keyword">class</span> <span class="hljs-title class_">DataCollatorForMultipleChoice</span>:
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;&quot;&quot;
<span class="hljs-meta">... </span>    Data collator that will dynamically pad the inputs for multiple choice received.
<span class="hljs-meta">... </span>    &quot;&quot;&quot;</span>

<span class="hljs-meta">... </span>    tokenizer: PreTrainedTokenizerBase
<span class="hljs-meta">... </span>    padding: <span class="hljs-type">Union</span>[<span class="hljs-built_in">bool</span>, <span class="hljs-built_in">str</span>, PaddingStrategy] = <span class="hljs-literal">True</span>
<span class="hljs-meta">... </span>    max_length: <span class="hljs-type">Optional</span>[<span class="hljs-built_in">int</span>] = <span class="hljs-literal">None</span>
<span class="hljs-meta">... </span>    pad_to_multiple_of: <span class="hljs-type">Optional</span>[<span class="hljs-built_in">int</span>] = <span class="hljs-literal">None</span>

<span class="hljs-meta">... </span>    <span class="hljs-keyword">def</span> <span class="hljs-title function_">__call__</span>(<span class="hljs-params">self, features</span>):
<span class="hljs-meta">... </span>        label_name = <span class="hljs-string">&quot;label&quot;</span> <span class="hljs-keyword">if</span> <span class="hljs-string">&quot;label&quot;</span> <span class="hljs-keyword">in</span> features[<span class="hljs-number">0</span>].keys() <span class="hljs-keyword">else</span> <span class="hljs-string">&quot;labels&quot;</span>
<span class="hljs-meta">... </span>        labels = [feature.pop(label_name) <span class="hljs-keyword">for</span> feature <span class="hljs-keyword">in</span> features]
<span class="hljs-meta">... </span>        batch_size = <span class="hljs-built_in">len</span>(features)
<span class="hljs-meta">... </span>        num_choices = <span class="hljs-built_in">len</span>(features[<span class="hljs-number">0</span>][<span class="hljs-string">&quot;input_ids&quot;</span>])
<span class="hljs-meta">... </span>        flattened_features = [
<span class="hljs-meta">... </span>            [{k: v[i] <span class="hljs-keyword">for</span> k, v <span class="hljs-keyword">in</span> feature.items()} <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(num_choices)] <span class="hljs-keyword">for</span> feature <span class="hljs-keyword">in</span> features
<span class="hljs-meta">... </span>        ]
<span class="hljs-meta">... </span>        flattened_features = <span class="hljs-built_in">sum</span>(flattened_features, [])

<span class="hljs-meta">... </span>        batch = self.tokenizer.pad(
<span class="hljs-meta">... </span>            flattened_features,
<span class="hljs-meta">... </span>            padding=self.padding,
<span class="hljs-meta">... </span>            max_length=self.max_length,
<span class="hljs-meta">... </span>            pad_to_multiple_of=self.pad_to_multiple_of,
<span class="hljs-meta">... </span>            return_tensors=<span class="hljs-string">&quot;pt&quot;</span>,
<span class="hljs-meta">... </span>        )

<span class="hljs-meta">... </span>        batch = {k: v.view(batch_size, num_choices, -<span class="hljs-number">1</span>) <span class="hljs-keyword">for</span> k, v <span class="hljs-keyword">in</span> batch.items()}
<span class="hljs-meta">... </span>        batch[<span class="hljs-string">&quot;labels&quot;</span>] = torch.tensor(labels, dtype=torch.int64)
<span class="hljs-meta">... </span>        <span class="hljs-keyword">return</span> batch`}}),{c(){T(i.$$.fragment)},l(p){A(i.$$.fragment,p)},m(p,g){z(i,p,g),c=!0},p:qa,i(p){c||(x(i.$$.fragment,p),c=!0)},o(p){q(i.$$.fragment,p),c=!1},d(p){C(i,p)}}}function bn(Y){let i,c;return i=new Ot({props:{$$slots:{default:[jn]},$$scope:{ctx:Y}}}),{c(){T(i.$$.fragment)},l(p){A(i.$$.fragment,p)},m(p,g){z(i,p,g),c=!0},p(p,g){const w={};g&2&&(w.$$scope={dirty:g,ctx:p}),i.$set(w)},i(p){c||(x(i.$$.fragment,p),c=!0)},o(p){q(i.$$.fragment,p),c=!1},d(p){C(i,p)}}}function wn(Y){let i,c;return i=new V({props:{code:`from dataclasses import dataclass
from transformers.tokenization_utils_base import PreTrainedTokenizerBase, PaddingStrategy
from typing import Optional, Union
import tensorflow as tf


@dataclass
class DataCollatorForMultipleChoice:
    """
    Data collator that will dynamically pad the inputs for multiple choice received.
    """

    tokenizer: PreTrainedTokenizerBase
    padding: Union[bool, str, PaddingStrategy] = True
    max_length: Optional[int] = None
    pad_to_multiple_of: Optional[int] = None

    def __call__(self, features):
        label_name = "label" if "label" in features[0].keys() else "labels"
        labels = [feature.pop(label_name) for feature in features]
        batch_size = len(features)
        num_choices = len(features[0]["input_ids"])
        flattened_features = [
            [{k: v[i] for k, v in feature.items()} for i in range(num_choices)] for feature in features
        ]
        flattened_features = sum(flattened_features, [])

        batch = self.tokenizer.pad(
            flattened_features,
            padding=self.padding,
            max_length=self.max_length,
            pad_to_multiple_of=self.pad_to_multiple_of,
            return_tensors="tf",
        )

        batch = {k: tf.reshape(v, (batch_size, num_choices, -1)) for k, v in batch.items()}
        batch["labels"] = tf.convert_to_tensor(labels, dtype=tf.int64)
        return batch`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> dataclasses <span class="hljs-keyword">import</span> dataclass
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers.tokenization_utils_base <span class="hljs-keyword">import</span> PreTrainedTokenizerBase, PaddingStrategy
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> typing <span class="hljs-keyword">import</span> <span class="hljs-type">Optional</span>, <span class="hljs-type">Union</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf


<span class="hljs-meta">&gt;&gt;&gt; </span>@dataclass
<span class="hljs-meta">... </span><span class="hljs-keyword">class</span> <span class="hljs-title class_">DataCollatorForMultipleChoice</span>:
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;&quot;&quot;
<span class="hljs-meta">... </span>    Data collator that will dynamically pad the inputs for multiple choice received.
<span class="hljs-meta">... </span>    &quot;&quot;&quot;</span>

<span class="hljs-meta">... </span>    tokenizer: PreTrainedTokenizerBase
<span class="hljs-meta">... </span>    padding: <span class="hljs-type">Union</span>[<span class="hljs-built_in">bool</span>, <span class="hljs-built_in">str</span>, PaddingStrategy] = <span class="hljs-literal">True</span>
<span class="hljs-meta">... </span>    max_length: <span class="hljs-type">Optional</span>[<span class="hljs-built_in">int</span>] = <span class="hljs-literal">None</span>
<span class="hljs-meta">... </span>    pad_to_multiple_of: <span class="hljs-type">Optional</span>[<span class="hljs-built_in">int</span>] = <span class="hljs-literal">None</span>

<span class="hljs-meta">... </span>    <span class="hljs-keyword">def</span> <span class="hljs-title function_">__call__</span>(<span class="hljs-params">self, features</span>):
<span class="hljs-meta">... </span>        label_name = <span class="hljs-string">&quot;label&quot;</span> <span class="hljs-keyword">if</span> <span class="hljs-string">&quot;label&quot;</span> <span class="hljs-keyword">in</span> features[<span class="hljs-number">0</span>].keys() <span class="hljs-keyword">else</span> <span class="hljs-string">&quot;labels&quot;</span>
<span class="hljs-meta">... </span>        labels = [feature.pop(label_name) <span class="hljs-keyword">for</span> feature <span class="hljs-keyword">in</span> features]
<span class="hljs-meta">... </span>        batch_size = <span class="hljs-built_in">len</span>(features)
<span class="hljs-meta">... </span>        num_choices = <span class="hljs-built_in">len</span>(features[<span class="hljs-number">0</span>][<span class="hljs-string">&quot;input_ids&quot;</span>])
<span class="hljs-meta">... </span>        flattened_features = [
<span class="hljs-meta">... </span>            [{k: v[i] <span class="hljs-keyword">for</span> k, v <span class="hljs-keyword">in</span> feature.items()} <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(num_choices)] <span class="hljs-keyword">for</span> feature <span class="hljs-keyword">in</span> features
<span class="hljs-meta">... </span>        ]
<span class="hljs-meta">... </span>        flattened_features = <span class="hljs-built_in">sum</span>(flattened_features, [])

<span class="hljs-meta">... </span>        batch = self.tokenizer.pad(
<span class="hljs-meta">... </span>            flattened_features,
<span class="hljs-meta">... </span>            padding=self.padding,
<span class="hljs-meta">... </span>            max_length=self.max_length,
<span class="hljs-meta">... </span>            pad_to_multiple_of=self.pad_to_multiple_of,
<span class="hljs-meta">... </span>            return_tensors=<span class="hljs-string">&quot;tf&quot;</span>,
<span class="hljs-meta">... </span>        )

<span class="hljs-meta">... </span>        batch = {k: tf.reshape(v, (batch_size, num_choices, -<span class="hljs-number">1</span>)) <span class="hljs-keyword">for</span> k, v <span class="hljs-keyword">in</span> batch.items()}
<span class="hljs-meta">... </span>        batch[<span class="hljs-string">&quot;labels&quot;</span>] = tf.convert_to_tensor(labels, dtype=tf.int64)
<span class="hljs-meta">... </span>        <span class="hljs-keyword">return</span> batch`}}),{c(){T(i.$$.fragment)},l(p){A(i.$$.fragment,p)},m(p,g){z(i,p,g),c=!0},p:qa,i(p){c||(x(i.$$.fragment,p),c=!0)},o(p){q(i.$$.fragment,p),c=!1},d(p){C(i,p)}}}function kn(Y){let i,c;return i=new Ot({props:{$$slots:{default:[wn]},$$scope:{ctx:Y}}}),{c(){T(i.$$.fragment)},l(p){A(i.$$.fragment,p)},m(p,g){z(i,p,g),c=!0},p(p,g){const w={};g&2&&(w.$$scope={dirty:g,ctx:p}),i.$set(w)},i(p){c||(x(i.$$.fragment,p),c=!0)},o(p){q(i.$$.fragment,p),c=!1},d(p){C(i,p)}}}function yn(Y){let i,c,p,g,w,y,P,M;return{c(){i=n("p"),c=a("If you aren\u2019t familiar with finetuning a model with the "),p=n("a"),g=a("Trainer"),w=a(", take a look at the basic tutorial "),y=n("a"),P=a("here"),M=a("!"),this.h()},l(v){i=r(v,"P",{});var D=o(i);c=l(D,"If you aren\u2019t familiar with finetuning a model with the "),p=r(D,"A",{href:!0});var B=o(p);g=l(B,"Trainer"),B.forEach(t),w=l(D,", take a look at the basic tutorial "),y=r(D,"A",{href:!0});var N=o(y);P=l(N,"here"),N.forEach(t),M=l(D,"!"),D.forEach(t),this.h()},h(){m(p,"href","/docs/transformers/main/en/main_classes/trainer#transformers.Trainer"),m(y,"href","../training#train-with-pytorch-trainer")},m(v,D){f(v,i,D),e(i,c),e(i,p),e(p,g),e(i,w),e(i,y),e(y,P),e(i,M)},d(v){v&&t(i)}}}function vn(Y){let i,c,p,g,w,y,P,M,v,D,B,N,I,H,W,Z,S,R,k,F,X,j,O,G,ge,Q,le,Ie,xe,fe,$e,qe,U,Oe,se,ve,Le,ue,K,je,re,be,oe,we,te,me,pe,J;return i=new xa({props:{$$slots:{default:[yn]},$$scope:{ctx:Y}}}),p=new V({props:{code:`from transformers import AutoModelForMultipleChoice, TrainingArguments, Trainer

model = AutoModelForMultipleChoice.from_pretrained("bert-base-uncased")`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForMultipleChoice, TrainingArguments, Trainer

<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForMultipleChoice.from_pretrained(<span class="hljs-string">&quot;bert-base-uncased&quot;</span>)`}}),K=new V({props:{code:`training_args = TrainingArguments(
    output_dir="my_awesome_swag_model",
    evaluation_strategy="epoch",
    save_strategy="epoch",
    load_best_model_at_end=True,
    learning_rate=5e-5,
    per_device_train_batch_size=16,
    per_device_eval_batch_size=16,
    num_train_epochs=3,
    weight_decay=0.01,
    push_to_hub=True,
)

trainer = Trainer(
    model=model,
    args=training_args,
    train_dataset=tokenized_swag["train"],
    eval_dataset=tokenized_swag["validation"],
    tokenizer=tokenizer,
    data_collator=DataCollatorForMultipleChoice(tokenizer=tokenizer),
    compute_metrics=compute_metrics,
)

trainer.train()`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>training_args = TrainingArguments(
<span class="hljs-meta">... </span>    output_dir=<span class="hljs-string">&quot;my_awesome_swag_model&quot;</span>,
<span class="hljs-meta">... </span>    evaluation_strategy=<span class="hljs-string">&quot;epoch&quot;</span>,
<span class="hljs-meta">... </span>    save_strategy=<span class="hljs-string">&quot;epoch&quot;</span>,
<span class="hljs-meta">... </span>    load_best_model_at_end=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    learning_rate=<span class="hljs-number">5e-5</span>,
<span class="hljs-meta">... </span>    per_device_train_batch_size=<span class="hljs-number">16</span>,
<span class="hljs-meta">... </span>    per_device_eval_batch_size=<span class="hljs-number">16</span>,
<span class="hljs-meta">... </span>    num_train_epochs=<span class="hljs-number">3</span>,
<span class="hljs-meta">... </span>    weight_decay=<span class="hljs-number">0.01</span>,
<span class="hljs-meta">... </span>    push_to_hub=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>trainer = Trainer(
<span class="hljs-meta">... </span>    model=model,
<span class="hljs-meta">... </span>    args=training_args,
<span class="hljs-meta">... </span>    train_dataset=tokenized_swag[<span class="hljs-string">&quot;train&quot;</span>],
<span class="hljs-meta">... </span>    eval_dataset=tokenized_swag[<span class="hljs-string">&quot;validation&quot;</span>],
<span class="hljs-meta">... </span>    tokenizer=tokenizer,
<span class="hljs-meta">... </span>    data_collator=DataCollatorForMultipleChoice(tokenizer=tokenizer),
<span class="hljs-meta">... </span>    compute_metrics=compute_metrics,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>trainer.train()`}}),pe=new V({props:{code:"trainer.push_to_hub()",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>trainer.push_to_hub()'}}),{c(){T(i.$$.fragment),c=a(`
You're ready to start training your model now! Load BERT with [AutoModelForMultipleChoice](/docs/transformers/main/en/model_doc/auto#transformers.AutoModelForMultipleChoice):

	`),T(p.$$.fragment),g=d(),w=n("p"),y=a("At this point, only three steps remain:"),P=d(),M=n("ol"),v=n("li"),D=a("Define your training hyperparameters in "),B=n("a"),N=a("TrainingArguments"),I=a(". The only required parameter is "),H=n("code"),W=a("output_dir"),Z=a(" which specifies where to save your model. You\u2019ll push this model to the Hub by setting "),S=n("code"),R=a("push_to_hub=True"),k=a(" (you need to be signed in to Hugging Face to upload your model). At the end of each epoch, the "),F=n("a"),X=a("Trainer"),j=a(" will evaluate the accuracy and save the training checkpoint."),O=d(),G=n("li"),ge=a("Pass the training arguments to "),Q=n("a"),le=a("Trainer"),Ie=a(" along with the model, dataset, tokenizer, data collator, and "),xe=n("code"),fe=a("compute_metrics"),$e=a(" function."),qe=d(),U=n("li"),Oe=a("Call "),se=n("a"),ve=a("train()"),Le=a(" to finetune your model."),ue=d(),T(K.$$.fragment),je=d(),re=n("p"),be=a("Once training is completed, share your model to the Hub with the "),oe=n("a"),we=a("push_to_hub()"),te=a(" method so everyone can use your model:"),me=d(),T(pe.$$.fragment),this.h()},l(b){A(i.$$.fragment,b),c=l(b,`
You're ready to start training your model now! Load BERT with [AutoModelForMultipleChoice](/docs/transformers/main/en/model_doc/auto#transformers.AutoModelForMultipleChoice):

	`),A(p.$$.fragment,b),g=_(b),w=r(b,"P",{});var L=o(w);y=l(L,"At this point, only three steps remain:"),L.forEach(t),P=_(b),M=r(b,"OL",{});var ae=o(M);v=r(ae,"LI",{});var ee=o(v);D=l(ee,"Define your training hyperparameters in "),B=r(ee,"A",{href:!0});var ke=o(B);N=l(ke,"TrainingArguments"),ke.forEach(t),I=l(ee,". The only required parameter is "),H=r(ee,"CODE",{});var Ce=o(H);W=l(Ce,"output_dir"),Ce.forEach(t),Z=l(ee," which specifies where to save your model. You\u2019ll push this model to the Hub by setting "),S=r(ee,"CODE",{});var Pe=o(S);R=l(Pe,"push_to_hub=True"),Pe.forEach(t),k=l(ee," (you need to be signed in to Hugging Face to upload your model). At the end of each epoch, the "),F=r(ee,"A",{href:!0});var Ee=o(F);X=l(Ee,"Trainer"),Ee.forEach(t),j=l(ee," will evaluate the accuracy and save the training checkpoint."),ee.forEach(t),O=_(ae),G=r(ae,"LI",{});var ie=o(G);ge=l(ie,"Pass the training arguments to "),Q=r(ie,"A",{href:!0});var Te=o(Q);le=l(Te,"Trainer"),Te.forEach(t),Ie=l(ie," along with the model, dataset, tokenizer, data collator, and "),xe=r(ie,"CODE",{});var Ae=o(xe);fe=l(Ae,"compute_metrics"),Ae.forEach(t),$e=l(ie," function."),ie.forEach(t),qe=_(ae),U=r(ae,"LI",{});var de=o(U);Oe=l(de,"Call "),se=r(de,"A",{href:!0});var _e=o(se);ve=l(_e,"train()"),_e.forEach(t),Le=l(de," to finetune your model."),de.forEach(t),ae.forEach(t),ue=_(b),A(K.$$.fragment,b),je=_(b),re=r(b,"P",{});var Me=o(re);be=l(Me,"Once training is completed, share your model to the Hub with the "),oe=r(Me,"A",{href:!0});var ne=o(oe);we=l(ne,"push_to_hub()"),ne.forEach(t),te=l(Me," method so everyone can use your model:"),Me.forEach(t),me=_(b),A(pe.$$.fragment,b),this.h()},h(){m(B,"href","/docs/transformers/main/en/main_classes/trainer#transformers.TrainingArguments"),m(F,"href","/docs/transformers/main/en/main_classes/trainer#transformers.Trainer"),m(Q,"href","/docs/transformers/main/en/main_classes/trainer#transformers.Trainer"),m(se,"href","/docs/transformers/main/en/main_classes/trainer#transformers.Trainer.train"),m(oe,"href","/docs/transformers/main/en/main_classes/trainer#transformers.Trainer.push_to_hub")},m(b,L){z(i,b,L),f(b,c,L),z(p,b,L),f(b,g,L),f(b,w,L),e(w,y),f(b,P,L),f(b,M,L),e(M,v),e(v,D),e(v,B),e(B,N),e(v,I),e(v,H),e(H,W),e(v,Z),e(v,S),e(S,R),e(v,k),e(v,F),e(F,X),e(v,j),e(M,O),e(M,G),e(G,ge),e(G,Q),e(Q,le),e(G,Ie),e(G,xe),e(xe,fe),e(G,$e),e(M,qe),e(M,U),e(U,Oe),e(U,se),e(se,ve),e(U,Le),f(b,ue,L),z(K,b,L),f(b,je,L),f(b,re,L),e(re,be),e(re,oe),e(oe,we),e(re,te),f(b,me,L),z(pe,b,L),J=!0},p(b,L){const ae={};L&2&&(ae.$$scope={dirty:L,ctx:b}),i.$set(ae)},i(b){J||(x(i.$$.fragment,b),x(p.$$.fragment,b),x(K.$$.fragment,b),x(pe.$$.fragment,b),J=!0)},o(b){q(i.$$.fragment,b),q(p.$$.fragment,b),q(K.$$.fragment,b),q(pe.$$.fragment,b),J=!1},d(b){C(i,b),b&&t(c),C(p,b),b&&t(g),b&&t(w),b&&t(P),b&&t(M),b&&t(ue),C(K,b),b&&t(je),b&&t(re),b&&t(me),C(pe,b)}}}function En(Y){let i,c;return i=new Ot({props:{$$slots:{default:[vn]},$$scope:{ctx:Y}}}),{c(){T(i.$$.fragment)},l(p){A(i.$$.fragment,p)},m(p,g){z(i,p,g),c=!0},p(p,g){const w={};g&2&&(w.$$scope={dirty:g,ctx:p}),i.$set(w)},i(p){c||(x(i.$$.fragment,p),c=!0)},o(p){q(i.$$.fragment,p),c=!1},d(p){C(i,p)}}}function Tn(Y){let i,c,p,g,w;return{c(){i=n("p"),c=a("If you aren\u2019t familiar with finetuning a model with Keras, take a look at the basic tutorial "),p=n("a"),g=a("here"),w=a("!"),this.h()},l(y){i=r(y,"P",{});var P=o(i);c=l(P,"If you aren\u2019t familiar with finetuning a model with Keras, take a look at the basic tutorial "),p=r(P,"A",{href:!0});var M=o(p);g=l(M,"here"),M.forEach(t),w=l(P,"!"),P.forEach(t),this.h()},h(){m(p,"href","../training#train-a-tensorflow-model-with-keras")},m(y,P){f(y,i,P),e(i,c),e(i,p),e(p,g),e(i,w)},d(y){y&&t(i)}}}function An(Y){let i,c,p,g,w,y,P,M,v,D,B,N,I,H,W,Z,S,R,k,F,X,j,O,G,ge,Q,le,Ie,xe,fe,$e,qe,U,Oe,se,ve,Le,ue,K,je,re,be,oe,we,te,me,pe,J,b,L,ae,ee,ke,Ce,Pe,Ee,ie,Te,Ae,de,_e,Me,ne,He,Ne,ye,cs,ls,ce,he,Qe,Fe,hs,Ve;return i=new xa({props:{$$slots:{default:[Tn]},$$scope:{ctx:Y}}}),p=new V({props:{code:`from transformers import create_optimizer

batch_size = 16
num_train_epochs = 2
total_train_steps = (len(tokenized_swag["train"]) // batch_size) * num_train_epochs
optimizer, schedule = create_optimizer(init_lr=5e-5, num_warmup_steps=0, num_train_steps=total_train_steps)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> create_optimizer

<span class="hljs-meta">&gt;&gt;&gt; </span>batch_size = <span class="hljs-number">16</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>num_train_epochs = <span class="hljs-number">2</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>total_train_steps = (<span class="hljs-built_in">len</span>(tokenized_swag[<span class="hljs-string">&quot;train&quot;</span>]) // batch_size) * num_train_epochs
<span class="hljs-meta">&gt;&gt;&gt; </span>optimizer, schedule = create_optimizer(init_lr=<span class="hljs-number">5e-5</span>, num_warmup_steps=<span class="hljs-number">0</span>, num_train_steps=total_train_steps)`}}),B=new V({props:{code:`from transformers import TFAutoModelForMultipleChoice

model = TFAutoModelForMultipleChoice.from_pretrained("bert-base-uncased")`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TFAutoModelForMultipleChoice

<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFAutoModelForMultipleChoice.from_pretrained(<span class="hljs-string">&quot;bert-base-uncased&quot;</span>)`}}),j=new V({props:{code:`data_collator = DataCollatorForMultipleChoice(tokenizer=tokenizer)
tf_train_set = model.prepare_tf_dataset(
    tokenized_swag["train"],
    shuffle=True,
    batch_size=batch_size,
    collate_fn=data_collator,
)

tf_validation_set = model.prepare_tf_dataset(
    tokenized_swag["validation"],
    shuffle=False,
    batch_size=batch_size,
    collate_fn=data_collator,
)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>data_collator = DataCollatorForMultipleChoice(tokenizer=tokenizer)
<span class="hljs-meta">&gt;&gt;&gt; </span>tf_train_set = model.prepare_tf_dataset(
<span class="hljs-meta">... </span>    tokenized_swag[<span class="hljs-string">&quot;train&quot;</span>],
<span class="hljs-meta">... </span>    shuffle=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    batch_size=batch_size,
<span class="hljs-meta">... </span>    collate_fn=data_collator,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>tf_validation_set = model.prepare_tf_dataset(
<span class="hljs-meta">... </span>    tokenized_swag[<span class="hljs-string">&quot;validation&quot;</span>],
<span class="hljs-meta">... </span>    shuffle=<span class="hljs-literal">False</span>,
<span class="hljs-meta">... </span>    batch_size=batch_size,
<span class="hljs-meta">... </span>    collate_fn=data_collator,
<span class="hljs-meta">... </span>)`}}),$e=new V({props:{code:"model.compile(optimizer=optimizer)",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>model.<span class="hljs-built_in">compile</span>(optimizer=optimizer)'}}),J=new V({props:{code:`from transformers.keras_callbacks import KerasMetricCallback

metric_callback = KerasMetricCallback(metric_fn=compute_metrics, eval_dataset=tf_validation_set)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers.keras_callbacks <span class="hljs-keyword">import</span> KerasMetricCallback

<span class="hljs-meta">&gt;&gt;&gt; </span>metric_callback = KerasMetricCallback(metric_fn=compute_metrics, eval_dataset=tf_validation_set)`}}),Ee=new V({props:{code:`from transformers.keras_callbacks import PushToHubCallback

push_to_hub_callback = PushToHubCallback(
    output_dir="my_awesome_model",
    tokenizer=tokenizer,
)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers.keras_callbacks <span class="hljs-keyword">import</span> PushToHubCallback

<span class="hljs-meta">&gt;&gt;&gt; </span>push_to_hub_callback = PushToHubCallback(
<span class="hljs-meta">... </span>    output_dir=<span class="hljs-string">&quot;my_awesome_model&quot;</span>,
<span class="hljs-meta">... </span>    tokenizer=tokenizer,
<span class="hljs-meta">... </span>)`}}),_e=new V({props:{code:"callbacks = [metric_callback, push_to_hub_callback]",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>callbacks = [metric_callback, push_to_hub_callback]'}}),he=new V({props:{code:"model.fit(x=tf_train_set, validation_data=tf_validation_set, epochs=2, callbacks=callbacks)",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>model.fit(x=tf_train_set, validation_data=tf_validation_set, epochs=<span class="hljs-number">2</span>, callbacks=callbacks)'}}),{c(){T(i.$$.fragment),c=a(`
To finetune a model in TensorFlow, start by setting up an optimizer function, learning rate schedule, and some training hyperparameters:

	`),T(p.$$.fragment),g=d(),w=n("p"),y=a("Then you can load BERT with "),P=n("a"),M=a("TFAutoModelForMultipleChoice"),v=a(":"),D=d(),T(B.$$.fragment),N=d(),I=n("p"),H=a("Convert your datasets to the "),W=n("code"),Z=a("tf.data.Dataset"),S=a(" format with "),R=n("a"),k=a("prepare_tf_dataset()"),F=a(":"),X=d(),T(j.$$.fragment),O=d(),G=n("p"),ge=a("Configure the model for training with "),Q=n("a"),le=n("code"),Ie=a("compile"),xe=a(":"),fe=d(),T($e.$$.fragment),qe=d(),U=n("p"),Oe=a("The last two things to setup before you start training is to compute the accuracy from the predictions, and provide a way to push your model to the Hub. Both are done by using "),se=n("a"),ve=a("Keras callbacks"),Le=a("."),ue=d(),K=n("p"),je=a("Pass your "),re=n("code"),be=a("compute_metrics"),oe=a(" function to "),we=n("a"),te=a("KerasMetricCallback"),me=a(":"),pe=d(),T(J.$$.fragment),b=d(),L=n("p"),ae=a("Specify where to push your model and tokenizer in the "),ee=n("a"),ke=a("PushToHubCallback"),Ce=a(":"),Pe=d(),T(Ee.$$.fragment),ie=d(),Te=n("p"),Ae=a("Then bundle your callbacks together:"),de=d(),T(_e.$$.fragment),Me=d(),ne=n("p"),He=a("Finally, you\u2019re ready to start training your model! Call "),Ne=n("a"),ye=n("code"),cs=a("fit"),ls=a(" with your training and validation datasets, the number of epochs, and your callbacks to finetune the model:"),ce=d(),T(he.$$.fragment),Qe=d(),Fe=n("p"),hs=a("Once training is completed, your model is automatically uploaded to the Hub so everyone can use it!"),this.h()},l(h){A(i.$$.fragment,h),c=l(h,`
To finetune a model in TensorFlow, start by setting up an optimizer function, learning rate schedule, and some training hyperparameters:

	`),A(p.$$.fragment,h),g=_(h),w=r(h,"P",{});var E=o(w);y=l(E,"Then you can load BERT with "),P=r(E,"A",{href:!0});var We=o(P);M=l(We,"TFAutoModelForMultipleChoice"),We.forEach(t),v=l(E,":"),E.forEach(t),D=_(h),A(B.$$.fragment,h),N=_(h),I=r(h,"P",{});var De=o(I);H=l(De,"Convert your datasets to the "),W=r(De,"CODE",{});var fs=o(W);Z=l(fs,"tf.data.Dataset"),fs.forEach(t),S=l(De," format with "),R=r(De,"A",{href:!0});var us=o(R);k=l(us,"prepare_tf_dataset()"),us.forEach(t),F=l(De,":"),De.forEach(t),X=_(h),A(j.$$.fragment,h),O=_(h),G=r(h,"P",{});var ze=o(G);ge=l(ze,"Configure the model for training with "),Q=r(ze,"A",{href:!0,rel:!0});var ns=o(Q);le=r(ns,"CODE",{});var ms=o(le);Ie=l(ms,"compile"),ms.forEach(t),ns.forEach(t),xe=l(ze,":"),ze.forEach(t),fe=_(h),A($e.$$.fragment,h),qe=_(h),U=r(h,"P",{});var Ge=o(U);Oe=l(Ge,"The last two things to setup before you start training is to compute the accuracy from the predictions, and provide a way to push your model to the Hub. Both are done by using "),se=r(Ge,"A",{href:!0});var ds=o(se);ve=l(ds,"Keras callbacks"),ds.forEach(t),Le=l(Ge,"."),Ge.forEach(t),ue=_(h),K=r(h,"P",{});var Be=o(K);je=l(Be,"Pass your "),re=r(Be,"CODE",{});var Ue=o(re);be=l(Ue,"compute_metrics"),Ue.forEach(t),oe=l(Be," function to "),we=r(Be,"A",{href:!0});var _s=o(we);te=l(_s,"KerasMetricCallback"),_s.forEach(t),me=l(Be,":"),Be.forEach(t),pe=_(h),A(J.$$.fragment,h),b=_(h),L=r(h,"P",{});var rs=o(L);ae=l(rs,"Specify where to push your model and tokenizer in the "),ee=r(rs,"A",{href:!0});var Je=o(ee);ke=l(Je,"PushToHubCallback"),Je.forEach(t),Ce=l(rs,":"),rs.forEach(t),Pe=_(h),A(Ee.$$.fragment,h),ie=_(h),Te=r(h,"P",{});var Se=o(Te);Ae=l(Se,"Then bundle your callbacks together:"),Se.forEach(t),de=_(h),A(_e.$$.fragment,h),Me=_(h),ne=r(h,"P",{});var Re=o(ne);He=l(Re,"Finally, you\u2019re ready to start training your model! Call "),Ne=r(Re,"A",{href:!0,rel:!0});var Ye=o(Ne);ye=r(Ye,"CODE",{});var Ze=o(ye);cs=l(Ze,"fit"),Ze.forEach(t),Ye.forEach(t),ls=l(Re," with your training and validation datasets, the number of epochs, and your callbacks to finetune the model:"),Re.forEach(t),ce=_(h),A(he.$$.fragment,h),Qe=_(h),Fe=r(h,"P",{});var gs=o(Fe);hs=l(gs,"Once training is completed, your model is automatically uploaded to the Hub so everyone can use it!"),gs.forEach(t),this.h()},h(){m(P,"href","/docs/transformers/main/en/model_doc/auto#transformers.TFAutoModelForMultipleChoice"),m(R,"href","/docs/transformers/main/en/main_classes/model#transformers.TFPreTrainedModel.prepare_tf_dataset"),m(Q,"href","https://keras.io/api/models/model_training_apis/#compile-method"),m(Q,"rel","nofollow"),m(se,"href","./main_classes/keras_callbacks"),m(we,"href","/docs/transformers/main/en/main_classes/keras_callbacks#transformers.KerasMetricCallback"),m(ee,"href","/docs/transformers/main/en/main_classes/keras_callbacks#transformers.PushToHubCallback"),m(Ne,"href","https://keras.io/api/models/model_training_apis/#fit-method"),m(Ne,"rel","nofollow")},m(h,E){z(i,h,E),f(h,c,E),z(p,h,E),f(h,g,E),f(h,w,E),e(w,y),e(w,P),e(P,M),e(w,v),f(h,D,E),z(B,h,E),f(h,N,E),f(h,I,E),e(I,H),e(I,W),e(W,Z),e(I,S),e(I,R),e(R,k),e(I,F),f(h,X,E),z(j,h,E),f(h,O,E),f(h,G,E),e(G,ge),e(G,Q),e(Q,le),e(le,Ie),e(G,xe),f(h,fe,E),z($e,h,E),f(h,qe,E),f(h,U,E),e(U,Oe),e(U,se),e(se,ve),e(U,Le),f(h,ue,E),f(h,K,E),e(K,je),e(K,re),e(re,be),e(K,oe),e(K,we),e(we,te),e(K,me),f(h,pe,E),z(J,h,E),f(h,b,E),f(h,L,E),e(L,ae),e(L,ee),e(ee,ke),e(L,Ce),f(h,Pe,E),z(Ee,h,E),f(h,ie,E),f(h,Te,E),e(Te,Ae),f(h,de,E),z(_e,h,E),f(h,Me,E),f(h,ne,E),e(ne,He),e(ne,Ne),e(Ne,ye),e(ye,cs),e(ne,ls),f(h,ce,E),z(he,h,E),f(h,Qe,E),f(h,Fe,E),e(Fe,hs),Ve=!0},p(h,E){const We={};E&2&&(We.$$scope={dirty:E,ctx:h}),i.$set(We)},i(h){Ve||(x(i.$$.fragment,h),x(p.$$.fragment,h),x(B.$$.fragment,h),x(j.$$.fragment,h),x($e.$$.fragment,h),x(J.$$.fragment,h),x(Ee.$$.fragment,h),x(_e.$$.fragment,h),x(he.$$.fragment,h),Ve=!0)},o(h){q(i.$$.fragment,h),q(p.$$.fragment,h),q(B.$$.fragment,h),q(j.$$.fragment,h),q($e.$$.fragment,h),q(J.$$.fragment,h),q(Ee.$$.fragment,h),q(_e.$$.fragment,h),q(he.$$.fragment,h),Ve=!1},d(h){C(i,h),h&&t(c),C(p,h),h&&t(g),h&&t(w),h&&t(D),C(B,h),h&&t(N),h&&t(I),h&&t(X),C(j,h),h&&t(O),h&&t(G),h&&t(fe),C($e,h),h&&t(qe),h&&t(U),h&&t(ue),h&&t(K),h&&t(pe),C(J,h),h&&t(b),h&&t(L),h&&t(Pe),C(Ee,h),h&&t(ie),h&&t(Te),h&&t(de),C(_e,h),h&&t(Me),h&&t(ne),h&&t(ce),C(he,h),h&&t(Qe),h&&t(Fe)}}}function zn(Y){let i,c;return i=new Ot({props:{$$slots:{default:[An]},$$scope:{ctx:Y}}}),{c(){T(i.$$.fragment)},l(p){A(i.$$.fragment,p)},m(p,g){z(i,p,g),c=!0},p(p,g){const w={};g&2&&(w.$$scope={dirty:g,ctx:p}),i.$set(w)},i(p){c||(x(i.$$.fragment,p),c=!0)},o(p){q(i.$$.fragment,p),c=!1},d(p){C(i,p)}}}function xn(Y){let i,c,p,g,w,y,P,M;return{c(){i=n("p"),c=a(`For a more in-depth example of how to finetune a model for multiple choice, take a look at the corresponding
`),p=n("a"),g=a("PyTorch notebook"),w=a(`
or `),y=n("a"),P=a("TensorFlow notebook"),M=a("."),this.h()},l(v){i=r(v,"P",{});var D=o(i);c=l(D,`For a more in-depth example of how to finetune a model for multiple choice, take a look at the corresponding
`),p=r(D,"A",{href:!0,rel:!0});var B=o(p);g=l(B,"PyTorch notebook"),B.forEach(t),w=l(D,`
or `),y=r(D,"A",{href:!0,rel:!0});var N=o(y);P=l(N,"TensorFlow notebook"),N.forEach(t),M=l(D,"."),D.forEach(t),this.h()},h(){m(p,"href","https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/multiple_choice.ipynb"),m(p,"rel","nofollow"),m(y,"href","https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/multiple_choice-tf.ipynb"),m(y,"rel","nofollow")},m(v,D){f(v,i,D),e(i,c),e(i,p),e(p,g),e(i,w),e(i,y),e(y,P),e(i,M)},d(v){v&&t(i)}}}function qn(Y){let i,c,p,g,w,y,P,M,v,D,B,N,I,H,W,Z,S,R,k,F,X;return P=new V({props:{code:`from transformers import AutoTokenizer

tokenizer = AutoTokenizer.from_pretrained("my_awesome_swag_model")
inputs = tokenizer([[prompt, candidate1], [prompt, candidate2]], return_tensors="pt", padding=True)
labels = torch.tensor(0).unsqueeze(0)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;my_awesome_swag_model&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer([[prompt, candidate1], [prompt, candidate2]], return_tensors=<span class="hljs-string">&quot;pt&quot;</span>, padding=<span class="hljs-literal">True</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>labels = torch.tensor(<span class="hljs-number">0</span>).unsqueeze(<span class="hljs-number">0</span>)`}}),W=new V({props:{code:`from transformers import AutoModelForMultipleChoice

model = AutoModelForMultipleChoice.from_pretrained("my_awesome_swag_model")
outputs = model(**{k: v.unsqueeze(0) for k, v in inputs.items()}, labels=labels)
logits = outputs.logits`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForMultipleChoice

<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForMultipleChoice.from_pretrained(<span class="hljs-string">&quot;my_awesome_swag_model&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**{k: v.unsqueeze(<span class="hljs-number">0</span>) <span class="hljs-keyword">for</span> k, v <span class="hljs-keyword">in</span> inputs.items()}, labels=labels)
<span class="hljs-meta">&gt;&gt;&gt; </span>logits = outputs.logits`}}),F=new V({props:{code:`predicted_class = logits.argmax().item()
predicted_class`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_class = logits.argmax().item()
<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_class
<span class="hljs-string">&#x27;0&#x27;</span>`}}),{c(){i=n("p"),c=a("Tokenize each prompt and candidate answer pair and return PyTorch tensors. You should also create some "),p=n("code"),g=a("labels"),w=a(":"),y=d(),T(P.$$.fragment),M=d(),v=n("p"),D=a("Pass your inputs and labels to the model and return the "),B=n("code"),N=a("logits"),I=a(":"),H=d(),T(W.$$.fragment),Z=d(),S=n("p"),R=a("Get the class with the highest probability:"),k=d(),T(F.$$.fragment)},l(j){i=r(j,"P",{});var O=o(i);c=l(O,"Tokenize each prompt and candidate answer pair and return PyTorch tensors. You should also create some "),p=r(O,"CODE",{});var G=o(p);g=l(G,"labels"),G.forEach(t),w=l(O,":"),O.forEach(t),y=_(j),A(P.$$.fragment,j),M=_(j),v=r(j,"P",{});var ge=o(v);D=l(ge,"Pass your inputs and labels to the model and return the "),B=r(ge,"CODE",{});var Q=o(B);N=l(Q,"logits"),Q.forEach(t),I=l(ge,":"),ge.forEach(t),H=_(j),A(W.$$.fragment,j),Z=_(j),S=r(j,"P",{});var le=o(S);R=l(le,"Get the class with the highest probability:"),le.forEach(t),k=_(j),A(F.$$.fragment,j)},m(j,O){f(j,i,O),e(i,c),e(i,p),e(p,g),e(i,w),f(j,y,O),z(P,j,O),f(j,M,O),f(j,v,O),e(v,D),e(v,B),e(B,N),e(v,I),f(j,H,O),z(W,j,O),f(j,Z,O),f(j,S,O),e(S,R),f(j,k,O),z(F,j,O),X=!0},p:qa,i(j){X||(x(P.$$.fragment,j),x(W.$$.fragment,j),x(F.$$.fragment,j),X=!0)},o(j){q(P.$$.fragment,j),q(W.$$.fragment,j),q(F.$$.fragment,j),X=!1},d(j){j&&t(i),j&&t(y),C(P,j),j&&t(M),j&&t(v),j&&t(H),C(W,j),j&&t(Z),j&&t(S),j&&t(k),C(F,j)}}}function Cn(Y){let i,c;return i=new Ot({props:{$$slots:{default:[qn]},$$scope:{ctx:Y}}}),{c(){T(i.$$.fragment)},l(p){A(i.$$.fragment,p)},m(p,g){z(i,p,g),c=!0},p(p,g){const w={};g&2&&(w.$$scope={dirty:g,ctx:p}),i.$set(w)},i(p){c||(x(i.$$.fragment,p),c=!0)},o(p){q(i.$$.fragment,p),c=!1},d(p){C(i,p)}}}function Pn(Y){let i,c,p,g,w,y,P,M,v,D,B,N,I,H,W,Z,S,R;return g=new V({props:{code:`from transformers import AutoTokenizer

tokenizer = AutoTokenizer.from_pretrained("my_awesome_swag_model")
inputs = tokenizer([[prompt, candidate1], [prompt, candidate2]], return_tensors="tf", padding=True)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;my_awesome_swag_model&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer([[prompt, candidate1], [prompt, candidate2]], return_tensors=<span class="hljs-string">&quot;tf&quot;</span>, padding=<span class="hljs-literal">True</span>)`}}),N=new V({props:{code:`from transformers import TFAutoModelForMultipleChoice

model = TFAutoModelForMultipleChoice.from_pretrained("my_awesome_swag_model")
inputs = {k: tf.expand_dims(v, 0) for k, v in inputs.items()}
outputs = model(inputs)
logits = outputs.logits`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TFAutoModelForMultipleChoice

<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFAutoModelForMultipleChoice.from_pretrained(<span class="hljs-string">&quot;my_awesome_swag_model&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = {k: tf.expand_dims(v, <span class="hljs-number">0</span>) <span class="hljs-keyword">for</span> k, v <span class="hljs-keyword">in</span> inputs.items()}
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(inputs)
<span class="hljs-meta">&gt;&gt;&gt; </span>logits = outputs.logits`}}),S=new V({props:{code:`predicted_class = int(tf.math.argmax(logits, axis=-1)[0])
predicted_class`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_class = <span class="hljs-built_in">int</span>(tf.math.argmax(logits, axis=-<span class="hljs-number">1</span>)[<span class="hljs-number">0</span>])
<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_class
<span class="hljs-string">&#x27;0&#x27;</span>`}}),{c(){i=n("p"),c=a("Tokenize each prompt and candidate answer pair and return TensorFlow tensors:"),p=d(),T(g.$$.fragment),w=d(),y=n("p"),P=a("Pass your inputs to the model and return the "),M=n("code"),v=a("logits"),D=a(":"),B=d(),T(N.$$.fragment),I=d(),H=n("p"),W=a("Get the class with the highest probability:"),Z=d(),T(S.$$.fragment)},l(k){i=r(k,"P",{});var F=o(i);c=l(F,"Tokenize each prompt and candidate answer pair and return TensorFlow tensors:"),F.forEach(t),p=_(k),A(g.$$.fragment,k),w=_(k),y=r(k,"P",{});var X=o(y);P=l(X,"Pass your inputs to the model and return the "),M=r(X,"CODE",{});var j=o(M);v=l(j,"logits"),j.forEach(t),D=l(X,":"),X.forEach(t),B=_(k),A(N.$$.fragment,k),I=_(k),H=r(k,"P",{});var O=o(H);W=l(O,"Get the class with the highest probability:"),O.forEach(t),Z=_(k),A(S.$$.fragment,k)},m(k,F){f(k,i,F),e(i,c),f(k,p,F),z(g,k,F),f(k,w,F),f(k,y,F),e(y,P),e(y,M),e(M,v),e(y,D),f(k,B,F),z(N,k,F),f(k,I,F),f(k,H,F),e(H,W),f(k,Z,F),z(S,k,F),R=!0},p:qa,i(k){R||(x(g.$$.fragment,k),x(N.$$.fragment,k),x(S.$$.fragment,k),R=!0)},o(k){q(g.$$.fragment,k),q(N.$$.fragment,k),q(S.$$.fragment,k),R=!1},d(k){k&&t(i),k&&t(p),C(g,k),k&&t(w),k&&t(y),k&&t(B),C(N,k),k&&t(I),k&&t(H),k&&t(Z),C(S,k)}}}function Mn(Y){let i,c;return i=new Ot({props:{$$slots:{default:[Pn]},$$scope:{ctx:Y}}}),{c(){T(i.$$.fragment)},l(p){A(i.$$.fragment,p)},m(p,g){z(i,p,g),c=!0},p(p,g){const w={};g&2&&(w.$$scope={dirty:g,ctx:p}),i.$set(w)},i(p){c||(x(i.$$.fragment,p),c=!0)},o(p){q(i.$$.fragment,p),c=!1},d(p){C(i,p)}}}function Fn(Y){let i,c,p,g,w,y,P,M,v,D,B,N,I,H,W,Z,S,R,k,F,X,j,O,G,ge,Q,le,Ie,xe,fe,$e,qe,U,Oe,se,ve,Le,ue,K,je,re,be,oe,we,te,me,pe,J,b,L,ae,ee,ke,Ce,Pe,Ee,ie,Te,Ae,de,_e,Me,ne,He,Ne,ye,cs,ls,ce,he,Qe,Fe,hs,Ve,h,E,We,De,fs,us,ze,ns,ms,Ge,ds,Be,Ue,_s,rs,Je,Se,Re,Ye,Ze,gs,os,Ys,Es,ts,Ks,Ts,es,As,Ke,$,Xs,as,ps,ft,zs,ut,mt,xs,dt,_t,gt,$s,$t,qs,jt,bt,wt,ss,kt,Cs,yt,vt,Ps,Et,Tt,Ms,At,zt,Qs,js,Vs,Xe,xt,bs,Ca,Pa,Lt,Ma,Fa,Nt,Da,Ba,ea,Js,sa,ws,Ra,qt,Oa,La,St,Na,Sa,ta,Zs,It,Ia,Ha,aa,Fs,la,ks,Ds,Ht,et,Wa,Wt,Ga,na,is,Ua,st,Ya,Ka,tt,Xa,Qa,at,Va,Ja,ra,lt,oa,Bs,Za,nt,el,sl,pa,rt,ia,Rs,tl,Gt,al,ll,ca,ys,Os,Ut,ot,nl,Yt,rl,ha,Ls,fa,Ns,ua,vs,Ss,Kt,pt,ol,Xt,pl,ma,Ct,il,da,Pt,cl,_a,it,ga,Is,$a;return y=new Rt({}),U=new xa({props:{$$slots:{default:[$n]},$$scope:{ctx:Y}}}),ue=new V({props:{code:"pip install transformers datasets evaluate",highlighted:"pip install transformers datasets evaluate"}}),oe=new V({props:{code:`from huggingface_hub import notebook_login

notebook_login()`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> notebook_login

<span class="hljs-meta">&gt;&gt;&gt; </span>notebook_login()`}}),J=new Rt({}),Ae=new V({props:{code:`from datasets import load_dataset

swag = load_dataset("swag", "regular")`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset

<span class="hljs-meta">&gt;&gt;&gt; </span>swag = load_dataset(<span class="hljs-string">&quot;swag&quot;</span>, <span class="hljs-string">&quot;regular&quot;</span>)`}}),He=new V({props:{code:'swag["train"][0]',highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>swag[<span class="hljs-string">&quot;train&quot;</span>][<span class="hljs-number">0</span>]
{<span class="hljs-string">&#x27;ending0&#x27;</span>: <span class="hljs-string">&#x27;passes by walking down the street playing their instruments.&#x27;</span>,
 <span class="hljs-string">&#x27;ending1&#x27;</span>: <span class="hljs-string">&#x27;has heard approaching them.&#x27;</span>,
 <span class="hljs-string">&#x27;ending2&#x27;</span>: <span class="hljs-string">&quot;arrives and they&#x27;re outside dancing and asleep.&quot;</span>,
 <span class="hljs-string">&#x27;ending3&#x27;</span>: <span class="hljs-string">&#x27;turns the lead singer watches the performance.&#x27;</span>,
 <span class="hljs-string">&#x27;fold-ind&#x27;</span>: <span class="hljs-string">&#x27;3416&#x27;</span>,
 <span class="hljs-string">&#x27;gold-source&#x27;</span>: <span class="hljs-string">&#x27;gold&#x27;</span>,
 <span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-number">0</span>,
 <span class="hljs-string">&#x27;sent1&#x27;</span>: <span class="hljs-string">&#x27;Members of the procession walk down the street holding small horn brass instruments.&#x27;</span>,
 <span class="hljs-string">&#x27;sent2&#x27;</span>: <span class="hljs-string">&#x27;A drum line&#x27;</span>,
 <span class="hljs-string">&#x27;startphrase&#x27;</span>: <span class="hljs-string">&#x27;Members of the procession walk down the street holding small horn brass instruments. A drum line&#x27;</span>,
 <span class="hljs-string">&#x27;video-id&#x27;</span>: <span class="hljs-string">&#x27;anetv_jkn6uvmqwh4&#x27;</span>}`}}),Ze=new Rt({}),es=new V({props:{code:`from transformers import AutoTokenizer

tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;bert-base-uncased&quot;</span>)`}}),js=new V({props:{code:`ending_names = ["ending0", "ending1", "ending2", "ending3"]


def preprocess_function(examples):
    first_sentences = [[context] * 4 for context in examples["sent1"]]
    question_headers = examples["sent2"]
    second_sentences = [
        [f"{header} {examples[end][i]}" for end in ending_names] for i, header in enumerate(question_headers)
    ]

    first_sentences = sum(first_sentences, [])
    second_sentences = sum(second_sentences, [])

    tokenized_examples = tokenizer(first_sentences, second_sentences, truncation=True)
    return {k: [v[i : i + 4] for i in range(0, len(v), 4)] for k, v in tokenized_examples.items()}`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>ending_names = [<span class="hljs-string">&quot;ending0&quot;</span>, <span class="hljs-string">&quot;ending1&quot;</span>, <span class="hljs-string">&quot;ending2&quot;</span>, <span class="hljs-string">&quot;ending3&quot;</span>]


<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">preprocess_function</span>(<span class="hljs-params">examples</span>):
<span class="hljs-meta">... </span>    first_sentences = [[context] * <span class="hljs-number">4</span> <span class="hljs-keyword">for</span> context <span class="hljs-keyword">in</span> examples[<span class="hljs-string">&quot;sent1&quot;</span>]]
<span class="hljs-meta">... </span>    question_headers = examples[<span class="hljs-string">&quot;sent2&quot;</span>]
<span class="hljs-meta">... </span>    second_sentences = [
<span class="hljs-meta">... </span>        [<span class="hljs-string">f&quot;<span class="hljs-subst">{header}</span> <span class="hljs-subst">{examples[end][i]}</span>&quot;</span> <span class="hljs-keyword">for</span> end <span class="hljs-keyword">in</span> ending_names] <span class="hljs-keyword">for</span> i, header <span class="hljs-keyword">in</span> <span class="hljs-built_in">enumerate</span>(question_headers)
<span class="hljs-meta">... </span>    ]

<span class="hljs-meta">... </span>    first_sentences = <span class="hljs-built_in">sum</span>(first_sentences, [])
<span class="hljs-meta">... </span>    second_sentences = <span class="hljs-built_in">sum</span>(second_sentences, [])

<span class="hljs-meta">... </span>    tokenized_examples = tokenizer(first_sentences, second_sentences, truncation=<span class="hljs-literal">True</span>)
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> {k: [v[i : i + <span class="hljs-number">4</span>] <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(<span class="hljs-number">0</span>, <span class="hljs-built_in">len</span>(v), <span class="hljs-number">4</span>)] <span class="hljs-keyword">for</span> k, v <span class="hljs-keyword">in</span> tokenized_examples.items()}`}}),Js=new V({props:{code:"tokenized_swag = swag.map(preprocess_function, batched=True)",highlighted:'tokenized_swag = swag.<span class="hljs-built_in">map</span>(preprocess_function, batched=<span class="hljs-literal">True</span>)'}}),Fs=new ml({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[kn],pytorch:[bn]},$$scope:{ctx:Y}}}),et=new Rt({}),lt=new V({props:{code:`import evaluate

accuracy = evaluate.load("accuracy")`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> evaluate

<span class="hljs-meta">&gt;&gt;&gt; </span>accuracy = evaluate.load(<span class="hljs-string">&quot;accuracy&quot;</span>)`}}),rt=new V({props:{code:`import numpy as np


def compute_metrics(eval_pred):
    predictions, labels = eval_pred
    predictions = np.argmax(predictions, axis=1)
    return accuracy.compute(predictions=predictions, references=labels)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np


<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">compute_metrics</span>(<span class="hljs-params">eval_pred</span>):
<span class="hljs-meta">... </span>    predictions, labels = eval_pred
<span class="hljs-meta">... </span>    predictions = np.argmax(predictions, axis=<span class="hljs-number">1</span>)
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> accuracy.compute(predictions=predictions, references=labels)`}}),ot=new Rt({}),Ls=new ml({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[zn],pytorch:[En]},$$scope:{ctx:Y}}}),Ns=new xa({props:{$$slots:{default:[xn]},$$scope:{ctx:Y}}}),pt=new Rt({}),it=new V({props:{code:`prompt = "France has a bread law, Le D\xE9cret Pain, with strict rules on what is allowed in a traditional baguette."
candidate1 = "The law does not apply to croissants and brioche."
candidate2 = "The law applies to baguettes."`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>prompt = <span class="hljs-string">&quot;France has a bread law, Le D\xE9cret Pain, with strict rules on what is allowed in a traditional baguette.&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>candidate1 = <span class="hljs-string">&quot;The law does not apply to croissants and brioche.&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>candidate2 = <span class="hljs-string">&quot;The law applies to baguettes.&quot;</span>`}}),Is=new ml({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[Mn],pytorch:[Cn]},$$scope:{ctx:Y}}}),{c(){i=n("meta"),c=d(),p=n("h1"),g=n("a"),w=n("span"),T(y.$$.fragment),P=d(),M=n("span"),v=a("Multiple choice"),D=d(),B=n("p"),N=a("A multiple choice task is similar to question answering, except several candidate answers are provided along with a context and the model is trained to select the correct answer."),I=d(),H=n("p"),W=a("This guide will show you how to:"),Z=d(),S=n("ol"),R=n("li"),k=a("Finetune "),F=n("a"),X=a("BERT"),j=a(" on the "),O=n("code"),G=a("regular"),ge=a(" configuration of the "),Q=n("a"),le=a("SWAG"),Ie=a(" dataset to select the best answer given multiple options and some context."),xe=d(),fe=n("li"),$e=a("Use your finetuned model for inference."),qe=d(),T(U.$$.fragment),Oe=d(),se=n("p"),ve=a("Before you begin, make sure you have all the necessary libraries installed:"),Le=d(),T(ue.$$.fragment),K=d(),je=n("p"),re=a("We encourage you to login to your Hugging Face account so you can upload and share your model with the community. When prompted, enter your token to login:"),be=d(),T(oe.$$.fragment),we=d(),te=n("h2"),me=n("a"),pe=n("span"),T(J.$$.fragment),b=d(),L=n("span"),ae=a("Load SWAG dataset"),ee=d(),ke=n("p"),Ce=a("Start by loading the "),Pe=n("code"),Ee=a("regular"),ie=a(" configuration of the SWAG dataset from the \u{1F917} Datasets library:"),Te=d(),T(Ae.$$.fragment),de=d(),_e=n("p"),Me=a("Then take a look at an example:"),ne=d(),T(He.$$.fragment),Ne=d(),ye=n("p"),cs=a("While it looks like there are a lot of fields here, it is actually pretty straightforward:"),ls=d(),ce=n("ul"),he=n("li"),Qe=n("code"),Fe=a("sent1"),hs=a(" and "),Ve=n("code"),h=a("sent2"),E=a(": these fields show how a sentence starts, and if you put the two together, you get the "),We=n("code"),De=a("startphrase"),fs=a(" field."),us=d(),ze=n("li"),ns=n("code"),ms=a("ending"),Ge=a(": suggests a possible ending for how a sentence can end, but only one of them is correct."),ds=d(),Be=n("li"),Ue=n("code"),_s=a("label"),rs=a(": identifies the correct sentence ending."),Je=d(),Se=n("h2"),Re=n("a"),Ye=n("span"),T(Ze.$$.fragment),gs=d(),os=n("span"),Ys=a("Preprocess"),Es=d(),ts=n("p"),Ks=a("The next step is to load a BERT tokenizer to process the sentence starts and the four possible endings:"),Ts=d(),T(es.$$.fragment),As=d(),Ke=n("p"),$=a("The preprocessing function you want to create needs to:"),Xs=d(),as=n("ol"),ps=n("li"),ft=a("Make four copies of the "),zs=n("code"),ut=a("sent1"),mt=a(" field and combine each of them with "),xs=n("code"),dt=a("sent2"),_t=a(" to recreate how a sentence starts."),gt=d(),$s=n("li"),$t=a("Combine "),qs=n("code"),jt=a("sent2"),bt=a(" with each of the four possible sentence endings."),wt=d(),ss=n("li"),kt=a("Flatten these two lists so you can tokenize them, and then unflatten them afterward so each example has a corresponding "),Cs=n("code"),yt=a("input_ids"),vt=a(", "),Ps=n("code"),Et=a("attention_mask"),Tt=a(", and "),Ms=n("code"),At=a("labels"),zt=a(" field."),Qs=d(),T(js.$$.fragment),Vs=d(),Xe=n("p"),xt=a("To apply the preprocessing function over the entire dataset, use \u{1F917} Datasets "),bs=n("a"),Ca=a("map"),Pa=a(" method. You can speed up the "),Lt=n("code"),Ma=a("map"),Fa=a(" function by setting "),Nt=n("code"),Da=a("batched=True"),Ba=a(" to process multiple elements of the dataset at once:"),ea=d(),T(Js.$$.fragment),sa=d(),ws=n("p"),Ra=a("\u{1F917} Transformers doesn\u2019t have a data collator for multiple choice, so you\u2019ll need to adapt the "),qt=n("a"),Oa=a("DataCollatorWithPadding"),La=a(" to create a batch of examples. It\u2019s more efficient to "),St=n("em"),Na=a("dynamically pad"),Sa=a(" the sentences to the longest length in a batch during collation, instead of padding the whole dataset to the maximium length."),ta=d(),Zs=n("p"),It=n("code"),Ia=a("DataCollatorForMultipleChoice"),Ha=a(" flattens all the model inputs, applies padding, and then unflattens the results:"),aa=d(),T(Fs.$$.fragment),la=d(),ks=n("h2"),Ds=n("a"),Ht=n("span"),T(et.$$.fragment),Wa=d(),Wt=n("span"),Ga=a("Evaluate"),na=d(),is=n("p"),Ua=a("Including a metric during training is often helpful for evaluating your model\u2019s performance. You can quickly load a evaluation method with the \u{1F917} "),st=n("a"),Ya=a("Evaluate"),Ka=a(" library. For this task, load the "),tt=n("a"),Xa=a("accuracy"),Qa=a(" metric (see the \u{1F917} Evaluate "),at=n("a"),Va=a("quick tour"),Ja=a(" to learn more about how to load and compute a metric):"),ra=d(),T(lt.$$.fragment),oa=d(),Bs=n("p"),Za=a("Then create a function that passes your predictions and labels to "),nt=n("a"),el=a("compute"),sl=a(" to calculate the accuracy:"),pa=d(),T(rt.$$.fragment),ia=d(),Rs=n("p"),tl=a("Your "),Gt=n("code"),al=a("compute_metrics"),ll=a(" function is ready to go now, and you\u2019ll return to it when you setup your training."),ca=d(),ys=n("h2"),Os=n("a"),Ut=n("span"),T(ot.$$.fragment),nl=d(),Yt=n("span"),rl=a("Train"),ha=d(),T(Ls.$$.fragment),fa=d(),T(Ns.$$.fragment),ua=d(),vs=n("h2"),Ss=n("a"),Kt=n("span"),T(pt.$$.fragment),ol=d(),Xt=n("span"),pl=a("Inference"),ma=d(),Ct=n("p"),il=a("Great, now that you\u2019ve finetuned a model, you can use it for inference!"),da=d(),Pt=n("p"),cl=a("Come up with some text and two candidate answers:"),_a=d(),T(it.$$.fragment),ga=d(),T(Is.$$.fragment),this.h()},l(s){const u=_n('[data-svelte="svelte-1phssyn"]',document.head);i=r(u,"META",{name:!0,content:!0}),u.forEach(t),c=_(s),p=r(s,"H1",{class:!0});var ct=o(p);g=r(ct,"A",{id:!0,class:!0,href:!0});var Qt=o(g);w=r(Qt,"SPAN",{});var Vt=o(w);A(y.$$.fragment,Vt),Vt.forEach(t),Qt.forEach(t),P=_(ct),M=r(ct,"SPAN",{});var Jt=o(M);v=l(Jt,"Multiple choice"),Jt.forEach(t),ct.forEach(t),D=_(s),B=r(s,"P",{});var Zt=o(B);N=l(Zt,"A multiple choice task is similar to question answering, except several candidate answers are provided along with a context and the model is trained to select the correct answer."),Zt.forEach(t),I=_(s),H=r(s,"P",{});var dl=o(H);W=l(dl,"This guide will show you how to:"),dl.forEach(t),Z=_(s),S=r(s,"OL",{});var ja=o(S);R=r(ja,"LI",{});var Hs=o(R);k=l(Hs,"Finetune "),F=r(Hs,"A",{href:!0,rel:!0});var _l=o(F);X=l(_l,"BERT"),_l.forEach(t),j=l(Hs," on the "),O=r(Hs,"CODE",{});var gl=o(O);G=l(gl,"regular"),gl.forEach(t),ge=l(Hs," configuration of the "),Q=r(Hs,"A",{href:!0,rel:!0});var $l=o(Q);le=l($l,"SWAG"),$l.forEach(t),Ie=l(Hs," dataset to select the best answer given multiple options and some context."),Hs.forEach(t),xe=_(ja),fe=r(ja,"LI",{});var jl=o(fe);$e=l(jl,"Use your finetuned model for inference."),jl.forEach(t),ja.forEach(t),qe=_(s),A(U.$$.fragment,s),Oe=_(s),se=r(s,"P",{});var bl=o(se);ve=l(bl,"Before you begin, make sure you have all the necessary libraries installed:"),bl.forEach(t),Le=_(s),A(ue.$$.fragment,s),K=_(s),je=r(s,"P",{});var wl=o(je);re=l(wl,"We encourage you to login to your Hugging Face account so you can upload and share your model with the community. When prompted, enter your token to login:"),wl.forEach(t),be=_(s),A(oe.$$.fragment,s),we=_(s),te=r(s,"H2",{class:!0});var ba=o(te);me=r(ba,"A",{id:!0,class:!0,href:!0});var kl=o(me);pe=r(kl,"SPAN",{});var yl=o(pe);A(J.$$.fragment,yl),yl.forEach(t),kl.forEach(t),b=_(ba),L=r(ba,"SPAN",{});var vl=o(L);ae=l(vl,"Load SWAG dataset"),vl.forEach(t),ba.forEach(t),ee=_(s),ke=r(s,"P",{});var wa=o(ke);Ce=l(wa,"Start by loading the "),Pe=r(wa,"CODE",{});var El=o(Pe);Ee=l(El,"regular"),El.forEach(t),ie=l(wa," configuration of the SWAG dataset from the \u{1F917} Datasets library:"),wa.forEach(t),Te=_(s),A(Ae.$$.fragment,s),de=_(s),_e=r(s,"P",{});var Tl=o(_e);Me=l(Tl,"Then take a look at an example:"),Tl.forEach(t),ne=_(s),A(He.$$.fragment,s),Ne=_(s),ye=r(s,"P",{});var Al=o(ye);cs=l(Al,"While it looks like there are a lot of fields here, it is actually pretty straightforward:"),Al.forEach(t),ls=_(s),ce=r(s,"UL",{});var Mt=o(ce);he=r(Mt,"LI",{});var ht=o(he);Qe=r(ht,"CODE",{});var zl=o(Qe);Fe=l(zl,"sent1"),zl.forEach(t),hs=l(ht," and "),Ve=r(ht,"CODE",{});var xl=o(Ve);h=l(xl,"sent2"),xl.forEach(t),E=l(ht,": these fields show how a sentence starts, and if you put the two together, you get the "),We=r(ht,"CODE",{});var ql=o(We);De=l(ql,"startphrase"),ql.forEach(t),fs=l(ht," field."),ht.forEach(t),us=_(Mt),ze=r(Mt,"LI",{});var hl=o(ze);ns=r(hl,"CODE",{});var Cl=o(ns);ms=l(Cl,"ending"),Cl.forEach(t),Ge=l(hl,": suggests a possible ending for how a sentence can end, but only one of them is correct."),hl.forEach(t),ds=_(Mt),Be=r(Mt,"LI",{});var fl=o(Be);Ue=r(fl,"CODE",{});var Pl=o(Ue);_s=l(Pl,"label"),Pl.forEach(t),rs=l(fl,": identifies the correct sentence ending."),fl.forEach(t),Mt.forEach(t),Je=_(s),Se=r(s,"H2",{class:!0});var ka=o(Se);Re=r(ka,"A",{id:!0,class:!0,href:!0});var Ml=o(Re);Ye=r(Ml,"SPAN",{});var Fl=o(Ye);A(Ze.$$.fragment,Fl),Fl.forEach(t),Ml.forEach(t),gs=_(ka),os=r(ka,"SPAN",{});var Dl=o(os);Ys=l(Dl,"Preprocess"),Dl.forEach(t),ka.forEach(t),Es=_(s),ts=r(s,"P",{});var Bl=o(ts);Ks=l(Bl,"The next step is to load a BERT tokenizer to process the sentence starts and the four possible endings:"),Bl.forEach(t),Ts=_(s),A(es.$$.fragment,s),As=_(s),Ke=r(s,"P",{});var Rl=o(Ke);$=l(Rl,"The preprocessing function you want to create needs to:"),Rl.forEach(t),Xs=_(s),as=r(s,"OL",{});var Ft=o(as);ps=r(Ft,"LI",{});var Dt=o(ps);ft=l(Dt,"Make four copies of the "),zs=r(Dt,"CODE",{});var Ol=o(zs);ut=l(Ol,"sent1"),Ol.forEach(t),mt=l(Dt," field and combine each of them with "),xs=r(Dt,"CODE",{});var Ll=o(xs);dt=l(Ll,"sent2"),Ll.forEach(t),_t=l(Dt," to recreate how a sentence starts."),Dt.forEach(t),gt=_(Ft),$s=r(Ft,"LI",{});var ya=o($s);$t=l(ya,"Combine "),qs=r(ya,"CODE",{});var Nl=o(qs);jt=l(Nl,"sent2"),Nl.forEach(t),bt=l(ya," with each of the four possible sentence endings."),ya.forEach(t),wt=_(Ft),ss=r(Ft,"LI",{});var Ws=o(ss);kt=l(Ws,"Flatten these two lists so you can tokenize them, and then unflatten them afterward so each example has a corresponding "),Cs=r(Ws,"CODE",{});var Sl=o(Cs);yt=l(Sl,"input_ids"),Sl.forEach(t),vt=l(Ws,", "),Ps=r(Ws,"CODE",{});var Il=o(Ps);Et=l(Il,"attention_mask"),Il.forEach(t),Tt=l(Ws,", and "),Ms=r(Ws,"CODE",{});var Hl=o(Ms);At=l(Hl,"labels"),Hl.forEach(t),zt=l(Ws," field."),Ws.forEach(t),Ft.forEach(t),Qs=_(s),A(js.$$.fragment,s),Vs=_(s),Xe=r(s,"P",{});var Gs=o(Xe);xt=l(Gs,"To apply the preprocessing function over the entire dataset, use \u{1F917} Datasets "),bs=r(Gs,"A",{href:!0,rel:!0});var Wl=o(bs);Ca=l(Wl,"map"),Wl.forEach(t),Pa=l(Gs," method. You can speed up the "),Lt=r(Gs,"CODE",{});var Gl=o(Lt);Ma=l(Gl,"map"),Gl.forEach(t),Fa=l(Gs," function by setting "),Nt=r(Gs,"CODE",{});var Ul=o(Nt);Da=l(Ul,"batched=True"),Ul.forEach(t),Ba=l(Gs," to process multiple elements of the dataset at once:"),Gs.forEach(t),ea=_(s),A(Js.$$.fragment,s),sa=_(s),ws=r(s,"P",{});var Bt=o(ws);Ra=l(Bt,"\u{1F917} Transformers doesn\u2019t have a data collator for multiple choice, so you\u2019ll need to adapt the "),qt=r(Bt,"A",{href:!0});var Yl=o(qt);Oa=l(Yl,"DataCollatorWithPadding"),Yl.forEach(t),La=l(Bt," to create a batch of examples. It\u2019s more efficient to "),St=r(Bt,"EM",{});var Kl=o(St);Na=l(Kl,"dynamically pad"),Kl.forEach(t),Sa=l(Bt," the sentences to the longest length in a batch during collation, instead of padding the whole dataset to the maximium length."),Bt.forEach(t),ta=_(s),Zs=r(s,"P",{});var ul=o(Zs);It=r(ul,"CODE",{});var Xl=o(It);Ia=l(Xl,"DataCollatorForMultipleChoice"),Xl.forEach(t),Ha=l(ul," flattens all the model inputs, applies padding, and then unflattens the results:"),ul.forEach(t),aa=_(s),A(Fs.$$.fragment,s),la=_(s),ks=r(s,"H2",{class:!0});var va=o(ks);Ds=r(va,"A",{id:!0,class:!0,href:!0});var Ql=o(Ds);Ht=r(Ql,"SPAN",{});var Vl=o(Ht);A(et.$$.fragment,Vl),Vl.forEach(t),Ql.forEach(t),Wa=_(va),Wt=r(va,"SPAN",{});var Jl=o(Wt);Ga=l(Jl,"Evaluate"),Jl.forEach(t),va.forEach(t),na=_(s),is=r(s,"P",{});var Us=o(is);Ua=l(Us,"Including a metric during training is often helpful for evaluating your model\u2019s performance. You can quickly load a evaluation method with the \u{1F917} "),st=r(Us,"A",{href:!0,rel:!0});var Zl=o(st);Ya=l(Zl,"Evaluate"),Zl.forEach(t),Ka=l(Us," library. For this task, load the "),tt=r(Us,"A",{href:!0,rel:!0});var en=o(tt);Xa=l(en,"accuracy"),en.forEach(t),Qa=l(Us," metric (see the \u{1F917} Evaluate "),at=r(Us,"A",{href:!0,rel:!0});var sn=o(at);Va=l(sn,"quick tour"),sn.forEach(t),Ja=l(Us," to learn more about how to load and compute a metric):"),Us.forEach(t),ra=_(s),A(lt.$$.fragment,s),oa=_(s),Bs=r(s,"P",{});var Ea=o(Bs);Za=l(Ea,"Then create a function that passes your predictions and labels to "),nt=r(Ea,"A",{href:!0,rel:!0});var tn=o(nt);el=l(tn,"compute"),tn.forEach(t),sl=l(Ea," to calculate the accuracy:"),Ea.forEach(t),pa=_(s),A(rt.$$.fragment,s),ia=_(s),Rs=r(s,"P",{});var Ta=o(Rs);tl=l(Ta,"Your "),Gt=r(Ta,"CODE",{});var an=o(Gt);al=l(an,"compute_metrics"),an.forEach(t),ll=l(Ta," function is ready to go now, and you\u2019ll return to it when you setup your training."),Ta.forEach(t),ca=_(s),ys=r(s,"H2",{class:!0});var Aa=o(ys);Os=r(Aa,"A",{id:!0,class:!0,href:!0});var ln=o(Os);Ut=r(ln,"SPAN",{});var nn=o(Ut);A(ot.$$.fragment,nn),nn.forEach(t),ln.forEach(t),nl=_(Aa),Yt=r(Aa,"SPAN",{});var rn=o(Yt);rl=l(rn,"Train"),rn.forEach(t),Aa.forEach(t),ha=_(s),A(Ls.$$.fragment,s),fa=_(s),A(Ns.$$.fragment,s),ua=_(s),vs=r(s,"H2",{class:!0});var za=o(vs);Ss=r(za,"A",{id:!0,class:!0,href:!0});var on=o(Ss);Kt=r(on,"SPAN",{});var pn=o(Kt);A(pt.$$.fragment,pn),pn.forEach(t),on.forEach(t),ol=_(za),Xt=r(za,"SPAN",{});var cn=o(Xt);pl=l(cn,"Inference"),cn.forEach(t),za.forEach(t),ma=_(s),Ct=r(s,"P",{});var hn=o(Ct);il=l(hn,"Great, now that you\u2019ve finetuned a model, you can use it for inference!"),hn.forEach(t),da=_(s),Pt=r(s,"P",{});var fn=o(Pt);cl=l(fn,"Come up with some text and two candidate answers:"),fn.forEach(t),_a=_(s),A(it.$$.fragment,s),ga=_(s),A(Is.$$.fragment,s),this.h()},h(){m(i,"name","hf:doc:metadata"),m(i,"content",JSON.stringify(Dn)),m(g,"id","multiple-choice"),m(g,"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"),m(g,"href","#multiple-choice"),m(p,"class","relative group"),m(F,"href","https://huggingface.co/bert-base-uncased"),m(F,"rel","nofollow"),m(Q,"href","https://huggingface.co/datasets/swag"),m(Q,"rel","nofollow"),m(me,"id","load-swag-dataset"),m(me,"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"),m(me,"href","#load-swag-dataset"),m(te,"class","relative group"),m(Re,"id","preprocess"),m(Re,"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"),m(Re,"href","#preprocess"),m(Se,"class","relative group"),m(bs,"href","https://huggingface.co/docs/datasets/main/en/package_reference/main_classes#datasets.Dataset.map"),m(bs,"rel","nofollow"),m(qt,"href","/docs/transformers/main/en/main_classes/data_collator#transformers.DataCollatorWithPadding"),m(Ds,"id","evaluate"),m(Ds,"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"),m(Ds,"href","#evaluate"),m(ks,"class","relative group"),m(st,"href","https://huggingface.co/docs/evaluate/index"),m(st,"rel","nofollow"),m(tt,"href","https://huggingface.co/spaces/evaluate-metric/accuracy"),m(tt,"rel","nofollow"),m(at,"href","https://huggingface.co/docs/evaluate/a_quick_tour"),m(at,"rel","nofollow"),m(nt,"href","https://huggingface.co/docs/evaluate/main/en/package_reference/main_classes#evaluate.EvaluationModule.compute"),m(nt,"rel","nofollow"),m(Os,"id","train"),m(Os,"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"),m(Os,"href","#train"),m(ys,"class","relative group"),m(Ss,"id","inference"),m(Ss,"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"),m(Ss,"href","#inference"),m(vs,"class","relative group")},m(s,u){e(document.head,i),f(s,c,u),f(s,p,u),e(p,g),e(g,w),z(y,w,null),e(p,P),e(p,M),e(M,v),f(s,D,u),f(s,B,u),e(B,N),f(s,I,u),f(s,H,u),e(H,W),f(s,Z,u),f(s,S,u),e(S,R),e(R,k),e(R,F),e(F,X),e(R,j),e(R,O),e(O,G),e(R,ge),e(R,Q),e(Q,le),e(R,Ie),e(S,xe),e(S,fe),e(fe,$e),f(s,qe,u),z(U,s,u),f(s,Oe,u),f(s,se,u),e(se,ve),f(s,Le,u),z(ue,s,u),f(s,K,u),f(s,je,u),e(je,re),f(s,be,u),z(oe,s,u),f(s,we,u),f(s,te,u),e(te,me),e(me,pe),z(J,pe,null),e(te,b),e(te,L),e(L,ae),f(s,ee,u),f(s,ke,u),e(ke,Ce),e(ke,Pe),e(Pe,Ee),e(ke,ie),f(s,Te,u),z(Ae,s,u),f(s,de,u),f(s,_e,u),e(_e,Me),f(s,ne,u),z(He,s,u),f(s,Ne,u),f(s,ye,u),e(ye,cs),f(s,ls,u),f(s,ce,u),e(ce,he),e(he,Qe),e(Qe,Fe),e(he,hs),e(he,Ve),e(Ve,h),e(he,E),e(he,We),e(We,De),e(he,fs),e(ce,us),e(ce,ze),e(ze,ns),e(ns,ms),e(ze,Ge),e(ce,ds),e(ce,Be),e(Be,Ue),e(Ue,_s),e(Be,rs),f(s,Je,u),f(s,Se,u),e(Se,Re),e(Re,Ye),z(Ze,Ye,null),e(Se,gs),e(Se,os),e(os,Ys),f(s,Es,u),f(s,ts,u),e(ts,Ks),f(s,Ts,u),z(es,s,u),f(s,As,u),f(s,Ke,u),e(Ke,$),f(s,Xs,u),f(s,as,u),e(as,ps),e(ps,ft),e(ps,zs),e(zs,ut),e(ps,mt),e(ps,xs),e(xs,dt),e(ps,_t),e(as,gt),e(as,$s),e($s,$t),e($s,qs),e(qs,jt),e($s,bt),e(as,wt),e(as,ss),e(ss,kt),e(ss,Cs),e(Cs,yt),e(ss,vt),e(ss,Ps),e(Ps,Et),e(ss,Tt),e(ss,Ms),e(Ms,At),e(ss,zt),f(s,Qs,u),z(js,s,u),f(s,Vs,u),f(s,Xe,u),e(Xe,xt),e(Xe,bs),e(bs,Ca),e(Xe,Pa),e(Xe,Lt),e(Lt,Ma),e(Xe,Fa),e(Xe,Nt),e(Nt,Da),e(Xe,Ba),f(s,ea,u),z(Js,s,u),f(s,sa,u),f(s,ws,u),e(ws,Ra),e(ws,qt),e(qt,Oa),e(ws,La),e(ws,St),e(St,Na),e(ws,Sa),f(s,ta,u),f(s,Zs,u),e(Zs,It),e(It,Ia),e(Zs,Ha),f(s,aa,u),z(Fs,s,u),f(s,la,u),f(s,ks,u),e(ks,Ds),e(Ds,Ht),z(et,Ht,null),e(ks,Wa),e(ks,Wt),e(Wt,Ga),f(s,na,u),f(s,is,u),e(is,Ua),e(is,st),e(st,Ya),e(is,Ka),e(is,tt),e(tt,Xa),e(is,Qa),e(is,at),e(at,Va),e(is,Ja),f(s,ra,u),z(lt,s,u),f(s,oa,u),f(s,Bs,u),e(Bs,Za),e(Bs,nt),e(nt,el),e(Bs,sl),f(s,pa,u),z(rt,s,u),f(s,ia,u),f(s,Rs,u),e(Rs,tl),e(Rs,Gt),e(Gt,al),e(Rs,ll),f(s,ca,u),f(s,ys,u),e(ys,Os),e(Os,Ut),z(ot,Ut,null),e(ys,nl),e(ys,Yt),e(Yt,rl),f(s,ha,u),z(Ls,s,u),f(s,fa,u),z(Ns,s,u),f(s,ua,u),f(s,vs,u),e(vs,Ss),e(Ss,Kt),z(pt,Kt,null),e(vs,ol),e(vs,Xt),e(Xt,pl),f(s,ma,u),f(s,Ct,u),e(Ct,il),f(s,da,u),f(s,Pt,u),e(Pt,cl),f(s,_a,u),z(it,s,u),f(s,ga,u),z(Is,s,u),$a=!0},p(s,[u]){const ct={};u&2&&(ct.$$scope={dirty:u,ctx:s}),U.$set(ct);const Qt={};u&2&&(Qt.$$scope={dirty:u,ctx:s}),Fs.$set(Qt);const Vt={};u&2&&(Vt.$$scope={dirty:u,ctx:s}),Ls.$set(Vt);const Jt={};u&2&&(Jt.$$scope={dirty:u,ctx:s}),Ns.$set(Jt);const Zt={};u&2&&(Zt.$$scope={dirty:u,ctx:s}),Is.$set(Zt)},i(s){$a||(x(y.$$.fragment,s),x(U.$$.fragment,s),x(ue.$$.fragment,s),x(oe.$$.fragment,s),x(J.$$.fragment,s),x(Ae.$$.fragment,s),x(He.$$.fragment,s),x(Ze.$$.fragment,s),x(es.$$.fragment,s),x(js.$$.fragment,s),x(Js.$$.fragment,s),x(Fs.$$.fragment,s),x(et.$$.fragment,s),x(lt.$$.fragment,s),x(rt.$$.fragment,s),x(ot.$$.fragment,s),x(Ls.$$.fragment,s),x(Ns.$$.fragment,s),x(pt.$$.fragment,s),x(it.$$.fragment,s),x(Is.$$.fragment,s),$a=!0)},o(s){q(y.$$.fragment,s),q(U.$$.fragment,s),q(ue.$$.fragment,s),q(oe.$$.fragment,s),q(J.$$.fragment,s),q(Ae.$$.fragment,s),q(He.$$.fragment,s),q(Ze.$$.fragment,s),q(es.$$.fragment,s),q(js.$$.fragment,s),q(Js.$$.fragment,s),q(Fs.$$.fragment,s),q(et.$$.fragment,s),q(lt.$$.fragment,s),q(rt.$$.fragment,s),q(ot.$$.fragment,s),q(Ls.$$.fragment,s),q(Ns.$$.fragment,s),q(pt.$$.fragment,s),q(it.$$.fragment,s),q(Is.$$.fragment,s),$a=!1},d(s){t(i),s&&t(c),s&&t(p),C(y),s&&t(D),s&&t(B),s&&t(I),s&&t(H),s&&t(Z),s&&t(S),s&&t(qe),C(U,s),s&&t(Oe),s&&t(se),s&&t(Le),C(ue,s),s&&t(K),s&&t(je),s&&t(be),C(oe,s),s&&t(we),s&&t(te),C(J),s&&t(ee),s&&t(ke),s&&t(Te),C(Ae,s),s&&t(de),s&&t(_e),s&&t(ne),C(He,s),s&&t(Ne),s&&t(ye),s&&t(ls),s&&t(ce),s&&t(Je),s&&t(Se),C(Ze),s&&t(Es),s&&t(ts),s&&t(Ts),C(es,s),s&&t(As),s&&t(Ke),s&&t(Xs),s&&t(as),s&&t(Qs),C(js,s),s&&t(Vs),s&&t(Xe),s&&t(ea),C(Js,s),s&&t(sa),s&&t(ws),s&&t(ta),s&&t(Zs),s&&t(aa),C(Fs,s),s&&t(la),s&&t(ks),C(et),s&&t(na),s&&t(is),s&&t(ra),C(lt,s),s&&t(oa),s&&t(Bs),s&&t(pa),C(rt,s),s&&t(ia),s&&t(Rs),s&&t(ca),s&&t(ys),C(ot),s&&t(ha),C(Ls,s),s&&t(fa),C(Ns,s),s&&t(ua),s&&t(vs),C(pt),s&&t(ma),s&&t(Ct),s&&t(da),s&&t(Pt),s&&t(_a),C(it,s),s&&t(ga),C(Is,s)}}}const Dn={local:"multiple-choice",sections:[{local:"load-swag-dataset",title:"Load SWAG dataset"},{local:"preprocess",title:"Preprocess"},{local:"evaluate",title:"Evaluate"},{local:"train",title:"Train"},{local:"inference",title:"Inference"}],title:"Multiple choice"};function Bn(Y){return gn(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class In extends un{constructor(i){super();mn(this,i,Bn,Fn,dn,{})}}export{In as default,Dn as metadata};
