import{S as mr,i as ur,s as _r,e as c,k as u,w as B,t as a,M as cr,c as $,d as r,m as _,x as M,a as b,h as m,b as C,G as i,g as n,y as P,o as h,p as ke,q as y,B as q,v as $r,n as he}from"../../chunks/vendor-hf-doc-builder.js";import{Y as pr}from"../../chunks/Youtube-hf-doc-builder.js";import{I as br}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{C as A}from"../../chunks/CodeBlock-hf-doc-builder.js";import{D as ar}from"../../chunks/DocNotebookDropdown-hf-doc-builder.js";import{F as dr}from"../../chunks/FrameworkSwitchCourse-hf-doc-builder.js";function kr(k){let l,o;return l=new ar({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/chapter2/section3_tf.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/chapter2/section3_tf.ipynb"}]}}),{c(){B(l.$$.fragment)},l(t){M(l.$$.fragment,t)},m(t,p){P(l,t,p),o=!0},i(t){o||(y(l.$$.fragment,t),o=!0)},o(t){h(l.$$.fragment,t),o=!1},d(t){q(l,t)}}}function hr(k){let l,o;return l=new ar({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/chapter2/section3_pt.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/chapter2/section3_pt.ipynb"}]}}),{c(){B(l.$$.fragment)},l(t){M(l.$$.fragment,t)},m(t,p){P(l,t,p),o=!0},i(t){o||(y(l.$$.fragment,t),o=!0)},o(t){h(l.$$.fragment,t),o=!1},d(t){q(l,t)}}}function yr(k){let l,o;return l=new pr({props:{id:"d3JVgghSOew"}}),{c(){B(l.$$.fragment)},l(t){M(l.$$.fragment,t)},m(t,p){P(l,t,p),o=!0},i(t){o||(y(l.$$.fragment,t),o=!0)},o(t){h(l.$$.fragment,t),o=!1},d(t){q(l,t)}}}function vr(k){let l,o;return l=new pr({props:{id:"AhChOFRegn4"}}),{c(){B(l.$$.fragment)},l(t){M(l.$$.fragment,t)},m(t,p){P(l,t,p),o=!0},i(t){o||(y(l.$$.fragment,t),o=!0)},o(t){h(l.$$.fragment,t),o=!1},d(t){q(l,t)}}}function wr(k){let l,o,t,p,v;return{c(){l=c("p"),o=a(`\u5728\u672C\u8282\u4E2D\uFF0C\u6211\u4EEC\u5C06\u66F4\u8BE6\u7EC6\u5730\u4E86\u89E3\u5982\u4F55\u521B\u5EFA\u548C\u4F7F\u7528\u6A21\u578B\u3002\u6211\u4EEC\u5C06\u4F7F\u7528
AutoModel\u7C7B\uFF0C\u5F53\u60A8\u5E0C\u671B\u4ECE\u68C0\u67E5\u70B9\u5B9E\u4F8B\u5316\u4EFB\u4F55\u6A21\u578B\u65F6\uFF0C\u8FD9\u975E\u5E38\u65B9\u4FBF\u3002`),t=u(),p=c("p"),v=a("\u8FD9\u4E2AAutoModel\u7C7B\u53CA\u5176\u6240\u6709\u76F8\u5173\u9879\u5B9E\u9645\u4E0A\u662F\u5BF9\u5E93\u4E2D\u5404\u79CD\u53EF\u7528\u6A21\u578B\u7684\u7B80\u5355\u5305\u88C5\u3002\u5B83\u662F\u4E00\u4E2A\u806A\u660E\u7684\u5305\u88C5\u5668\uFF0C\u56E0\u4E3A\u5B83\u53EF\u4EE5\u81EA\u52A8\u731C\u6D4B\u68C0\u67E5\u70B9\u7684\u9002\u5F53\u6A21\u578B\u4F53\u7CFB\u7ED3\u6784\uFF0C\u7136\u540E\u7528\u8BE5\u4F53\u7CFB\u7ED3\u6784\u5B9E\u4F8B\u5316\u6A21\u578B\u3002")},l(f){l=$(f,"P",{});var d=b(l);o=m(d,`\u5728\u672C\u8282\u4E2D\uFF0C\u6211\u4EEC\u5C06\u66F4\u8BE6\u7EC6\u5730\u4E86\u89E3\u5982\u4F55\u521B\u5EFA\u548C\u4F7F\u7528\u6A21\u578B\u3002\u6211\u4EEC\u5C06\u4F7F\u7528
AutoModel\u7C7B\uFF0C\u5F53\u60A8\u5E0C\u671B\u4ECE\u68C0\u67E5\u70B9\u5B9E\u4F8B\u5316\u4EFB\u4F55\u6A21\u578B\u65F6\uFF0C\u8FD9\u975E\u5E38\u65B9\u4FBF\u3002`),d.forEach(r),t=_(f),p=$(f,"P",{});var w=b(p);v=m(w,"\u8FD9\u4E2AAutoModel\u7C7B\u53CA\u5176\u6240\u6709\u76F8\u5173\u9879\u5B9E\u9645\u4E0A\u662F\u5BF9\u5E93\u4E2D\u5404\u79CD\u53EF\u7528\u6A21\u578B\u7684\u7B80\u5355\u5305\u88C5\u3002\u5B83\u662F\u4E00\u4E2A\u806A\u660E\u7684\u5305\u88C5\u5668\uFF0C\u56E0\u4E3A\u5B83\u53EF\u4EE5\u81EA\u52A8\u731C\u6D4B\u68C0\u67E5\u70B9\u7684\u9002\u5F53\u6A21\u578B\u4F53\u7CFB\u7ED3\u6784\uFF0C\u7136\u540E\u7528\u8BE5\u4F53\u7CFB\u7ED3\u6784\u5B9E\u4F8B\u5316\u6A21\u578B\u3002"),w.forEach(r)},m(f,d){n(f,l,d),i(l,o),n(f,t,d),n(f,p,d),i(p,v)},d(f){f&&r(l),f&&r(t),f&&r(p)}}}function Er(k){let l,o,t,p,v;return{c(){l=c("p"),o=a(`\u5728\u672C\u8282\u4E2D\uFF0C\u6211\u4EEC\u5C06\u66F4\u8BE6\u7EC6\u5730\u4E86\u89E3\u5982\u4F55\u521B\u5EFA\u548C\u4F7F\u7528\u6A21\u578B\u3002\u6211\u4EEC\u5C06\u4F7F\u7528
AutoModel\u7C7B\uFF0C\u5F53\u60A8\u5E0C\u671B\u4ECE\u68C0\u67E5\u70B9\u5B9E\u4F8B\u5316\u4EFB\u4F55\u6A21\u578B\u65F6\uFF0C\u8FD9\u975E\u5E38\u65B9\u4FBF\u3002`),t=u(),p=c("p"),v=a("\u8FD9\u4E2AAutoModel\u7C7B\u53CA\u5176\u6240\u6709\u76F8\u5173\u9879\u5B9E\u9645\u4E0A\u662F\u5BF9\u5E93\u4E2D\u5404\u79CD\u53EF\u7528\u6A21\u578B\u7684\u7B80\u5355\u5305\u88C5\u3002\u5B83\u662F\u4E00\u4E2A\u806A\u660E\u7684\u5305\u88C5\u5668\uFF0C\u56E0\u4E3A\u5B83\u53EF\u4EE5\u81EA\u52A8\u731C\u6D4B\u68C0\u67E5\u70B9\u7684\u9002\u5F53\u6A21\u578B\u4F53\u7CFB\u7ED3\u6784\uFF0C\u7136\u540E\u7528\u8BE5\u4F53\u7CFB\u7ED3\u6784\u5B9E\u4F8B\u5316\u6A21\u578B\u3002")},l(f){l=$(f,"P",{});var d=b(l);o=m(d,`\u5728\u672C\u8282\u4E2D\uFF0C\u6211\u4EEC\u5C06\u66F4\u8BE6\u7EC6\u5730\u4E86\u89E3\u5982\u4F55\u521B\u5EFA\u548C\u4F7F\u7528\u6A21\u578B\u3002\u6211\u4EEC\u5C06\u4F7F\u7528
AutoModel\u7C7B\uFF0C\u5F53\u60A8\u5E0C\u671B\u4ECE\u68C0\u67E5\u70B9\u5B9E\u4F8B\u5316\u4EFB\u4F55\u6A21\u578B\u65F6\uFF0C\u8FD9\u975E\u5E38\u65B9\u4FBF\u3002`),d.forEach(r),t=_(f),p=$(f,"P",{});var w=b(p);v=m(w,"\u8FD9\u4E2AAutoModel\u7C7B\u53CA\u5176\u6240\u6709\u76F8\u5173\u9879\u5B9E\u9645\u4E0A\u662F\u5BF9\u5E93\u4E2D\u5404\u79CD\u53EF\u7528\u6A21\u578B\u7684\u7B80\u5355\u5305\u88C5\u3002\u5B83\u662F\u4E00\u4E2A\u806A\u660E\u7684\u5305\u88C5\u5668\uFF0C\u56E0\u4E3A\u5B83\u53EF\u4EE5\u81EA\u52A8\u731C\u6D4B\u68C0\u67E5\u70B9\u7684\u9002\u5F53\u6A21\u578B\u4F53\u7CFB\u7ED3\u6784\uFF0C\u7136\u540E\u7528\u8BE5\u4F53\u7CFB\u7ED3\u6784\u5B9E\u4F8B\u5316\u6A21\u578B\u3002"),w.forEach(r)},m(f,d){n(f,l,d),i(l,o),n(f,t,d),n(f,p,d),i(p,v)},d(f){f&&r(l),f&&r(t),f&&r(p)}}}function jr(k){let l,o;return l=new A({props:{code:`
`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> BertConfig, TFBertModel

<span class="hljs-comment"># Building the config</span>
config = BertConfig()

<span class="hljs-comment"># Building the model from the config</span>
model = TFBertModel(config)`}}),{c(){B(l.$$.fragment)},l(t){M(l.$$.fragment,t)},m(t,p){P(l,t,p),o=!0},i(t){o||(y(l.$$.fragment,t),o=!0)},o(t){h(l.$$.fragment,t),o=!1},d(t){q(l,t)}}}function Br(k){let l,o;return l=new A({props:{code:`
`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> BertConfig, BertModel

<span class="hljs-comment"># Building the config</span>
config = BertConfig()

<span class="hljs-comment"># Building the model from the config</span>
model = BertModel(config)`}}),{c(){B(l.$$.fragment)},l(t){M(l.$$.fragment,t)},m(t,p){P(l,t,p),o=!0},i(t){o||(y(l.$$.fragment,t),o=!0)},o(t){h(l.$$.fragment,t),o=!1},d(t){q(l,t)}}}function Mr(k){let l,o;return l=new A({props:{code:`
`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> BertConfig, TFBertModel

config = BertConfig()
model = TFBertModel(config)

<span class="hljs-comment"># Model is randomly initialized!</span>`}}),{c(){B(l.$$.fragment)},l(t){M(l.$$.fragment,t)},m(t,p){P(l,t,p),o=!0},i(t){o||(y(l.$$.fragment,t),o=!0)},o(t){h(l.$$.fragment,t),o=!1},d(t){q(l,t)}}}function Pr(k){let l,o;return l=new A({props:{code:`
`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> BertConfig, BertModel

config = BertConfig()
model = BertModel(config)

<span class="hljs-comment"># Model is randomly initialized!</span>`}}),{c(){B(l.$$.fragment)},l(t){M(l.$$.fragment,t)},m(t,p){P(l,t,p),o=!0},i(t){o||(y(l.$$.fragment,t),o=!0)},o(t){h(l.$$.fragment,t),o=!1},d(t){q(l,t)}}}function qr(k){let l,o,t,p,v;return l=new A({props:{code:"",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TFBertModel

model = TFBertModel.from_pretrained(<span class="hljs-string">&quot;bert-base-cased&quot;</span>)`}}),{c(){B(l.$$.fragment),o=u(),t=c("p"),p=a("\u6B63\u5982\u60A8\u4E4B\u524D\u770B\u5230\u7684\uFF0C\u6211\u4EEC\u53EF\u4EE5\u7528\u7B49\u6548\u7684AutoModel\u7C7B\u66FF\u6362Bert\u6A21\u578B\u3002\u4ECE\u73B0\u5728\u5F00\u59CB\uFF0C\u6211\u4EEC\u5C06\u8FD9\u6837\u505A\uFF0C\u56E0\u4E3A\u8FD9\u4F1A\u4EA7\u751F\u68C0\u67E5\u70B9\u4E0D\u53EF\u77E5\u7684\u4EE3\u7801\uFF1B\u5982\u679C\u60A8\u7684\u4EE3\u7801\u9002\u7528\u4E8E\u4E00\u4E2A\u68C0\u67E5\u70B9\uFF0C\u90A3\u4E48\u5B83\u5E94\u8BE5\u4E0E\u53E6\u4E00\u4E2A\u68C0\u67E5\u70B9\u65E0\u7F1D\u5730\u5DE5\u4F5C\u3002\u5373\u4F7F\u4F53\u7CFB\u7ED3\u6784\u4E0D\u540C\uFF0C\u8FD9\u4E5F\u9002\u7528\uFF0C\u53EA\u8981\u68C0\u67E5\u70B9\u662F\u9488\u5BF9\u7C7B\u4F3C\u4EFB\u52A1\uFF08\u4F8B\u5982\uFF0C\u60C5\u7EEA\u5206\u6790\u4EFB\u52A1\uFF09\u8BAD\u7EC3\u7684\u3002")},l(f){M(l.$$.fragment,f),o=_(f),t=$(f,"P",{});var d=b(t);p=m(d,"\u6B63\u5982\u60A8\u4E4B\u524D\u770B\u5230\u7684\uFF0C\u6211\u4EEC\u53EF\u4EE5\u7528\u7B49\u6548\u7684AutoModel\u7C7B\u66FF\u6362Bert\u6A21\u578B\u3002\u4ECE\u73B0\u5728\u5F00\u59CB\uFF0C\u6211\u4EEC\u5C06\u8FD9\u6837\u505A\uFF0C\u56E0\u4E3A\u8FD9\u4F1A\u4EA7\u751F\u68C0\u67E5\u70B9\u4E0D\u53EF\u77E5\u7684\u4EE3\u7801\uFF1B\u5982\u679C\u60A8\u7684\u4EE3\u7801\u9002\u7528\u4E8E\u4E00\u4E2A\u68C0\u67E5\u70B9\uFF0C\u90A3\u4E48\u5B83\u5E94\u8BE5\u4E0E\u53E6\u4E00\u4E2A\u68C0\u67E5\u70B9\u65E0\u7F1D\u5730\u5DE5\u4F5C\u3002\u5373\u4F7F\u4F53\u7CFB\u7ED3\u6784\u4E0D\u540C\uFF0C\u8FD9\u4E5F\u9002\u7528\uFF0C\u53EA\u8981\u68C0\u67E5\u70B9\u662F\u9488\u5BF9\u7C7B\u4F3C\u4EFB\u52A1\uFF08\u4F8B\u5982\uFF0C\u60C5\u7EEA\u5206\u6790\u4EFB\u52A1\uFF09\u8BAD\u7EC3\u7684\u3002"),d.forEach(r)},m(f,d){P(l,f,d),n(f,o,d),n(f,t,d),i(t,p),v=!0},i(f){v||(y(l.$$.fragment,f),v=!0)},o(f){h(l.$$.fragment,f),v=!1},d(f){q(l,f),f&&r(o),f&&r(t)}}}function Tr(k){let l,o,t,p,v;return l=new A({props:{code:"",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> BertModel

model = BertModel.from_pretrained(<span class="hljs-string">&quot;bert-base-cased&quot;</span>)`}}),{c(){B(l.$$.fragment),o=u(),t=c("p"),p=a("\u6B63\u5982\u60A8\u4E4B\u524D\u770B\u5230\u7684\uFF0C\u6211\u4EEC\u53EF\u4EE5\u7528\u7B49\u6548\u7684AutoModel\u7C7B\u66FF\u6362Bert\u6A21\u578B\u3002\u4ECE\u73B0\u5728\u5F00\u59CB\uFF0C\u6211\u4EEC\u5C06\u8FD9\u6837\u505A\uFF0C\u56E0\u4E3A\u8FD9\u4F1A\u4EA7\u751F\u68C0\u67E5\u70B9\u4E0D\u53EF\u77E5\u7684\u4EE3\u7801\uFF1B\u5982\u679C\u60A8\u7684\u4EE3\u7801\u9002\u7528\u4E8E\u4E00\u4E2A\u68C0\u67E5\u70B9\uFF0C\u90A3\u4E48\u5B83\u5E94\u8BE5\u4E0E\u53E6\u4E00\u4E2A\u68C0\u67E5\u70B9\u65E0\u7F1D\u5730\u5DE5\u4F5C\u3002\u5373\u4F7F\u4F53\u7CFB\u7ED3\u6784\u4E0D\u540C\uFF0C\u8FD9\u4E5F\u9002\u7528\uFF0C\u53EA\u8981\u68C0\u67E5\u70B9\u662F\u9488\u5BF9\u7C7B\u4F3C\u4EFB\u52A1\uFF08\u4F8B\u5982\uFF0C\u60C5\u7EEA\u5206\u6790\u4EFB\u52A1\uFF09\u8BAD\u7EC3\u7684\u3002")},l(f){M(l.$$.fragment,f),o=_(f),t=$(f,"P",{});var d=b(t);p=m(d,"\u6B63\u5982\u60A8\u4E4B\u524D\u770B\u5230\u7684\uFF0C\u6211\u4EEC\u53EF\u4EE5\u7528\u7B49\u6548\u7684AutoModel\u7C7B\u66FF\u6362Bert\u6A21\u578B\u3002\u4ECE\u73B0\u5728\u5F00\u59CB\uFF0C\u6211\u4EEC\u5C06\u8FD9\u6837\u505A\uFF0C\u56E0\u4E3A\u8FD9\u4F1A\u4EA7\u751F\u68C0\u67E5\u70B9\u4E0D\u53EF\u77E5\u7684\u4EE3\u7801\uFF1B\u5982\u679C\u60A8\u7684\u4EE3\u7801\u9002\u7528\u4E8E\u4E00\u4E2A\u68C0\u67E5\u70B9\uFF0C\u90A3\u4E48\u5B83\u5E94\u8BE5\u4E0E\u53E6\u4E00\u4E2A\u68C0\u67E5\u70B9\u65E0\u7F1D\u5730\u5DE5\u4F5C\u3002\u5373\u4F7F\u4F53\u7CFB\u7ED3\u6784\u4E0D\u540C\uFF0C\u8FD9\u4E5F\u9002\u7528\uFF0C\u53EA\u8981\u68C0\u67E5\u70B9\u662F\u9488\u5BF9\u7C7B\u4F3C\u4EFB\u52A1\uFF08\u4F8B\u5982\uFF0C\u60C5\u7EEA\u5206\u6790\u4EFB\u52A1\uFF09\u8BAD\u7EC3\u7684\u3002"),d.forEach(r)},m(f,d){P(l,f,d),n(f,o,d),n(f,t,d),i(t,p),v=!0},i(f){v||(y(l.$$.fragment,f),v=!0)},o(f){h(l.$$.fragment,f),v=!1},d(f){q(l,f),f&&r(o),f&&r(t)}}}function gr(k){let l,o;return l=new A({props:{code:"",highlighted:`ls <span class="hljs-keyword">directory_on_my_computer
</span>
<span class="hljs-built_in">config</span>.<span class="hljs-keyword">json </span>tf_model.h5`}}),{c(){B(l.$$.fragment)},l(t){M(l.$$.fragment,t)},m(t,p){P(l,t,p),o=!0},i(t){o||(y(l.$$.fragment,t),o=!0)},o(t){h(l.$$.fragment,t),o=!1},d(t){q(l,t)}}}function Cr(k){let l,o;return l=new A({props:{code:"",highlighted:`ls <span class="hljs-keyword">directory_on_my_computer
</span>
<span class="hljs-built_in">config</span>.<span class="hljs-keyword">json </span>pytorch_model.<span class="hljs-keyword">bin</span>`}}),{c(){B(l.$$.fragment)},l(t){M(l.$$.fragment,t)},m(t,p){P(l,t,p),o=!0},i(t){o||(y(l.$$.fragment,t),o=!0)},o(t){h(l.$$.fragment,t),o=!1},d(t){q(l,t)}}}function Ar(k){let l,o,t,p,v,f,d,w;return{c(){l=c("p"),o=a("\u8FD9\u4E2A "),t=c("em"),p=a("pytorch_model.bin"),v=a(" \u6587\u4EF6\u5C31\u662F\u4F17\u6240\u5468\u77E5\u7684"),f=c("em"),d=a("state dictionary"),w=a("; \u5B83\u5305\u542B\u6A21\u578B\u7684\u6240\u6709\u6743\u91CD\u3002\u8FD9\u4E24\u4E2A\u6587\u4EF6\u9F50\u5934\u5E76\u8FDB\uFF1B\u914D\u7F6E\u662F\u4E86\u89E3\u6A21\u578B\u4F53\u7CFB\u7ED3\u6784\u6240\u5FC5\u9700\u7684\uFF0C\u800C\u6A21\u578B\u6743\u91CD\u662F\u6A21\u578B\u7684\u53C2\u6570\u3002")},l(j){l=$(j,"P",{});var E=b(l);o=m(E,"\u8FD9\u4E2A "),t=$(E,"EM",{});var T=b(t);p=m(T,"pytorch_model.bin"),T.forEach(r),v=m(E," \u6587\u4EF6\u5C31\u662F\u4F17\u6240\u5468\u77E5\u7684"),f=$(E,"EM",{});var g=b(f);d=m(g,"state dictionary"),g.forEach(r),w=m(E,"; \u5B83\u5305\u542B\u6A21\u578B\u7684\u6240\u6709\u6743\u91CD\u3002\u8FD9\u4E24\u4E2A\u6587\u4EF6\u9F50\u5934\u5E76\u8FDB\uFF1B\u914D\u7F6E\u662F\u4E86\u89E3\u6A21\u578B\u4F53\u7CFB\u7ED3\u6784\u6240\u5FC5\u9700\u7684\uFF0C\u800C\u6A21\u578B\u6743\u91CD\u662F\u6A21\u578B\u7684\u53C2\u6570\u3002"),E.forEach(r)},m(j,E){n(j,l,E),i(l,o),i(l,t),i(t,p),i(l,v),i(l,f),i(f,d),i(l,w)},d(j){j&&r(l)}}}function Nr(k){let l,o,t,p,v,f,d,w;return{c(){l=c("p"),o=a("\u8FD9\u4E2A "),t=c("em"),p=a("pytorch_model.bin"),v=a(" \u6587\u4EF6\u5C31\u662F\u4F17\u6240\u5468\u77E5\u7684"),f=c("em"),d=a("state dictionary"),w=a("; \u5B83\u5305\u542B\u6A21\u578B\u7684\u6240\u6709\u6743\u91CD\u3002\u8FD9\u4E24\u4E2A\u6587\u4EF6\u9F50\u5934\u5E76\u8FDB\uFF1B\u914D\u7F6E\u662F\u4E86\u89E3\u6A21\u578B\u4F53\u7CFB\u7ED3\u6784\u6240\u5FC5\u9700\u7684\uFF0C\u800C\u6A21\u578B\u6743\u91CD\u662F\u6A21\u578B\u7684\u53C2\u6570\u3002")},l(j){l=$(j,"P",{});var E=b(l);o=m(E,"\u8FD9\u4E2A "),t=$(E,"EM",{});var T=b(t);p=m(T,"pytorch_model.bin"),T.forEach(r),v=m(E," \u6587\u4EF6\u5C31\u662F\u4F17\u6240\u5468\u77E5\u7684"),f=$(E,"EM",{});var g=b(f);d=m(g,"state dictionary"),g.forEach(r),w=m(E,"; \u5B83\u5305\u542B\u6A21\u578B\u7684\u6240\u6709\u6743\u91CD\u3002\u8FD9\u4E24\u4E2A\u6587\u4EF6\u9F50\u5934\u5E76\u8FDB\uFF1B\u914D\u7F6E\u662F\u4E86\u89E3\u6A21\u578B\u4F53\u7CFB\u7ED3\u6784\u6240\u5FC5\u9700\u7684\uFF0C\u800C\u6A21\u578B\u6743\u91CD\u662F\u6A21\u578B\u7684\u53C2\u6570\u3002"),E.forEach(r)},m(j,E){n(j,l,E),i(l,o),i(l,t),i(t,p),i(l,v),i(l,f),i(f,d),i(l,w)},d(j){j&&r(l)}}}function Hr(k){let l,o;return l=new A({props:{code:"",highlighted:`<span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf

model_inputs = tf.constant(encoded_sequences)`}}),{c(){B(l.$$.fragment)},l(t){M(l.$$.fragment,t)},m(t,p){P(l,t,p),o=!0},i(t){o||(y(l.$$.fragment,t),o=!0)},o(t){h(l.$$.fragment,t),o=!1},d(t){q(l,t)}}}function Rr(k){let l,o;return l=new A({props:{code:"",highlighted:`<span class="hljs-keyword">import</span> torch

model_inputs = torch.tensor(encoded_sequences)`}}),{c(){B(l.$$.fragment)},l(t){M(l.$$.fragment,t)},m(t,p){P(l,t,p),o=!0},i(t){o||(y(l.$$.fragment,t),o=!0)},o(t){h(l.$$.fragment,t),o=!1},d(t){q(l,t)}}}function Fr(k){let l,o,t,p,v,f,d,w,j,E,T,g,ye,ve,we,xt,rt,X,Gt,st,Ee,Jt,ot,N,H,je,Be,Lt,nt,Z,ft,ee,it,Y,Yt,Ze,Ut,Vt,pt,te,Kt,at,Me,Qt,mt,R,F,Pe,U,Wt,qe,Xt,Zt,ut,Te,el,_t,z,S,ge,Ce,tl,ct,V,ll,le,rl,sl,$t,Ae,ol,bt,Ne,nl,dt,K,fl,re,il,pl,kt,se,al,ht,He,ml,yt,oe,vt,Re,ul,wt,D,I,Fe,ze,_l,Et,Se,G,Q,et,ne,cl,tt,$l,jt,De,bl,Bt,Ie,dl,Mt,Oe,kl,Pt,fe,qt,xe,hl,Tt,ie,gt,Ge,yl,Ct,O,x,Je,pe,vl,At,Le,wl,Nt,ae,Ht,Ye,El,Rt;t=new dr({props:{fw:k[0]}});const jl=[hr,kr],me=[];function Bl(e,s){return e[0]==="pt"?0:1}w=Bl(k),j=me[w]=jl[w](k);const Ml=[vr,yr],ue=[];function Pl(e,s){return e[0]==="pt"?0:1}T=Pl(k),g=ue[T]=Ml[T](k);function ql(e,s){return e[0]==="pt"?Er:wr}let Ft=ql(k),J=Ft(k);const Tl=[Br,jr],_e=[];function gl(e,s){return e[0]==="pt"?0:1}N=gl(k),H=_e[N]=Tl[N](k),Z=new A({props:{code:"print(config)",highlighted:'<span class="hljs-built_in">print</span>(config)'}}),ee=new A({props:{code:`BertConfig {
  [...]
  "hidden_size": 768,
  "intermediate_size": 3072,
  "max_position_embeddings": 512,
  "num_attention_heads": 12,
  "num_hidden_layers": 12,
  [...]
}`,highlighted:`BertConfig {
  [...]
  <span class="hljs-string">&quot;hidden_size&quot;</span>: <span class="hljs-number">768</span>,
  <span class="hljs-string">&quot;intermediate_size&quot;</span>: <span class="hljs-number">3072</span>,
  <span class="hljs-string">&quot;max_position_embeddings&quot;</span>: <span class="hljs-number">512</span>,
  <span class="hljs-string">&quot;num_attention_heads&quot;</span>: <span class="hljs-number">12</span>,
  <span class="hljs-string">&quot;num_hidden_layers&quot;</span>: <span class="hljs-number">12</span>,
  [...]
}`}});const Cl=[Pr,Mr],ce=[];function Al(e,s){return e[0]==="pt"?0:1}R=Al(k),F=ce[R]=Cl[R](k);const Nl=[Tr,qr],$e=[];function Hl(e,s){return e[0]==="pt"?0:1}z=Hl(k),S=$e[z]=Nl[z](k),oe=new A({props:{code:'model.save_pretrained("directory_on_my_computer")',highlighted:'model.save_pretrained(<span class="hljs-string">&quot;directory_on_my_computer&quot;</span>)'}});const Rl=[Cr,gr],be=[];function Fl(e,s){return e[0]==="pt"?0:1}D=Fl(k),I=be[D]=Rl[D](k);function zl(e,s){return e[0]==="pt"?Nr:Ar}let zt=zl(k),L=zt(k);ne=new br({}),fe=new A({props:{code:'sequences = ["Hello!", "Cool.", "Nice!"]',highlighted:'sequences = [<span class="hljs-string">&quot;Hello!&quot;</span>, <span class="hljs-string">&quot;Cool.&quot;</span>, <span class="hljs-string">&quot;Nice!&quot;</span>]'}}),ie=new A({props:{code:`encoded_sequences = [
    [101, 7592, 999, 102],
    [101, 4658, 1012, 102],
    [101, 3835, 999, 102],
]`,highlighted:`encoded_sequences = [
    [<span class="hljs-number">101</span>, <span class="hljs-number">7592</span>, <span class="hljs-number">999</span>, <span class="hljs-number">102</span>],
    [<span class="hljs-number">101</span>, <span class="hljs-number">4658</span>, <span class="hljs-number">1012</span>, <span class="hljs-number">102</span>],
    [<span class="hljs-number">101</span>, <span class="hljs-number">3835</span>, <span class="hljs-number">999</span>, <span class="hljs-number">102</span>],
]`}});const Sl=[Rr,Hr],de=[];function Dl(e,s){return e[0]==="pt"?0:1}return O=Dl(k),x=de[O]=Sl[O](k),ae=new A({props:{code:"output = model(model_inputs)",highlighted:"output = model(model_inputs)"}}),{c(){l=c("meta"),o=u(),B(t.$$.fragment),p=u(),v=c("h1"),f=a("\u6A21\u578B"),d=u(),j.c(),E=u(),g.c(),ye=u(),J.c(),ve=u(),we=c("p"),xt=a("\u4F46\u662F\uFF0C\u5982\u679C\u60A8\u77E5\u9053\u8981\u4F7F\u7528\u7684\u6A21\u578B\u7C7B\u578B\uFF0C\u5219\u53EF\u4EE5\u4F7F\u7528\u76F4\u63A5\u5B9A\u4E49\u5176\u4F53\u7CFB\u7ED3\u6784\u7684\u7C7B\u3002\u8BA9\u6211\u4EEC\u770B\u770B\u8FD9\u662F\u5982\u4F55\u4E0EBERT\u6A21\u578B\u4E00\u8D77\u5DE5\u4F5C\u7684\u3002"),rt=u(),X=c("h2"),Gt=a("\u521B\u5EFA\u8F6C\u6362\u5668"),st=u(),Ee=c("p"),Jt=a("\u521D\u59CB\u5316BERT\u6A21\u578B\u9700\u8981\u505A\u7684\u7B2C\u4E00\u4EF6\u4E8B\u662F\u52A0\u8F7D\u914D\u7F6E\u5BF9\u8C61\uFF1A"),ot=u(),H.c(),je=u(),Be=c("p"),Lt=a("\u914D\u7F6E\u5305\u542B\u8BB8\u591A\u7528\u4E8E\u6784\u5EFA\u6A21\u578B\u7684\u5C5E\u6027\uFF1A"),nt=u(),B(Z.$$.fragment),ft=u(),B(ee.$$.fragment),it=u(),Y=c("p"),Yt=a("\u867D\u7136\u60A8\u8FD8\u6CA1\u6709\u770B\u5230\u6240\u6709\u8FD9\u4E9B\u5C5E\u6027\u90FD\u505A\u4E86\u4EC0\u4E48\uFF0C\u4F46\u60A8\u5E94\u8BE5\u8BA4\u8BC6\u5230\u5176\u4E2D\u7684\u4E00\u4E9B\u5C5E\u6027\uFF1Ahidden"),Ze=c("em"),Ut=a("size\u5C5E\u6027\u5B9A\u4E49\u4E86hidden"),Vt=a("\u72B6\u6001\u5411\u91CF\u7684\u5927\u5C0F\uFF0Cnum_hidden_layers\u5B9A\u4E49\u4E86Transformer\u6A21\u578B\u7684\u5C42\u6570\u3002"),pt=u(),te=c("h3"),Kt=a("\u4E0D\u540C\u7684\u52A0\u8F7D\u65B9\u5F0F"),at=u(),Me=c("p"),Qt=a("\u4ECE\u9ED8\u8BA4\u914D\u7F6E\u521B\u5EFA\u6A21\u578B\u4F1A\u4F7F\u7528\u968F\u673A\u503C\u5BF9\u5176\u8FDB\u884C\u521D\u59CB\u5316\uFF1A"),mt=u(),F.c(),Pe=u(),U=c("p"),Wt=a(`\u8BE5\u6A21\u578B\u53EF\u4EE5\u5728\u8FD9\u79CD\u72B6\u6001\u4E0B\u4F7F\u7528\uFF0C\u4F46\u4F1A\u8F93\u51FA\u80E1\u8A00\u4E71\u8BED\uFF1B\u9996\u5148\u9700\u8981\u5BF9\u5176\u8FDB\u884C\u8BAD\u7EC3\u3002\u6211\u4EEC\u53EF\u4EE5\u6839\u636E\u624B\u5934\u7684\u4EFB\u52A1\u4ECE\u5934\u5F00\u59CB\u8BAD\u7EC3\u6A21\u578B\uFF0C\u4F46\u6B63\u5982\u60A8\u5728
`),qe=c("a"),Xt=a("Chapter 1"),Zt=a(`
\uFF0C\u8FD9\u5C06\u9700\u8981\u5F88\u957F\u7684\u65F6\u95F4\u548C\u5927\u91CF\u7684\u6570\u636E\uFF0C\u5E76\u5C06\u4EA7\u751F\u4E0D\u53EF\u5FFD\u89C6\u7684\u73AF\u5883\u5F71\u54CD\u3002\u4E3A\u4E86\u907F\u514D\u4E0D\u5FC5\u8981\u7684\u91CD\u590D\u5DE5\u4F5C\uFF0C\u5FC5\u987B\u80FD\u591F\u5171\u4EAB\u548C\u91CD\u7528\u5DF2\u7ECF\u8BAD\u7EC3\u8FC7\u7684\u6A21\u578B\u3002`),ut=u(),Te=c("p"),el=a(`\u52A0\u8F7D\u5DF2\u7ECF\u8BAD\u7EC3\u8FC7\u7684Transformers\u6A21\u578B\u5F88\u7B80\u5355-\u6211\u4EEC\u53EF\u4EE5\u4F7F\u7528from_pretrained()
\u65B9\u6CD5\uFF1A`),_t=u(),S.c(),ge=u(),Ce=c("p"),tl=a("\u5728\u4E0A\u9762\u7684\u4EE3\u7801\u793A\u4F8B\u4E2D\uFF0C\u6211\u4EEC\u6CA1\u6709\u4F7F\u7528BertConfig"),ct=u(),V=c("p"),ll=a(`\uFF0C\u800C\u662F\u901A\u8FC7Bert base cased\u6807\u8BC6\u7B26\u52A0\u8F7D\u4E86\u4E00\u4E2A\u9884\u8BAD\u7EC3\u6A21\u578B\u3002\u8FD9\u662F\u4E00\u4E2A\u6A21\u578B\u68C0\u67E5\u70B9\uFF0C\u7531BERT\u7684\u4F5C\u8005\u81EA\u5DF1\u8BAD\u7EC3\uFF1B\u60A8\u53EF\u4EE5\u5728
`),le=c("a"),rl=a("model card"),sl=a("\u4E2D\u627E\u5230\u66F4\u591A\u7EC6\u8282."),$t=u(),Ae=c("p"),ol=a("\u8BE5\u6A21\u578B\u73B0\u5728\u4F7F\u7528\u68C0\u67E5\u70B9\u7684\u6240\u6709\u6743\u91CD\u8FDB\u884C\u521D\u59CB\u5316\u3002\u5B83\u53EF\u4EE5\u76F4\u63A5\u7528\u4E8E\u5BF9\u8BAD\u7EC3\u8FC7\u7684\u4EFB\u52A1\u8FDB\u884C\u63A8\u7406\uFF0C\u4E5F\u53EF\u4EE5\u5BF9\u65B0\u4EFB\u52A1\u8FDB\u884C\u5FAE\u8C03\u3002\u901A\u8FC7\u9884\u5148\u8BAD\u7EC3\u91CD\u91CF\u800C\u4E0D\u662F\u4ECE\u5934\u5F00\u59CB\u7684\u8BAD\u7EC3\uFF0C\u6211\u4EEC\u53EF\u4EE5\u5F88\u5FEB\u53D6\u5F97\u597D\u7684\u6548\u679C\u3002"),bt=u(),Ne=c("p"),nl=a(`\u6743\u91CD\u5DF2\u4E0B\u8F7D\u5E76\u7F13\u5B58\u5728\u7F13\u5B58\u6587\u4EF6\u5939\u4E2D\uFF08\u56E0\u6B64\u5C06\u6765\u5BF9from_pretrained()\u65B9\u6CD5\u7684\u8C03\u7528\u5C06\u4E0D\u4F1A\u91CD\u65B0\u4E0B\u8F7D\u5B83\u4EEC\uFF09\u9ED8\u8BA4\u4E3A
~/.cache/huggingface/transformers
. \u60A8\u53EF\u4EE5\u901A\u8FC7\u8BBE\u7F6E
HF_HOME
\u73AF\u5883\u53D8\u91CF\u6765\u81EA\u5B9A\u4E49\u7F13\u5B58\u6587\u4EF6\u5939\u3002`),dt=u(),K=c("p"),fl=a(`\u7528\u4E8E\u52A0\u8F7D\u6A21\u578B\u7684\u6807\u8BC6\u7B26\u53EF\u4EE5\u662F\u6A21\u578B\u4E2D\u5FC3Hub\u4E0A\u4EFB\u4F55\u6A21\u578B\u7684\u6807\u8BC6\u7B26\uFF0C\u53EA\u8981\u5B83\u4E0EBERT\u4F53\u7CFB\u7ED3\u6784\u517C\u5BB9\u3002\u53EF\u4EE5\u627E\u5230\u53EF\u7528\u7684BERT\u68C0\u67E5\u70B9\u7684\u5B8C\u6574\u5217\u8868
`),re=c("a"),il=a("here"),pl=a(`
.`),kt=u(),se=c("h3"),al=a("\u4FDD\u5B58\u6A21\u578B"),ht=u(),He=c("p"),ml=a(`\u4FDD\u5B58\u6A21\u578B\u548C\u52A0\u8F7D\u6A21\u578B\u4E00\u6837\u7B80\u5355\u2014\u6211\u4EEC\u4F7F\u7528
save_pretrained()
\u65B9\u6CD5\uFF0C\u7C7B\u4F3C\u4E8E
from_pretrained()
\u65B9\u6CD5\uFF1A`),yt=u(),B(oe.$$.fragment),vt=u(),Re=c("p"),ul=a("\u8FD9\u4F1A\u5C06\u4E24\u4E2A\u6587\u4EF6\u4FDD\u5B58\u5230\u78C1\u76D8\uFF1A"),wt=u(),I.c(),Fe=u(),ze=c("p"),_l=a(`\u5982\u679C\u4F60\u770B\u4E00\u4E0B
config.json
\u6587\u4EF6\uFF0C\u60A8\u5C06\u8BC6\u522B\u6784\u5EFA\u6A21\u578B\u4F53\u7CFB\u7ED3\u6784\u6240\u9700\u7684\u5C5E\u6027\u3002\u8BE5\u6587\u4EF6\u8FD8\u5305\u542B\u4E00\u4E9B\u5143\u6570\u636E\uFF0C\u4F8B\u5982\u68C0\u67E5\u70B9\u7684\u6765\u6E90\u4EE5\u53CA\u4E0A\u6B21\u4FDD\u5B58\u68C0\u67E5\u70B9\u65F6\u4F7F\u7528\u7684\u{1F917} Transformers\u7248\u672C\u3002`),Et=u(),L.c(),Se=u(),G=c("h3"),Q=c("a"),et=c("span"),B(ne.$$.fragment),cl=u(),tt=c("span"),$l=a("\u4F7F\u7528Transformers\u6A21\u578B\u8FDB\u884C\u63A8\u7406"),jt=u(),De=c("p"),bl=a("\u65E2\u7136\u60A8\u77E5\u9053\u4E86\u5982\u4F55\u52A0\u8F7D\u548C\u4FDD\u5B58\u6A21\u578B\uFF0C\u90A3\u4E48\u8BA9\u6211\u4EEC\u5C1D\u8BD5\u4F7F\u7528\u5B83\u8FDB\u884C\u4E00\u4E9B\u9884\u6D4B\u3002Transformer\u6A21\u578B\u53EA\u80FD\u5904\u7406\u6570\u5B57\u2014\u2014\u5206\u8BCD\u5668\u751F\u6210\u7684\u6570\u5B57\u3002\u4F46\u5728\u6211\u4EEC\u8BA8\u8BBA\u6807\u8BB0\u5316\u5668\u4E4B\u524D\uFF0C\u8BA9\u6211\u4EEC\u5148\u63A2\u8BA8\u6A21\u578B\u63A5\u53D7\u54EA\u4E9B\u8F93\u5165\u3002"),Bt=u(),Ie=c("p"),dl=a("\u6807\u8BB0\u5316\u5668\u53EF\u4EE5\u5C06\u8F93\u5165\u8F6C\u6362\u4E3A\u9002\u5F53\u7684\u6846\u67B6\u5F20\u91CF\uFF0C\u4F46\u4E3A\u4E86\u5E2E\u52A9\u60A8\u4E86\u89E3\u53D1\u751F\u4E86\u4EC0\u4E48\uFF0C\u6211\u4EEC\u5C06\u5FEB\u901F\u4E86\u89E3\u5728\u5C06\u8F93\u5165\u53D1\u9001\u5230\u6A21\u578B\u4E4B\u524D\u5FC5\u987B\u505A\u4EC0\u4E48\u3002"),Mt=u(),Oe=c("p"),kl=a("\u5047\u8BBE\u6211\u4EEC\u6709\u51E0\u4E2A\u5E8F\u5217\uFF1A"),Pt=u(),B(fe.$$.fragment),qt=u(),xe=c("p"),hl=a(`\u5206\u8BCD\u5668\u5C06\u8FD9\u4E9B\u8F6C\u6362\u4E3A\u8BCD\u6C47\u8868\u7D22\u5F15\uFF0C\u901A\u5E38\u79F0\u4E3A
input IDs
. \u6BCF\u4E2A\u5E8F\u5217\u73B0\u5728\u90FD\u662F\u4E00\u4E2A\u6570\u5B57\u5217\u8868\uFF01\u7ED3\u679C\u662F\uFF1A`),Tt=u(),B(ie.$$.fragment),gt=u(),Ge=c("p"),yl=a("\u8FD9\u662F\u4E00\u4E2A\u7F16\u7801\u5E8F\u5217\u5217\u8868\uFF1A\u4E00\u4E2A\u5217\u8868\u5217\u8868\u3002\u5F20\u91CF\u53EA\u63A5\u53D7\u77E9\u5F62\uFF08\u60F3\u60F3\u77E9\u9635\uFF09\u3002\u6B64\u201C\u6570\u7EC4\u201D\u5DF2\u4E3A\u77E9\u5F62\uFF0C\u56E0\u6B64\u5C06\u5176\u8F6C\u6362\u4E3A\u5F20\u91CF\u5F88\u5BB9\u6613\uFF1A"),Ct=u(),x.c(),Je=u(),pe=c("h3"),vl=a("\u4F7F\u7528\u5F20\u91CF\u4F5C\u4E3A\u6A21\u578B\u7684\u8F93\u5165"),At=u(),Le=c("p"),wl=a("\u5728\u6A21\u578B\u4E2D\u4F7F\u7528\u5F20\u91CF\u975E\u5E38\u7B80\u5355-\u6211\u4EEC\u53EA\u9700\u5C06\u8F93\u5165\u79F0\u4E3A\u6A21\u578B\uFF1A"),Nt=u(),B(ae.$$.fragment),Ht=u(),Ye=c("p"),El=a(`\u867D\u7136\u6A21\u578B\u63A5\u53D7\u8BB8\u591A\u4E0D\u540C\u7684\u53C2\u6570\uFF0C\u4F46\u53EA\u9700\u8981
input IDs\u3002\u6211\u4EEC\u7A0D\u540E\u5C06\u89E3\u91CA\u5176\u4ED6\u53C2\u6570\u7684\u4F5C\u7528\u4EE5\u53CA\u4F55\u65F6\u9700\u8981\u5B83\u4EEC\uFF0C\u4F46\u9996\u5148\u6211\u4EEC\u9700\u8981\u66F4\u4ED4\u7EC6\u5730\u4E86\u89E3
Transformer\u6A21\u578B\u53EF\u4EE5\u7406\u89E3\u7684\u8F93\u5165\u7684\u6807\u8BB0`),this.h()},l(e){const s=cr('[data-svelte="svelte-1phssyn"]',document.head);l=$(s,"META",{name:!0,content:!0}),s.forEach(r),o=_(e),M(t.$$.fragment,e),p=_(e),v=$(e,"H1",{id:!0});var lt=b(v);f=m(lt,"\u6A21\u578B"),lt.forEach(r),d=_(e),j.l(e),E=_(e),g.l(e),ye=_(e),J.l(e),ve=_(e),we=$(e,"P",{});var Ue=b(we);xt=m(Ue,"\u4F46\u662F\uFF0C\u5982\u679C\u60A8\u77E5\u9053\u8981\u4F7F\u7528\u7684\u6A21\u578B\u7C7B\u578B\uFF0C\u5219\u53EF\u4EE5\u4F7F\u7528\u76F4\u63A5\u5B9A\u4E49\u5176\u4F53\u7CFB\u7ED3\u6784\u7684\u7C7B\u3002\u8BA9\u6211\u4EEC\u770B\u770B\u8FD9\u662F\u5982\u4F55\u4E0EBERT\u6A21\u578B\u4E00\u8D77\u5DE5\u4F5C\u7684\u3002"),Ue.forEach(r),rt=_(e),X=$(e,"H2",{id:!0});var Ve=b(X);Gt=m(Ve,"\u521B\u5EFA\u8F6C\u6362\u5668"),Ve.forEach(r),st=_(e),Ee=$(e,"P",{});var Ke=b(Ee);Jt=m(Ke,"\u521D\u59CB\u5316BERT\u6A21\u578B\u9700\u8981\u505A\u7684\u7B2C\u4E00\u4EF6\u4E8B\u662F\u52A0\u8F7D\u914D\u7F6E\u5BF9\u8C61\uFF1A"),Ke.forEach(r),ot=_(e),H.l(e),je=_(e),Be=$(e,"P",{});var Qe=b(Be);Lt=m(Qe,"\u914D\u7F6E\u5305\u542B\u8BB8\u591A\u7528\u4E8E\u6784\u5EFA\u6A21\u578B\u7684\u5C5E\u6027\uFF1A"),Qe.forEach(r),nt=_(e),M(Z.$$.fragment,e),ft=_(e),M(ee.$$.fragment,e),it=_(e),Y=$(e,"P",{});var W=b(Y);Yt=m(W,"\u867D\u7136\u60A8\u8FD8\u6CA1\u6709\u770B\u5230\u6240\u6709\u8FD9\u4E9B\u5C5E\u6027\u90FD\u505A\u4E86\u4EC0\u4E48\uFF0C\u4F46\u60A8\u5E94\u8BE5\u8BA4\u8BC6\u5230\u5176\u4E2D\u7684\u4E00\u4E9B\u5C5E\u6027\uFF1Ahidden"),Ze=$(W,"EM",{});var We=b(Ze);Ut=m(We,"size\u5C5E\u6027\u5B9A\u4E49\u4E86hidden"),We.forEach(r),Vt=m(W,"\u72B6\u6001\u5411\u91CF\u7684\u5927\u5C0F\uFF0Cnum_hidden_layers\u5B9A\u4E49\u4E86Transformer\u6A21\u578B\u7684\u5C42\u6570\u3002"),W.forEach(r),pt=_(e),te=$(e,"H3",{id:!0});var Xe=b(te);Kt=m(Xe,"\u4E0D\u540C\u7684\u52A0\u8F7D\u65B9\u5F0F"),Xe.forEach(r),at=_(e),Me=$(e,"P",{});var Il=b(Me);Qt=m(Il,"\u4ECE\u9ED8\u8BA4\u914D\u7F6E\u521B\u5EFA\u6A21\u578B\u4F1A\u4F7F\u7528\u968F\u673A\u503C\u5BF9\u5176\u8FDB\u884C\u521D\u59CB\u5316\uFF1A"),Il.forEach(r),mt=_(e),F.l(e),Pe=_(e),U=$(e,"P",{});var St=b(U);Wt=m(St,`\u8BE5\u6A21\u578B\u53EF\u4EE5\u5728\u8FD9\u79CD\u72B6\u6001\u4E0B\u4F7F\u7528\uFF0C\u4F46\u4F1A\u8F93\u51FA\u80E1\u8A00\u4E71\u8BED\uFF1B\u9996\u5148\u9700\u8981\u5BF9\u5176\u8FDB\u884C\u8BAD\u7EC3\u3002\u6211\u4EEC\u53EF\u4EE5\u6839\u636E\u624B\u5934\u7684\u4EFB\u52A1\u4ECE\u5934\u5F00\u59CB\u8BAD\u7EC3\u6A21\u578B\uFF0C\u4F46\u6B63\u5982\u60A8\u5728
`),qe=$(St,"A",{href:!0});var Ol=b(qe);Xt=m(Ol,"Chapter 1"),Ol.forEach(r),Zt=m(St,`
\uFF0C\u8FD9\u5C06\u9700\u8981\u5F88\u957F\u7684\u65F6\u95F4\u548C\u5927\u91CF\u7684\u6570\u636E\uFF0C\u5E76\u5C06\u4EA7\u751F\u4E0D\u53EF\u5FFD\u89C6\u7684\u73AF\u5883\u5F71\u54CD\u3002\u4E3A\u4E86\u907F\u514D\u4E0D\u5FC5\u8981\u7684\u91CD\u590D\u5DE5\u4F5C\uFF0C\u5FC5\u987B\u80FD\u591F\u5171\u4EAB\u548C\u91CD\u7528\u5DF2\u7ECF\u8BAD\u7EC3\u8FC7\u7684\u6A21\u578B\u3002`),St.forEach(r),ut=_(e),Te=$(e,"P",{});var xl=b(Te);el=m(xl,`\u52A0\u8F7D\u5DF2\u7ECF\u8BAD\u7EC3\u8FC7\u7684Transformers\u6A21\u578B\u5F88\u7B80\u5355-\u6211\u4EEC\u53EF\u4EE5\u4F7F\u7528from_pretrained()
\u65B9\u6CD5\uFF1A`),xl.forEach(r),_t=_(e),S.l(e),ge=_(e),Ce=$(e,"P",{});var Gl=b(Ce);tl=m(Gl,"\u5728\u4E0A\u9762\u7684\u4EE3\u7801\u793A\u4F8B\u4E2D\uFF0C\u6211\u4EEC\u6CA1\u6709\u4F7F\u7528BertConfig"),Gl.forEach(r),ct=_(e),V=$(e,"P",{});var Dt=b(V);ll=m(Dt,`\uFF0C\u800C\u662F\u901A\u8FC7Bert base cased\u6807\u8BC6\u7B26\u52A0\u8F7D\u4E86\u4E00\u4E2A\u9884\u8BAD\u7EC3\u6A21\u578B\u3002\u8FD9\u662F\u4E00\u4E2A\u6A21\u578B\u68C0\u67E5\u70B9\uFF0C\u7531BERT\u7684\u4F5C\u8005\u81EA\u5DF1\u8BAD\u7EC3\uFF1B\u60A8\u53EF\u4EE5\u5728
`),le=$(Dt,"A",{href:!0,rel:!0});var Jl=b(le);rl=m(Jl,"model card"),Jl.forEach(r),sl=m(Dt,"\u4E2D\u627E\u5230\u66F4\u591A\u7EC6\u8282."),Dt.forEach(r),$t=_(e),Ae=$(e,"P",{});var Ll=b(Ae);ol=m(Ll,"\u8BE5\u6A21\u578B\u73B0\u5728\u4F7F\u7528\u68C0\u67E5\u70B9\u7684\u6240\u6709\u6743\u91CD\u8FDB\u884C\u521D\u59CB\u5316\u3002\u5B83\u53EF\u4EE5\u76F4\u63A5\u7528\u4E8E\u5BF9\u8BAD\u7EC3\u8FC7\u7684\u4EFB\u52A1\u8FDB\u884C\u63A8\u7406\uFF0C\u4E5F\u53EF\u4EE5\u5BF9\u65B0\u4EFB\u52A1\u8FDB\u884C\u5FAE\u8C03\u3002\u901A\u8FC7\u9884\u5148\u8BAD\u7EC3\u91CD\u91CF\u800C\u4E0D\u662F\u4ECE\u5934\u5F00\u59CB\u7684\u8BAD\u7EC3\uFF0C\u6211\u4EEC\u53EF\u4EE5\u5F88\u5FEB\u53D6\u5F97\u597D\u7684\u6548\u679C\u3002"),Ll.forEach(r),bt=_(e),Ne=$(e,"P",{});var Yl=b(Ne);nl=m(Yl,`\u6743\u91CD\u5DF2\u4E0B\u8F7D\u5E76\u7F13\u5B58\u5728\u7F13\u5B58\u6587\u4EF6\u5939\u4E2D\uFF08\u56E0\u6B64\u5C06\u6765\u5BF9from_pretrained()\u65B9\u6CD5\u7684\u8C03\u7528\u5C06\u4E0D\u4F1A\u91CD\u65B0\u4E0B\u8F7D\u5B83\u4EEC\uFF09\u9ED8\u8BA4\u4E3A
~/.cache/huggingface/transformers
. \u60A8\u53EF\u4EE5\u901A\u8FC7\u8BBE\u7F6E
HF_HOME
\u73AF\u5883\u53D8\u91CF\u6765\u81EA\u5B9A\u4E49\u7F13\u5B58\u6587\u4EF6\u5939\u3002`),Yl.forEach(r),dt=_(e),K=$(e,"P",{});var It=b(K);fl=m(It,`\u7528\u4E8E\u52A0\u8F7D\u6A21\u578B\u7684\u6807\u8BC6\u7B26\u53EF\u4EE5\u662F\u6A21\u578B\u4E2D\u5FC3Hub\u4E0A\u4EFB\u4F55\u6A21\u578B\u7684\u6807\u8BC6\u7B26\uFF0C\u53EA\u8981\u5B83\u4E0EBERT\u4F53\u7CFB\u7ED3\u6784\u517C\u5BB9\u3002\u53EF\u4EE5\u627E\u5230\u53EF\u7528\u7684BERT\u68C0\u67E5\u70B9\u7684\u5B8C\u6574\u5217\u8868
`),re=$(It,"A",{href:!0,rel:!0});var Ul=b(re);il=m(Ul,"here"),Ul.forEach(r),pl=m(It,`
.`),It.forEach(r),kt=_(e),se=$(e,"H3",{id:!0});var Vl=b(se);al=m(Vl,"\u4FDD\u5B58\u6A21\u578B"),Vl.forEach(r),ht=_(e),He=$(e,"P",{});var Kl=b(He);ml=m(Kl,`\u4FDD\u5B58\u6A21\u578B\u548C\u52A0\u8F7D\u6A21\u578B\u4E00\u6837\u7B80\u5355\u2014\u6211\u4EEC\u4F7F\u7528
save_pretrained()
\u65B9\u6CD5\uFF0C\u7C7B\u4F3C\u4E8E
from_pretrained()
\u65B9\u6CD5\uFF1A`),Kl.forEach(r),yt=_(e),M(oe.$$.fragment,e),vt=_(e),Re=$(e,"P",{});var Ql=b(Re);ul=m(Ql,"\u8FD9\u4F1A\u5C06\u4E24\u4E2A\u6587\u4EF6\u4FDD\u5B58\u5230\u78C1\u76D8\uFF1A"),Ql.forEach(r),wt=_(e),I.l(e),Fe=_(e),ze=$(e,"P",{});var Wl=b(ze);_l=m(Wl,`\u5982\u679C\u4F60\u770B\u4E00\u4E0B
config.json
\u6587\u4EF6\uFF0C\u60A8\u5C06\u8BC6\u522B\u6784\u5EFA\u6A21\u578B\u4F53\u7CFB\u7ED3\u6784\u6240\u9700\u7684\u5C5E\u6027\u3002\u8BE5\u6587\u4EF6\u8FD8\u5305\u542B\u4E00\u4E9B\u5143\u6570\u636E\uFF0C\u4F8B\u5982\u68C0\u67E5\u70B9\u7684\u6765\u6E90\u4EE5\u53CA\u4E0A\u6B21\u4FDD\u5B58\u68C0\u67E5\u70B9\u65F6\u4F7F\u7528\u7684\u{1F917} Transformers\u7248\u672C\u3002`),Wl.forEach(r),Et=_(e),L.l(e),Se=_(e),G=$(e,"H3",{class:!0});var Ot=b(G);Q=$(Ot,"A",{id:!0,class:!0,href:!0});var Xl=b(Q);et=$(Xl,"SPAN",{});var Zl=b(et);M(ne.$$.fragment,Zl),Zl.forEach(r),Xl.forEach(r),cl=_(Ot),tt=$(Ot,"SPAN",{});var er=b(tt);$l=m(er,"\u4F7F\u7528Transformers\u6A21\u578B\u8FDB\u884C\u63A8\u7406"),er.forEach(r),Ot.forEach(r),jt=_(e),De=$(e,"P",{});var tr=b(De);bl=m(tr,"\u65E2\u7136\u60A8\u77E5\u9053\u4E86\u5982\u4F55\u52A0\u8F7D\u548C\u4FDD\u5B58\u6A21\u578B\uFF0C\u90A3\u4E48\u8BA9\u6211\u4EEC\u5C1D\u8BD5\u4F7F\u7528\u5B83\u8FDB\u884C\u4E00\u4E9B\u9884\u6D4B\u3002Transformer\u6A21\u578B\u53EA\u80FD\u5904\u7406\u6570\u5B57\u2014\u2014\u5206\u8BCD\u5668\u751F\u6210\u7684\u6570\u5B57\u3002\u4F46\u5728\u6211\u4EEC\u8BA8\u8BBA\u6807\u8BB0\u5316\u5668\u4E4B\u524D\uFF0C\u8BA9\u6211\u4EEC\u5148\u63A2\u8BA8\u6A21\u578B\u63A5\u53D7\u54EA\u4E9B\u8F93\u5165\u3002"),tr.forEach(r),Bt=_(e),Ie=$(e,"P",{});var lr=b(Ie);dl=m(lr,"\u6807\u8BB0\u5316\u5668\u53EF\u4EE5\u5C06\u8F93\u5165\u8F6C\u6362\u4E3A\u9002\u5F53\u7684\u6846\u67B6\u5F20\u91CF\uFF0C\u4F46\u4E3A\u4E86\u5E2E\u52A9\u60A8\u4E86\u89E3\u53D1\u751F\u4E86\u4EC0\u4E48\uFF0C\u6211\u4EEC\u5C06\u5FEB\u901F\u4E86\u89E3\u5728\u5C06\u8F93\u5165\u53D1\u9001\u5230\u6A21\u578B\u4E4B\u524D\u5FC5\u987B\u505A\u4EC0\u4E48\u3002"),lr.forEach(r),Mt=_(e),Oe=$(e,"P",{});var rr=b(Oe);kl=m(rr,"\u5047\u8BBE\u6211\u4EEC\u6709\u51E0\u4E2A\u5E8F\u5217\uFF1A"),rr.forEach(r),Pt=_(e),M(fe.$$.fragment,e),qt=_(e),xe=$(e,"P",{});var sr=b(xe);hl=m(sr,`\u5206\u8BCD\u5668\u5C06\u8FD9\u4E9B\u8F6C\u6362\u4E3A\u8BCD\u6C47\u8868\u7D22\u5F15\uFF0C\u901A\u5E38\u79F0\u4E3A
input IDs
. \u6BCF\u4E2A\u5E8F\u5217\u73B0\u5728\u90FD\u662F\u4E00\u4E2A\u6570\u5B57\u5217\u8868\uFF01\u7ED3\u679C\u662F\uFF1A`),sr.forEach(r),Tt=_(e),M(ie.$$.fragment,e),gt=_(e),Ge=$(e,"P",{});var or=b(Ge);yl=m(or,"\u8FD9\u662F\u4E00\u4E2A\u7F16\u7801\u5E8F\u5217\u5217\u8868\uFF1A\u4E00\u4E2A\u5217\u8868\u5217\u8868\u3002\u5F20\u91CF\u53EA\u63A5\u53D7\u77E9\u5F62\uFF08\u60F3\u60F3\u77E9\u9635\uFF09\u3002\u6B64\u201C\u6570\u7EC4\u201D\u5DF2\u4E3A\u77E9\u5F62\uFF0C\u56E0\u6B64\u5C06\u5176\u8F6C\u6362\u4E3A\u5F20\u91CF\u5F88\u5BB9\u6613\uFF1A"),or.forEach(r),Ct=_(e),x.l(e),Je=_(e),pe=$(e,"H3",{id:!0});var nr=b(pe);vl=m(nr,"\u4F7F\u7528\u5F20\u91CF\u4F5C\u4E3A\u6A21\u578B\u7684\u8F93\u5165"),nr.forEach(r),At=_(e),Le=$(e,"P",{});var fr=b(Le);wl=m(fr,"\u5728\u6A21\u578B\u4E2D\u4F7F\u7528\u5F20\u91CF\u975E\u5E38\u7B80\u5355-\u6211\u4EEC\u53EA\u9700\u5C06\u8F93\u5165\u79F0\u4E3A\u6A21\u578B\uFF1A"),fr.forEach(r),Nt=_(e),M(ae.$$.fragment,e),Ht=_(e),Ye=$(e,"P",{});var ir=b(Ye);El=m(ir,`\u867D\u7136\u6A21\u578B\u63A5\u53D7\u8BB8\u591A\u4E0D\u540C\u7684\u53C2\u6570\uFF0C\u4F46\u53EA\u9700\u8981
input IDs\u3002\u6211\u4EEC\u7A0D\u540E\u5C06\u89E3\u91CA\u5176\u4ED6\u53C2\u6570\u7684\u4F5C\u7528\u4EE5\u53CA\u4F55\u65F6\u9700\u8981\u5B83\u4EEC\uFF0C\u4F46\u9996\u5148\u6211\u4EEC\u9700\u8981\u66F4\u4ED4\u7EC6\u5730\u4E86\u89E3
Transformer\u6A21\u578B\u53EF\u4EE5\u7406\u89E3\u7684\u8F93\u5165\u7684\u6807\u8BB0`),ir.forEach(r),this.h()},h(){C(l,"name","hf:doc:metadata"),C(l,"content",JSON.stringify(zr)),C(v,"id",""),C(X,"id",""),C(te,"id",""),C(qe,"href","/course/chapter1"),C(le,"href","https://huggingface.co/bert-base-cased"),C(le,"rel","nofollow"),C(re,"href","https://huggingface.co/models?filter=bert"),C(re,"rel","nofollow"),C(se,"id",""),C(Q,"id","transformers"),C(Q,"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"),C(Q,"href","#transformers"),C(G,"class","relative group"),C(pe,"id","")},m(e,s){i(document.head,l),n(e,o,s),P(t,e,s),n(e,p,s),n(e,v,s),i(v,f),n(e,d,s),me[w].m(e,s),n(e,E,s),ue[T].m(e,s),n(e,ye,s),J.m(e,s),n(e,ve,s),n(e,we,s),i(we,xt),n(e,rt,s),n(e,X,s),i(X,Gt),n(e,st,s),n(e,Ee,s),i(Ee,Jt),n(e,ot,s),_e[N].m(e,s),n(e,je,s),n(e,Be,s),i(Be,Lt),n(e,nt,s),P(Z,e,s),n(e,ft,s),P(ee,e,s),n(e,it,s),n(e,Y,s),i(Y,Yt),i(Y,Ze),i(Ze,Ut),i(Y,Vt),n(e,pt,s),n(e,te,s),i(te,Kt),n(e,at,s),n(e,Me,s),i(Me,Qt),n(e,mt,s),ce[R].m(e,s),n(e,Pe,s),n(e,U,s),i(U,Wt),i(U,qe),i(qe,Xt),i(U,Zt),n(e,ut,s),n(e,Te,s),i(Te,el),n(e,_t,s),$e[z].m(e,s),n(e,ge,s),n(e,Ce,s),i(Ce,tl),n(e,ct,s),n(e,V,s),i(V,ll),i(V,le),i(le,rl),i(V,sl),n(e,$t,s),n(e,Ae,s),i(Ae,ol),n(e,bt,s),n(e,Ne,s),i(Ne,nl),n(e,dt,s),n(e,K,s),i(K,fl),i(K,re),i(re,il),i(K,pl),n(e,kt,s),n(e,se,s),i(se,al),n(e,ht,s),n(e,He,s),i(He,ml),n(e,yt,s),P(oe,e,s),n(e,vt,s),n(e,Re,s),i(Re,ul),n(e,wt,s),be[D].m(e,s),n(e,Fe,s),n(e,ze,s),i(ze,_l),n(e,Et,s),L.m(e,s),n(e,Se,s),n(e,G,s),i(G,Q),i(Q,et),P(ne,et,null),i(G,cl),i(G,tt),i(tt,$l),n(e,jt,s),n(e,De,s),i(De,bl),n(e,Bt,s),n(e,Ie,s),i(Ie,dl),n(e,Mt,s),n(e,Oe,s),i(Oe,kl),n(e,Pt,s),P(fe,e,s),n(e,qt,s),n(e,xe,s),i(xe,hl),n(e,Tt,s),P(ie,e,s),n(e,gt,s),n(e,Ge,s),i(Ge,yl),n(e,Ct,s),de[O].m(e,s),n(e,Je,s),n(e,pe,s),i(pe,vl),n(e,At,s),n(e,Le,s),i(Le,wl),n(e,Nt,s),P(ae,e,s),n(e,Ht,s),n(e,Ye,s),i(Ye,El),Rt=!0},p(e,[s]){const lt={};s&1&&(lt.fw=e[0]),t.$set(lt);let Ue=w;w=Bl(e),w!==Ue&&(he(),h(me[Ue],1,1,()=>{me[Ue]=null}),ke(),j=me[w],j||(j=me[w]=jl[w](e),j.c()),y(j,1),j.m(E.parentNode,E));let Ve=T;T=Pl(e),T!==Ve&&(he(),h(ue[Ve],1,1,()=>{ue[Ve]=null}),ke(),g=ue[T],g||(g=ue[T]=Ml[T](e),g.c()),y(g,1),g.m(ye.parentNode,ye)),Ft!==(Ft=ql(e))&&(J.d(1),J=Ft(e),J&&(J.c(),J.m(ve.parentNode,ve)));let Ke=N;N=gl(e),N!==Ke&&(he(),h(_e[Ke],1,1,()=>{_e[Ke]=null}),ke(),H=_e[N],H||(H=_e[N]=Tl[N](e),H.c()),y(H,1),H.m(je.parentNode,je));let Qe=R;R=Al(e),R!==Qe&&(he(),h(ce[Qe],1,1,()=>{ce[Qe]=null}),ke(),F=ce[R],F||(F=ce[R]=Cl[R](e),F.c()),y(F,1),F.m(Pe.parentNode,Pe));let W=z;z=Hl(e),z!==W&&(he(),h($e[W],1,1,()=>{$e[W]=null}),ke(),S=$e[z],S||(S=$e[z]=Nl[z](e),S.c()),y(S,1),S.m(ge.parentNode,ge));let We=D;D=Fl(e),D!==We&&(he(),h(be[We],1,1,()=>{be[We]=null}),ke(),I=be[D],I||(I=be[D]=Rl[D](e),I.c()),y(I,1),I.m(Fe.parentNode,Fe)),zt!==(zt=zl(e))&&(L.d(1),L=zt(e),L&&(L.c(),L.m(Se.parentNode,Se)));let Xe=O;O=Dl(e),O!==Xe&&(he(),h(de[Xe],1,1,()=>{de[Xe]=null}),ke(),x=de[O],x||(x=de[O]=Sl[O](e),x.c()),y(x,1),x.m(Je.parentNode,Je))},i(e){Rt||(y(t.$$.fragment,e),y(j),y(g),y(H),y(Z.$$.fragment,e),y(ee.$$.fragment,e),y(F),y(S),y(oe.$$.fragment,e),y(I),y(ne.$$.fragment,e),y(fe.$$.fragment,e),y(ie.$$.fragment,e),y(x),y(ae.$$.fragment,e),Rt=!0)},o(e){h(t.$$.fragment,e),h(j),h(g),h(H),h(Z.$$.fragment,e),h(ee.$$.fragment,e),h(F),h(S),h(oe.$$.fragment,e),h(I),h(ne.$$.fragment,e),h(fe.$$.fragment,e),h(ie.$$.fragment,e),h(x),h(ae.$$.fragment,e),Rt=!1},d(e){r(l),e&&r(o),q(t,e),e&&r(p),e&&r(v),e&&r(d),me[w].d(e),e&&r(E),ue[T].d(e),e&&r(ye),J.d(e),e&&r(ve),e&&r(we),e&&r(rt),e&&r(X),e&&r(st),e&&r(Ee),e&&r(ot),_e[N].d(e),e&&r(je),e&&r(Be),e&&r(nt),q(Z,e),e&&r(ft),q(ee,e),e&&r(it),e&&r(Y),e&&r(pt),e&&r(te),e&&r(at),e&&r(Me),e&&r(mt),ce[R].d(e),e&&r(Pe),e&&r(U),e&&r(ut),e&&r(Te),e&&r(_t),$e[z].d(e),e&&r(ge),e&&r(Ce),e&&r(ct),e&&r(V),e&&r($t),e&&r(Ae),e&&r(bt),e&&r(Ne),e&&r(dt),e&&r(K),e&&r(kt),e&&r(se),e&&r(ht),e&&r(He),e&&r(yt),q(oe,e),e&&r(vt),e&&r(Re),e&&r(wt),be[D].d(e),e&&r(Fe),e&&r(ze),e&&r(Et),L.d(e),e&&r(Se),e&&r(G),q(ne),e&&r(jt),e&&r(De),e&&r(Bt),e&&r(Ie),e&&r(Mt),e&&r(Oe),e&&r(Pt),q(fe,e),e&&r(qt),e&&r(xe),e&&r(Tt),q(ie,e),e&&r(gt),e&&r(Ge),e&&r(Ct),de[O].d(e),e&&r(Je),e&&r(pe),e&&r(At),e&&r(Le),e&&r(Nt),q(ae,e),e&&r(Ht),e&&r(Ye)}}}const zr={local:"",sections:[{local:"",sections:[{local:"",title:"\u4E0D\u540C\u7684\u52A0\u8F7D\u65B9\u5F0F"},{local:"",title:"\u4FDD\u5B58\u6A21\u578B"},{local:"transformers",title:"\u4F7F\u7528Transformers\u6A21\u578B\u8FDB\u884C\u63A8\u7406"},{local:"",title:"\u4F7F\u7528\u5F20\u91CF\u4F5C\u4E3A\u6A21\u578B\u7684\u8F93\u5165"}],title:"\u521B\u5EFA\u8F6C\u6362\u5668"}],title:"\u6A21\u578B"};function Sr(k,l,o){let t="pt";return $r(()=>{const p=new URLSearchParams(window.location.search);o(0,t=p.get("fw")||"pt")}),[t]}class Lr extends mr{constructor(l){super();ur(this,l,Sr,Fr,_r,{})}}export{Lr as default,zr as metadata};
