import{S as B_,i as I_,s as F_,e as o,t as a,k as d,w as q,c as i,a as p,h as n,d as s,m as f,x as E,g as l,G as t,y,q as w,o as g,B as D,b as B,U as L_,M as z_,V as N_,N as Op,p as Ct,v as H_,n as Tt}from"../../chunks/vendor-hf-doc-builder.js";import{T as Mp}from"../../chunks/Tip-hf-doc-builder.js";import{Y as Bp}from"../../chunks/Youtube-hf-doc-builder.js";import{I as _f}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{C as P}from"../../chunks/CodeBlock-hf-doc-builder.js";import{D as O_}from"../../chunks/DocNotebookDropdown-hf-doc-builder.js";import{F as V_}from"../../chunks/FrameworkSwitchCourse-hf-doc-builder.js";function Q_(H){let c,h;return c=new O_({props:{classNames:"absolute z-10 right-0 top-0",options:[{label:"Google Colab",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/master/course/chapter7/section7_tf.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/chapter7/section7_tf.ipynb"}]}}),{c(){q(c.$$.fragment)},l(_){E(c.$$.fragment,_)},m(_,v){y(c,_,v),h=!0},i(_){h||(w(c.$$.fragment,_),h=!0)},o(_){g(c.$$.fragment,_),h=!1},d(_){D(c,_)}}}function R_(H){let c,h;return c=new O_({props:{classNames:"absolute z-10 right-0 top-0",options:[{label:"Google Colab",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/master/course/chapter7/section7_pt.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/chapter7/section7_pt.ipynb"}]}}),{c(){q(c.$$.fragment)},l(_){E(c.$$.fragment,_)},m(_,v){y(c,_,v),h=!0},i(_){h||(w(c.$$.fragment,_),h=!0)},o(_){g(c.$$.fragment,_),h=!1},d(_){D(c,_)}}}function G_(H){let c,h,_,v,T,$,j,x,m,S,b,k,O,L;return{c(){c=o("p"),h=a("\u{1F4A1} \u50CF BERT \u8FD9\u6837\u7684\u7EAF\u7F16\u7801\u5668\u6A21\u578B\u5F80\u5F80\u5F88\u64C5\u957F\u63D0\u53D6\u8BF8\u5982 \u201C\u8C01\u53D1\u660E\u4E86 Transformer \u67B6\u6784?\u201D\u4E4B\u7C7B\u7684\u4E8B\u5B9E\u6027\u95EE\u9898\u7684\u7B54\u6848\u3002\u4F46\u5728\u7ED9\u51FA\u8BF8\u5982 \u201C\u4E3A\u4EC0\u4E48\u5929\u7A7A\u662F\u84DD\u8272\u7684?\u201D \u4E4B\u7C7B\u7684\u5F00\u653E\u5F0F\u95EE\u9898\u65F6\u8868\u73B0\u4E0D\u4F73\u3002\u5728\u8FD9\u4E9B\u66F4\u5177\u6311\u6218\u6027\u7684\u60C5\u51B5\u4E0B, T5 \u548C BART \u7B49\u7F16\u7801\u5668-\u89E3\u7801\u5668\u6A21\u578B\u901A\u5E38\u4F7F\u7528\u4EE5\u4E0E "),_=o("a"),v=a("\u6587\u672C\u6458\u8981"),T=a(" \u975E\u5E38\u76F8\u4F3C\u7684\u65B9\u5F0F\u5408\u6210\u4FE1\u606F\u3002\u5982\u679C\u4F60\u5BF9\u8FD9\u79CD\u7C7B\u578B\u7684"),$=o("em"),j=a("\u751F\u6210\u5F0F"),x=a("\u95EE\u7B54\u611F\u5174\u8DA3, \u6211\u4EEC\u5EFA\u8BAE\u60A8\u67E5\u770B\u6211\u4EEC\u57FA\u4E8E "),m=o("a"),S=a("ELI5 \u6570\u636E\u96C6"),b=a(" \u7684 "),k=o("a"),O=a("\u6F14\u793A"),L=a("\u3002"),this.h()},l(M){c=i(M,"P",{});var C=p(c);h=n(C,"\u{1F4A1} \u50CF BERT \u8FD9\u6837\u7684\u7EAF\u7F16\u7801\u5668\u6A21\u578B\u5F80\u5F80\u5F88\u64C5\u957F\u63D0\u53D6\u8BF8\u5982 \u201C\u8C01\u53D1\u660E\u4E86 Transformer \u67B6\u6784?\u201D\u4E4B\u7C7B\u7684\u4E8B\u5B9E\u6027\u95EE\u9898\u7684\u7B54\u6848\u3002\u4F46\u5728\u7ED9\u51FA\u8BF8\u5982 \u201C\u4E3A\u4EC0\u4E48\u5929\u7A7A\u662F\u84DD\u8272\u7684?\u201D \u4E4B\u7C7B\u7684\u5F00\u653E\u5F0F\u95EE\u9898\u65F6\u8868\u73B0\u4E0D\u4F73\u3002\u5728\u8FD9\u4E9B\u66F4\u5177\u6311\u6218\u6027\u7684\u60C5\u51B5\u4E0B, T5 \u548C BART \u7B49\u7F16\u7801\u5668-\u89E3\u7801\u5668\u6A21\u578B\u901A\u5E38\u4F7F\u7528\u4EE5\u4E0E "),_=i(C,"A",{href:!0});var Q=p(_);v=n(Q,"\u6587\u672C\u6458\u8981"),Q.forEach(s),T=n(C," \u975E\u5E38\u76F8\u4F3C\u7684\u65B9\u5F0F\u5408\u6210\u4FE1\u606F\u3002\u5982\u679C\u4F60\u5BF9\u8FD9\u79CD\u7C7B\u578B\u7684"),$=i(C,"EM",{});var z=p($);j=n(z,"\u751F\u6210\u5F0F"),z.forEach(s),x=n(C,"\u95EE\u7B54\u611F\u5174\u8DA3, \u6211\u4EEC\u5EFA\u8BAE\u60A8\u67E5\u770B\u6211\u4EEC\u57FA\u4E8E "),m=i(C,"A",{href:!0,rel:!0});var A=p(m);S=n(A,"ELI5 \u6570\u636E\u96C6"),A.forEach(s),b=n(C," \u7684 "),k=i(C,"A",{href:!0,rel:!0});var N=p(k);O=n(N,"\u6F14\u793A"),N.forEach(s),L=n(C,"\u3002"),C.forEach(s),this.h()},h(){B(_,"href","/course/chapter7/5"),B(m,"href","https://huggingface.co/datasets/eli5"),B(m,"rel","nofollow"),B(k,"href","https://yjernite.github.io/lfqa.html"),B(k,"rel","nofollow")},m(M,C){l(M,c,C),t(c,h),t(c,_),t(_,v),t(c,T),t(c,$),t($,j),t(c,x),t(c,m),t(m,S),t(c,b),t(c,k),t(k,O),t(c,L)},d(M){M&&s(c)}}}function W_(H){let c,h,_,v,T,$,j,x,m,S,b;return{c(){c=o("p"),h=a("\u270F\uFE0F "),_=o("strong"),v=a("\u8F6E\u5230\u4F60\u4E86!"),T=a(" \u4F7F\u7528 XLNet \u67B6\u6784\u65F6, \u5728\u5DE6\u4FA7\u5E94\u7528\u586B\u5145, \u5E76\u5207\u6362\u95EE\u9898\u548C\u4E0A\u4E0B\u6587\u3002\u5C06\u6211\u4EEC\u521A\u521A\u770B\u5230\u7684\u6240\u6709\u4EE3\u7801\u6539\u7F16\u4E3A XLNet \u67B6\u6784 (\u5E76\u6DFB\u52A0 "),$=o("code"),j=a("padding=True"),x=a(")\u3002\u8BF7\u6CE8\u610F, "),m=o("code"),S=a("[CLS]"),b=a(" \u6807\u8BB0\u53EF\u80FD\u4E0D\u5728\u5E94\u7528\u586B\u5145\u7684 0 \u4F4D\u7F6E\u3002")},l(k){c=i(k,"P",{});var O=p(c);h=n(O,"\u270F\uFE0F "),_=i(O,"STRONG",{});var L=p(_);v=n(L,"\u8F6E\u5230\u4F60\u4E86!"),L.forEach(s),T=n(O," \u4F7F\u7528 XLNet \u67B6\u6784\u65F6, \u5728\u5DE6\u4FA7\u5E94\u7528\u586B\u5145, \u5E76\u5207\u6362\u95EE\u9898\u548C\u4E0A\u4E0B\u6587\u3002\u5C06\u6211\u4EEC\u521A\u521A\u770B\u5230\u7684\u6240\u6709\u4EE3\u7801\u6539\u7F16\u4E3A XLNet \u67B6\u6784 (\u5E76\u6DFB\u52A0 "),$=i(O,"CODE",{});var M=p($);j=n(M,"padding=True"),M.forEach(s),x=n(O,")\u3002\u8BF7\u6CE8\u610F, "),m=i(O,"CODE",{});var C=p(m);S=n(C,"[CLS]"),C.forEach(s),b=n(O," \u6807\u8BB0\u53EF\u80FD\u4E0D\u5728\u5E94\u7528\u586B\u5145\u7684 0 \u4F4D\u7F6E\u3002"),O.forEach(s)},m(k,O){l(k,c,O),t(c,h),t(c,_),t(_,v),t(c,T),t(c,$),t($,j),t(c,x),t(c,m),t(m,S),t(c,b)},d(k){k&&s(c)}}}function U_(H){let c,h,_,v,T,$,j,x,m,S,b;return v=new _f({}),{c(){c=o("h2"),h=o("a"),_=o("span"),q(v.$$.fragment),T=d(),$=o("span"),j=a("\u4F7F\u7528 Keras \u5FAE\u8C03\u6A21\u578B"),x=d(),m=o("p"),S=a("\u8FD9\u4E2A\u793A\u4F8B\u7684\u8BAD\u7EC3\u4EE3\u7801\u770B\u8D77\u6765\u5F88\u50CF\u524D\u51E0\u8282\u4E2D\u7684\u4EE3\u7801, \u4F46\u662F\u8BA1\u7B97\u6307\u6807\u5C06\u662F\u552F\u4E00\u7684\u6311\u6218\u3002\u56E0\u4E3A\u6211\u4EEC\u5C06\u6240\u6709\u7684\u6837\u672C\u586B\u5145\u5230\u6211\u4EEC\u8BBE\u7F6E\u7684\u6700\u5927\u957F\u5EA6, \u6240\u4EE5\u4E0D\u9700\u8981\u5B9A\u4E49\u6570\u636E\u6574\u7406\u5668, \u6240\u4EE5\u8FD9\u4E2A\u5EA6\u91CF\u8BA1\u7B97\u5B9E\u9645\u4E0A\u662F\u6211\u4EEC\u552F\u4E00\u9700\u8981\u62C5\u5FC3\u7684\u4E8B\u60C5\u3002\u56F0\u96BE\u7684\u90E8\u5206\u662F\u5C06\u6A21\u578B\u9884\u6D4B\u540E\u5904\u7406\u6210\u539F\u59CB\u4F8B\u5B50\u4E2D\u7684\u6587\u672C\u8303\u56F4; \u4E00\u65E6\u6211\u4EEC\u5B8C\u6210\u4E86\u8FD9\u4E9B, \u{1F917} Datasets \u5E93\u4E2D\u7684\u6307\u6807\u5C06\u4E3A\u6211\u4EEC\u5B8C\u6210\u5927\u90E8\u5206\u5DE5\u4F5C\u3002"),this.h()},l(k){c=i(k,"H2",{class:!0});var O=p(c);h=i(O,"A",{id:!0,class:!0,href:!0});var L=p(h);_=i(L,"SPAN",{});var M=p(_);E(v.$$.fragment,M),M.forEach(s),L.forEach(s),T=f(O),$=i(O,"SPAN",{});var C=p($);j=n(C,"\u4F7F\u7528 Keras \u5FAE\u8C03\u6A21\u578B"),C.forEach(s),O.forEach(s),x=f(k),m=i(k,"P",{});var Q=p(m);S=n(Q,"\u8FD9\u4E2A\u793A\u4F8B\u7684\u8BAD\u7EC3\u4EE3\u7801\u770B\u8D77\u6765\u5F88\u50CF\u524D\u51E0\u8282\u4E2D\u7684\u4EE3\u7801, \u4F46\u662F\u8BA1\u7B97\u6307\u6807\u5C06\u662F\u552F\u4E00\u7684\u6311\u6218\u3002\u56E0\u4E3A\u6211\u4EEC\u5C06\u6240\u6709\u7684\u6837\u672C\u586B\u5145\u5230\u6211\u4EEC\u8BBE\u7F6E\u7684\u6700\u5927\u957F\u5EA6, \u6240\u4EE5\u4E0D\u9700\u8981\u5B9A\u4E49\u6570\u636E\u6574\u7406\u5668, \u6240\u4EE5\u8FD9\u4E2A\u5EA6\u91CF\u8BA1\u7B97\u5B9E\u9645\u4E0A\u662F\u6211\u4EEC\u552F\u4E00\u9700\u8981\u62C5\u5FC3\u7684\u4E8B\u60C5\u3002\u56F0\u96BE\u7684\u90E8\u5206\u662F\u5C06\u6A21\u578B\u9884\u6D4B\u540E\u5904\u7406\u6210\u539F\u59CB\u4F8B\u5B50\u4E2D\u7684\u6587\u672C\u8303\u56F4; \u4E00\u65E6\u6211\u4EEC\u5B8C\u6210\u4E86\u8FD9\u4E9B, \u{1F917} Datasets \u5E93\u4E2D\u7684\u6307\u6807\u5C06\u4E3A\u6211\u4EEC\u5B8C\u6210\u5927\u90E8\u5206\u5DE5\u4F5C\u3002"),Q.forEach(s),this.h()},h(){B(h,"id","keras"),B(h,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),B(h,"href","#keras"),B(c,"class","relative group")},m(k,O){l(k,c,O),t(c,h),t(h,_),y(v,_,null),t(c,T),t(c,$),t($,j),l(k,x,O),l(k,m,O),t(m,S),b=!0},i(k){b||(w(v.$$.fragment,k),b=!0)},o(k){g(v.$$.fragment,k),b=!1},d(k){k&&s(c),D(v),k&&s(x),k&&s(m)}}}function J_(H){let c,h,_,v,T,$,j,x,m,S,b,k,O,L,M,C,Q;return v=new _f({}),{c(){c=o("h2"),h=o("a"),_=o("span"),q(v.$$.fragment),T=d(),$=o("span"),j=a("\u4F7F\u7528 "),x=o("code"),m=a("Trainer"),S=a(" API \u5FAE\u8C03\u6A21\u578B"),b=d(),k=o("p"),O=a("\u8FD9\u4E2A\u4F8B\u5B50\u7684\u8BAD\u7EC3\u4EE3\u7801\u770B\u8D77\u6765\u5F88\u50CF\u524D\u9762\u51E0\u8282\u4E2D\u7684\u4EE3\u7801 \u2014 \u6700\u96BE\u7684\u662F\u7F16\u5199 "),L=o("code"),M=a("compute_metrics()"),C=a(" \u51FD\u6570\u3002\u7531\u4E8E\u6211\u4EEC\u5C06\u6240\u6709\u6837\u672C\u586B\u5145\u5230\u6211\u4EEC\u8BBE\u7F6E\u7684\u6700\u5927\u957F\u5EA6, \u56E0\u6B64\u6CA1\u6709\u6570\u636E\u6574\u7406\u5668\u8981\u5B9A\u4E49, \u6240\u4EE5\u8FD9\u4E2A\u5EA6\u91CF\u8BA1\u7B97\u771F\u7684\u662F\u6211\u4EEC\u552F\u4E00\u9700\u8981\u62C5\u5FC3\u7684\u4E8B\u60C5\u3002\u56F0\u96BE\u7684\u90E8\u5206\u662F\u5C06\u6A21\u578B\u9884\u6D4B\u540E\u5904\u7406\u4E3A\u539F\u59CB\u793A\u4F8B\u4E2D\u7684\u6587\u672C\u8303\u56F4; \u4E00\u65E6\u6211\u4EEC\u8FD9\u6837\u505A\u4E86, \u{1F917} Datasets \u5E93\u4E2D\u7684\u6307\u6807\u5C06\u4E3A\u6211\u4EEC\u5B8C\u6210\u5927\u90E8\u5206\u5DE5\u4F5C\u3002"),this.h()},l(z){c=i(z,"H2",{class:!0});var A=p(c);h=i(A,"A",{id:!0,class:!0,href:!0});var N=p(h);_=i(N,"SPAN",{});var R=p(_);E(v.$$.fragment,R),R.forEach(s),N.forEach(s),T=f(A),$=i(A,"SPAN",{});var G=p($);j=n(G,"\u4F7F\u7528 "),x=i(G,"CODE",{});var K=p(x);m=n(K,"Trainer"),K.forEach(s),S=n(G," API \u5FAE\u8C03\u6A21\u578B"),G.forEach(s),A.forEach(s),b=f(z),k=i(z,"P",{});var W=p(k);O=n(W,"\u8FD9\u4E2A\u4F8B\u5B50\u7684\u8BAD\u7EC3\u4EE3\u7801\u770B\u8D77\u6765\u5F88\u50CF\u524D\u9762\u51E0\u8282\u4E2D\u7684\u4EE3\u7801 \u2014 \u6700\u96BE\u7684\u662F\u7F16\u5199 "),L=i(W,"CODE",{});var I=p(L);M=n(I,"compute_metrics()"),I.forEach(s),C=n(W," \u51FD\u6570\u3002\u7531\u4E8E\u6211\u4EEC\u5C06\u6240\u6709\u6837\u672C\u586B\u5145\u5230\u6211\u4EEC\u8BBE\u7F6E\u7684\u6700\u5927\u957F\u5EA6, \u56E0\u6B64\u6CA1\u6709\u6570\u636E\u6574\u7406\u5668\u8981\u5B9A\u4E49, \u6240\u4EE5\u8FD9\u4E2A\u5EA6\u91CF\u8BA1\u7B97\u771F\u7684\u662F\u6211\u4EEC\u552F\u4E00\u9700\u8981\u62C5\u5FC3\u7684\u4E8B\u60C5\u3002\u56F0\u96BE\u7684\u90E8\u5206\u662F\u5C06\u6A21\u578B\u9884\u6D4B\u540E\u5904\u7406\u4E3A\u539F\u59CB\u793A\u4F8B\u4E2D\u7684\u6587\u672C\u8303\u56F4; \u4E00\u65E6\u6211\u4EEC\u8FD9\u6837\u505A\u4E86, \u{1F917} Datasets \u5E93\u4E2D\u7684\u6307\u6807\u5C06\u4E3A\u6211\u4EEC\u5B8C\u6210\u5927\u90E8\u5206\u5DE5\u4F5C\u3002"),W.forEach(s),this.h()},h(){B(h,"id","trainer-api"),B(h,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),B(h,"href","#trainer-api"),B(c,"class","relative group")},m(z,A){l(z,c,A),t(c,h),t(h,_),y(v,_,null),t(c,T),t(c,$),t($,j),t($,x),t(x,m),t($,S),l(z,b,A),l(z,k,A),t(k,O),t(k,L),t(L,M),t(k,C),Q=!0},i(z){Q||(w(v.$$.fragment,z),Q=!0)},o(z){g(v.$$.fragment,z),Q=!1},d(z){z&&s(c),D(v),z&&s(b),z&&s(k)}}}function X_(H){let c,h;return c=new Bp({props:{id:"VN67ZpN33Ss"}}),{c(){q(c.$$.fragment)},l(_){E(c.$$.fragment,_)},m(_,v){y(c,_,v),h=!0},i(_){h||(w(c.$$.fragment,_),h=!0)},o(_){g(c.$$.fragment,_),h=!1},d(_){D(c,_)}}}function K_(H){let c,h;return c=new Bp({props:{id:"BNy08iIWVJM"}}),{c(){q(c.$$.fragment)},l(_){E(c.$$.fragment,_)},m(_,v){y(c,_,v),h=!0},i(_){h||(w(c.$$.fragment,_),h=!0)},o(_){g(c.$$.fragment,_),h=!1},d(_){D(c,_)}}}function Y_(H){let c,h,_,v,T,$,j;return c=new P({props:{code:`import tensorflow as tf
from transformers import TFAutoModelForQuestionAnswering

eval_set_for_model = eval_set.remove_columns(["example_id", "offset_mapping"])
eval_set_for_model.set_format("numpy")

batch = {k: eval_set_for_model[k] for k in eval_set_for_model.column_names}
trained_model = TFAutoModelForQuestionAnswering.from_pretrained(trained_checkpoint)

outputs = trained_model(**batch)`,highlighted:`<span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TFAutoModelForQuestionAnswering

eval_set_for_model = eval_set.remove_columns([<span class="hljs-string">&quot;example_id&quot;</span>, <span class="hljs-string">&quot;offset_mapping&quot;</span>])
eval_set_for_model.set_format(<span class="hljs-string">&quot;numpy&quot;</span>)

batch = {k: eval_set_for_model[k] <span class="hljs-keyword">for</span> k <span class="hljs-keyword">in</span> eval_set_for_model.column_names}
trained_model = TFAutoModelForQuestionAnswering.from_pretrained(trained_checkpoint)

outputs = trained_model(**batch)`}}),$=new P({props:{code:`start_logits = outputs.start_logits.numpy()
end_logits = outputs.end_logits.numpy()`,highlighted:`start_logits = outputs.start_logits.numpy()
end_logits = outputs.end_logits.numpy()`}}),{c(){q(c.$$.fragment),h=d(),_=o("p"),v=a("\u4E3A\u4E86\u4FBF\u4E8E\u5B9E\u9A8C, \u8BA9\u6211\u4EEC\u5C06\u8FD9\u4E9B\u8F93\u51FA\u8F6C\u6362\u4E3A NumPy \u6570\u7EC4:"),T=d(),q($.$$.fragment)},l(x){E(c.$$.fragment,x),h=f(x),_=i(x,"P",{});var m=p(_);v=n(m,"\u4E3A\u4E86\u4FBF\u4E8E\u5B9E\u9A8C, \u8BA9\u6211\u4EEC\u5C06\u8FD9\u4E9B\u8F93\u51FA\u8F6C\u6362\u4E3A NumPy \u6570\u7EC4:"),m.forEach(s),T=f(x),E($.$$.fragment,x)},m(x,m){y(c,x,m),l(x,h,m),l(x,_,m),t(_,v),l(x,T,m),y($,x,m),j=!0},i(x){j||(w(c.$$.fragment,x),w($.$$.fragment,x),j=!0)},o(x){g(c.$$.fragment,x),g($.$$.fragment,x),j=!1},d(x){D(c,x),x&&s(h),x&&s(_),x&&s(T),D($,x)}}}function Z_(H){let c,h,_,v,T,$,j,x,m,S;return c=new P({props:{code:`import torch
from transformers import AutoModelForQuestionAnswering

eval_set_for_model = eval_set.remove_columns(["example_id", "offset_mapping"])
eval_set_for_model.set_format("torch")

device = torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu")
batch = {k: eval_set_for_model[k].to(device) for k in eval_set_for_model.column_names}
trained_model = AutoModelForQuestionAnswering.from_pretrained(trained_checkpoint).to(
    device
)

with torch.no_grad():
    outputs = trained_model(**batch)`,highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForQuestionAnswering

eval_set_for_model = eval_set.remove_columns([<span class="hljs-string">&quot;example_id&quot;</span>, <span class="hljs-string">&quot;offset_mapping&quot;</span>])
eval_set_for_model.set_format(<span class="hljs-string">&quot;torch&quot;</span>)

device = torch.device(<span class="hljs-string">&quot;cuda&quot;</span>) <span class="hljs-keyword">if</span> torch.cuda.is_available() <span class="hljs-keyword">else</span> torch.device(<span class="hljs-string">&quot;cpu&quot;</span>)
batch = {k: eval_set_for_model[k].to(device) <span class="hljs-keyword">for</span> k <span class="hljs-keyword">in</span> eval_set_for_model.column_names}
trained_model = AutoModelForQuestionAnswering.from_pretrained(trained_checkpoint).to(
    device
)

<span class="hljs-keyword">with</span> torch.no_grad():
    outputs = trained_model(**batch)`}}),m=new P({props:{code:`start_logits = outputs.start_logits.cpu().numpy()
end_logits = outputs.end_logits.cpu().numpy()`,highlighted:`start_logits = outputs.start_logits.cpu().numpy()
end_logits = outputs.end_logits.cpu().numpy()`}}),{c(){q(c.$$.fragment),h=d(),_=o("p"),v=a("\u7531\u4E8E "),T=o("code"),$=a("Trainer"),j=a(" \u5C06\u4E3A\u6211\u4EEC\u63D0\u4F9B NumPy \u6570\u7EC4\u7684\u9884\u6D4B, \u6211\u4EEC\u83B7\u53D6\u5F00\u59CB\u548C\u7ED3\u675F logits \u5E76\u5C06\u5B83\u4EEC\u8F6C\u6362\u4E3A\u8BE5\u683C\u5F0F"),x=d(),q(m.$$.fragment)},l(b){E(c.$$.fragment,b),h=f(b),_=i(b,"P",{});var k=p(_);v=n(k,"\u7531\u4E8E "),T=i(k,"CODE",{});var O=p(T);$=n(O,"Trainer"),O.forEach(s),j=n(k," \u5C06\u4E3A\u6211\u4EEC\u63D0\u4F9B NumPy \u6570\u7EC4\u7684\u9884\u6D4B, \u6211\u4EEC\u83B7\u53D6\u5F00\u59CB\u548C\u7ED3\u675F logits \u5E76\u5C06\u5B83\u4EEC\u8F6C\u6362\u4E3A\u8BE5\u683C\u5F0F"),k.forEach(s),x=f(b),E(m.$$.fragment,b)},m(b,k){y(c,b,k),l(b,h,k),l(b,_,k),t(_,v),t(_,T),t(T,$),t(_,j),l(b,x,k),y(m,b,k),S=!0},i(b){S||(w(c.$$.fragment,b),w(m.$$.fragment,b),S=!0)},o(b){g(c.$$.fragment,b),g(m.$$.fragment,b),S=!1},d(b){D(c,b),b&&s(h),b&&s(_),b&&s(x),D(m,b)}}}function em(H){let c,h,_,v,T;return{c(){c=o("p"),h=a("\u73B0\u5728, \u8BA9\u6211\u4EEC\u5C06\u521A\u624D\u6240\u505A\u7684\u4E00\u5207\u653E\u5165 "),_=o("code"),v=a("compute_metrics()"),T=a(" \u51FD\u6570\u4E2D, \u6211\u4EEC\u5C06\u5728\u8BAD\u7EC3\u6A21\u578B\u540E\u4F7F\u7528\u8BE5\u51FD\u6570\u3002\u6211\u4EEC\u9700\u8981\u4F20\u9012\u7684\u4E0D\u4EC5\u4EC5\u662F\u8F93\u51FA\u65E5\u5FD7, \u56E0\u4E3A\u6211\u4EEC\u5FC5\u987B\u5728\u7279\u5F81\u6570\u636E\u96C6\u4E2D\u5BFB\u627E\u504F\u79FB\u91CF, \u5728\u539F\u59CB\u4E0A\u4E0B\u6587\u7684\u793A\u4F8B\u6570\u636E\u96C6\u4E2D\u5BFB\u627E:")},l($){c=i($,"P",{});var j=p(c);h=n(j,"\u73B0\u5728, \u8BA9\u6211\u4EEC\u5C06\u521A\u624D\u6240\u505A\u7684\u4E00\u5207\u653E\u5165 "),_=i(j,"CODE",{});var x=p(_);v=n(x,"compute_metrics()"),x.forEach(s),T=n(j," \u51FD\u6570\u4E2D, \u6211\u4EEC\u5C06\u5728\u8BAD\u7EC3\u6A21\u578B\u540E\u4F7F\u7528\u8BE5\u51FD\u6570\u3002\u6211\u4EEC\u9700\u8981\u4F20\u9012\u7684\u4E0D\u4EC5\u4EC5\u662F\u8F93\u51FA\u65E5\u5FD7, \u56E0\u4E3A\u6211\u4EEC\u5FC5\u987B\u5728\u7279\u5F81\u6570\u636E\u96C6\u4E2D\u5BFB\u627E\u504F\u79FB\u91CF, \u5728\u539F\u59CB\u4E0A\u4E0B\u6587\u7684\u793A\u4F8B\u6570\u636E\u96C6\u4E2D\u5BFB\u627E:"),j.forEach(s)},m($,j){l($,c,j),t(c,h),t(c,_),t(_,v),t(c,T)},d($){$&&s(c)}}}function sm(H){let c,h,_,v,T,$,j,x,m,S,b,k,O,L,M,C,Q,z,A;return{c(){c=o("p"),h=a("\u73B0\u5728, \u8BA9\u6211\u4EEC\u628A\u521A\u624D\u6240\u505A\u7684\u4E00\u5207\u653E\u5728 "),_=o("code"),v=a("compute_metrics()"),T=a(" \u51FD\u6570\u4E2D, \u6211\u4EEC\u5C06\u5728 "),$=o("code"),j=a("Trainer"),x=a(" \u4E2D\u4F7F\u7528\u5B83\u3002\u901A\u5E38, "),m=o("code"),S=a("compute_metrics()"),b=a(" \u51FD\u6570\u53EA\u63A5\u6536\u4E00\u4E2A\u5305\u542B logits \u548C labels \u7684\u5143\u7EC4 "),k=o("code"),O=a("eval_preds"),L=a("\u3002\u8FD9\u91CC\u6211\u4EEC\u9700\u8981\u66F4\u591A, \u56E0\u4E3A\u6211\u4EEC\u5FC5\u987B\u5728\u7279\u5F81\u6570\u636E\u96C6\u4E2D\u67E5\u627E\u504F\u79FB\u91CF, \u5728\u539F\u59CB\u4E0A\u4E0B\u6587\u7684\u793A\u4F8B\u6570\u636E\u96C6\u4E2D\u67E5\u627E, \u56E0\u6B64\u6211\u4EEC\u5C06\u65E0\u6CD5\u5728\u8BAD\u7EC3\u671F\u95F4\u4F7F\u7528\u6B64\u51FD\u6570\u83B7\u5F97\u5E38\u89C4\u8BC4\u4F30\u7ED3\u679C\u3002\u6211\u4EEC\u53EA\u4F1A\u5728\u8BAD\u7EC3\u7ED3\u675F\u65F6\u4F7F\u7528\u5B83\u6765\u68C0\u67E5\u7ED3\u679C\u3002"),M=d(),C=o("p"),Q=o("code"),z=a("compute_metrics()"),A=a(" \u51FD\u6570\u5C06\u4E0E\u524D\u9762\u76F8\u540C\u7684\u6B65\u9AA4\u5206\u7EC4; \u6211\u4EEC\u53EA\u662F\u6DFB\u52A0\u4E00\u4E2A\u5C0F\u68C0\u67E5, \u4EE5\u9632\u6211\u4EEC\u6CA1\u6709\u63D0\u51FA\u4EFB\u4F55\u6709\u6548\u7684\u7B54\u6848 (\u5728\u8FD9\u79CD\u60C5\u51B5\u4E0B, \u6211\u4EEC\u9884\u6D4B\u4E00\u4E2A\u7A7A\u5B57\u7B26\u4E32)\u3002")},l(N){c=i(N,"P",{});var R=p(c);h=n(R,"\u73B0\u5728, \u8BA9\u6211\u4EEC\u628A\u521A\u624D\u6240\u505A\u7684\u4E00\u5207\u653E\u5728 "),_=i(R,"CODE",{});var G=p(_);v=n(G,"compute_metrics()"),G.forEach(s),T=n(R," \u51FD\u6570\u4E2D, \u6211\u4EEC\u5C06\u5728 "),$=i(R,"CODE",{});var K=p($);j=n(K,"Trainer"),K.forEach(s),x=n(R," \u4E2D\u4F7F\u7528\u5B83\u3002\u901A\u5E38, "),m=i(R,"CODE",{});var W=p(m);S=n(W,"compute_metrics()"),W.forEach(s),b=n(R," \u51FD\u6570\u53EA\u63A5\u6536\u4E00\u4E2A\u5305\u542B logits \u548C labels \u7684\u5143\u7EC4 "),k=i(R,"CODE",{});var I=p(k);O=n(I,"eval_preds"),I.forEach(s),L=n(R,"\u3002\u8FD9\u91CC\u6211\u4EEC\u9700\u8981\u66F4\u591A, \u56E0\u4E3A\u6211\u4EEC\u5FC5\u987B\u5728\u7279\u5F81\u6570\u636E\u96C6\u4E2D\u67E5\u627E\u504F\u79FB\u91CF, \u5728\u539F\u59CB\u4E0A\u4E0B\u6587\u7684\u793A\u4F8B\u6570\u636E\u96C6\u4E2D\u67E5\u627E, \u56E0\u6B64\u6211\u4EEC\u5C06\u65E0\u6CD5\u5728\u8BAD\u7EC3\u671F\u95F4\u4F7F\u7528\u6B64\u51FD\u6570\u83B7\u5F97\u5E38\u89C4\u8BC4\u4F30\u7ED3\u679C\u3002\u6211\u4EEC\u53EA\u4F1A\u5728\u8BAD\u7EC3\u7ED3\u675F\u65F6\u4F7F\u7528\u5B83\u6765\u68C0\u67E5\u7ED3\u679C\u3002"),R.forEach(s),M=f(N),C=i(N,"P",{});var U=p(C);Q=i(U,"CODE",{});var ae=p(Q);z=n(ae,"compute_metrics()"),ae.forEach(s),A=n(U," \u51FD\u6570\u5C06\u4E0E\u524D\u9762\u76F8\u540C\u7684\u6B65\u9AA4\u5206\u7EC4; \u6211\u4EEC\u53EA\u662F\u6DFB\u52A0\u4E00\u4E2A\u5C0F\u68C0\u67E5, \u4EE5\u9632\u6211\u4EEC\u6CA1\u6709\u63D0\u51FA\u4EFB\u4F55\u6709\u6548\u7684\u7B54\u6848 (\u5728\u8FD9\u79CD\u60C5\u51B5\u4E0B, \u6211\u4EEC\u9884\u6D4B\u4E00\u4E2A\u7A7A\u5B57\u7B26\u4E32)\u3002"),U.forEach(s)},m(N,R){l(N,c,R),t(c,h),t(c,_),t(_,v),t(c,T),t(c,$),t($,j),t(c,x),t(c,m),t(m,S),t(c,b),t(c,k),t(k,O),t(c,L),l(N,M,R),l(N,C,R),t(C,Q),t(Q,z),t(C,A)},d(N){N&&s(c),N&&s(M),N&&s(C)}}}function tm(H){let c,h,_,v,T,$,j,x;return j=new P({props:{code:"model = TFAutoModelForQuestionAnswering.from_pretrained(model_checkpoint)",highlighted:"model = TFAutoModelForQuestionAnswering.from_pretrained(model_checkpoint)"}}),{c(){c=o("p"),h=a("\u6211\u4EEC\u73B0\u5728\u51C6\u5907\u597D\u8BAD\u7EC3\u6211\u4EEC\u7684\u6A21\u578B\u4E86\u3002\u8BA9\u6211\u4EEC\u9996\u5148\u521B\u5EFA\u5B83, \u50CF\u4EE5\u524D\u4E00\u6837\u4F7F\u7528 "),_=o("code"),v=a("TFAutoModelForQuestionAnswering"),T=a(" \u7C7B:"),$=d(),q(j.$$.fragment)},l(m){c=i(m,"P",{});var S=p(c);h=n(S,"\u6211\u4EEC\u73B0\u5728\u51C6\u5907\u597D\u8BAD\u7EC3\u6211\u4EEC\u7684\u6A21\u578B\u4E86\u3002\u8BA9\u6211\u4EEC\u9996\u5148\u521B\u5EFA\u5B83, \u50CF\u4EE5\u524D\u4E00\u6837\u4F7F\u7528 "),_=i(S,"CODE",{});var b=p(_);v=n(b,"TFAutoModelForQuestionAnswering"),b.forEach(s),T=n(S," \u7C7B:"),S.forEach(s),$=f(m),E(j.$$.fragment,m)},m(m,S){l(m,c,S),t(c,h),t(c,_),t(_,v),t(c,T),l(m,$,S),y(j,m,S),x=!0},i(m){x||(w(j.$$.fragment,m),x=!0)},o(m){g(j.$$.fragment,m),x=!1},d(m){m&&s(c),m&&s($),D(j,m)}}}function am(H){let c,h,_,v,T,$,j,x;return j=new P({props:{code:"model = AutoModelForQuestionAnswering.from_pretrained(model_checkpoint)",highlighted:"model = AutoModelForQuestionAnswering.from_pretrained(model_checkpoint)"}}),{c(){c=o("p"),h=a("\u6211\u4EEC\u73B0\u5728\u51C6\u5907\u597D\u8BAD\u7EC3\u6211\u4EEC\u7684\u6A21\u578B\u4E86\u3002\u8BA9\u6211\u4EEC\u9996\u5148\u521B\u5EFA\u5B83, \u50CF\u4EE5\u524D\u4E00\u6837\u4F7F\u7528 "),_=o("code"),v=a("AutoModelForQuestionAnswering"),T=a(" \u7C7B:"),$=d(),q(j.$$.fragment)},l(m){c=i(m,"P",{});var S=p(c);h=n(S,"\u6211\u4EEC\u73B0\u5728\u51C6\u5907\u597D\u8BAD\u7EC3\u6211\u4EEC\u7684\u6A21\u578B\u4E86\u3002\u8BA9\u6211\u4EEC\u9996\u5148\u521B\u5EFA\u5B83, \u50CF\u4EE5\u524D\u4E00\u6837\u4F7F\u7528 "),_=i(S,"CODE",{});var b=p(_);v=n(b,"AutoModelForQuestionAnswering"),b.forEach(s),T=n(S," \u7C7B:"),S.forEach(s),$=f(m),E(j.$$.fragment,m)},m(m,S){l(m,c,S),t(c,h),t(c,_),t(_,v),t(c,T),l(m,$,S),y(j,m,S),x=!0},i(m){x||(w(j.$$.fragment,m),x=!0)},o(m){g(j.$$.fragment,m),x=!1},d(m){m&&s(c),m&&s($),D(j,m)}}}function nm(H){let c,h,_,v,T,$,j,x,m,S,b,k,O,L,M,C,Q,z,A,N,R,G,K,W;return v=new P({props:{code:`from transformers import DefaultDataCollator

data_collator = DefaultDataCollator(return_tensors="tf")`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DefaultDataCollator

data_collator = DefaultDataCollator(return_tensors=<span class="hljs-string">&quot;tf&quot;</span>)`}}),m=new P({props:{code:`tf_train_dataset = train_dataset.to_tf_dataset(
    columns=[
        "input_ids",
        "start_positions",
        "end_positions",
        "attention_mask",
        "token_type_ids",
    ],
    collate_fn=data_collator,
    shuffle=True,
    batch_size=16,
)
tf_eval_dataset = validation_dataset.to_tf_dataset(
    columns=["input_ids", "attention_mask", "token_type_ids"],
    collate_fn=data_collator,
    shuffle=False,
    batch_size=16,
)`,highlighted:`tf_train_dataset = train_dataset.to_tf_dataset(
    columns=[
        <span class="hljs-string">&quot;input_ids&quot;</span>,
        <span class="hljs-string">&quot;start_positions&quot;</span>,
        <span class="hljs-string">&quot;end_positions&quot;</span>,
        <span class="hljs-string">&quot;attention_mask&quot;</span>,
        <span class="hljs-string">&quot;token_type_ids&quot;</span>,
    ],
    collate_fn=data_collator,
    shuffle=<span class="hljs-literal">True</span>,
    batch_size=<span class="hljs-number">16</span>,
)
tf_eval_dataset = validation_dataset.to_tf_dataset(
    columns=[<span class="hljs-string">&quot;input_ids&quot;</span>, <span class="hljs-string">&quot;attention_mask&quot;</span>, <span class="hljs-string">&quot;token_type_ids&quot;</span>],
    collate_fn=data_collator,
    shuffle=<span class="hljs-literal">False</span>,
    batch_size=<span class="hljs-number">16</span>,
)`}}),L=new P({props:{code:`from transformers import create_optimizer
from transformers.keras_callbacks import PushToHubCallback
import tensorflow as tf

# The number of training steps is the number of samples in the dataset, divided by the batch size then multiplied
# by the total number of epochs. Note that the tf_train_dataset here is a batched tf.data.Dataset,
# not the original Hugging Face Dataset, so its len() is already num_samples // batch_size.
num_train_epochs = 3
num_train_steps = len(tf_train_dataset) * num_train_epochs
optimizer, schedule = create_optimizer(
    init_lr=2e-5,
    num_warmup_steps=0,
    num_train_steps=num_train_steps,
    weight_decay_rate=0.01,
)
model.compile(optimizer=optimizer)

# Train in mixed-precision float16
tf.keras.mixed_precision.set_global_policy("mixed_float16")`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> create_optimizer
<span class="hljs-keyword">from</span> transformers.keras_callbacks <span class="hljs-keyword">import</span> PushToHubCallback
<span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf

<span class="hljs-comment"># The number of training steps is the number of samples in the dataset, divided by the batch size then multiplied</span>
<span class="hljs-comment"># by the total number of epochs. Note that the tf_train_dataset here is a batched tf.data.Dataset,</span>
<span class="hljs-comment"># not the original Hugging Face Dataset, so its len() is already num_samples // batch_size.</span>
num_train_epochs = <span class="hljs-number">3</span>
num_train_steps = <span class="hljs-built_in">len</span>(tf_train_dataset) * num_train_epochs
optimizer, schedule = create_optimizer(
    init_lr=<span class="hljs-number">2e-5</span>,
    num_warmup_steps=<span class="hljs-number">0</span>,
    num_train_steps=num_train_steps,
    weight_decay_rate=<span class="hljs-number">0.01</span>,
)
model.<span class="hljs-built_in">compile</span>(optimizer=optimizer)

<span class="hljs-comment"># Train in mixed-precision float16</span>
tf.keras.mixed_precision.set_global_policy(<span class="hljs-string">&quot;mixed_float16&quot;</span>)`}}),{c(){c=o("p"),h=a("\u73B0\u5728, \u6211\u4EEC\u53EF\u4EE5\u521B\u5EFA\u6211\u4EEC\u7684 TF \u6570\u636E\u96C6\u3002\u8FD9\u6B21\u6211\u4EEC\u53EF\u4EE5\u4F7F\u7528\u7B80\u5355\u7684\u9ED8\u8BA4\u6570\u636E\u6574\u7406\u5668:"),_=d(),q(v.$$.fragment),T=d(),$=o("p"),j=a("\u73B0\u5728\u6211\u4EEC\u50CF\u5F80\u5E38\u4E00\u6837\u521B\u5EFA\u6570\u636E\u96C6\u3002"),x=d(),q(m.$$.fragment),S=d(),b=o("p"),k=a("\u63A5\u4E0B\u6765, \u6211\u4EEC\u8BBE\u7F6E\u4E86\u6211\u4EEC\u7684\u8BAD\u7EC3\u8D85\u53C2\u6570\u5E76\u7F16\u8BD1\u4E86\u6211\u4EEC\u7684\u6A21\u578B:"),O=d(),q(L.$$.fragment),M=d(),C=o("p"),Q=a("\u6700\u540E, \u6211\u4EEC\u51C6\u5907\u597D\u4F7F\u7528 "),z=o("code"),A=a("model.fit()"),N=a(" \u8FDB\u884C\u8BAD\u7EC3\u4E86\u3002\u6211\u4EEC\u4F7F\u7528 "),R=o("code"),G=a("PushToHubCallback"),K=a(" \u5728\u6BCF\u4E2A\u65F6\u671F\u4E4B\u540E\u5C06\u6A21\u578B\u4E0A\u4F20\u5230Hub\u3002")},l(I){c=i(I,"P",{});var U=p(c);h=n(U,"\u73B0\u5728, \u6211\u4EEC\u53EF\u4EE5\u521B\u5EFA\u6211\u4EEC\u7684 TF \u6570\u636E\u96C6\u3002\u8FD9\u6B21\u6211\u4EEC\u53EF\u4EE5\u4F7F\u7528\u7B80\u5355\u7684\u9ED8\u8BA4\u6570\u636E\u6574\u7406\u5668:"),U.forEach(s),_=f(I),E(v.$$.fragment,I),T=f(I),$=i(I,"P",{});var ae=p($);j=n(ae,"\u73B0\u5728\u6211\u4EEC\u50CF\u5F80\u5E38\u4E00\u6837\u521B\u5EFA\u6570\u636E\u96C6\u3002"),ae.forEach(s),x=f(I),E(m.$$.fragment,I),S=f(I),b=i(I,"P",{});var J=p(b);k=n(J,"\u63A5\u4E0B\u6765, \u6211\u4EEC\u8BBE\u7F6E\u4E86\u6211\u4EEC\u7684\u8BAD\u7EC3\u8D85\u53C2\u6570\u5E76\u7F16\u8BD1\u4E86\u6211\u4EEC\u7684\u6A21\u578B:"),J.forEach(s),O=f(I),E(L.$$.fragment,I),M=f(I),C=i(I,"P",{});var pe=p(C);Q=n(pe,"\u6700\u540E, \u6211\u4EEC\u51C6\u5907\u597D\u4F7F\u7528 "),z=i(pe,"CODE",{});var se=p(z);A=n(se,"model.fit()"),se.forEach(s),N=n(pe," \u8FDB\u884C\u8BAD\u7EC3\u4E86\u3002\u6211\u4EEC\u4F7F\u7528 "),R=i(pe,"CODE",{});var Z=p(R);G=n(Z,"PushToHubCallback"),Z.forEach(s),K=n(pe," \u5728\u6BCF\u4E2A\u65F6\u671F\u4E4B\u540E\u5C06\u6A21\u578B\u4E0A\u4F20\u5230Hub\u3002"),pe.forEach(s)},m(I,U){l(I,c,U),t(c,h),l(I,_,U),y(v,I,U),l(I,T,U),l(I,$,U),t($,j),l(I,x,U),y(m,I,U),l(I,S,U),l(I,b,U),t(b,k),l(I,O,U),y(L,I,U),l(I,M,U),l(I,C,U),t(C,Q),t(C,z),t(z,A),t(C,N),t(C,R),t(R,G),t(C,K),W=!0},i(I){W||(w(v.$$.fragment,I),w(m.$$.fragment,I),w(L.$$.fragment,I),W=!0)},o(I){g(v.$$.fragment,I),g(m.$$.fragment,I),g(L.$$.fragment,I),W=!1},d(I){I&&s(c),I&&s(_),D(v,I),I&&s(T),I&&s($),I&&s(x),D(m,I),I&&s(S),I&&s(b),I&&s(O),D(L,I),I&&s(M),I&&s(C)}}}function lm(H){let c,h,_,v,T,$,j,x,m,S,b,k,O,L,M,C,Q,z,A,N,R,G,K,W,I,U,ae,J,pe,se,Z,Ue,Se,ne,Oe;return J=new P({props:{code:`from transformers import TrainingArguments

args = TrainingArguments(
    "bert-finetuned-squad",
    evaluation_strategy="no",
    save_strategy="epoch",
    learning_rate=2e-5,
    num_train_epochs=3,
    weight_decay=0.01,
    fp16=True,
    push_to_hub=True,
)`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TrainingArguments

args = TrainingArguments(
    <span class="hljs-string">&quot;bert-finetuned-squad&quot;</span>,
    evaluation_strategy=<span class="hljs-string">&quot;no&quot;</span>,
    save_strategy=<span class="hljs-string">&quot;epoch&quot;</span>,
    learning_rate=<span class="hljs-number">2e-5</span>,
    num_train_epochs=<span class="hljs-number">3</span>,
    weight_decay=<span class="hljs-number">0.01</span>,
    fp16=<span class="hljs-literal">True</span>,
    push_to_hub=<span class="hljs-literal">True</span>,
)`}}),{c(){c=o("p"),h=a("\u5B8C\u6210\u540E, \u6211\u4EEC\u5C31\u53EF\u4EE5\u5B9A\u4E49\u6211\u4EEC\u7684 "),_=o("code"),v=a("TrainingArguments"),T=a("\u3002\u6B63\u5982\u6211\u4EEC\u5728\u5B9A\u4E49\u51FD\u6570\u6765\u8BA1\u7B97\u5EA6\u91CF\u65F6\u6240\u8BF4\u7684\u90A3\u6837, \u7531\u4E8E "),$=o("code"),j=a("compute_metrics()"),x=a(" \u51FD\u6570\u7684\u7B7E\u540D, \u6211\u4EEC\u5C06\u4E0D\u80FD\u6709\u5E38\u89C4\u7684\u6C42\u503C\u5FAA\u73AF\u3002\u6211\u4EEC\u53EF\u4EE5\u7F16\u5199 "),m=o("code"),S=a("Trainer"),b=a(" \u7684\u5B50\u7C7B\u6765\u5B8C\u6210\u8FD9\u4E00\u4EFB\u52A1(\u4F60\u53EF\u4EE5\u5728 "),k=o("a"),O=a("question answering example script"),L=a("\u4E2D\u627E\u5230\u4E00\u79CD\u65B9\u6CD5), \u4F46\u8FD9\u5BF9\u4E8E\u672C\u8282\u6765\u8BF4\u6709\u70B9\u592A\u957F\u4E86\u3002\u76F8\u53CD, \u6211\u4EEC\u53EA\u4F1A\u5728\u8BAD\u7EC3\u7ED3\u675F\u65F6\u8BC4\u4F30\u6A21\u578B, \u5E76\u5728\u4E0B\u9762\u7684\u201D\u81EA\u5B9A\u4E49\u8BAD\u7EC3\u5FAA\u73AF\u201D\u5411\u4F60\u5C55\u793A\u5982\u4F55\u8FDB\u884C\u5E38\u89C4\u8BC4\u4F30\u3002"),M=d(),C=o("p"),Q=a("T\u8FD9\u786E\u5B9E\u65F6 "),z=o("code"),A=a("Trainer"),N=a(" API \u663E\u793A\u5176\u5C40\u9650\u6027\u548C \u{1F917} Accelerate \u5E93\u7684\u4EAE\u70B9\u6240\u5728: \u6839\u636E\u7279\u5B9A\u7528\u4F8B\u81EA\u5B9A\u4E49\u7C7B\u53EF\u80FD\u5F88\u75DB\u82E6, \u4F46\u8C03\u6574\u5B8C\u5168\u516C\u5F00\u7684\u8BAD\u7EC3\u5FAA\u73AF\u5F88\u5BB9\u6613\u3002"),R=d(),G=o("p"),K=a("\u6765\u770B\u770B\u6211\u4EEC\u7684 "),W=o("code"),I=a("TrainingArguments"),U=a(":"),ae=d(),q(J.$$.fragment),pe=d(),se=o("p"),Z=a("\u6211\u4EEC\u4E4B\u524D\u5DF2\u7ECF\u770B\u5230\u4E86\u5176\u4E2D\u7684\u5927\u90E8\u5206: \u6211\u4EEC\u8BBE\u7F6E\u4E86\u4E00\u4E9B\u8D85\u53C2\u6570 (\u6BD4\u5982\u5B66\u4E60\u7387\u3001\u8BAD\u7EC3\u7684 epoch \u6570\u548C\u4E00\u4E9B\u6743\u91CD\u8870\u51CF), \u5E76\u8868\u660E\u6211\u4EEC\u5E0C\u671B\u5728\u6BCF\u4E2A epoch \u7ED3\u675F\u65F6\u4FDD\u5B58\u6A21\u578B, \u8DF3\u8FC7\u8BC4\u4F30, \u5E76\u5C06\u6211\u4EEC\u7684\u7ED3\u679C\u4E0A\u4F20\u5230\u6A21\u578B\u4E2D\u5FC3\u3002\u6211\u4EEC\u8FD8\u4F7F\u7528 "),Ue=o("code"),Se=a("fp16=True"),ne=a(" \u542F\u7528\u6DF7\u5408\u7CBE\u5EA6\u8BAD\u7EC3, \u56E0\u4E3A\u5B83\u53EF\u4EE5\u5728\u6700\u8FD1\u7684 GPU \u4E0A\u5F88\u597D\u5730\u52A0\u5FEB\u8BAD\u7EC3\u901F\u5EA6\u3002"),this.h()},l(V){c=i(V,"P",{});var X=p(c);h=n(X,"\u5B8C\u6210\u540E, \u6211\u4EEC\u5C31\u53EF\u4EE5\u5B9A\u4E49\u6211\u4EEC\u7684 "),_=i(X,"CODE",{});var us=p(_);v=n(us,"TrainingArguments"),us.forEach(s),T=n(X,"\u3002\u6B63\u5982\u6211\u4EEC\u5728\u5B9A\u4E49\u51FD\u6570\u6765\u8BA1\u7B97\u5EA6\u91CF\u65F6\u6240\u8BF4\u7684\u90A3\u6837, \u7531\u4E8E "),$=i(X,"CODE",{});var xe=p($);j=n(xe,"compute_metrics()"),xe.forEach(s),x=n(X," \u51FD\u6570\u7684\u7B7E\u540D, \u6211\u4EEC\u5C06\u4E0D\u80FD\u6709\u5E38\u89C4\u7684\u6C42\u503C\u5FAA\u73AF\u3002\u6211\u4EEC\u53EF\u4EE5\u7F16\u5199 "),m=i(X,"CODE",{});var we=p(m);S=n(we,"Trainer"),we.forEach(s),b=n(X," \u7684\u5B50\u7C7B\u6765\u5B8C\u6210\u8FD9\u4E00\u4EFB\u52A1(\u4F60\u53EF\u4EE5\u5728 "),k=i(X,"A",{href:!0,rel:!0});var ge=p(k);O=n(ge,"question answering example script"),ge.forEach(s),L=n(X,"\u4E2D\u627E\u5230\u4E00\u79CD\u65B9\u6CD5), \u4F46\u8FD9\u5BF9\u4E8E\u672C\u8282\u6765\u8BF4\u6709\u70B9\u592A\u957F\u4E86\u3002\u76F8\u53CD, \u6211\u4EEC\u53EA\u4F1A\u5728\u8BAD\u7EC3\u7ED3\u675F\u65F6\u8BC4\u4F30\u6A21\u578B, \u5E76\u5728\u4E0B\u9762\u7684\u201D\u81EA\u5B9A\u4E49\u8BAD\u7EC3\u5FAA\u73AF\u201D\u5411\u4F60\u5C55\u793A\u5982\u4F55\u8FDB\u884C\u5E38\u89C4\u8BC4\u4F30\u3002"),X.forEach(s),M=f(V),C=i(V,"P",{});var $e=p(C);Q=n($e,"T\u8FD9\u786E\u5B9E\u65F6 "),z=i($e,"CODE",{});var Je=p(z);A=n(Je,"Trainer"),Je.forEach(s),N=n($e," API \u663E\u793A\u5176\u5C40\u9650\u6027\u548C \u{1F917} Accelerate \u5E93\u7684\u4EAE\u70B9\u6240\u5728: \u6839\u636E\u7279\u5B9A\u7528\u4F8B\u81EA\u5B9A\u4E49\u7C7B\u53EF\u80FD\u5F88\u75DB\u82E6, \u4F46\u8C03\u6574\u5B8C\u5168\u516C\u5F00\u7684\u8BAD\u7EC3\u5FAA\u73AF\u5F88\u5BB9\u6613\u3002"),$e.forEach(s),R=f(V),G=i(V,"P",{});var Me=p(G);K=n(Me,"\u6765\u770B\u770B\u6211\u4EEC\u7684 "),W=i(Me,"CODE",{});var fe=p(W);I=n(fe,"TrainingArguments"),fe.forEach(s),U=n(Me,":"),Me.forEach(s),ae=f(V),E(J.$$.fragment,V),pe=f(V),se=i(V,"P",{});var Be=p(se);Z=n(Be,"\u6211\u4EEC\u4E4B\u524D\u5DF2\u7ECF\u770B\u5230\u4E86\u5176\u4E2D\u7684\u5927\u90E8\u5206: \u6211\u4EEC\u8BBE\u7F6E\u4E86\u4E00\u4E9B\u8D85\u53C2\u6570 (\u6BD4\u5982\u5B66\u4E60\u7387\u3001\u8BAD\u7EC3\u7684 epoch \u6570\u548C\u4E00\u4E9B\u6743\u91CD\u8870\u51CF), \u5E76\u8868\u660E\u6211\u4EEC\u5E0C\u671B\u5728\u6BCF\u4E2A epoch \u7ED3\u675F\u65F6\u4FDD\u5B58\u6A21\u578B, \u8DF3\u8FC7\u8BC4\u4F30, \u5E76\u5C06\u6211\u4EEC\u7684\u7ED3\u679C\u4E0A\u4F20\u5230\u6A21\u578B\u4E2D\u5FC3\u3002\u6211\u4EEC\u8FD8\u4F7F\u7528 "),Ue=i(Be,"CODE",{});var ce=p(Ue);Se=n(ce,"fp16=True"),ce.forEach(s),ne=n(Be," \u542F\u7528\u6DF7\u5408\u7CBE\u5EA6\u8BAD\u7EC3, \u56E0\u4E3A\u5B83\u53EF\u4EE5\u5728\u6700\u8FD1\u7684 GPU \u4E0A\u5F88\u597D\u5730\u52A0\u5FEB\u8BAD\u7EC3\u901F\u5EA6\u3002"),Be.forEach(s),this.h()},h(){B(k,"href","https://github.com/huggingface/transformers/blob/master/examples/pytorch/question-answering/trainer_qa.py"),B(k,"rel","nofollow")},m(V,X){l(V,c,X),t(c,h),t(c,_),t(_,v),t(c,T),t(c,$),t($,j),t(c,x),t(c,m),t(m,S),t(c,b),t(c,k),t(k,O),t(c,L),l(V,M,X),l(V,C,X),t(C,Q),t(C,z),t(z,A),t(C,N),l(V,R,X),l(V,G,X),t(G,K),t(G,W),t(W,I),t(G,U),l(V,ae,X),y(J,V,X),l(V,pe,X),l(V,se,X),t(se,Z),t(se,Ue),t(Ue,Se),t(se,ne),Oe=!0},i(V){Oe||(w(J.$$.fragment,V),Oe=!0)},o(V){g(J.$$.fragment,V),Oe=!1},d(V){V&&s(c),V&&s(M),V&&s(C),V&&s(R),V&&s(G),V&&s(ae),D(J,V),V&&s(pe),V&&s(se)}}}function rm(H){let c,h;return c=new P({props:{code:`from transformers.keras_callbacks import PushToHubCallback

callback = PushToHubCallback(output_dir="bert-finetuned-squad", tokenizer=tokenizer)

# We're going to do validation afterwards, so no validation mid-training
model.fit(tf_train_dataset, callbacks=[callback], epochs=num_train_epochs)`,highlighted:`<span class="hljs-keyword">from</span> transformers.keras_callbacks <span class="hljs-keyword">import</span> PushToHubCallback

callback = PushToHubCallback(output_dir=<span class="hljs-string">&quot;bert-finetuned-squad&quot;</span>, tokenizer=tokenizer)

<span class="hljs-comment"># We&#x27;re going to do validation afterwards, so no validation mid-training</span>
model.fit(tf_train_dataset, callbacks=[callback], epochs=num_train_epochs)`}}),{c(){q(c.$$.fragment)},l(_){E(c.$$.fragment,_)},m(_,v){y(c,_,v),h=!0},i(_){h||(w(c.$$.fragment,_),h=!0)},o(_){g(c.$$.fragment,_),h=!1},d(_){D(c,_)}}}function om(H){let c,h,_,v,T,$,j,x,m,S;return c=new Mp({props:{$$slots:{default:[im]},$$scope:{ctx:H}}}),m=new P({props:{code:`from transformers import Trainer

trainer = Trainer(
    model=model,
    args=args,
    train_dataset=train_dataset,
    eval_dataset=validation_dataset,
    tokenizer=tokenizer,
)
trainer.train()`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> Trainer

trainer = Trainer(
    model=model,
    args=args,
    train_dataset=train_dataset,
    eval_dataset=validation_dataset,
    tokenizer=tokenizer,
)
trainer.train()`}}),{c(){q(c.$$.fragment),h=d(),_=o("p"),v=a("\u6700\u540E, \u6211\u4EEC\u53EA\u9700\u5C06\u6240\u6709\u5185\u5BB9\u4F20\u9012\u7ED9 "),T=o("code"),$=a("Trainer"),j=a(" \u7C7B\u5E76\u542F\u52A8\u8BAD\u7EC3:"),x=d(),q(m.$$.fragment)},l(b){E(c.$$.fragment,b),h=f(b),_=i(b,"P",{});var k=p(_);v=n(k,"\u6700\u540E, \u6211\u4EEC\u53EA\u9700\u5C06\u6240\u6709\u5185\u5BB9\u4F20\u9012\u7ED9 "),T=i(k,"CODE",{});var O=p(T);$=n(O,"Trainer"),O.forEach(s),j=n(k," \u7C7B\u5E76\u542F\u52A8\u8BAD\u7EC3:"),k.forEach(s),x=f(b),E(m.$$.fragment,b)},m(b,k){y(c,b,k),l(b,h,k),l(b,_,k),t(_,v),t(_,T),t(T,$),t(_,j),l(b,x,k),y(m,b,k),S=!0},i(b){S||(w(c.$$.fragment,b),w(m.$$.fragment,b),S=!0)},o(b){g(c.$$.fragment,b),g(m.$$.fragment,b),S=!1},d(b){D(c,b),b&&s(h),b&&s(_),b&&s(x),D(m,b)}}}function im(H){let c,h,_,v,T;return{c(){c=o("p"),h=a("\u{1F4A1} \u5982\u679C\u60A8\u4F7F\u7528\u7684\u8F93\u51FA\u76EE\u5F55\u5B58\u5728, \u5219\u5B83\u9700\u8981\u662F\u60A8\u8981\u63A8\u9001\u5230\u7684\u5B58\u50A8\u5E93\u7684\u672C\u5730\u514B\u9686 (\u56E0\u6B64, \u5982\u679C\u5728\u5B9A\u4E49 "),_=o("code"),v=a("Trainer"),T=a(" \u65F6\u51FA\u9519, \u8BF7\u8BBE\u7F6E\u65B0\u540D\u79F0)\u3002")},l($){c=i($,"P",{});var j=p(c);h=n(j,"\u{1F4A1} \u5982\u679C\u60A8\u4F7F\u7528\u7684\u8F93\u51FA\u76EE\u5F55\u5B58\u5728, \u5219\u5B83\u9700\u8981\u662F\u60A8\u8981\u63A8\u9001\u5230\u7684\u5B58\u50A8\u5E93\u7684\u672C\u5730\u514B\u9686 (\u56E0\u6B64, \u5982\u679C\u5728\u5B9A\u4E49 "),_=i(j,"CODE",{});var x=p(_);v=n(x,"Trainer"),x.forEach(s),T=n(j," \u65F6\u51FA\u9519, \u8BF7\u8BBE\u7F6E\u65B0\u540D\u79F0)\u3002"),j.forEach(s)},m($,j){l($,c,j),t(c,h),t(c,_),t(_,v),t(c,T)},d($){$&&s(c)}}}function pm(H){let c,h,_,v,T,$,j,x,m,S,b,k,O,L;return O=new P({props:{code:`predictions = model.predict(tf_eval_dataset)
compute_metrics(
    predictions["start_logits"],
    predictions["end_logits"],
    validation_dataset,
    raw_datasets["validation"],
)`,highlighted:`predictions = model.predict(tf_eval_dataset)
compute_metrics(
    predictions[<span class="hljs-string">&quot;start_logits&quot;</span>],
    predictions[<span class="hljs-string">&quot;end_logits&quot;</span>],
    validation_dataset,
    raw_datasets[<span class="hljs-string">&quot;validation&quot;</span>],
)`}}),{c(){c=o("p"),h=a("\u4E00\u65E6\u8BAD\u7EC3\u5B8C\u6210, \u6211\u4EEC\u7EC8\u4E8E\u53EF\u4EE5\u8BC4\u4F30\u6211\u4EEC\u7684\u6A21\u578B(\u5E76\u7948\u7977\u6211\u4EEC\u6CA1\u6709\u628A\u6240\u6709\u7684\u8BA1\u7B97\u65F6\u95F4\u90FD\u82B1\u5728\u4EFB\u4F55\u4E8B\u60C5\u4E0A)\u3002\u6211\u4EEC\u7684 "),_=o("code"),v=a("model"),T=a(" \u7684 "),$=o("code"),j=a("predict()"),x=a(" \u65B9\u6CD5\u5C06\u8D1F\u8D23\u83B7\u53D6\u9884\u6D4B, \u5E76\u4E14\u7531\u4E8E\u6211\u4EEC\u4E4B\u524D\u5DF2\u7ECF\u5B8C\u6210\u4E86\u5B9A\u4E49 "),m=o("code"),S=a("compute_metrics()"),b=a(" \u51FD\u6570\u7684\u6240\u4EE5\u8270\u82E6\u5DE5\u4F5C, \u56E0\u6B64\u6211\u4EEC\u53EF\u4EE5\u5728\u4E00\u884C\u4E2D\u83B7\u5F97\u7ED3\u679C:"),k=d(),q(O.$$.fragment)},l(M){c=i(M,"P",{});var C=p(c);h=n(C,"\u4E00\u65E6\u8BAD\u7EC3\u5B8C\u6210, \u6211\u4EEC\u7EC8\u4E8E\u53EF\u4EE5\u8BC4\u4F30\u6211\u4EEC\u7684\u6A21\u578B(\u5E76\u7948\u7977\u6211\u4EEC\u6CA1\u6709\u628A\u6240\u6709\u7684\u8BA1\u7B97\u65F6\u95F4\u90FD\u82B1\u5728\u4EFB\u4F55\u4E8B\u60C5\u4E0A)\u3002\u6211\u4EEC\u7684 "),_=i(C,"CODE",{});var Q=p(_);v=n(Q,"model"),Q.forEach(s),T=n(C," \u7684 "),$=i(C,"CODE",{});var z=p($);j=n(z,"predict()"),z.forEach(s),x=n(C," \u65B9\u6CD5\u5C06\u8D1F\u8D23\u83B7\u53D6\u9884\u6D4B, \u5E76\u4E14\u7531\u4E8E\u6211\u4EEC\u4E4B\u524D\u5DF2\u7ECF\u5B8C\u6210\u4E86\u5B9A\u4E49 "),m=i(C,"CODE",{});var A=p(m);S=n(A,"compute_metrics()"),A.forEach(s),b=n(C," \u51FD\u6570\u7684\u6240\u4EE5\u8270\u82E6\u5DE5\u4F5C, \u56E0\u6B64\u6211\u4EEC\u53EF\u4EE5\u5728\u4E00\u884C\u4E2D\u83B7\u5F97\u7ED3\u679C:"),C.forEach(s),k=f(M),E(O.$$.fragment,M)},m(M,C){l(M,c,C),t(c,h),t(c,_),t(_,v),t(c,T),t(c,$),t($,j),t(c,x),t(c,m),t(m,S),t(c,b),l(M,k,C),y(O,M,C),L=!0},i(M){L||(w(O.$$.fragment,M),L=!0)},o(M){g(O.$$.fragment,M),L=!1},d(M){M&&s(c),M&&s(k),D(O,M)}}}function cm(H){let c,h,_,v,T,$,j,x,m,S,b,k,O,L;return O=new P({props:{code:`predictions, _ = trainer.predict(validation_dataset)
start_logits, end_logits = predictions
compute_metrics(start_logits, end_logits, validation_dataset, raw_datasets["validation"])`,highlighted:`predictions, _ = trainer.predict(validation_dataset)
start_logits, end_logits = predictions
compute_metrics(start_logits, end_logits, validation_dataset, raw_datasets[<span class="hljs-string">&quot;validation&quot;</span>])`}}),{c(){c=o("p"),h=a("\u4E00\u65E6\u8BAD\u7EC3\u5B8C\u6210, \u6211\u4EEC\u7EC8\u4E8E\u53EF\u4EE5\u8BC4\u4F30\u6211\u4EEC\u7684\u6A21\u578B(\u5E76\u7948\u7977\u6211\u4EEC\u6CA1\u6709\u628A\u6240\u6709\u7684\u8BA1\u7B97\u65F6\u95F4\u90FD\u82B1\u5728\u4EFB\u4F55\u4E8B\u60C5\u4E0A)\u3002"),_=o("code"),v=a("Trainer"),T=a(" \u7684 "),$=o("code"),j=a("predict()"),x=a(" \u65B9\u6CD5\u5C06\u8FD4\u56DE\u4E00\u4E2A\u5143\u7EC4, \u5176\u4E2D\u7B2C\u4E00\u4E2A\u5143\u7D20\u5C06\u662F\u6A21\u578B\u7684\u9884\u6D4B (\u8FD9\u91CC\u662F\u5E26\u6709\u5F00\u59CB\u548C\u7ED3\u675F logits \u7684\u5BF9)\u3002\u6211\u4EEC\u5C06\u5176\u53D1\u9001\u7ED9 "),m=o("code"),S=a("compute_metrics()"),b=a(" \u51FD\u6570:"),k=d(),q(O.$$.fragment)},l(M){c=i(M,"P",{});var C=p(c);h=n(C,"\u4E00\u65E6\u8BAD\u7EC3\u5B8C\u6210, \u6211\u4EEC\u7EC8\u4E8E\u53EF\u4EE5\u8BC4\u4F30\u6211\u4EEC\u7684\u6A21\u578B(\u5E76\u7948\u7977\u6211\u4EEC\u6CA1\u6709\u628A\u6240\u6709\u7684\u8BA1\u7B97\u65F6\u95F4\u90FD\u82B1\u5728\u4EFB\u4F55\u4E8B\u60C5\u4E0A)\u3002"),_=i(C,"CODE",{});var Q=p(_);v=n(Q,"Trainer"),Q.forEach(s),T=n(C," \u7684 "),$=i(C,"CODE",{});var z=p($);j=n(z,"predict()"),z.forEach(s),x=n(C," \u65B9\u6CD5\u5C06\u8FD4\u56DE\u4E00\u4E2A\u5143\u7EC4, \u5176\u4E2D\u7B2C\u4E00\u4E2A\u5143\u7D20\u5C06\u662F\u6A21\u578B\u7684\u9884\u6D4B (\u8FD9\u91CC\u662F\u5E26\u6709\u5F00\u59CB\u548C\u7ED3\u675F logits \u7684\u5BF9)\u3002\u6211\u4EEC\u5C06\u5176\u53D1\u9001\u7ED9 "),m=i(C,"CODE",{});var A=p(m);S=n(A,"compute_metrics()"),A.forEach(s),b=n(C," \u51FD\u6570:"),C.forEach(s),k=f(M),E(O.$$.fragment,M)},m(M,C){l(M,c,C),t(c,h),t(c,_),t(_,v),t(c,T),t(c,$),t($,j),t(c,x),t(c,m),t(m,S),t(c,b),l(M,k,C),y(O,M,C),L=!0},i(M){L||(w(O.$$.fragment,M),L=!0)},o(M){g(O.$$.fragment,M),L=!1},d(M){M&&s(c),M&&s(k),D(O,M)}}}function P_(H){let c,h,_,v,T,$,j,x,m,S,b,k,O,L,M,C,Q,z;return j=new P({props:{code:'trainer.push_to_hub(commit_message="Training complete")',highlighted:'trainer.push_to_hub(commit_message=<span class="hljs-string">&quot;Training complete&quot;</span>)'}}),k=new P({props:{code:"'https://huggingface.co/sgugger/bert-finetuned-squad/commit/9dcee1fbc25946a6ed4bb32efb1bd71d5fa90b68'",highlighted:'<span class="hljs-string">&#x27;https://huggingface.co/sgugger/bert-finetuned-squad/commit/9dcee1fbc25946a6ed4bb32efb1bd71d5fa90b68&#x27;</span>'}}),{c(){c=o("p"),h=a("\u6700\u540E, \u6211\u4EEC\u4F7F\u7528 "),_=o("code"),v=a("push_to_hub()"),T=a(" \u65B9\u6CD5\u786E\u4FDD\u6211\u4EEC\u4E0A\u4F20\u6A21\u578B\u7684\u6700\u65B0\u7248\u672C:"),$=d(),q(j.$$.fragment),x=d(),m=o("p"),S=a("\u5982\u679C\u4F60\u60F3\u68C0\u67E5\u5B83, \u8FD9\u5C06\u8FD4\u56DE\u5B83\u521A\u521A\u6267\u884C\u7684\u63D0\u4EA4\u7684 URL:"),b=d(),q(k.$$.fragment),O=d(),L=o("p"),M=o("code"),C=a("Trainer"),Q=a(" \u8FD8\u8D77\u8349\u4E86\u5305\u542B\u6240\u6709\u8BC4\u4F30\u7ED3\u679C\u7684\u6A21\u578B\u5361\u5E76\u4E0A\u4F20\u3002")},l(A){c=i(A,"P",{});var N=p(c);h=n(N,"\u6700\u540E, \u6211\u4EEC\u4F7F\u7528 "),_=i(N,"CODE",{});var R=p(_);v=n(R,"push_to_hub()"),R.forEach(s),T=n(N," \u65B9\u6CD5\u786E\u4FDD\u6211\u4EEC\u4E0A\u4F20\u6A21\u578B\u7684\u6700\u65B0\u7248\u672C:"),N.forEach(s),$=f(A),E(j.$$.fragment,A),x=f(A),m=i(A,"P",{});var G=p(m);S=n(G,"\u5982\u679C\u4F60\u60F3\u68C0\u67E5\u5B83, \u8FD9\u5C06\u8FD4\u56DE\u5B83\u521A\u521A\u6267\u884C\u7684\u63D0\u4EA4\u7684 URL:"),G.forEach(s),b=f(A),E(k.$$.fragment,A),O=f(A),L=i(A,"P",{});var K=p(L);M=i(K,"CODE",{});var W=p(M);C=n(W,"Trainer"),W.forEach(s),Q=n(K," \u8FD8\u8D77\u8349\u4E86\u5305\u542B\u6240\u6709\u8BC4\u4F30\u7ED3\u679C\u7684\u6A21\u578B\u5361\u5E76\u4E0A\u4F20\u3002"),K.forEach(s)},m(A,N){l(A,c,N),t(c,h),t(c,_),t(_,v),t(c,T),l(A,$,N),y(j,A,N),l(A,x,N),l(A,m,N),t(m,S),l(A,b,N),y(k,A,N),l(A,O,N),l(A,L,N),t(L,M),t(M,C),t(L,Q),z=!0},i(A){z||(w(j.$$.fragment,A),w(k.$$.fragment,A),z=!0)},o(A){g(j.$$.fragment,A),g(k.$$.fragment,A),z=!1},d(A){A&&s(c),A&&s($),D(j,A),A&&s(x),A&&s(m),A&&s(b),D(k,A),A&&s(O),A&&s(L)}}}function dm(H){let c,h,_,v,T;return{c(){c=o("p"),h=a("\u270F\uFE0F "),_=o("strong"),v=a("\u8F6E\u5230\u4F60\u4E86!"),T=a(" \u5C1D\u8BD5\u53E6\u4E00\u79CD\u6A21\u578B\u67B6\u6784, \u770B\u770B\u5B83\u662F\u5426\u5728\u6B64\u4EFB\u52A1\u4E0A\u8868\u73B0\u66F4\u597D!")},l($){c=i($,"P",{});var j=p(c);h=n(j,"\u270F\uFE0F "),_=i(j,"STRONG",{});var x=p(_);v=n(x,"\u8F6E\u5230\u4F60\u4E86!"),x.forEach(s),T=n(j," \u5C1D\u8BD5\u53E6\u4E00\u79CD\u6A21\u578B\u67B6\u6784, \u770B\u770B\u5B83\u662F\u5426\u5728\u6B64\u4EFB\u52A1\u4E0A\u8868\u73B0\u66F4\u597D!"),j.forEach(s)},m($,j){l($,c,j),t(c,h),t(c,_),t(_,v),t(c,T)},d($){$&&s(c)}}}function S_(H){let c,h,_,v,T,$,j,x,m,S,b,k,O,L,M,C,Q,z,A,N,R,G,K,W,I,U,ae,J,pe,se,Z,Ue,Se,ne,Oe,V,X,us,xe,we,ge,$e,Je,Me,fe,Be,ce,sa,le,_s,At,Za,ta,je,Xe,Pt,Ie,en,St,Ot,aa,Ke,Mt,Bt,sn,na,Ye,Ze,ve,Xs,It,la,ms,Ks,hs,ra,ue,ws,Ys,be,tn,gs,an,nn,$s,ln,rn,Zs,bs,oa,es,ss,te,Fe,ia,et,Ft,pa,xs,st,ye,on,js,pn,cn,vs,dn,fn,tt,ks,un,Lt,ke,_n,at,De,qs,ca,Le,da,Es,fa,de,mn,nt,ys,ua,ze,_a,lt,zt,ma,Ds,ha,_e,wa,ts,hn,ga,Ne,wn,$a,as,Cs,rt,ba,ns,Ts,ot,xa,ls,rs,me,ee,As,Nt,gn,Ht,Vt,$n,Qt,Rt,bn,ja,He,va,Ps,it,pt,xn,ct,Ss,ka,os,jn,qa,is,qe,Os,dt,ft,vn,ps,Ee,Ms,Cl,Ea;return ne=new P({props:{code:`from torch.utils.data import DataLoader
from transformers import default_data_collator

train_dataset.set_format("torch")
validation_set = validation_dataset.remove_columns(["example_id", "offset_mapping"])
validation_set.set_format("torch")

train_dataloader = DataLoader(
    train_dataset,
    shuffle=True,
    collate_fn=default_data_collator,
    batch_size=8,
)
eval_dataloader = DataLoader(
    validation_set, collate_fn=default_data_collator, batch_size=8
)`,highlighted:`<span class="hljs-keyword">from</span> torch.utils.data <span class="hljs-keyword">import</span> DataLoader
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> default_data_collator

train_dataset.set_format(<span class="hljs-string">&quot;torch&quot;</span>)
validation_set = validation_dataset.remove_columns([<span class="hljs-string">&quot;example_id&quot;</span>, <span class="hljs-string">&quot;offset_mapping&quot;</span>])
validation_set.set_format(<span class="hljs-string">&quot;torch&quot;</span>)

train_dataloader = DataLoader(
    train_dataset,
    shuffle=<span class="hljs-literal">True</span>,
    collate_fn=default_data_collator,
    batch_size=<span class="hljs-number">8</span>,
)
eval_dataloader = DataLoader(
    validation_set, collate_fn=default_data_collator, batch_size=<span class="hljs-number">8</span>
)`}}),xe=new P({props:{code:"model = AutoModelForQuestionAnswering.from_pretrained(model_checkpoint)",highlighted:"model = AutoModelForQuestionAnswering.from_pretrained(model_checkpoint)"}}),ce=new P({props:{code:`from torch.optim import AdamW

optimizer = AdamW(model.parameters(), lr=2e-5)`,highlighted:`<span class="hljs-keyword">from</span> torch.optim <span class="hljs-keyword">import</span> AdamW

optimizer = AdamW(model.parameters(), lr=<span class="hljs-number">2e-5</span>)`}}),Ye=new P({props:{code:`from accelerate import Accelerator

accelerator = Accelerator(fp16=True)
model, optimizer, train_dataloader, eval_dataloader = accelerator.prepare(
    model, optimizer, train_dataloader, eval_dataloader
)`,highlighted:`<span class="hljs-keyword">from</span> accelerate <span class="hljs-keyword">import</span> Accelerator

accelerator = Accelerator(fp16=<span class="hljs-literal">True</span>)
model, optimizer, train_dataloader, eval_dataloader = accelerator.prepare(
    model, optimizer, train_dataloader, eval_dataloader
)`}}),ws=new P({props:{code:`from transformers import get_scheduler

num_train_epochs = 3
num_update_steps_per_epoch = len(train_dataloader)
num_training_steps = num_train_epochs * num_update_steps_per_epoch

lr_scheduler = get_scheduler(
    "linear",
    optimizer=optimizer,
    num_warmup_steps=0,
    num_training_steps=num_training_steps,
)`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> get_scheduler

num_train_epochs = <span class="hljs-number">3</span>
num_update_steps_per_epoch = <span class="hljs-built_in">len</span>(train_dataloader)
num_training_steps = num_train_epochs * num_update_steps_per_epoch

lr_scheduler = get_scheduler(
    <span class="hljs-string">&quot;linear&quot;</span>,
    optimizer=optimizer,
    num_warmup_steps=<span class="hljs-number">0</span>,
    num_training_steps=num_training_steps,
)`}}),ss=new P({props:{code:`from huggingface_hub import Repository, get_full_repo_name

model_name = "bert-finetuned-squad-accelerate"
repo_name = get_full_repo_name(model_name)
repo_name`,highlighted:`<span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> Repository, get_full_repo_name

model_name = <span class="hljs-string">&quot;bert-finetuned-squad-accelerate&quot;</span>
repo_name = get_full_repo_name(model_name)
repo_name`}}),Fe=new P({props:{code:"'sgugger/bert-finetuned-squad-accelerate'",highlighted:'<span class="hljs-string">&#x27;sgugger/bert-finetuned-squad-accelerate&#x27;</span>'}}),xs=new P({props:{code:`output_dir = "bert-finetuned-squad-accelerate"
repo = Repository(output_dir, clone_from=repo_name)`,highlighted:`output_dir = <span class="hljs-string">&quot;bert-finetuned-squad-accelerate&quot;</span>
repo = Repository(output_dir, clone_from=repo_name)`}}),ns=new P({props:{code:`from tqdm.auto import tqdm
import torch

progress_bar = tqdm(range(num_training_steps))

for epoch in range(num_train_epochs):
    # Training
    model.train()
    for step, batch in enumerate(train_dataloader):
        outputs = model(**batch)
        loss = outputs.loss
        accelerator.backward(loss)

        optimizer.step()
        lr_scheduler.step()
        optimizer.zero_grad()
        progress_bar.update(1)

    # Evaluation
    model.eval()
    start_logits = []
    end_logits = []
    accelerator.print("Evaluation!")
    for batch in tqdm(eval_dataloader):
        with torch.no_grad():
            outputs = model(**batch)

        start_logits.append(accelerator.gather(outputs.start_logits).cpu().numpy())
        end_logits.append(accelerator.gather(outputs.end_logits).cpu().numpy())

    start_logits = np.concatenate(start_logits)
    end_logits = np.concatenate(end_logits)
    start_logits = start_logits[: len(validation_dataset)]
    end_logits = end_logits[: len(validation_dataset)]

    metrics = compute_metrics(
        start_logits, end_logits, validation_dataset, raw_datasets["validation"]
    )
    print(f"epoch {epoch}:", metrics)

    # Save and upload
    accelerator.wait_for_everyone()
    unwrapped_model = accelerator.unwrap_model(model)
    unwrapped_model.save_pretrained(output_dir, save_function=accelerator.save)
    if accelerator.is_main_process:
        tokenizer.save_pretrained(output_dir)
        repo.push_to_hub(
            commit_message=f"Training in progress epoch {epoch}", blocking=False
        )`,highlighted:`<span class="hljs-keyword">from</span> tqdm.auto <span class="hljs-keyword">import</span> tqdm
<span class="hljs-keyword">import</span> torch

progress_bar = tqdm(<span class="hljs-built_in">range</span>(num_training_steps))

<span class="hljs-keyword">for</span> epoch <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(num_train_epochs):
    <span class="hljs-comment"># Training</span>
    model.train()
    <span class="hljs-keyword">for</span> step, batch <span class="hljs-keyword">in</span> <span class="hljs-built_in">enumerate</span>(train_dataloader):
        outputs = model(**batch)
        loss = outputs.loss
        accelerator.backward(loss)

        optimizer.step()
        lr_scheduler.step()
        optimizer.zero_grad()
        progress_bar.update(<span class="hljs-number">1</span>)

    <span class="hljs-comment"># Evaluation</span>
    model.<span class="hljs-built_in">eval</span>()
    start_logits = []
    end_logits = []
    accelerator.<span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;Evaluation!&quot;</span>)
    <span class="hljs-keyword">for</span> batch <span class="hljs-keyword">in</span> tqdm(eval_dataloader):
        <span class="hljs-keyword">with</span> torch.no_grad():
            outputs = model(**batch)

        start_logits.append(accelerator.gather(outputs.start_logits).cpu().numpy())
        end_logits.append(accelerator.gather(outputs.end_logits).cpu().numpy())

    start_logits = np.concatenate(start_logits)
    end_logits = np.concatenate(end_logits)
    start_logits = start_logits[: <span class="hljs-built_in">len</span>(validation_dataset)]
    end_logits = end_logits[: <span class="hljs-built_in">len</span>(validation_dataset)]

    metrics = compute_metrics(
        start_logits, end_logits, validation_dataset, raw_datasets[<span class="hljs-string">&quot;validation&quot;</span>]
    )
    <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;epoch <span class="hljs-subst">{epoch}</span>:&quot;</span>, metrics)

    <span class="hljs-comment"># Save and upload</span>
    accelerator.wait_for_everyone()
    unwrapped_model = accelerator.unwrap_model(model)
    unwrapped_model.save_pretrained(output_dir, save_function=accelerator.save)
    <span class="hljs-keyword">if</span> accelerator.is_main_process:
        tokenizer.save_pretrained(output_dir)
        repo.push_to_hub(
            commit_message=<span class="hljs-string">f&quot;Training in progress epoch <span class="hljs-subst">{epoch}</span>&quot;</span>, blocking=<span class="hljs-literal">False</span>
        )`}}),rs=new P({props:{code:`accelerator.wait_for_everyone()
unwrapped_model = accelerator.unwrap_model(model)
unwrapped_model.save_pretrained(output_dir, save_function=accelerator.save)`,highlighted:`accelerator.wait_for_everyone()
unwrapped_model = accelerator.unwrap_model(model)
unwrapped_model.save_pretrained(output_dir, save_function=accelerator.save)`}}),{c(){c=o("p"),h=a("\u5982\u679C\u4F60\u60F3\u66F4\u6DF1\u5165\u5730\u4E86\u89E3\u8BAD\u7EC3\u5FAA\u73AF, \u6211\u4EEC\u73B0\u5728\u5C06\u5411\u4F60\u5C55\u793A\u5982\u4F55\u4F7F\u7528 \u{1F917} Accelerate \u6765\u505A\u540C\u6837\u7684\u4E8B\u60C5\u3002"),_=d(),v=o("h2"),T=a("\u81EA\u5B9A\u4E49\u8BAD\u7EC3\u5FAA\u73AF"),$=d(),j=o("p"),x=a("\u73B0\u5728\u8BA9\u6211\u4EEC\u6765\u770B\u4E00\u4E0B\u5B8C\u6574\u7684\u8BAD\u7EC3\u5FAA\u73AF, \u8FD9\u6837\u60A8\u5C31\u53EF\u4EE5\u8F7B\u677E\u5730\u81EA\u5B9A\u4E49\u6240\u9700\u7684\u90E8\u5206\u3002\u5B83\u770B\u8D77\u6765\u5F88\u50CF "),m=o("a"),S=a("\u7B2C\u4E09\u7AE0"),b=a(" \u4E2D\u7684\u8BAD\u7EC3\u5FAA\u73AF, \u9664\u4E86\u8BC4\u4F30\u5FAA\u73AF\u3002\u6211\u4EEC\u5C06\u80FD\u591F\u5B9A\u671F\u8BC4\u4F30\u6A21\u578B, \u56E0\u4E3A\u6211\u4EEC\u4E0D\u518D\u53D7 "),k=o("code"),O=a("Trainer"),L=a(" \u7C7B\u7684\u9650\u5236\u3002"),M=d(),C=o("h3"),Q=a("\u4E3A\u8BAD\u7EC3\u505A\u51C6\u5907"),z=d(),A=o("p"),N=a("\u9996\u5148, \u6211\u4EEC\u9700\u8981\u4ECE\u6211\u4EEC\u7684\u6570\u636E\u96C6\u4E2D\u6784\u5EFA "),R=o("code"),G=a("DataLoader"),K=a("\u3002\u6211\u4EEC\u5C06\u8FD9\u4E9B\u6570\u636E\u96C6\u7684\u683C\u5F0F\u8BBE\u7F6E\u4E3A "),W=o("code"),I=a('"torch"'),U=a(", \u5E76\u5220\u9664\u6A21\u578B\u672A\u4F7F\u7528\u7684\u9A8C\u8BC1\u96C6\u4E2D\u7684\u5217\u3002\u7136\u540E, \u6211\u4EEC\u53EF\u4EE5\u4F7F\u7528 Transformers \u63D0\u4F9B\u7684 "),ae=o("code"),J=a("default_data_collator"),pe=a(" \u4F5C\u4E3A "),se=o("code"),Z=a("collate_fn"),Ue=a(", \u5E76\u6253\u4E71\u8BAD\u7EC3\u96C6, \u4F46\u4E0D\u6253\u4E71\u9A8C\u8BC1\u96C658:"),Se=d(),q(ne.$$.fragment),Oe=d(),V=o("p"),X=a("\u63A5\u4E0B\u6765\u6211\u4EEC\u91CD\u65B0\u5B9E\u4F8B\u5316\u6211\u4EEC\u7684\u6A21\u578B, \u4EE5\u786E\u4FDD\u6211\u4EEC\u4E0D\u4F1A\u7EE7\u7EED\u4E4B\u524D\u7684\u5FAE\u8C03, \u800C\u662F\u518D\u6B21\u4ECE BERT \u9884\u8BAD\u7EC3\u6A21\u578B\u5F00\u59CB:"),us=d(),q(xe.$$.fragment),we=d(),ge=o("p"),$e=a("\u7136\u540E\u6211\u4EEC\u9700\u8981\u4E00\u4E2A\u4F18\u5316\u5668\u3002\u50CF\u5F80\u5E38\u4E00\u6837, \u6211\u4EEC\u4F7F\u7528\u7ECF\u5178\u7684 "),Je=o("code"),Me=a("AdamW"),fe=a(", \u5B83\u4E0E Adam \u7C7B\u4F3C, \u4F46\u5BF9\u6743\u91CD\u8870\u51CF\u7684\u5E94\u7528\u65B9\u5F0F\u8FDB\u884C\u4E86\u4FEE\u590D:"),Be=d(),q(ce.$$.fragment),sa=d(),le=o("p"),_s=a("\u4E00\u65E6\u6211\u4EEC\u62E5\u6709\u6240\u6709\u8FD9\u4E9B\u5BF9\u8C61, \u6211\u4EEC\u53EF\u4EE5\u5C06\u5B83\u4EEC\u53D1\u9001\u7ED9 "),At=o("code"),Za=a("accelerator.prepare()"),ta=a(" \u65B9\u6CD5\u3002\u8BF7\u8BB0\u4F4F, \u5982\u679C\u60A8\u60F3\u5728 Colab \u7B14\u8BB0\u672C\u4E2D\u7684 TPU \u4E0A\u8FDB\u884C\u8BAD\u7EC3, \u60A8\u9700\u8981\u5C06\u6240\u6709\u8FD9\u4E9B\u4EE3\u7801\u79FB\u52A8\u5230\u4E00\u4E2A\u8BAD\u7EC3\u51FD\u6570\u4E2D, \u5E76\u4E14\u4E0D\u5E94\u8BE5\u6267\u884C\u4EFB\u4F55\u5B9E\u4F8B\u5316 "),je=o("code"),Xe=a("Accelerator"),Pt=a(" \u7684\u5355\u5143\u3002\u6211\u4EEC\u53EF\u4EE5\u901A\u8FC7\u4F20\u9012 "),Ie=o("code"),en=a("fp16=True"),St=a(" \u7ED9 "),Ot=o("code"),aa=a("Accelerator"),Ke=a(" (\u6216\u8005, \u5982\u679C\u4F60\u5C06\u4EE3\u7801\u4F5C\u4E3A\u811A\u672C\u6267\u884C, \u53EA\u9700\u786E\u4FDD\u9002\u5F53\u5730\u586B\u5199 \u{1F917} Accelerate "),Mt=o("code"),Bt=a("config"),sn=a(" )\u3002"),na=d(),q(Ye.$$.fragment),Ze=d(),ve=o("p"),Xs=a("\u4ECE\u524D\u9762\u51E0\u8282\u4E2D\u4F60\u5E94\u8BE5\u77E5\u9053, \u6211\u4EEC\u53EA\u80FD\u4F7F\u7528 "),It=o("code"),la=a("train_dataloader"),ms=a(" \u957F\u5EA6\u6765\u8BA1\u7B97\u7ECF\u8FC7 "),Ks=o("code"),hs=a("accelerator.prepare()"),ra=a(" \u65B9\u6CD5\u540E\u7684\u8BAD\u7EC3\u6B65\u9AA4\u7684\u6570\u91CF\u3002\u6211\u4EEC\u4F7F\u7528\u4E0E\u524D\u51E0\u8282\u76F8\u540C\u7684\u7EBF\u6027\u65F6\u95F4\u8868:"),ue=d(),q(ws.$$.fragment),Ys=d(),be=o("p"),tn=a("\u8981\u5C06\u6211\u4EEC\u7684\u6A21\u578B\u63A8\u9001\u5230 Hub, \u6211\u4EEC\u9700\u8981\u5728\u5DE5\u4F5C\u6587\u4EF6\u5939\u4E2D\u521B\u5EFA\u4E00\u4E2A "),gs=o("code"),an=a("Repository"),nn=a(" \u5BF9\u8C61\u3002\u5982\u679C\u4F60\u5C1A\u672A\u767B\u5F55, \u8BF7\u5148\u767B\u5F55 Hugging Face Hub\u3002\u6211\u4EEC\u5C06\u6839\u636E\u6211\u4EEC\u60F3\u8981\u4E3A\u6A21\u578B\u63D0\u4F9B\u7684\u6A21\u578B ID \u786E\u5B9A\u5B58\u50A8\u5E93\u540D\u79F0 (\u968F\u610F\u7528\u4F60\u81EA\u5DF1\u7684\u9009\u62E9\u66FF\u6362 "),$s=o("code"),ln=a("repo_name"),rn=a("; \u5B83\u53EA\u9700\u8981\u5305\u542B\u4F60\u7684\u7528\u6237\u540D, \u8FD9\u5C31\u662F\u51FD\u6570 "),Zs=o("code"),bs=a("get_full_repo_name()"),oa=a(" \u6240\u505A\u7684):"),es=d(),q(ss.$$.fragment),te=d(),q(Fe.$$.fragment),ia=d(),et=o("p"),Ft=a("\u7136\u540E\u6211\u4EEC\u53EF\u4EE5\u5C06\u8BE5\u5B58\u50A8\u5E93\u514B\u9686\u5230\u672C\u5730\u6587\u4EF6\u5939\u4E2D\u3002\u5982\u679C\u5B83\u5DF2\u7ECF\u5B58\u5728, \u8FD9\u4E2A\u672C\u5730\u6587\u4EF6\u5939\u5E94\u8BE5\u662F\u6211\u4EEC\u6B63\u5728\u4F7F\u7528\u7684\u5B58\u50A8\u5E93\u7684\u514B\u9686:"),pa=d(),q(xs.$$.fragment),st=d(),ye=o("p"),on=a("\u6211\u4EEC\u73B0\u5728\u53EF\u4EE5\u901A\u8FC7\u8C03\u7528 "),js=o("code"),pn=a("repo.push_to_hub()"),cn=a(" \u65B9\u6CD5\u4E0A\u4F20\u6211\u4EEC\u4FDD\u5B58\u5728 "),vs=o("code"),dn=a("output_dir"),fn=a(" \u4E2D\u7684\u4EFB\u4F55\u5185\u5BB9\u3002\u8FD9\u5C06\u5E2E\u52A9\u6211\u4EEC\u5728\u6BCF\u4E2A epoch \u7ED3\u675F\u65F6\u4E0A\u4F20\u4E2D\u95F4\u6A21\u578B\u3002"),tt=d(),ks=o("h2"),un=a("\u8BAD\u7EC3\u5FAA\u73AF"),Lt=d(),ke=o("p"),_n=a("\u6211\u4EEC\u73B0\u5728\u51C6\u5907\u7F16\u5199\u5B8C\u6574\u7684\u8BAD\u7EC3\u5FAA\u73AF\u3002\u5728\u5B9A\u4E49\u4E86\u4E00\u4E2A\u8FDB\u5EA6\u6761\u6765\u8DDF\u8E2A\u8BAD\u7EC3\u8FDB\u884C\u540E, \u5FAA\u73AF\u5206\u4E3A\u4E09\u4E2A\u90E8\u5206:"),at=d(),De=o("ul"),qs=o("li"),ca=a("\u8BAD\u7EC3\u672C\u8EAB\u662F\u5BF9 "),Le=o("code"),da=a("train_dataloader"),Es=a(" \u7684\u7ECF\u5178\u8FED\u4EE3, \u524D\u5411\u4F20\u9012\u6A21\u578B, \u7136\u540E\u53CD\u5411\u4F20\u9012\u548C\u4F18\u5316\u5668\u6B65\u9AA4\u3002"),fa=d(),de=o("li"),mn=a("\u5728\u8BA1\u7B97\u4E2D, \u6211\u4EEC\u5728\u5C06 "),nt=o("code"),ys=a("start_logits"),ua=a(" \u548C "),ze=o("code"),_a=a("end_logits"),lt=a(" \u7684\u6240\u6709\u503C\u8F6C\u6362\u4E3A NumPy \u6570\u7EC4\u4E4B\u524D, \u6536\u96C6\u5B83\u4EEC\u7684\u6240\u6709\u503C\u3002\u8BC4\u4F30\u5FAA\u73AF\u5B8C\u6210\u540E,\u6211\u4EEC\u5C06\u8FDE\u63A5\u6240\u6709\u7ED3\u679C\u3002\u8BF7\u6CE8\u610F, \u6211\u4EEC\u9700\u8981\u622A\u65AD, \u56E0\u4E3A "),zt=o("code"),ma=a("Accelerator"),Ds=a(" \u53EF\u80FD\u5728\u6700\u540E\u6DFB\u52A0\u4E86\u4E00\u4E9B\u793A\u4F8B, \u4EE5\u786E\u4FDD\u6211\u4EEC\u5728\u6BCF\u4E2A\u8FC7\u7A0B\u4E2D\u62E5\u6709\u76F8\u540C\u6570\u91CF\u7684\u793A\u4F8B\u3002"),ha=d(),_e=o("li"),wa=a("\u4FDD\u5B58\u548C\u4E0A\u4F20, \u8FD9\u91CC\u6211\u4EEC\u5148\u4FDD\u5B58\u6A21\u578B\u548C\u5206\u8BCD\u5668, \u7136\u540E\u8C03\u7528 "),ts=o("code"),hn=a("repo.push_to_hub()"),ga=a("\u3002\u6B63\u5982\u6211\u4EEC\u4E4B\u524D\u6240\u505A\u7684\u90A3\u6837, \u6211\u4EEC\u4F7F\u7528\u53C2\u6570 "),Ne=o("code"),wn=a("blocking=False"),$a=a(" \u6765\u544A\u8BC9 \u{1F917} Hub \u5E93\u63A8\u5165\u4E00\u4E2A\u5F02\u6B65\u8FDB\u7A0B\u3002\u8FD9\u6837, \u8BAD\u7EC3\u6B63\u5E38\u7EE7\u7EED, \u5E76\u4E14\u8FD9\u4E2A (\u957F) \u6307\u4EE4\u5728\u540E\u53F0\u6267\u884C\u3002"),as=d(),Cs=o("p"),rt=a("\u8FD9\u662F\u8BAD\u7EC3\u5FAA\u73AF\u7684\u5B8C\u6574\u4EE3\u7801:"),ba=d(),q(ns.$$.fragment),Ts=d(),ot=o("p"),xa=a("\u5982\u679C\u8FD9\u662F\u60A8\u7B2C\u4E00\u6B21\u770B\u5230\u4F7F\u7528 \u{1F917} Accelerate \u4FDD\u5B58\u7684\u6A21\u578B, \u8BA9\u6211\u4EEC\u82B1\u70B9\u65F6\u95F4\u68C0\u67E5\u4E00\u4E0B\u5B83\u9644\u5E26\u7684\u4E09\u884C\u4EE3\u7801:"),ls=d(),q(rs.$$.fragment),me=d(),ee=o("p"),As=a("\u7B2C\u4E00\u884C\u662F\u4E0D\u8A00\u81EA\u660E\u7684: \u5B83\u544A\u8BC9\u6240\u6709\u8FDB\u7A0B\u8981\u7B49\u5230\u6BCF\u4E2A\u4EBA\u90FD\u5904\u4E8E\u90A3\u4E2A\u9636\u6BB5\u624D\u80FD\u7EE7\u7EED\u3002\u8FD9\u662F\u4E3A\u4E86\u786E\u4FDD\u6211\u4EEC\u5728\u4FDD\u5B58\u4E4B\u524D\u5728\u6BCF\u4E2A\u8FC7\u7A0B\u4E2D\u90FD\u6709\u76F8\u540C\u7684\u6A21\u578B\u3002\u7136\u540E\u6211\u4EEC\u83B7\u53D6 "),Nt=o("code"),gn=a("unwrapped_model"),Ht=a(", \u8FD9\u662F\u6211\u4EEC\u5B9A\u4E49\u7684\u57FA\u7840\u6A21\u578B\u3002 "),Vt=o("code"),$n=a("accelerator.prepare()"),Qt=a(" \u65B9\u6CD5\u5C06\u6A21\u578B\u66F4\u6539\u4E3A\u5728\u5206\u5E03\u5F0F\u8BAD\u7EC3\u4E2D\u5DE5\u4F5C, \u56E0\u6B64\u5B83\u5C06\u4E0D\u518D\u6709 "),Rt=o("code"),bn=a("save_pretrained()"),ja=a(" \u65B9\u6CD5; "),He=o("code"),va=a("accelerator.unwrap_model()"),Ps=a(" \u65B9\u6CD5\u4F1A\u64A4\u9500\u8BE5\u6B65\u9AA4\u3002\u6700\u540E, \u6211\u4EEC\u8C03\u7528 "),it=o("code"),pt=a("save_pretrained()"),xn=a(", \u4F46\u544A\u8BC9\u8BE5\u65B9\u6CD5\u4F7F\u7528 "),ct=o("code"),Ss=a("accelerator.save()"),ka=a(" \u800C\u4E0D\u662F "),os=o("code"),jn=a("torch.save()"),qa=a("\u3002"),is=d(),qe=o("p"),Os=a("\u5B8C\u6210\u540E, \u4F60\u5E94\u8BE5\u62E5\u6709\u4E00\u4E2A\u6A21\u578B, \u8BE5\u6A21\u578B\u4EA7\u751F\u7684\u7ED3\u679C\u4E0E\u4F7F\u7528 "),dt=o("code"),ft=a("Trainer"),vn=a(" \u8BAD\u7EC3\u7684\u6A21\u578B\u975E\u5E38\u76F8\u4F3C\u3002\u4F60\u53EF\u4EE5\u5728 "),ps=o("a"),Ee=o("em"),Ms=a("huggingface-course/bert-finetuned-squad-accelerate"),Cl=a(" \u4E0A\u67E5\u770B\u6211\u4EEC\u4F7F\u7528\u6B64\u4EE3\u7801\u8BAD\u7EC3\u7684\u6A21\u578B\u3002\u5982\u679C\u4F60\u60F3\u6D4B\u8BD5\u5BF9\u8BAD\u7EC3\u5FAA\u73AF\u7684\u4EFB\u4F55\u8C03\u6574, \u4F60\u53EF\u4EE5\u901A\u8FC7\u7F16\u8F91\u4E0A\u9762\u663E\u793A\u7684\u4EE3\u7801\u76F4\u63A5\u5B9E\u73B0\u5B83\u4EEC!"),this.h()},l(u){c=i(u,"P",{});var F=p(c);h=n(F,"\u5982\u679C\u4F60\u60F3\u66F4\u6DF1\u5165\u5730\u4E86\u89E3\u8BAD\u7EC3\u5FAA\u73AF, \u6211\u4EEC\u73B0\u5728\u5C06\u5411\u4F60\u5C55\u793A\u5982\u4F55\u4F7F\u7528 \u{1F917} Accelerate \u6765\u505A\u540C\u6837\u7684\u4E8B\u60C5\u3002"),F.forEach(s),_=f(u),v=i(u,"H2",{id:!0});var kn=p(v);T=n(kn,"\u81EA\u5B9A\u4E49\u8BAD\u7EC3\u5FAA\u73AF"),kn.forEach(s),$=f(u),j=i(u,"P",{});var he=p(j);x=n(he,"\u73B0\u5728\u8BA9\u6211\u4EEC\u6765\u770B\u4E00\u4E0B\u5B8C\u6574\u7684\u8BAD\u7EC3\u5FAA\u73AF, \u8FD9\u6837\u60A8\u5C31\u53EF\u4EE5\u8F7B\u677E\u5730\u81EA\u5B9A\u4E49\u6240\u9700\u7684\u90E8\u5206\u3002\u5B83\u770B\u8D77\u6765\u5F88\u50CF "),m=i(he,"A",{href:!0});var Tl=p(m);S=n(Tl,"\u7B2C\u4E09\u7AE0"),Tl.forEach(s),b=n(he," \u4E2D\u7684\u8BAD\u7EC3\u5FAA\u73AF, \u9664\u4E86\u8BC4\u4F30\u5FAA\u73AF\u3002\u6211\u4EEC\u5C06\u80FD\u591F\u5B9A\u671F\u8BC4\u4F30\u6A21\u578B, \u56E0\u4E3A\u6211\u4EEC\u4E0D\u518D\u53D7 "),k=i(he,"CODE",{});var Gt=p(k);O=n(Gt,"Trainer"),Gt.forEach(s),L=n(he," \u7C7B\u7684\u9650\u5236\u3002"),he.forEach(s),M=f(u),C=i(u,"H3",{id:!0});var Al=p(C);Q=n(Al,"\u4E3A\u8BAD\u7EC3\u505A\u51C6\u5907"),Al.forEach(s),z=f(u),A=i(u,"P",{});var Ce=p(A);N=n(Ce,"\u9996\u5148, \u6211\u4EEC\u9700\u8981\u4ECE\u6211\u4EEC\u7684\u6570\u636E\u96C6\u4E2D\u6784\u5EFA "),R=i(Ce,"CODE",{});var ya=p(R);G=n(ya,"DataLoader"),ya.forEach(s),K=n(Ce,"\u3002\u6211\u4EEC\u5C06\u8FD9\u4E9B\u6570\u636E\u96C6\u7684\u683C\u5F0F\u8BBE\u7F6E\u4E3A "),W=i(Ce,"CODE",{});var Pl=p(W);I=n(Pl,'"torch"'),Pl.forEach(s),U=n(Ce,", \u5E76\u5220\u9664\u6A21\u578B\u672A\u4F7F\u7528\u7684\u9A8C\u8BC1\u96C6\u4E2D\u7684\u5217\u3002\u7136\u540E, \u6211\u4EEC\u53EF\u4EE5\u4F7F\u7528 Transformers \u63D0\u4F9B\u7684 "),ae=i(Ce,"CODE",{});var Sl=p(ae);J=n(Sl,"default_data_collator"),Sl.forEach(s),pe=n(Ce," \u4F5C\u4E3A "),se=i(Ce,"CODE",{});var qn=p(se);Z=n(qn,"collate_fn"),qn.forEach(s),Ue=n(Ce,", \u5E76\u6253\u4E71\u8BAD\u7EC3\u96C6, \u4F46\u4E0D\u6253\u4E71\u9A8C\u8BC1\u96C658:"),Ce.forEach(s),Se=f(u),E(ne.$$.fragment,u),Oe=f(u),V=i(u,"P",{});var Wt=p(V);X=n(Wt,"\u63A5\u4E0B\u6765\u6211\u4EEC\u91CD\u65B0\u5B9E\u4F8B\u5316\u6211\u4EEC\u7684\u6A21\u578B, \u4EE5\u786E\u4FDD\u6211\u4EEC\u4E0D\u4F1A\u7EE7\u7EED\u4E4B\u524D\u7684\u5FAE\u8C03, \u800C\u662F\u518D\u6B21\u4ECE BERT \u9884\u8BAD\u7EC3\u6A21\u578B\u5F00\u59CB:"),Wt.forEach(s),us=f(u),E(xe.$$.fragment,u),we=f(u),ge=i(u,"P",{});var Da=p(ge);$e=n(Da,"\u7136\u540E\u6211\u4EEC\u9700\u8981\u4E00\u4E2A\u4F18\u5316\u5668\u3002\u50CF\u5F80\u5E38\u4E00\u6837, \u6211\u4EEC\u4F7F\u7528\u7ECF\u5178\u7684 "),Je=i(Da,"CODE",{});var En=p(Je);Me=n(En,"AdamW"),En.forEach(s),fe=n(Da,", \u5B83\u4E0E Adam \u7C7B\u4F3C, \u4F46\u5BF9\u6743\u91CD\u8870\u51CF\u7684\u5E94\u7528\u65B9\u5F0F\u8FDB\u884C\u4E86\u4FEE\u590D:"),Da.forEach(s),Be=f(u),E(ce.$$.fragment,u),sa=f(u),le=i(u,"P",{});var Y=p(le);_s=n(Y,"\u4E00\u65E6\u6211\u4EEC\u62E5\u6709\u6240\u6709\u8FD9\u4E9B\u5BF9\u8C61, \u6211\u4EEC\u53EF\u4EE5\u5C06\u5B83\u4EEC\u53D1\u9001\u7ED9 "),At=i(Y,"CODE",{});var Ut=p(At);Za=n(Ut,"accelerator.prepare()"),Ut.forEach(s),ta=n(Y," \u65B9\u6CD5\u3002\u8BF7\u8BB0\u4F4F, \u5982\u679C\u60A8\u60F3\u5728 Colab \u7B14\u8BB0\u672C\u4E2D\u7684 TPU \u4E0A\u8FDB\u884C\u8BAD\u7EC3, \u60A8\u9700\u8981\u5C06\u6240\u6709\u8FD9\u4E9B\u4EE3\u7801\u79FB\u52A8\u5230\u4E00\u4E2A\u8BAD\u7EC3\u51FD\u6570\u4E2D, \u5E76\u4E14\u4E0D\u5E94\u8BE5\u6267\u884C\u4EFB\u4F55\u5B9E\u4F8B\u5316 "),je=i(Y,"CODE",{});var Ca=p(je);Xe=n(Ca,"Accelerator"),Ca.forEach(s),Pt=n(Y," \u7684\u5355\u5143\u3002\u6211\u4EEC\u53EF\u4EE5\u901A\u8FC7\u4F20\u9012 "),Ie=i(Y,"CODE",{});var Ol=p(Ie);en=n(Ol,"fp16=True"),Ol.forEach(s),St=n(Y," \u7ED9 "),Ot=i(Y,"CODE",{});var Ml=p(Ot);aa=n(Ml,"Accelerator"),Ml.forEach(s),Ke=n(Y," (\u6216\u8005, \u5982\u679C\u4F60\u5C06\u4EE3\u7801\u4F5C\u4E3A\u811A\u672C\u6267\u884C, \u53EA\u9700\u786E\u4FDD\u9002\u5F53\u5730\u586B\u5199 \u{1F917} Accelerate "),Mt=i(Y,"CODE",{});var Bl=p(Mt);Bt=n(Bl,"config"),Bl.forEach(s),sn=n(Y," )\u3002"),Y.forEach(s),na=f(u),E(Ye.$$.fragment,u),Ze=f(u),ve=i(u,"P",{});var Ve=p(ve);Xs=n(Ve,"\u4ECE\u524D\u9762\u51E0\u8282\u4E2D\u4F60\u5E94\u8BE5\u77E5\u9053, \u6211\u4EEC\u53EA\u80FD\u4F7F\u7528 "),It=i(Ve,"CODE",{});var Ta=p(It);la=n(Ta,"train_dataloader"),Ta.forEach(s),ms=n(Ve," \u957F\u5EA6\u6765\u8BA1\u7B97\u7ECF\u8FC7 "),Ks=i(Ve,"CODE",{});var Il=p(Ks);hs=n(Il,"accelerator.prepare()"),Il.forEach(s),ra=n(Ve," \u65B9\u6CD5\u540E\u7684\u8BAD\u7EC3\u6B65\u9AA4\u7684\u6570\u91CF\u3002\u6211\u4EEC\u4F7F\u7528\u4E0E\u524D\u51E0\u8282\u76F8\u540C\u7684\u7EBF\u6027\u65F6\u95F4\u8868:"),Ve.forEach(s),ue=f(u),E(ws.$$.fragment,u),Ys=f(u),be=i(u,"P",{});var cs=p(be);tn=n(cs,"\u8981\u5C06\u6211\u4EEC\u7684\u6A21\u578B\u63A8\u9001\u5230 Hub, \u6211\u4EEC\u9700\u8981\u5728\u5DE5\u4F5C\u6587\u4EF6\u5939\u4E2D\u521B\u5EFA\u4E00\u4E2A "),gs=i(cs,"CODE",{});var Fl=p(gs);an=n(Fl,"Repository"),Fl.forEach(s),nn=n(cs," \u5BF9\u8C61\u3002\u5982\u679C\u4F60\u5C1A\u672A\u767B\u5F55, \u8BF7\u5148\u767B\u5F55 Hugging Face Hub\u3002\u6211\u4EEC\u5C06\u6839\u636E\u6211\u4EEC\u60F3\u8981\u4E3A\u6A21\u578B\u63D0\u4F9B\u7684\u6A21\u578B ID \u786E\u5B9A\u5B58\u50A8\u5E93\u540D\u79F0 (\u968F\u610F\u7528\u4F60\u81EA\u5DF1\u7684\u9009\u62E9\u66FF\u6362 "),$s=i(cs,"CODE",{});var Jt=p($s);ln=n(Jt,"repo_name"),Jt.forEach(s),rn=n(cs,"; \u5B83\u53EA\u9700\u8981\u5305\u542B\u4F60\u7684\u7528\u6237\u540D, \u8FD9\u5C31\u662F\u51FD\u6570 "),Zs=i(cs,"CODE",{});var Aa=p(Zs);bs=n(Aa,"get_full_repo_name()"),Aa.forEach(s),oa=n(cs," \u6240\u505A\u7684):"),cs.forEach(s),es=f(u),E(ss.$$.fragment,u),te=f(u),E(Fe.$$.fragment,u),ia=f(u),et=i(u,"P",{});var Ll=p(et);Ft=n(Ll,"\u7136\u540E\u6211\u4EEC\u53EF\u4EE5\u5C06\u8BE5\u5B58\u50A8\u5E93\u514B\u9686\u5230\u672C\u5730\u6587\u4EF6\u5939\u4E2D\u3002\u5982\u679C\u5B83\u5DF2\u7ECF\u5B58\u5728, \u8FD9\u4E2A\u672C\u5730\u6587\u4EF6\u5939\u5E94\u8BE5\u662F\u6211\u4EEC\u6B63\u5728\u4F7F\u7528\u7684\u5B58\u50A8\u5E93\u7684\u514B\u9686:"),Ll.forEach(s),pa=f(u),E(xs.$$.fragment,u),st=f(u),ye=i(u,"P",{});var ut=p(ye);on=n(ut,"\u6211\u4EEC\u73B0\u5728\u53EF\u4EE5\u901A\u8FC7\u8C03\u7528 "),js=i(ut,"CODE",{});var zl=p(js);pn=n(zl,"repo.push_to_hub()"),zl.forEach(s),cn=n(ut," \u65B9\u6CD5\u4E0A\u4F20\u6211\u4EEC\u4FDD\u5B58\u5728 "),vs=i(ut,"CODE",{});var Xt=p(vs);dn=n(Xt,"output_dir"),Xt.forEach(s),fn=n(ut," \u4E2D\u7684\u4EFB\u4F55\u5185\u5BB9\u3002\u8FD9\u5C06\u5E2E\u52A9\u6211\u4EEC\u5728\u6BCF\u4E2A epoch \u7ED3\u675F\u65F6\u4E0A\u4F20\u4E2D\u95F4\u6A21\u578B\u3002"),ut.forEach(s),tt=f(u),ks=i(u,"H2",{id:!0});var Pa=p(ks);un=n(Pa,"\u8BAD\u7EC3\u5FAA\u73AF"),Pa.forEach(s),Lt=f(u),ke=i(u,"P",{});var Nl=p(ke);_n=n(Nl,"\u6211\u4EEC\u73B0\u5728\u51C6\u5907\u7F16\u5199\u5B8C\u6574\u7684\u8BAD\u7EC3\u5FAA\u73AF\u3002\u5728\u5B9A\u4E49\u4E86\u4E00\u4E2A\u8FDB\u5EA6\u6761\u6765\u8DDF\u8E2A\u8BAD\u7EC3\u8FDB\u884C\u540E, \u5FAA\u73AF\u5206\u4E3A\u4E09\u4E2A\u90E8\u5206:"),Nl.forEach(s),at=f(u),De=i(u,"UL",{});var _t=p(De);qs=i(_t,"LI",{});var Kt=p(qs);ca=n(Kt,"\u8BAD\u7EC3\u672C\u8EAB\u662F\u5BF9 "),Le=i(Kt,"CODE",{});var mt=p(Le);da=n(mt,"train_dataloader"),mt.forEach(s),Es=n(Kt," \u7684\u7ECF\u5178\u8FED\u4EE3, \u524D\u5411\u4F20\u9012\u6A21\u578B, \u7136\u540E\u53CD\u5411\u4F20\u9012\u548C\u4F18\u5316\u5668\u6B65\u9AA4\u3002"),Kt.forEach(s),fa=f(_t),de=i(_t,"LI",{});var Qe=p(de);mn=n(Qe,"\u5728\u8BA1\u7B97\u4E2D, \u6211\u4EEC\u5728\u5C06 "),nt=i(Qe,"CODE",{});var ht=p(nt);ys=n(ht,"start_logits"),ht.forEach(s),ua=n(Qe," \u548C "),ze=i(Qe,"CODE",{});var yn=p(ze);_a=n(yn,"end_logits"),yn.forEach(s),lt=n(Qe," \u7684\u6240\u6709\u503C\u8F6C\u6362\u4E3A NumPy \u6570\u7EC4\u4E4B\u524D, \u6536\u96C6\u5B83\u4EEC\u7684\u6240\u6709\u503C\u3002\u8BC4\u4F30\u5FAA\u73AF\u5B8C\u6210\u540E,\u6211\u4EEC\u5C06\u8FDE\u63A5\u6240\u6709\u7ED3\u679C\u3002\u8BF7\u6CE8\u610F, \u6211\u4EEC\u9700\u8981\u622A\u65AD, \u56E0\u4E3A "),zt=i(Qe,"CODE",{});var Re=p(zt);ma=n(Re,"Accelerator"),Re.forEach(s),Ds=n(Qe," \u53EF\u80FD\u5728\u6700\u540E\u6DFB\u52A0\u4E86\u4E00\u4E9B\u793A\u4F8B, \u4EE5\u786E\u4FDD\u6211\u4EEC\u5728\u6BCF\u4E2A\u8FC7\u7A0B\u4E2D\u62E5\u6709\u76F8\u540C\u6570\u91CF\u7684\u793A\u4F8B\u3002"),Qe.forEach(s),ha=f(_t),_e=i(_t,"LI",{});var wt=p(_e);wa=n(wt,"\u4FDD\u5B58\u548C\u4E0A\u4F20, \u8FD9\u91CC\u6211\u4EEC\u5148\u4FDD\u5B58\u6A21\u578B\u548C\u5206\u8BCD\u5668, \u7136\u540E\u8C03\u7528 "),ts=i(wt,"CODE",{});var Sa=p(ts);hn=n(Sa,"repo.push_to_hub()"),Sa.forEach(s),ga=n(wt,"\u3002\u6B63\u5982\u6211\u4EEC\u4E4B\u524D\u6240\u505A\u7684\u90A3\u6837, \u6211\u4EEC\u4F7F\u7528\u53C2\u6570 "),Ne=i(wt,"CODE",{});var Hl=p(Ne);wn=n(Hl,"blocking=False"),Hl.forEach(s),$a=n(wt," \u6765\u544A\u8BC9 \u{1F917} Hub \u5E93\u63A8\u5165\u4E00\u4E2A\u5F02\u6B65\u8FDB\u7A0B\u3002\u8FD9\u6837, \u8BAD\u7EC3\u6B63\u5E38\u7EE7\u7EED, \u5E76\u4E14\u8FD9\u4E2A (\u957F) \u6307\u4EE4\u5728\u540E\u53F0\u6267\u884C\u3002"),wt.forEach(s),_t.forEach(s),as=f(u),Cs=i(u,"P",{});var Vl=p(Cs);rt=n(Vl,"\u8FD9\u662F\u8BAD\u7EC3\u5FAA\u73AF\u7684\u5B8C\u6574\u4EE3\u7801:"),Vl.forEach(s),ba=f(u),E(ns.$$.fragment,u),Ts=f(u),ot=i(u,"P",{});var Oa=p(ot);xa=n(Oa,"\u5982\u679C\u8FD9\u662F\u60A8\u7B2C\u4E00\u6B21\u770B\u5230\u4F7F\u7528 \u{1F917} Accelerate \u4FDD\u5B58\u7684\u6A21\u578B, \u8BA9\u6211\u4EEC\u82B1\u70B9\u65F6\u95F4\u68C0\u67E5\u4E00\u4E0B\u5B83\u9644\u5E26\u7684\u4E09\u884C\u4EE3\u7801:"),Oa.forEach(s),ls=f(u),E(rs.$$.fragment,u),me=f(u),ee=i(u,"P",{});var re=p(ee);As=n(re,"\u7B2C\u4E00\u884C\u662F\u4E0D\u8A00\u81EA\u660E\u7684: \u5B83\u544A\u8BC9\u6240\u6709\u8FDB\u7A0B\u8981\u7B49\u5230\u6BCF\u4E2A\u4EBA\u90FD\u5904\u4E8E\u90A3\u4E2A\u9636\u6BB5\u624D\u80FD\u7EE7\u7EED\u3002\u8FD9\u662F\u4E3A\u4E86\u786E\u4FDD\u6211\u4EEC\u5728\u4FDD\u5B58\u4E4B\u524D\u5728\u6BCF\u4E2A\u8FC7\u7A0B\u4E2D\u90FD\u6709\u76F8\u540C\u7684\u6A21\u578B\u3002\u7136\u540E\u6211\u4EEC\u83B7\u53D6 "),Nt=i(re,"CODE",{});var Ql=p(Nt);gn=n(Ql,"unwrapped_model"),Ql.forEach(s),Ht=n(re,", \u8FD9\u662F\u6211\u4EEC\u5B9A\u4E49\u7684\u57FA\u7840\u6A21\u578B\u3002 "),Vt=i(re,"CODE",{});var Dn=p(Vt);$n=n(Dn,"accelerator.prepare()"),Dn.forEach(s),Qt=n(re," \u65B9\u6CD5\u5C06\u6A21\u578B\u66F4\u6539\u4E3A\u5728\u5206\u5E03\u5F0F\u8BAD\u7EC3\u4E2D\u5DE5\u4F5C, \u56E0\u6B64\u5B83\u5C06\u4E0D\u518D\u6709 "),Rt=i(re,"CODE",{});var Ge=p(Rt);bn=n(Ge,"save_pretrained()"),Ge.forEach(s),ja=n(re," \u65B9\u6CD5; "),He=i(re,"CODE",{});var Rl=p(He);va=n(Rl,"accelerator.unwrap_model()"),Rl.forEach(s),Ps=n(re," \u65B9\u6CD5\u4F1A\u64A4\u9500\u8BE5\u6B65\u9AA4\u3002\u6700\u540E, \u6211\u4EEC\u8C03\u7528 "),it=i(re,"CODE",{});var Yt=p(it);pt=n(Yt,"save_pretrained()"),Yt.forEach(s),xn=n(re,", \u4F46\u544A\u8BC9\u8BE5\u65B9\u6CD5\u4F7F\u7528 "),ct=i(re,"CODE",{});var Gl=p(ct);Ss=n(Gl,"accelerator.save()"),Gl.forEach(s),ka=n(re," \u800C\u4E0D\u662F "),os=i(re,"CODE",{});var Wl=p(os);jn=n(Wl,"torch.save()"),Wl.forEach(s),qa=n(re,"\u3002"),re.forEach(s),is=f(u),qe=i(u,"P",{});var ds=p(qe);Os=n(ds,"\u5B8C\u6210\u540E, \u4F60\u5E94\u8BE5\u62E5\u6709\u4E00\u4E2A\u6A21\u578B, \u8BE5\u6A21\u578B\u4EA7\u751F\u7684\u7ED3\u679C\u4E0E\u4F7F\u7528 "),dt=i(ds,"CODE",{});var Ul=p(dt);ft=n(Ul,"Trainer"),Ul.forEach(s),vn=n(ds," \u8BAD\u7EC3\u7684\u6A21\u578B\u975E\u5E38\u76F8\u4F3C\u3002\u4F60\u53EF\u4EE5\u5728 "),ps=i(ds,"A",{href:!0,rel:!0});var Jl=p(ps);Ee=i(Jl,"EM",{});var Cn=p(Ee);Ms=n(Cn,"huggingface-course/bert-finetuned-squad-accelerate"),Cn.forEach(s),Jl.forEach(s),Cl=n(ds," \u4E0A\u67E5\u770B\u6211\u4EEC\u4F7F\u7528\u6B64\u4EE3\u7801\u8BAD\u7EC3\u7684\u6A21\u578B\u3002\u5982\u679C\u4F60\u60F3\u6D4B\u8BD5\u5BF9\u8BAD\u7EC3\u5FAA\u73AF\u7684\u4EFB\u4F55\u8C03\u6574, \u4F60\u53EF\u4EE5\u901A\u8FC7\u7F16\u8F91\u4E0A\u9762\u663E\u793A\u7684\u4EE3\u7801\u76F4\u63A5\u5B9E\u73B0\u5B83\u4EEC!"),ds.forEach(s),this.h()},h(){B(v,"id",""),B(m,"href","/course/chapter3/4"),B(C,"id",""),B(ks,"id",""),B(ps,"href","https://huggingface.co/huggingface-course/bert-finetuned-squad-accelerate"),B(ps,"rel","nofollow")},m(u,F){l(u,c,F),t(c,h),l(u,_,F),l(u,v,F),t(v,T),l(u,$,F),l(u,j,F),t(j,x),t(j,m),t(m,S),t(j,b),t(j,k),t(k,O),t(j,L),l(u,M,F),l(u,C,F),t(C,Q),l(u,z,F),l(u,A,F),t(A,N),t(A,R),t(R,G),t(A,K),t(A,W),t(W,I),t(A,U),t(A,ae),t(ae,J),t(A,pe),t(A,se),t(se,Z),t(A,Ue),l(u,Se,F),y(ne,u,F),l(u,Oe,F),l(u,V,F),t(V,X),l(u,us,F),y(xe,u,F),l(u,we,F),l(u,ge,F),t(ge,$e),t(ge,Je),t(Je,Me),t(ge,fe),l(u,Be,F),y(ce,u,F),l(u,sa,F),l(u,le,F),t(le,_s),t(le,At),t(At,Za),t(le,ta),t(le,je),t(je,Xe),t(le,Pt),t(le,Ie),t(Ie,en),t(le,St),t(le,Ot),t(Ot,aa),t(le,Ke),t(le,Mt),t(Mt,Bt),t(le,sn),l(u,na,F),y(Ye,u,F),l(u,Ze,F),l(u,ve,F),t(ve,Xs),t(ve,It),t(It,la),t(ve,ms),t(ve,Ks),t(Ks,hs),t(ve,ra),l(u,ue,F),y(ws,u,F),l(u,Ys,F),l(u,be,F),t(be,tn),t(be,gs),t(gs,an),t(be,nn),t(be,$s),t($s,ln),t(be,rn),t(be,Zs),t(Zs,bs),t(be,oa),l(u,es,F),y(ss,u,F),l(u,te,F),y(Fe,u,F),l(u,ia,F),l(u,et,F),t(et,Ft),l(u,pa,F),y(xs,u,F),l(u,st,F),l(u,ye,F),t(ye,on),t(ye,js),t(js,pn),t(ye,cn),t(ye,vs),t(vs,dn),t(ye,fn),l(u,tt,F),l(u,ks,F),t(ks,un),l(u,Lt,F),l(u,ke,F),t(ke,_n),l(u,at,F),l(u,De,F),t(De,qs),t(qs,ca),t(qs,Le),t(Le,da),t(qs,Es),t(De,fa),t(De,de),t(de,mn),t(de,nt),t(nt,ys),t(de,ua),t(de,ze),t(ze,_a),t(de,lt),t(de,zt),t(zt,ma),t(de,Ds),t(De,ha),t(De,_e),t(_e,wa),t(_e,ts),t(ts,hn),t(_e,ga),t(_e,Ne),t(Ne,wn),t(_e,$a),l(u,as,F),l(u,Cs,F),t(Cs,rt),l(u,ba,F),y(ns,u,F),l(u,Ts,F),l(u,ot,F),t(ot,xa),l(u,ls,F),y(rs,u,F),l(u,me,F),l(u,ee,F),t(ee,As),t(ee,Nt),t(Nt,gn),t(ee,Ht),t(ee,Vt),t(Vt,$n),t(ee,Qt),t(ee,Rt),t(Rt,bn),t(ee,ja),t(ee,He),t(He,va),t(ee,Ps),t(ee,it),t(it,pt),t(ee,xn),t(ee,ct),t(ct,Ss),t(ee,ka),t(ee,os),t(os,jn),t(ee,qa),l(u,is,F),l(u,qe,F),t(qe,Os),t(qe,dt),t(dt,ft),t(qe,vn),t(qe,ps),t(ps,Ee),t(Ee,Ms),t(qe,Cl),Ea=!0},i(u){Ea||(w(ne.$$.fragment,u),w(xe.$$.fragment,u),w(ce.$$.fragment,u),w(Ye.$$.fragment,u),w(ws.$$.fragment,u),w(ss.$$.fragment,u),w(Fe.$$.fragment,u),w(xs.$$.fragment,u),w(ns.$$.fragment,u),w(rs.$$.fragment,u),Ea=!0)},o(u){g(ne.$$.fragment,u),g(xe.$$.fragment,u),g(ce.$$.fragment,u),g(Ye.$$.fragment,u),g(ws.$$.fragment,u),g(ss.$$.fragment,u),g(Fe.$$.fragment,u),g(xs.$$.fragment,u),g(ns.$$.fragment,u),g(rs.$$.fragment,u),Ea=!1},d(u){u&&s(c),u&&s(_),u&&s(v),u&&s($),u&&s(j),u&&s(M),u&&s(C),u&&s(z),u&&s(A),u&&s(Se),D(ne,u),u&&s(Oe),u&&s(V),u&&s(us),D(xe,u),u&&s(we),u&&s(ge),u&&s(Be),D(ce,u),u&&s(sa),u&&s(le),u&&s(na),D(Ye,u),u&&s(Ze),u&&s(ve),u&&s(ue),D(ws,u),u&&s(Ys),u&&s(be),u&&s(es),D(ss,u),u&&s(te),D(Fe,u),u&&s(ia),u&&s(et),u&&s(pa),D(xs,u),u&&s(st),u&&s(ye),u&&s(tt),u&&s(ks),u&&s(Lt),u&&s(ke),u&&s(at),u&&s(De),u&&s(as),u&&s(Cs),u&&s(ba),D(ns,u),u&&s(Ts),u&&s(ot),u&&s(ls),D(rs,u),u&&s(me),u&&s(ee),u&&s(is),u&&s(qe)}}}function fm(H){let c,h,_,v,T,$,j,x,m,S,b,k,O,L,M,C,Q,z,A,N,R,G,K,W,I,U,ae,J,pe,se,Z,Ue,Se,ne,Oe,V,X,us,xe,we,ge,$e,Je,Me,fe,Be,ce,sa,le,_s,At,Za,ta,je,Xe,Pt,Ie,en,St,Ot,aa,Ke,Mt,Bt,sn,na,Ye,Ze,ve,Xs,It,la,ms,Ks,hs,ra,ue,ws,Ys,be,tn,gs,an,nn,$s,ln,rn,Zs,bs,oa,es,ss,te,Fe,ia,et,Ft,pa,xs,st,ye,on,js,pn,cn,vs,dn,fn,tt,ks,un,Lt,ke,_n,at,De,qs,ca,Le,da,Es,fa,de,mn,nt,ys,ua,ze,_a,lt,zt,ma,Ds,ha,_e,wa,ts,hn,ga,Ne,wn,$a,as,Cs,rt,ba,ns,Ts,ot,xa,ls,rs,me,ee,As,Nt,gn,Ht,Vt,$n,Qt,Rt,bn,ja,He,va,Ps,it,pt,xn,ct,Ss,ka,os,jn,qa,is,qe,Os,dt,ft,vn,ps,Ee,Ms,Cl,Ea,u,F,kn,he,Tl,Gt,Al,Ce,ya,Pl,Sl,qn,Wt,Da,En,Y,Ut,Ca,Ol,Ml,Bl,Ve,Ta,Il,cs,Fl,Jt,Aa,Ll,ut,zl,Xt,Pa,Nl,_t,Kt,mt,Qe,ht,yn,Re,wt,Sa,Hl,Vl,Oa,re,Ql,Dn,Ge,Rl,Yt,Gl,Wl,ds,Ul,Jl,Cn,Tn,Bo,An,Io,gt,Ip,Gr,Fp,Lp,Wr,zp,Np,Fo,Pn,Lo,Sn,zo,Xl,Hp,No,On,Ho,Mn,Vo,Kl,Vp,Qo,Yl,Qp,Ro,Ma,Zl,Ur,Rp,Gp,Wp,$t,Jr,Up,Jp,Xr,Xp,Kp,Kr,Yp,Zp,Go,bt,ec,Yr,sc,tc,Zr,ac,nc,Wo,Ba,lc,eo,rc,oc,Uo,Bn,Jo,In,Xo,Ia,ic,so,pc,cc,Ko,Fn,Yo,Ln,Zo,Fa,dc,to,fc,uc,ei,zn,si,Nn,ti,er,_c,ai,La,ni,sr,mc,li,Hn,ri,tr,hc,oi,xt,wc,ao,gc,$c,no,bc,xc,ii,Vn,pi,Qn,ci,ar,jc,di,Rn,vc,fi,nr,kc,ui,jt,qc,lo,Ec,yc,ro,Dc,Cc,_i,Gn,mi,lr,Tc,hi,Wn,wi,Un,gi,rr,Ac,$i,or,Pc,bi,Bs,Is,ir,Jn,Sc,xi,Fs,Ls,pr,za,Oc,Xn,oo,Mc,Bc,Ic,ji,fs,io,Fc,Lc,po,zc,Nc,Kn,Hc,co,Vc,Qc,Rc,Zt,Gc,fo,Wc,Uc,uo,Jc,Xc,vi,Te,Kc,_o,Yc,Zc,mo,ed,sd,ho,td,ad,ki,M_='<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>log</mi><mo>\u2061</mo><mo stretchy="false">(</mo><mi>a</mi><mi>b</mi><mo stretchy="false">)</mo><mo>=</mo><mi>log</mi><mo>\u2061</mo><mo stretchy="false">(</mo><mi>a</mi><mo stretchy="false">)</mo><mo>+</mo><mi>log</mi><mo>\u2061</mo><mo stretchy="false">(</mo><mi>b</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">\\log(ab) = \\log(a) + \\log(b)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop">lo<span style="margin-right:0.01389em;">g</span></span><span class="mopen">(</span><span class="mord mathnormal">ab</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop">lo<span style="margin-right:0.01389em;">g</span></span><span class="mopen">(</span><span class="mord mathnormal">a</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop">lo<span style="margin-right:0.01389em;">g</span></span><span class="mopen">(</span><span class="mord mathnormal">b</span><span class="mclose">)</span></span></span></span>',qi,Ei,Na,nd,wo,ld,rd,yi,Yn,Di,cr,od,Ci,Zn,Ti,Ha,id,go,pd,cd,Ai,zs,Ns,dr,Ae,dd,$o,fd,ud,bo,_d,md,xo,hd,wd,jo,gd,$d,Pi,el,Si,Va,bd,vo,xd,jd,Oi,vt,ko,vd,kd,qo,qd,Ed,sl,yd,Eo,Dd,Cd,Mi,fr,Td,Bi,tl,Ii,ur,Ad,Fi,al,Li,_r,Pd,zi,nl,Ni,mr,Sd,Hi,ll,Vi,rl,Qi,hr,Od,Ri,ol,Gi,il,Wi,Qa,Md,pl,Bd,Id,Ui,wr,cl,Ji,gr,Fd,Xi,dl,Ki,fl,Yi,$r,Ld,Zi,ul,zd,ep,Hs,Vs,br,xr,Nd,sp,jr,Hd,tp,_l,ap,vr,Vd,np,ml,lp,Qs,Rs,kr,Pe,Qd,yo,Rd,Gd,Do,Wd,Ud,Co,Jd,Xd,To,Kd,Yd,rp,Gs,Ws,qr,Er,Zd,op,Us,Js,yr,hl,ip,Dr,ef,pp,Cr,Tr,sf,cp,Ra,dp,Ar,wl,tf,fp,Ga,af,Ao,nf,lf,up,gl,_p,$l,mp,Pr,rf,hp;_=new V_({props:{fw:H[0]}});const mf=[R_,Q_],bl=[];function hf(e,r){return e[0]==="pt"?0:1}x=hf(H),m=bl[x]=mf[x](H),N=new Bp({props:{id:"ajPx5LwJD-I"}}),we=new Mp({props:{$$slots:{default:[G_]},$$scope:{ctx:H}}}),Ie=new _f({}),Ze=new P({props:{code:`from datasets import load_dataset

raw_datasets = load_dataset("squad")`,highlighted:`<span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset

raw_datasets = load_dataset(<span class="hljs-string">&quot;squad&quot;</span>)`}}),ms=new P({props:{code:"raw_datasets",highlighted:"raw_datasets"}}),hs=new P({props:{code:`DatasetDict({
    train: Dataset({
        features: ['id', 'title', 'context', 'question', 'answers'],
        num_rows: 87599
    })
    validation: Dataset({
        features: ['id', 'title', 'context', 'question', 'answers'],
        num_rows: 10570
    })
})`,highlighted:`DatasetDict({
    train: Dataset({
        features: [<span class="hljs-string">&#x27;id&#x27;</span>, <span class="hljs-string">&#x27;title&#x27;</span>, <span class="hljs-string">&#x27;context&#x27;</span>, <span class="hljs-string">&#x27;question&#x27;</span>, <span class="hljs-string">&#x27;answers&#x27;</span>],
        num_rows: <span class="hljs-number">87599</span>
    })
    validation: Dataset({
        features: [<span class="hljs-string">&#x27;id&#x27;</span>, <span class="hljs-string">&#x27;title&#x27;</span>, <span class="hljs-string">&#x27;context&#x27;</span>, <span class="hljs-string">&#x27;question&#x27;</span>, <span class="hljs-string">&#x27;answers&#x27;</span>],
        num_rows: <span class="hljs-number">10570</span>
    })
})`}}),bs=new P({props:{code:`print("Context: ", raw_datasets["train"][0]["context"])
print("Question: ", raw_datasets["train"][0]["question"])
print("Answer: ", raw_datasets["train"][0]["answers"])`,highlighted:`<span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;Context: &quot;</span>, raw_datasets[<span class="hljs-string">&quot;train&quot;</span>][<span class="hljs-number">0</span>][<span class="hljs-string">&quot;context&quot;</span>])
<span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;Question: &quot;</span>, raw_datasets[<span class="hljs-string">&quot;train&quot;</span>][<span class="hljs-number">0</span>][<span class="hljs-string">&quot;question&quot;</span>])
<span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;Answer: &quot;</span>, raw_datasets[<span class="hljs-string">&quot;train&quot;</span>][<span class="hljs-number">0</span>][<span class="hljs-string">&quot;answers&quot;</span>])`}}),es=new P({props:{code:`Context: 'Architecturally, the school has a Catholic character. Atop the Main Building\\'s gold dome is a golden statue of the Virgin Mary. Immediately in front of the Main Building and facing it, is a copper statue of Christ with arms upraised with the legend "Venite Ad Me Omnes". Next to the Main Building is the Basilica of the Sacred Heart. Immediately behind the basilica is the Grotto, a Marian place of prayer and reflection. It is a replica of the grotto at Lourdes, France where the Virgin Mary reputedly appeared to Saint Bernadette Soubirous in 1858. At the end of the main drive (and in a direct line that connects through 3 statues and the Gold Dome), is a simple, modern stone statue of Mary.'
Question: 'To whom did the Virgin Mary allegedly appear in 1858 in Lourdes France?'
Answer: {'text': ['Saint Bernadette Soubirous'], 'answer_start': [515]}`,highlighted:`Context: <span class="hljs-string">&#x27;Architecturally, the school has a Catholic character. Atop the Main Building\\&#x27;s gold dome is a golden statue of the Virgin Mary. Immediately in front of the Main Building and facing it, is a copper statue of Christ with arms upraised with the legend &quot;Venite Ad Me Omnes&quot;. Next to the Main Building is the Basilica of the Sacred Heart. Immediately behind the basilica is the Grotto, a Marian place of prayer and reflection. It is a replica of the grotto at Lourdes, France where the Virgin Mary reputedly appeared to Saint Bernadette Soubirous in 1858. At the end of the main drive (and in a direct line that connects through 3 statues and the Gold Dome), is a simple, modern stone statue of Mary.&#x27;</span>
Question: <span class="hljs-string">&#x27;To whom did the Virgin Mary allegedly appear in 1858 in Lourdes France?&#x27;</span>
Answer: {<span class="hljs-string">&#x27;text&#x27;</span>: [<span class="hljs-string">&#x27;Saint Bernadette Soubirous&#x27;</span>], <span class="hljs-string">&#x27;answer_start&#x27;</span>: [<span class="hljs-number">515</span>]}`}}),Le=new P({props:{code:'raw_datasets["train"].filter(lambda x: len(x["answers"]["text"]) != 1)',highlighted:'raw_datasets[<span class="hljs-string">&quot;train&quot;</span>].<span class="hljs-built_in">filter</span>(<span class="hljs-keyword">lambda</span> x: <span class="hljs-built_in">len</span>(x[<span class="hljs-string">&quot;answers&quot;</span>][<span class="hljs-string">&quot;text&quot;</span>]) != <span class="hljs-number">1</span>)'}}),Es=new P({props:{code:`Dataset({
    features: ['id', 'title', 'context', 'question', 'answers'],
    num_rows: 0
})`,highlighted:`Dataset({
    features: [<span class="hljs-string">&#x27;id&#x27;</span>, <span class="hljs-string">&#x27;title&#x27;</span>, <span class="hljs-string">&#x27;context&#x27;</span>, <span class="hljs-string">&#x27;question&#x27;</span>, <span class="hljs-string">&#x27;answers&#x27;</span>],
    num_rows: <span class="hljs-number">0</span>
})`}}),ys=new P({props:{code:`print(raw_datasets["validation"][0]["answers"])
print(raw_datasets["validation"][2]["answers"])`,highlighted:`<span class="hljs-built_in">print</span>(raw_datasets[<span class="hljs-string">&quot;validation&quot;</span>][<span class="hljs-number">0</span>][<span class="hljs-string">&quot;answers&quot;</span>])
<span class="hljs-built_in">print</span>(raw_datasets[<span class="hljs-string">&quot;validation&quot;</span>][<span class="hljs-number">2</span>][<span class="hljs-string">&quot;answers&quot;</span>])`}}),ze=new P({props:{code:`{'text': ['Denver Broncos', 'Denver Broncos', 'Denver Broncos'], 'answer_start': [177, 177, 177]}
{'text': ['Santa Clara, California', "Levi's Stadium", "Levi's Stadium in the San Francisco Bay Area at Santa Clara, California."], 'answer_start': [403, 355, 355]}`,highlighted:`{<span class="hljs-string">&#x27;text&#x27;</span>: [<span class="hljs-string">&#x27;Denver Broncos&#x27;</span>, <span class="hljs-string">&#x27;Denver Broncos&#x27;</span>, <span class="hljs-string">&#x27;Denver Broncos&#x27;</span>], <span class="hljs-string">&#x27;answer_start&#x27;</span>: [<span class="hljs-number">177</span>, <span class="hljs-number">177</span>, <span class="hljs-number">177</span>]}
{<span class="hljs-string">&#x27;text&#x27;</span>: [<span class="hljs-string">&#x27;Santa Clara, California&#x27;</span>, <span class="hljs-string">&quot;Levi&#x27;s Stadium&quot;</span>, <span class="hljs-string">&quot;Levi&#x27;s Stadium in the San Francisco Bay Area at Santa Clara, California.&quot;</span>], <span class="hljs-string">&#x27;answer_start&#x27;</span>: [<span class="hljs-number">403</span>, <span class="hljs-number">355</span>, <span class="hljs-number">355</span>]}`}}),Ds=new P({props:{code:`print(raw_datasets["validation"][2]["context"])
print(raw_datasets["validation"][2]["question"])`,highlighted:`<span class="hljs-built_in">print</span>(raw_datasets[<span class="hljs-string">&quot;validation&quot;</span>][<span class="hljs-number">2</span>][<span class="hljs-string">&quot;context&quot;</span>])
<span class="hljs-built_in">print</span>(raw_datasets[<span class="hljs-string">&quot;validation&quot;</span>][<span class="hljs-number">2</span>][<span class="hljs-string">&quot;question&quot;</span>])`}}),_e=new P({props:{code:`'Super Bowl 50 was an American football game to determine the champion of the National Football League (NFL) for the 2015 season. The American Football Conference (AFC) champion Denver Broncos defeated the National Football Conference (NFC) champion Carolina Panthers 24\u201310 to earn their third Super Bowl title. The game was played on February 7, 2016, at Levi\\'s Stadium in the San Francisco Bay Area at Santa Clara, California. As this was the 50th Super Bowl, the league emphasized the "golden anniversary" with various gold-themed initiatives, as well as temporarily suspending the tradition of naming each Super Bowl game with Roman numerals (under which the game would have been known as "Super Bowl L"), so that the logo could prominently feature the Arabic numerals 50.'
'Where did Super Bowl 50 take place?'`,highlighted:`<span class="hljs-string">&#x27;Super Bowl 50 was an American football game to determine the champion of the National Football League (NFL) for the 2015 season. The American Football Conference (AFC) champion Denver Broncos defeated the National Football Conference (NFC) champion Carolina Panthers 24\u201310 to earn their third Super Bowl title. The game was played on February 7, 2016, at Levi\\&#x27;s Stadium in the San Francisco Bay Area at Santa Clara, California. As this was the 50th Super Bowl, the league emphasized the &quot;golden anniversary&quot; with various gold-themed initiatives, as well as temporarily suspending the tradition of naming each Super Bowl game with Roman numerals (under which the game would have been known as &quot;Super Bowl L&quot;), so that the logo could prominently feature the Arabic numerals 50.&#x27;</span>
<span class="hljs-string">&#x27;Where did Super Bowl 50 take place?&#x27;</span>`}}),as=new Bp({props:{id:"qgaM0weJHpA"}}),ls=new P({props:{code:`from transformers import AutoTokenizer

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

model_checkpoint = <span class="hljs-string">&quot;bert-base-cased&quot;</span>
tokenizer = AutoTokenizer.from_pretrained(model_checkpoint)`}}),He=new P({props:{code:"tokenizer.is_fast",highlighted:"tokenizer.is_fast"}}),Ps=new P({props:{code:"True",highlighted:'<span class="hljs-literal">True</span>'}}),Ss=new P({props:{code:"[CLS] question [SEP] context [SEP]",highlighted:'<span class="hljs-selector-attr">[CLS]</span> question <span class="hljs-selector-attr">[SEP]</span> context <span class="hljs-selector-attr">[SEP]</span>'}}),is=new P({props:{code:`context = raw_datasets["train"][0]["context"]
question = raw_datasets["train"][0]["question"]

inputs = tokenizer(question, context)
tokenizer.decode(inputs["input_ids"])`,highlighted:`context = raw_datasets[<span class="hljs-string">&quot;train&quot;</span>][<span class="hljs-number">0</span>][<span class="hljs-string">&quot;context&quot;</span>]
question = raw_datasets[<span class="hljs-string">&quot;train&quot;</span>][<span class="hljs-number">0</span>][<span class="hljs-string">&quot;question&quot;</span>]

inputs = tokenizer(question, context)
tokenizer.decode(inputs[<span class="hljs-string">&quot;input_ids&quot;</span>])`}}),Os=new P({props:{code:`'[CLS] To whom did the Virgin Mary allegedly appear in 1858 in Lourdes France? [SEP] Architecturally, '
'the school has a Catholic character. Atop the Main Building\\'s gold dome is a golden statue of the Virgin '
'Mary. Immediately in front of the Main Building and facing it, is a copper statue of Christ with arms '
'upraised with the legend " Venite Ad Me Omnes ". Next to the Main Building is the Basilica of the Sacred '
'Heart. Immediately behind the basilica is the Grotto, a Marian place of prayer and reflection. It is a '
'replica of the grotto at Lourdes, France where the Virgin Mary reputedly appeared to Saint Bernadette '
'Soubirous in 1858. At the end of the main drive ( and in a direct line that connects through 3 statues '
'and the Gold Dome ), is a simple, modern stone statue of Mary. [SEP]'`,highlighted:`<span class="hljs-string">&#x27;[CLS] To whom did the Virgin Mary allegedly appear in 1858 in Lourdes France? [SEP] Architecturally, &#x27;</span>
<span class="hljs-string">&#x27;the school has a Catholic character. Atop the Main Building\\&#x27;s gold dome is a golden statue of the Virgin &#x27;</span>
<span class="hljs-string">&#x27;Mary. Immediately in front of the Main Building and facing it, is a copper statue of Christ with arms &#x27;</span>
<span class="hljs-string">&#x27;upraised with the legend &quot; Venite Ad Me Omnes &quot;. Next to the Main Building is the Basilica of the Sacred &#x27;</span>
<span class="hljs-string">&#x27;Heart. Immediately behind the basilica is the Grotto, a Marian place of prayer and reflection. It is a &#x27;</span>
<span class="hljs-string">&#x27;replica of the grotto at Lourdes, France where the Virgin Mary reputedly appeared to Saint Bernadette &#x27;</span>
<span class="hljs-string">&#x27;Soubirous in 1858. At the end of the main drive ( and in a direct line that connects through 3 statues &#x27;</span>
<span class="hljs-string">&#x27;and the Gold Dome ), is a simple, modern stone statue of Mary. [SEP]&#x27;</span>`}}),mt=new P({props:{code:`inputs = tokenizer(
    question,
    context,
    max_length=100,
    truncation="only_second",
    stride=50,
    return_overflowing_tokens=True,
)

for ids in inputs["input_ids"]:
    print(tokenizer.decode(ids))`,highlighted:`inputs = tokenizer(
    question,
    context,
    max_length=<span class="hljs-number">100</span>,
    truncation=<span class="hljs-string">&quot;only_second&quot;</span>,
    stride=<span class="hljs-number">50</span>,
    return_overflowing_tokens=<span class="hljs-literal">True</span>,
)

<span class="hljs-keyword">for</span> ids <span class="hljs-keyword">in</span> inputs[<span class="hljs-string">&quot;input_ids&quot;</span>]:
    <span class="hljs-built_in">print</span>(tokenizer.decode(ids))`}}),ht=new P({props:{code:`'[CLS] To whom did the Virgin Mary allegedly appear in 1858 in Lourdes France? [SEP] Architecturally, the school has a Catholic character. Atop the Main Building\\'s gold dome is a golden statue of the Virgin Mary. Immediately in front of the Main Building and facing it, is a copper statue of Christ with arms upraised with the legend " Venite Ad Me Omnes ". Next to the Main Building is the Basilica of the Sacred Heart. Immediately behind the basi [SEP]'
'[CLS] To whom did the Virgin Mary allegedly appear in 1858 in Lourdes France? [SEP] the Main Building and facing it, is a copper statue of Christ with arms upraised with the legend " Venite Ad Me Omnes ". Next to the Main Building is the Basilica of the Sacred Heart. Immediately behind the basilica is the Grotto, a Marian place of prayer and reflection. It is a replica of the grotto at Lourdes, France where the Virgin [SEP]'
'[CLS] To whom did the Virgin Mary allegedly appear in 1858 in Lourdes France? [SEP] Next to the Main Building is the Basilica of the Sacred Heart. Immediately behind the basilica is the Grotto, a Marian place of prayer and reflection. It is a replica of the grotto at Lourdes, France where the Virgin Mary reputedly appeared to Saint Bernadette Soubirous in 1858. At the end of the main drive ( and in a direct line that connects through 3 [SEP]'
'[CLS] To whom did the Virgin Mary allegedly appear in 1858 in Lourdes France? [SEP]. It is a replica of the grotto at Lourdes, France where the Virgin Mary reputedly appeared to Saint Bernadette Soubirous in 1858. At the end of the main drive ( and in a direct line that connects through 3 statues and the Gold Dome ), is a simple, modern stone statue of Mary. [SEP]'`,highlighted:`<span class="hljs-string">&#x27;[CLS] To whom did the Virgin Mary allegedly appear in 1858 in Lourdes France? [SEP] Architecturally, the school has a Catholic character. Atop the Main Building\\&#x27;s gold dome is a golden statue of the Virgin Mary. Immediately in front of the Main Building and facing it, is a copper statue of Christ with arms upraised with the legend &quot; Venite Ad Me Omnes &quot;. Next to the Main Building is the Basilica of the Sacred Heart. Immediately behind the basi [SEP]&#x27;</span>
<span class="hljs-string">&#x27;[CLS] To whom did the Virgin Mary allegedly appear in 1858 in Lourdes France? [SEP] the Main Building and facing it, is a copper statue of Christ with arms upraised with the legend &quot; Venite Ad Me Omnes &quot;. Next to the Main Building is the Basilica of the Sacred Heart. Immediately behind the basilica is the Grotto, a Marian place of prayer and reflection. It is a replica of the grotto at Lourdes, France where the Virgin [SEP]&#x27;</span>
<span class="hljs-string">&#x27;[CLS] To whom did the Virgin Mary allegedly appear in 1858 in Lourdes France? [SEP] Next to the Main Building is the Basilica of the Sacred Heart. Immediately behind the basilica is the Grotto, a Marian place of prayer and reflection. It is a replica of the grotto at Lourdes, France where the Virgin Mary reputedly appeared to Saint Bernadette Soubirous in 1858. At the end of the main drive ( and in a direct line that connects through 3 [SEP]&#x27;</span>
<span class="hljs-string">&#x27;[CLS] To whom did the Virgin Mary allegedly appear in 1858 in Lourdes France? [SEP]. It is a replica of the grotto at Lourdes, France where the Virgin Mary reputedly appeared to Saint Bernadette Soubirous in 1858. At the end of the main drive ( and in a direct line that connects through 3 statues and the Gold Dome ), is a simple, modern stone statue of Mary. [SEP]&#x27;</span>`}}),Tn=new P({props:{code:`inputs = tokenizer(
    question,
    context,
    max_length=100,
    truncation="only_second",
    stride=50,
    return_overflowing_tokens=True,
    return_offsets_mapping=True,
)
inputs.keys()`,highlighted:`inputs = tokenizer(
    question,
    context,
    max_length=<span class="hljs-number">100</span>,
    truncation=<span class="hljs-string">&quot;only_second&quot;</span>,
    stride=<span class="hljs-number">50</span>,
    return_overflowing_tokens=<span class="hljs-literal">True</span>,
    return_offsets_mapping=<span class="hljs-literal">True</span>,
)
inputs.keys()`}}),An=new P({props:{code:"dict_keys(['input_ids', 'token_type_ids', 'attention_mask', 'offset_mapping', 'overflow_to_sample_mapping'])",highlighted:'dict_keys([<span class="hljs-string">&#x27;input_ids&#x27;</span>, <span class="hljs-string">&#x27;token_type_ids&#x27;</span>, <span class="hljs-string">&#x27;attention_mask&#x27;</span>, <span class="hljs-string">&#x27;offset_mapping&#x27;</span>, <span class="hljs-string">&#x27;overflow_to_sample_mapping&#x27;</span>])'}}),Pn=new P({props:{code:'inputs["overflow_to_sample_mapping"]',highlighted:'inputs[<span class="hljs-string">&quot;overflow_to_sample_mapping&quot;</span>]'}}),Sn=new P({props:{code:"[0, 0, 0, 0]",highlighted:'[<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>]'}}),On=new P({props:{code:`inputs = tokenizer(
    raw_datasets["train"][2:6]["question"],
    raw_datasets["train"][2:6]["context"],
    max_length=100,
    truncation="only_second",
    stride=50,
    return_overflowing_tokens=True,
    return_offsets_mapping=True,
)

print(f"The 4 examples gave {len(inputs['input_ids'])} features.")
print(f"Here is where each comes from: {inputs['overflow_to_sample_mapping']}.")`,highlighted:`inputs = tokenizer(
    raw_datasets[<span class="hljs-string">&quot;train&quot;</span>][<span class="hljs-number">2</span>:<span class="hljs-number">6</span>][<span class="hljs-string">&quot;question&quot;</span>],
    raw_datasets[<span class="hljs-string">&quot;train&quot;</span>][<span class="hljs-number">2</span>:<span class="hljs-number">6</span>][<span class="hljs-string">&quot;context&quot;</span>],
    max_length=<span class="hljs-number">100</span>,
    truncation=<span class="hljs-string">&quot;only_second&quot;</span>,
    stride=<span class="hljs-number">50</span>,
    return_overflowing_tokens=<span class="hljs-literal">True</span>,
    return_offsets_mapping=<span class="hljs-literal">True</span>,
)

<span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;The 4 examples gave <span class="hljs-subst">{<span class="hljs-built_in">len</span>(inputs[<span class="hljs-string">&#x27;input_ids&#x27;</span>])}</span> features.&quot;</span>)
<span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;Here is where each comes from: <span class="hljs-subst">{inputs[<span class="hljs-string">&#x27;overflow_to_sample_mapping&#x27;</span>]}</span>.&quot;</span>)`}}),Mn=new P({props:{code:`'The 4 examples gave 19 features.'
'Here is where each comes from: [0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3].'`,highlighted:`<span class="hljs-string">&#x27;The 4 examples gave 19 features.&#x27;</span>
<span class="hljs-string">&#x27;Here is where each comes from: [0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3].&#x27;</span>`}}),Bn=new P({props:{code:`answers = raw_datasets["train"][2:6]["answers"]
start_positions = []
end_positions = []

for i, offset in enumerate(inputs["offset_mapping"]):
    sample_idx = inputs["overflow_to_sample_mapping"][i]
    answer = answers[sample_idx]
    start_char = answer["answer_start"][0]
    end_char = answer["answer_start"][0] + len(answer["text"][0])
    sequence_ids = inputs.sequence_ids(i)

    # Find the start and end of the context
    idx = 0
    while sequence_ids[idx] != 1:
        idx += 1
    context_start = idx
    while sequence_ids[idx] == 1:
        idx += 1
    context_end = idx - 1

    # If the answer is not fully inside the context, label is (0, 0)
    if offset[context_start][0] > start_char or offset[context_end][1] < end_char:
        start_positions.append(0)
        end_positions.append(0)
    else:
        # Otherwise it's the start and end token positions
        idx = context_start
        while idx <= context_end and offset[idx][0] <= start_char:
            idx += 1
        start_positions.append(idx - 1)

        idx = context_end
        while idx >= context_start and offset[idx][1] >= end_char:
            idx -= 1
        end_positions.append(idx + 1)

start_positions, end_positions`,highlighted:`answers = raw_datasets[<span class="hljs-string">&quot;train&quot;</span>][<span class="hljs-number">2</span>:<span class="hljs-number">6</span>][<span class="hljs-string">&quot;answers&quot;</span>]
start_positions = []
end_positions = []

<span class="hljs-keyword">for</span> i, offset <span class="hljs-keyword">in</span> <span class="hljs-built_in">enumerate</span>(inputs[<span class="hljs-string">&quot;offset_mapping&quot;</span>]):
    sample_idx = inputs[<span class="hljs-string">&quot;overflow_to_sample_mapping&quot;</span>][i]
    answer = answers[sample_idx]
    start_char = answer[<span class="hljs-string">&quot;answer_start&quot;</span>][<span class="hljs-number">0</span>]
    end_char = answer[<span class="hljs-string">&quot;answer_start&quot;</span>][<span class="hljs-number">0</span>] + <span class="hljs-built_in">len</span>(answer[<span class="hljs-string">&quot;text&quot;</span>][<span class="hljs-number">0</span>])
    sequence_ids = inputs.sequence_ids(i)

    <span class="hljs-comment"># Find the start and end of the context</span>
    idx = <span class="hljs-number">0</span>
    <span class="hljs-keyword">while</span> sequence_ids[idx] != <span class="hljs-number">1</span>:
        idx += <span class="hljs-number">1</span>
    context_start = idx
    <span class="hljs-keyword">while</span> sequence_ids[idx] == <span class="hljs-number">1</span>:
        idx += <span class="hljs-number">1</span>
    context_end = idx - <span class="hljs-number">1</span>

    <span class="hljs-comment"># If the answer is not fully inside the context, label is (0, 0)</span>
    <span class="hljs-keyword">if</span> offset[context_start][<span class="hljs-number">0</span>] &gt; start_char <span class="hljs-keyword">or</span> offset[context_end][<span class="hljs-number">1</span>] &lt; end_char:
        start_positions.append(<span class="hljs-number">0</span>)
        end_positions.append(<span class="hljs-number">0</span>)
    <span class="hljs-keyword">else</span>:
        <span class="hljs-comment"># Otherwise it&#x27;s the start and end token positions</span>
        idx = context_start
        <span class="hljs-keyword">while</span> idx &lt;= context_end <span class="hljs-keyword">and</span> offset[idx][<span class="hljs-number">0</span>] &lt;= start_char:
            idx += <span class="hljs-number">1</span>
        start_positions.append(idx - <span class="hljs-number">1</span>)

        idx = context_end
        <span class="hljs-keyword">while</span> idx &gt;= context_start <span class="hljs-keyword">and</span> offset[idx][<span class="hljs-number">1</span>] &gt;= end_char:
            idx -= <span class="hljs-number">1</span>
        end_positions.append(idx + <span class="hljs-number">1</span>)

start_positions, end_positions`}}),In=new P({props:{code:`([83, 51, 19, 0, 0, 64, 27, 0, 34, 0, 0, 0, 67, 34, 0, 0, 0, 0, 0],
 [85, 53, 21, 0, 0, 70, 33, 0, 40, 0, 0, 0, 68, 35, 0, 0, 0, 0, 0])`,highlighted:`([<span class="hljs-number">83</span>, <span class="hljs-number">51</span>, <span class="hljs-number">19</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">64</span>, <span class="hljs-number">27</span>, <span class="hljs-number">0</span>, <span class="hljs-number">34</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">67</span>, <span class="hljs-number">34</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>],
 [<span class="hljs-number">85</span>, <span class="hljs-number">53</span>, <span class="hljs-number">21</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">70</span>, <span class="hljs-number">33</span>, <span class="hljs-number">0</span>, <span class="hljs-number">40</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">68</span>, <span class="hljs-number">35</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>])`}}),Fn=new P({props:{code:`idx = 0
sample_idx = inputs["overflow_to_sample_mapping"][idx]
answer = answers[sample_idx]["text"][0]

start = start_positions[idx]
end = end_positions[idx]
labeled_answer = tokenizer.decode(inputs["input_ids"][idx][start : end + 1])

print(f"Theoretical answer: {answer}, labels give: {labeled_answer}")`,highlighted:`idx = <span class="hljs-number">0</span>
sample_idx = inputs[<span class="hljs-string">&quot;overflow_to_sample_mapping&quot;</span>][idx]
answer = answers[sample_idx][<span class="hljs-string">&quot;text&quot;</span>][<span class="hljs-number">0</span>]

start = start_positions[idx]
end = end_positions[idx]
labeled_answer = tokenizer.decode(inputs[<span class="hljs-string">&quot;input_ids&quot;</span>][idx][start : end + <span class="hljs-number">1</span>])

<span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;Theoretical answer: <span class="hljs-subst">{answer}</span>, labels give: <span class="hljs-subst">{labeled_answer}</span>&quot;</span>)`}}),Ln=new P({props:{code:"'Theoretical answer: the Main Building, labels give: the Main Building'",highlighted:'<span class="hljs-string">&#x27;Theoretical answer: the Main Building, labels give: the Main Building&#x27;</span>'}}),zn=new P({props:{code:`idx = 4
sample_idx = inputs["overflow_to_sample_mapping"][idx]
answer = answers[sample_idx]["text"][0]

decoded_example = tokenizer.decode(inputs["input_ids"][idx])
print(f"Theoretical answer: {answer}, decoded example: {decoded_example}")`,highlighted:`idx = <span class="hljs-number">4</span>
sample_idx = inputs[<span class="hljs-string">&quot;overflow_to_sample_mapping&quot;</span>][idx]
answer = answers[sample_idx][<span class="hljs-string">&quot;text&quot;</span>][<span class="hljs-number">0</span>]

decoded_example = tokenizer.decode(inputs[<span class="hljs-string">&quot;input_ids&quot;</span>][idx])
<span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;Theoretical answer: <span class="hljs-subst">{answer}</span>, decoded example: <span class="hljs-subst">{decoded_example}</span>&quot;</span>)`}}),Nn=new P({props:{code:`'Theoretical answer: a Marian place of prayer and reflection, decoded example: [CLS] What is the Grotto at Notre Dame? [SEP] Architecturally, the school has a Catholic character. Atop the Main Building\\'s gold dome is a golden statue of the Virgin Mary. Immediately in front of the Main Building and facing it, is a copper statue of Christ with arms upraised with the legend " Venite Ad Me Omnes ". Next to the Main Building is the Basilica of the Sacred Heart. Immediately behind the basilica is the Grot [SEP]'`,highlighted:'<span class="hljs-string">&#x27;Theoretical answer: a Marian place of prayer and reflection, decoded example: [CLS] What is the Grotto at Notre Dame? [SEP] Architecturally, the school has a Catholic character. Atop the Main Building\\&#x27;s gold dome is a golden statue of the Virgin Mary. Immediately in front of the Main Building and facing it, is a copper statue of Christ with arms upraised with the legend &quot; Venite Ad Me Omnes &quot;. Next to the Main Building is the Basilica of the Sacred Heart. Immediately behind the basilica is the Grot [SEP]&#x27;</span>'}}),La=new Mp({props:{$$slots:{default:[W_]},$$scope:{ctx:H}}}),Hn=new P({props:{code:`max_length = 384
stride = 128


def preprocess_training_examples(examples):
    questions = [q.strip() for q in examples["question"]]
    inputs = tokenizer(
        questions,
        examples["context"],
        max_length=max_length,
        truncation="only_second",
        stride=stride,
        return_overflowing_tokens=True,
        return_offsets_mapping=True,
        padding="max_length",
    )

    offset_mapping = inputs.pop("offset_mapping")
    sample_map = inputs.pop("overflow_to_sample_mapping")
    answers = examples["answers"]
    start_positions = []
    end_positions = []

    for i, offset in enumerate(offset_mapping):
        sample_idx = sample_map[i]
        answer = answers[sample_idx]
        start_char = answer["answer_start"][0]
        end_char = answer["answer_start"][0] + len(answer["text"][0])
        sequence_ids = inputs.sequence_ids(i)

        # Find the start and end of the context
        idx = 0
        while sequence_ids[idx] != 1:
            idx += 1
        context_start = idx
        while sequence_ids[idx] == 1:
            idx += 1
        context_end = idx - 1

        # If the answer is not fully inside the context, label is (0, 0)
        if offset[context_start][0] > start_char or offset[context_end][1] < end_char:
            start_positions.append(0)
            end_positions.append(0)
        else:
            # Otherwise it's the start and end token positions
            idx = context_start
            while idx <= context_end and offset[idx][0] <= start_char:
                idx += 1
            start_positions.append(idx - 1)

            idx = context_end
            while idx >= context_start and offset[idx][1] >= end_char:
                idx -= 1
            end_positions.append(idx + 1)

    inputs["start_positions"] = start_positions
    inputs["end_positions"] = end_positions
    return inputs`,highlighted:`max_length = <span class="hljs-number">384</span>
stride = <span class="hljs-number">128</span>


<span class="hljs-keyword">def</span> <span class="hljs-title function_">preprocess_training_examples</span>(<span class="hljs-params">examples</span>):
    questions = [q.strip() <span class="hljs-keyword">for</span> q <span class="hljs-keyword">in</span> examples[<span class="hljs-string">&quot;question&quot;</span>]]
    inputs = tokenizer(
        questions,
        examples[<span class="hljs-string">&quot;context&quot;</span>],
        max_length=max_length,
        truncation=<span class="hljs-string">&quot;only_second&quot;</span>,
        stride=stride,
        return_overflowing_tokens=<span class="hljs-literal">True</span>,
        return_offsets_mapping=<span class="hljs-literal">True</span>,
        padding=<span class="hljs-string">&quot;max_length&quot;</span>,
    )

    offset_mapping = inputs.pop(<span class="hljs-string">&quot;offset_mapping&quot;</span>)
    sample_map = inputs.pop(<span class="hljs-string">&quot;overflow_to_sample_mapping&quot;</span>)
    answers = examples[<span class="hljs-string">&quot;answers&quot;</span>]
    start_positions = []
    end_positions = []

    <span class="hljs-keyword">for</span> i, offset <span class="hljs-keyword">in</span> <span class="hljs-built_in">enumerate</span>(offset_mapping):
        sample_idx = sample_map[i]
        answer = answers[sample_idx]
        start_char = answer[<span class="hljs-string">&quot;answer_start&quot;</span>][<span class="hljs-number">0</span>]
        end_char = answer[<span class="hljs-string">&quot;answer_start&quot;</span>][<span class="hljs-number">0</span>] + <span class="hljs-built_in">len</span>(answer[<span class="hljs-string">&quot;text&quot;</span>][<span class="hljs-number">0</span>])
        sequence_ids = inputs.sequence_ids(i)

        <span class="hljs-comment"># Find the start and end of the context</span>
        idx = <span class="hljs-number">0</span>
        <span class="hljs-keyword">while</span> sequence_ids[idx] != <span class="hljs-number">1</span>:
            idx += <span class="hljs-number">1</span>
        context_start = idx
        <span class="hljs-keyword">while</span> sequence_ids[idx] == <span class="hljs-number">1</span>:
            idx += <span class="hljs-number">1</span>
        context_end = idx - <span class="hljs-number">1</span>

        <span class="hljs-comment"># If the answer is not fully inside the context, label is (0, 0)</span>
        <span class="hljs-keyword">if</span> offset[context_start][<span class="hljs-number">0</span>] &gt; start_char <span class="hljs-keyword">or</span> offset[context_end][<span class="hljs-number">1</span>] &lt; end_char:
            start_positions.append(<span class="hljs-number">0</span>)
            end_positions.append(<span class="hljs-number">0</span>)
        <span class="hljs-keyword">else</span>:
            <span class="hljs-comment"># Otherwise it&#x27;s the start and end token positions</span>
            idx = context_start
            <span class="hljs-keyword">while</span> idx &lt;= context_end <span class="hljs-keyword">and</span> offset[idx][<span class="hljs-number">0</span>] &lt;= start_char:
                idx += <span class="hljs-number">1</span>
            start_positions.append(idx - <span class="hljs-number">1</span>)

            idx = context_end
            <span class="hljs-keyword">while</span> idx &gt;= context_start <span class="hljs-keyword">and</span> offset[idx][<span class="hljs-number">1</span>] &gt;= end_char:
                idx -= <span class="hljs-number">1</span>
            end_positions.append(idx + <span class="hljs-number">1</span>)

    inputs[<span class="hljs-string">&quot;start_positions&quot;</span>] = start_positions
    inputs[<span class="hljs-string">&quot;end_positions&quot;</span>] = end_positions
    <span class="hljs-keyword">return</span> inputs`}}),Vn=new P({props:{code:`train_dataset = raw_datasets["train"].map(
    preprocess_training_examples,
    batched=True,
    remove_columns=raw_datasets["train"].column_names,
)
len(raw_datasets["train"]), len(train_dataset)`,highlighted:`train_dataset = raw_datasets[<span class="hljs-string">&quot;train&quot;</span>].<span class="hljs-built_in">map</span>(
    preprocess_training_examples,
    batched=<span class="hljs-literal">True</span>,
    remove_columns=raw_datasets[<span class="hljs-string">&quot;train&quot;</span>].column_names,
)
<span class="hljs-built_in">len</span>(raw_datasets[<span class="hljs-string">&quot;train&quot;</span>]), <span class="hljs-built_in">len</span>(train_dataset)`}}),Qn=new P({props:{code:"(87599, 88729)",highlighted:'(<span class="hljs-number">87599</span>, <span class="hljs-number">88729</span>)'}}),Gn=new P({props:{code:`def preprocess_validation_examples(examples):
    questions = [q.strip() for q in examples["question"]]
    inputs = tokenizer(
        questions,
        examples["context"],
        max_length=max_length,
        truncation="only_second",
        stride=stride,
        return_overflowing_tokens=True,
        return_offsets_mapping=True,
        padding="max_length",
    )

    sample_map = inputs.pop("overflow_to_sample_mapping")
    example_ids = []

    for i in range(len(inputs["input_ids"])):
        sample_idx = sample_map[i]
        example_ids.append(examples["id"][sample_idx])

        sequence_ids = inputs.sequence_ids(i)
        offset = inputs["offset_mapping"][i]
        inputs["offset_mapping"][i] = [
            o if sequence_ids[k] == 1 else None for k, o in enumerate(offset)
        ]

    inputs["example_id"] = example_ids
    return inputs`,highlighted:`<span class="hljs-keyword">def</span> <span class="hljs-title function_">preprocess_validation_examples</span>(<span class="hljs-params">examples</span>):
    questions = [q.strip() <span class="hljs-keyword">for</span> q <span class="hljs-keyword">in</span> examples[<span class="hljs-string">&quot;question&quot;</span>]]
    inputs = tokenizer(
        questions,
        examples[<span class="hljs-string">&quot;context&quot;</span>],
        max_length=max_length,
        truncation=<span class="hljs-string">&quot;only_second&quot;</span>,
        stride=stride,
        return_overflowing_tokens=<span class="hljs-literal">True</span>,
        return_offsets_mapping=<span class="hljs-literal">True</span>,
        padding=<span class="hljs-string">&quot;max_length&quot;</span>,
    )

    sample_map = inputs.pop(<span class="hljs-string">&quot;overflow_to_sample_mapping&quot;</span>)
    example_ids = []

    <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(<span class="hljs-built_in">len</span>(inputs[<span class="hljs-string">&quot;input_ids&quot;</span>])):
        sample_idx = sample_map[i]
        example_ids.append(examples[<span class="hljs-string">&quot;id&quot;</span>][sample_idx])

        sequence_ids = inputs.sequence_ids(i)
        offset = inputs[<span class="hljs-string">&quot;offset_mapping&quot;</span>][i]
        inputs[<span class="hljs-string">&quot;offset_mapping&quot;</span>][i] = [
            o <span class="hljs-keyword">if</span> sequence_ids[k] == <span class="hljs-number">1</span> <span class="hljs-keyword">else</span> <span class="hljs-literal">None</span> <span class="hljs-keyword">for</span> k, o <span class="hljs-keyword">in</span> <span class="hljs-built_in">enumerate</span>(offset)
        ]

    inputs[<span class="hljs-string">&quot;example_id&quot;</span>] = example_ids
    <span class="hljs-keyword">return</span> inputs`}}),Wn=new P({props:{code:`validation_dataset = raw_datasets["validation"].map(
    preprocess_validation_examples,
    batched=True,
    remove_columns=raw_datasets["validation"].column_names,
)
len(raw_datasets["validation"]), len(validation_dataset)`,highlighted:`validation_dataset = raw_datasets[<span class="hljs-string">&quot;validation&quot;</span>].<span class="hljs-built_in">map</span>(
    preprocess_validation_examples,
    batched=<span class="hljs-literal">True</span>,
    remove_columns=raw_datasets[<span class="hljs-string">&quot;validation&quot;</span>].column_names,
)
<span class="hljs-built_in">len</span>(raw_datasets[<span class="hljs-string">&quot;validation&quot;</span>]), <span class="hljs-built_in">len</span>(validation_dataset)`}}),Un=new P({props:{code:"(10570, 10822)",highlighted:'(<span class="hljs-number">10570</span>, <span class="hljs-number">10822</span>)'}});const wf=[J_,U_],xl=[];function gf(e,r){return e[0]==="pt"?0:1}Bs=gf(H),Is=xl[Bs]=wf[Bs](H);const $f=[K_,X_],jl=[];function bf(e,r){return e[0]==="pt"?0:1}Fs=bf(H),Ls=jl[Fs]=$f[Fs](H),Yn=new P({props:{code:`small_eval_set = raw_datasets["validation"].select(range(100))
trained_checkpoint = "distilbert-base-cased-distilled-squad"

tokenizer = AutoTokenizer.from_pretrained(trained_checkpoint)
eval_set = small_eval_set.map(
    preprocess_validation_examples,
    batched=True,
    remove_columns=raw_datasets["validation"].column_names,
)`,highlighted:`small_eval_set = raw_datasets[<span class="hljs-string">&quot;validation&quot;</span>].select(<span class="hljs-built_in">range</span>(<span class="hljs-number">100</span>))
trained_checkpoint = <span class="hljs-string">&quot;distilbert-base-cased-distilled-squad&quot;</span>

tokenizer = AutoTokenizer.from_pretrained(trained_checkpoint)
eval_set = small_eval_set.<span class="hljs-built_in">map</span>(
    preprocess_validation_examples,
    batched=<span class="hljs-literal">True</span>,
    remove_columns=raw_datasets[<span class="hljs-string">&quot;validation&quot;</span>].column_names,
)`}}),Zn=new P({props:{code:"tokenizer = AutoTokenizer.from_pretrained(model_checkpoint)",highlighted:"tokenizer = AutoTokenizer.from_pretrained(model_checkpoint)"}});const xf=[Z_,Y_],vl=[];function jf(e,r){return e[0]==="pt"?0:1}zs=jf(H),Ns=vl[zs]=xf[zs](H),el=new P({props:{code:`import collections

example_to_features = collections.defaultdict(list)
for idx, feature in enumerate(eval_set):
    example_to_features[feature["example_id"]].append(idx)`,highlighted:`<span class="hljs-keyword">import</span> collections

example_to_features = collections.defaultdict(<span class="hljs-built_in">list</span>)
<span class="hljs-keyword">for</span> idx, feature <span class="hljs-keyword">in</span> <span class="hljs-built_in">enumerate</span>(eval_set):
    example_to_features[feature[<span class="hljs-string">&quot;example_id&quot;</span>]].append(idx)`}}),tl=new P({props:{code:`import numpy as np

n_best = 20
max_answer_length = 30
predicted_answers = []

for example in small_eval_set:
    example_id = example["id"]
    context = example["context"]
    answers = []

    for feature_index in example_to_features[example_id]:
        start_logit = start_logits[feature_index]
        end_logit = end_logits[feature_index]
        offsets = eval_set["offset_mapping"][feature_index]

        start_indexes = np.argsort(start_logit)[-1 : -n_best - 1 : -1].tolist()
        end_indexes = np.argsort(end_logit)[-1 : -n_best - 1 : -1].tolist()
        for start_index in start_indexes:
            for end_index in end_indexes:
                # Skip answers that are not fully in the context
                if offsets[start_index] is None or offsets[end_index] is None:
                    continue
                # Skip answers with a length that is either < 0 or > max_answer_length.
                if (
                    end_index < start_index
                    or end_index - start_index + 1 > max_answer_length
                ):
                    continue

                answers.append(
                    {
                        "text": context[offsets[start_index][0] : offsets[end_index][1]],
                        "logit_score": start_logit[start_index] + end_logit[end_index],
                    }
                )

    best_answer = max(answers, key=lambda x: x["logit_score"])
    predicted_answers.append({"id": example_id, "prediction_text": best_answer["text"]})`,highlighted:`<span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np

n_best = <span class="hljs-number">20</span>
max_answer_length = <span class="hljs-number">30</span>
predicted_answers = []

<span class="hljs-keyword">for</span> example <span class="hljs-keyword">in</span> small_eval_set:
    example_id = example[<span class="hljs-string">&quot;id&quot;</span>]
    context = example[<span class="hljs-string">&quot;context&quot;</span>]
    answers = []

    <span class="hljs-keyword">for</span> feature_index <span class="hljs-keyword">in</span> example_to_features[example_id]:
        start_logit = start_logits[feature_index]
        end_logit = end_logits[feature_index]
        offsets = eval_set[<span class="hljs-string">&quot;offset_mapping&quot;</span>][feature_index]

        start_indexes = np.argsort(start_logit)[-<span class="hljs-number">1</span> : -n_best - <span class="hljs-number">1</span> : -<span class="hljs-number">1</span>].tolist()
        end_indexes = np.argsort(end_logit)[-<span class="hljs-number">1</span> : -n_best - <span class="hljs-number">1</span> : -<span class="hljs-number">1</span>].tolist()
        <span class="hljs-keyword">for</span> start_index <span class="hljs-keyword">in</span> start_indexes:
            <span class="hljs-keyword">for</span> end_index <span class="hljs-keyword">in</span> end_indexes:
                <span class="hljs-comment"># Skip answers that are not fully in the context</span>
                <span class="hljs-keyword">if</span> offsets[start_index] <span class="hljs-keyword">is</span> <span class="hljs-literal">None</span> <span class="hljs-keyword">or</span> offsets[end_index] <span class="hljs-keyword">is</span> <span class="hljs-literal">None</span>:
                    <span class="hljs-keyword">continue</span>
                <span class="hljs-comment"># Skip answers with a length that is either &lt; 0 or &gt; max_answer_length.</span>
                <span class="hljs-keyword">if</span> (
                    end_index &lt; start_index
                    <span class="hljs-keyword">or</span> end_index - start_index + <span class="hljs-number">1</span> &gt; max_answer_length
                ):
                    <span class="hljs-keyword">continue</span>

                answers.append(
                    {
                        <span class="hljs-string">&quot;text&quot;</span>: context[offsets[start_index][<span class="hljs-number">0</span>] : offsets[end_index][<span class="hljs-number">1</span>]],
                        <span class="hljs-string">&quot;logit_score&quot;</span>: start_logit[start_index] + end_logit[end_index],
                    }
                )

    best_answer = <span class="hljs-built_in">max</span>(answers, key=<span class="hljs-keyword">lambda</span> x: x[<span class="hljs-string">&quot;logit_score&quot;</span>])
    predicted_answers.append({<span class="hljs-string">&quot;id&quot;</span>: example_id, <span class="hljs-string">&quot;prediction_text&quot;</span>: best_answer[<span class="hljs-string">&quot;text&quot;</span>]})`}}),al=new P({props:{code:`from datasets import load_metric

metric = load_metric("squad")`,highlighted:`<span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_metric

metric = load_metric(<span class="hljs-string">&quot;squad&quot;</span>)`}}),nl=new P({props:{code:`theoretical_answers = [
    {"id": ex["id"], "answers": ex["answers"]} for ex in small_eval_set
]`,highlighted:`theoretical_answers = [
    {<span class="hljs-string">&quot;id&quot;</span>: ex[<span class="hljs-string">&quot;id&quot;</span>], <span class="hljs-string">&quot;answers&quot;</span>: ex[<span class="hljs-string">&quot;answers&quot;</span>]} <span class="hljs-keyword">for</span> ex <span class="hljs-keyword">in</span> small_eval_set
]`}}),ll=new P({props:{code:`print(predicted_answers[0])
print(theoretical_answers[0])`,highlighted:`<span class="hljs-built_in">print</span>(predicted_answers[<span class="hljs-number">0</span>])
<span class="hljs-built_in">print</span>(theoretical_answers[<span class="hljs-number">0</span>])`}}),rl=new P({props:{code:`{'id': '56be4db0acb8001400a502ec', 'prediction_text': 'Denver Broncos'}
{'id': '56be4db0acb8001400a502ec', 'answers': {'text': ['Denver Broncos', 'Denver Broncos', 'Denver Broncos'], 'answer_start': [177, 177, 177]}}`,highlighted:`{<span class="hljs-string">&#x27;id&#x27;</span>: <span class="hljs-string">&#x27;56be4db0acb8001400a502ec&#x27;</span>, <span class="hljs-string">&#x27;prediction_text&#x27;</span>: <span class="hljs-string">&#x27;Denver Broncos&#x27;</span>}
{<span class="hljs-string">&#x27;id&#x27;</span>: <span class="hljs-string">&#x27;56be4db0acb8001400a502ec&#x27;</span>, <span class="hljs-string">&#x27;answers&#x27;</span>: {<span class="hljs-string">&#x27;text&#x27;</span>: [<span class="hljs-string">&#x27;Denver Broncos&#x27;</span>, <span class="hljs-string">&#x27;Denver Broncos&#x27;</span>, <span class="hljs-string">&#x27;Denver Broncos&#x27;</span>], <span class="hljs-string">&#x27;answer_start&#x27;</span>: [<span class="hljs-number">177</span>, <span class="hljs-number">177</span>, <span class="hljs-number">177</span>]}}`}}),ol=new P({props:{code:"metric.compute(predictions=predicted_answers, references=theoretical_answers)",highlighted:"metric.compute(predictions=predicted_answers, references=theoretical_answers)"}}),il=new P({props:{code:"{'exact_match': 83.0, 'f1': 88.25}",highlighted:'{<span class="hljs-string">&#x27;exact_match&#x27;</span>: <span class="hljs-number">83.0</span>, <span class="hljs-string">&#x27;f1&#x27;</span>: <span class="hljs-number">88.25</span>}'}});function vf(e,r){return e[0]==="pt"?sm:em}let wp=vf(H),ea=wp(H);cl=new P({props:{code:`from tqdm.auto import tqdm


def compute_metrics(start_logits, end_logits, features, examples):
    example_to_features = collections.defaultdict(list)
    for idx, feature in enumerate(features):
        example_to_features[feature["example_id"]].append(idx)

    predicted_answers = []
    for example in tqdm(examples):
        example_id = example["id"]
        context = example["context"]
        answers = []

        # Loop through all features associated with that example
        for feature_index in example_to_features[example_id]:
            start_logit = start_logits[feature_index]
            end_logit = end_logits[feature_index]
            offsets = features[feature_index]["offset_mapping"]

            start_indexes = np.argsort(start_logit)[-1 : -n_best - 1 : -1].tolist()
            end_indexes = np.argsort(end_logit)[-1 : -n_best - 1 : -1].tolist()
            for start_index in start_indexes:
                for end_index in end_indexes:
                    # Skip answers that are not fully in the context
                    if offsets[start_index] is None or offsets[end_index] is None:
                        continue
                    # Skip answers with a length that is either < 0 or > max_answer_length
                    if (
                        end_index < start_index
                        or end_index - start_index + 1 > max_answer_length
                    ):
                        continue

                    answer = {
                        "text": context[offsets[start_index][0] : offsets[end_index][1]],
                        "logit_score": start_logit[start_index] + end_logit[end_index],
                    }
                    answers.append(answer)

        # Select the answer with the best score
        if len(answers) > 0:
            best_answer = max(answers, key=lambda x: x["logit_score"])
            predicted_answers.append(
                {"id": example_id, "prediction_text": best_answer["text"]}
            )
        else:
            predicted_answers.append({"id": example_id, "prediction_text": ""})

    theoretical_answers = [{"id": ex["id"], "answers": ex["answers"]} for ex in examples]
    return metric.compute(predictions=predicted_answers, references=theoretical_answers)`,highlighted:`<span class="hljs-keyword">from</span> tqdm.auto <span class="hljs-keyword">import</span> tqdm


<span class="hljs-keyword">def</span> <span class="hljs-title function_">compute_metrics</span>(<span class="hljs-params">start_logits, end_logits, features, examples</span>):
    example_to_features = collections.defaultdict(<span class="hljs-built_in">list</span>)
    <span class="hljs-keyword">for</span> idx, feature <span class="hljs-keyword">in</span> <span class="hljs-built_in">enumerate</span>(features):
        example_to_features[feature[<span class="hljs-string">&quot;example_id&quot;</span>]].append(idx)

    predicted_answers = []
    <span class="hljs-keyword">for</span> example <span class="hljs-keyword">in</span> tqdm(examples):
        example_id = example[<span class="hljs-string">&quot;id&quot;</span>]
        context = example[<span class="hljs-string">&quot;context&quot;</span>]
        answers = []

        <span class="hljs-comment"># Loop through all features associated with that example</span>
        <span class="hljs-keyword">for</span> feature_index <span class="hljs-keyword">in</span> example_to_features[example_id]:
            start_logit = start_logits[feature_index]
            end_logit = end_logits[feature_index]
            offsets = features[feature_index][<span class="hljs-string">&quot;offset_mapping&quot;</span>]

            start_indexes = np.argsort(start_logit)[-<span class="hljs-number">1</span> : -n_best - <span class="hljs-number">1</span> : -<span class="hljs-number">1</span>].tolist()
            end_indexes = np.argsort(end_logit)[-<span class="hljs-number">1</span> : -n_best - <span class="hljs-number">1</span> : -<span class="hljs-number">1</span>].tolist()
            <span class="hljs-keyword">for</span> start_index <span class="hljs-keyword">in</span> start_indexes:
                <span class="hljs-keyword">for</span> end_index <span class="hljs-keyword">in</span> end_indexes:
                    <span class="hljs-comment"># Skip answers that are not fully in the context</span>
                    <span class="hljs-keyword">if</span> offsets[start_index] <span class="hljs-keyword">is</span> <span class="hljs-literal">None</span> <span class="hljs-keyword">or</span> offsets[end_index] <span class="hljs-keyword">is</span> <span class="hljs-literal">None</span>:
                        <span class="hljs-keyword">continue</span>
                    <span class="hljs-comment"># Skip answers with a length that is either &lt; 0 or &gt; max_answer_length</span>
                    <span class="hljs-keyword">if</span> (
                        end_index &lt; start_index
                        <span class="hljs-keyword">or</span> end_index - start_index + <span class="hljs-number">1</span> &gt; max_answer_length
                    ):
                        <span class="hljs-keyword">continue</span>

                    answer = {
                        <span class="hljs-string">&quot;text&quot;</span>: context[offsets[start_index][<span class="hljs-number">0</span>] : offsets[end_index][<span class="hljs-number">1</span>]],
                        <span class="hljs-string">&quot;logit_score&quot;</span>: start_logit[start_index] + end_logit[end_index],
                    }
                    answers.append(answer)

        <span class="hljs-comment"># Select the answer with the best score</span>
        <span class="hljs-keyword">if</span> <span class="hljs-built_in">len</span>(answers) &gt; <span class="hljs-number">0</span>:
            best_answer = <span class="hljs-built_in">max</span>(answers, key=<span class="hljs-keyword">lambda</span> x: x[<span class="hljs-string">&quot;logit_score&quot;</span>])
            predicted_answers.append(
                {<span class="hljs-string">&quot;id&quot;</span>: example_id, <span class="hljs-string">&quot;prediction_text&quot;</span>: best_answer[<span class="hljs-string">&quot;text&quot;</span>]}
            )
        <span class="hljs-keyword">else</span>:
            predicted_answers.append({<span class="hljs-string">&quot;id&quot;</span>: example_id, <span class="hljs-string">&quot;prediction_text&quot;</span>: <span class="hljs-string">&quot;&quot;</span>})

    theoretical_answers = [{<span class="hljs-string">&quot;id&quot;</span>: ex[<span class="hljs-string">&quot;id&quot;</span>], <span class="hljs-string">&quot;answers&quot;</span>: ex[<span class="hljs-string">&quot;answers&quot;</span>]} <span class="hljs-keyword">for</span> ex <span class="hljs-keyword">in</span> examples]
    <span class="hljs-keyword">return</span> metric.compute(predictions=predicted_answers, references=theoretical_answers)`}}),dl=new P({props:{code:"compute_metrics(start_logits, end_logits, eval_set, small_eval_set)",highlighted:"compute_metrics(start_logits, end_logits, eval_set, small_eval_set)"}}),fl=new P({props:{code:"{'exact_match': 83.0, 'f1': 88.25}",highlighted:'{<span class="hljs-string">&#x27;exact_match&#x27;</span>: <span class="hljs-number">83.0</span>, <span class="hljs-string">&#x27;f1&#x27;</span>: <span class="hljs-number">88.25</span>}'}});const kf=[am,tm],kl=[];function qf(e,r){return e[0]==="pt"?0:1}Hs=qf(H),Vs=kl[Hs]=kf[Hs](H),_l=new P({props:{code:`from huggingface_hub import notebook_login

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

notebook_login()`}}),ml=new P({props:{code:"huggingface-cli login",highlighted:"huggingface-cli login"}});const Ef=[lm,nm],ql=[];function yf(e,r){return e[0]==="pt"?0:1}Qs=yf(H),Rs=ql[Qs]=Ef[Qs](H);const Df=[om,rm],El=[];function Cf(e,r){return e[0]==="pt"?0:1}Gs=Cf(H),Ws=El[Gs]=Df[Gs](H);const Tf=[cm,pm],yl=[];function Af(e,r){return e[0]==="pt"?0:1}Us=Af(H),Js=yl[Us]=Tf[Us](H),hl=new P({props:{code:"{'exact_match': 81.18259224219489, 'f1': 88.67381321905516}",highlighted:'{<span class="hljs-string">&#x27;exact_match&#x27;</span>: <span class="hljs-number">81.18259224219489</span>, <span class="hljs-string">&#x27;f1&#x27;</span>: <span class="hljs-number">88.67381321905516</span>}'}});let oe=H[0]==="pt"&&P_();Ra=new Mp({props:{$$slots:{default:[dm]},$$scope:{ctx:H}}});let ie=H[0]==="pt"&&S_();return gl=new P({props:{code:`from transformers import pipeline

# Replace this with your own checkpoint
model_checkpoint = "huggingface-course/bert-finetuned-squad"
question_answerer = pipeline("question-answering", model=model_checkpoint)

context = """
\u{1F917} Transformers is backed by the three most popular deep learning libraries \u2014 Jax, PyTorch and TensorFlow \u2014 with a seamless integration
between them. It's straightforward to train your models with one before loading them for inference with the other.
"""
question = "Which deep learning libraries back \u{1F917} Transformers?"
question_answerer(question=question, context=context)`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

<span class="hljs-comment"># Replace this with your own checkpoint</span>
model_checkpoint = <span class="hljs-string">&quot;huggingface-course/bert-finetuned-squad&quot;</span>
question_answerer = pipeline(<span class="hljs-string">&quot;question-answering&quot;</span>, model=model_checkpoint)

context = <span class="hljs-string">&quot;&quot;&quot;
\u{1F917} Transformers is backed by the three most popular deep learning libraries \u2014 Jax, PyTorch and TensorFlow \u2014 with a seamless integration
between them. It&#x27;s straightforward to train your models with one before loading them for inference with the other.
&quot;&quot;&quot;</span>
question = <span class="hljs-string">&quot;Which deep learning libraries back \u{1F917} Transformers?&quot;</span>
question_answerer(question=question, context=context)`}}),$l=new P({props:{code:`{'score': 0.9979003071784973,
 'start': 78,
 'end': 105,
 'answer': 'Jax, PyTorch and TensorFlow'}`,highlighted:`{<span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.9979003071784973</span>,
 <span class="hljs-string">&#x27;start&#x27;</span>: <span class="hljs-number">78</span>,
 <span class="hljs-string">&#x27;end&#x27;</span>: <span class="hljs-number">105</span>,
 <span class="hljs-string">&#x27;answer&#x27;</span>: <span class="hljs-string">&#x27;Jax, PyTorch and TensorFlow&#x27;</span>}`}}),{c(){c=o("meta"),h=d(),q(_.$$.fragment),v=d(),T=o("h1"),$=a("\u95EE\u7B54"),j=d(),m.c(),S=d(),b=o("p"),k=a("\u662F\u65F6\u5019\u770B\u95EE\u7B54\u4E86! \u8FD9\u9879\u4EFB\u52A1\u6709\u591A\u79CD\u5F62\u5F0F, \u4F46\u6211\u4EEC\u5C06\u5728\u672C\u8282\u4E2D\u5173\u6CE8\u7684\u4E00\u9879\u79F0\u4E3A"),O=o("em"),L=a("\u63D0\u53D6"),M=a("\u7684\u95EE\u7B54\u3002\u95EE\u9898\u7684\u7B54\u6848\u5C31\u5728 "),C=o("em"),Q=a("\u7ED9\u5B9A\u7684\u6587\u6863"),z=a(" \u4E4B\u4E2D\u3002"),A=d(),q(N.$$.fragment),R=d(),G=o("p"),K=a("\u6211\u4EEC\u5C06\u4F7F\u7528 "),W=o("a"),I=a("SQuAD \u6570\u636E\u96C6"),U=a(" \u5FAE\u8C03\u4E00\u4E2ABERT\u6A21\u578B, \u5176\u4E2D\u5305\u62EC\u7FA4\u4F17\u5DE5\u4F5C\u8005\u5BF9\u4E00\u7EC4\u7EF4\u57FA\u767E\u79D1\u6587\u7AE0\u63D0\u51FA\u7684\u95EE\u9898\u3002\u4EE5\u4E0B\u662F\u4E00\u4E2A\u5C0F\u7684\u6D4B\u8BD5\u6837\u4F8B:"),ae=d(),J=o("iframe"),se=d(),Z=o("iframe"),Se=d(),ne=o("p"),Oe=a("\u672C\u8282\u4F7F\u7528\u7684\u4EE3\u7801\u5DF2\u7ECF\u4E0A\u4F20\u5230\u4E86Hub\u3002\u4F60\u53EF\u4EE5\u5728 "),V=o("a"),X=a("\u8FD9\u91CC"),us=a(" \u627E\u5230\u5B83\u5E76\u5C1D\u8BD5\u7528\u5B83\u8FDB\u884C\u9884\u6D4B\u3002"),xe=d(),q(we.$$.fragment),ge=d(),$e=o("h2"),Je=a("\u51C6\u5907\u6570\u636E"),Me=d(),fe=o("p"),Be=a("\u6700\u5E38\u7528\u4F5C\u62BD\u53D6\u5F0F\u95EE\u7B54\u7684\u5B66\u672F\u57FA\u51C6\u7684\u6570\u636E\u96C6\u662F "),ce=o("a"),sa=a("SQuAD"),le=a(", \u6240\u4EE5\u8FD9\u5C31\u662F\u6211\u4EEC\u5C06\u5728\u8FD9\u91CC\u4F7F\u7528\u7684\u3002\u8FD8\u6709\u4E00\u4E2A\u66F4\u96BE\u7684 "),_s=o("a"),At=a("SQuAD v2"),Za=a(" \u57FA\u51C6, \u5176\u4E2D\u5305\u62EC\u6CA1\u6709\u7B54\u6848\u7684\u95EE\u9898\u3002\u53EA\u8981\u4F60\u81EA\u5DF1\u7684\u6570\u636E\u96C6\u5305\u542B\u4E0A\u4E0B\u6587\u5217\u3001\u95EE\u9898\u5217\u548C\u7B54\u6848\u5217, \u4F60\u5C31\u5E94\u8BE5\u80FD\u591F\u8C03\u6574\u4EE5\u4E0B\u6B65\u9AA4\u3002"),ta=d(),je=o("h3"),Xe=o("a"),Pt=o("span"),q(Ie.$$.fragment),en=d(),St=o("span"),Ot=a("SQuAD \u6570\u636E\u96C6"),aa=d(),Ke=o("p"),Mt=a("\u50CF\u5F80\u5E38\u4E00\u6837, \u6211\u4EEC\u53EA\u9700\u4E00\u6B65\u5C31\u53EF\u4EE5\u4E0B\u8F7D\u548C\u7F13\u5B58\u6570\u636E\u96C6, \u8FD9\u8981\u5F52\u529F\u4E8E "),Bt=o("code"),sn=a("load_dataset()"),na=a(":"),Ye=d(),q(Ze.$$.fragment),ve=d(),Xs=o("p"),It=a("\u7136\u540E\u6211\u4EEC\u53EF\u4EE5\u67E5\u770B\u8FD9\u4E2A\u5BF9\u8C61\u4EE5, \u4E86\u89E3\u6709\u5173 SQuAD \u6570\u636E\u96C6\u7684\u66F4\u591A\u4FE1\u606F:"),la=d(),q(ms.$$.fragment),Ks=d(),q(hs.$$.fragment),ra=d(),ue=o("p"),ws=a("\u770B\u8D77\u6765\u6211\u4EEC\u62E5\u6709\u6240\u9700\u7684 "),Ys=o("code"),be=a("context"),tn=a(" \u3001"),gs=o("code"),an=a("question"),nn=a(" \u548C "),$s=o("code"),ln=a("answers"),rn=a(" \u5B57\u6BB5, \u6240\u4EE5\u8BA9\u6211\u4EEC\u6253\u5370\u8BAD\u7EC3\u96C6\u7684\u7B2C\u4E00\u4E2A\u5143\u7D20:"),Zs=d(),q(bs.$$.fragment),oa=d(),q(es.$$.fragment),ss=d(),te=o("p"),Fe=o("code"),ia=a("context"),et=a(" \u548C "),Ft=o("code"),pa=a("question"),xs=a(" \u5B57\u6BB5\u4F7F\u7528\u8D77\u6765\u975E\u5E38\u7B80\u5355\u3002\u4F46\u662F "),st=o("code"),ye=a("answers"),on=a(" \u5B57\u6BB5\u6709\u70B9\u68D8\u624B, \u56E0\u4E3A\u5B83\u5C06\u5B57\u5178\u4E0E\u4E24\u4E2A\u90FD\u662F\u5217\u8868\u7684\u5B57\u6BB5\u7EC4\u6210\u3002\u8FD9\u662F\u5728\u8BC4\u4F30\u8FC7\u7A0B\u4E2D "),js=o("code"),pn=a("squad"),cn=a(" \u6307\u6807\u6240\u671F\u671B\u7684\u683C\u5F0F; \u5982\u679C\u4F60\u4F7F\u7528\u7684\u662F\u81EA\u5DF1\u7684\u6570\u636E, \u5219\u4E0D\u5FC5\u62C5\u5FC3\u5C06\u7B54\u6848\u91C7\u7528\u76F8\u540C\u7684\u683C\u5F0F\u3002"),vs=o("code"),dn=a("text"),fn=a(" \u5B57\u6BB5\u6BD4\u8F83\u660E\u663E, \u800C "),tt=o("code"),ks=a("answer_start"),un=a(" \u5B57\u6BB5\u5305\u542B\u4E0A\u4E0B\u6587\u4E2D\u6BCF\u4E2A\u7B54\u6848\u7684\u8D77\u59CB\u5B57\u7B26\u7D22\u5F15\u3002"),Lt=d(),ke=o("p"),_n=a("\u5728\u8BAD\u7EC3\u671F\u95F4, \u53EA\u6709\u4E00\u79CD\u53EF\u80FD\u7684\u7B54\u6848\u3002\u6211\u4EEC\u53EF\u4EE5\u4F7F\u7528 "),at=o("code"),De=a("Dataset.filter()"),qs=a(" \u65B9\u6CD5:"),ca=d(),q(Le.$$.fragment),da=d(),q(Es.$$.fragment),fa=d(),de=o("p"),mn=a("\u7136\u800C, \u5BF9\u4E8E\u8BC4\u4F30, \u6BCF\u4E2A\u6837\u672C\u90FD\u6709\u51E0\u4E2A\u53EF\u80FD\u7684\u7B54\u6848, \u5B83\u4EEC\u53EF\u80FD\u76F8\u540C\u6216\u4E0D\u540C:"),nt=d(),q(ys.$$.fragment),ua=d(),q(ze.$$.fragment),_a=d(),lt=o("p"),zt=a("\u6211\u4EEC\u4E0D\u4F1A\u6DF1\u5165\u7814\u7A76\u8BC4\u4F30\u811A\u672C, \u56E0\u4E3A\u5B83\u90FD\u4F1A\u88AB\u4E00\u4E2A \u{1F917} Datasets \u6307\u6807\u5305\u88F9\u8D77\u6765, \u4F46\u7B80\u77ED\u7684\u7248\u672C\u662F\u4E00\u4E9B\u95EE\u9898\u6709\u51E0\u4E2A\u53EF\u80FD\u7684\u7B54\u6848, \u8FD9\u4E2A\u811A\u672C\u4F1A\u5C06\u9884\u6D4B\u7684\u7B54\u6848\u4E0E\u6240\u6709\u200B\u200B\u7684\u53EF\u63A5\u53D7\u7684\u7B54\u6848\u5E76\u83B7\u5F97\u6700\u9AD8\u5206\u3002\u4F8B\u5982, \u6211\u4EEC\u770B\u4E00\u4E0B\u7D22\u5F15 2 \u5904\u7684\u6837\u672Ce:"),ma=d(),q(Ds.$$.fragment),ha=d(),q(_e.$$.fragment),wa=d(),ts=o("p"),hn=a("\u6211\u4EEC\u53EF\u4EE5\u770B\u5230, \u7B54\u6848\u786E\u5B9E\u53EF\u4EE5\u662F\u6211\u4EEC\u4E4B\u524D\u770B\u5230\u7684\u4E09\u79CD\u53EF\u80FD\u6027\u4E4B\u4E00\u3002"),ga=d(),Ne=o("h3"),wn=a("\u5904\u7406\u8BAD\u7EC3\u6570\u636E"),$a=d(),q(as.$$.fragment),Cs=d(),rt=o("p"),ba=a("\u8BA9\u6211\u4EEC\u4ECE\u9884\u5904\u7406\u8BAD\u7EC3\u6570\u636E\u5F00\u59CB\u3002\u56F0\u96BE\u7684\u90E8\u5206\u5C06\u662F\u4E3A\u95EE\u9898\u7684\u7B54\u6848\u751F\u6210\u6807\u7B7E, \u8FD9\u5C06\u662F\u4E0E\u4E0A\u4E0B\u6587\u4E2D\u7684\u7B54\u6848\u76F8\u5BF9\u5E94\u7684\u6807\u8BB0\u7684\u5F00\u59CB\u548C\u7ED3\u675F\u4F4D\u7F6E\u3002"),ns=d(),Ts=o("p"),ot=a("\u4F46\u662F, \u6211\u4EEC\u4E0D\u8981\u8D85\u8D8A\u81EA\u5DF1\u3002\u9996\u5148, \u6211\u4EEC\u9700\u8981\u4F7F\u7528\u5206\u8BCD\u5668\u5C06\u8F93\u5165\u4E2D\u7684\u6587\u672C\u8F6C\u6362\u4E3A\u6A21\u578B\u53EF\u4EE5\u7406\u89E3\u7684 ID:"),xa=d(),q(ls.$$.fragment),rs=d(),me=o("p"),ee=a("\u5982\u524D\u6240\u8FF0, \u6211\u4EEC\u5C06\u5BF9 BERT \u6A21\u578B\u8FDB\u884C\u5FAE\u8C03, \u4F46\u4F60\u53EF\u4EE5\u4F7F\u7528\u4EFB\u4F55\u5176\u4ED6\u6A21\u578B\u7C7B\u578B, \u53EA\u8981\u5B83\u5B9E\u73B0\u4E86\u5FEB\u901F\u6807\u8BB0\u5668\u5373\u53EF\u3002\u4F60\u53EF\u4EE5\u5728 "),As=o("a"),Nt=a("this big table"),gn=a(" \u4E2D\u770B\u5230\u6240\u6709\u5FEB\u901F\u7248\u672C\u7684\u67B6\u6784, \u5E76\u68C0\u67E5\u4F60\u6B63\u5728\u4F7F\u7528\u7684 "),Ht=o("code"),Vt=a("tokenizer"),$n=a(" \u5BF9\u8C61\u786E\u5B9E\u7531 \u{1F917} Tokenizers \u652F\u6301, \u4F60\u53EF\u4EE5\u67E5\u770B\u5B83\u7684 "),Qt=o("code"),Rt=a("is_fast"),bn=a(" \u5C5E\u6027:"),ja=d(),q(He.$$.fragment),va=d(),q(Ps.$$.fragment),it=d(),pt=o("p"),xn=a("\u6211\u4EEC\u53EF\u4EE5\u5C06\u95EE\u9898\u548C\u4E0A\u4E0B\u6587\u4E00\u8D77\u4F20\u9012\u7ED9\u6211\u4EEC\u7684\u6807\u8BB0\u5668, \u5B83\u4F1A\u6B63\u786E\u63D2\u5165\u7279\u6B8A\u6807\u8BB0\u4EE5\u5F62\u6210\u5982\u4E0B\u53E5\u5B50:"),ct=d(),q(Ss.$$.fragment),ka=d(),os=o("p"),jn=a("\u8BA9\u6211\u4EEC\u4ED4\u7EC6\u68C0\u67E5\u4E00\u4E0B:"),qa=d(),q(is.$$.fragment),qe=d(),q(Os.$$.fragment),dt=d(),ft=o("p"),vn=a("\u7136\u540E\u6807\u7B7E\u5C06\u6210\u4E3A\u5F00\u59CB\u548C\u7ED3\u675F\u7B54\u6848\u7684\u6807\u8BB0\u7684\u7D22\u5F15, \u5E76\u4E14\u6A21\u578B\u7684\u4EFB\u52A1\u662F\u9884\u6D4B\u8F93\u5165\u4E2D\u6BCF\u4E2A\u6807\u8BB0\u7684\u5F00\u59CB\u548C\u7ED3\u675F logit, \u7406\u8BBA\u6807\u7B7E\u5982\u4E0B:"),ps=d(),Ee=o("div"),Ms=o("img"),Ea=d(),u=o("img"),kn=d(),he=o("p"),Tl=a("\u5728\u8FD9\u79CD\u60C5\u51B5\u4E0B, \u4E0A\u4E0B\u6587\u4E0D\u4F1A\u592A\u957F, \u4F46\u662F\u6570\u636E\u96C6\u4E2D\u7684\u4E00\u4E9B\u793A\u4F8B\u7684\u4E0A\u4E0B\u6587\u5F88\u957F, \u4F1A\u8D85\u8FC7\u6211\u4EEC\u8BBE\u7F6E\u7684\u6700\u5927\u957F\u5EA6(\u5728\u8FD9\u79CD\u60C5\u51B5\u4E0B\u4E3A 384)\u3002\u6B63\u5982\u6211\u4EEC\u5728 "),Gt=o("a"),Al=a("\u7B2C\u516D\u7AE0"),Ce=a(" \u4E2D\u6240\u770B\u5230\u7684, \u5F53\u6211\u4EEC\u63A2\u7D22 "),ya=o("code"),Pl=a("question-answering"),Sl=a(" \u7BA1\u9053\u7684\u5185\u90E8\u7ED3\u6784\u65F6, \u6211\u4EEC\u5C06\u901A\u8FC7\u4ECE\u6211\u4EEC\u7684\u6570\u636E\u96C6\u7684\u4E00\u4E2A\u6837\u672C\u4E2D\u521B\u5EFA\u51E0\u4E2A\u8BAD\u7EC3\u7279\u5F81\u6765\u5904\u7406\u957F\u4E0A\u4E0B\u6587, \u5B83\u4EEC\u4E4B\u95F4\u6709\u4E00\u4E2A\u6ED1\u52A8\u7A97\u53E3\u3002"),qn=d(),Wt=o("p"),Da=a("\u8981\u4F7F\u7528\u5F53\u524D\u793A\u4F8B\u67E5\u770B\u5176\u5DE5\u4F5C\u539F\u7406, \u6211\u4EEC\u53EF\u4EE5\u5C06\u957F\u5EA6\u9650\u5236\u4E3A 100, \u5E76\u4F7F\u7528 50 \u4E2A\u6807\u8BB0\u7684\u6ED1\u52A8\u7A97\u53E3\u3002\u63D0\u9192\u4E00\u4E0B, \u6211\u4EEC\u4F7F\u7528:"),En=d(),Y=o("ul"),Ut=o("li"),Ca=o("code"),Ol=a("max_length"),Ml=a(" \u8BBE\u7F6E\u6700\u5927\u957F\u5EA6 (\u6B64\u5904\u4E3A 100)"),Bl=d(),Ve=o("li"),Ta=o("code"),Il=a('truncation="only_second"'),cs=a(" \u7528\u4E8E\u5F53\u5E26\u6709\u4E0A\u4E0B\u6587\u7684\u95EE\u9898\u592A\u957F\u65F6, \u622A\u65AD\u4E0A\u4E0B\u6587t (\u4F4D\u4E8E\u7B2C\u4E8C\u4E2A\u4F4D\u7F6E)"),Fl=d(),Jt=o("li"),Aa=o("code"),Ll=a("stride"),ut=a(" \u8BBE\u7F6E\u4E24\u4E2A\u8FDE\u7EED\u5757\u4E4B\u95F4\u7684\u91CD\u53E0\u6807\u8BB0\u6570 (\u8FD9\u91CC\u4E3A 50)"),zl=d(),Xt=o("li"),Pa=o("code"),Nl=a("return_overflowing_tokens=True"),_t=a(" \u8BA9\u6807\u8BB0\u5668\u77E5\u9053\u6211\u4EEC\u60F3\u8981\u6EA2\u51FA\u7684\u6807\u8BB0"),Kt=d(),q(mt.$$.fragment),Qe=d(),q(ht.$$.fragment),yn=d(),Re=o("p"),wt=a("\u5982\u6211\u4EEC\u6240\u89C1, \u6211\u4EEC\u7684\u793A\u4F8B\u88AB\u5206\u6210\u56DB\u4E2A\u8F93\u5165, \u6BCF\u4E2A\u8F93\u5165\u90FD\u5305\u542B\u95EE\u9898\u548C\u4E0A\u4E0B\u6587\u7684\u4E00\u90E8\u5206\u3002 \u8BF7\u6CE8\u610F, \u95EE\u9898\u7684\u7B54\u6848 (\u201CBernadette Soubirous\u201D) \u4EC5\u51FA\u73B0\u5728\u7B2C\u4E09\u4E2A\u4E5F\u662F\u6700\u540E\u4E00\u4E2A\u8F93\u5165\u4E2D, \u56E0\u6B64\u901A\u8FC7\u4EE5\u8FD9\u79CD\u65B9\u5F0F\u5904\u7406\u957F\u4E0A\u4E0B\u6587, \u6211\u4EEC\u5C06\u521B\u5EFA\u4E00\u4E9B\u7B54\u6848\u4E0D\u5305\u542B\u5728\u4E0A\u4E0B\u6587\u4E2D\u7684\u8BAD\u7EC3\u793A\u4F8B\u3002\u5BF9\u4E8E\u8FD9\u4E9B\u793A\u4F8B, \u6807\u7B7E\u5C06\u662F "),Sa=o("code"),Hl=a("start_position = end_position = 0"),Vl=a(" (\u6240\u4EE5\u6211\u4EEC\u9884\u6D4B "),Oa=o("code"),re=a("[CLS]"),Ql=a(" \u6807\u8BB0)\u3002\u6211\u4EEC\u8FD8\u5C06\u5728\u7B54\u6848\u88AB\u622A\u65AD\u7684\u4E0D\u5E78\u60C5\u51B5\u4E0B\u8BBE\u7F6E\u8FD9\u4E9B\u6807\u7B7E, \u4EE5\u4FBF\u6211\u4EEC\u53EA\u6709\u5B83\u7684\u5F00\u59CB(\u6216\u7ED3\u675F)\u3002\u5BF9\u4E8E\u7B54\u6848\u5B8C\u5168\u5728\u4E0A\u4E0B\u6587\u4E2D\u7684\u793A\u4F8B, \u6807\u7B7E\u5C06\u662F\u7B54\u6848\u5F00\u59CB\u7684\u6807\u8BB0\u7684\u7D22\u5F15\u548C\u7B54\u6848\u7ED3\u675F\u7684\u6807\u8BB0\u7684\u7D22\u5F15\u3002"),Dn=d(),Ge=o("p"),Rl=a("\u6570\u636E\u96C6\u4E3A\u6211\u4EEC\u63D0\u4F9B\u4E86\u4E0A\u4E0B\u6587\u4E2D\u7B54\u6848\u7684\u5F00\u59CB\u5B57\u7B26, \u901A\u8FC7\u6DFB\u52A0\u7B54\u6848\u7684\u957F\u5EA6, \u6211\u4EEC\u53EF\u4EE5\u627E\u5230\u4E0A\u4E0B\u6587\u4E2D\u7684\u7ED3\u675F\u5B57\u7B26\u3002\u8981\u5C06\u5B83\u4EEC\u6620\u5C04\u5230\u4EE4\u724C\u7D22\u5F15, \u6211\u4EEC\u5C06\u9700\u8981\u4F7F\u7528\u6211\u4EEC\u5728 "),Yt=o("a"),Gl=a("\u7B2C\u516D\u7AE0"),Wl=a(" \u4E2D\u7814\u7A76\u7684\u504F\u79FB\u6620\u5C04\u3002\u6211\u4EEC\u53EF\u4EE5\u8BA9\u6807\u8BB0\u5668\u901A\u8FC7\u4F20\u9012 "),ds=o("code"),Ul=a("return_offsets_mapping=True"),Jl=a(" \u6765\u8FD4\u56DE\u8FD9\u4E9B\u503C:"),Cn=d(),q(Tn.$$.fragment),Bo=d(),q(An.$$.fragment),Io=d(),gt=o("p"),Ip=a("\u5982\u6211\u4EEC\u6240\u89C1, \u6211\u4EEC\u53D6\u56DE\u4E86\u901A\u5E38\u7684\u8F93\u5165 ID\u3001\u4EE4\u724C\u7C7B\u578B ID \u548C\u6CE8\u610F\u63A9\u7801, \u4EE5\u53CA\u6211\u4EEC\u9700\u8981\u7684\u504F\u79FB\u6620\u5C04\u548C\u4E00\u4E2A\u989D\u5916\u7684\u952E, "),Gr=o("code"),Fp=a("overflow_to_sample_mapping"),Lp=a("\u3002\u5F53\u6211\u4EEC\u540C\u65F6\u6807\u8BB0\u591A\u4E2A\u6587\u672C\u65F6, \u76F8\u5E94\u7684\u503C\u5C06\u5BF9\u6211\u4EEC\u6709\u7528(\u6211\u4EEC\u5E94\u8BE5\u8FD9\u6837\u505A\u4EE5\u53D7\u76CA\u4E8E\u6211\u4EEC\u7684\u6807\u8BB0\u5668\u7531 Rust \u652F\u6301\u7684\u4E8B\u5B9E)\u3002\u7531\u4E8E\u4E00\u4E2A\u6837\u672C\u53EF\u4EE5\u63D0\u4F9B\u591A\u4E2A\u7279\u5F81, \u56E0\u6B64\u5B83\u5C06\u6BCF\u4E2A\u7279\u5F81\u6620\u5C04\u5230\u5176\u6765\u6E90\u7684\u793A\u4F8B\u3002\u56E0\u4E3A\u8FD9\u91CC\u6211\u4EEC\u53EA\u6807\u8BB0\u4E86\u4E00\u4E2A\u4F8B\u5B50, \u6211\u4EEC\u5F97\u5230\u4E00\u4E2A "),Wr=o("code"),zp=a("0"),Np=a(" \u7684\u5217\u8868:"),Fo=d(),q(Pn.$$.fragment),Lo=d(),q(Sn.$$.fragment),zo=d(),Xl=o("p"),Hp=a("\u4F46\u662F, \u5982\u679C\u6211\u4EEC\u6807\u8BB0\u66F4\u591A\u793A\u4F8B, \u8FD9\u5C06\u53D8\u5F97\u66F4\u52A0\u6709\u7528:"),No=d(),q(On.$$.fragment),Ho=d(),q(Mn.$$.fragment),Vo=d(),Kl=o("p"),Vp=a("\u6B63\u5982\u6211\u4EEC\u6240\u770B\u5230\u7684, \u524D\u4E09\u4E2A\u793A\u4F8B (\u5728\u8BAD\u7EC3\u96C6\u4E2D\u7684\u7D22\u5F15 2\u30013 \u548C 4 \u5904) \u6BCF\u4E2A\u90FD\u7ED9\u51FA\u4E86\u56DB\u4E2A\u7279\u5F81, \u6700\u540E\u4E00\u4E2A\u793A\u4F8B(\u5728\u8BAD\u7EC3\u96C6\u4E2D\u7684\u7D22\u5F15 5 \u5904) \u7ED9\u51FA\u4E86 7 \u4E2A\u7279\u5F81\u3002"),Qo=d(),Yl=o("p"),Qp=a("\u6B64\u4FE1\u606F\u5C06\u6709\u52A9\u4E8E\u5C06\u6211\u4EEC\u83B7\u5F97\u7684\u6BCF\u4E2A\u7279\u5F81\u6620\u5C04\u5230\u5176\u76F8\u5E94\u7684\u6807\u7B7E\u3002\u5982\u524D\u6240\u8FF0, \u8FD9\u4E9B\u6807\u7B7E\u662F:"),Ro=d(),Ma=o("ul"),Zl=o("li"),Ur=o("code"),Rp=a("(0, 0)"),Gp=a(" \u5982\u679C\u7B54\u6848\u4E0D\u5728\u4E0A\u4E0B\u6587\u7684\u76F8\u5E94\u8303\u56F4\u5185"),Wp=d(),$t=o("li"),Jr=o("code"),Up=a("(start_position, end_position)"),Jp=a(" \u5982\u679C\u7B54\u6848\u5728\u4E0A\u4E0B\u6587\u7684\u76F8\u5E94\u8303\u56F4\u5185, \u5219 "),Xr=o("code"),Xp=a("start_position"),Kp=a(" \u662F\u7B54\u6848\u5F00\u5934\u7684\u6807\u8BB0\u7D22\u5F15 (\u5728\u8F93\u5165 ID \u4E2D), \u5E76\u4E14 "),Kr=o("code"),Yp=a("end_position"),Zp=a(" \u662F\u7B54\u6848\u7ED3\u675F\u7684\u6807\u8BB0\u7684\u7D22\u5F15 (\u5728\u8F93\u5165 ID \u4E2D)\u3002"),Go=d(),bt=o("p"),ec=a("\u4E3A\u4E86\u786E\u5B9A\u662F\u54EA\u79CD\u60C5\u51B5\u4EE5\u53CA\u6807\u8BB0\u7684\u4F4D\u7F6E, \u4EE5\u53CA(\u5982\u679C\u76F8\u5173\u7684\u8BDD)\u6807\u8BB0\u7684\u4F4D\u7F6E, \u6211\u4EEC\u9996\u5148\u5728\u8F93\u5165 ID \u4E2D\u627E\u5230\u5F00\u59CB\u548C\u7ED3\u675F\u4E0A\u4E0B\u6587\u7684\u7D22\u5F15\u3002\u6211\u4EEC\u53EF\u4EE5\u4F7F\u7528\u6807\u8BB0\u7C7B\u578B ID \u6765\u6267\u884C\u6B64\u64CD\u4F5C, \u4F46\u7531\u4E8E\u8FD9\u4E9B ID \u4E0D\u4E00\u5B9A\u5B58\u5728\u4E8E\u6240\u6709\u6A21\u578B\u4E2D (\u4F8B\u5982, DistilBERT \u4E0D\u9700\u8981\u5B83\u4EEC), \u6211\u4EEC\u5C06\u6539\u4E3A\u4F7F\u7528\u6211\u4EEC\u7684\u6807\u8BB0\u5668\u8FD4\u56DE\u7684 "),Yr=o("code"),sc=a("BatchEncoding"),tc=a(" \u7684 "),Zr=o("code"),ac=a("sequence_ids()"),nc=a(" \u65B9\u6CD5\u3002"),Wo=d(),Ba=o("p"),lc=a("\u4E00\u65E6\u6211\u4EEC\u6709\u4E86\u8FD9\u4E9B\u6807\u8BB0\u7D22\u5F15, \u6211\u4EEC\u5C31\u4F1A\u67E5\u770B\u76F8\u5E94\u7684\u504F\u79FB\u91CF, \u5B83\u4EEC\u662F\u4E24\u4E2A\u6574\u6570\u7684\u5143\u7EC4, \u8868\u793A\u539F\u59CB\u4E0A\u4E0B\u6587\u4E2D\u7684\u5B57\u7B26\u8303\u56F4\u3002\u56E0\u6B64, \u6211\u4EEC\u53EF\u4EE5\u68C0\u6D4B\u6B64\u7279\u5F81\u4E2D\u7684\u4E0A\u4E0B\u6587\u5757\u662F\u5728\u7B54\u6848\u4E4B\u540E\u5F00\u59CB\u8FD8\u662F\u5728\u7B54\u6848\u5F00\u59CB\u4E4B\u524D\u7ED3\u675F(\u5728\u8FD9\u79CD\u60C5\u51B5\u4E0B, \u6807\u7B7E\u662F "),eo=o("code"),rc=a("(0, 0)"),oc=a(")\u3002\u5982\u679C\u4E0D\u662F\u8FD9\u6837, \u6211\u4EEC\u5FAA\u73AF\u67E5\u627E\u7B54\u6848\u7684\u7B2C\u4E00\u4E2A\u548C\u6700\u540E\u4E00\u4E2A\u6807\u8BB0:"),Uo=d(),q(Bn.$$.fragment),Jo=d(),q(In.$$.fragment),Xo=d(),Ia=o("p"),ic=a("\u8BA9\u6211\u4EEC\u770B\u4E00\u4E9B\u7ED3\u679C\u6765\u9A8C\u8BC1\u6211\u4EEC\u7684\u65B9\u6CD5\u662F\u5426\u6B63\u786E\u3002\u5BF9\u4E8E\u6211\u4EEC\u53D1\u73B0\u7684\u7B2C\u4E00\u4E2A\u7279\u5F81, \u6211\u4EEC\u5C06 "),so=o("code"),pc=a("(83, 85)"),cc=a(" \u4F5C\u4E3A\u6807\u7B7E, \u8BA9\u6211\u4EEC\u5C06\u7406\u8BBA\u7B54\u6848\u4E0E\u4ECE 83 \u5230 85 (\u5305\u62EC)\u7684\u6807\u8BB0\u89E3\u7801\u8303\u56F4\u8FDB\u884C\u6BD4\u8F83:"),Ko=d(),q(Fn.$$.fragment),Yo=d(),q(Ln.$$.fragment),Zo=d(),Fa=o("p"),dc=a("\u6240\u4EE5\u8FD9\u662F\u4E00\u573A\u6BD4\u8D5B! \u73B0\u5728\u8BA9\u6211\u4EEC\u68C0\u67E5\u7D22\u5F15 4, \u6211\u4EEC\u5C06\u6807\u7B7E\u8BBE\u7F6E\u4E3A "),to=o("code"),fc=a("(0, 0)"),uc=a(", \u8FD9\u610F\u5473\u7740\u7B54\u6848\u4E0D\u5728\u8BE5\u529F\u80FD\u7684\u4E0A\u4E0B\u6587\u5757\u4E2D"),ei=d(),q(zn.$$.fragment),si=d(),q(Nn.$$.fragment),ti=d(),er=o("p"),_c=a("\u4E8B\u5B9E\u4E0A, \u6211\u4EEC\u5728\u4E0A\u4E0B\u6587\u4E2D\u770B\u4E0D\u5230\u7B54\u6848\u3002"),ai=d(),q(La.$$.fragment),ni=d(),sr=o("p"),mc=a("\u73B0\u5728\u6211\u4EEC\u5DF2\u7ECF\u9010\u6B65\u4E86\u89E3\u4E86\u5982\u4F55\u9884\u5904\u7406\u6211\u4EEC\u7684\u8BAD\u7EC3\u6570\u636E, \u6211\u4EEC\u53EF\u4EE5\u5C06\u5176\u5206\u7EC4\u5230\u4E00\u4E2A\u51FD\u6570\u4E2D, \u6211\u4EEC\u5C06\u5E94\u7528\u4E8E\u6574\u4E2A\u8BAD\u7EC3\u6570\u636E\u96C6\u3002\u6211\u4EEC\u4F1A\u5C06\u6BCF\u4E2A\u7279\u5F81\u586B\u5145\u5230\u6211\u4EEC\u8BBE\u7F6E\u7684\u6700\u5927\u957F\u5EA6, \u56E0\u4E3A\u5927\u591A\u6570\u4E0A\u4E0B\u6587\u4F1A\u5F88\u957F (\u5E76\u4E14\u76F8\u5E94\u7684\u6837\u672C\u5C06\u88AB\u5206\u6210\u51E0\u4E2A\u7279\u5F81), \u6240\u4EE5\u5728\u8FD9\u91CC\u5E94\u7528\u52A8\u6001\u586B\u5145\u6CA1\u6709\u771F\u6B63\u7684\u597D\u5904:"),li=d(),q(Hn.$$.fragment),ri=d(),tr=o("p"),hc=a("\u8BF7\u6CE8\u610F, \u6211\u4EEC\u5B9A\u4E49\u4E86\u4E24\u4E2A\u5E38\u6570\u6765\u786E\u5B9A\u4F7F\u7528\u7684\u6700\u5927\u957F\u5EA6\u4EE5\u53CA\u6ED1\u52A8\u7A97\u53E3\u7684\u957F\u5EA6, \u5E76\u4E14\u6211\u4EEC\u5728\u6807\u8BB0\u5316\u4E4B\u524D\u6DFB\u52A0\u4E86\u4E00\u70B9\u6E05\u7406: SQuAD \u6570\u636E\u96C6\u4E2D\u7684\u4E00\u4E9B\u95EE\u9898\u5728\u5F00\u5934\u6709\u989D\u5916\u7684\u7A7A\u683C, \u5E76\u4E14\u4E0D\u6DFB\u52A0\u4EFB\u4F55\u5185\u5BB9\u7684\u7ED3\u5C3E (\u5982\u679C\u4F60\u4F7F\u7528\u50CF RoBERTa \u8FD9\u6837\u7684\u6A21\u578B, \u5219\u5728\u6807\u8BB0\u5316\u65F6\u4F1A\u5360\u7528\u7A7A\u95F4), \u56E0\u6B64\u6211\u4EEC\u5220\u9664\u4E86\u90A3\u4E9B\u989D\u5916\u7684\u7A7A\u683C\u3002"),oi=d(),xt=o("p"),wc=a("\u4E3A\u4E86\u5C06\u6B64\u51FD\u6570\u5E94\u7528\u4E8E\u6574\u4E2A\u8BAD\u7EC3\u96C6, \u6211\u4EEC\u4F7F\u7528 "),ao=o("code"),gc=a("Dataset.map()"),$c=a(" \u65B9\u6CD5\u4E0E "),no=o("code"),bc=a("batched=True"),xc=a(" \u6807\u5FD7\u3002\u8FD9\u662F\u5FC5\u8981\u7684, \u56E0\u4E3A\u6211\u4EEC\u6B63\u5728\u66F4\u6539\u6570\u636E\u96C6\u7684\u957F\u5EA6(\u56E0\u4E3A\u4E00\u4E2A\u793A\u4F8B\u53EF\u4EE5\u63D0\u4F9B\u591A\u4E2A\u8BAD\u7EC3\u7279\u5F81):"),ii=d(),q(Vn.$$.fragment),pi=d(),q(Qn.$$.fragment),ci=d(),ar=o("p"),jc=a("\u6B63\u5982\u6211\u4EEC\u6240\u89C1, \u9884\u5904\u7406\u589E\u52A0\u4E86\u5927\u7EA6 1,000 \u4E2A\u7279\u5F81\u3002\u6211\u4EEC\u7684\u8BAD\u7EC3\u96C6\u73B0\u5728\u53EF\u4EE5\u4F7F\u7528\u4E86\u2014 \u8BA9\u6211\u4EEC\u6DF1\u5165\u7814\u7A76\u9A8C\u8BC1\u96C6\u7684\u9884\u5904\u7406!"),di=d(),Rn=o("h3"),vc=a("\u5904\u7406\u9A8C\u8BC1\u6570\u636E"),fi=d(),nr=o("p"),kc=a("\u9884\u5904\u7406\u9A8C\u8BC1\u6570\u636E\u4F1A\u7A0D\u5FAE\u5BB9\u6613\u4E00\u4E9B, \u56E0\u4E3A\u6211\u4EEC\u4E0D\u9700\u8981\u751F\u6210\u6807\u7B7E(\u9664\u975E\u6211\u4EEC\u60F3\u8BA1\u7B97\u9A8C\u8BC1\u635F\u5931, \u4F46\u8FD9\u4E2A\u6570\u5B57\u5E76\u4E0D\u80FD\u771F\u6B63\u5E2E\u52A9\u6211\u4EEC\u7406\u89E3\u6A21\u578B\u6709\u591A\u597D)\u3002\u771F\u6B63\u7684\u4E50\u8DA3\u662F\u5C06\u6A21\u578B\u7684\u9884\u6D4B\u89E3\u91CA\u4E3A\u539F\u59CB\u4E0A\u4E0B\u6587\u7684\u8DE8\u5EA6\u3002\u4E3A\u6B64, \u6211\u4EEC\u53EA\u9700\u8981\u5B58\u50A8\u504F\u79FB\u6620\u5C04\u548C\u67D0\u79CD\u65B9\u5F0F\u6765\u5C06\u6BCF\u4E2A\u521B\u5EFA\u7684\u7279\u5F81\u4E0E\u5B83\u6765\u81EA\u7684\u539F\u59CB\u793A\u4F8B\u76F8\u5339\u914D\u3002\u7531\u4E8E\u539F\u59CB\u6570\u636E\u96C6\u4E2D\u6709\u4E00\u4E2A ID \u5217, \u6211\u4EEC\u5C06\u4F7F\u7528\u8BE5 ID\u3002"),ui=d(),jt=o("p"),qc=a("\u6211\u4EEC\u5C06\u5728\u8FD9\u91CC\u6DFB\u52A0\u7684\u552F\u4E00\u5185\u5BB9\u662F\u5BF9\u504F\u79FB\u6620\u5C04\u7684\u4E00\u70B9\u70B9\u6E05\u7406\u3002\u5B83\u4EEC\u5C06\u5305\u542B\u95EE\u9898\u548C\u4E0A\u4E0B\u6587\u7684\u504F\u79FB\u91CF, \u4F46\u662F\u4E00\u65E6\u6211\u4EEC\u8FDB\u5165\u540E\u5904\u7406\u9636\u6BB5, \u6211\u4EEC\u5C06\u65E0\u6CD5\u77E5\u9053\u8F93\u5165 ID \u7684\u54EA\u4E00\u90E8\u5206\u5BF9\u5E94\u4E8E\u4E0A\u4E0B\u6587\u4EE5\u53CA\u54EA\u4E00\u90E8\u5206\u662F\u95EE\u9898(\u6211\u4EEC\u4F7F\u7528\u7684 "),lo=o("code"),Ec=a("sequence_ids()"),yc=a(" \u65B9\u6CD5\u4EC5\u53EF\u7528\u4E8E\u6807\u8BB0\u5668\u7684\u8F93\u51FA)\u3002\u56E0\u6B64, \u6211\u4EEC\u5C06\u4E0E\u95EE\u9898\u5BF9\u5E94\u7684\u504F\u79FB\u91CF\u8BBE\u7F6E\u4E3A "),ro=o("code"),Dc=a("None"),Cc=a(":"),_i=d(),q(Gn.$$.fragment),mi=d(),lr=o("p"),Tc=a("\u6211\u4EEC\u53EF\u4EE5\u50CF\u4EE5\u524D\u4E00\u6837\u5C06\u6B64\u51FD\u6570\u5E94\u7528\u4E8E\u6574\u4E2A\u9A8C\u8BC1\u6570\u636E\u96C6:"),hi=d(),q(Wn.$$.fragment),wi=d(),q(Un.$$.fragment),gi=d(),rr=o("p"),Ac=a("I\u5728\u8FD9\u79CD\u60C5\u51B5\u4E0B, \u6211\u4EEC\u53EA\u6DFB\u52A0\u4E86\u51E0\u767E\u4E2A\u6837\u672C, \u56E0\u6B64\u9A8C\u8BC1\u6570\u636E\u96C6\u4E2D\u7684\u4E0A\u4E0B\u6587\u4F3C\u4E4E\u6709\u70B9\u77ED\u3002"),$i=d(),or=o("p"),Pc=a("\u73B0\u5728\u6211\u4EEC\u5DF2\u7ECF\u5BF9\u6240\u6709\u6570\u636E\u8FDB\u884C\u4E86\u9884\u5904\u7406, \u6211\u4EEC\u53EF\u4EE5\u5F00\u59CB\u8BAD\u7EC3\u4E86\u3002"),bi=d(),Is.c(),ir=d(),Jn=o("h3"),Sc=a("\u540E\u5904\u7406"),xi=d(),Ls.c(),pr=d(),za=o("p"),Oc=a("\u8BE5\u6A21\u578B\u5C06\u5728\u8F93\u5165ID\u4E2D\u4E3A\u7B54\u6848\u7684\u5F00\u59CB\u548C\u7ED3\u675F\u4F4D\u7F6E\u8F93\u51FALogit, \u6B63\u5982\u6211\u4EEC\u5728\u63A2\u7D22 "),Xn=o("a"),oo=o("code"),Mc=a("question-answering"),Bc=a(" pipeline"),Ic=a(" \u65F6\u770B\u5230\u7684\u90A3\u6837\u3002\u540E\u5904\u7406\u6B65\u9AA4\u5C06\u7C7B\u4F3C\u4E8E\u6211\u4EEC\u5728\u90A3\u91CC\u6240\u505A\u7684, \u6240\u4EE5\u8FD9\u91CC\u662F\u6211\u4EEC\u91C7\u53D6\u7684\u884C\u52A8\u7684\u5FEB\u901F\u63D0\u9192:"),ji=d(),fs=o("ul"),io=o("li"),Fc=a("\u6211\u4EEC\u5C4F\u853D\u4E86\u4E0E\u4E0A\u4E0B\u6587\u4E4B\u5916\u7684\u6807\u8BB0\u76F8\u5BF9\u5E94\u7684\u5F00\u59CB\u548C\u7ED3\u675F logits\u3002"),Lc=d(),po=o("li"),zc=a("\u7136\u540E, \u6211\u4EEC\u4F7F\u7528 softmax \u5C06\u5F00\u59CB\u548C\u7ED3\u675F logits \u8F6C\u6362\u4E3A\u6982\u7387\u3002"),Nc=d(),Kn=o("li"),Hc=a("\u6211\u4EEC\u901A\u8FC7\u53D6\u5BF9\u5E94\u7684\u4E24\u4E2A\u6982\u7387\u7684\u4E58\u79EF\u6765\u7ED9\u6BCF\u4E2A "),co=o("code"),Vc=a("(start_token, end_token)"),Qc=a(" \u7EC4\u5408\u8D4B\u503C\u3002"),Rc=d(),Zt=o("li"),Gc=a("\u6211\u4EEC\u5BFB\u627E\u4EA7\u751F\u6709\u6548\u7B54\u6848\u7684\u6700\u9AD8\u5206\u6570\u7684\u914D\u5BF9 (\u4F8B\u5982, "),fo=o("code"),Wc=a("start_token"),Uc=a(" \u4F4E\u4E8E "),uo=o("code"),Jc=a("end_token"),Xc=a(")\u3002"),vi=d(),Te=o("p"),Kc=a("\u5728\u8FD9\u91CC, \u6211\u4EEC\u5C06\u7A0D\u5FAE\u6539\u53D8\u8FD9\u4E2A\u8FC7\u7A0B, \u56E0\u4E3A\u6211\u4EEC\u4E0D\u9700\u8981\u8BA1\u7B97\u5B9E\u9645\u5206\u6570 (\u53EA\u662F\u9884\u6D4B\u7684\u7B54\u6848)\u3002\u8FD9\u610F\u5473\u7740\u6211\u4EEC\u53EF\u4EE5\u8DF3\u8FC7 softmax \u6B65\u9AA4\u3002\u4E3A\u4E86\u66F4\u5FEB, \u6211\u4EEC\u4E5F\u4E0D\u4F1A\u5BF9\u6240\u6709\u53EF\u80FD\u7684 "),_o=o("code"),Yc=a("(start_token, end_token)"),Zc=a(" \u5BF9\u8FDB\u884C\u8BC4\u5206, \u800C\u53EA\u4F1A\u5BF9\u5BF9\u5E94\u4E8E\u6700\u9AD8 "),mo=o("code"),ed=a("n_best"),sd=a(" \u7684\u90A3\u4E9B\u5BF9\u8FDB\u884C\u8BC4\u5206 (\u4F7F\u7528 "),ho=o("code"),td=a("n_best=20"),ad=a(")\u3002\u7531\u4E8E\u6211\u4EEC\u5C06\u8DF3\u8FC7 softmax, \u56E0\u6B64\u8FD9\u4E9B\u5206\u6570\u5C06\u662F logit \u5206\u6570, \u5E76\u4E14\u5C06\u901A\u8FC7\u53D6 start \u548C end logits \u7684\u603B\u548C\u6765\u83B7\u5F97 (\u800C\u4E0D\u662F\u4E58\u79EF, \u56E0\u4E3A\u89C4\u5219 "),ki=new L_,qi=a(")\u3002"),Ei=d(),Na=o("p"),nd=a("\u4E3A\u4E86\u8BC1\u660E\u8FD9\u4E00\u5207, \u6211\u4EEC\u9700\u8981\u4E00\u4E9B\u9884\u6D4B\u3002\u7531\u4E8E\u6211\u4EEC\u8FD8\u6CA1\u6709\u8BAD\u7EC3\u6211\u4EEC\u7684\u6A21\u578B, \u6211\u4EEC\u5C06\u4F7F\u7528 QA \u7BA1\u9053\u7684\u9ED8\u8BA4\u6A21\u578B\u5BF9\u4E00\u5C0F\u90E8\u5206\u9A8C\u8BC1\u96C6\u751F\u6210\u4E00\u4E9B\u9884\u6D4B\u3002\u6211\u4EEC\u53EF\u4EE5\u4F7F\u7528\u548C\u4E4B\u524D\u4E00\u6837\u7684\u5904\u7406\u51FD\u6570; \u56E0\u4E3A\u5B83\u4F9D\u8D56\u4E8E\u5168\u5C40\u5E38\u91CF "),wo=o("code"),ld=a("tokenizer"),rd=a(", \u6211\u4EEC\u53EA\u9700\u5C06\u8BE5\u5BF9\u8C61\u66F4\u6539\u4E3A\u6211\u4EEC\u8981\u4E34\u65F6\u4F7F\u7528\u7684\u6A21\u578B\u7684\u6807\u8BB0\u5668:"),yi=d(),q(Yn.$$.fragment),Di=d(),cr=o("p"),od=a("\u73B0\u5728\u9884\u5904\u7406\u5DF2\u7ECF\u5B8C\u6210, \u6211\u4EEC\u5C06\u5206\u8BCD\u5668\u6539\u56DE\u6211\u4EEC\u6700\u521D\u9009\u62E9\u7684\u90A3\u4E2A:"),Ci=d(),q(Zn.$$.fragment),Ti=d(),Ha=o("p"),id=a("\u7136\u540E, \u6211\u4EEC\u5220\u9664 "),go=o("code"),pd=a("eval_set"),cd=a(" \u4E2D\u6A21\u578B\u4E0D\u671F\u5F85\u7684\u5217, \u7528\u6240\u6709\u7684\u5C0F\u9A8C\u8BC1\u96C6\u6784\u5EFA\u4E00\u4E2A\u6279\u6B21, \u7136\u540E\u901A\u8FC7\u6A21\u578B\u3002\u5982\u679C GPU \u53EF\u7528, \u6211\u4EEC\u4F1A\u4F7F\u7528\u5B83\u6765\u52A0\u5FEB\u901F\u5EA6:"),Ai=d(),Ns.c(),dr=d(),Ae=o("p"),dd=a("\u73B0\u5728, \u6211\u4EEC\u9700\u8981\u5728 "),$o=o("code"),fd=a("small_eval_set"),ud=a(" \u4E2D\u627E\u5230\u6BCF\u4E2A\u793A\u4F8B\u7684\u9884\u6D4B\u7B54\u6848\u3002\u4E00\u4E2A\u793A\u4F8B\u53EF\u80FD\u5DF2\u7ECF\u5728  "),bo=o("code"),_d=a("eval_set"),md=a(" \u4E2D\u62C6\u5206\u4E3A\u591A\u4E2A\u7279\u5F81, \u56E0\u6B64\u7B2C\u4E00\u6B65\u662F\u5C06 "),xo=o("code"),hd=a("small_eval_set"),wd=a(" \u4E2D\u7684\u6BCF\u4E2A\u793A\u4F8B\u6620\u5C04\u5230 "),jo=o("code"),gd=a("eval_set"),$d=a(" \u4E2D\u76F8\u5E94\u7684\u7279\u5F81:"),Pi=d(),q(el.$$.fragment),Si=d(),Va=o("p"),bd=a("\u6709\u4E86\u8FD9\u4E2A, \u6211\u4EEC\u5C31\u53EF\u4EE5\u771F\u6B63\u5F00\u59CB\u5DE5\u4F5C, \u5FAA\u73AF\u904D\u5386\u6240\u6709\u793A\u4F8B, \u5E76\u4E3A\u6BCF\u4E2A\u793A\u4F8B\u904D\u5386\u6240\u6709\u76F8\u5173\u529F\u80FD\u3002\u6B63\u5982\u6211\u4EEC\u4E4B\u524D\u6240\u8BF4, \u6211\u4EEC\u5C06\u67E5\u770B "),vo=o("code"),xd=a("n_best"),jd=a(" \u5F00\u59CB logits \u548C\u7ED3\u675F logits \u7684 logit \u5206\u6570, \u4E0D\u5305\u62EC\u4EE5\u4E0B\u7684\u4F4D\u7F6E:"),Oi=d(),vt=o("ul"),ko=o("li"),vd=a("\u4E00\u4E2A\u4E0D\u5728\u4E0A\u4E0B\u6587\u4E2D\u7684\u7B54\u6848"),kd=d(),qo=o("li"),qd=a("\u957F\u5EA6\u4E3A\u8D1F\u7684\u7B54\u6848"),Ed=d(),sl=o("li"),yd=a("\u7B54\u6848\u592A\u957F (\u6211\u4EEC\u5C06\u53EF\u80FD\u6027\u9650\u5236\u5728 "),Eo=o("code"),Dd=a("max_answer_length=30"),Cd=a(")"),Mi=d(),fr=o("p"),Td=a("\u4E00\u65E6\u6211\u4EEC\u4E3A\u4E00\u4E2A\u793A\u4F8B\u83B7\u5F97\u4E86\u6240\u6709\u53EF\u80FD\u7684\u7B54\u6848, \u6211\u4EEC\u53EA\u9700\u9009\u62E9\u4E00\u4E2A\u5177\u6709\u6700\u4F73 logit \u5206\u6570\u7684\u7B54\u6848:"),Bi=d(),q(tl.$$.fragment),Ii=d(),ur=o("p"),Ad=a("\u9884\u6D4B\u7B54\u6848\u7684\u6700\u7EC8\u683C\u5F0F\u662F\u6211\u4EEC\u5C06\u4F7F\u7528\u7684\u5EA6\u91CF\u6807\u51C6\u6240\u671F\u671B\u7684\u683C\u5F0F\u3002\u50CF\u5F80\u5E38\u4E00\u6837, \u6211\u4EEC\u53EF\u4EE5\u5728 \u{1F917} Datasets \u5E93\u7684\u5E2E\u52A9\u4E0B\u52A0\u8F7D\u5B83:"),Fi=d(),q(al.$$.fragment),Li=d(),_r=o("p"),Pd=a("\u8BE5\u6307\u6807\u671F\u671B\u6211\u4EEC\u4E0A\u9762\u770B\u5230\u7684\u683C\u5F0F\u7684\u9884\u6D4B\u7B54\u6848 (\u4E00\u4E2A\u5B57\u5178\u5217\u8868, \u5176\u4E2D\u4E00\u4E2A\u952E\u7528\u4E8E\u793A\u4F8B ID, \u4E00\u4E2A\u952E\u7528\u4E8E\u9884\u6D4B\u6587\u672C) \u548C\u4EE5\u4E0B\u683C\u5F0F\u7684\u7406\u8BBA\u7B54\u6848 (\u4E00\u4E2A\u5B57\u5178\u5217\u8868, \u4E00\u4E2A\u952E\u793A\u4F8B\u7684 ID \u548C\u53EF\u80FD\u7B54\u6848\u7684\u4E00\u952E):"),zi=d(),q(nl.$$.fragment),Ni=d(),mr=o("p"),Sd=a("\u6211\u4EEC\u73B0\u5728\u53EF\u4EE5\u901A\u8FC7\u67E5\u770B\u4E24\u4E2A\u5217\u8868\u7684\u7B2C\u4E00\u4E2A\u5143\u7D20\u6765\u68C0\u67E5\u6211\u4EEC\u662F\u5426\u5F97\u5230\u4E86\u5408\u7406\u7684\u7ED3\u679C:"),Hi=d(),q(ll.$$.fragment),Vi=d(),q(rl.$$.fragment),Qi=d(),hr=o("p"),Od=a("\u8FD8\u4E0D\u9519! \u73B0\u5728\u8BA9\u6211\u4EEC\u770B\u770B\u8FD9\u4E2A\u6307\u6807\u7ED9\u6211\u4EEC\u7684\u5206\u6570:"),Ri=d(),q(ol.$$.fragment),Gi=d(),q(il.$$.fragment),Wi=d(),Qa=o("p"),Md=a("\u540C\u6837, \u8003\u8651\u5230\u6839\u636E "),pl=o("a"),Bd=a("its paper"),Id=a(", \u5728 SQuAD \u4E0A\u5FAE\u8C03\u7684 DistilBERT \u5728\u6574\u4E2A\u6570\u636E\u96C6\u4E0A\u7684\u5F97\u5206\u5206\u522B\u4E3A 79.1 \u548C 86.9, \u8FD9\u662F\u76F8\u5F53\u4E0D\u9519\u7684\u3002"),Ui=d(),ea.c(),wr=d(),q(cl.$$.fragment),Ji=d(),gr=o("p"),Fd=a("\u6211\u4EEC\u53EF\u4EE5\u68C0\u67E5\u5B83\u662F\u5426\u9002\u7528\u4E8E\u6211\u4EEC\u7684\u9884\u6D4B:"),Xi=d(),q(dl.$$.fragment),Ki=d(),q(fl.$$.fragment),Yi=d(),$r=o("p"),Ld=a("\u770B\u8D77\u6765\u4E0D\u9519! \u73B0\u5728\u8BA9\u6211\u4EEC\u7528\u5B83\u6765\u5FAE\u8C03\u6211\u4EEC\u7684\u6A21\u578B\u3002"),Zi=d(),ul=o("h3"),zd=a("\u5FAE\u8C03\u6A21\u578B"),ep=d(),Vs.c(),br=d(),xr=o("p"),Nd=a("\u50CF\u5F80\u5E38\u4E00\u6837, \u6211\u4EEC\u6536\u5230\u4E00\u4E2A\u8B66\u544A, \u6709\u4E9B\u6743\u91CD\u6CA1\u6709\u4F7F\u7528(\u6765\u81EA\u9884\u8BAD\u7EC3\u5934\u7684), \u800C\u53E6\u4E00\u4E9B\u662F\u968F\u673A\u521D\u59CB\u5316\u7684 (\u7528\u4E8E\u95EE\u7B54\u5934\u7684)\u3002\u4F60\u73B0\u5728\u5E94\u8BE5\u5DF2\u7ECF\u4E60\u60EF\u4E86, \u4F46\u8FD9\u610F\u5473\u7740\u8FD9\u4E2A\u6A21\u578B\u8FD8\u6CA1\u6709\u51C6\u5907\u597D\u4F7F\u7528, \u9700\u8981\u5FAE\u8C03 \u2014 \u6211\u4EEC\u5373\u5C06\u8FD9\u6837\u505A!"),sp=d(),jr=o("p"),Hd=a("\u4E3A\u4E86\u80FD\u591F\u5C06\u6211\u4EEC\u7684\u6A21\u578B\u63A8\u9001\u5230 Hub, \u6211\u4EEC\u9700\u8981\u767B\u5F55 Hugging Face\u3002 \u5982\u679C\u4F60\u5728\u7B14\u8BB0\u672C\u4E2D\u8FD0\u884C\u6B64\u4EE3\u7801, \u5219\u53EF\u4EE5\u4F7F\u7528\u4EE5\u4E0B\u5B9E\u7528\u7A0B\u5E8F\u51FD\u6570\u6267\u884C\u6B64\u64CD\u4F5C, \u8BE5\u51FD\u6570\u4F1A\u663E\u793A\u4E00\u4E2A\u5C0F\u90E8\u4EF6, \u4F60\u53EF\u4EE5\u5728\u5176\u4E2D\u8F93\u5165\u767B\u5F55\u51ED\u636E:"),tp=d(),q(_l.$$.fragment),ap=d(),vr=o("p"),Vd=a("\u5982\u679C\u4F60\u4E0D\u5728\u7B14\u8BB0\u672C\u4E2D\u5DE5\u4F5C, \u53EA\u9700\u5728\u7EC8\u7AEF\u4E2D\u952E\u5165\u4EE5\u4E0B\u884C:"),np=d(),q(ml.$$.fragment),lp=d(),Rs.c(),kr=d(),Pe=o("p"),Qd=a("\u9ED8\u8BA4\u60C5\u51B5\u4E0B, \u4F7F\u7528\u7684\u5B58\u50A8\u5E93\u5C06\u5728\u60A8\u7684\u547D\u540D\u7A7A\u95F4\u4E2D, \u5E76\u4EE5\u60A8\u8BBE\u7F6E\u7684\u8F93\u51FA\u76EE\u5F55\u547D\u540D, \u56E0\u6B64\u5728\u6211\u4EEC\u7684\u4F8B\u5B50\u4E2D, \u5B83\u5C06\u5728 "),yo=o("code"),Rd=a('"sgugger/bert-finetuned-squad"'),Gd=a(" \u4E2D\u3002\u6211\u4EEC\u53EF\u4EE5\u901A\u8FC7\u4F20\u9012 "),Do=o("code"),Wd=a("hub_model_id"),Ud=a(" \u6765\u8986\u76D6\u5B83; \u4F8B\u5982, \u4E3A\u4E86\u5C06\u6A21\u578B\u63A8\u9001\u5230 "),Co=o("code"),Jd=a("huggingface_course"),Xd=a(" \u7EC4\u7EC7, \u6211\u4EEC\u4F7F\u7528\u4E86 "),To=o("code"),Kd=a('hub_model_id="huggingface_course/bert-finetuned-squad"'),Yd=a(" (\u8FD9\u662F\u6211\u4EEC\u5728\u672C\u8282\u5F00\u5934\u94FE\u63A5\u7684\u6A21\u578B)\u3002"),rp=d(),Ws.c(),qr=d(),Er=o("p"),Zd=a("\u8BF7\u6CE8\u610F, \u5728\u8FDB\u884C\u8BAD\u7EC3\u65F6, \u6BCF\u6B21\u4FDD\u5B58\u6A21\u578B\u65F6 (\u8FD9\u91CC\u662F\u6BCF\u4E2A epoch) \u5B83\u90FD\u4F1A\u5728\u540E\u53F0\u4E0A\u4F20\u5230 Hub\u3002\u8FD9\u6837, \u5982\u6709\u5FC5\u8981, \u4F60\u5C06\u80FD\u591F\u5728\u53E6\u4E00\u53F0\u673A\u5668\u4E0A\u6062\u590D\u8BAD\u7EC3\u3002\u6574\u4E2A\u57F9\u8BAD\u9700\u8981\u4E00\u6BB5\u65F6\u95F4 (\u5728 Titan RTX \u4E0A\u9700\u8981\u4E00\u4E2A\u591A\u5C0F\u65F6), \u56E0\u6B64\u60A8\u53EF\u4EE5\u559D\u676F\u5496\u5561\u6216\u91CD\u8BFB\u8BFE\u7A0B\u4E2D\u60A8\u53D1\u73B0\u5728\u8FDB\u884C\u8FC7\u7A0B\u4E2D\u66F4\u5177\u6311\u6218\u6027\u7684\u90E8\u5206\u5185\u5BB9\u3002\u53E6\u8BF7\u6CE8\u610F, \u4E00\u65E6\u7B2C\u4E00\u4E2A epoch \u5B8C\u6210, \u4F60\u5C06\u770B\u5230\u4E00\u4E9B\u6743\u91CD\u4E0A\u4F20\u5230 Hub, \u4F60\u53EF\u4EE5\u5F00\u59CB\u5728\u5176\u9875\u9762\u4E0A\u4F7F\u7528\u4F60\u7684\u6A21\u578B\u3002"),op=d(),Js.c(),yr=d(),q(hl.$$.fragment),ip=d(),Dr=o("p"),ef=a("\u5F88\u597D! \u4F5C\u4E3A\u6BD4\u8F83, BERT \u6587\u7AE0\u4E2D\u62A5\u544A\u7684\u8BE5\u6A21\u578B\u7684\u57FA\u7EBF\u5206\u6570\u662F 80.8 \u548C 88.5, \u6240\u4EE5\u6211\u4EEC\u5E94\u8BE5\u662F\u6B63\u786E\u7684\u3002"),pp=d(),oe&&oe.c(),Cr=d(),Tr=o("p"),sf=a("\u5728\u8FD9\u4E2A\u9636\u6BB5, \u4F60\u53EF\u4EE5\u4F7F\u7528\u6A21\u578B\u4E2D\u5FC3\u4E0A\u7684\u63A8\u7406\u5C0F\u90E8\u4EF6\u6765\u6D4B\u8BD5\u6A21\u578B\u5E76\u4E0E\u60A8\u7684\u670B\u53CB\u3001\u5BB6\u4EBA\u548C\u6700\u559C\u6B22\u7684\u5BA0\u7269\u5206\u4EAB\u3002\u4F60\u5DF2\u7ECF\u6210\u529F\u5730\u5FAE\u8C03\u4E86\u4E00\u4E2A\u95EE\u7B54\u4EFB\u52A1\u7684\u6A21\u578B \u2014 \u606D\u559C!"),cp=d(),q(Ra.$$.fragment),dp=d(),ie&&ie.c(),Ar=d(),wl=o("h2"),tf=a("\u4F7F\u7528\u5FAE\u8C03\u6A21\u578B"),fp=d(),Ga=o("p"),af=a("\u6211\u4EEC\u5DF2\u7ECF\u5411\u60A8\u5C55\u793A\u4E86\u5982\u4F55\u5C06\u6211\u4EEC\u5728\u6A21\u578B\u4E2D\u5FC3\u5FAE\u8C03\u7684\u6A21\u578B\u4E0E\u63A8\u7406\u5C0F\u90E8\u4EF6\u4E00\u8D77\u4F7F\u7528\u3002\u8981\u5728 "),Ao=o("code"),nf=a("pipeline"),lf=a(" \u4E2D\u672C\u5730\u4F7F\u7528\u5B83, \u4F60\u53EA\u9700\u8981\u6307\u5B9A\u6A21\u578B\u6807\u8BC6\u7B26:"),up=d(),q(gl.$$.fragment),_p=d(),q($l.$$.fragment),mp=d(),Pr=o("p"),rf=a("\u5F88\u68D2! \u6211\u4EEC\u7684\u6A21\u578B\u4E0E\u8BE5\u7BA1\u9053\u7684\u9ED8\u8BA4\u6A21\u578B\u4E00\u6837\u6709\u6548!"),this.h()},l(e){const r=z_('[data-svelte="svelte-1phssyn"]',document.head);c=i(r,"META",{name:!0,content:!0}),r.forEach(s),h=f(e),E(_.$$.fragment,e),v=f(e),T=i(e,"H1",{id:!0});var Po=p(T);$=n(Po,"\u95EE\u7B54"),Po.forEach(s),j=f(e),m.l(e),S=f(e),b=i(e,"P",{});var kt=p(b);k=n(kt,"\u662F\u65F6\u5019\u770B\u95EE\u7B54\u4E86! \u8FD9\u9879\u4EFB\u52A1\u6709\u591A\u79CD\u5F62\u5F0F, \u4F46\u6211\u4EEC\u5C06\u5728\u672C\u8282\u4E2D\u5173\u6CE8\u7684\u4E00\u9879\u79F0\u4E3A"),O=i(kt,"EM",{});var So=p(O);L=n(So,"\u63D0\u53D6"),So.forEach(s),M=n(kt,"\u7684\u95EE\u7B54\u3002\u95EE\u9898\u7684\u7B54\u6848\u5C31\u5728 "),C=i(kt,"EM",{});var Oo=p(C);Q=n(Oo,"\u7ED9\u5B9A\u7684\u6587\u6863"),Oo.forEach(s),z=n(kt," \u4E4B\u4E2D\u3002"),kt.forEach(s),A=f(e),E(N.$$.fragment,e),R=f(e),G=i(e,"P",{});var Wa=p(G);K=n(Wa,"\u6211\u4EEC\u5C06\u4F7F\u7528 "),W=i(Wa,"A",{href:!0,rel:!0});var Sr=p(W);I=n(Sr,"SQuAD \u6570\u636E\u96C6"),Sr.forEach(s),U=n(Wa," \u5FAE\u8C03\u4E00\u4E2ABERT\u6A21\u578B, \u5176\u4E2D\u5305\u62EC\u7FA4\u4F17\u5DE5\u4F5C\u8005\u5BF9\u4E00\u7EC4\u7EF4\u57FA\u767E\u79D1\u6587\u7AE0\u63D0\u51FA\u7684\u95EE\u9898\u3002\u4EE5\u4E0B\u662F\u4E00\u4E2A\u5C0F\u7684\u6D4B\u8BD5\u6837\u4F8B:"),Wa.forEach(s),ae=f(e),J=i(e,"IFRAME",{src:!0,frameborder:!0,height:!0,title:!0,class:!0,allow:!0,sandbox:!0}),p(J).forEach(s),se=f(e),Z=i(e,"IFRAME",{src:!0,frameborder:!0,height:!0,title:!0,class:!0,allow:!0,sandbox:!0}),p(Z).forEach(s),Se=f(e),ne=i(e,"P",{});var Ua=p(ne);Oe=n(Ua,"\u672C\u8282\u4F7F\u7528\u7684\u4EE3\u7801\u5DF2\u7ECF\u4E0A\u4F20\u5230\u4E86Hub\u3002\u4F60\u53EF\u4EE5\u5728 "),V=i(Ua,"A",{href:!0,rel:!0});var Or=p(V);X=n(Or,"\u8FD9\u91CC"),Or.forEach(s),us=n(Ua," \u627E\u5230\u5B83\u5E76\u5C1D\u8BD5\u7528\u5B83\u8FDB\u884C\u9884\u6D4B\u3002"),Ua.forEach(s),xe=f(e),E(we.$$.fragment,e),ge=f(e),$e=i(e,"H2",{id:!0});var Mr=p($e);Je=n(Mr,"\u51C6\u5907\u6570\u636E"),Mr.forEach(s),Me=f(e),fe=i(e,"P",{});var qt=p(fe);Be=n(qt,"\u6700\u5E38\u7528\u4F5C\u62BD\u53D6\u5F0F\u95EE\u7B54\u7684\u5B66\u672F\u57FA\u51C6\u7684\u6570\u636E\u96C6\u662F "),ce=i(qt,"A",{href:!0,rel:!0});var Br=p(ce);sa=n(Br,"SQuAD"),Br.forEach(s),le=n(qt,", \u6240\u4EE5\u8FD9\u5C31\u662F\u6211\u4EEC\u5C06\u5728\u8FD9\u91CC\u4F7F\u7528\u7684\u3002\u8FD8\u6709\u4E00\u4E2A\u66F4\u96BE\u7684 "),_s=i(qt,"A",{href:!0,rel:!0});var Mo=p(_s);At=n(Mo,"SQuAD v2"),Mo.forEach(s),Za=n(qt," \u57FA\u51C6, \u5176\u4E2D\u5305\u62EC\u6CA1\u6709\u7B54\u6848\u7684\u95EE\u9898\u3002\u53EA\u8981\u4F60\u81EA\u5DF1\u7684\u6570\u636E\u96C6\u5305\u542B\u4E0A\u4E0B\u6587\u5217\u3001\u95EE\u9898\u5217\u548C\u7B54\u6848\u5217, \u4F60\u5C31\u5E94\u8BE5\u80FD\u591F\u8C03\u6574\u4EE5\u4E0B\u6B65\u9AA4\u3002"),qt.forEach(s),ta=f(e),je=i(e,"H3",{class:!0});var gp=p(je);Xe=i(gp,"A",{id:!0,class:!0,href:!0});var Pf=p(Xe);Pt=i(Pf,"SPAN",{});var Sf=p(Pt);E(Ie.$$.fragment,Sf),Sf.forEach(s),Pf.forEach(s),en=f(gp),St=i(gp,"SPAN",{});var Of=p(St);Ot=n(Of,"SQuAD \u6570\u636E\u96C6"),Of.forEach(s),gp.forEach(s),aa=f(e),Ke=i(e,"P",{});var $p=p(Ke);Mt=n($p,"\u50CF\u5F80\u5E38\u4E00\u6837, \u6211\u4EEC\u53EA\u9700\u4E00\u6B65\u5C31\u53EF\u4EE5\u4E0B\u8F7D\u548C\u7F13\u5B58\u6570\u636E\u96C6, \u8FD9\u8981\u5F52\u529F\u4E8E "),Bt=i($p,"CODE",{});var Mf=p(Bt);sn=n(Mf,"load_dataset()"),Mf.forEach(s),na=n($p,":"),$p.forEach(s),Ye=f(e),E(Ze.$$.fragment,e),ve=f(e),Xs=i(e,"P",{});var Bf=p(Xs);It=n(Bf,"\u7136\u540E\u6211\u4EEC\u53EF\u4EE5\u67E5\u770B\u8FD9\u4E2A\u5BF9\u8C61\u4EE5, \u4E86\u89E3\u6709\u5173 SQuAD \u6570\u636E\u96C6\u7684\u66F4\u591A\u4FE1\u606F:"),Bf.forEach(s),la=f(e),E(ms.$$.fragment,e),Ks=f(e),E(hs.$$.fragment,e),ra=f(e),ue=i(e,"P",{});var Ja=p(ue);ws=n(Ja,"\u770B\u8D77\u6765\u6211\u4EEC\u62E5\u6709\u6240\u9700\u7684 "),Ys=i(Ja,"CODE",{});var If=p(Ys);be=n(If,"context"),If.forEach(s),tn=n(Ja," \u3001"),gs=i(Ja,"CODE",{});var Ff=p(gs);an=n(Ff,"question"),Ff.forEach(s),nn=n(Ja," \u548C "),$s=i(Ja,"CODE",{});var Lf=p($s);ln=n(Lf,"answers"),Lf.forEach(s),rn=n(Ja," \u5B57\u6BB5, \u6240\u4EE5\u8BA9\u6211\u4EEC\u6253\u5370\u8BAD\u7EC3\u96C6\u7684\u7B2C\u4E00\u4E2A\u5143\u7D20:"),Ja.forEach(s),Zs=f(e),E(bs.$$.fragment,e),oa=f(e),E(es.$$.fragment,e),ss=f(e),te=i(e,"P",{});var We=p(te);Fe=i(We,"CODE",{});var zf=p(Fe);ia=n(zf,"context"),zf.forEach(s),et=n(We," \u548C "),Ft=i(We,"CODE",{});var Nf=p(Ft);pa=n(Nf,"question"),Nf.forEach(s),xs=n(We," \u5B57\u6BB5\u4F7F\u7528\u8D77\u6765\u975E\u5E38\u7B80\u5355\u3002\u4F46\u662F "),st=i(We,"CODE",{});var Hf=p(st);ye=n(Hf,"answers"),Hf.forEach(s),on=n(We," \u5B57\u6BB5\u6709\u70B9\u68D8\u624B, \u56E0\u4E3A\u5B83\u5C06\u5B57\u5178\u4E0E\u4E24\u4E2A\u90FD\u662F\u5217\u8868\u7684\u5B57\u6BB5\u7EC4\u6210\u3002\u8FD9\u662F\u5728\u8BC4\u4F30\u8FC7\u7A0B\u4E2D "),js=i(We,"CODE",{});var Vf=p(js);pn=n(Vf,"squad"),Vf.forEach(s),cn=n(We," \u6307\u6807\u6240\u671F\u671B\u7684\u683C\u5F0F; \u5982\u679C\u4F60\u4F7F\u7528\u7684\u662F\u81EA\u5DF1\u7684\u6570\u636E, \u5219\u4E0D\u5FC5\u62C5\u5FC3\u5C06\u7B54\u6848\u91C7\u7528\u76F8\u540C\u7684\u683C\u5F0F\u3002"),vs=i(We,"CODE",{});var Qf=p(vs);dn=n(Qf,"text"),Qf.forEach(s),fn=n(We," \u5B57\u6BB5\u6BD4\u8F83\u660E\u663E, \u800C "),tt=i(We,"CODE",{});var Rf=p(tt);ks=n(Rf,"answer_start"),Rf.forEach(s),un=n(We," \u5B57\u6BB5\u5305\u542B\u4E0A\u4E0B\u6587\u4E2D\u6BCF\u4E2A\u7B54\u6848\u7684\u8D77\u59CB\u5B57\u7B26\u7D22\u5F15\u3002"),We.forEach(s),Lt=f(e),ke=i(e,"P",{});var bp=p(ke);_n=n(bp,"\u5728\u8BAD\u7EC3\u671F\u95F4, \u53EA\u6709\u4E00\u79CD\u53EF\u80FD\u7684\u7B54\u6848\u3002\u6211\u4EEC\u53EF\u4EE5\u4F7F\u7528 "),at=i(bp,"CODE",{});var Gf=p(at);De=n(Gf,"Dataset.filter()"),Gf.forEach(s),qs=n(bp," \u65B9\u6CD5:"),bp.forEach(s),ca=f(e),E(Le.$$.fragment,e),da=f(e),E(Es.$$.fragment,e),fa=f(e),de=i(e,"P",{});var Wf=p(de);mn=n(Wf,"\u7136\u800C, \u5BF9\u4E8E\u8BC4\u4F30, \u6BCF\u4E2A\u6837\u672C\u90FD\u6709\u51E0\u4E2A\u53EF\u80FD\u7684\u7B54\u6848, \u5B83\u4EEC\u53EF\u80FD\u76F8\u540C\u6216\u4E0D\u540C:"),Wf.forEach(s),nt=f(e),E(ys.$$.fragment,e),ua=f(e),E(ze.$$.fragment,e),_a=f(e),lt=i(e,"P",{});var Uf=p(lt);zt=n(Uf,"\u6211\u4EEC\u4E0D\u4F1A\u6DF1\u5165\u7814\u7A76\u8BC4\u4F30\u811A\u672C, \u56E0\u4E3A\u5B83\u90FD\u4F1A\u88AB\u4E00\u4E2A \u{1F917} Datasets \u6307\u6807\u5305\u88F9\u8D77\u6765, \u4F46\u7B80\u77ED\u7684\u7248\u672C\u662F\u4E00\u4E9B\u95EE\u9898\u6709\u51E0\u4E2A\u53EF\u80FD\u7684\u7B54\u6848, \u8FD9\u4E2A\u811A\u672C\u4F1A\u5C06\u9884\u6D4B\u7684\u7B54\u6848\u4E0E\u6240\u6709\u200B\u200B\u7684\u53EF\u63A5\u53D7\u7684\u7B54\u6848\u5E76\u83B7\u5F97\u6700\u9AD8\u5206\u3002\u4F8B\u5982, \u6211\u4EEC\u770B\u4E00\u4E0B\u7D22\u5F15 2 \u5904\u7684\u6837\u672Ce:"),Uf.forEach(s),ma=f(e),E(Ds.$$.fragment,e),ha=f(e),E(_e.$$.fragment,e),wa=f(e),ts=i(e,"P",{});var Jf=p(ts);hn=n(Jf,"\u6211\u4EEC\u53EF\u4EE5\u770B\u5230, \u7B54\u6848\u786E\u5B9E\u53EF\u4EE5\u662F\u6211\u4EEC\u4E4B\u524D\u770B\u5230\u7684\u4E09\u79CD\u53EF\u80FD\u6027\u4E4B\u4E00\u3002"),Jf.forEach(s),ga=f(e),Ne=i(e,"H3",{id:!0});var Xf=p(Ne);wn=n(Xf,"\u5904\u7406\u8BAD\u7EC3\u6570\u636E"),Xf.forEach(s),$a=f(e),E(as.$$.fragment,e),Cs=f(e),rt=i(e,"P",{});var Kf=p(rt);ba=n(Kf,"\u8BA9\u6211\u4EEC\u4ECE\u9884\u5904\u7406\u8BAD\u7EC3\u6570\u636E\u5F00\u59CB\u3002\u56F0\u96BE\u7684\u90E8\u5206\u5C06\u662F\u4E3A\u95EE\u9898\u7684\u7B54\u6848\u751F\u6210\u6807\u7B7E, \u8FD9\u5C06\u662F\u4E0E\u4E0A\u4E0B\u6587\u4E2D\u7684\u7B54\u6848\u76F8\u5BF9\u5E94\u7684\u6807\u8BB0\u7684\u5F00\u59CB\u548C\u7ED3\u675F\u4F4D\u7F6E\u3002"),Kf.forEach(s),ns=f(e),Ts=i(e,"P",{});var Yf=p(Ts);ot=n(Yf,"\u4F46\u662F, \u6211\u4EEC\u4E0D\u8981\u8D85\u8D8A\u81EA\u5DF1\u3002\u9996\u5148, \u6211\u4EEC\u9700\u8981\u4F7F\u7528\u5206\u8BCD\u5668\u5C06\u8F93\u5165\u4E2D\u7684\u6587\u672C\u8F6C\u6362\u4E3A\u6A21\u578B\u53EF\u4EE5\u7406\u89E3\u7684 ID:"),Yf.forEach(s),xa=f(e),E(ls.$$.fragment,e),rs=f(e),me=i(e,"P",{});var Xa=p(me);ee=n(Xa,"\u5982\u524D\u6240\u8FF0, \u6211\u4EEC\u5C06\u5BF9 BERT \u6A21\u578B\u8FDB\u884C\u5FAE\u8C03, \u4F46\u4F60\u53EF\u4EE5\u4F7F\u7528\u4EFB\u4F55\u5176\u4ED6\u6A21\u578B\u7C7B\u578B, \u53EA\u8981\u5B83\u5B9E\u73B0\u4E86\u5FEB\u901F\u6807\u8BB0\u5668\u5373\u53EF\u3002\u4F60\u53EF\u4EE5\u5728 "),As=i(Xa,"A",{href:!0,rel:!0});var Zf=p(As);Nt=n(Zf,"this big table"),Zf.forEach(s),gn=n(Xa," \u4E2D\u770B\u5230\u6240\u6709\u5FEB\u901F\u7248\u672C\u7684\u67B6\u6784, \u5E76\u68C0\u67E5\u4F60\u6B63\u5728\u4F7F\u7528\u7684 "),Ht=i(Xa,"CODE",{});var eu=p(Ht);Vt=n(eu,"tokenizer"),eu.forEach(s),$n=n(Xa," \u5BF9\u8C61\u786E\u5B9E\u7531 \u{1F917} Tokenizers \u652F\u6301, \u4F60\u53EF\u4EE5\u67E5\u770B\u5B83\u7684 "),Qt=i(Xa,"CODE",{});var su=p(Qt);Rt=n(su,"is_fast"),su.forEach(s),bn=n(Xa," \u5C5E\u6027:"),Xa.forEach(s),ja=f(e),E(He.$$.fragment,e),va=f(e),E(Ps.$$.fragment,e),it=f(e),pt=i(e,"P",{});var tu=p(pt);xn=n(tu,"\u6211\u4EEC\u53EF\u4EE5\u5C06\u95EE\u9898\u548C\u4E0A\u4E0B\u6587\u4E00\u8D77\u4F20\u9012\u7ED9\u6211\u4EEC\u7684\u6807\u8BB0\u5668, \u5B83\u4F1A\u6B63\u786E\u63D2\u5165\u7279\u6B8A\u6807\u8BB0\u4EE5\u5F62\u6210\u5982\u4E0B\u53E5\u5B50:"),tu.forEach(s),ct=f(e),E(Ss.$$.fragment,e),ka=f(e),os=i(e,"P",{});var au=p(os);jn=n(au,"\u8BA9\u6211\u4EEC\u4ED4\u7EC6\u68C0\u67E5\u4E00\u4E0B:"),au.forEach(s),qa=f(e),E(is.$$.fragment,e),qe=f(e),E(Os.$$.fragment,e),dt=f(e),ft=i(e,"P",{});var nu=p(ft);vn=n(nu,"\u7136\u540E\u6807\u7B7E\u5C06\u6210\u4E3A\u5F00\u59CB\u548C\u7ED3\u675F\u7B54\u6848\u7684\u6807\u8BB0\u7684\u7D22\u5F15, \u5E76\u4E14\u6A21\u578B\u7684\u4EFB\u52A1\u662F\u9884\u6D4B\u8F93\u5165\u4E2D\u6BCF\u4E2A\u6807\u8BB0\u7684\u5F00\u59CB\u548C\u7ED3\u675F logit, \u7406\u8BBA\u6807\u7B7E\u5982\u4E0B:"),nu.forEach(s),ps=f(e),Ee=i(e,"DIV",{class:!0});var xp=p(Ee);Ms=i(xp,"IMG",{class:!0,src:!0,alt:!0}),Ea=f(xp),u=i(xp,"IMG",{class:!0,src:!0,alt:!0}),xp.forEach(s),kn=f(e),he=i(e,"P",{});var Ir=p(he);Tl=n(Ir,"\u5728\u8FD9\u79CD\u60C5\u51B5\u4E0B, \u4E0A\u4E0B\u6587\u4E0D\u4F1A\u592A\u957F, \u4F46\u662F\u6570\u636E\u96C6\u4E2D\u7684\u4E00\u4E9B\u793A\u4F8B\u7684\u4E0A\u4E0B\u6587\u5F88\u957F, \u4F1A\u8D85\u8FC7\u6211\u4EEC\u8BBE\u7F6E\u7684\u6700\u5927\u957F\u5EA6(\u5728\u8FD9\u79CD\u60C5\u51B5\u4E0B\u4E3A 384)\u3002\u6B63\u5982\u6211\u4EEC\u5728 "),Gt=i(Ir,"A",{href:!0});var lu=p(Gt);Al=n(lu,"\u7B2C\u516D\u7AE0"),lu.forEach(s),Ce=n(Ir," \u4E2D\u6240\u770B\u5230\u7684, \u5F53\u6211\u4EEC\u63A2\u7D22 "),ya=i(Ir,"CODE",{});var ru=p(ya);Pl=n(ru,"question-answering"),ru.forEach(s),Sl=n(Ir," \u7BA1\u9053\u7684\u5185\u90E8\u7ED3\u6784\u65F6, \u6211\u4EEC\u5C06\u901A\u8FC7\u4ECE\u6211\u4EEC\u7684\u6570\u636E\u96C6\u7684\u4E00\u4E2A\u6837\u672C\u4E2D\u521B\u5EFA\u51E0\u4E2A\u8BAD\u7EC3\u7279\u5F81\u6765\u5904\u7406\u957F\u4E0A\u4E0B\u6587, \u5B83\u4EEC\u4E4B\u95F4\u6709\u4E00\u4E2A\u6ED1\u52A8\u7A97\u53E3\u3002"),Ir.forEach(s),qn=f(e),Wt=i(e,"P",{});var ou=p(Wt);Da=n(ou,"\u8981\u4F7F\u7528\u5F53\u524D\u793A\u4F8B\u67E5\u770B\u5176\u5DE5\u4F5C\u539F\u7406, \u6211\u4EEC\u53EF\u4EE5\u5C06\u957F\u5EA6\u9650\u5236\u4E3A 100, \u5E76\u4F7F\u7528 50 \u4E2A\u6807\u8BB0\u7684\u6ED1\u52A8\u7A97\u53E3\u3002\u63D0\u9192\u4E00\u4E0B, \u6211\u4EEC\u4F7F\u7528:"),ou.forEach(s),En=f(e),Y=i(e,"UL",{});var Ka=p(Y);Ut=i(Ka,"LI",{});var of=p(Ut);Ca=i(of,"CODE",{});var iu=p(Ca);Ol=n(iu,"max_length"),iu.forEach(s),Ml=n(of," \u8BBE\u7F6E\u6700\u5927\u957F\u5EA6 (\u6B64\u5904\u4E3A 100)"),of.forEach(s),Bl=f(Ka),Ve=i(Ka,"LI",{});var pf=p(Ve);Ta=i(pf,"CODE",{});var pu=p(Ta);Il=n(pu,'truncation="only_second"'),pu.forEach(s),cs=n(pf," \u7528\u4E8E\u5F53\u5E26\u6709\u4E0A\u4E0B\u6587\u7684\u95EE\u9898\u592A\u957F\u65F6, \u622A\u65AD\u4E0A\u4E0B\u6587t (\u4F4D\u4E8E\u7B2C\u4E8C\u4E2A\u4F4D\u7F6E)"),pf.forEach(s),Fl=f(Ka),Jt=i(Ka,"LI",{});var cf=p(Jt);Aa=i(cf,"CODE",{});var cu=p(Aa);Ll=n(cu,"stride"),cu.forEach(s),ut=n(cf," \u8BBE\u7F6E\u4E24\u4E2A\u8FDE\u7EED\u5757\u4E4B\u95F4\u7684\u91CD\u53E0\u6807\u8BB0\u6570 (\u8FD9\u91CC\u4E3A 50)"),cf.forEach(s),zl=f(Ka),Xt=i(Ka,"LI",{});var df=p(Xt);Pa=i(df,"CODE",{});var du=p(Pa);Nl=n(du,"return_overflowing_tokens=True"),du.forEach(s),_t=n(df," \u8BA9\u6807\u8BB0\u5668\u77E5\u9053\u6211\u4EEC\u60F3\u8981\u6EA2\u51FA\u7684\u6807\u8BB0"),df.forEach(s),Ka.forEach(s),Kt=f(e),E(mt.$$.fragment,e),Qe=f(e),E(ht.$$.fragment,e),yn=f(e),Re=i(e,"P",{});var Fr=p(Re);wt=n(Fr,"\u5982\u6211\u4EEC\u6240\u89C1, \u6211\u4EEC\u7684\u793A\u4F8B\u88AB\u5206\u6210\u56DB\u4E2A\u8F93\u5165, \u6BCF\u4E2A\u8F93\u5165\u90FD\u5305\u542B\u95EE\u9898\u548C\u4E0A\u4E0B\u6587\u7684\u4E00\u90E8\u5206\u3002 \u8BF7\u6CE8\u610F, \u95EE\u9898\u7684\u7B54\u6848 (\u201CBernadette Soubirous\u201D) \u4EC5\u51FA\u73B0\u5728\u7B2C\u4E09\u4E2A\u4E5F\u662F\u6700\u540E\u4E00\u4E2A\u8F93\u5165\u4E2D, \u56E0\u6B64\u901A\u8FC7\u4EE5\u8FD9\u79CD\u65B9\u5F0F\u5904\u7406\u957F\u4E0A\u4E0B\u6587, \u6211\u4EEC\u5C06\u521B\u5EFA\u4E00\u4E9B\u7B54\u6848\u4E0D\u5305\u542B\u5728\u4E0A\u4E0B\u6587\u4E2D\u7684\u8BAD\u7EC3\u793A\u4F8B\u3002\u5BF9\u4E8E\u8FD9\u4E9B\u793A\u4F8B, \u6807\u7B7E\u5C06\u662F "),Sa=i(Fr,"CODE",{});var fu=p(Sa);Hl=n(fu,"start_position = end_position = 0"),fu.forEach(s),Vl=n(Fr," (\u6240\u4EE5\u6211\u4EEC\u9884\u6D4B "),Oa=i(Fr,"CODE",{});var uu=p(Oa);re=n(uu,"[CLS]"),uu.forEach(s),Ql=n(Fr," \u6807\u8BB0)\u3002\u6211\u4EEC\u8FD8\u5C06\u5728\u7B54\u6848\u88AB\u622A\u65AD\u7684\u4E0D\u5E78\u60C5\u51B5\u4E0B\u8BBE\u7F6E\u8FD9\u4E9B\u6807\u7B7E, \u4EE5\u4FBF\u6211\u4EEC\u53EA\u6709\u5B83\u7684\u5F00\u59CB(\u6216\u7ED3\u675F)\u3002\u5BF9\u4E8E\u7B54\u6848\u5B8C\u5168\u5728\u4E0A\u4E0B\u6587\u4E2D\u7684\u793A\u4F8B, \u6807\u7B7E\u5C06\u662F\u7B54\u6848\u5F00\u59CB\u7684\u6807\u8BB0\u7684\u7D22\u5F15\u548C\u7B54\u6848\u7ED3\u675F\u7684\u6807\u8BB0\u7684\u7D22\u5F15\u3002"),Fr.forEach(s),Dn=f(e),Ge=i(e,"P",{});var Lr=p(Ge);Rl=n(Lr,"\u6570\u636E\u96C6\u4E3A\u6211\u4EEC\u63D0\u4F9B\u4E86\u4E0A\u4E0B\u6587\u4E2D\u7B54\u6848\u7684\u5F00\u59CB\u5B57\u7B26, \u901A\u8FC7\u6DFB\u52A0\u7B54\u6848\u7684\u957F\u5EA6, \u6211\u4EEC\u53EF\u4EE5\u627E\u5230\u4E0A\u4E0B\u6587\u4E2D\u7684\u7ED3\u675F\u5B57\u7B26\u3002\u8981\u5C06\u5B83\u4EEC\u6620\u5C04\u5230\u4EE4\u724C\u7D22\u5F15, \u6211\u4EEC\u5C06\u9700\u8981\u4F7F\u7528\u6211\u4EEC\u5728 "),Yt=i(Lr,"A",{href:!0});var _u=p(Yt);Gl=n(_u,"\u7B2C\u516D\u7AE0"),_u.forEach(s),Wl=n(Lr," \u4E2D\u7814\u7A76\u7684\u504F\u79FB\u6620\u5C04\u3002\u6211\u4EEC\u53EF\u4EE5\u8BA9\u6807\u8BB0\u5668\u901A\u8FC7\u4F20\u9012 "),ds=i(Lr,"CODE",{});var mu=p(ds);Ul=n(mu,"return_offsets_mapping=True"),mu.forEach(s),Jl=n(Lr," \u6765\u8FD4\u56DE\u8FD9\u4E9B\u503C:"),Lr.forEach(s),Cn=f(e),E(Tn.$$.fragment,e),Bo=f(e),E(An.$$.fragment,e),Io=f(e),gt=i(e,"P",{});var zr=p(gt);Ip=n(zr,"\u5982\u6211\u4EEC\u6240\u89C1, \u6211\u4EEC\u53D6\u56DE\u4E86\u901A\u5E38\u7684\u8F93\u5165 ID\u3001\u4EE4\u724C\u7C7B\u578B ID \u548C\u6CE8\u610F\u63A9\u7801, \u4EE5\u53CA\u6211\u4EEC\u9700\u8981\u7684\u504F\u79FB\u6620\u5C04\u548C\u4E00\u4E2A\u989D\u5916\u7684\u952E, "),Gr=i(zr,"CODE",{});var hu=p(Gr);Fp=n(hu,"overflow_to_sample_mapping"),hu.forEach(s),Lp=n(zr,"\u3002\u5F53\u6211\u4EEC\u540C\u65F6\u6807\u8BB0\u591A\u4E2A\u6587\u672C\u65F6, \u76F8\u5E94\u7684\u503C\u5C06\u5BF9\u6211\u4EEC\u6709\u7528(\u6211\u4EEC\u5E94\u8BE5\u8FD9\u6837\u505A\u4EE5\u53D7\u76CA\u4E8E\u6211\u4EEC\u7684\u6807\u8BB0\u5668\u7531 Rust \u652F\u6301\u7684\u4E8B\u5B9E)\u3002\u7531\u4E8E\u4E00\u4E2A\u6837\u672C\u53EF\u4EE5\u63D0\u4F9B\u591A\u4E2A\u7279\u5F81, \u56E0\u6B64\u5B83\u5C06\u6BCF\u4E2A\u7279\u5F81\u6620\u5C04\u5230\u5176\u6765\u6E90\u7684\u793A\u4F8B\u3002\u56E0\u4E3A\u8FD9\u91CC\u6211\u4EEC\u53EA\u6807\u8BB0\u4E86\u4E00\u4E2A\u4F8B\u5B50, \u6211\u4EEC\u5F97\u5230\u4E00\u4E2A "),Wr=i(zr,"CODE",{});var wu=p(Wr);zp=n(wu,"0"),wu.forEach(s),Np=n(zr," \u7684\u5217\u8868:"),zr.forEach(s),Fo=f(e),E(Pn.$$.fragment,e),Lo=f(e),E(Sn.$$.fragment,e),zo=f(e),Xl=i(e,"P",{});var gu=p(Xl);Hp=n(gu,"\u4F46\u662F, \u5982\u679C\u6211\u4EEC\u6807\u8BB0\u66F4\u591A\u793A\u4F8B, \u8FD9\u5C06\u53D8\u5F97\u66F4\u52A0\u6709\u7528:"),gu.forEach(s),No=f(e),E(On.$$.fragment,e),Ho=f(e),E(Mn.$$.fragment,e),Vo=f(e),Kl=i(e,"P",{});var $u=p(Kl);Vp=n($u,"\u6B63\u5982\u6211\u4EEC\u6240\u770B\u5230\u7684, \u524D\u4E09\u4E2A\u793A\u4F8B (\u5728\u8BAD\u7EC3\u96C6\u4E2D\u7684\u7D22\u5F15 2\u30013 \u548C 4 \u5904) \u6BCF\u4E2A\u90FD\u7ED9\u51FA\u4E86\u56DB\u4E2A\u7279\u5F81, \u6700\u540E\u4E00\u4E2A\u793A\u4F8B(\u5728\u8BAD\u7EC3\u96C6\u4E2D\u7684\u7D22\u5F15 5 \u5904) \u7ED9\u51FA\u4E86 7 \u4E2A\u7279\u5F81\u3002"),$u.forEach(s),Qo=f(e),Yl=i(e,"P",{});var bu=p(Yl);Qp=n(bu,"\u6B64\u4FE1\u606F\u5C06\u6709\u52A9\u4E8E\u5C06\u6211\u4EEC\u83B7\u5F97\u7684\u6BCF\u4E2A\u7279\u5F81\u6620\u5C04\u5230\u5176\u76F8\u5E94\u7684\u6807\u7B7E\u3002\u5982\u524D\u6240\u8FF0, \u8FD9\u4E9B\u6807\u7B7E\u662F:"),bu.forEach(s),Ro=f(e),Ma=i(e,"UL",{});var jp=p(Ma);Zl=i(jp,"LI",{});var ff=p(Zl);Ur=i(ff,"CODE",{});var xu=p(Ur);Rp=n(xu,"(0, 0)"),xu.forEach(s),Gp=n(ff," \u5982\u679C\u7B54\u6848\u4E0D\u5728\u4E0A\u4E0B\u6587\u7684\u76F8\u5E94\u8303\u56F4\u5185"),ff.forEach(s),Wp=f(jp),$t=i(jp,"LI",{});var Dl=p($t);Jr=i(Dl,"CODE",{});var ju=p(Jr);Up=n(ju,"(start_position, end_position)"),ju.forEach(s),Jp=n(Dl," \u5982\u679C\u7B54\u6848\u5728\u4E0A\u4E0B\u6587\u7684\u76F8\u5E94\u8303\u56F4\u5185, \u5219 "),Xr=i(Dl,"CODE",{});var vu=p(Xr);Xp=n(vu,"start_position"),vu.forEach(s),Kp=n(Dl," \u662F\u7B54\u6848\u5F00\u5934\u7684\u6807\u8BB0\u7D22\u5F15 (\u5728\u8F93\u5165 ID \u4E2D), \u5E76\u4E14 "),Kr=i(Dl,"CODE",{});var ku=p(Kr);Yp=n(ku,"end_position"),ku.forEach(s),Zp=n(Dl," \u662F\u7B54\u6848\u7ED3\u675F\u7684\u6807\u8BB0\u7684\u7D22\u5F15 (\u5728\u8F93\u5165 ID \u4E2D)\u3002"),Dl.forEach(s),jp.forEach(s),Go=f(e),bt=i(e,"P",{});var Nr=p(bt);ec=n(Nr,"\u4E3A\u4E86\u786E\u5B9A\u662F\u54EA\u79CD\u60C5\u51B5\u4EE5\u53CA\u6807\u8BB0\u7684\u4F4D\u7F6E, \u4EE5\u53CA(\u5982\u679C\u76F8\u5173\u7684\u8BDD)\u6807\u8BB0\u7684\u4F4D\u7F6E, \u6211\u4EEC\u9996\u5148\u5728\u8F93\u5165 ID \u4E2D\u627E\u5230\u5F00\u59CB\u548C\u7ED3\u675F\u4E0A\u4E0B\u6587\u7684\u7D22\u5F15\u3002\u6211\u4EEC\u53EF\u4EE5\u4F7F\u7528\u6807\u8BB0\u7C7B\u578B ID \u6765\u6267\u884C\u6B64\u64CD\u4F5C, \u4F46\u7531\u4E8E\u8FD9\u4E9B ID \u4E0D\u4E00\u5B9A\u5B58\u5728\u4E8E\u6240\u6709\u6A21\u578B\u4E2D (\u4F8B\u5982, DistilBERT \u4E0D\u9700\u8981\u5B83\u4EEC), \u6211\u4EEC\u5C06\u6539\u4E3A\u4F7F\u7528\u6211\u4EEC\u7684\u6807\u8BB0\u5668\u8FD4\u56DE\u7684 "),Yr=i(Nr,"CODE",{});var qu=p(Yr);sc=n(qu,"BatchEncoding"),qu.forEach(s),tc=n(Nr," \u7684 "),Zr=i(Nr,"CODE",{});var Eu=p(Zr);ac=n(Eu,"sequence_ids()"),Eu.forEach(s),nc=n(Nr," \u65B9\u6CD5\u3002"),Nr.forEach(s),Wo=f(e),Ba=i(e,"P",{});var vp=p(Ba);lc=n(vp,"\u4E00\u65E6\u6211\u4EEC\u6709\u4E86\u8FD9\u4E9B\u6807\u8BB0\u7D22\u5F15, \u6211\u4EEC\u5C31\u4F1A\u67E5\u770B\u76F8\u5E94\u7684\u504F\u79FB\u91CF, \u5B83\u4EEC\u662F\u4E24\u4E2A\u6574\u6570\u7684\u5143\u7EC4, \u8868\u793A\u539F\u59CB\u4E0A\u4E0B\u6587\u4E2D\u7684\u5B57\u7B26\u8303\u56F4\u3002\u56E0\u6B64, \u6211\u4EEC\u53EF\u4EE5\u68C0\u6D4B\u6B64\u7279\u5F81\u4E2D\u7684\u4E0A\u4E0B\u6587\u5757\u662F\u5728\u7B54\u6848\u4E4B\u540E\u5F00\u59CB\u8FD8\u662F\u5728\u7B54\u6848\u5F00\u59CB\u4E4B\u524D\u7ED3\u675F(\u5728\u8FD9\u79CD\u60C5\u51B5\u4E0B, \u6807\u7B7E\u662F "),eo=i(vp,"CODE",{});var yu=p(eo);rc=n(yu,"(0, 0)"),yu.forEach(s),oc=n(vp,")\u3002\u5982\u679C\u4E0D\u662F\u8FD9\u6837, \u6211\u4EEC\u5FAA\u73AF\u67E5\u627E\u7B54\u6848\u7684\u7B2C\u4E00\u4E2A\u548C\u6700\u540E\u4E00\u4E2A\u6807\u8BB0:"),vp.forEach(s),Uo=f(e),E(Bn.$$.fragment,e),Jo=f(e),E(In.$$.fragment,e),Xo=f(e),Ia=i(e,"P",{});var kp=p(Ia);ic=n(kp,"\u8BA9\u6211\u4EEC\u770B\u4E00\u4E9B\u7ED3\u679C\u6765\u9A8C\u8BC1\u6211\u4EEC\u7684\u65B9\u6CD5\u662F\u5426\u6B63\u786E\u3002\u5BF9\u4E8E\u6211\u4EEC\u53D1\u73B0\u7684\u7B2C\u4E00\u4E2A\u7279\u5F81, \u6211\u4EEC\u5C06 "),so=i(kp,"CODE",{});var Du=p(so);pc=n(Du,"(83, 85)"),Du.forEach(s),cc=n(kp," \u4F5C\u4E3A\u6807\u7B7E, \u8BA9\u6211\u4EEC\u5C06\u7406\u8BBA\u7B54\u6848\u4E0E\u4ECE 83 \u5230 85 (\u5305\u62EC)\u7684\u6807\u8BB0\u89E3\u7801\u8303\u56F4\u8FDB\u884C\u6BD4\u8F83:"),kp.forEach(s),Ko=f(e),E(Fn.$$.fragment,e),Yo=f(e),E(Ln.$$.fragment,e),Zo=f(e),Fa=i(e,"P",{});var qp=p(Fa);dc=n(qp,"\u6240\u4EE5\u8FD9\u662F\u4E00\u573A\u6BD4\u8D5B! \u73B0\u5728\u8BA9\u6211\u4EEC\u68C0\u67E5\u7D22\u5F15 4, \u6211\u4EEC\u5C06\u6807\u7B7E\u8BBE\u7F6E\u4E3A "),to=i(qp,"CODE",{});var Cu=p(to);fc=n(Cu,"(0, 0)"),Cu.forEach(s),uc=n(qp,", \u8FD9\u610F\u5473\u7740\u7B54\u6848\u4E0D\u5728\u8BE5\u529F\u80FD\u7684\u4E0A\u4E0B\u6587\u5757\u4E2D"),qp.forEach(s),ei=f(e),E(zn.$$.fragment,e),si=f(e),E(Nn.$$.fragment,e),ti=f(e),er=i(e,"P",{});var Tu=p(er);_c=n(Tu,"\u4E8B\u5B9E\u4E0A, \u6211\u4EEC\u5728\u4E0A\u4E0B\u6587\u4E2D\u770B\u4E0D\u5230\u7B54\u6848\u3002"),Tu.forEach(s),ai=f(e),E(La.$$.fragment,e),ni=f(e),sr=i(e,"P",{});var Au=p(sr);mc=n(Au,"\u73B0\u5728\u6211\u4EEC\u5DF2\u7ECF\u9010\u6B65\u4E86\u89E3\u4E86\u5982\u4F55\u9884\u5904\u7406\u6211\u4EEC\u7684\u8BAD\u7EC3\u6570\u636E, \u6211\u4EEC\u53EF\u4EE5\u5C06\u5176\u5206\u7EC4\u5230\u4E00\u4E2A\u51FD\u6570\u4E2D, \u6211\u4EEC\u5C06\u5E94\u7528\u4E8E\u6574\u4E2A\u8BAD\u7EC3\u6570\u636E\u96C6\u3002\u6211\u4EEC\u4F1A\u5C06\u6BCF\u4E2A\u7279\u5F81\u586B\u5145\u5230\u6211\u4EEC\u8BBE\u7F6E\u7684\u6700\u5927\u957F\u5EA6, \u56E0\u4E3A\u5927\u591A\u6570\u4E0A\u4E0B\u6587\u4F1A\u5F88\u957F (\u5E76\u4E14\u76F8\u5E94\u7684\u6837\u672C\u5C06\u88AB\u5206\u6210\u51E0\u4E2A\u7279\u5F81), \u6240\u4EE5\u5728\u8FD9\u91CC\u5E94\u7528\u52A8\u6001\u586B\u5145\u6CA1\u6709\u771F\u6B63\u7684\u597D\u5904:"),Au.forEach(s),li=f(e),E(Hn.$$.fragment,e),ri=f(e),tr=i(e,"P",{});var Pu=p(tr);hc=n(Pu,"\u8BF7\u6CE8\u610F, \u6211\u4EEC\u5B9A\u4E49\u4E86\u4E24\u4E2A\u5E38\u6570\u6765\u786E\u5B9A\u4F7F\u7528\u7684\u6700\u5927\u957F\u5EA6\u4EE5\u53CA\u6ED1\u52A8\u7A97\u53E3\u7684\u957F\u5EA6, \u5E76\u4E14\u6211\u4EEC\u5728\u6807\u8BB0\u5316\u4E4B\u524D\u6DFB\u52A0\u4E86\u4E00\u70B9\u6E05\u7406: SQuAD \u6570\u636E\u96C6\u4E2D\u7684\u4E00\u4E9B\u95EE\u9898\u5728\u5F00\u5934\u6709\u989D\u5916\u7684\u7A7A\u683C, \u5E76\u4E14\u4E0D\u6DFB\u52A0\u4EFB\u4F55\u5185\u5BB9\u7684\u7ED3\u5C3E (\u5982\u679C\u4F60\u4F7F\u7528\u50CF RoBERTa \u8FD9\u6837\u7684\u6A21\u578B, \u5219\u5728\u6807\u8BB0\u5316\u65F6\u4F1A\u5360\u7528\u7A7A\u95F4), \u56E0\u6B64\u6211\u4EEC\u5220\u9664\u4E86\u90A3\u4E9B\u989D\u5916\u7684\u7A7A\u683C\u3002"),Pu.forEach(s),oi=f(e),xt=i(e,"P",{});var Hr=p(xt);wc=n(Hr,"\u4E3A\u4E86\u5C06\u6B64\u51FD\u6570\u5E94\u7528\u4E8E\u6574\u4E2A\u8BAD\u7EC3\u96C6, \u6211\u4EEC\u4F7F\u7528 "),ao=i(Hr,"CODE",{});var Su=p(ao);gc=n(Su,"Dataset.map()"),Su.forEach(s),$c=n(Hr," \u65B9\u6CD5\u4E0E "),no=i(Hr,"CODE",{});var Ou=p(no);bc=n(Ou,"batched=True"),Ou.forEach(s),xc=n(Hr," \u6807\u5FD7\u3002\u8FD9\u662F\u5FC5\u8981\u7684, \u56E0\u4E3A\u6211\u4EEC\u6B63\u5728\u66F4\u6539\u6570\u636E\u96C6\u7684\u957F\u5EA6(\u56E0\u4E3A\u4E00\u4E2A\u793A\u4F8B\u53EF\u4EE5\u63D0\u4F9B\u591A\u4E2A\u8BAD\u7EC3\u7279\u5F81):"),Hr.forEach(s),ii=f(e),E(Vn.$$.fragment,e),pi=f(e),E(Qn.$$.fragment,e),ci=f(e),ar=i(e,"P",{});var Mu=p(ar);jc=n(Mu,"\u6B63\u5982\u6211\u4EEC\u6240\u89C1, \u9884\u5904\u7406\u589E\u52A0\u4E86\u5927\u7EA6 1,000 \u4E2A\u7279\u5F81\u3002\u6211\u4EEC\u7684\u8BAD\u7EC3\u96C6\u73B0\u5728\u53EF\u4EE5\u4F7F\u7528\u4E86\u2014 \u8BA9\u6211\u4EEC\u6DF1\u5165\u7814\u7A76\u9A8C\u8BC1\u96C6\u7684\u9884\u5904\u7406!"),Mu.forEach(s),di=f(e),Rn=i(e,"H3",{id:!0});var Bu=p(Rn);vc=n(Bu,"\u5904\u7406\u9A8C\u8BC1\u6570\u636E"),Bu.forEach(s),fi=f(e),nr=i(e,"P",{});var Iu=p(nr);kc=n(Iu,"\u9884\u5904\u7406\u9A8C\u8BC1\u6570\u636E\u4F1A\u7A0D\u5FAE\u5BB9\u6613\u4E00\u4E9B, \u56E0\u4E3A\u6211\u4EEC\u4E0D\u9700\u8981\u751F\u6210\u6807\u7B7E(\u9664\u975E\u6211\u4EEC\u60F3\u8BA1\u7B97\u9A8C\u8BC1\u635F\u5931, \u4F46\u8FD9\u4E2A\u6570\u5B57\u5E76\u4E0D\u80FD\u771F\u6B63\u5E2E\u52A9\u6211\u4EEC\u7406\u89E3\u6A21\u578B\u6709\u591A\u597D)\u3002\u771F\u6B63\u7684\u4E50\u8DA3\u662F\u5C06\u6A21\u578B\u7684\u9884\u6D4B\u89E3\u91CA\u4E3A\u539F\u59CB\u4E0A\u4E0B\u6587\u7684\u8DE8\u5EA6\u3002\u4E3A\u6B64, \u6211\u4EEC\u53EA\u9700\u8981\u5B58\u50A8\u504F\u79FB\u6620\u5C04\u548C\u67D0\u79CD\u65B9\u5F0F\u6765\u5C06\u6BCF\u4E2A\u521B\u5EFA\u7684\u7279\u5F81\u4E0E\u5B83\u6765\u81EA\u7684\u539F\u59CB\u793A\u4F8B\u76F8\u5339\u914D\u3002\u7531\u4E8E\u539F\u59CB\u6570\u636E\u96C6\u4E2D\u6709\u4E00\u4E2A ID \u5217, \u6211\u4EEC\u5C06\u4F7F\u7528\u8BE5 ID\u3002"),Iu.forEach(s),ui=f(e),jt=i(e,"P",{});var Vr=p(jt);qc=n(Vr,"\u6211\u4EEC\u5C06\u5728\u8FD9\u91CC\u6DFB\u52A0\u7684\u552F\u4E00\u5185\u5BB9\u662F\u5BF9\u504F\u79FB\u6620\u5C04\u7684\u4E00\u70B9\u70B9\u6E05\u7406\u3002\u5B83\u4EEC\u5C06\u5305\u542B\u95EE\u9898\u548C\u4E0A\u4E0B\u6587\u7684\u504F\u79FB\u91CF, \u4F46\u662F\u4E00\u65E6\u6211\u4EEC\u8FDB\u5165\u540E\u5904\u7406\u9636\u6BB5, \u6211\u4EEC\u5C06\u65E0\u6CD5\u77E5\u9053\u8F93\u5165 ID \u7684\u54EA\u4E00\u90E8\u5206\u5BF9\u5E94\u4E8E\u4E0A\u4E0B\u6587\u4EE5\u53CA\u54EA\u4E00\u90E8\u5206\u662F\u95EE\u9898(\u6211\u4EEC\u4F7F\u7528\u7684 "),lo=i(Vr,"CODE",{});var Fu=p(lo);Ec=n(Fu,"sequence_ids()"),Fu.forEach(s),yc=n(Vr," \u65B9\u6CD5\u4EC5\u53EF\u7528\u4E8E\u6807\u8BB0\u5668\u7684\u8F93\u51FA)\u3002\u56E0\u6B64, \u6211\u4EEC\u5C06\u4E0E\u95EE\u9898\u5BF9\u5E94\u7684\u504F\u79FB\u91CF\u8BBE\u7F6E\u4E3A "),ro=i(Vr,"CODE",{});var Lu=p(ro);Dc=n(Lu,"None"),Lu.forEach(s),Cc=n(Vr,":"),Vr.forEach(s),_i=f(e),E(Gn.$$.fragment,e),mi=f(e),lr=i(e,"P",{});var zu=p(lr);Tc=n(zu,"\u6211\u4EEC\u53EF\u4EE5\u50CF\u4EE5\u524D\u4E00\u6837\u5C06\u6B64\u51FD\u6570\u5E94\u7528\u4E8E\u6574\u4E2A\u9A8C\u8BC1\u6570\u636E\u96C6:"),zu.forEach(s),hi=f(e),E(Wn.$$.fragment,e),wi=f(e),E(Un.$$.fragment,e),gi=f(e),rr=i(e,"P",{});var Nu=p(rr);Ac=n(Nu,"I\u5728\u8FD9\u79CD\u60C5\u51B5\u4E0B, \u6211\u4EEC\u53EA\u6DFB\u52A0\u4E86\u51E0\u767E\u4E2A\u6837\u672C, \u56E0\u6B64\u9A8C\u8BC1\u6570\u636E\u96C6\u4E2D\u7684\u4E0A\u4E0B\u6587\u4F3C\u4E4E\u6709\u70B9\u77ED\u3002"),Nu.forEach(s),$i=f(e),or=i(e,"P",{});var Hu=p(or);Pc=n(Hu,"\u73B0\u5728\u6211\u4EEC\u5DF2\u7ECF\u5BF9\u6240\u6709\u6570\u636E\u8FDB\u884C\u4E86\u9884\u5904\u7406, \u6211\u4EEC\u53EF\u4EE5\u5F00\u59CB\u8BAD\u7EC3\u4E86\u3002"),Hu.forEach(s),bi=f(e),Is.l(e),ir=f(e),Jn=i(e,"H3",{id:!0});var Vu=p(Jn);Sc=n(Vu,"\u540E\u5904\u7406"),Vu.forEach(s),xi=f(e),Ls.l(e),pr=f(e),za=i(e,"P",{});var Ep=p(za);Oc=n(Ep,"\u8BE5\u6A21\u578B\u5C06\u5728\u8F93\u5165ID\u4E2D\u4E3A\u7B54\u6848\u7684\u5F00\u59CB\u548C\u7ED3\u675F\u4F4D\u7F6E\u8F93\u51FALogit, \u6B63\u5982\u6211\u4EEC\u5728\u63A2\u7D22 "),Xn=i(Ep,"A",{href:!0});var uf=p(Xn);oo=i(uf,"CODE",{});var Qu=p(oo);Mc=n(Qu,"question-answering"),Qu.forEach(s),Bc=n(uf," pipeline"),uf.forEach(s),Ic=n(Ep," \u65F6\u770B\u5230\u7684\u90A3\u6837\u3002\u540E\u5904\u7406\u6B65\u9AA4\u5C06\u7C7B\u4F3C\u4E8E\u6211\u4EEC\u5728\u90A3\u91CC\u6240\u505A\u7684, \u6240\u4EE5\u8FD9\u91CC\u662F\u6211\u4EEC\u91C7\u53D6\u7684\u884C\u52A8\u7684\u5FEB\u901F\u63D0\u9192:"),Ep.forEach(s),ji=f(e),fs=i(e,"UL",{});var Ya=p(fs);io=i(Ya,"LI",{});var Ru=p(io);Fc=n(Ru,"\u6211\u4EEC\u5C4F\u853D\u4E86\u4E0E\u4E0A\u4E0B\u6587\u4E4B\u5916\u7684\u6807\u8BB0\u76F8\u5BF9\u5E94\u7684\u5F00\u59CB\u548C\u7ED3\u675F logits\u3002"),Ru.forEach(s),Lc=f(Ya),po=i(Ya,"LI",{});var Gu=p(po);zc=n(Gu,"\u7136\u540E, \u6211\u4EEC\u4F7F\u7528 softmax \u5C06\u5F00\u59CB\u548C\u7ED3\u675F logits \u8F6C\u6362\u4E3A\u6982\u7387\u3002"),Gu.forEach(s),Nc=f(Ya),Kn=i(Ya,"LI",{});var yp=p(Kn);Hc=n(yp,"\u6211\u4EEC\u901A\u8FC7\u53D6\u5BF9\u5E94\u7684\u4E24\u4E2A\u6982\u7387\u7684\u4E58\u79EF\u6765\u7ED9\u6BCF\u4E2A "),co=i(yp,"CODE",{});var Wu=p(co);Vc=n(Wu,"(start_token, end_token)"),Wu.forEach(s),Qc=n(yp," \u7EC4\u5408\u8D4B\u503C\u3002"),yp.forEach(s),Rc=f(Ya),Zt=i(Ya,"LI",{});var Qr=p(Zt);Gc=n(Qr,"\u6211\u4EEC\u5BFB\u627E\u4EA7\u751F\u6709\u6548\u7B54\u6848\u7684\u6700\u9AD8\u5206\u6570\u7684\u914D\u5BF9 (\u4F8B\u5982, "),fo=i(Qr,"CODE",{});var Uu=p(fo);Wc=n(Uu,"start_token"),Uu.forEach(s),Uc=n(Qr," \u4F4E\u4E8E "),uo=i(Qr,"CODE",{});var Ju=p(uo);Jc=n(Ju,"end_token"),Ju.forEach(s),Xc=n(Qr,")\u3002"),Qr.forEach(s),Ya.forEach(s),vi=f(e),Te=i(e,"P",{});var Et=p(Te);Kc=n(Et,"\u5728\u8FD9\u91CC, \u6211\u4EEC\u5C06\u7A0D\u5FAE\u6539\u53D8\u8FD9\u4E2A\u8FC7\u7A0B, \u56E0\u4E3A\u6211\u4EEC\u4E0D\u9700\u8981\u8BA1\u7B97\u5B9E\u9645\u5206\u6570 (\u53EA\u662F\u9884\u6D4B\u7684\u7B54\u6848)\u3002\u8FD9\u610F\u5473\u7740\u6211\u4EEC\u53EF\u4EE5\u8DF3\u8FC7 softmax \u6B65\u9AA4\u3002\u4E3A\u4E86\u66F4\u5FEB, \u6211\u4EEC\u4E5F\u4E0D\u4F1A\u5BF9\u6240\u6709\u53EF\u80FD\u7684 "),_o=i(Et,"CODE",{});var Xu=p(_o);Yc=n(Xu,"(start_token, end_token)"),Xu.forEach(s),Zc=n(Et," \u5BF9\u8FDB\u884C\u8BC4\u5206, \u800C\u53EA\u4F1A\u5BF9\u5BF9\u5E94\u4E8E\u6700\u9AD8 "),mo=i(Et,"CODE",{});var Ku=p(mo);ed=n(Ku,"n_best"),Ku.forEach(s),sd=n(Et," \u7684\u90A3\u4E9B\u5BF9\u8FDB\u884C\u8BC4\u5206 (\u4F7F\u7528 "),ho=i(Et,"CODE",{});var Yu=p(ho);td=n(Yu,"n_best=20"),Yu.forEach(s),ad=n(Et,")\u3002\u7531\u4E8E\u6211\u4EEC\u5C06\u8DF3\u8FC7 softmax, \u56E0\u6B64\u8FD9\u4E9B\u5206\u6570\u5C06\u662F logit \u5206\u6570, \u5E76\u4E14\u5C06\u901A\u8FC7\u53D6 start \u548C end logits \u7684\u603B\u548C\u6765\u83B7\u5F97 (\u800C\u4E0D\u662F\u4E58\u79EF, \u56E0\u4E3A\u89C4\u5219 "),ki=N_(Et),qi=n(Et,")\u3002"),Et.forEach(s),Ei=f(e),Na=i(e,"P",{});var Dp=p(Na);nd=n(Dp,"\u4E3A\u4E86\u8BC1\u660E\u8FD9\u4E00\u5207, \u6211\u4EEC\u9700\u8981\u4E00\u4E9B\u9884\u6D4B\u3002\u7531\u4E8E\u6211\u4EEC\u8FD8\u6CA1\u6709\u8BAD\u7EC3\u6211\u4EEC\u7684\u6A21\u578B, \u6211\u4EEC\u5C06\u4F7F\u7528 QA \u7BA1\u9053\u7684\u9ED8\u8BA4\u6A21\u578B\u5BF9\u4E00\u5C0F\u90E8\u5206\u9A8C\u8BC1\u96C6\u751F\u6210\u4E00\u4E9B\u9884\u6D4B\u3002\u6211\u4EEC\u53EF\u4EE5\u4F7F\u7528\u548C\u4E4B\u524D\u4E00\u6837\u7684\u5904\u7406\u51FD\u6570; \u56E0\u4E3A\u5B83\u4F9D\u8D56\u4E8E\u5168\u5C40\u5E38\u91CF "),wo=i(Dp,"CODE",{});var Zu=p(wo);ld=n(Zu,"tokenizer"),Zu.forEach(s),rd=n(Dp,", \u6211\u4EEC\u53EA\u9700\u5C06\u8BE5\u5BF9\u8C61\u66F4\u6539\u4E3A\u6211\u4EEC\u8981\u4E34\u65F6\u4F7F\u7528\u7684\u6A21\u578B\u7684\u6807\u8BB0\u5668:"),Dp.forEach(s),yi=f(e),E(Yn.$$.fragment,e),Di=f(e),cr=i(e,"P",{});var e_=p(cr);od=n(e_,"\u73B0\u5728\u9884\u5904\u7406\u5DF2\u7ECF\u5B8C\u6210, \u6211\u4EEC\u5C06\u5206\u8BCD\u5668\u6539\u56DE\u6211\u4EEC\u6700\u521D\u9009\u62E9\u7684\u90A3\u4E2A:"),e_.forEach(s),Ci=f(e),E(Zn.$$.fragment,e),Ti=f(e),Ha=i(e,"P",{});var Cp=p(Ha);id=n(Cp,"\u7136\u540E, \u6211\u4EEC\u5220\u9664 "),go=i(Cp,"CODE",{});var s_=p(go);pd=n(s_,"eval_set"),s_.forEach(s),cd=n(Cp," \u4E2D\u6A21\u578B\u4E0D\u671F\u5F85\u7684\u5217, \u7528\u6240\u6709\u7684\u5C0F\u9A8C\u8BC1\u96C6\u6784\u5EFA\u4E00\u4E2A\u6279\u6B21, \u7136\u540E\u901A\u8FC7\u6A21\u578B\u3002\u5982\u679C GPU \u53EF\u7528, \u6211\u4EEC\u4F1A\u4F7F\u7528\u5B83\u6765\u52A0\u5FEB\u901F\u5EA6:"),Cp.forEach(s),Ai=f(e),Ns.l(e),dr=f(e),Ae=i(e,"P",{});var yt=p(Ae);dd=n(yt,"\u73B0\u5728, \u6211\u4EEC\u9700\u8981\u5728 "),$o=i(yt,"CODE",{});var t_=p($o);fd=n(t_,"small_eval_set"),t_.forEach(s),ud=n(yt," \u4E2D\u627E\u5230\u6BCF\u4E2A\u793A\u4F8B\u7684\u9884\u6D4B\u7B54\u6848\u3002\u4E00\u4E2A\u793A\u4F8B\u53EF\u80FD\u5DF2\u7ECF\u5728  "),bo=i(yt,"CODE",{});var a_=p(bo);_d=n(a_,"eval_set"),a_.forEach(s),md=n(yt," \u4E2D\u62C6\u5206\u4E3A\u591A\u4E2A\u7279\u5F81, \u56E0\u6B64\u7B2C\u4E00\u6B65\u662F\u5C06 "),xo=i(yt,"CODE",{});var n_=p(xo);hd=n(n_,"small_eval_set"),n_.forEach(s),wd=n(yt," \u4E2D\u7684\u6BCF\u4E2A\u793A\u4F8B\u6620\u5C04\u5230 "),jo=i(yt,"CODE",{});var l_=p(jo);gd=n(l_,"eval_set"),l_.forEach(s),$d=n(yt," \u4E2D\u76F8\u5E94\u7684\u7279\u5F81:"),yt.forEach(s),Pi=f(e),E(el.$$.fragment,e),Si=f(e),Va=i(e,"P",{});var Tp=p(Va);bd=n(Tp,"\u6709\u4E86\u8FD9\u4E2A, \u6211\u4EEC\u5C31\u53EF\u4EE5\u771F\u6B63\u5F00\u59CB\u5DE5\u4F5C, \u5FAA\u73AF\u904D\u5386\u6240\u6709\u793A\u4F8B, \u5E76\u4E3A\u6BCF\u4E2A\u793A\u4F8B\u904D\u5386\u6240\u6709\u76F8\u5173\u529F\u80FD\u3002\u6B63\u5982\u6211\u4EEC\u4E4B\u524D\u6240\u8BF4, \u6211\u4EEC\u5C06\u67E5\u770B "),vo=i(Tp,"CODE",{});var r_=p(vo);xd=n(r_,"n_best"),r_.forEach(s),jd=n(Tp," \u5F00\u59CB logits \u548C\u7ED3\u675F logits \u7684 logit \u5206\u6570, \u4E0D\u5305\u62EC\u4EE5\u4E0B\u7684\u4F4D\u7F6E:"),Tp.forEach(s),Oi=f(e),vt=i(e,"UL",{});var Rr=p(vt);ko=i(Rr,"LI",{});var o_=p(ko);vd=n(o_,"\u4E00\u4E2A\u4E0D\u5728\u4E0A\u4E0B\u6587\u4E2D\u7684\u7B54\u6848"),o_.forEach(s),kd=f(Rr),qo=i(Rr,"LI",{});var i_=p(qo);qd=n(i_,"\u957F\u5EA6\u4E3A\u8D1F\u7684\u7B54\u6848"),i_.forEach(s),Ed=f(Rr),sl=i(Rr,"LI",{});var Ap=p(sl);yd=n(Ap,"\u7B54\u6848\u592A\u957F (\u6211\u4EEC\u5C06\u53EF\u80FD\u6027\u9650\u5236\u5728 "),Eo=i(Ap,"CODE",{});var p_=p(Eo);Dd=n(p_,"max_answer_length=30"),p_.forEach(s),Cd=n(Ap,")"),Ap.forEach(s),Rr.forEach(s),Mi=f(e),fr=i(e,"P",{});var c_=p(fr);Td=n(c_,"\u4E00\u65E6\u6211\u4EEC\u4E3A\u4E00\u4E2A\u793A\u4F8B\u83B7\u5F97\u4E86\u6240\u6709\u53EF\u80FD\u7684\u7B54\u6848, \u6211\u4EEC\u53EA\u9700\u9009\u62E9\u4E00\u4E2A\u5177\u6709\u6700\u4F73 logit \u5206\u6570\u7684\u7B54\u6848:"),c_.forEach(s),Bi=f(e),E(tl.$$.fragment,e),Ii=f(e),ur=i(e,"P",{});var d_=p(ur);Ad=n(d_,"\u9884\u6D4B\u7B54\u6848\u7684\u6700\u7EC8\u683C\u5F0F\u662F\u6211\u4EEC\u5C06\u4F7F\u7528\u7684\u5EA6\u91CF\u6807\u51C6\u6240\u671F\u671B\u7684\u683C\u5F0F\u3002\u50CF\u5F80\u5E38\u4E00\u6837, \u6211\u4EEC\u53EF\u4EE5\u5728 \u{1F917} Datasets \u5E93\u7684\u5E2E\u52A9\u4E0B\u52A0\u8F7D\u5B83:"),d_.forEach(s),Fi=f(e),E(al.$$.fragment,e),Li=f(e),_r=i(e,"P",{});var f_=p(_r);Pd=n(f_,"\u8BE5\u6307\u6807\u671F\u671B\u6211\u4EEC\u4E0A\u9762\u770B\u5230\u7684\u683C\u5F0F\u7684\u9884\u6D4B\u7B54\u6848 (\u4E00\u4E2A\u5B57\u5178\u5217\u8868, \u5176\u4E2D\u4E00\u4E2A\u952E\u7528\u4E8E\u793A\u4F8B ID, \u4E00\u4E2A\u952E\u7528\u4E8E\u9884\u6D4B\u6587\u672C) \u548C\u4EE5\u4E0B\u683C\u5F0F\u7684\u7406\u8BBA\u7B54\u6848 (\u4E00\u4E2A\u5B57\u5178\u5217\u8868, \u4E00\u4E2A\u952E\u793A\u4F8B\u7684 ID \u548C\u53EF\u80FD\u7B54\u6848\u7684\u4E00\u952E):"),f_.forEach(s),zi=f(e),E(nl.$$.fragment,e),Ni=f(e),mr=i(e,"P",{});var u_=p(mr);Sd=n(u_,"\u6211\u4EEC\u73B0\u5728\u53EF\u4EE5\u901A\u8FC7\u67E5\u770B\u4E24\u4E2A\u5217\u8868\u7684\u7B2C\u4E00\u4E2A\u5143\u7D20\u6765\u68C0\u67E5\u6211\u4EEC\u662F\u5426\u5F97\u5230\u4E86\u5408\u7406\u7684\u7ED3\u679C:"),u_.forEach(s),Hi=f(e),E(ll.$$.fragment,e),Vi=f(e),E(rl.$$.fragment,e),Qi=f(e),hr=i(e,"P",{});var __=p(hr);Od=n(__,"\u8FD8\u4E0D\u9519! \u73B0\u5728\u8BA9\u6211\u4EEC\u770B\u770B\u8FD9\u4E2A\u6307\u6807\u7ED9\u6211\u4EEC\u7684\u5206\u6570:"),__.forEach(s),Ri=f(e),E(ol.$$.fragment,e),Gi=f(e),E(il.$$.fragment,e),Wi=f(e),Qa=i(e,"P",{});var Pp=p(Qa);Md=n(Pp,"\u540C\u6837, \u8003\u8651\u5230\u6839\u636E "),pl=i(Pp,"A",{href:!0,rel:!0});var m_=p(pl);Bd=n(m_,"its paper"),m_.forEach(s),Id=n(Pp,", \u5728 SQuAD \u4E0A\u5FAE\u8C03\u7684 DistilBERT \u5728\u6574\u4E2A\u6570\u636E\u96C6\u4E0A\u7684\u5F97\u5206\u5206\u522B\u4E3A 79.1 \u548C 86.9, \u8FD9\u662F\u76F8\u5F53\u4E0D\u9519\u7684\u3002"),Pp.forEach(s),Ui=f(e),ea.l(e),wr=f(e),E(cl.$$.fragment,e),Ji=f(e),gr=i(e,"P",{});var h_=p(gr);Fd=n(h_,"\u6211\u4EEC\u53EF\u4EE5\u68C0\u67E5\u5B83\u662F\u5426\u9002\u7528\u4E8E\u6211\u4EEC\u7684\u9884\u6D4B:"),h_.forEach(s),Xi=f(e),E(dl.$$.fragment,e),Ki=f(e),E(fl.$$.fragment,e),Yi=f(e),$r=i(e,"P",{});var w_=p($r);Ld=n(w_,"\u770B\u8D77\u6765\u4E0D\u9519! \u73B0\u5728\u8BA9\u6211\u4EEC\u7528\u5B83\u6765\u5FAE\u8C03\u6211\u4EEC\u7684\u6A21\u578B\u3002"),w_.forEach(s),Zi=f(e),ul=i(e,"H3",{id:!0});var g_=p(ul);zd=n(g_,"\u5FAE\u8C03\u6A21\u578B"),g_.forEach(s),ep=f(e),Vs.l(e),br=f(e),xr=i(e,"P",{});var $_=p(xr);Nd=n($_,"\u50CF\u5F80\u5E38\u4E00\u6837, \u6211\u4EEC\u6536\u5230\u4E00\u4E2A\u8B66\u544A, \u6709\u4E9B\u6743\u91CD\u6CA1\u6709\u4F7F\u7528(\u6765\u81EA\u9884\u8BAD\u7EC3\u5934\u7684), \u800C\u53E6\u4E00\u4E9B\u662F\u968F\u673A\u521D\u59CB\u5316\u7684 (\u7528\u4E8E\u95EE\u7B54\u5934\u7684)\u3002\u4F60\u73B0\u5728\u5E94\u8BE5\u5DF2\u7ECF\u4E60\u60EF\u4E86, \u4F46\u8FD9\u610F\u5473\u7740\u8FD9\u4E2A\u6A21\u578B\u8FD8\u6CA1\u6709\u51C6\u5907\u597D\u4F7F\u7528, \u9700\u8981\u5FAE\u8C03 \u2014 \u6211\u4EEC\u5373\u5C06\u8FD9\u6837\u505A!"),$_.forEach(s),sp=f(e),jr=i(e,"P",{});var b_=p(jr);Hd=n(b_,"\u4E3A\u4E86\u80FD\u591F\u5C06\u6211\u4EEC\u7684\u6A21\u578B\u63A8\u9001\u5230 Hub, \u6211\u4EEC\u9700\u8981\u767B\u5F55 Hugging Face\u3002 \u5982\u679C\u4F60\u5728\u7B14\u8BB0\u672C\u4E2D\u8FD0\u884C\u6B64\u4EE3\u7801, \u5219\u53EF\u4EE5\u4F7F\u7528\u4EE5\u4E0B\u5B9E\u7528\u7A0B\u5E8F\u51FD\u6570\u6267\u884C\u6B64\u64CD\u4F5C, \u8BE5\u51FD\u6570\u4F1A\u663E\u793A\u4E00\u4E2A\u5C0F\u90E8\u4EF6, \u4F60\u53EF\u4EE5\u5728\u5176\u4E2D\u8F93\u5165\u767B\u5F55\u51ED\u636E:"),b_.forEach(s),tp=f(e),E(_l.$$.fragment,e),ap=f(e),vr=i(e,"P",{});var x_=p(vr);Vd=n(x_,"\u5982\u679C\u4F60\u4E0D\u5728\u7B14\u8BB0\u672C\u4E2D\u5DE5\u4F5C, \u53EA\u9700\u5728\u7EC8\u7AEF\u4E2D\u952E\u5165\u4EE5\u4E0B\u884C:"),x_.forEach(s),np=f(e),E(ml.$$.fragment,e),lp=f(e),Rs.l(e),kr=f(e),Pe=i(e,"P",{});var Dt=p(Pe);Qd=n(Dt,"\u9ED8\u8BA4\u60C5\u51B5\u4E0B, \u4F7F\u7528\u7684\u5B58\u50A8\u5E93\u5C06\u5728\u60A8\u7684\u547D\u540D\u7A7A\u95F4\u4E2D, \u5E76\u4EE5\u60A8\u8BBE\u7F6E\u7684\u8F93\u51FA\u76EE\u5F55\u547D\u540D, \u56E0\u6B64\u5728\u6211\u4EEC\u7684\u4F8B\u5B50\u4E2D, \u5B83\u5C06\u5728 "),yo=i(Dt,"CODE",{});var j_=p(yo);Rd=n(j_,'"sgugger/bert-finetuned-squad"'),j_.forEach(s),Gd=n(Dt," \u4E2D\u3002\u6211\u4EEC\u53EF\u4EE5\u901A\u8FC7\u4F20\u9012 "),Do=i(Dt,"CODE",{});var v_=p(Do);Wd=n(v_,"hub_model_id"),v_.forEach(s),Ud=n(Dt," \u6765\u8986\u76D6\u5B83; \u4F8B\u5982, \u4E3A\u4E86\u5C06\u6A21\u578B\u63A8\u9001\u5230 "),Co=i(Dt,"CODE",{});var k_=p(Co);Jd=n(k_,"huggingface_course"),k_.forEach(s),Xd=n(Dt," \u7EC4\u7EC7, \u6211\u4EEC\u4F7F\u7528\u4E86 "),To=i(Dt,"CODE",{});var q_=p(To);Kd=n(q_,'hub_model_id="huggingface_course/bert-finetuned-squad"'),q_.forEach(s),Yd=n(Dt," (\u8FD9\u662F\u6211\u4EEC\u5728\u672C\u8282\u5F00\u5934\u94FE\u63A5\u7684\u6A21\u578B)\u3002"),Dt.forEach(s),rp=f(e),Ws.l(e),qr=f(e),Er=i(e,"P",{});var E_=p(Er);Zd=n(E_,"\u8BF7\u6CE8\u610F, \u5728\u8FDB\u884C\u8BAD\u7EC3\u65F6, \u6BCF\u6B21\u4FDD\u5B58\u6A21\u578B\u65F6 (\u8FD9\u91CC\u662F\u6BCF\u4E2A epoch) \u5B83\u90FD\u4F1A\u5728\u540E\u53F0\u4E0A\u4F20\u5230 Hub\u3002\u8FD9\u6837, \u5982\u6709\u5FC5\u8981, \u4F60\u5C06\u80FD\u591F\u5728\u53E6\u4E00\u53F0\u673A\u5668\u4E0A\u6062\u590D\u8BAD\u7EC3\u3002\u6574\u4E2A\u57F9\u8BAD\u9700\u8981\u4E00\u6BB5\u65F6\u95F4 (\u5728 Titan RTX \u4E0A\u9700\u8981\u4E00\u4E2A\u591A\u5C0F\u65F6), \u56E0\u6B64\u60A8\u53EF\u4EE5\u559D\u676F\u5496\u5561\u6216\u91CD\u8BFB\u8BFE\u7A0B\u4E2D\u60A8\u53D1\u73B0\u5728\u8FDB\u884C\u8FC7\u7A0B\u4E2D\u66F4\u5177\u6311\u6218\u6027\u7684\u90E8\u5206\u5185\u5BB9\u3002\u53E6\u8BF7\u6CE8\u610F, \u4E00\u65E6\u7B2C\u4E00\u4E2A epoch \u5B8C\u6210, \u4F60\u5C06\u770B\u5230\u4E00\u4E9B\u6743\u91CD\u4E0A\u4F20\u5230 Hub, \u4F60\u53EF\u4EE5\u5F00\u59CB\u5728\u5176\u9875\u9762\u4E0A\u4F7F\u7528\u4F60\u7684\u6A21\u578B\u3002"),E_.forEach(s),op=f(e),Js.l(e),yr=f(e),E(hl.$$.fragment,e),ip=f(e),Dr=i(e,"P",{});var y_=p(Dr);ef=n(y_,"\u5F88\u597D! \u4F5C\u4E3A\u6BD4\u8F83, BERT \u6587\u7AE0\u4E2D\u62A5\u544A\u7684\u8BE5\u6A21\u578B\u7684\u57FA\u7EBF\u5206\u6570\u662F 80.8 \u548C 88.5, \u6240\u4EE5\u6211\u4EEC\u5E94\u8BE5\u662F\u6B63\u786E\u7684\u3002"),y_.forEach(s),pp=f(e),oe&&oe.l(e),Cr=f(e),Tr=i(e,"P",{});var D_=p(Tr);sf=n(D_,"\u5728\u8FD9\u4E2A\u9636\u6BB5, \u4F60\u53EF\u4EE5\u4F7F\u7528\u6A21\u578B\u4E2D\u5FC3\u4E0A\u7684\u63A8\u7406\u5C0F\u90E8\u4EF6\u6765\u6D4B\u8BD5\u6A21\u578B\u5E76\u4E0E\u60A8\u7684\u670B\u53CB\u3001\u5BB6\u4EBA\u548C\u6700\u559C\u6B22\u7684\u5BA0\u7269\u5206\u4EAB\u3002\u4F60\u5DF2\u7ECF\u6210\u529F\u5730\u5FAE\u8C03\u4E86\u4E00\u4E2A\u95EE\u7B54\u4EFB\u52A1\u7684\u6A21\u578B \u2014 \u606D\u559C!"),D_.forEach(s),cp=f(e),E(Ra.$$.fragment,e),dp=f(e),ie&&ie.l(e),Ar=f(e),wl=i(e,"H2",{id:!0});var C_=p(wl);tf=n(C_,"\u4F7F\u7528\u5FAE\u8C03\u6A21\u578B"),C_.forEach(s),fp=f(e),Ga=i(e,"P",{});var Sp=p(Ga);af=n(Sp,"\u6211\u4EEC\u5DF2\u7ECF\u5411\u60A8\u5C55\u793A\u4E86\u5982\u4F55\u5C06\u6211\u4EEC\u5728\u6A21\u578B\u4E2D\u5FC3\u5FAE\u8C03\u7684\u6A21\u578B\u4E0E\u63A8\u7406\u5C0F\u90E8\u4EF6\u4E00\u8D77\u4F7F\u7528\u3002\u8981\u5728 "),Ao=i(Sp,"CODE",{});var T_=p(Ao);nf=n(T_,"pipeline"),T_.forEach(s),lf=n(Sp," \u4E2D\u672C\u5730\u4F7F\u7528\u5B83, \u4F60\u53EA\u9700\u8981\u6307\u5B9A\u6A21\u578B\u6807\u8BC6\u7B26:"),Sp.forEach(s),up=f(e),E(gl.$$.fragment,e),_p=f(e),E($l.$$.fragment,e),mp=f(e),Pr=i(e,"P",{});var A_=p(Pr);rf=n(A_,"\u5F88\u68D2! \u6211\u4EEC\u7684\u6A21\u578B\u4E0E\u8BE5\u7BA1\u9053\u7684\u9ED8\u8BA4\u6A21\u578B\u4E00\u6837\u6709\u6548!"),A_.forEach(s),this.h()},h(){B(c,"name","hf:doc:metadata"),B(c,"content",JSON.stringify(um)),B(T,"id",""),B(W,"href","https://rajpurkar.github.io/SQuAD-explorer/"),B(W,"rel","nofollow"),Op(J.src,pe="https://hf.space/gradioiframe/course-demos/bert-finetuned-squad/+")||B(J,"src",pe),B(J,"frameborder","0"),B(J,"height","450"),B(J,"title","Gradio app"),B(J,"class","block dark:hidden container p-0 flex-grow space-iframe"),B(J,"allow","accelerometer; ambient-light-sensor; autoplay; battery; camera; document-domain; encrypted-media; fullscreen; geolocation; gyroscope; layout-animations; legacy-image-formats; magnetometer; microphone; midi; oversized-images; payment; picture-in-picture; publickey-credentials-get; sync-xhr; usb; vr ; wake-lock; xr-spatial-tracking"),B(J,"sandbox","allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-downloads"),Op(Z.src,Ue="https://hf.space/gradioiframe/course-demos/bert-finetuned-squad-darkmode/+")||B(Z,"src",Ue),B(Z,"frameborder","0"),B(Z,"height","450"),B(Z,"title","Gradio app"),B(Z,"class","hidden dark:block container p-0 flex-grow space-iframe"),B(Z,"allow","accelerometer; ambient-light-sensor; autoplay; battery; camera; document-domain; encrypted-media; fullscreen; geolocation; gyroscope; layout-animations; legacy-image-formats; magnetometer; microphone; midi; oversized-images; payment; picture-in-picture; publickey-credentials-get; sync-xhr; usb; vr ; wake-lock; xr-spatial-tracking"),B(Z,"sandbox","allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-downloads"),B(V,"href","https://huggingface.co/huggingface-course/bert-finetuned-squad?context=%F0%9F%A4%97+Transformers+is+backed+by+the+three+most+popular+deep+learning+libraries+%E2%80%94+Jax%2C+PyTorch+and+TensorFlow+%E2%80%94+with+a+seamless+integration+between+them.+It%27s+straightforward+to+train+your+models+with+one+before+loading+them+for+inference+with+the+other.&question=Which+deep+learning+libraries+back+%F0%9F%A4%97+Transformers%3F"),B(V,"rel","nofollow"),B($e,"id",""),B(ce,"href","https://rajpurkar.github.io/SQuAD-explorer/"),B(ce,"rel","nofollow"),B(_s,"href","https://huggingface.co/datasets/squad_v2"),B(_s,"rel","nofollow"),B(Xe,"id","squad"),B(Xe,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),B(Xe,"href","#squad"),B(je,"class","relative group"),B(Ne,"id",""),B(As,"href","https://huggingface.co/transformers/#supported-frameworks"),B(As,"rel","nofollow"),B(Ms,"class","block dark:hidden"),Op(Ms.src,Cl="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter7/qa_labels.svg")||B(Ms,"src",Cl),B(Ms,"alt","One-hot encoded labels for question answering."),B(u,"class","hidden dark:block"),Op(u.src,F="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter7/qa_labels-dark.svg")||B(u,"src",F),B(u,"alt","One-hot encoded labels for question answering."),B(Ee,"class","flex justify-center"),B(Gt,"href","/course/chapter6/4"),B(Yt,"href","/course/chapter6/4"),B(Rn,"id",""),B(Jn,"id",""),B(Xn,"href","/course/chapter6/4"),ki.a=qi,B(pl,"href","https://arxiv.org/abs/1910.01108v2"),B(pl,"rel","nofollow"),B(ul,"id",""),B(wl,"id","")},m(e,r){t(document.head,c),l(e,h,r),y(_,e,r),l(e,v,r),l(e,T,r),t(T,$),l(e,j,r),bl[x].m(e,r),l(e,S,r),l(e,b,r),t(b,k),t(b,O),t(O,L),t(b,M),t(b,C),t(C,Q),t(b,z),l(e,A,r),y(N,e,r),l(e,R,r),l(e,G,r),t(G,K),t(G,W),t(W,I),t(G,U),l(e,ae,r),l(e,J,r),l(e,se,r),l(e,Z,r),l(e,Se,r),l(e,ne,r),t(ne,Oe),t(ne,V),t(V,X),t(ne,us),l(e,xe,r),y(we,e,r),l(e,ge,r),l(e,$e,r),t($e,Je),l(e,Me,r),l(e,fe,r),t(fe,Be),t(fe,ce),t(ce,sa),t(fe,le),t(fe,_s),t(_s,At),t(fe,Za),l(e,ta,r),l(e,je,r),t(je,Xe),t(Xe,Pt),y(Ie,Pt,null),t(je,en),t(je,St),t(St,Ot),l(e,aa,r),l(e,Ke,r),t(Ke,Mt),t(Ke,Bt),t(Bt,sn),t(Ke,na),l(e,Ye,r),y(Ze,e,r),l(e,ve,r),l(e,Xs,r),t(Xs,It),l(e,la,r),y(ms,e,r),l(e,Ks,r),y(hs,e,r),l(e,ra,r),l(e,ue,r),t(ue,ws),t(ue,Ys),t(Ys,be),t(ue,tn),t(ue,gs),t(gs,an),t(ue,nn),t(ue,$s),t($s,ln),t(ue,rn),l(e,Zs,r),y(bs,e,r),l(e,oa,r),y(es,e,r),l(e,ss,r),l(e,te,r),t(te,Fe),t(Fe,ia),t(te,et),t(te,Ft),t(Ft,pa),t(te,xs),t(te,st),t(st,ye),t(te,on),t(te,js),t(js,pn),t(te,cn),t(te,vs),t(vs,dn),t(te,fn),t(te,tt),t(tt,ks),t(te,un),l(e,Lt,r),l(e,ke,r),t(ke,_n),t(ke,at),t(at,De),t(ke,qs),l(e,ca,r),y(Le,e,r),l(e,da,r),y(Es,e,r),l(e,fa,r),l(e,de,r),t(de,mn),l(e,nt,r),y(ys,e,r),l(e,ua,r),y(ze,e,r),l(e,_a,r),l(e,lt,r),t(lt,zt),l(e,ma,r),y(Ds,e,r),l(e,ha,r),y(_e,e,r),l(e,wa,r),l(e,ts,r),t(ts,hn),l(e,ga,r),l(e,Ne,r),t(Ne,wn),l(e,$a,r),y(as,e,r),l(e,Cs,r),l(e,rt,r),t(rt,ba),l(e,ns,r),l(e,Ts,r),t(Ts,ot),l(e,xa,r),y(ls,e,r),l(e,rs,r),l(e,me,r),t(me,ee),t(me,As),t(As,Nt),t(me,gn),t(me,Ht),t(Ht,Vt),t(me,$n),t(me,Qt),t(Qt,Rt),t(me,bn),l(e,ja,r),y(He,e,r),l(e,va,r),y(Ps,e,r),l(e,it,r),l(e,pt,r),t(pt,xn),l(e,ct,r),y(Ss,e,r),l(e,ka,r),l(e,os,r),t(os,jn),l(e,qa,r),y(is,e,r),l(e,qe,r),y(Os,e,r),l(e,dt,r),l(e,ft,r),t(ft,vn),l(e,ps,r),l(e,Ee,r),t(Ee,Ms),t(Ee,Ea),t(Ee,u),l(e,kn,r),l(e,he,r),t(he,Tl),t(he,Gt),t(Gt,Al),t(he,Ce),t(he,ya),t(ya,Pl),t(he,Sl),l(e,qn,r),l(e,Wt,r),t(Wt,Da),l(e,En,r),l(e,Y,r),t(Y,Ut),t(Ut,Ca),t(Ca,Ol),t(Ut,Ml),t(Y,Bl),t(Y,Ve),t(Ve,Ta),t(Ta,Il),t(Ve,cs),t(Y,Fl),t(Y,Jt),t(Jt,Aa),t(Aa,Ll),t(Jt,ut),t(Y,zl),t(Y,Xt),t(Xt,Pa),t(Pa,Nl),t(Xt,_t),l(e,Kt,r),y(mt,e,r),l(e,Qe,r),y(ht,e,r),l(e,yn,r),l(e,Re,r),t(Re,wt),t(Re,Sa),t(Sa,Hl),t(Re,Vl),t(Re,Oa),t(Oa,re),t(Re,Ql),l(e,Dn,r),l(e,Ge,r),t(Ge,Rl),t(Ge,Yt),t(Yt,Gl),t(Ge,Wl),t(Ge,ds),t(ds,Ul),t(Ge,Jl),l(e,Cn,r),y(Tn,e,r),l(e,Bo,r),y(An,e,r),l(e,Io,r),l(e,gt,r),t(gt,Ip),t(gt,Gr),t(Gr,Fp),t(gt,Lp),t(gt,Wr),t(Wr,zp),t(gt,Np),l(e,Fo,r),y(Pn,e,r),l(e,Lo,r),y(Sn,e,r),l(e,zo,r),l(e,Xl,r),t(Xl,Hp),l(e,No,r),y(On,e,r),l(e,Ho,r),y(Mn,e,r),l(e,Vo,r),l(e,Kl,r),t(Kl,Vp),l(e,Qo,r),l(e,Yl,r),t(Yl,Qp),l(e,Ro,r),l(e,Ma,r),t(Ma,Zl),t(Zl,Ur),t(Ur,Rp),t(Zl,Gp),t(Ma,Wp),t(Ma,$t),t($t,Jr),t(Jr,Up),t($t,Jp),t($t,Xr),t(Xr,Xp),t($t,Kp),t($t,Kr),t(Kr,Yp),t($t,Zp),l(e,Go,r),l(e,bt,r),t(bt,ec),t(bt,Yr),t(Yr,sc),t(bt,tc),t(bt,Zr),t(Zr,ac),t(bt,nc),l(e,Wo,r),l(e,Ba,r),t(Ba,lc),t(Ba,eo),t(eo,rc),t(Ba,oc),l(e,Uo,r),y(Bn,e,r),l(e,Jo,r),y(In,e,r),l(e,Xo,r),l(e,Ia,r),t(Ia,ic),t(Ia,so),t(so,pc),t(Ia,cc),l(e,Ko,r),y(Fn,e,r),l(e,Yo,r),y(Ln,e,r),l(e,Zo,r),l(e,Fa,r),t(Fa,dc),t(Fa,to),t(to,fc),t(Fa,uc),l(e,ei,r),y(zn,e,r),l(e,si,r),y(Nn,e,r),l(e,ti,r),l(e,er,r),t(er,_c),l(e,ai,r),y(La,e,r),l(e,ni,r),l(e,sr,r),t(sr,mc),l(e,li,r),y(Hn,e,r),l(e,ri,r),l(e,tr,r),t(tr,hc),l(e,oi,r),l(e,xt,r),t(xt,wc),t(xt,ao),t(ao,gc),t(xt,$c),t(xt,no),t(no,bc),t(xt,xc),l(e,ii,r),y(Vn,e,r),l(e,pi,r),y(Qn,e,r),l(e,ci,r),l(e,ar,r),t(ar,jc),l(e,di,r),l(e,Rn,r),t(Rn,vc),l(e,fi,r),l(e,nr,r),t(nr,kc),l(e,ui,r),l(e,jt,r),t(jt,qc),t(jt,lo),t(lo,Ec),t(jt,yc),t(jt,ro),t(ro,Dc),t(jt,Cc),l(e,_i,r),y(Gn,e,r),l(e,mi,r),l(e,lr,r),t(lr,Tc),l(e,hi,r),y(Wn,e,r),l(e,wi,r),y(Un,e,r),l(e,gi,r),l(e,rr,r),t(rr,Ac),l(e,$i,r),l(e,or,r),t(or,Pc),l(e,bi,r),xl[Bs].m(e,r),l(e,ir,r),l(e,Jn,r),t(Jn,Sc),l(e,xi,r),jl[Fs].m(e,r),l(e,pr,r),l(e,za,r),t(za,Oc),t(za,Xn),t(Xn,oo),t(oo,Mc),t(Xn,Bc),t(za,Ic),l(e,ji,r),l(e,fs,r),t(fs,io),t(io,Fc),t(fs,Lc),t(fs,po),t(po,zc),t(fs,Nc),t(fs,Kn),t(Kn,Hc),t(Kn,co),t(co,Vc),t(Kn,Qc),t(fs,Rc),t(fs,Zt),t(Zt,Gc),t(Zt,fo),t(fo,Wc),t(Zt,Uc),t(Zt,uo),t(uo,Jc),t(Zt,Xc),l(e,vi,r),l(e,Te,r),t(Te,Kc),t(Te,_o),t(_o,Yc),t(Te,Zc),t(Te,mo),t(mo,ed),t(Te,sd),t(Te,ho),t(ho,td),t(Te,ad),ki.m(M_,Te),t(Te,qi),l(e,Ei,r),l(e,Na,r),t(Na,nd),t(Na,wo),t(wo,ld),t(Na,rd),l(e,yi,r),y(Yn,e,r),l(e,Di,r),l(e,cr,r),t(cr,od),l(e,Ci,r),y(Zn,e,r),l(e,Ti,r),l(e,Ha,r),t(Ha,id),t(Ha,go),t(go,pd),t(Ha,cd),l(e,Ai,r),vl[zs].m(e,r),l(e,dr,r),l(e,Ae,r),t(Ae,dd),t(Ae,$o),t($o,fd),t(Ae,ud),t(Ae,bo),t(bo,_d),t(Ae,md),t(Ae,xo),t(xo,hd),t(Ae,wd),t(Ae,jo),t(jo,gd),t(Ae,$d),l(e,Pi,r),y(el,e,r),l(e,Si,r),l(e,Va,r),t(Va,bd),t(Va,vo),t(vo,xd),t(Va,jd),l(e,Oi,r),l(e,vt,r),t(vt,ko),t(ko,vd),t(vt,kd),t(vt,qo),t(qo,qd),t(vt,Ed),t(vt,sl),t(sl,yd),t(sl,Eo),t(Eo,Dd),t(sl,Cd),l(e,Mi,r),l(e,fr,r),t(fr,Td),l(e,Bi,r),y(tl,e,r),l(e,Ii,r),l(e,ur,r),t(ur,Ad),l(e,Fi,r),y(al,e,r),l(e,Li,r),l(e,_r,r),t(_r,Pd),l(e,zi,r),y(nl,e,r),l(e,Ni,r),l(e,mr,r),t(mr,Sd),l(e,Hi,r),y(ll,e,r),l(e,Vi,r),y(rl,e,r),l(e,Qi,r),l(e,hr,r),t(hr,Od),l(e,Ri,r),y(ol,e,r),l(e,Gi,r),y(il,e,r),l(e,Wi,r),l(e,Qa,r),t(Qa,Md),t(Qa,pl),t(pl,Bd),t(Qa,Id),l(e,Ui,r),ea.m(e,r),l(e,wr,r),y(cl,e,r),l(e,Ji,r),l(e,gr,r),t(gr,Fd),l(e,Xi,r),y(dl,e,r),l(e,Ki,r),y(fl,e,r),l(e,Yi,r),l(e,$r,r),t($r,Ld),l(e,Zi,r),l(e,ul,r),t(ul,zd),l(e,ep,r),kl[Hs].m(e,r),l(e,br,r),l(e,xr,r),t(xr,Nd),l(e,sp,r),l(e,jr,r),t(jr,Hd),l(e,tp,r),y(_l,e,r),l(e,ap,r),l(e,vr,r),t(vr,Vd),l(e,np,r),y(ml,e,r),l(e,lp,r),ql[Qs].m(e,r),l(e,kr,r),l(e,Pe,r),t(Pe,Qd),t(Pe,yo),t(yo,Rd),t(Pe,Gd),t(Pe,Do),t(Do,Wd),t(Pe,Ud),t(Pe,Co),t(Co,Jd),t(Pe,Xd),t(Pe,To),t(To,Kd),t(Pe,Yd),l(e,rp,r),El[Gs].m(e,r),l(e,qr,r),l(e,Er,r),t(Er,Zd),l(e,op,r),yl[Us].m(e,r),l(e,yr,r),y(hl,e,r),l(e,ip,r),l(e,Dr,r),t(Dr,ef),l(e,pp,r),oe&&oe.m(e,r),l(e,Cr,r),l(e,Tr,r),t(Tr,sf),l(e,cp,r),y(Ra,e,r),l(e,dp,r),ie&&ie.m(e,r),l(e,Ar,r),l(e,wl,r),t(wl,tf),l(e,fp,r),l(e,Ga,r),t(Ga,af),t(Ga,Ao),t(Ao,nf),t(Ga,lf),l(e,up,r),y(gl,e,r),l(e,_p,r),y($l,e,r),l(e,mp,r),l(e,Pr,r),t(Pr,rf),hp=!0},p(e,[r]){const Po={};r&1&&(Po.fw=e[0]),_.$set(Po);let kt=x;x=hf(e),x!==kt&&(Tt(),g(bl[kt],1,1,()=>{bl[kt]=null}),Ct(),m=bl[x],m||(m=bl[x]=mf[x](e),m.c()),w(m,1),m.m(S.parentNode,S));const So={};r&2&&(So.$$scope={dirty:r,ctx:e}),we.$set(So);const Oo={};r&2&&(Oo.$$scope={dirty:r,ctx:e}),La.$set(Oo);let Wa=Bs;Bs=gf(e),Bs!==Wa&&(Tt(),g(xl[Wa],1,1,()=>{xl[Wa]=null}),Ct(),Is=xl[Bs],Is||(Is=xl[Bs]=wf[Bs](e),Is.c()),w(Is,1),Is.m(ir.parentNode,ir));let Sr=Fs;Fs=bf(e),Fs!==Sr&&(Tt(),g(jl[Sr],1,1,()=>{jl[Sr]=null}),Ct(),Ls=jl[Fs],Ls||(Ls=jl[Fs]=$f[Fs](e),Ls.c()),w(Ls,1),Ls.m(pr.parentNode,pr));let Ua=zs;zs=jf(e),zs!==Ua&&(Tt(),g(vl[Ua],1,1,()=>{vl[Ua]=null}),Ct(),Ns=vl[zs],Ns||(Ns=vl[zs]=xf[zs](e),Ns.c()),w(Ns,1),Ns.m(dr.parentNode,dr)),wp!==(wp=vf(e))&&(ea.d(1),ea=wp(e),ea&&(ea.c(),ea.m(wr.parentNode,wr)));let Or=Hs;Hs=qf(e),Hs!==Or&&(Tt(),g(kl[Or],1,1,()=>{kl[Or]=null}),Ct(),Vs=kl[Hs],Vs||(Vs=kl[Hs]=kf[Hs](e),Vs.c()),w(Vs,1),Vs.m(br.parentNode,br));let Mr=Qs;Qs=yf(e),Qs!==Mr&&(Tt(),g(ql[Mr],1,1,()=>{ql[Mr]=null}),Ct(),Rs=ql[Qs],Rs||(Rs=ql[Qs]=Ef[Qs](e),Rs.c()),w(Rs,1),Rs.m(kr.parentNode,kr));let qt=Gs;Gs=Cf(e),Gs!==qt&&(Tt(),g(El[qt],1,1,()=>{El[qt]=null}),Ct(),Ws=El[Gs],Ws||(Ws=El[Gs]=Df[Gs](e),Ws.c()),w(Ws,1),Ws.m(qr.parentNode,qr));let Br=Us;Us=Af(e),Us!==Br&&(Tt(),g(yl[Br],1,1,()=>{yl[Br]=null}),Ct(),Js=yl[Us],Js||(Js=yl[Us]=Tf[Us](e),Js.c()),w(Js,1),Js.m(yr.parentNode,yr)),e[0]==="pt"?oe?r&1&&w(oe,1):(oe=P_(),oe.c(),w(oe,1),oe.m(Cr.parentNode,Cr)):oe&&(Tt(),g(oe,1,1,()=>{oe=null}),Ct());const Mo={};r&2&&(Mo.$$scope={dirty:r,ctx:e}),Ra.$set(Mo),e[0]==="pt"?ie?r&1&&w(ie,1):(ie=S_(),ie.c(),w(ie,1),ie.m(Ar.parentNode,Ar)):ie&&(Tt(),g(ie,1,1,()=>{ie=null}),Ct())},i(e){hp||(w(_.$$.fragment,e),w(m),w(N.$$.fragment,e),w(we.$$.fragment,e),w(Ie.$$.fragment,e),w(Ze.$$.fragment,e),w(ms.$$.fragment,e),w(hs.$$.fragment,e),w(bs.$$.fragment,e),w(es.$$.fragment,e),w(Le.$$.fragment,e),w(Es.$$.fragment,e),w(ys.$$.fragment,e),w(ze.$$.fragment,e),w(Ds.$$.fragment,e),w(_e.$$.fragment,e),w(as.$$.fragment,e),w(ls.$$.fragment,e),w(He.$$.fragment,e),w(Ps.$$.fragment,e),w(Ss.$$.fragment,e),w(is.$$.fragment,e),w(Os.$$.fragment,e),w(mt.$$.fragment,e),w(ht.$$.fragment,e),w(Tn.$$.fragment,e),w(An.$$.fragment,e),w(Pn.$$.fragment,e),w(Sn.$$.fragment,e),w(On.$$.fragment,e),w(Mn.$$.fragment,e),w(Bn.$$.fragment,e),w(In.$$.fragment,e),w(Fn.$$.fragment,e),w(Ln.$$.fragment,e),w(zn.$$.fragment,e),w(Nn.$$.fragment,e),w(La.$$.fragment,e),w(Hn.$$.fragment,e),w(Vn.$$.fragment,e),w(Qn.$$.fragment,e),w(Gn.$$.fragment,e),w(Wn.$$.fragment,e),w(Un.$$.fragment,e),w(Is),w(Ls),w(Yn.$$.fragment,e),w(Zn.$$.fragment,e),w(Ns),w(el.$$.fragment,e),w(tl.$$.fragment,e),w(al.$$.fragment,e),w(nl.$$.fragment,e),w(ll.$$.fragment,e),w(rl.$$.fragment,e),w(ol.$$.fragment,e),w(il.$$.fragment,e),w(cl.$$.fragment,e),w(dl.$$.fragment,e),w(fl.$$.fragment,e),w(Vs),w(_l.$$.fragment,e),w(ml.$$.fragment,e),w(Rs),w(Ws),w(Js),w(hl.$$.fragment,e),w(oe),w(Ra.$$.fragment,e),w(ie),w(gl.$$.fragment,e),w($l.$$.fragment,e),hp=!0)},o(e){g(_.$$.fragment,e),g(m),g(N.$$.fragment,e),g(we.$$.fragment,e),g(Ie.$$.fragment,e),g(Ze.$$.fragment,e),g(ms.$$.fragment,e),g(hs.$$.fragment,e),g(bs.$$.fragment,e),g(es.$$.fragment,e),g(Le.$$.fragment,e),g(Es.$$.fragment,e),g(ys.$$.fragment,e),g(ze.$$.fragment,e),g(Ds.$$.fragment,e),g(_e.$$.fragment,e),g(as.$$.fragment,e),g(ls.$$.fragment,e),g(He.$$.fragment,e),g(Ps.$$.fragment,e),g(Ss.$$.fragment,e),g(is.$$.fragment,e),g(Os.$$.fragment,e),g(mt.$$.fragment,e),g(ht.$$.fragment,e),g(Tn.$$.fragment,e),g(An.$$.fragment,e),g(Pn.$$.fragment,e),g(Sn.$$.fragment,e),g(On.$$.fragment,e),g(Mn.$$.fragment,e),g(Bn.$$.fragment,e),g(In.$$.fragment,e),g(Fn.$$.fragment,e),g(Ln.$$.fragment,e),g(zn.$$.fragment,e),g(Nn.$$.fragment,e),g(La.$$.fragment,e),g(Hn.$$.fragment,e),g(Vn.$$.fragment,e),g(Qn.$$.fragment,e),g(Gn.$$.fragment,e),g(Wn.$$.fragment,e),g(Un.$$.fragment,e),g(Is),g(Ls),g(Yn.$$.fragment,e),g(Zn.$$.fragment,e),g(Ns),g(el.$$.fragment,e),g(tl.$$.fragment,e),g(al.$$.fragment,e),g(nl.$$.fragment,e),g(ll.$$.fragment,e),g(rl.$$.fragment,e),g(ol.$$.fragment,e),g(il.$$.fragment,e),g(cl.$$.fragment,e),g(dl.$$.fragment,e),g(fl.$$.fragment,e),g(Vs),g(_l.$$.fragment,e),g(ml.$$.fragment,e),g(Rs),g(Ws),g(Js),g(hl.$$.fragment,e),g(oe),g(Ra.$$.fragment,e),g(ie),g(gl.$$.fragment,e),g($l.$$.fragment,e),hp=!1},d(e){s(c),e&&s(h),D(_,e),e&&s(v),e&&s(T),e&&s(j),bl[x].d(e),e&&s(S),e&&s(b),e&&s(A),D(N,e),e&&s(R),e&&s(G),e&&s(ae),e&&s(J),e&&s(se),e&&s(Z),e&&s(Se),e&&s(ne),e&&s(xe),D(we,e),e&&s(ge),e&&s($e),e&&s(Me),e&&s(fe),e&&s(ta),e&&s(je),D(Ie),e&&s(aa),e&&s(Ke),e&&s(Ye),D(Ze,e),e&&s(ve),e&&s(Xs),e&&s(la),D(ms,e),e&&s(Ks),D(hs,e),e&&s(ra),e&&s(ue),e&&s(Zs),D(bs,e),e&&s(oa),D(es,e),e&&s(ss),e&&s(te),e&&s(Lt),e&&s(ke),e&&s(ca),D(Le,e),e&&s(da),D(Es,e),e&&s(fa),e&&s(de),e&&s(nt),D(ys,e),e&&s(ua),D(ze,e),e&&s(_a),e&&s(lt),e&&s(ma),D(Ds,e),e&&s(ha),D(_e,e),e&&s(wa),e&&s(ts),e&&s(ga),e&&s(Ne),e&&s($a),D(as,e),e&&s(Cs),e&&s(rt),e&&s(ns),e&&s(Ts),e&&s(xa),D(ls,e),e&&s(rs),e&&s(me),e&&s(ja),D(He,e),e&&s(va),D(Ps,e),e&&s(it),e&&s(pt),e&&s(ct),D(Ss,e),e&&s(ka),e&&s(os),e&&s(qa),D(is,e),e&&s(qe),D(Os,e),e&&s(dt),e&&s(ft),e&&s(ps),e&&s(Ee),e&&s(kn),e&&s(he),e&&s(qn),e&&s(Wt),e&&s(En),e&&s(Y),e&&s(Kt),D(mt,e),e&&s(Qe),D(ht,e),e&&s(yn),e&&s(Re),e&&s(Dn),e&&s(Ge),e&&s(Cn),D(Tn,e),e&&s(Bo),D(An,e),e&&s(Io),e&&s(gt),e&&s(Fo),D(Pn,e),e&&s(Lo),D(Sn,e),e&&s(zo),e&&s(Xl),e&&s(No),D(On,e),e&&s(Ho),D(Mn,e),e&&s(Vo),e&&s(Kl),e&&s(Qo),e&&s(Yl),e&&s(Ro),e&&s(Ma),e&&s(Go),e&&s(bt),e&&s(Wo),e&&s(Ba),e&&s(Uo),D(Bn,e),e&&s(Jo),D(In,e),e&&s(Xo),e&&s(Ia),e&&s(Ko),D(Fn,e),e&&s(Yo),D(Ln,e),e&&s(Zo),e&&s(Fa),e&&s(ei),D(zn,e),e&&s(si),D(Nn,e),e&&s(ti),e&&s(er),e&&s(ai),D(La,e),e&&s(ni),e&&s(sr),e&&s(li),D(Hn,e),e&&s(ri),e&&s(tr),e&&s(oi),e&&s(xt),e&&s(ii),D(Vn,e),e&&s(pi),D(Qn,e),e&&s(ci),e&&s(ar),e&&s(di),e&&s(Rn),e&&s(fi),e&&s(nr),e&&s(ui),e&&s(jt),e&&s(_i),D(Gn,e),e&&s(mi),e&&s(lr),e&&s(hi),D(Wn,e),e&&s(wi),D(Un,e),e&&s(gi),e&&s(rr),e&&s($i),e&&s(or),e&&s(bi),xl[Bs].d(e),e&&s(ir),e&&s(Jn),e&&s(xi),jl[Fs].d(e),e&&s(pr),e&&s(za),e&&s(ji),e&&s(fs),e&&s(vi),e&&s(Te),e&&s(Ei),e&&s(Na),e&&s(yi),D(Yn,e),e&&s(Di),e&&s(cr),e&&s(Ci),D(Zn,e),e&&s(Ti),e&&s(Ha),e&&s(Ai),vl[zs].d(e),e&&s(dr),e&&s(Ae),e&&s(Pi),D(el,e),e&&s(Si),e&&s(Va),e&&s(Oi),e&&s(vt),e&&s(Mi),e&&s(fr),e&&s(Bi),D(tl,e),e&&s(Ii),e&&s(ur),e&&s(Fi),D(al,e),e&&s(Li),e&&s(_r),e&&s(zi),D(nl,e),e&&s(Ni),e&&s(mr),e&&s(Hi),D(ll,e),e&&s(Vi),D(rl,e),e&&s(Qi),e&&s(hr),e&&s(Ri),D(ol,e),e&&s(Gi),D(il,e),e&&s(Wi),e&&s(Qa),e&&s(Ui),ea.d(e),e&&s(wr),D(cl,e),e&&s(Ji),e&&s(gr),e&&s(Xi),D(dl,e),e&&s(Ki),D(fl,e),e&&s(Yi),e&&s($r),e&&s(Zi),e&&s(ul),e&&s(ep),kl[Hs].d(e),e&&s(br),e&&s(xr),e&&s(sp),e&&s(jr),e&&s(tp),D(_l,e),e&&s(ap),e&&s(vr),e&&s(np),D(ml,e),e&&s(lp),ql[Qs].d(e),e&&s(kr),e&&s(Pe),e&&s(rp),El[Gs].d(e),e&&s(qr),e&&s(Er),e&&s(op),yl[Us].d(e),e&&s(yr),D(hl,e),e&&s(ip),e&&s(Dr),e&&s(pp),oe&&oe.d(e),e&&s(Cr),e&&s(Tr),e&&s(cp),D(Ra,e),e&&s(dp),ie&&ie.d(e),e&&s(Ar),e&&s(wl),e&&s(fp),e&&s(Ga),e&&s(up),D(gl,e),e&&s(_p),D($l,e),e&&s(mp),e&&s(Pr)}}}const um={local:"",sections:[{local:"",sections:[{local:"squad",title:"SQuAD \u6570\u636E\u96C6"},{local:"",title:"\u5904\u7406\u8BAD\u7EC3\u6570\u636E"},{local:"",title:"\u5904\u7406\u9A8C\u8BC1\u6570\u636E"}],title:"\u51C6\u5907\u6570\u636E"},{local:"trainer-api",title:"\u4F7F\u7528 `Trainer` API \u5FAE\u8C03\u6A21\u578B"},{local:"keras",sections:[{local:"",title:"\u540E\u5904\u7406"},{local:"",title:"\u5FAE\u8C03\u6A21\u578B"}],title:"\u4F7F\u7528 Keras \u5FAE\u8C03\u6A21\u578B"},{local:"",sections:[{local:"",title:"\u4E3A\u8BAD\u7EC3\u505A\u51C6\u5907"}],title:"\u81EA\u5B9A\u4E49\u8BAD\u7EC3\u5FAA\u73AF"},{local:"",title:"\u8BAD\u7EC3\u5FAA\u73AF"},{local:"",title:"\u4F7F\u7528\u5FAE\u8C03\u6A21\u578B"}],title:"\u95EE\u7B54"};function _m(H,c,h){let _="pt";return H_(()=>{const v=new URLSearchParams(window.location.search);h(0,_=v.get("fw")||"pt")}),[_]}class jm extends B_{constructor(c){super();I_(this,c,_m,fm,F_,{})}}export{jm as default,um as metadata};
