import{s as Vl,o as Xl,n as ms}from"../chunks/scheduler.9bc65507.js";import{S as Wl,i as Bl,g as J,s as M,r as y,A as Al,h as b,f as e,c as m,j as kl,u as h,x as U,k as Il,y as vl,a as t,v as d,d as f,t as u,w,m as Gl,n as Rl}from"../chunks/index.707bf1b6.js";import{T as ol}from"../chunks/Tip.c2ecdbf4.js";import{C as R}from"../chunks/CodeBlock.54a9f38d.js";import{D as El}from"../chunks/DocNotebookDropdown.41f65cb5.js";import{F as il,M as As}from"../chunks/Markdown.8ab98a13.js";import{H as Bs}from"../chunks/Heading.342b1fa6.js";function xl(_){let a,c,l='<a href="../model_doc/albert">ALBERT</a>, <a href="../model_doc/bert">BERT</a>, <a href="../model_doc/big_bird">BigBird</a>, <a href="../model_doc/camembert">CamemBERT</a>, <a href="../model_doc/canine">CANINE</a>, <a href="../model_doc/convbert">ConvBERT</a>, <a href="../model_doc/data2vec-text">Data2VecText</a>, <a href="../model_doc/deberta-v2">DeBERTa-v2</a>, <a href="../model_doc/distilbert">DistilBERT</a>, <a href="../model_doc/electra">ELECTRA</a>, <a href="../model_doc/ernie">ERNIE</a>, <a href="../model_doc/ernie_m">ErnieM</a>, <a href="../model_doc/flaubert">FlauBERT</a>, <a href="../model_doc/fnet">FNet</a>, <a href="../model_doc/funnel">Funnel Transformer</a>, <a href="../model_doc/ibert">I-BERT</a>, <a href="../model_doc/longformer">Longformer</a>, <a href="../model_doc/luke">LUKE</a>, <a href="../model_doc/mega">MEGA</a>, <a href="../model_doc/megatron-bert">Megatron-BERT</a>, <a href="../model_doc/mobilebert">MobileBERT</a>, <a href="../model_doc/mpnet">MPNet</a>, <a href="../model_doc/mra">MRA</a>, <a href="../model_doc/nezha">Nezha</a>, <a href="../model_doc/nystromformer">Nyströmformer</a>, <a href="../model_doc/qdqbert">QDQBert</a>, <a href="../model_doc/rembert">RemBERT</a>, <a href="../model_doc/roberta">RoBERTa</a>, <a href="../model_doc/roberta-prelayernorm">RoBERTa-PreLayerNorm</a>, <a href="../model_doc/roc_bert">RoCBert</a>, <a href="../model_doc/roformer">RoFormer</a>, <a href="../model_doc/squeezebert">SqueezeBERT</a>, <a href="../model_doc/xlm">XLM</a>, <a href="../model_doc/xlm-roberta">XLM-RoBERTa</a>, <a href="../model_doc/xlm-roberta-xl">XLM-RoBERTa-XL</a>, <a href="../model_doc/xlnet">XLNet</a>, <a href="../model_doc/xmod">X-MOD</a>, <a href="../model_doc/yoso">YOSO</a>';return{c(){a=Gl(`このチュートリアルで説明するタスクは、次のモデル アーキテクチャでサポートされています。

`),c=J("p"),c.innerHTML=l},l(o){a=Rl(o,`このチュートリアルで説明するタスクは、次のモデル アーキテクチャでサポートされています。

`),c=b(o,"P",{"data-svelte-h":!0}),U(c)!=="svelte-nxrbbi"&&(c.innerHTML=l)},m(o,j){t(o,a,j),t(o,c,j)},p:ms,d(o){o&&(e(a),e(c))}}}function Yl(_){let a,c;return a=new R({props:{code:"ZnJvbSUyMGRhdGFjbGFzc2VzJTIwaW1wb3J0JTIwZGF0YWNsYXNzJTBBZnJvbSUyMHRyYW5zZm9ybWVycy50b2tlbml6YXRpb25fdXRpbHNfYmFzZSUyMGltcG9ydCUyMFByZVRyYWluZWRUb2tlbml6ZXJCYXNlJTJDJTIwUGFkZGluZ1N0cmF0ZWd5JTBBZnJvbSUyMHR5cGluZyUyMGltcG9ydCUyME9wdGlvbmFsJTJDJTIwVW5pb24lMEFpbXBvcnQlMjB0b3JjaCUwQSUwQSUwQSU0MGRhdGFjbGFzcyUwQWNsYXNzJTIwRGF0YUNvbGxhdG9yRm9yTXVsdGlwbGVDaG9pY2UlM0ElMEElMjAlMjAlMjAlMjAlMjIlMjIlMjIlMEElMjAlMjAlMjAlMjBEYXRhJTIwY29sbGF0b3IlMjB0aGF0JTIwd2lsbCUyMGR5bmFtaWNhbGx5JTIwcGFkJTIwdGhlJTIwaW5wdXRzJTIwZm9yJTIwbXVsdGlwbGUlMjBjaG9pY2UlMjByZWNlaXZlZC4lMEElMjAlMjAlMj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RjaF9zaXplJTJDJTIwbnVtX2Nob2ljZXMlMkMlMjAtMSklMjBmb3IlMjBrJTJDJTIwdiUyMGluJTIwYmF0Y2guaXRlbXMoKSU3RCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGJhdGNoJTVCJTIybGFiZWxzJTIyJTVEJTIwJTNEJTIwdG9yY2gudGVuc29yKGxhYmVscyUyQyUyMGR0eXBlJTNEdG9yY2guaW50NjQpJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcmV0dXJuJTIwYmF0Y2g=",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`,wrap:!1}}),{c(){y(a.$$.fragment)},l(l){h(a.$$.fragment,l)},m(l,o){d(a,l,o),c=!0},p:ms,i(l){c||(f(a.$$.fragment,l),c=!0)},o(l){u(a.$$.fragment,l),c=!1},d(l){w(a,l)}}}function Fl(_){let a,c;return a=new As({props:{$$slots:{default:[Yl]},$$scope:{ctx:_}}}),{c(){y(a.$$.fragment)},l(l){h(a.$$.fragment,l)},m(l,o){d(a,l,o),c=!0},p(l,o){const j={};o&2&&(j.$$scope={dirty:o,ctx:l}),a.$set(j)},i(l){c||(f(a.$$.fragment,l),c=!0)},o(l){u(a.$$.fragment,l),c=!1},d(l){w(a,l)}}}function Nl(_){let a,c;return a=new R({props:{code:"ZnJvbSUyMGRhdGFjbGFzc2VzJTIwaW1wb3J0JTIwZGF0YWNsYXNzJTBBZnJvbSUyMHRyYW5zZm9ybWVycy50b2tlbml6YXRpb25fdXRpbHNfYmFzZSUyMGltcG9ydCUyMFByZVRyYWluZWRUb2tlbml6ZXJCYXNlJTJDJTIwUGFkZGluZ1N0cmF0ZWd5JTBBZnJvbSUyMHR5cGluZyUyMGltcG9ydCUyME9wdGlvbmFsJTJDJTIwVW5pb24lMEFpbXBvcnQlMjB0ZW5zb3JmbG93JTIwYXMlMjB0ZiUwQSUwQSUwQSU0MGRhdGFjbGFzcyUwQWNsYXNzJTIwRGF0YUNvbGxhdG9yRm9yTXVsdGlwbGVDaG9pY2UlM0ElMEElMjAlMjAlMjAlMjAlMjIlMjIlMjIlMEElMjAlMjAlMjAlMjBEYXRhJTIwY29sbGF0b3IlMjB0aGF0JTIwd2lsbCUyMGR5bmFtaWNhbGx5JTIwcGFkJTIwdGhlJTIwaW5wdXRzJTIwZm9yJTIwbXVsdGlwbGUlMjBjaG9pY2UlMjByZWNlaXZlZC4lMEElMjAlMjA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2hhcGUodiUyQyUyMChiYXRjaF9zaXplJTJDJTIwbnVtX2Nob2ljZXMlMkMlMjAtMSkpJTIwZm9yJTIwayUyQyUyMHYlMjBpbiUyMGJhdGNoLml0ZW1zKCklN0QlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBiYXRjaCU1QiUyMmxhYmVscyUyMiU1RCUyMCUzRCUyMHRmLmNvbnZlcnRfdG9fdGVuc29yKGxhYmVscyUyQyUyMGR0eXBlJTNEdGYuaW50NjQpJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcmV0dXJuJTIwYmF0Y2g=",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`,wrap:!1}}),{c(){y(a.$$.fragment)},l(l){h(a.$$.fragment,l)},m(l,o){d(a,l,o),c=!0},p:ms,i(l){c||(f(a.$$.fragment,l),c=!0)},o(l){u(a.$$.fragment,l),c=!1},d(l){w(a,l)}}}function zl(_){let a,c;return a=new As({props:{$$slots:{default:[Nl]},$$scope:{ctx:_}}}),{c(){y(a.$$.fragment)},l(l){h(a.$$.fragment,l)},m(l,o){d(a,l,o),c=!0},p(l,o){const j={};o&2&&(j.$$scope={dirty:o,ctx:l}),a.$set(j)},i(l){c||(f(a.$$.fragment,l),c=!0)},o(l){u(a.$$.fragment,l),c=!1},d(l){w(a,l)}}}function Ql(_){let a,c='<a href="/docs/transformers/v4.39.2/ja/main_classes/trainer#transformers.Trainer">Trainer</a> を使用したモデルの微調整に慣れていない場合は、<a href="../training#train-with-pytorch-trainer">ここ</a> の基本的なチュートリアルをご覧ください。';return{c(){a=J("p"),a.innerHTML=c},l(l){a=b(l,"P",{"data-svelte-h":!0}),U(a)!=="svelte-1sqpyut"&&(a.innerHTML=c)},m(l,o){t(l,a,o)},p:ms,d(l){l&&e(a)}}}function Hl(_){let a,c,l,o='これでモデルのトレーニングを開始する準備が整いました。 <a href="/docs/transformers/v4.39.2/ja/model_doc/auto#transformers.AutoModelForMultipleChoice">AutoModelForMultipleChoice</a> を使用して BERT をロードします。',j,C,B,I,Z="この時点で残っている手順は次の 3 つだけです。",X,k,A='<li><a href="/docs/transformers/v4.39.2/ja/main_classes/trainer#transformers.TrainingArguments">TrainingArguments</a> でトレーニング ハイパーパラメータを定義します。唯一の必須パラメータは、モデルの保存場所を指定する <code>output_dir</code> です。 <code>push_to_hub=True</code>を設定して、このモデルをハブにプッシュします (モデルをアップロードするには、Hugging Face にサインインする必要があります)。各エポックの終了時に、<a href="/docs/transformers/v4.39.2/ja/main_classes/trainer#transformers.Trainer">Trainer</a> は精度を評価し、トレーニング チェックポイントを保存します。</li> <li>トレーニング引数を、モデル、データセット、トークナイザー、データ照合器、および <code>compute_metrics</code> 関数とともに <a href="/docs/transformers/v4.39.2/ja/main_classes/trainer#transformers.Trainer">Trainer</a> に渡します。</li> <li><a href="/docs/transformers/v4.39.2/ja/main_classes/trainer#transformers.Trainer.train">train()</a> を呼び出してモデルを微調整します。</li>',W,$,G,r,g='トレーニングが完了したら、 <a href="/docs/transformers/v4.39.2/ja/main_classes/trainer#transformers.Trainer.push_to_hub">push_to_hub()</a> メソッドを使用してモデルをハブに共有し、誰もがモデルを使用できますように。',v,Y,E;return a=new ol({props:{$$slots:{default:[Ql]},$$scope:{ctx:_}}}),C=new R({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvck11bHRpcGxlQ2hvaWNlJTJDJTIwVHJhaW5pbmdBcmd1bWVudHMlMkMlMjBUcmFpbmVyJTBBJTBBbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JNdWx0aXBsZUNob2ljZS5mcm9tX3ByZXRyYWluZWQoJTIyZ29vZ2xlLWJlcnQlMkZiZXJ0LWJhc2UtdW5jYXNlZCUyMik=",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;google-bert/bert-base-uncased&quot;</span>)`,wrap:!1}}),$=new R({props:{code:"dHJhaW5pbmdfYXJncyUyMCUzRCUyMFRyYWluaW5nQXJndW1lbnRzKCUwQSUyMCUyMCUyMCUyMG91dHB1dF9kaXIlM0QlMjJteV9hd2Vzb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wdXRlX21ldHJpY3MlM0Rjb21wdXRlX21ldHJpY3MlMkMlMEEpJTBBJTBBdHJhaW5lci50cmFpbigp",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()`,wrap:!1}}),Y=new R({props:{code:"dHJhaW5lci5wdXNoX3RvX2h1Yigp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>trainer.push_to_hub()',wrap:!1}}),{c(){y(a.$$.fragment),c=M(),l=J("p"),l.innerHTML=o,j=M(),y(C.$$.fragment),B=M(),I=J("p"),I.textContent=Z,X=M(),k=J("ol"),k.innerHTML=A,W=M(),y($.$$.fragment),G=M(),r=J("p"),r.innerHTML=g,v=M(),y(Y.$$.fragment)},l(i){h(a.$$.fragment,i),c=m(i),l=b(i,"P",{"data-svelte-h":!0}),U(l)!=="svelte-1g2069p"&&(l.innerHTML=o),j=m(i),h(C.$$.fragment,i),B=m(i),I=b(i,"P",{"data-svelte-h":!0}),U(I)!=="svelte-1j8bgyv"&&(I.textContent=Z),X=m(i),k=b(i,"OL",{"data-svelte-h":!0}),U(k)!=="svelte-f736p4"&&(k.innerHTML=A),W=m(i),h($.$$.fragment,i),G=m(i),r=b(i,"P",{"data-svelte-h":!0}),U(r)!=="svelte-x1kfme"&&(r.innerHTML=g),v=m(i),h(Y.$$.fragment,i)},m(i,V){d(a,i,V),t(i,c,V),t(i,l,V),t(i,j,V),d(C,i,V),t(i,B,V),t(i,I,V),t(i,X,V),t(i,k,V),t(i,W,V),d($,i,V),t(i,G,V),t(i,r,V),t(i,v,V),d(Y,i,V),E=!0},p(i,V){const x={};V&2&&(x.$$scope={dirty:V,ctx:i}),a.$set(x)},i(i){E||(f(a.$$.fragment,i),f(C.$$.fragment,i),f($.$$.fragment,i),f(Y.$$.fragment,i),E=!0)},o(i){u(a.$$.fragment,i),u(C.$$.fragment,i),u($.$$.fragment,i),u(Y.$$.fragment,i),E=!1},d(i){i&&(e(c),e(l),e(j),e(B),e(I),e(X),e(k),e(W),e(G),e(r),e(v)),w(a,i),w(C,i),w($,i),w(Y,i)}}}function Sl(_){let a,c;return a=new As({props:{$$slots:{default:[Hl]},$$scope:{ctx:_}}}),{c(){y(a.$$.fragment)},l(l){h(a.$$.fragment,l)},m(l,o){d(a,l,o),c=!0},p(l,o){const j={};o&2&&(j.$$scope={dirty:o,ctx:l}),a.$set(j)},i(l){c||(f(a.$$.fragment,l),c=!0)},o(l){u(a.$$.fragment,l),c=!1},d(l){w(a,l)}}}function ql(_){let a,c='Keras を使用したモデルの微調整に慣れていない場合は、<a href="../training#train-a-tensorflow-model-with-keras">こちら</a> の基本的なチュートリアルをご覧ください。';return{c(){a=J("p"),a.innerHTML=c},l(l){a=b(l,"P",{"data-svelte-h":!0}),U(a)!=="svelte-1jwo7q8"&&(a.innerHTML=c)},m(l,o){t(l,a,o)},p:ms,d(l){l&&e(a)}}}function Ll(_){let a,c,l,o,j,C='次に、<a href="/docs/transformers/v4.39.2/ja/model_doc/auto#transformers.TFAutoModelForMultipleChoice">TFAutoModelForMultipleChoice</a> を使用して BERT をロードできます。',B,I,Z,X,k='<a href="/docs/transformers/v4.39.2/ja/main_classes/model#transformers.TFPreTrainedModel.prepare_tf_dataset">prepare_tf_dataset()</a> を使用して、データセットを <code>tf.data.Dataset</code> 形式に変換します。',A,W,$,G,r='<a href="https://keras.io/api/models/model_training_apis/#compile-method" rel="nofollow"><code>compile</code></a> を使用してトレーニング用のモデルを設定します。 Transformers モデルにはすべてデフォルトのタスク関連の損失関数があるため、次の場合を除き、損失関数を指定する必要はないことに注意してください。',g,v,Y,E,i='トレーニングを開始する前にセットアップする最後の 2 つのことは、予測から精度を計算することと、モデルをハブにプッシュする方法を提供することです。どちらも <a href="../main_classes/keras_callbacks">Keras コールバック</a> を使用して行われます。',V,x,os='<code>compute_metrics</code> 関数を <a href="/docs/transformers/v4.39.2/ja/main_classes/keras_callbacks#transformers.KerasMetricCallback">KerasMetricCallback</a> に渡します。',N,ss,ns,F,is='<a href="/docs/transformers/v4.39.2/ja/main_classes/keras_callbacks#transformers.PushToHubCallback">PushToHubCallback</a> でモデルとトークナイザーをプッシュする場所を指定します。',z,Q,H,ls,js="次に、コールバックをまとめてバンドルします。",S,q,L,as,ys='ついに、モデルのトレーニングを開始する準備が整いました。トレーニングおよび検証データセット、エポック数、コールバックを指定して <a href="https://keras.io/api/models/model_training_apis/#fit-method" rel="nofollow"><code>fit</code></a> を呼び出し、モデルを微調整します。',D,P,K,es,hs="トレーニングが完了すると、モデルは自動的にハブにアップロードされ、誰でも使用できるようになります。",O;return a=new ol({props:{$$slots:{default:[ql]},$$scope:{ctx:_}}}),l=new R({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMGNyZWF0ZV9vcHRpbWl6ZXIlMEElMEFiYXRjaF9zaXplJTIwJTNEJTIwMTYlMEFudW1fdHJhaW5fZXBvY2hzJTIwJTNEJTIwMiUwQXRvdGFsX3RyYWluX3N0ZXBzJTIwJTNEJTIwKGxlbih0b2tlbml6ZWRfc3dhZyU1QiUyMnRyYWluJTIyJTVEKSUyMCUyRiUyRiUyMGJhdGNoX3NpemUpJTIwKiUyMG51bV90cmFpbl9lcG9jaHMlMEFvcHRpbWl6ZXIlMkMlMjBzY2hlZHVsZSUyMCUzRCUyMGNyZWF0ZV9vcHRpbWl6ZXIoaW5pdF9sciUzRDVlLTUlMkMlMjBudW1fd2FybXVwX3N0ZXBzJTNEMCUyQyUyMG51bV90cmFpbl9zdGVwcyUzRHRvdGFsX3RyYWluX3N0ZXBzKQ==",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)`,wrap:!1}}),I=new R({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGQXV0b01vZGVsRm9yTXVsdGlwbGVDaG9pY2UlMEElMEFtb2RlbCUyMCUzRCUyMFRGQXV0b01vZGVsRm9yTXVsdGlwbGVDaG9pY2UuZnJvbV9wcmV0cmFpbmVkKCUyMmdvb2dsZS1iZXJ0JTJGYmVydC1iYXNlLXVuY2FzZWQlMjIp",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;google-bert/bert-base-uncased&quot;</span>)`,wrap:!1}}),W=new R({props:{code:"ZGF0YV9jb2xsYXRvciUyMCUzRCUyMERhdGFDb2xsYXRvckZvck11bHRpcGxlQ2hvaWNlKHRva2VuaXplciUzRHRva2VuaXplciklMEF0Zl90cmFpbl9zZXQlMjAlM0QlMjBtb2RlbC5wcmVwYXJlX3RmX2RhdGFzZXQoJTBBJTIwJTIwJTIwJTIwdG9rZW5pemVkX3N3YWclNUIlMjJ0cmFpbiUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMHNodWZmbGUlM0RUcnVlJTJDJTBBJTIwJTIwJTIwJTIwYmF0Y2hfc2l6ZSUzRGJhdGNoX3NpemUlMkMlMEElMjAlMjAlMjAlMjBjb2xsYXRlX2ZuJTNEZGF0YV9jb2xsYXRvciUyQyUwQSklMEElMEF0Zl92YWxpZGF0aW9uX3NldCUyMCUzRCUyMG1vZGVsLnByZXBhcmVfdGZfZGF0YXNldCglMEElMjAlMjAlMjAlMjB0b2tlbml6ZWRfc3dhZyU1QiUyMnZhbGlkYXRpb24lMjIlNUQlMkMlMEElMjAlMjAlMjAlMjBzaHVmZmxlJTNERmFsc2UlMkMlMEElMjAlMjAlMjAlMjBiYXRjaF9zaXplJTNEYmF0Y2hfc2l6ZSUyQyUwQSUyMCUyMCUyMCUyMGNvbGxhdGVfZm4lM0RkYXRhX2NvbGxhdG9yJTJDJTBBKQ==",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>)`,wrap:!1}}),v=new R({props:{code:"bW9kZWwuY29tcGlsZShvcHRpbWl6ZXIlM0RvcHRpbWl6ZXIpJTIwJTIwJTIzJTIwTm8lMjBsb3NzJTIwYXJndW1lbnQh",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>model.<span class="hljs-built_in">compile</span>(optimizer=optimizer)  <span class="hljs-comment"># No loss argument!</span>',wrap:!1}}),ss=new R({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycy5rZXJhc19jYWxsYmFja3MlMjBpbXBvcnQlMjBLZXJhc01ldHJpY0NhbGxiYWNrJTBBJTBBbWV0cmljX2NhbGxiYWNrJTIwJTNEJTIwS2VyYXNNZXRyaWNDYWxsYmFjayhtZXRyaWNfZm4lM0Rjb21wdXRlX21ldHJpY3MlMkMlMjBldmFsX2RhdGFzZXQlM0R0Zl92YWxpZGF0aW9uX3NldCk=",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)`,wrap:!1}}),Q=new R({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycy5rZXJhc19jYWxsYmFja3MlMjBpbXBvcnQlMjBQdXNoVG9IdWJDYWxsYmFjayUwQSUwQXB1c2hfdG9faHViX2NhbGxiYWNrJTIwJTNEJTIwUHVzaFRvSHViQ2FsbGJhY2soJTBBJTIwJTIwJTIwJTIwb3V0cHV0X2RpciUzRCUyMm15X2F3ZXNvbWVfbW9kZWwlMjIlMkMlMEElMjAlMjAlMjAlMjB0b2tlbml6ZXIlM0R0b2tlbml6ZXIlMkMlMEEp",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>)`,wrap:!1}}),q=new R({props:{code:"Y2FsbGJhY2tzJTIwJTNEJTIwJTVCbWV0cmljX2NhbGxiYWNrJTJDJTIwcHVzaF90b19odWJfY2FsbGJhY2slNUQ=",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>callbacks = [metric_callback, push_to_hub_callback]',wrap:!1}}),P=new R({props:{code:"bW9kZWwuZml0KHglM0R0Zl90cmFpbl9zZXQlMkMlMjB2YWxpZGF0aW9uX2RhdGElM0R0Zl92YWxpZGF0aW9uX3NldCUyQyUyMGVwb2NocyUzRDIlMkMlMjBjYWxsYmFja3MlM0RjYWxsYmFja3Mp",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)',wrap:!1}}),{c(){y(a.$$.fragment),c=Gl(`
TensorFlow でモデルを微調整するには、オプティマイザー関数、学習率スケジュール、およびいくつかのトレーニング ハイパーパラメーターをセットアップすることから始めます。

	`),y(l.$$.fragment),o=M(),j=J("p"),j.innerHTML=C,B=M(),y(I.$$.fragment),Z=M(),X=J("p"),X.innerHTML=k,A=M(),y(W.$$.fragment),$=M(),G=J("p"),G.innerHTML=r,g=M(),y(v.$$.fragment),Y=M(),E=J("p"),E.innerHTML=i,V=M(),x=J("p"),x.innerHTML=os,N=M(),y(ss.$$.fragment),ns=M(),F=J("p"),F.innerHTML=is,z=M(),y(Q.$$.fragment),H=M(),ls=J("p"),ls.textContent=js,S=M(),y(q.$$.fragment),L=M(),as=J("p"),as.innerHTML=ys,D=M(),y(P.$$.fragment),K=M(),es=J("p"),es.textContent=hs},l(n){h(a.$$.fragment,n),c=Rl(n,`
TensorFlow でモデルを微調整するには、オプティマイザー関数、学習率スケジュール、およびいくつかのトレーニング ハイパーパラメーターをセットアップすることから始めます。

	`),h(l.$$.fragment,n),o=m(n),j=b(n,"P",{"data-svelte-h":!0}),U(j)!=="svelte-15ony3i"&&(j.innerHTML=C),B=m(n),h(I.$$.fragment,n),Z=m(n),X=b(n,"P",{"data-svelte-h":!0}),U(X)!=="svelte-yz999t"&&(X.innerHTML=k),A=m(n),h(W.$$.fragment,n),$=m(n),G=b(n,"P",{"data-svelte-h":!0}),U(G)!=="svelte-1pd5few"&&(G.innerHTML=r),g=m(n),h(v.$$.fragment,n),Y=m(n),E=b(n,"P",{"data-svelte-h":!0}),U(E)!=="svelte-16n7r85"&&(E.innerHTML=i),V=m(n),x=b(n,"P",{"data-svelte-h":!0}),U(x)!=="svelte-1ua3o67"&&(x.innerHTML=os),N=m(n),h(ss.$$.fragment,n),ns=m(n),F=b(n,"P",{"data-svelte-h":!0}),U(F)!=="svelte-1kbimay"&&(F.innerHTML=is),z=m(n),h(Q.$$.fragment,n),H=m(n),ls=b(n,"P",{"data-svelte-h":!0}),U(ls)!=="svelte-r16oc5"&&(ls.textContent=js),S=m(n),h(q.$$.fragment,n),L=m(n),as=b(n,"P",{"data-svelte-h":!0}),U(as)!=="svelte-ffgub5"&&(as.innerHTML=ys),D=m(n),h(P.$$.fragment,n),K=m(n),es=b(n,"P",{"data-svelte-h":!0}),U(es)!=="svelte-vh7z0v"&&(es.textContent=hs)},m(n,T){d(a,n,T),t(n,c,T),d(l,n,T),t(n,o,T),t(n,j,T),t(n,B,T),d(I,n,T),t(n,Z,T),t(n,X,T),t(n,A,T),d(W,n,T),t(n,$,T),t(n,G,T),t(n,g,T),d(v,n,T),t(n,Y,T),t(n,E,T),t(n,V,T),t(n,x,T),t(n,N,T),d(ss,n,T),t(n,ns,T),t(n,F,T),t(n,z,T),d(Q,n,T),t(n,H,T),t(n,ls,T),t(n,S,T),d(q,n,T),t(n,L,T),t(n,as,T),t(n,D,T),d(P,n,T),t(n,K,T),t(n,es,T),O=!0},p(n,T){const ts={};T&2&&(ts.$$scope={dirty:T,ctx:n}),a.$set(ts)},i(n){O||(f(a.$$.fragment,n),f(l.$$.fragment,n),f(I.$$.fragment,n),f(W.$$.fragment,n),f(v.$$.fragment,n),f(ss.$$.fragment,n),f(Q.$$.fragment,n),f(q.$$.fragment,n),f(P.$$.fragment,n),O=!0)},o(n){u(a.$$.fragment,n),u(l.$$.fragment,n),u(I.$$.fragment,n),u(W.$$.fragment,n),u(v.$$.fragment,n),u(ss.$$.fragment,n),u(Q.$$.fragment,n),u(q.$$.fragment,n),u(P.$$.fragment,n),O=!1},d(n){n&&(e(c),e(o),e(j),e(B),e(Z),e(X),e(A),e($),e(G),e(g),e(Y),e(E),e(V),e(x),e(N),e(ns),e(F),e(z),e(H),e(ls),e(S),e(L),e(as),e(D),e(K),e(es)),w(a,n),w(l,n),w(I,n),w(W,n),w(v,n),w(ss,n),w(Q,n),w(q,n),w(P,n)}}}function Dl(_){let a,c;return a=new As({props:{$$slots:{default:[Ll]},$$scope:{ctx:_}}}),{c(){y(a.$$.fragment)},l(l){h(a.$$.fragment,l)},m(l,o){d(a,l,o),c=!0},p(l,o){const j={};o&2&&(j.$$scope={dirty:o,ctx:l}),a.$set(j)},i(l){c||(f(a.$$.fragment,l),c=!0)},o(l){u(a.$$.fragment,l),c=!1},d(l){w(a,l)}}}function Pl(_){let a,c=`複数選択用にモデルを微調整する方法の詳細な例については、対応するセクションを参照してください。
<a href="https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/multiple_choice.ipynb" rel="nofollow">PyTorch ノートブック</a>
または <a href="https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/multiple_choice-tf.ipynb" rel="nofollow">TensorFlow ノートブック</a>。`;return{c(){a=J("p"),a.innerHTML=c},l(l){a=b(l,"P",{"data-svelte-h":!0}),U(a)!=="svelte-qfa40k"&&(a.innerHTML=c)},m(l,o){t(l,a,o)},p:ms,d(l){l&&e(a)}}}function Kl(_){let a,c="各プロンプトと回答候補のペアをトークン化し、PyTorch テンソルを返します。いくつかの<code>lables</code>も作成する必要があります。",l,o,j,C,B="入力とラベルをモデルに渡し、<code>logits</code>を返します。",I,Z,X,k,A="最も高い確率でクラスを取得します。",W,$,G;return o=new R({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJteV9hd2Vzb21lX3N3YWdfbW9kZWwlMjIpJTBBaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKCU1QiU1QnByb21wdCUyQyUyMGNhbmRpZGF0ZTElNUQlMkMlMjAlNUJwcm9tcHQlMkMlMjBjYW5kaWRhdGUyJTVEJTVEJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiUyQyUyMHBhZGRpbmclM0RUcnVlKSUwQWxhYmVscyUyMCUzRCUyMHRvcmNoLnRlbnNvcigwKS51bnNxdWVlemUoMCk=",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>)`,wrap:!1}}),Z=new R({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvck11bHRpcGxlQ2hvaWNlJTBBJTBBbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JNdWx0aXBsZUNob2ljZS5mcm9tX3ByZXRyYWluZWQoJTIybXlfYXdlc29tZV9zd2FnX21vZGVsJTIyKSUwQW91dHB1dHMlMjAlM0QlMjBtb2RlbCgqKiU3QmslM0ElMjB2LnVuc3F1ZWV6ZSgwKSUyMGZvciUyMGslMkMlMjB2JTIwaW4lMjBpbnB1dHMuaXRlbXMoKSU3RCUyQyUyMGxhYmVscyUzRGxhYmVscyklMEFsb2dpdHMlMjAlM0QlMjBvdXRwdXRzLmxvZ2l0cw==",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`,wrap:!1}}),$=new R({props:{code:"cHJlZGljdGVkX2NsYXNzJTIwJTNEJTIwbG9naXRzLmFyZ21heCgpLml0ZW0oKSUwQXByZWRpY3RlZF9jbGFzcw==",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>`,wrap:!1}}),{c(){a=J("p"),a.innerHTML=c,l=M(),y(o.$$.fragment),j=M(),C=J("p"),C.innerHTML=B,I=M(),y(Z.$$.fragment),X=M(),k=J("p"),k.textContent=A,W=M(),y($.$$.fragment)},l(r){a=b(r,"P",{"data-svelte-h":!0}),U(a)!=="svelte-zbyraq"&&(a.innerHTML=c),l=m(r),h(o.$$.fragment,r),j=m(r),C=b(r,"P",{"data-svelte-h":!0}),U(C)!=="svelte-3ueqnu"&&(C.innerHTML=B),I=m(r),h(Z.$$.fragment,r),X=m(r),k=b(r,"P",{"data-svelte-h":!0}),U(k)!=="svelte-yua5rw"&&(k.textContent=A),W=m(r),h($.$$.fragment,r)},m(r,g){t(r,a,g),t(r,l,g),d(o,r,g),t(r,j,g),t(r,C,g),t(r,I,g),d(Z,r,g),t(r,X,g),t(r,k,g),t(r,W,g),d($,r,g),G=!0},p:ms,i(r){G||(f(o.$$.fragment,r),f(Z.$$.fragment,r),f($.$$.fragment,r),G=!0)},o(r){u(o.$$.fragment,r),u(Z.$$.fragment,r),u($.$$.fragment,r),G=!1},d(r){r&&(e(a),e(l),e(j),e(C),e(I),e(X),e(k),e(W)),w(o,r),w(Z,r),w($,r)}}}function Ol(_){let a,c;return a=new As({props:{$$slots:{default:[Kl]},$$scope:{ctx:_}}}),{c(){y(a.$$.fragment)},l(l){h(a.$$.fragment,l)},m(l,o){d(a,l,o),c=!0},p(l,o){const j={};o&2&&(j.$$scope={dirty:o,ctx:l}),a.$set(j)},i(l){c||(f(a.$$.fragment,l),c=!0)},o(l){u(a.$$.fragment,l),c=!1},d(l){w(a,l)}}}function sa(_){let a,c="各プロンプトと回答候補のペアをトークン化し、TensorFlow テンソルを返します。",l,o,j,C,B="入力をモデルに渡し、<code>logits</code>を返します。",I,Z,X,k,A="最も高い確率でクラスを取得します。",W,$,G;return o=new R({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJteV9hd2Vzb21lX3N3YWdfbW9kZWwlMjIpJTBBaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKCU1QiU1QnByb21wdCUyQyUyMGNhbmRpZGF0ZTElNUQlMkMlMjAlNUJwcm9tcHQlMkMlMjBjYW5kaWRhdGUyJTVEJTVEJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJ0ZiUyMiUyQyUyMHBhZGRpbmclM0RUcnVlKQ==",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>)`,wrap:!1}}),Z=new R({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGQXV0b01vZGVsRm9yTXVsdGlwbGVDaG9pY2UlMEElMEFtb2RlbCUyMCUzRCUyMFRGQXV0b01vZGVsRm9yTXVsdGlwbGVDaG9pY2UuZnJvbV9wcmV0cmFpbmVkKCUyMm15X2F3ZXNvbWVfc3dhZ19tb2RlbCUyMiklMEFpbnB1dHMlMjAlM0QlMjAlN0JrJTNBJTIwdGYuZXhwYW5kX2RpbXModiUyQyUyMDApJTIwZm9yJTIwayUyQyUyMHYlMjBpbiUyMGlucHV0cy5pdGVtcygpJTdEJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsKGlucHV0cyklMEFsb2dpdHMlMjAlM0QlMjBvdXRwdXRzLmxvZ2l0cw==",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`,wrap:!1}}),$=new R({props:{code:"cHJlZGljdGVkX2NsYXNzJTIwJTNEJTIwaW50KHRmLm1hdGguYXJnbWF4KGxvZ2l0cyUyQyUyMGF4aXMlM0QtMSklNUIwJTVEKSUwQXByZWRpY3RlZF9jbGFzcw==",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>`,wrap:!1}}),{c(){a=J("p"),a.textContent=c,l=M(),y(o.$$.fragment),j=M(),C=J("p"),C.innerHTML=B,I=M(),y(Z.$$.fragment),X=M(),k=J("p"),k.textContent=A,W=M(),y($.$$.fragment)},l(r){a=b(r,"P",{"data-svelte-h":!0}),U(a)!=="svelte-fvrqfh"&&(a.textContent=c),l=m(r),h(o.$$.fragment,r),j=m(r),C=b(r,"P",{"data-svelte-h":!0}),U(C)!=="svelte-1rvunpz"&&(C.innerHTML=B),I=m(r),h(Z.$$.fragment,r),X=m(r),k=b(r,"P",{"data-svelte-h":!0}),U(k)!=="svelte-yua5rw"&&(k.textContent=A),W=m(r),h($.$$.fragment,r)},m(r,g){t(r,a,g),t(r,l,g),d(o,r,g),t(r,j,g),t(r,C,g),t(r,I,g),d(Z,r,g),t(r,X,g),t(r,k,g),t(r,W,g),d($,r,g),G=!0},p:ms,i(r){G||(f(o.$$.fragment,r),f(Z.$$.fragment,r),f($.$$.fragment,r),G=!0)},o(r){u(o.$$.fragment,r),u(Z.$$.fragment,r),u($.$$.fragment,r),G=!1},d(r){r&&(e(a),e(l),e(j),e(C),e(I),e(X),e(k),e(W)),w(o,r),w(Z,r),w($,r)}}}function la(_){let a,c;return a=new As({props:{$$slots:{default:[sa]},$$scope:{ctx:_}}}),{c(){y(a.$$.fragment)},l(l){h(a.$$.fragment,l)},m(l,o){d(a,l,o),c=!0},p(l,o){const j={};o&2&&(j.$$scope={dirty:o,ctx:l}),a.$set(j)},i(l){c||(f(a.$$.fragment,l),c=!0)},o(l){u(a.$$.fragment,l),c=!1},d(l){w(a,l)}}}function aa(_){let a,c,l,o,j,C,B,I,Z,X="多肢選択タスクは質問応答に似ていますが、いくつかの候補の回答がコンテキストとともに提供され、正しい回答を選択するようにモデルがトレーニングされる点が異なります。",k,A,W="このガイドでは、次の方法を説明します。",$,G,r='<li><a href="https://huggingface.co/datasets/swag" rel="nofollow">SWAG</a> データセットの「通常」構成で <a href="https://huggingface.co/google-bert/bert-base-uncased" rel="nofollow">BERT</a> を微調整して、最適なデータセットを選択します複数の選択肢と何らかのコンテキストを考慮して回答します。</li> <li>微調整したモデルを推論に使用します。</li>',g,v,Y,E,i="始める前に、必要なライブラリがすべてインストールされていることを確認してください。",V,x,os,N,ss="モデルをアップロードしてコミュニティと共有できるように、Hugging Face アカウントにログインすることをお勧めします。プロンプトが表示されたら、トークンを入力してログインします。",ns,F,is,z,Q,H,ls="まず、🤗 データセット ライブラリから SWAG データセットの「通常」構成をロードします。",js,S,q,L,as="次に、例を見てみましょう。",ys,D,P,K,es="ここにはたくさんのフィールドがあるように見えますが、実際は非常に簡単です。",hs,O,n="<li><code>sent1</code> と <code>sent2</code>: これらのフィールドは文の始まりを示し、この 2 つを組み合わせると <code>startphrase</code> フィールドが得られます。</li> <li><code>ending</code>: 文の終わり方として考えられる終わり方を示唆しますが、正しいのは 1 つだけです。</li> <li><code>label</code>: 正しい文の終わりを識別します。</li>",T,ts,Es,ds,jl="次のステップでは、BERT トークナイザーをロードして、文の始まりと 4 つの可能な終わりを処理します。",xs,fs,Ys,us,yl="作成する前処理関数は次のことを行う必要があります。",Fs,ws,hl="<li><code>sent1</code> フィールドのコピーを 4 つ作成し、それぞれを <code>sent2</code> と組み合わせて文の始まりを再現します。</li> <li><code>sent2</code> を 4 つの可能な文末尾のそれぞれと組み合わせます。</li> <li>これら 2 つのリストをトークン化できるようにフラット化し、その後、各例に対応する <code>input_ids</code>、<code>attention_mask</code>、および <code>labels</code> フィールドが含まれるように非フラット化します。</li>",Ns,Js,zs,bs,dl="データセット全体に前処理関数を適用するには、🤗 Datasets <code>map</code> メソッドを使用します。 <code>batched=True</code> を設定してデータセットの複数の要素を一度に処理することで、<code>map</code> 関数を高速化できます。",Qs,Ts,Hs,Us,fl="🤗 Transformers には多肢選択用のデータ照合器がないため、<code>DataCollat​​orWithPadding</code> を調整してサンプルのバッチを作成する必要があります。データセット全体を最大長までパディングするのではなく、照合中にバッチ内の最長の長さまで文を <em>動的にパディング</em> する方が効率的です。",Ss,gs,ul="<code>DataCollat​​orForMultipleChoice</code> は、すべてのモデル入力を平坦化し、パディングを適用して、結果を非平坦化します。",qs,ps,Ls,$s,Ds,_s,wl='トレーニング中にメトリクスを含めると、多くの場合、モデルのパフォーマンスを評価するのに役立ちます。 🤗 <a href="https://huggingface.co/docs/evaluate/index" rel="nofollow">Evaluate</a> ライブラリを使用して、評価メソッドをすばやくロードできます。このタスクでは、<a href="https://huggingface.co/spaces/evaluate-metric/accuracy" rel="nofollow">accuracy</a> メトリクスを読み込みます (🤗 Evaluate <a href="https://huggingface.co/docs/evaluate/a_quick_tour" rel="nofollow">クイック ツアー</a> を参照してください) ) メトリクスの読み込みと計算方法の詳細については、次を参照してください)。',Ps,Cs,Ks,Zs,Jl="次に、予測とラベルを <code>compute</code> に渡して精度を計算する関数を作成します。",Os,ks,sl,Is,bl="これで<code>compute_metrics</code>関数の準備が整いました。トレーニングをセットアップするときにこの関数に戻ります。",ll,Gs,al,rs,el,cs,tl,Rs,nl,Vs,Tl="モデルを微調整したので、それを推論に使用できるようになりました。",pl,Xs,Ul="いくつかのテキストと 2 つの回答候補を考えてください。",rl,Ws,cl,Ms,Ml,vs,ml;return j=new Bs({props:{title:"Multiple choice",local:"multiple-choice",headingTag:"h1"}}),B=new El({props:{classNames:"absolute z-10 right-0 top-0",options:[{label:"Mixed",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/ja/multiple_choice.ipynb"},{label:"PyTorch",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/ja/pytorch/multiple_choice.ipynb"},{label:"TensorFlow",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/ja/tensorflow/multiple_choice.ipynb"},{label:"Mixed",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/ja/multiple_choice.ipynb"},{label:"PyTorch",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/ja/pytorch/multiple_choice.ipynb"},{label:"TensorFlow",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/ja/tensorflow/multiple_choice.ipynb"}]}}),v=new ol({props:{$$slots:{default:[xl]},$$scope:{ctx:_}}}),x=new R({props:{code:"cGlwJTIwaW5zdGFsbCUyMHRyYW5zZm9ybWVycyUyMGRhdGFzZXRzJTIwZXZhbHVhdGU=",highlighted:"pip install transformers datasets evaluate",wrap:!1}}),F=new R({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMG5vdGVib29rX2xvZ2luJTBBJTBBbm90ZWJvb2tfbG9naW4oKQ==",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()`,wrap:!1}}),z=new Bs({props:{title:"Load SWAG dataset",local:"load-swag-dataset",headingTag:"h2"}}),S=new R({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBJTBBc3dhZyUyMCUzRCUyMGxvYWRfZGF0YXNldCglMjJzd2FnJTIyJTJDJTIwJTIycmVndWxhciUyMik=",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>)`,wrap:!1}}),D=new R({props:{code:"c3dhZyU1QiUyMnRyYWluJTIyJTVEJTVCMCU1RA==",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>}`,wrap:!1}}),ts=new Bs({props:{title:"Preprocess",local:"preprocess",headingTag:"h2"}}),fs=new R({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJnb29nbGUtYmVydCUyRmJlcnQtYmFzZS11bmNhc2VkJTIyKQ==",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;google-bert/bert-base-uncased&quot;</span>)`,wrap:!1}}),Js=new R({props:{code:"ZW5kaW5nX25hbWVzJTIwJTNEJTIwJTVCJTIyZW5kaW5nMCUyMiUyQyUyMCUyMmVuZGluZzElMjIlMkMlMjAlMjJlbmRpbmcyJTIyJTJDJTIwJTIyZW5kaW5nMyUyMiU1RCUwQSUwQSUwQWRlZiUyMHByZXByb2Nlc3NfZnVuY3Rp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wbGVuKHYpJTJDJTIwNCklNUQlMjBmb3IlMjBrJTJDJTIwdiUyMGluJTIwdG9rZW5pemVkX2V4YW1wbGVzLml0ZW1zKCklN0Q=",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()}`,wrap:!1}}),Ts=new R({props:{code:"dG9rZW5pemVkX3N3YWclMjAlM0QlMjBzd2FnLm1hcChwcmVwcm9jZXNzX2Z1bmN0aW9uJTJDJTIwYmF0Y2hlZCUzRFRydWUp",highlighted:'tokenized_swag = swag.<span class="hljs-built_in">map</span>(preprocess_function, batched=<span class="hljs-literal">True</span>)',wrap:!1}}),ps=new il({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[zl],pytorch:[Fl]},$$scope:{ctx:_}}}),$s=new Bs({props:{title:"Evaluate",local:"evaluate",headingTag:"h2"}}),Cs=new R({props:{code:"aW1wb3J0JTIwZXZhbHVhdGUlMEElMEFhY2N1cmFjeSUyMCUzRCUyMGV2YWx1YXRlLmxvYWQoJTIyYWNjdXJhY3klMjIp",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>)`,wrap:!1}}),ks=new R({props:{code:"aW1wb3J0JTIwbnVtcHklMjBhcyUyMG5wJTBBJTBBJTBBZGVmJTIwY29tcHV0ZV9tZXRyaWNzKGV2YWxfcHJlZCklM0ElMEElMjAlMjAlMjAlMjBwcmVkaWN0aW9ucyUyQyUyMGxhYmVscyUyMCUzRCUyMGV2YWxfcHJlZCUwQSUyMCUyMCUyMCUyMHByZWRpY3Rpb25zJTIwJTNEJTIwbnAuYXJnbWF4KHByZWRpY3Rpb25zJTJDJTIwYXhpcyUzRDEpJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwYWNjdXJhY3kuY29tcHV0ZShwcmVkaWN0aW9ucyUzRHByZWRpY3Rpb25zJTJDJTIwcmVmZXJlbmNlcyUzRGxhYmVscyk=",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)`,wrap:!1}}),Gs=new Bs({props:{title:"Train",local:"train",headingTag:"h2"}}),rs=new il({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[Dl],pytorch:[Sl]},$$scope:{ctx:_}}}),cs=new ol({props:{$$slots:{default:[Pl]},$$scope:{ctx:_}}}),Rs=new Bs({props:{title:"Inference",local:"inference",headingTag:"h1"}}),Ws=new R({props:{code:"cHJvbXB0JTIwJTNEJTIwJTIyRnJhbmNlJTIwaGFzJTIwYSUyMGJyZWFkJTIwbGF3JTJDJTIwTGUlMjBEJUMzJUE5Y3JldCUyMFBhaW4lMkMlMjB3aXRoJTIwc3RyaWN0JTIwcnVsZXMlMjBvbiUyMHdoYXQlMjBpcyUyMGFsbG93ZWQlMjBpbiUyMGElMjB0cmFkaXRpb25hbCUyMGJhZ3VldHRlLiUyMiUwQWNhbmRpZGF0ZTElMjAlM0QlMjAlMjJUaGUlMjBsYXclMjBkb2VzJTIwbm90JTIwYXBwbHklMjB0byUyMGNyb2lzc2FudHMlMjBhbmQlMjBicmlvY2hlLiUyMiUwQWNhbmRpZGF0ZTIlMjAlM0QlMjAlMjJUaGUlMjBsYXclMjBhcHBsaWVzJTIwdG8lMjBiYWd1ZXR0ZXMuJTIy",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>prompt = <span class="hljs-string">&quot;France has a bread law, Le Décret 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>`,wrap:!1}}),Ms=new il({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[la],pytorch:[Ol]},$$scope:{ctx:_}}}),{c(){a=J("meta"),c=M(),l=J("p"),o=M(),y(j.$$.fragment),C=M(),y(B.$$.fragment),I=M(),Z=J("p"),Z.textContent=X,k=M(),A=J("p"),A.textContent=W,$=M(),G=J("ol"),G.innerHTML=r,g=M(),y(v.$$.fragment),Y=M(),E=J("p"),E.textContent=i,V=M(),y(x.$$.fragment),os=M(),N=J("p"),N.textContent=ss,ns=M(),y(F.$$.fragment),is=M(),y(z.$$.fragment),Q=M(),H=J("p"),H.textContent=ls,js=M(),y(S.$$.fragment),q=M(),L=J("p"),L.textContent=as,ys=M(),y(D.$$.fragment),P=M(),K=J("p"),K.textContent=es,hs=M(),O=J("ul"),O.innerHTML=n,T=M(),y(ts.$$.fragment),Es=M(),ds=J("p"),ds.textContent=jl,xs=M(),y(fs.$$.fragment),Ys=M(),us=J("p"),us.textContent=yl,Fs=M(),ws=J("ol"),ws.innerHTML=hl,Ns=M(),y(Js.$$.fragment),zs=M(),bs=J("p"),bs.innerHTML=dl,Qs=M(),y(Ts.$$.fragment),Hs=M(),Us=J("p"),Us.innerHTML=fl,Ss=M(),gs=J("p"),gs.innerHTML=ul,qs=M(),y(ps.$$.fragment),Ls=M(),y($s.$$.fragment),Ds=M(),_s=J("p"),_s.innerHTML=wl,Ps=M(),y(Cs.$$.fragment),Ks=M(),Zs=J("p"),Zs.innerHTML=Jl,Os=M(),y(ks.$$.fragment),sl=M(),Is=J("p"),Is.innerHTML=bl,ll=M(),y(Gs.$$.fragment),al=M(),y(rs.$$.fragment),el=M(),y(cs.$$.fragment),tl=M(),y(Rs.$$.fragment),nl=M(),Vs=J("p"),Vs.textContent=Tl,pl=M(),Xs=J("p"),Xs.textContent=Ul,rl=M(),y(Ws.$$.fragment),cl=M(),y(Ms.$$.fragment),Ml=M(),vs=J("p"),this.h()},l(s){const p=Al("svelte-u9bgzb",document.head);a=b(p,"META",{name:!0,content:!0}),p.forEach(e),c=m(s),l=b(s,"P",{}),kl(l).forEach(e),o=m(s),h(j.$$.fragment,s),C=m(s),h(B.$$.fragment,s),I=m(s),Z=b(s,"P",{"data-svelte-h":!0}),U(Z)!=="svelte-eakc5k"&&(Z.textContent=X),k=m(s),A=b(s,"P",{"data-svelte-h":!0}),U(A)!=="svelte-w5jzhi"&&(A.textContent=W),$=m(s),G=b(s,"OL",{"data-svelte-h":!0}),U(G)!=="svelte-2ipb08"&&(G.innerHTML=r),g=m(s),h(v.$$.fragment,s),Y=m(s),E=b(s,"P",{"data-svelte-h":!0}),U(E)!=="svelte-1lya3k8"&&(E.textContent=i),V=m(s),h(x.$$.fragment,s),os=m(s),N=b(s,"P",{"data-svelte-h":!0}),U(N)!=="svelte-193zy02"&&(N.textContent=ss),ns=m(s),h(F.$$.fragment,s),is=m(s),h(z.$$.fragment,s),Q=m(s),H=b(s,"P",{"data-svelte-h":!0}),U(H)!=="svelte-gtxhgw"&&(H.textContent=ls),js=m(s),h(S.$$.fragment,s),q=m(s),L=b(s,"P",{"data-svelte-h":!0}),U(L)!=="svelte-1r6oj5w"&&(L.textContent=as),ys=m(s),h(D.$$.fragment,s),P=m(s),K=b(s,"P",{"data-svelte-h":!0}),U(K)!=="svelte-1441z1m"&&(K.textContent=es),hs=m(s),O=b(s,"UL",{"data-svelte-h":!0}),U(O)!=="svelte-aqbkoq"&&(O.innerHTML=n),T=m(s),h(ts.$$.fragment,s),Es=m(s),ds=b(s,"P",{"data-svelte-h":!0}),U(ds)!=="svelte-1onnjgu"&&(ds.textContent=jl),xs=m(s),h(fs.$$.fragment,s),Ys=m(s),us=b(s,"P",{"data-svelte-h":!0}),U(us)!=="svelte-pmbrx1"&&(us.textContent=yl),Fs=m(s),ws=b(s,"OL",{"data-svelte-h":!0}),U(ws)!=="svelte-b8ymrh"&&(ws.innerHTML=hl),Ns=m(s),h(Js.$$.fragment,s),zs=m(s),bs=b(s,"P",{"data-svelte-h":!0}),U(bs)!=="svelte-1rdkxip"&&(bs.innerHTML=dl),Qs=m(s),h(Ts.$$.fragment,s),Hs=m(s),Us=b(s,"P",{"data-svelte-h":!0}),U(Us)!=="svelte-15vpmmb"&&(Us.innerHTML=fl),Ss=m(s),gs=b(s,"P",{"data-svelte-h":!0}),U(gs)!=="svelte-3rlquo"&&(gs.innerHTML=ul),qs=m(s),h(ps.$$.fragment,s),Ls=m(s),h($s.$$.fragment,s),Ds=m(s),_s=b(s,"P",{"data-svelte-h":!0}),U(_s)!=="svelte-629o19"&&(_s.innerHTML=wl),Ps=m(s),h(Cs.$$.fragment,s),Ks=m(s),Zs=b(s,"P",{"data-svelte-h":!0}),U(Zs)!=="svelte-o90xg4"&&(Zs.innerHTML=Jl),Os=m(s),h(ks.$$.fragment,s),sl=m(s),Is=b(s,"P",{"data-svelte-h":!0}),U(Is)!=="svelte-18cw5xr"&&(Is.innerHTML=bl),ll=m(s),h(Gs.$$.fragment,s),al=m(s),h(rs.$$.fragment,s),el=m(s),h(cs.$$.fragment,s),tl=m(s),h(Rs.$$.fragment,s),nl=m(s),Vs=b(s,"P",{"data-svelte-h":!0}),U(Vs)!=="svelte-cyrfc8"&&(Vs.textContent=Tl),pl=m(s),Xs=b(s,"P",{"data-svelte-h":!0}),U(Xs)!=="svelte-l4pjg8"&&(Xs.textContent=Ul),rl=m(s),h(Ws.$$.fragment,s),cl=m(s),h(Ms.$$.fragment,s),Ml=m(s),vs=b(s,"P",{}),kl(vs).forEach(e),this.h()},h(){Il(a,"name","hf:doc:metadata"),Il(a,"content",ea)},m(s,p){vl(document.head,a),t(s,c,p),t(s,l,p),t(s,o,p),d(j,s,p),t(s,C,p),d(B,s,p),t(s,I,p),t(s,Z,p),t(s,k,p),t(s,A,p),t(s,$,p),t(s,G,p),t(s,g,p),d(v,s,p),t(s,Y,p),t(s,E,p),t(s,V,p),d(x,s,p),t(s,os,p),t(s,N,p),t(s,ns,p),d(F,s,p),t(s,is,p),d(z,s,p),t(s,Q,p),t(s,H,p),t(s,js,p),d(S,s,p),t(s,q,p),t(s,L,p),t(s,ys,p),d(D,s,p),t(s,P,p),t(s,K,p),t(s,hs,p),t(s,O,p),t(s,T,p),d(ts,s,p),t(s,Es,p),t(s,ds,p),t(s,xs,p),d(fs,s,p),t(s,Ys,p),t(s,us,p),t(s,Fs,p),t(s,ws,p),t(s,Ns,p),d(Js,s,p),t(s,zs,p),t(s,bs,p),t(s,Qs,p),d(Ts,s,p),t(s,Hs,p),t(s,Us,p),t(s,Ss,p),t(s,gs,p),t(s,qs,p),d(ps,s,p),t(s,Ls,p),d($s,s,p),t(s,Ds,p),t(s,_s,p),t(s,Ps,p),d(Cs,s,p),t(s,Ks,p),t(s,Zs,p),t(s,Os,p),d(ks,s,p),t(s,sl,p),t(s,Is,p),t(s,ll,p),d(Gs,s,p),t(s,al,p),d(rs,s,p),t(s,el,p),d(cs,s,p),t(s,tl,p),d(Rs,s,p),t(s,nl,p),t(s,Vs,p),t(s,pl,p),t(s,Xs,p),t(s,rl,p),d(Ws,s,p),t(s,cl,p),d(Ms,s,p),t(s,Ml,p),t(s,vs,p),ml=!0},p(s,[p]){const gl={};p&2&&(gl.$$scope={dirty:p,ctx:s}),v.$set(gl);const $l={};p&2&&($l.$$scope={dirty:p,ctx:s}),ps.$set($l);const _l={};p&2&&(_l.$$scope={dirty:p,ctx:s}),rs.$set(_l);const Cl={};p&2&&(Cl.$$scope={dirty:p,ctx:s}),cs.$set(Cl);const Zl={};p&2&&(Zl.$$scope={dirty:p,ctx:s}),Ms.$set(Zl)},i(s){ml||(f(j.$$.fragment,s),f(B.$$.fragment,s),f(v.$$.fragment,s),f(x.$$.fragment,s),f(F.$$.fragment,s),f(z.$$.fragment,s),f(S.$$.fragment,s),f(D.$$.fragment,s),f(ts.$$.fragment,s),f(fs.$$.fragment,s),f(Js.$$.fragment,s),f(Ts.$$.fragment,s),f(ps.$$.fragment,s),f($s.$$.fragment,s),f(Cs.$$.fragment,s),f(ks.$$.fragment,s),f(Gs.$$.fragment,s),f(rs.$$.fragment,s),f(cs.$$.fragment,s),f(Rs.$$.fragment,s),f(Ws.$$.fragment,s),f(Ms.$$.fragment,s),ml=!0)},o(s){u(j.$$.fragment,s),u(B.$$.fragment,s),u(v.$$.fragment,s),u(x.$$.fragment,s),u(F.$$.fragment,s),u(z.$$.fragment,s),u(S.$$.fragment,s),u(D.$$.fragment,s),u(ts.$$.fragment,s),u(fs.$$.fragment,s),u(Js.$$.fragment,s),u(Ts.$$.fragment,s),u(ps.$$.fragment,s),u($s.$$.fragment,s),u(Cs.$$.fragment,s),u(ks.$$.fragment,s),u(Gs.$$.fragment,s),u(rs.$$.fragment,s),u(cs.$$.fragment,s),u(Rs.$$.fragment,s),u(Ws.$$.fragment,s),u(Ms.$$.fragment,s),ml=!1},d(s){s&&(e(c),e(l),e(o),e(C),e(I),e(Z),e(k),e(A),e($),e(G),e(g),e(Y),e(E),e(V),e(os),e(N),e(ns),e(is),e(Q),e(H),e(js),e(q),e(L),e(ys),e(P),e(K),e(hs),e(O),e(T),e(Es),e(ds),e(xs),e(Ys),e(us),e(Fs),e(ws),e(Ns),e(zs),e(bs),e(Qs),e(Hs),e(Us),e(Ss),e(gs),e(qs),e(Ls),e(Ds),e(_s),e(Ps),e(Ks),e(Zs),e(Os),e(sl),e(Is),e(ll),e(al),e(el),e(tl),e(nl),e(Vs),e(pl),e(Xs),e(rl),e(cl),e(Ml),e(vs)),e(a),w(j,s),w(B,s),w(v,s),w(x,s),w(F,s),w(z,s),w(S,s),w(D,s),w(ts,s),w(fs,s),w(Js,s),w(Ts,s),w(ps,s),w($s,s),w(Cs,s),w(ks,s),w(Gs,s),w(rs,s),w(cs,s),w(Rs,s),w(Ws,s),w(Ms,s)}}}const ea='{"title":"Multiple choice","local":"multiple-choice","sections":[{"title":"Load SWAG dataset","local":"load-swag-dataset","sections":[],"depth":2},{"title":"Preprocess","local":"preprocess","sections":[],"depth":2},{"title":"Evaluate","local":"evaluate","sections":[],"depth":2},{"title":"Train","local":"train","sections":[],"depth":2}],"depth":1}';function ta(_){return Xl(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ia extends Wl{constructor(a){super(),Bl(this,a,ta,aa,Vl,{})}}export{ia as component};
