import{s as At,o as Lt,n as pe}from"../chunks/scheduler.9bc65507.js";import{S as Pt,i as Dt,g as $,s as i,r as h,A as Kt,h as j,f as a,c as p,j as Et,u as d,x as T,k as Yt,y as Ot,a as l,v as u,d as M,t as y,w as b,m as qt,n as Qt}from"../chunks/index.707bf1b6.js";import{T as Tt}from"../chunks/Tip.c2ecdbf4.js";import{Y as es}from"../chunks/Youtube.e1129c6f.js";import{C}from"../chunks/CodeBlock.54a9f38d.js";import{D as ts}from"../chunks/DocNotebookDropdown.3e6b3817.js";import{F as Ut,M as Ne}from"../chunks/Markdown.8ab98a13.js";import{H as Fe}from"../chunks/Heading.342b1fa6.js";function ss(k){let s,c,t='<a href="../model_doc/bart">BART</a>, <a href="../model_doc/bigbird_pegasus">BigBird-Pegasus</a>, <a href="../model_doc/blenderbot">Blenderbot</a>, <a href="../model_doc/blenderbot-small">BlenderbotSmall</a>, <a href="../model_doc/encoder-decoder">Encoder decoder</a>, <a href="../model_doc/fsmt">FairSeq Machine-Translation</a>, <a href="../model_doc/gptsan-japanese">GPTSAN-japanese</a>, <a href="../model_doc/led">LED</a>, <a href="../model_doc/longt5">LongT5</a>, <a href="../model_doc/m2m_100">M2M100</a>, <a href="../model_doc/marian">Marian</a>, <a href="../model_doc/mbart">mBART</a>, <a href="../model_doc/mt5">MT5</a>, <a href="../model_doc/mvp">MVP</a>, <a href="../model_doc/nllb">NLLB</a>, <a href="../model_doc/nllb-moe">NLLB-MOE</a>, <a href="../model_doc/pegasus">Pegasus</a>, <a href="../model_doc/pegasus_x">PEGASUS-X</a>, <a href="../model_doc/plbart">PLBart</a>, <a href="../model_doc/prophetnet">ProphetNet</a>, <a href="../model_doc/switch_transformers">SwitchTransformers</a>, <a href="../model_doc/t5">T5</a>, <a href="../model_doc/umt5">UMT5</a>, <a href="../model_doc/xlm-prophetnet">XLM-ProphetNet</a>';return{c(){s=qt(`このチュートリアルで説明するタスクは、次のモデル アーキテクチャでサポートされています。

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

`),c=j(m,"P",{"data-svelte-h":!0}),T(c)!=="svelte-2s8ce4"&&(c.innerHTML=t)},m(m,g){l(m,s,g),l(m,c,g)},p:pe,d(m){m&&(a(s),a(c))}}}function as(k){let s,c;return s=new C({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERhdGFDb2xsYXRvckZvclNlcTJTZXElMEElMEFkYXRhX2NvbGxhdG9yJTIwJTNEJTIwRGF0YUNvbGxhdG9yRm9yU2VxMlNlcSh0b2tlbml6ZXIlM0R0b2tlbml6ZXIlMkMlMjBtb2RlbCUzRGNoZWNrcG9pbnQp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DataCollatorForSeq2Seq

<span class="hljs-meta">&gt;&gt;&gt; </span>data_collator = DataCollatorForSeq2Seq(tokenizer=tokenizer, model=checkpoint)`,wrap:!1}}),{c(){h(s.$$.fragment)},l(t){d(s.$$.fragment,t)},m(t,m){u(s,t,m),c=!0},p:pe,i(t){c||(M(s.$$.fragment,t),c=!0)},o(t){y(s.$$.fragment,t),c=!1},d(t){b(s,t)}}}function ls(k){let s,c;return s=new Ne({props:{$$slots:{default:[as]},$$scope:{ctx:k}}}),{c(){h(s.$$.fragment)},l(t){d(s.$$.fragment,t)},m(t,m){u(s,t,m),c=!0},p(t,m){const g={};m&2&&(g.$$scope={dirty:m,ctx:t}),s.$set(g)},i(t){c||(M(s.$$.fragment,t),c=!0)},o(t){y(s.$$.fragment,t),c=!1},d(t){b(s,t)}}}function ns(k){let s,c;return s=new C({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERhdGFDb2xsYXRvckZvclNlcTJTZXElMEElMEFkYXRhX2NvbGxhdG9yJTIwJTNEJTIwRGF0YUNvbGxhdG9yRm9yU2VxMlNlcSh0b2tlbml6ZXIlM0R0b2tlbml6ZXIlMkMlMjBtb2RlbCUzRGNoZWNrcG9pbnQlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnRmJTIyKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DataCollatorForSeq2Seq

<span class="hljs-meta">&gt;&gt;&gt; </span>data_collator = DataCollatorForSeq2Seq(tokenizer=tokenizer, model=checkpoint, return_tensors=<span class="hljs-string">&quot;tf&quot;</span>)`,wrap:!1}}),{c(){h(s.$$.fragment)},l(t){d(s.$$.fragment,t)},m(t,m){u(s,t,m),c=!0},p:pe,i(t){c||(M(s.$$.fragment,t),c=!0)},o(t){y(s.$$.fragment,t),c=!1},d(t){b(s,t)}}}function rs(k){let s,c;return s=new Ne({props:{$$slots:{default:[ns]},$$scope:{ctx:k}}}),{c(){h(s.$$.fragment)},l(t){d(s.$$.fragment,t)},m(t,m){u(s,t,m),c=!0},p(t,m){const g={};m&2&&(g.$$scope={dirty:m,ctx:t}),s.$set(g)},i(t){c||(M(s.$$.fragment,t),c=!0)},o(t){y(s.$$.fragment,t),c=!1},d(t){b(s,t)}}}function os(k){let s,c='<a href="/docs/transformers/v4.36.1/ja/main_classes/trainer#transformers.Trainer">Trainer</a> を使用したモデルの微調整に慣れていない場合は、<a href="../training#train-with-pytorch-trainer">こちら</a> の基本的なチュートリアルをご覧ください。';return{c(){s=$("p"),s.innerHTML=c},l(t){s=j(t,"P",{"data-svelte-h":!0}),T(s)!=="svelte-sldk32"&&(s.innerHTML=c)},m(t,m){l(t,s,m)},p:pe,d(t){t&&a(s)}}}function is(k){let s,c,t,m='これでモデルのトレーニングを開始する準備が整いました。 <a href="/docs/transformers/v4.36.1/ja/model_doc/auto#transformers.AutoModelForSeq2SeqLM">AutoModelForSeq2SeqLM</a> を使用して T5 をロードします。',g,v,B,G,Z="この時点で残っている手順は次の 3 つだけです。",V,J,I='<li><a href="/docs/transformers/v4.36.1/ja/main_classes/trainer#transformers.Seq2SeqTrainingArguments">Seq2SeqTrainingArguments</a> でトレーニング ハイパーパラメータを定義します。唯一の必須パラメータは、モデルの保存場所を指定する <code>output_dir</code> です。 <code>push_to_hub=True</code>を設定して、このモデルをハブにプッシュします (モデルをアップロードするには、Hugging Face にサインインする必要があります)。各エポックの終了時に、<a href="/docs/transformers/v4.36.1/ja/main_classes/trainer#transformers.Trainer">Trainer</a> は ROUGE メトリクスを評価し、トレーニング チェックポイントを保存します。</li> <li>トレーニング引数をモデル、データセット、トークナイザー、データ照合器、および <code>compute_metrics</code> 関数とともに <a href="/docs/transformers/v4.36.1/ja/main_classes/trainer#transformers.Seq2SeqTrainer">Seq2SeqTrainer</a> に渡します。</li> <li><a href="/docs/transformers/v4.36.1/ja/main_classes/trainer#transformers.Trainer.train">train()</a> を呼び出してモデルを微調整します。</li>',R,_,W,o,U='トレーニングが完了したら、 <a href="/docs/transformers/v4.36.1/ja/main_classes/trainer#transformers.Trainer.push_to_hub">push_to_hub()</a> メソッドを使用してモデルをハブに共有し、誰もがモデルを使用できるようにします。',F,z,X;return s=new Tt({props:{$$slots:{default:[os]},$$scope:{ctx:k}}}),v=new C({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvclNlcTJTZXFMTSUyQyUyMFNlcTJTZXFUcmFpbmluZ0FyZ3VtZW50cyUyQyUyMFNlcTJTZXFUcmFpbmVyJTBBJTBBbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JTZXEyU2VxTE0uZnJvbV9wcmV0cmFpbmVkKGNoZWNrcG9pbnQp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForSeq2SeqLM, Seq2SeqTrainingArguments, Seq2SeqTrainer

<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForSeq2SeqLM.from_pretrained(checkpoint)`,wrap:!1}}),_=new C({props:{code:"dHJhaW5pbmdfYXJncyUyMCUzRCUyMFNlcTJTZXFUcmFpbmluZ0FyZ3VtZW50cyglMEElMjAlMjAlMjAlMjBvdXRwdXRfZGlyJTNEJTIybXlfYXdlc29tZV9iaWxsc3VtX21vZGVsJTIyJTJDJTBBJTIwJTIwJTIwJTIwZXZhbHVhdGlvbl9zdHJhdGVneSUzRCUyMmVwb2NoJTIyJTJDJTBBJTIwJTIwJTIwJTIwbGVhcm5pbmdfcmF0ZSUzRDJlLTUlMkMlMEElMjAlMjAlMjAlMjBwZXJfZGV2aWNlX3RyYWluX2JhdGNoX3NpemUlM0QxNiUyQyUwQSUyMCUyMCUyMCUyMHBlcl9kZXZpY2VfZXZhbF9iYXRjaF9zaXplJTNEMTYlMkMlMEElMjAlMjAlMjAlMjB3ZWlnaHRfZGVjYXklM0QwLjAxJTJDJTBBJTIwJTIwJTIwJTIwc2F2ZV90b3RhbF9saW1pdCUzRDMlMkMlMEElMjAlMjAlMjAlMjBudW1fdHJhaW5fZXBvY2hzJTNENCUyQyUwQSUyMCUyMCUyMCUyMHByZWRpY3Rfd2l0aF9nZW5lcmF0ZSUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjBmcDE2JTNEVHJ1ZSUyQyUwQSUyMCUyMCUyMCUyMHB1c2hfdG9faHViJTNEVHJ1ZSUyQyUwQSklMEElMEF0cmFpbmVyJTIwJTNEJTIwU2VxMlNlcVRyYWluZXIoJTBBJTIwJTIwJTIwJTIwbW9kZWwlM0Rtb2RlbCUyQyUwQSUyMCUyMCUyMCUyMGFyZ3MlM0R0cmFpbmluZ19hcmdzJTJDJTBBJTIwJTIwJTIwJTIwdHJhaW5fZGF0YXNldCUzRHRva2VuaXplZF9iaWxsc3VtJTVCJTIydHJhaW4lMjIlNUQlMkMlMEElMjAlMjAlMjAlMjBldmFsX2RhdGFzZXQlM0R0b2tlbml6ZWRfYmlsbHN1bSU1QiUyMnRlc3QlMjIlNUQlMkMlMEElMjAlMjAlMjAlMjB0b2tlbml6ZXIlM0R0b2tlbml6ZXIlMkMlMEElMjAlMjAlMjAlMjBkYXRhX2NvbGxhdG9yJTNEZGF0YV9jb2xsYXRvciUyQyUwQSUyMCUyMCUyMCUyMGNvbXB1dGVfbWV0cmljcyUzRGNvbXB1dGVfbWV0cmljcyUyQyUwQSklMEElMEF0cmFpbmVyLnRyYWluKCk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>training_args = Seq2SeqTrainingArguments(
<span class="hljs-meta">... </span>    output_dir=<span class="hljs-string">&quot;my_awesome_billsum_model&quot;</span>,
<span class="hljs-meta">... </span>    evaluation_strategy=<span class="hljs-string">&quot;epoch&quot;</span>,
<span class="hljs-meta">... </span>    learning_rate=<span class="hljs-number">2e-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>    weight_decay=<span class="hljs-number">0.01</span>,
<span class="hljs-meta">... </span>    save_total_limit=<span class="hljs-number">3</span>,
<span class="hljs-meta">... </span>    num_train_epochs=<span class="hljs-number">4</span>,
<span class="hljs-meta">... </span>    predict_with_generate=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    fp16=<span class="hljs-literal">True</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 = Seq2SeqTrainer(
<span class="hljs-meta">... </span>    model=model,
<span class="hljs-meta">... </span>    args=training_args,
<span class="hljs-meta">... </span>    train_dataset=tokenized_billsum[<span class="hljs-string">&quot;train&quot;</span>],
<span class="hljs-meta">... </span>    eval_dataset=tokenized_billsum[<span class="hljs-string">&quot;test&quot;</span>],
<span class="hljs-meta">... </span>    tokenizer=tokenizer,
<span class="hljs-meta">... </span>    data_collator=data_collator,
<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}}),z=new C({props:{code:"dHJhaW5lci5wdXNoX3RvX2h1Yigp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>trainer.push_to_hub()',wrap:!1}}),{c(){h(s.$$.fragment),c=i(),t=$("p"),t.innerHTML=m,g=i(),h(v.$$.fragment),B=i(),G=$("p"),G.textContent=Z,V=i(),J=$("ol"),J.innerHTML=I,R=i(),h(_.$$.fragment),W=i(),o=$("p"),o.innerHTML=U,F=i(),h(z.$$.fragment)},l(f){d(s.$$.fragment,f),c=p(f),t=j(f,"P",{"data-svelte-h":!0}),T(t)!=="svelte-aw3f4x"&&(t.innerHTML=m),g=p(f),d(v.$$.fragment,f),B=p(f),G=j(f,"P",{"data-svelte-h":!0}),T(G)!=="svelte-1j8bgyv"&&(G.textContent=Z),V=p(f),J=j(f,"OL",{"data-svelte-h":!0}),T(J)!=="svelte-3uq2si"&&(J.innerHTML=I),R=p(f),d(_.$$.fragment,f),W=p(f),o=j(f,"P",{"data-svelte-h":!0}),T(o)!=="svelte-z94b66"&&(o.innerHTML=U),F=p(f),d(z.$$.fragment,f)},m(f,x){u(s,f,x),l(f,c,x),l(f,t,x),l(f,g,x),u(v,f,x),l(f,B,x),l(f,G,x),l(f,V,x),l(f,J,x),l(f,R,x),u(_,f,x),l(f,W,x),l(f,o,x),l(f,F,x),u(z,f,x),X=!0},p(f,x){const H={};x&2&&(H.$$scope={dirty:x,ctx:f}),s.$set(H)},i(f){X||(M(s.$$.fragment,f),M(v.$$.fragment,f),M(_.$$.fragment,f),M(z.$$.fragment,f),X=!0)},o(f){y(s.$$.fragment,f),y(v.$$.fragment,f),y(_.$$.fragment,f),y(z.$$.fragment,f),X=!1},d(f){f&&(a(c),a(t),a(g),a(B),a(G),a(V),a(J),a(R),a(W),a(o),a(F)),b(s,f),b(v,f),b(_,f),b(z,f)}}}function ps(k){let s,c;return s=new Ne({props:{$$slots:{default:[is]},$$scope:{ctx:k}}}),{c(){h(s.$$.fragment)},l(t){d(s.$$.fragment,t)},m(t,m){u(s,t,m),c=!0},p(t,m){const g={};m&2&&(g.$$scope={dirty:m,ctx:t}),s.$set(g)},i(t){c||(M(s.$$.fragment,t),c=!0)},o(t){y(s.$$.fragment,t),c=!1},d(t){b(s,t)}}}function cs(k){let s,c='Keras を使用したモデルの微調整に慣れていない場合は、<a href="../training#train-a-tensorflow-model-with-keras">こちら</a> の基本的なチュートリアルをご覧ください。';return{c(){s=$("p"),s.innerHTML=c},l(t){s=j(t,"P",{"data-svelte-h":!0}),T(s)!=="svelte-1jwo7q8"&&(s.innerHTML=c)},m(t,m){l(t,s,m)},p:pe,d(t){t&&a(s)}}}function ms(k){let s,c,t,m,g,v='次に、<a href="/docs/transformers/v4.36.1/ja/model_doc/auto#transformers.TFAutoModelForSeq2SeqLM">TFAutoModelForSeq2SeqLM</a> を使用して T5 をロードできます。',B,G,Z,V,J='<a href="/docs/transformers/v4.36.1/ja/main_classes/model#transformers.TFPreTrainedModel.prepare_tf_dataset">prepare_tf_dataset()</a> を使用して、データセットを <code>tf.data.Dataset</code> 形式に変換します。',I,R,_,W,o='<a href="https://keras.io/api/models/model_training_apis/#compile-method" rel="nofollow"><code>compile</code></a> を使用してトレーニング用のモデルを設定します。 Transformers モデルにはすべてデフォルトのタスク関連の損失関数があるため、次の場合を除き、損失関数を指定する必要はないことに注意してください。',U,F,z,X,f='トレーニングを開始する前にセットアップする最後の 2 つのことは、予測から ROUGE スコアを計算し、モデルをハブにプッシュする方法を提供することです。どちらも <a href="../main_classes/keras_callbacks">Keras コールバック</a> を使用して行われます。',x,H,ce='<code>compute_metrics</code> 関数を <a href="/docs/transformers/v4.36.1/ja/main_classes/keras_callbacks#transformers.KerasMetricCallback">KerasMetricCallback</a> に渡します。',E,O,ae,N,me='Specify where to push your model and tokenizer in the <a href="/docs/transformers/v4.36.1/ja/main_classes/keras_callbacks#transformers.PushToHubCallback">PushToHubCallback</a>:',Y,ee,le,S,fe="次に、コールバックをまとめてバンドルします。",q,Q,A,te,he='ついに、モデルのトレーニングを開始する準備が整いました。トレーニングおよび検証データセット、エポック数、コールバックを指定して <a href="https://keras.io/api/models/model_training_apis/#fit-method" rel="nofollow"><code>fit</code></a> を呼び出し、モデルを微調整します。',L,P,D,se,de="トレーニングが完了すると、モデルは自動的にハブにアップロードされ、誰でも使用できるようになります。",K;return s=new Tt({props:{$$slots:{default:[cs]},$$scope:{ctx:k}}}),t=new C({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMGNyZWF0ZV9vcHRpbWl6ZXIlMkMlMjBBZGFtV2VpZ2h0RGVjYXklMEElMEFvcHRpbWl6ZXIlMjAlM0QlMjBBZGFtV2VpZ2h0RGVjYXkobGVhcm5pbmdfcmF0ZSUzRDJlLTUlMkMlMjB3ZWlnaHRfZGVjYXlfcmF0ZSUzRDAuMDEp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> create_optimizer, AdamWeightDecay

<span class="hljs-meta">&gt;&gt;&gt; </span>optimizer = AdamWeightDecay(learning_rate=<span class="hljs-number">2e-5</span>, weight_decay_rate=<span class="hljs-number">0.01</span>)`,wrap:!1}}),G=new C({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGQXV0b01vZGVsRm9yU2VxMlNlcUxNJTBBJTBBbW9kZWwlMjAlM0QlMjBURkF1dG9Nb2RlbEZvclNlcTJTZXFMTS5mcm9tX3ByZXRyYWluZWQoY2hlY2twb2ludCk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TFAutoModelForSeq2SeqLM

<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFAutoModelForSeq2SeqLM.from_pretrained(checkpoint)`,wrap:!1}}),R=new C({props:{code:"dGZfdHJhaW5fc2V0JTIwJTNEJTIwbW9kZWwucHJlcGFyZV90Zl9kYXRhc2V0KCUwQSUyMCUyMCUyMCUyMHRva2VuaXplZF9iaWxsc3VtJTVCJTIydHJhaW4lMjIlNUQlMkMlMEElMjAlMjAlMjAlMjBzaHVmZmxlJTNEVHJ1ZSUyQyUwQSUyMCUyMCUyMCUyMGJhdGNoX3NpemUlM0QxNiUyQyUwQSUyMCUyMCUyMCUyMGNvbGxhdGVfZm4lM0RkYXRhX2NvbGxhdG9yJTJDJTBBKSUwQSUwQXRmX3Rlc3Rfc2V0JTIwJTNEJTIwbW9kZWwucHJlcGFyZV90Zl9kYXRhc2V0KCUwQSUyMCUyMCUyMCUyMHRva2VuaXplZF9iaWxsc3VtJTVCJTIydGVzdCUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMHNodWZmbGUlM0RGYWxzZSUyQyUwQSUyMCUyMCUyMCUyMGJhdGNoX3NpemUlM0QxNiUyQyUwQSUyMCUyMCUyMCUyMGNvbGxhdGVfZm4lM0RkYXRhX2NvbGxhdG9yJTJDJTBBKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>tf_train_set = model.prepare_tf_dataset(
<span class="hljs-meta">... </span>    tokenized_billsum[<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=<span class="hljs-number">16</span>,
<span class="hljs-meta">... </span>    collate_fn=data_collator,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>tf_test_set = model.prepare_tf_dataset(
<span class="hljs-meta">... </span>    tokenized_billsum[<span class="hljs-string">&quot;test&quot;</span>],
<span class="hljs-meta">... </span>    shuffle=<span class="hljs-literal">False</span>,
<span class="hljs-meta">... </span>    batch_size=<span class="hljs-number">16</span>,
<span class="hljs-meta">... </span>    collate_fn=data_collator,
<span class="hljs-meta">... </span>)`,wrap:!1}}),F=new C({props:{code:"aW1wb3J0JTIwdGVuc29yZmxvdyUyMGFzJTIwdGYlMEElMEFtb2RlbC5jb21waWxlKG9wdGltaXplciUzRG9wdGltaXplciklMjAlMjAlMjMlMjBObyUyMGxvc3MlMjBhcmd1bWVudCE=",highlighted:`<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>model.<span class="hljs-built_in">compile</span>(optimizer=optimizer)  <span class="hljs-comment"># No loss argument!</span>`,wrap:!1}}),O=new C({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}}),ee=new C({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycy5rZXJhc19jYWxsYmFja3MlMjBpbXBvcnQlMjBQdXNoVG9IdWJDYWxsYmFjayUwQSUwQXB1c2hfdG9faHViX2NhbGxiYWNrJTIwJTNEJTIwUHVzaFRvSHViQ2FsbGJhY2soJTBBJTIwJTIwJTIwJTIwb3V0cHV0X2RpciUzRCUyMm15X2F3ZXNvbWVfYmlsbHN1bV9tb2RlbCUyMiUyQyUwQSUyMCUyMCUyMCUyMHRva2VuaXplciUzRHRva2VuaXplciUyQyUwQSk=",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_billsum_model&quot;</span>,
<span class="hljs-meta">... </span>    tokenizer=tokenizer,
<span class="hljs-meta">... </span>)`,wrap:!1}}),Q=new C({props:{code:"Y2FsbGJhY2tzJTIwJTNEJTIwJTVCbWV0cmljX2NhbGxiYWNrJTJDJTIwcHVzaF90b19odWJfY2FsbGJhY2slNUQ=",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>callbacks = [metric_callback, push_to_hub_callback]',wrap:!1}}),P=new C({props:{code:"bW9kZWwuZml0KHglM0R0Zl90cmFpbl9zZXQlMkMlMjB2YWxpZGF0aW9uX2RhdGElM0R0Zl90ZXN0X3NldCUyQyUyMGVwb2NocyUzRDMlMkMlMjBjYWxsYmFja3MlM0RjYWxsYmFja3Mp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>model.fit(x=tf_train_set, validation_data=tf_test_set, epochs=<span class="hljs-number">3</span>, callbacks=callbacks)',wrap:!1}}),{c(){h(s.$$.fragment),c=qt(`
TensorFlow でモデルを微調整するには、オプティマイザー関数、学習率スケジュール、およびいくつかのトレーニング ハイパーパラメーターをセットアップすることから始めます。

	`),h(t.$$.fragment),m=i(),g=$("p"),g.innerHTML=v,B=i(),h(G.$$.fragment),Z=i(),V=$("p"),V.innerHTML=J,I=i(),h(R.$$.fragment),_=i(),W=$("p"),W.innerHTML=o,U=i(),h(F.$$.fragment),z=i(),X=$("p"),X.innerHTML=f,x=i(),H=$("p"),H.innerHTML=ce,E=i(),h(O.$$.fragment),ae=i(),N=$("p"),N.innerHTML=me,Y=i(),h(ee.$$.fragment),le=i(),S=$("p"),S.textContent=fe,q=i(),h(Q.$$.fragment),A=i(),te=$("p"),te.innerHTML=he,L=i(),h(P.$$.fragment),D=i(),se=$("p"),se.textContent=de},l(r){d(s.$$.fragment,r),c=Qt(r,`
TensorFlow でモデルを微調整するには、オプティマイザー関数、学習率スケジュール、およびいくつかのトレーニング ハイパーパラメーターをセットアップすることから始めます。

	`),d(t.$$.fragment,r),m=p(r),g=j(r,"P",{"data-svelte-h":!0}),T(g)!=="svelte-1w4c056"&&(g.innerHTML=v),B=p(r),d(G.$$.fragment,r),Z=p(r),V=j(r,"P",{"data-svelte-h":!0}),T(V)!=="svelte-1v8b12p"&&(V.innerHTML=J),I=p(r),d(R.$$.fragment,r),_=p(r),W=j(r,"P",{"data-svelte-h":!0}),T(W)!=="svelte-1pd5few"&&(W.innerHTML=o),U=p(r),d(F.$$.fragment,r),z=p(r),X=j(r,"P",{"data-svelte-h":!0}),T(X)!=="svelte-6w2fcl"&&(X.innerHTML=f),x=p(r),H=j(r,"P",{"data-svelte-h":!0}),T(H)!=="svelte-qstdi7"&&(H.innerHTML=ce),E=p(r),d(O.$$.fragment,r),ae=p(r),N=j(r,"P",{"data-svelte-h":!0}),T(N)!=="svelte-1lx3gdy"&&(N.innerHTML=me),Y=p(r),d(ee.$$.fragment,r),le=p(r),S=j(r,"P",{"data-svelte-h":!0}),T(S)!=="svelte-r16oc5"&&(S.textContent=fe),q=p(r),d(Q.$$.fragment,r),A=p(r),te=j(r,"P",{"data-svelte-h":!0}),T(te)!=="svelte-ffgub5"&&(te.innerHTML=he),L=p(r),d(P.$$.fragment,r),D=p(r),se=j(r,"P",{"data-svelte-h":!0}),T(se)!=="svelte-vh7z0v"&&(se.textContent=de)},m(r,w){u(s,r,w),l(r,c,w),u(t,r,w),l(r,m,w),l(r,g,w),l(r,B,w),u(G,r,w),l(r,Z,w),l(r,V,w),l(r,I,w),u(R,r,w),l(r,_,w),l(r,W,w),l(r,U,w),u(F,r,w),l(r,z,w),l(r,X,w),l(r,x,w),l(r,H,w),l(r,E,w),u(O,r,w),l(r,ae,w),l(r,N,w),l(r,Y,w),u(ee,r,w),l(r,le,w),l(r,S,w),l(r,q,w),u(Q,r,w),l(r,A,w),l(r,te,w),l(r,L,w),u(P,r,w),l(r,D,w),l(r,se,w),K=!0},p(r,w){const Se={};w&2&&(Se.$$scope={dirty:w,ctx:r}),s.$set(Se)},i(r){K||(M(s.$$.fragment,r),M(t.$$.fragment,r),M(G.$$.fragment,r),M(R.$$.fragment,r),M(F.$$.fragment,r),M(O.$$.fragment,r),M(ee.$$.fragment,r),M(Q.$$.fragment,r),M(P.$$.fragment,r),K=!0)},o(r){y(s.$$.fragment,r),y(t.$$.fragment,r),y(G.$$.fragment,r),y(R.$$.fragment,r),y(F.$$.fragment,r),y(O.$$.fragment,r),y(ee.$$.fragment,r),y(Q.$$.fragment,r),y(P.$$.fragment,r),K=!1},d(r){r&&(a(c),a(m),a(g),a(B),a(Z),a(V),a(I),a(_),a(W),a(U),a(z),a(X),a(x),a(H),a(E),a(ae),a(N),a(Y),a(le),a(S),a(q),a(A),a(te),a(L),a(D),a(se)),b(s,r),b(t,r),b(G,r),b(R,r),b(F,r),b(O,r),b(ee,r),b(Q,r),b(P,r)}}}function fs(k){let s,c;return s=new Ne({props:{$$slots:{default:[ms]},$$scope:{ctx:k}}}),{c(){h(s.$$.fragment)},l(t){d(s.$$.fragment,t)},m(t,m){u(s,t,m),c=!0},p(t,m){const g={};m&2&&(g.$$scope={dirty:m,ctx:t}),s.$set(g)},i(t){c||(M(s.$$.fragment,t),c=!0)},o(t){y(s.$$.fragment,t),c=!1},d(t){b(s,t)}}}function hs(k){let s,c=`要約用にモデルを微調整する方法のより詳細な例については、対応するセクションを参照してください。
<a href="https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/summarization.ipynb" rel="nofollow">PyTorch ノートブック</a>
または <a href="https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/summarization-tf.ipynb" rel="nofollow">TensorFlow ノートブック</a>。`;return{c(){s=$("p"),s.innerHTML=c},l(t){s=j(t,"P",{"data-svelte-h":!0}),T(s)!=="svelte-nrfgic"&&(s.innerHTML=c)},m(t,m){l(t,s,m)},p:pe,d(t){t&&a(s)}}}function ds(k){let s,c="Tokenize the text and return the <code>input_ids</code> as PyTorch tensors:",t,m,g,v,B='<a href="/docs/transformers/v4.36.1/ja/main_classes/text_generation#transformers.GenerationMixin.generate">generate()</a> メソッドを使用して要約を作成します。さまざまなテキスト生成戦略と生成を制御するためのパラメーターの詳細については、<a href="../main_classes/text_generation">Text Generation</a> API を確認してください。',G,Z,V,J,I="生成されたトークン ID をデコードしてテキストに戻します。",R,_,W;return m=new C({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJzdGV2aGxpdSUyRm15X2F3ZXNvbWVfYmlsbHN1bV9tb2RlbCUyMiklMEFpbnB1dHMlMjAlM0QlMjB0b2tlbml6ZXIodGV4dCUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpLmlucHV0X2lkcw==",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;stevhliu/my_awesome_billsum_model&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(text, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>).input_ids`,wrap:!1}}),Z=new C({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvclNlcTJTZXFMTSUwQSUwQW1vZGVsJTIwJTNEJTIwQXV0b01vZGVsRm9yU2VxMlNlcUxNLmZyb21fcHJldHJhaW5lZCglMjJzdGV2aGxpdSUyRm15X2F3ZXNvbWVfYmlsbHN1bV9tb2RlbCUyMiklMEFvdXRwdXRzJTIwJTNEJTIwbW9kZWwuZ2VuZXJhdGUoaW5wdXRzJTJDJTIwbWF4X25ld190b2tlbnMlM0QxMDAlMkMlMjBkb19zYW1wbGUlM0RGYWxzZSk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForSeq2SeqLM

<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForSeq2SeqLM.from_pretrained(<span class="hljs-string">&quot;stevhliu/my_awesome_billsum_model&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model.generate(inputs, max_new_tokens=<span class="hljs-number">100</span>, do_sample=<span class="hljs-literal">False</span>)`,wrap:!1}}),_=new C({props:{code:"dG9rZW5pemVyLmRlY29kZShvdXRwdXRzJTVCMCU1RCUyQyUyMHNraXBfc3BlY2lhbF90b2tlbnMlM0RUcnVlKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer.decode(outputs[<span class="hljs-number">0</span>], skip_special_tokens=<span class="hljs-literal">True</span>)
<span class="hljs-string">&#x27;the inflation reduction act lowers prescription drug costs, health care costs, and energy costs. it&#x27;</span>s the most aggressive action on tackling the climate crisis <span class="hljs-keyword">in</span> american history. it will ask the ultra-wealthy <span class="hljs-keyword">and</span> corporations to pay their fair share.<span class="hljs-string">&#x27;</span>`,wrap:!1}}),{c(){s=$("p"),s.innerHTML=c,t=i(),h(m.$$.fragment),g=i(),v=$("p"),v.innerHTML=B,G=i(),h(Z.$$.fragment),V=i(),J=$("p"),J.textContent=I,R=i(),h(_.$$.fragment)},l(o){s=j(o,"P",{"data-svelte-h":!0}),T(s)!=="svelte-1c2y1ia"&&(s.innerHTML=c),t=p(o),d(m.$$.fragment,o),g=p(o),v=j(o,"P",{"data-svelte-h":!0}),T(v)!=="svelte-1ae7280"&&(v.innerHTML=B),G=p(o),d(Z.$$.fragment,o),V=p(o),J=j(o,"P",{"data-svelte-h":!0}),T(J)!=="svelte-izrqac"&&(J.textContent=I),R=p(o),d(_.$$.fragment,o)},m(o,U){l(o,s,U),l(o,t,U),u(m,o,U),l(o,g,U),l(o,v,U),l(o,G,U),u(Z,o,U),l(o,V,U),l(o,J,U),l(o,R,U),u(_,o,U),W=!0},p:pe,i(o){W||(M(m.$$.fragment,o),M(Z.$$.fragment,o),M(_.$$.fragment,o),W=!0)},o(o){y(m.$$.fragment,o),y(Z.$$.fragment,o),y(_.$$.fragment,o),W=!1},d(o){o&&(a(s),a(t),a(g),a(v),a(G),a(V),a(J),a(R)),b(m,o),b(Z,o),b(_,o)}}}function us(k){let s,c;return s=new Ne({props:{$$slots:{default:[ds]},$$scope:{ctx:k}}}),{c(){h(s.$$.fragment)},l(t){d(s.$$.fragment,t)},m(t,m){u(s,t,m),c=!0},p(t,m){const g={};m&2&&(g.$$scope={dirty:m,ctx:t}),s.$set(g)},i(t){c||(M(s.$$.fragment,t),c=!0)},o(t){y(s.$$.fragment,t),c=!1},d(t){b(s,t)}}}function Ms(k){let s,c="テキストをトークン化し、<code>input_ids</code>を TensorFlow テンソルとして返します。",t,m,g,v,B='<a href="/docs/transformers/v4.36.1/ja/main_classes/text_generation#transformers.TFGenerationMixin.generate">generate()</a> メソッドを使用して要約を作成します。さまざまなテキスト生成戦略と生成を制御するためのパラメーターの詳細については、<a href="../main_classes/text_generation">Text Generation</a> API を確認してください。',G,Z,V,J,I="生成されたトークン ID をデコードしてテキストに戻します。",R,_,W;return m=new C({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJzdGV2aGxpdSUyRm15X2F3ZXNvbWVfYmlsbHN1bV9tb2RlbCUyMiklMEFpbnB1dHMlMjAlM0QlMjB0b2tlbml6ZXIodGV4dCUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIydGYlMjIpLmlucHV0X2lkcw==",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;stevhliu/my_awesome_billsum_model&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(text, return_tensors=<span class="hljs-string">&quot;tf&quot;</span>).input_ids`,wrap:!1}}),Z=new C({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGQXV0b01vZGVsRm9yU2VxMlNlcUxNJTBBJTBBbW9kZWwlMjAlM0QlMjBURkF1dG9Nb2RlbEZvclNlcTJTZXFMTS5mcm9tX3ByZXRyYWluZWQoJTIyc3RldmhsaXUlMkZteV9hd2Vzb21lX2JpbGxzdW1fbW9kZWwlMjIpJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsLmdlbmVyYXRlKGlucHV0cyUyQyUyMG1heF9uZXdfdG9rZW5zJTNEMTAwJTJDJTIwZG9fc2FtcGxlJTNERmFsc2Up",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TFAutoModelForSeq2SeqLM

<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFAutoModelForSeq2SeqLM.from_pretrained(<span class="hljs-string">&quot;stevhliu/my_awesome_billsum_model&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model.generate(inputs, max_new_tokens=<span class="hljs-number">100</span>, do_sample=<span class="hljs-literal">False</span>)`,wrap:!1}}),_=new C({props:{code:"dG9rZW5pemVyLmRlY29kZShvdXRwdXRzJTVCMCU1RCUyQyUyMHNraXBfc3BlY2lhbF90b2tlbnMlM0RUcnVlKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer.decode(outputs[<span class="hljs-number">0</span>], skip_special_tokens=<span class="hljs-literal">True</span>)
<span class="hljs-string">&#x27;the inflation reduction act lowers prescription drug costs, health care costs, and energy costs. it&#x27;</span>s the most aggressive action on tackling the climate crisis <span class="hljs-keyword">in</span> american history. it will ask the ultra-wealthy <span class="hljs-keyword">and</span> corporations to pay their fair share.<span class="hljs-string">&#x27;</span>`,wrap:!1}}),{c(){s=$("p"),s.innerHTML=c,t=i(),h(m.$$.fragment),g=i(),v=$("p"),v.innerHTML=B,G=i(),h(Z.$$.fragment),V=i(),J=$("p"),J.textContent=I,R=i(),h(_.$$.fragment)},l(o){s=j(o,"P",{"data-svelte-h":!0}),T(s)!=="svelte-pv8irx"&&(s.innerHTML=c),t=p(o),d(m.$$.fragment,o),g=p(o),v=j(o,"P",{"data-svelte-h":!0}),T(v)!=="svelte-5qxrbq"&&(v.innerHTML=B),G=p(o),d(Z.$$.fragment,o),V=p(o),J=j(o,"P",{"data-svelte-h":!0}),T(J)!=="svelte-izrqac"&&(J.textContent=I),R=p(o),d(_.$$.fragment,o)},m(o,U){l(o,s,U),l(o,t,U),u(m,o,U),l(o,g,U),l(o,v,U),l(o,G,U),u(Z,o,U),l(o,V,U),l(o,J,U),l(o,R,U),u(_,o,U),W=!0},p:pe,i(o){W||(M(m.$$.fragment,o),M(Z.$$.fragment,o),M(_.$$.fragment,o),W=!0)},o(o){y(m.$$.fragment,o),y(Z.$$.fragment,o),y(_.$$.fragment,o),W=!1},d(o){o&&(a(s),a(t),a(g),a(v),a(G),a(V),a(J),a(R)),b(m,o),b(Z,o),b(_,o)}}}function ys(k){let s,c;return s=new Ne({props:{$$slots:{default:[Ms]},$$scope:{ctx:k}}}),{c(){h(s.$$.fragment)},l(t){d(s.$$.fragment,t)},m(t,m){u(s,t,m),c=!0},p(t,m){const g={};m&2&&(g.$$scope={dirty:m,ctx:t}),s.$set(g)},i(t){c||(M(s.$$.fragment,t),c=!0)},o(t){y(s.$$.fragment,t),c=!1},d(t){b(s,t)}}}function bs(k){let s,c,t,m,g,v,B,G,Z,V,J,I="要約により、すべての重要な情報をまとめた短いバージョンの文書または記事が作成されます。これは、翻訳と並んで、シーケンス間のタスクとして定式化できるタスクのもう 1 つの例です。要約は次のようになります。",R,_,W="<li>抽出: 文書から最も関連性の高い情報を抽出します。</li> <li>抽象的: 最も関連性の高い情報を捉えた新しいテキストを生成します。</li>",o,U,F="このガイドでは、次の方法を説明します。",z,X,f='<li>抽象的な要約のために、<a href="https://huggingface.co/datasets/billsum" rel="nofollow">BillSum</a> データセットのカリフォルニア州請求書サブセットで <a href="https://huggingface.co/t5-small" rel="nofollow">T5</a> を微調整します。</li> <li>微調整したモデルを推論に使用します。</li>',x,H,ce,E,O="始める前に、必要なライブラリがすべてインストールされていることを確認してください。",ae,N,me,Y,ee="モデルをアップロードしてコミュニティと共有できるように、Hugging Face アカウントにログインすることをお勧めします。プロンプトが表示されたら、トークンを入力してログインします。",le,S,fe,q,Q,A,te="まず、🤗 データセット ライブラリから BillSum データセットの小さいカリフォルニア州請求書サブセットを読み込みます。",he,L,P,D,se="<code>train_test_split</code> メソッドを使用して、データセットをトレイン セットとテスト セットに分割します。",de,K,r,w,Se="次に、例を見てみましょう。",Ye,ue,qe,Me,_t="使用するフィールドが 2 つあります。",Qe,ye,Jt="<li><code>text</code>: モデルへの入力となる請求書のテキスト。</li> <li><code>summary</code>: モデルのターゲットとなる <code>text</code> の要約版。</li>",Ae,be,Le,ge,kt="次のステップでは、T5 トークナイザーをロードして「text」と<code>summary</code>を処理します。",Pe,$e,De,je,vt="作成する前処理関数は次のことを行う必要があります。",Ke,we,Zt="<li>T5 がこれが要約タスクであることを認識できるように、入力の前にプロンプ​​トを付けます。複数の NLP タスクが可能な一部のモデルでは、特定のタスクのプロンプトが必要です。</li> <li>ラベルをトークン化するときにキーワード <code>text_target</code> 引数を使用します。</li> <li><code>max_length</code>パラメータで設定された最大長を超えないようにシーケンスを切り詰めます。</li>",Oe,Te,et,Ue,Ct="データセット全体に前処理関数を適用するには、🤗 Datasets <code>map</code> メソッドを使用します。 <code>batched=True</code> を設定してデータセットの複数の要素を一度に処理することで、<code>map</code> 関数を高速化できます。",tt,_e,st,Je,Gt="次に、<code>DataCollat​​orForSeq2Seq</code> を使用してサンプルのバッチを作成します。データセット全体を最大長までパディングするのではなく、照合中にバッチ内の最長の長さまで文を <em>動的にパディング</em> する方が効率的です。",at,ne,lt,ke,nt,ve,xt='トレーニング中にメトリクスを含めると、多くの場合、モデルのパフォーマンスを評価するのに役立ちます。 🤗 <a href="https://huggingface.co/docs/evaluate/index" rel="nofollow">Evaluate</a> ライブラリを使用して、評価メソッドをすばやくロードできます。このタスクでは、<a href="https://huggingface.co/spaces/evaluate-metric/rouge" rel="nofollow">ROUGE</a> メトリックを読み込みます (🤗 Evaluate <a href="https://huggingface.co/docs/evaluate/a_quick_tour" rel="nofollow">クイック ツアー</a> を参照してください) ) メトリクスをロードして計算する方法の詳細については、次を参照してください)。',rt,Ze,ot,Ce,Vt="次に、予測とラベルを <code>compute</code> に渡して ROUGE メトリクスを計算する関数を作成します。",it,Ge,pt,xe,Rt="これで<code>compute_metrics</code>関数の準備が整いました。トレーニングをセットアップするときにこの関数に戻ります。",ct,Ve,mt,re,ft,oe,ht,Re,dt,We,Wt="モデルを微調整したので、それを推論に使用できるようになりました。",ut,Be,Bt="要約したいテキストを考え出します。 T5 の場合、作業中のタスクに応じて入力に接頭辞を付ける必要があります。要約するには、以下に示すように入力にプレフィックスを付ける必要があります。",Mt,Xe,yt,He,Xt='推論用に微調整されたモデルを試す最も簡単な方法は、それを <a href="/docs/transformers/v4.36.1/ja/main_classes/pipelines#transformers.pipeline">pipeline()</a> で使用することです。モデルを使用して要約用の <code>pipeline</code> をインスタンス化し、テキストをそれに渡します。',bt,ze,gt,Ie,Ht="必要に応じて、<code>pipeline</code>」の結果を手動で複製することもできます。",$t,ie,jt,Ee,wt;return g=new Fe({props:{title:"Summarization",local:"summarization",headingTag:"h1"}}),B=new ts({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/summarization.ipynb"},{label:"PyTorch",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/ja/pytorch/summarization.ipynb"},{label:"TensorFlow",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/ja/tensorflow/summarization.ipynb"},{label:"Mixed",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/ja/summarization.ipynb"},{label:"PyTorch",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/ja/pytorch/summarization.ipynb"},{label:"TensorFlow",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/ja/tensorflow/summarization.ipynb"}]}}),Z=new es({props:{id:"yHnr5Dk2zCI"}}),H=new Tt({props:{$$slots:{default:[ss]},$$scope:{ctx:k}}}),N=new C({props:{code:"cGlwJTIwaW5zdGFsbCUyMHRyYW5zZm9ybWVycyUyMGRhdGFzZXRzJTIwZXZhbHVhdGUlMjByb3VnZV9zY29yZQ==",highlighted:"pip install transformers datasets evaluate rouge_score",wrap:!1}}),S=new C({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}}),q=new Fe({props:{title:"Load BillSum dataset",local:"load-billsum-dataset",headingTag:"h2"}}),L=new C({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBJTBBYmlsbHN1bSUyMCUzRCUyMGxvYWRfZGF0YXNldCglMjJiaWxsc3VtJTIyJTJDJTIwc3BsaXQlM0QlMjJjYV90ZXN0JTIyKQ==",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>billsum = load_dataset(<span class="hljs-string">&quot;billsum&quot;</span>, split=<span class="hljs-string">&quot;ca_test&quot;</span>)`,wrap:!1}}),K=new C({props:{code:"YmlsbHN1bSUyMCUzRCUyMGJpbGxzdW0udHJhaW5fdGVzdF9zcGxpdCh0ZXN0X3NpemUlM0QwLjIp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>billsum = billsum.train_test_split(test_size=<span class="hljs-number">0.2</span>)',wrap:!1}}),ue=new C({props:{code:"YmlsbHN1bSU1QiUyMnRyYWluJTIyJTVEJTVCMCU1RA==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>billsum[<span class="hljs-string">&quot;train&quot;</span>][<span class="hljs-number">0</span>]
{<span class="hljs-string">&#x27;summary&#x27;</span>: <span class="hljs-string">&#x27;Existing law authorizes state agencies to enter into contracts for the acquisition of goods or services upon approval by the Department of General Services. Existing law sets forth various requirements and prohibitions for those contracts, including, but not limited to, a prohibition on entering into contracts for the acquisition of goods or services of $100,000 or more with a contractor that discriminates between spouses and domestic partners or same-sex and different-sex couples in the provision of benefits. Existing law provides that a contract entered into in violation of those requirements and prohibitions is void and authorizes the state or any person acting on behalf of the state to bring a civil action seeking a determination that a contract is in violation and therefore void. Under existing law, a willful violation of those requirements and prohibitions is a misdemeanor.\\nThis bill would also prohibit a state agency from entering into contracts for the acquisition of goods or services of $100,000 or more with a contractor that discriminates between employees on the basis of gender identity in the provision of benefits, as specified. By expanding the scope of a crime, this bill would impose a state-mandated local program.\\nThe California Constitution requires the state to reimburse local agencies and school districts for certain costs mandated by the state. Statutory provisions establish procedures for making that reimbursement.\\nThis bill would provide that no reimbursement is required by this act for a specified reason.&#x27;</span>,
 <span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27;The people of the State of California do enact as follows:\\n\\n\\nSECTION 1.\\nSection 10295.35 is added to the Public Contract Code, to read:\\n10295.35.\\n(a) (1) Notwithstanding any other law, a state agency shall not enter into any contract for the acquisition of goods or services in the amount of one hundred thousand dollars ($100,000) or more with a contractor that, in the provision of benefits, discriminates between employees on the basis of an employee’s or dependent’s actual or perceived gender identity, including, but not limited to, the employee’s or dependent’s identification as transgender.\\n(2) For purposes of this section, “contract” includes contracts with a cumulative amount of one hundred thousand dollars ($100,000) or more per contractor in each fiscal year.\\n(3) For purposes of this section, an employee health plan is discriminatory if the plan is not consistent with Section 1365.5 of the Health and Safety Code and Section 10140 of the Insurance Code.\\n(4) The requirements of this section shall apply only to those portions of a contractor’s operations that occur under any of the following conditions:\\n(A) Within the state.\\n(B) On real property outside the state if the property is owned by the state or if the state has a right to occupy the property, and if the contractor’s presence at that location is connected to a contract with the state.\\n(C) Elsewhere in the United States where work related to a state contract is being performed.\\n(b) Contractors shall treat as confidential, to the maximum extent allowed by law or by the requirement of the contractor’s insurance provider, any request by an employee or applicant for employment benefits or any documentation of eligibility for benefits submitted by an employee or applicant for employment.\\n(c) After taking all reasonable measures to find a contractor that complies with this section, as determined by the state agency, the requirements of this section may be waived under any of the following circumstances:\\n(1) There is only one prospective contractor willing to enter into a specific contract with the state agency.\\n(2) The contract is necessary to respond to an emergency, as determined by the state agency, that endangers the public health, welfare, or safety, or the contract is necessary for the provision of essential services, and no entity that complies with the requirements of this section capable of responding to the emergency is immediately available.\\n(3) The requirements of this section violate, or are inconsistent with, the terms or conditions of a grant, subvention, or agreement, if the agency has made a good faith attempt to change the terms or conditions of any grant, subvention, or agreement to authorize application of this section.\\n(4) The contractor is providing wholesale or bulk water, power, or natural gas, the conveyance or transmission of the same, or ancillary services, as required for ensuring reliable services in accordance with good utility practice, if the purchase of the same cannot practically be accomplished through the standard competitive bidding procedures and the contractor is not providing direct retail services to end users.\\n(d) (1) A contractor shall not be deemed to discriminate in the provision of benefits if the contractor, in providing the benefits, pays the actual costs incurred in obtaining the benefit.\\n(2) If a contractor is unable to provide a certain benefit, despite taking reasonable measures to do so, the contractor shall not be deemed to discriminate in the provision of benefits.\\n(e) (1) Every contract subject to this chapter shall contain a statement by which the contractor certifies that the contractor is in compliance with this section.\\n(2) The department or other contracting agency shall enforce this section pursuant to its existing enforcement powers.\\n(3) (A) If a contractor falsely certifies that it is in compliance with this section, the contract with that contractor shall be subject to Article 9 (commencing with Section 10420), unless, within a time period specified by the department or other contracting agency, the contractor provides to the department or agency proof that it has complied, or is in the process of complying, with this section.\\n(B) The application of the remedies or penalties contained in Article 9 (commencing with Section 10420) to a contract subject to this chapter shall not preclude the application of any existing remedies otherwise available to the department or other contracting agency under its existing enforcement powers.\\n(f) Nothing in this section is intended to regulate the contracting practices of any local jurisdiction.\\n(g) This section shall be construed so as not to conflict with applicable federal laws, rules, or regulations. In the event that a court or agency of competent jurisdiction holds that federal law, rule, or regulation invalidates any clause, sentence, paragraph, or section of this code or the application thereof to any person or circumstances, it is the intent of the state that the court or agency sever that clause, sentence, paragraph, or section so that the remainder of this section shall remain in effect.\\nSEC. 2.\\nSection 10295.35 of the Public Contract Code shall not be construed to create any new enforcement authority or responsibility in the Department of General Services or any other contracting agency.\\nSEC. 3.\\nNo reimbursement is required by this act pursuant to Section 6 of Article XIII\\u2009B of the California Constitution because the only costs that may be incurred by a local agency or school district will be incurred because this act creates a new crime or infraction, eliminates a crime or infraction, or changes the penalty for a crime or infraction, within the meaning of Section 17556 of the Government Code, or changes the definition of a crime within the meaning of Section 6 of Article XIII\\u2009B of the California Constitution.&#x27;</span>,
 <span class="hljs-string">&#x27;title&#x27;</span>: <span class="hljs-string">&#x27;An act to add Section 10295.35 to the Public Contract Code, relating to public contracts.&#x27;</span>}`,wrap:!1}}),be=new Fe({props:{title:"Preprocess",local:"preprocess",headingTag:"h2"}}),$e=new C({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEFjaGVja3BvaW50JTIwJTNEJTIwJTIydDUtc21hbGwlMjIlMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZChjaGVja3BvaW50KQ==",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>checkpoint = <span class="hljs-string">&quot;t5-small&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(checkpoint)`,wrap:!1}}),Te=new C({props:{code:"cHJlZml4JTIwJTNEJTIwJTIyc3VtbWFyaXplJTNBJTIwJTIyJTBBJTBBJTBBZGVmJTIwcHJlcHJvY2Vzc19mdW5jdGlvbihleGFtcGxlcyklM0ElMEElMjAlMjAlMjAlMjBpbnB1dHMlMjAlM0QlMjAlNUJwcmVmaXglMjAlMkIlMjBkb2MlMjBmb3IlMjBkb2MlMjBpbiUyMGV4YW1wbGVzJTVCJTIydGV4dCUyMiU1RCU1RCUwQSUyMCUyMCUyMCUyMG1vZGVsX2lucHV0cyUyMCUzRCUyMHRva2VuaXplcihpbnB1dHMlMkMlMjBtYXhfbGVuZ3RoJTNEMTAyNCUyQyUyMHRydW5jYXRpb24lM0RUcnVlKSUwQSUwQSUyMCUyMCUyMCUyMGxhYmVscyUyMCUzRCUyMHRva2VuaXplcih0ZXh0X3RhcmdldCUzRGV4YW1wbGVzJTVCJTIyc3VtbWFyeSUyMiU1RCUyQyUyMG1heF9sZW5ndGglM0QxMjglMkMlMjB0cnVuY2F0aW9uJTNEVHJ1ZSklMEElMEElMjAlMjAlMjAlMjBtb2RlbF9pbnB1dHMlNUIlMjJsYWJlbHMlMjIlNUQlMjAlM0QlMjBsYWJlbHMlNUIlMjJpbnB1dF9pZHMlMjIlNUQlMEElMjAlMjAlMjAlMjByZXR1cm4lMjBtb2RlbF9pbnB1dHM=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>prefix = <span class="hljs-string">&quot;summarize: &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>    inputs = [prefix + doc <span class="hljs-keyword">for</span> doc <span class="hljs-keyword">in</span> examples[<span class="hljs-string">&quot;text&quot;</span>]]
<span class="hljs-meta">... </span>    model_inputs = tokenizer(inputs, max_length=<span class="hljs-number">1024</span>, truncation=<span class="hljs-literal">True</span>)

<span class="hljs-meta">... </span>    labels = tokenizer(text_target=examples[<span class="hljs-string">&quot;summary&quot;</span>], max_length=<span class="hljs-number">128</span>, truncation=<span class="hljs-literal">True</span>)

<span class="hljs-meta">... </span>    model_inputs[<span class="hljs-string">&quot;labels&quot;</span>] = labels[<span class="hljs-string">&quot;input_ids&quot;</span>]
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> model_inputs`,wrap:!1}}),_e=new C({props:{code:"dG9rZW5pemVkX2JpbGxzdW0lMjAlM0QlMjBiaWxsc3VtLm1hcChwcmVwcm9jZXNzX2Z1bmN0aW9uJTJDJTIwYmF0Y2hlZCUzRFRydWUp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>tokenized_billsum = billsum.<span class="hljs-built_in">map</span>(preprocess_function, batched=<span class="hljs-literal">True</span>)',wrap:!1}}),ne=new Ut({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[rs],pytorch:[ls]},$$scope:{ctx:k}}}),ke=new Fe({props:{title:"Evaluate",local:"evaluate",headingTag:"h2"}}),Ze=new C({props:{code:"aW1wb3J0JTIwZXZhbHVhdGUlMEElMEFyb3VnZSUyMCUzRCUyMGV2YWx1YXRlLmxvYWQoJTIycm91Z2UlMjIp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> evaluate

<span class="hljs-meta">&gt;&gt;&gt; </span>rouge = evaluate.load(<span class="hljs-string">&quot;rouge&quot;</span>)`,wrap:!1}}),Ge=new C({props:{code:"aW1wb3J0JTIwbnVtcHklMjBhcyUyMG5wJTBBJTBBJTBBZGVmJTIwY29tcHV0ZV9tZXRyaWNzKGV2YWxfcHJlZCklM0ElMEElMjAlMjAlMjAlMjBwcmVkaWN0aW9ucyUyQyUyMGxhYmVscyUyMCUzRCUyMGV2YWxfcHJlZCUwQSUyMCUyMCUyMCUyMGRlY29kZWRfcHJlZHMlMjAlM0QlMjB0b2tlbml6ZXIuYmF0Y2hfZGVjb2RlKHByZWRpY3Rpb25zJTJDJTIwc2tpcF9zcGVjaWFsX3Rva2VucyUzRFRydWUpJTBBJTIwJTIwJTIwJTIwbGFiZWxzJTIwJTNEJTIwbnAud2hlcmUobGFiZWxzJTIwISUzRCUyMC0xMDAlMkMlMjBsYWJlbHMlMkMlMjB0b2tlbml6ZXIucGFkX3Rva2VuX2lkKSUwQSUyMCUyMCUyMCUyMGRlY29kZWRfbGFiZWxzJTIwJTNEJTIwdG9rZW5pemVyLmJhdGNoX2RlY29kZShsYWJlbHMlMkMlMjBza2lwX3NwZWNpYWxfdG9rZW5zJTNEVHJ1ZSklMEElMEElMjAlMjAlMjAlMjByZXN1bHQlMjAlM0QlMjByb3VnZS5jb21wdXRlKHByZWRpY3Rpb25zJTNEZGVjb2RlZF9wcmVkcyUyQyUyMHJlZmVyZW5jZXMlM0RkZWNvZGVkX2xhYmVscyUyQyUyMHVzZV9zdGVtbWVyJTNEVHJ1ZSklMEElMEElMjAlMjAlMjAlMjBwcmVkaWN0aW9uX2xlbnMlMjAlM0QlMjAlNUJucC5jb3VudF9ub256ZXJvKHByZWQlMjAhJTNEJTIwdG9rZW5pemVyLnBhZF90b2tlbl9pZCklMjBmb3IlMjBwcmVkJTIwaW4lMjBwcmVkaWN0aW9ucyU1RCUwQSUyMCUyMCUyMCUyMHJlc3VsdCU1QiUyMmdlbl9sZW4lMjIlNUQlMjAlM0QlMjBucC5tZWFuKHByZWRpY3Rpb25fbGVucyklMEElMEElMjAlMjAlMjAlMjByZXR1cm4lMjAlN0JrJTNBJTIwcm91bmQodiUyQyUyMDQpJTIwZm9yJTIwayUyQyUyMHYlMjBpbiUyMHJlc3VsdC5pdGVtcygpJTdE",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>    decoded_preds = tokenizer.batch_decode(predictions, skip_special_tokens=<span class="hljs-literal">True</span>)
<span class="hljs-meta">... </span>    labels = np.where(labels != -<span class="hljs-number">100</span>, labels, tokenizer.pad_token_id)
<span class="hljs-meta">... </span>    decoded_labels = tokenizer.batch_decode(labels, skip_special_tokens=<span class="hljs-literal">True</span>)

<span class="hljs-meta">... </span>    result = rouge.compute(predictions=decoded_preds, references=decoded_labels, use_stemmer=<span class="hljs-literal">True</span>)

<span class="hljs-meta">... </span>    prediction_lens = [np.count_nonzero(pred != tokenizer.pad_token_id) <span class="hljs-keyword">for</span> pred <span class="hljs-keyword">in</span> predictions]
<span class="hljs-meta">... </span>    result[<span class="hljs-string">&quot;gen_len&quot;</span>] = np.mean(prediction_lens)

<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> {k: <span class="hljs-built_in">round</span>(v, <span class="hljs-number">4</span>) <span class="hljs-keyword">for</span> k, v <span class="hljs-keyword">in</span> result.items()}`,wrap:!1}}),Ve=new Fe({props:{title:"Train",local:"train",headingTag:"h2"}}),re=new Ut({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[fs],pytorch:[ps]},$$scope:{ctx:k}}}),oe=new Tt({props:{$$slots:{default:[hs]},$$scope:{ctx:k}}}),Re=new Fe({props:{title:"Inference",local:"inference",headingTag:"h2"}}),Xe=new C({props:{code:"dGV4dCUyMCUzRCUyMCUyMnN1bW1hcml6ZSUzQSUyMFRoZSUyMEluZmxhdGlvbiUyMFJlZHVjdGlvbiUyMEFjdCUyMGxvd2VycyUyMHByZXNjcmlwdGlvbiUyMGRydWclMjBjb3N0cyUyQyUyMGhlYWx0aCUyMGNhcmUlMjBjb3N0cyUyQyUyMGFuZCUyMGVuZXJneSUyMGNvc3RzLiUyMEl0J3MlMjB0aGUlMjBtb3N0JTIwYWdncmVzc2l2ZSUyMGFjdGlvbiUyMG9uJTIwdGFja2xpbmclMjB0aGUlMjBjbGltYXRlJTIwY3Jpc2lzJTIwaW4lMjBBbWVyaWNhbiUyMGhpc3RvcnklMkMlMjB3aGljaCUyMHdpbGwlMjBsaWZ0JTIwdXAlMjBBbWVyaWNhbiUyMHdvcmtlcnMlMjBhbmQlMjBjcmVhdGUlMjBnb29kLXBheWluZyUyQyUyMHVuaW9uJTIwam9icyUyMGFjcm9zcyUyMHRoZSUyMGNvdW50cnkuJTIwSXQnbGwlMjBsb3dlciUyMHRoZSUyMGRlZmljaXQlMjBhbmQlMjBhc2slMjB0aGUlMjB1bHRyYS13ZWFsdGh5JTIwYW5kJTIwY29ycG9yYXRpb25zJTIwdG8lMjBwYXklMjB0aGVpciUyMGZhaXIlMjBzaGFyZS4lMjBBbmQlMjBubyUyMG9uZSUyMG1ha2luZyUyMHVuZGVyJTIwJTI0NDAwJTJDMDAwJTIwcGVyJTIweWVhciUyMHdpbGwlMjBwYXklMjBhJTIwcGVubnklMjBtb3JlJTIwaW4lMjB0YXhlcy4lMjI=",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>text = <span class="hljs-string">&quot;summarize: The Inflation Reduction Act lowers prescription drug costs, health care costs, and energy costs. It&#x27;s the most aggressive action on tackling the climate crisis in American history, which will lift up American workers and create good-paying, union jobs across the country. It&#x27;ll lower the deficit and ask the ultra-wealthy and corporations to pay their fair share. And no one making under $400,000 per year will pay a penny more in taxes.&quot;</span>',wrap:!1}}),ze=new C({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMHBpcGVsaW5lJTBBJTBBc3VtbWFyaXplciUyMCUzRCUyMHBpcGVsaW5lKCUyMnN1bW1hcml6YXRpb24lMjIlMkMlMjBtb2RlbCUzRCUyMnN0ZXZobGl1JTJGbXlfYXdlc29tZV9iaWxsc3VtX21vZGVsJTIyKSUwQXN1bW1hcml6ZXIodGV4dCk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

<span class="hljs-meta">&gt;&gt;&gt; </span>summarizer = pipeline(<span class="hljs-string">&quot;summarization&quot;</span>, model=<span class="hljs-string">&quot;stevhliu/my_awesome_billsum_model&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>summarizer(text)
[{<span class="hljs-string">&quot;summary_text&quot;</span>: <span class="hljs-string">&quot;The Inflation Reduction Act lowers prescription drug costs, health care costs, and energy costs. It&#x27;s the most aggressive action on tackling the climate crisis in American history, which will lift up American workers and create good-paying, union jobs across the country.&quot;</span>}]`,wrap:!1}}),ie=new Ut({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[ys],pytorch:[us]},$$scope:{ctx:k}}}),{c(){s=$("meta"),c=i(),t=$("p"),m=i(),h(g.$$.fragment),v=i(),h(B.$$.fragment),G=i(),h(Z.$$.fragment),V=i(),J=$("p"),J.textContent=I,R=i(),_=$("ul"),_.innerHTML=W,o=i(),U=$("p"),U.textContent=F,z=i(),X=$("ol"),X.innerHTML=f,x=i(),h(H.$$.fragment),ce=i(),E=$("p"),E.textContent=O,ae=i(),h(N.$$.fragment),me=i(),Y=$("p"),Y.textContent=ee,le=i(),h(S.$$.fragment),fe=i(),h(q.$$.fragment),Q=i(),A=$("p"),A.textContent=te,he=i(),h(L.$$.fragment),P=i(),D=$("p"),D.innerHTML=se,de=i(),h(K.$$.fragment),r=i(),w=$("p"),w.textContent=Se,Ye=i(),h(ue.$$.fragment),qe=i(),Me=$("p"),Me.textContent=_t,Qe=i(),ye=$("ul"),ye.innerHTML=Jt,Ae=i(),h(be.$$.fragment),Le=i(),ge=$("p"),ge.innerHTML=kt,Pe=i(),h($e.$$.fragment),De=i(),je=$("p"),je.textContent=vt,Ke=i(),we=$("ol"),we.innerHTML=Zt,Oe=i(),h(Te.$$.fragment),et=i(),Ue=$("p"),Ue.innerHTML=Ct,tt=i(),h(_e.$$.fragment),st=i(),Je=$("p"),Je.innerHTML=Gt,at=i(),h(ne.$$.fragment),lt=i(),h(ke.$$.fragment),nt=i(),ve=$("p"),ve.innerHTML=xt,rt=i(),h(Ze.$$.fragment),ot=i(),Ce=$("p"),Ce.innerHTML=Vt,it=i(),h(Ge.$$.fragment),pt=i(),xe=$("p"),xe.innerHTML=Rt,ct=i(),h(Ve.$$.fragment),mt=i(),h(re.$$.fragment),ft=i(),h(oe.$$.fragment),ht=i(),h(Re.$$.fragment),dt=i(),We=$("p"),We.textContent=Wt,ut=i(),Be=$("p"),Be.textContent=Bt,Mt=i(),h(Xe.$$.fragment),yt=i(),He=$("p"),He.innerHTML=Xt,bt=i(),h(ze.$$.fragment),gt=i(),Ie=$("p"),Ie.innerHTML=Ht,$t=i(),h(ie.$$.fragment),jt=i(),Ee=$("p"),this.h()},l(e){const n=Kt("svelte-u9bgzb",document.head);s=j(n,"META",{name:!0,content:!0}),n.forEach(a),c=p(e),t=j(e,"P",{}),Et(t).forEach(a),m=p(e),d(g.$$.fragment,e),v=p(e),d(B.$$.fragment,e),G=p(e),d(Z.$$.fragment,e),V=p(e),J=j(e,"P",{"data-svelte-h":!0}),T(J)!=="svelte-bkoa0b"&&(J.textContent=I),R=p(e),_=j(e,"UL",{"data-svelte-h":!0}),T(_)!=="svelte-154z6ot"&&(_.innerHTML=W),o=p(e),U=j(e,"P",{"data-svelte-h":!0}),T(U)!=="svelte-w5jzhi"&&(U.textContent=F),z=p(e),X=j(e,"OL",{"data-svelte-h":!0}),T(X)!=="svelte-pv3khb"&&(X.innerHTML=f),x=p(e),d(H.$$.fragment,e),ce=p(e),E=j(e,"P",{"data-svelte-h":!0}),T(E)!=="svelte-1lya3k8"&&(E.textContent=O),ae=p(e),d(N.$$.fragment,e),me=p(e),Y=j(e,"P",{"data-svelte-h":!0}),T(Y)!=="svelte-193zy02"&&(Y.textContent=ee),le=p(e),d(S.$$.fragment,e),fe=p(e),d(q.$$.fragment,e),Q=p(e),A=j(e,"P",{"data-svelte-h":!0}),T(A)!=="svelte-dg03sv"&&(A.textContent=te),he=p(e),d(L.$$.fragment,e),P=p(e),D=j(e,"P",{"data-svelte-h":!0}),T(D)!=="svelte-1la4z0h"&&(D.innerHTML=se),de=p(e),d(K.$$.fragment,e),r=p(e),w=j(e,"P",{"data-svelte-h":!0}),T(w)!=="svelte-1r6oj5w"&&(w.textContent=Se),Ye=p(e),d(ue.$$.fragment,e),qe=p(e),Me=j(e,"P",{"data-svelte-h":!0}),T(Me)!=="svelte-9qowt6"&&(Me.textContent=_t),Qe=p(e),ye=j(e,"UL",{"data-svelte-h":!0}),T(ye)!=="svelte-jfaa91"&&(ye.innerHTML=Jt),Ae=p(e),d(be.$$.fragment,e),Le=p(e),ge=j(e,"P",{"data-svelte-h":!0}),T(ge)!=="svelte-1mu6eql"&&(ge.innerHTML=kt),Pe=p(e),d($e.$$.fragment,e),De=p(e),je=j(e,"P",{"data-svelte-h":!0}),T(je)!=="svelte-pmbrx1"&&(je.textContent=vt),Ke=p(e),we=j(e,"OL",{"data-svelte-h":!0}),T(we)!=="svelte-fm2iy8"&&(we.innerHTML=Zt),Oe=p(e),d(Te.$$.fragment,e),et=p(e),Ue=j(e,"P",{"data-svelte-h":!0}),T(Ue)!=="svelte-1rdkxip"&&(Ue.innerHTML=Ct),tt=p(e),d(_e.$$.fragment,e),st=p(e),Je=j(e,"P",{"data-svelte-h":!0}),T(Je)!=="svelte-1uxhmr6"&&(Je.innerHTML=Gt),at=p(e),d(ne.$$.fragment,e),lt=p(e),d(ke.$$.fragment,e),nt=p(e),ve=j(e,"P",{"data-svelte-h":!0}),T(ve)!=="svelte-lno9gt"&&(ve.innerHTML=xt),rt=p(e),d(Ze.$$.fragment,e),ot=p(e),Ce=j(e,"P",{"data-svelte-h":!0}),T(Ce)!=="svelte-10ia8m5"&&(Ce.innerHTML=Vt),it=p(e),d(Ge.$$.fragment,e),pt=p(e),xe=j(e,"P",{"data-svelte-h":!0}),T(xe)!=="svelte-18cw5xr"&&(xe.innerHTML=Rt),ct=p(e),d(Ve.$$.fragment,e),mt=p(e),d(re.$$.fragment,e),ft=p(e),d(oe.$$.fragment,e),ht=p(e),d(Re.$$.fragment,e),dt=p(e),We=j(e,"P",{"data-svelte-h":!0}),T(We)!=="svelte-cyrfc8"&&(We.textContent=Wt),ut=p(e),Be=j(e,"P",{"data-svelte-h":!0}),T(Be)!=="svelte-1ba6pwv"&&(Be.textContent=Bt),Mt=p(e),d(Xe.$$.fragment,e),yt=p(e),He=j(e,"P",{"data-svelte-h":!0}),T(He)!=="svelte-liwj3o"&&(He.innerHTML=Xt),bt=p(e),d(ze.$$.fragment,e),gt=p(e),Ie=j(e,"P",{"data-svelte-h":!0}),T(Ie)!=="svelte-1cm59bz"&&(Ie.innerHTML=Ht),$t=p(e),d(ie.$$.fragment,e),jt=p(e),Ee=j(e,"P",{}),Et(Ee).forEach(a),this.h()},h(){Yt(s,"name","hf:doc:metadata"),Yt(s,"content",gs)},m(e,n){Ot(document.head,s),l(e,c,n),l(e,t,n),l(e,m,n),u(g,e,n),l(e,v,n),u(B,e,n),l(e,G,n),u(Z,e,n),l(e,V,n),l(e,J,n),l(e,R,n),l(e,_,n),l(e,o,n),l(e,U,n),l(e,z,n),l(e,X,n),l(e,x,n),u(H,e,n),l(e,ce,n),l(e,E,n),l(e,ae,n),u(N,e,n),l(e,me,n),l(e,Y,n),l(e,le,n),u(S,e,n),l(e,fe,n),u(q,e,n),l(e,Q,n),l(e,A,n),l(e,he,n),u(L,e,n),l(e,P,n),l(e,D,n),l(e,de,n),u(K,e,n),l(e,r,n),l(e,w,n),l(e,Ye,n),u(ue,e,n),l(e,qe,n),l(e,Me,n),l(e,Qe,n),l(e,ye,n),l(e,Ae,n),u(be,e,n),l(e,Le,n),l(e,ge,n),l(e,Pe,n),u($e,e,n),l(e,De,n),l(e,je,n),l(e,Ke,n),l(e,we,n),l(e,Oe,n),u(Te,e,n),l(e,et,n),l(e,Ue,n),l(e,tt,n),u(_e,e,n),l(e,st,n),l(e,Je,n),l(e,at,n),u(ne,e,n),l(e,lt,n),u(ke,e,n),l(e,nt,n),l(e,ve,n),l(e,rt,n),u(Ze,e,n),l(e,ot,n),l(e,Ce,n),l(e,it,n),u(Ge,e,n),l(e,pt,n),l(e,xe,n),l(e,ct,n),u(Ve,e,n),l(e,mt,n),u(re,e,n),l(e,ft,n),u(oe,e,n),l(e,ht,n),u(Re,e,n),l(e,dt,n),l(e,We,n),l(e,ut,n),l(e,Be,n),l(e,Mt,n),u(Xe,e,n),l(e,yt,n),l(e,He,n),l(e,bt,n),u(ze,e,n),l(e,gt,n),l(e,Ie,n),l(e,$t,n),u(ie,e,n),l(e,jt,n),l(e,Ee,n),wt=!0},p(e,[n]){const zt={};n&2&&(zt.$$scope={dirty:n,ctx:e}),H.$set(zt);const It={};n&2&&(It.$$scope={dirty:n,ctx:e}),ne.$set(It);const Ft={};n&2&&(Ft.$$scope={dirty:n,ctx:e}),re.$set(Ft);const Nt={};n&2&&(Nt.$$scope={dirty:n,ctx:e}),oe.$set(Nt);const St={};n&2&&(St.$$scope={dirty:n,ctx:e}),ie.$set(St)},i(e){wt||(M(g.$$.fragment,e),M(B.$$.fragment,e),M(Z.$$.fragment,e),M(H.$$.fragment,e),M(N.$$.fragment,e),M(S.$$.fragment,e),M(q.$$.fragment,e),M(L.$$.fragment,e),M(K.$$.fragment,e),M(ue.$$.fragment,e),M(be.$$.fragment,e),M($e.$$.fragment,e),M(Te.$$.fragment,e),M(_e.$$.fragment,e),M(ne.$$.fragment,e),M(ke.$$.fragment,e),M(Ze.$$.fragment,e),M(Ge.$$.fragment,e),M(Ve.$$.fragment,e),M(re.$$.fragment,e),M(oe.$$.fragment,e),M(Re.$$.fragment,e),M(Xe.$$.fragment,e),M(ze.$$.fragment,e),M(ie.$$.fragment,e),wt=!0)},o(e){y(g.$$.fragment,e),y(B.$$.fragment,e),y(Z.$$.fragment,e),y(H.$$.fragment,e),y(N.$$.fragment,e),y(S.$$.fragment,e),y(q.$$.fragment,e),y(L.$$.fragment,e),y(K.$$.fragment,e),y(ue.$$.fragment,e),y(be.$$.fragment,e),y($e.$$.fragment,e),y(Te.$$.fragment,e),y(_e.$$.fragment,e),y(ne.$$.fragment,e),y(ke.$$.fragment,e),y(Ze.$$.fragment,e),y(Ge.$$.fragment,e),y(Ve.$$.fragment,e),y(re.$$.fragment,e),y(oe.$$.fragment,e),y(Re.$$.fragment,e),y(Xe.$$.fragment,e),y(ze.$$.fragment,e),y(ie.$$.fragment,e),wt=!1},d(e){e&&(a(c),a(t),a(m),a(v),a(G),a(V),a(J),a(R),a(_),a(o),a(U),a(z),a(X),a(x),a(ce),a(E),a(ae),a(me),a(Y),a(le),a(fe),a(Q),a(A),a(he),a(P),a(D),a(de),a(r),a(w),a(Ye),a(qe),a(Me),a(Qe),a(ye),a(Ae),a(Le),a(ge),a(Pe),a(De),a(je),a(Ke),a(we),a(Oe),a(et),a(Ue),a(tt),a(st),a(Je),a(at),a(lt),a(nt),a(ve),a(rt),a(ot),a(Ce),a(it),a(pt),a(xe),a(ct),a(mt),a(ft),a(ht),a(dt),a(We),a(ut),a(Be),a(Mt),a(yt),a(He),a(bt),a(gt),a(Ie),a($t),a(jt),a(Ee)),a(s),b(g,e),b(B,e),b(Z,e),b(H,e),b(N,e),b(S,e),b(q,e),b(L,e),b(K,e),b(ue,e),b(be,e),b($e,e),b(Te,e),b(_e,e),b(ne,e),b(ke,e),b(Ze,e),b(Ge,e),b(Ve,e),b(re,e),b(oe,e),b(Re,e),b(Xe,e),b(ze,e),b(ie,e)}}}const gs='{"title":"Summarization","local":"summarization","sections":[{"title":"Load BillSum dataset","local":"load-billsum-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},{"title":"Inference","local":"inference","sections":[],"depth":2}],"depth":1}';function $s(k){return Lt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Zs extends Pt{constructor(s){super(),Dt(this,s,$s,bs,At,{})}}export{Zs as component};
