import{s as ll,f as sl,o as nl,n as Je}from"../chunks/scheduler.25b97de1.js";import{S as al,i as rl,g as $,s as r,r as h,A as il,h as c,f as l,c as i,j as Ht,u as b,x as d,k as F,y as pl,a as s,v as M,d as _,t as w,w as T}from"../chunks/index.d9030fc9.js";import{T as ml}from"../chunks/Tip.baa67368.js";import{Y as ol}from"../chunks/Youtube.eaf1a617.js";import{C as U}from"../chunks/CodeBlock.b38ef023.js";import{F as tl,M as Ze}from"../chunks/Markdown.d8c1b6cc.js";import{H as R,E as fl}from"../chunks/index.676ef4be.js";function ul(W){let n,o='要与社区共享模型，您需要在<a href="https://huggingface.co/join" rel="nofollow">huggingface.co</a>上拥有一个帐户。您还可以加入现有的组织或创建一个新的组织。';return{c(){n=$("p"),n.innerHTML=o},l(a){n=c(a,"P",{"data-svelte-h":!0}),d(n)!=="svelte-ono6xp"&&(n.innerHTML=o)},m(a,p){s(a,n,p)},p:Je,d(a){a&&l(n)}}}function $l(W){let n,o="指定<code>from_tf=True</code>将checkpoint从TensorFlow转换为PyTorch。",a,p,u;return p=new U({props:{code:"cHRfbW9kZWwlMjAlM0QlMjBEaXN0aWxCZXJ0Rm9yU2VxdWVuY2VDbGFzc2lmaWNhdGlvbi5mcm9tX3ByZXRyYWluZWQoJTIycGF0aCUyRnRvJTJGYXdlc29tZS1uYW1lLXlvdS1waWNrZWQlMjIlMkMlMjBmcm9tX3RmJTNEVHJ1ZSklMEFwdF9tb2RlbC5zYXZlX3ByZXRyYWluZWQoJTIycGF0aCUyRnRvJTJGYXdlc29tZS1uYW1lLXlvdS1waWNrZWQlMjIp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>pt_model = DistilBertForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;path/to/awesome-name-you-picked&quot;</span>, from_tf=<span class="hljs-literal">True</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>pt_model.save_pretrained(<span class="hljs-string">&quot;path/to/awesome-name-you-picked&quot;</span>)`,wrap:!1}}),{c(){n=$("p"),n.innerHTML=o,a=r(),h(p.$$.fragment)},l(m){n=c(m,"P",{"data-svelte-h":!0}),d(n)!=="svelte-xo84fy"&&(n.innerHTML=o),a=i(m),b(p.$$.fragment,m)},m(m,v){s(m,n,v),s(m,a,v),M(p,m,v),u=!0},p:Je,i(m){u||(_(p.$$.fragment,m),u=!0)},o(m){w(p.$$.fragment,m),u=!1},d(m){m&&(l(n),l(a)),T(p,m)}}}function cl(W){let n,o;return n=new Ze({props:{$$slots:{default:[$l]},$$scope:{ctx:W}}}),{c(){h(n.$$.fragment)},l(a){b(n.$$.fragment,a)},m(a,p){M(n,a,p),o=!0},p(a,p){const u={};p&2&&(u.$$scope={dirty:p,ctx:a}),n.$set(u)},i(a){o||(_(n.$$.fragment,a),o=!0)},o(a){w(n.$$.fragment,a),o=!1},d(a){T(n,a)}}}function gl(W){let n,o="指定<code>from_pt=True</code>将checkpoint从PyTorch转换为TensorFlow。",a,p,u,m,v="然后，您可以使用新的checkpoint保存您的新TensorFlow模型：",C,k,Z;return p=new U({props:{code:"dGZfbW9kZWwlMjAlM0QlMjBURkRpc3RpbEJlcnRGb3JTZXF1ZW5jZUNsYXNzaWZpY2F0aW9uLmZyb21fcHJldHJhaW5lZCglMjJwYXRoJTJGdG8lMkZhd2Vzb21lLW5hbWUteW91LXBpY2tlZCUyMiUyQyUyMGZyb21fcHQlM0RUcnVlKQ==",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>tf_model = TFDistilBertForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;path/to/awesome-name-you-picked&quot;</span>, from_pt=<span class="hljs-literal">True</span>)',wrap:!1}}),k=new U({props:{code:"dGZfbW9kZWwuc2F2ZV9wcmV0cmFpbmVkKCUyMnBhdGglMkZ0byUyRmF3ZXNvbWUtbmFtZS15b3UtcGlja2VkJTIyKQ==",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>tf_model.save_pretrained(<span class="hljs-string">&quot;path/to/awesome-name-you-picked&quot;</span>)',wrap:!1}}),{c(){n=$("p"),n.innerHTML=o,a=r(),h(p.$$.fragment),u=r(),m=$("p"),m.textContent=v,C=r(),h(k.$$.fragment)},l(g){n=c(g,"P",{"data-svelte-h":!0}),d(n)!=="svelte-6zl8ge"&&(n.innerHTML=o),a=i(g),b(p.$$.fragment,g),u=i(g),m=c(g,"P",{"data-svelte-h":!0}),d(m)!=="svelte-pq7zsz"&&(m.textContent=v),C=i(g),b(k.$$.fragment,g)},m(g,H){s(g,n,H),s(g,a,H),M(p,g,H),s(g,u,H),s(g,m,H),s(g,C,H),M(k,g,H),Z=!0},p:Je,i(g){Z||(_(p.$$.fragment,g),_(k.$$.fragment,g),Z=!0)},o(g){w(p.$$.fragment,g),w(k.$$.fragment,g),Z=!1},d(g){g&&(l(n),l(a),l(u),l(m),l(C)),T(p,g),T(k,g)}}}function dl(W){let n,o;return n=new Ze({props:{$$slots:{default:[gl]},$$scope:{ctx:W}}}),{c(){h(n.$$.fragment)},l(a){b(n.$$.fragment,a)},m(a,p){M(n,a,p),o=!0},p(a,p){const u={};p&2&&(u.$$scope={dirty:p,ctx:a}),n.$set(u)},i(a){o||(_(n.$$.fragment,a),o=!0)},o(a){w(n.$$.fragment,a),o=!1},d(a){T(n,a)}}}function hl(W){let n,o="如果模型在Flax中可用，您还可以将PyTorch checkpoint转换为Flax：",a,p,u;return p=new U({props:{code:"ZmxheF9tb2RlbCUyMCUzRCUyMEZsYXhEaXN0aWxCZXJ0Rm9yU2VxdWVuY2VDbGFzc2lmaWNhdGlvbi5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIycGF0aCUyRnRvJTJGYXdlc29tZS1uYW1lLXlvdS1waWNrZWQlMjIlMkMlMjBmcm9tX3B0JTNEVHJ1ZSUwQSk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>flax_model = FlaxDistilBertForSequenceClassification.from_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;path/to/awesome-name-you-picked&quot;</span>, from_pt=<span class="hljs-literal">True</span>
<span class="hljs-meta">... </span>)`,wrap:!1}}),{c(){n=$("p"),n.textContent=o,a=r(),h(p.$$.fragment)},l(m){n=c(m,"P",{"data-svelte-h":!0}),d(n)!=="svelte-4ux5nj"&&(n.textContent=o),a=i(m),b(p.$$.fragment,m)},m(m,v){s(m,n,v),s(m,a,v),M(p,m,v),u=!0},p:Je,i(m){u||(_(p.$$.fragment,m),u=!0)},o(m){w(p.$$.fragment,m),u=!1},d(m){m&&(l(n),l(a)),T(p,m)}}}function bl(W){let n,o;return n=new Ze({props:{$$slots:{default:[hl]},$$scope:{ctx:W}}}),{c(){h(n.$$.fragment)},l(a){b(n.$$.fragment,a)},m(a,p){M(n,a,p),o=!0},p(a,p){const u={};p&2&&(u.$$scope={dirty:p,ctx:a}),n.$set(u)},i(a){o||(_(n.$$.fragment,a),o=!0)},o(a){w(n.$$.fragment,a),o=!1},d(a){T(n,a)}}}function Ml(W){let n,o,a,p='将模型分享到Hub就像添加一个额外的参数或回调函数一样简单。请记住，在<a href="training">微调教程</a>中，<code>TrainingArguments</code>类是您指定超参数和附加训练选项的地方。其中一项训练选项包括直接将模型推送到Hub的能力。在您的<code>TrainingArguments</code>中设置<code>push_to_hub=True</code>：',u,m,v,C,k="像往常一样将您的训练参数传递给<code>Trainer</code>：",Z,g,H,x,y="在您微调完模型后，在<code>Trainer</code>上调用<code>push_to_hub()</code>将训练好的模型推送到Hub。🤗 Transformers甚至会自动将训练超参数、训练结果和框架版本添加到你的模型卡片中！",L,J,Y;return n=new ol({props:{id:"Z1-XMy-GNLQ"}}),m=new U({props:{code:"dHJhaW5pbmdfYXJncyUyMCUzRCUyMFRyYWluaW5nQXJndW1lbnRzKG91dHB1dF9kaXIlM0QlMjJteS1hd2Vzb21lLW1vZGVsJTIyJTJDJTIwcHVzaF90b19odWIlM0RUcnVlKQ==",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>training_args = TrainingArguments(output_dir=<span class="hljs-string">&quot;my-awesome-model&quot;</span>, push_to_hub=<span class="hljs-literal">True</span>)',wrap:!1}}),g=new U({props:{code:"dHJhaW5lciUyMCUzRCUyMFRyYWluZXIoJTBBJTIwJTIwJTIwJTIwbW9kZWwlM0Rtb2RlbCUyQyUwQSUyMCUyMCUyMCUyMGFyZ3MlM0R0cmFpbmluZ19hcmdzJTJDJTBBJTIwJTIwJTIwJTIwdHJhaW5fZGF0YXNldCUzRHNtYWxsX3RyYWluX2RhdGFzZXQlMkMlMEElMjAlMjAlMjAlMjBldmFsX2RhdGFzZXQlM0RzbWFsbF9ldmFsX2RhdGFzZXQlMkMlMEElMjAlMjAlMjAlMjBjb21wdXRlX21ldHJpY3MlM0Rjb21wdXRlX21ldHJpY3MlMkMlMEEp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>trainer = Trainer(
<span class="hljs-meta">... </span>    model=model,
<span class="hljs-meta">... </span>    args=training_args,
<span class="hljs-meta">... </span>    train_dataset=small_train_dataset,
<span class="hljs-meta">... </span>    eval_dataset=small_eval_dataset,
<span class="hljs-meta">... </span>    compute_metrics=compute_metrics,
<span class="hljs-meta">... </span>)`,wrap:!1}}),J=new U({props:{code:"dHJhaW5lci5wdXNoX3RvX2h1Yigp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>trainer.push_to_hub()',wrap:!1}}),{c(){h(n.$$.fragment),o=r(),a=$("p"),a.innerHTML=p,u=r(),h(m.$$.fragment),v=r(),C=$("p"),C.innerHTML=k,Z=r(),h(g.$$.fragment),H=r(),x=$("p"),x.innerHTML=y,L=r(),h(J.$$.fragment)},l(f){b(n.$$.fragment,f),o=i(f),a=c(f,"P",{"data-svelte-h":!0}),d(a)!=="svelte-1rm1fnz"&&(a.innerHTML=p),u=i(f),b(m.$$.fragment,f),v=i(f),C=c(f,"P",{"data-svelte-h":!0}),d(C)!=="svelte-o485dv"&&(C.innerHTML=k),Z=i(f),b(g.$$.fragment,f),H=i(f),x=c(f,"P",{"data-svelte-h":!0}),d(x)!=="svelte-1ue1tej"&&(x.innerHTML=y),L=i(f),b(J.$$.fragment,f)},m(f,j){M(n,f,j),s(f,o,j),s(f,a,j),s(f,u,j),M(m,f,j),s(f,v,j),s(f,C,j),s(f,Z,j),M(g,f,j),s(f,H,j),s(f,x,j),s(f,L,j),M(J,f,j),Y=!0},p:Je,i(f){Y||(_(n.$$.fragment,f),_(m.$$.fragment,f),_(g.$$.fragment,f),_(J.$$.fragment,f),Y=!0)},o(f){w(n.$$.fragment,f),w(m.$$.fragment,f),w(g.$$.fragment,f),w(J.$$.fragment,f),Y=!1},d(f){f&&(l(o),l(a),l(u),l(v),l(C),l(Z),l(H),l(x),l(L)),T(n,f),T(m,f),T(g,f),T(J,f)}}}function _l(W){let n,o;return n=new Ze({props:{$$slots:{default:[Ml]},$$scope:{ctx:W}}}),{c(){h(n.$$.fragment)},l(a){b(n.$$.fragment,a)},m(a,p){M(n,a,p),o=!0},p(a,p){const u={};p&2&&(u.$$scope={dirty:p,ctx:a}),n.$set(u)},i(a){o||(_(n.$$.fragment,a),o=!0)},o(a){w(n.$$.fragment,a),o=!1},d(a){T(n,a)}}}function wl(W){let n,o='使用<a href="/docs/transformers/main/zh/main_classes/keras_callbacks#transformers.PushToHubCallback">PushToHubCallback</a>将模型分享到Hub。在<a href="/docs/transformers/main/zh/main_classes/keras_callbacks#transformers.PushToHubCallback">PushToHubCallback</a>函数中，添加以下内容：',a,p,u="<li>一个用于存储模型的输出目录。</li> <li>一个tokenizer。</li> <li><code>hub_model_id</code>，即您的Hub用户名和模型名称。</li>",m,v,C,k,Z='将回调函数添加到 <a href="https://keras.io/api/models/model_training_apis/" rel="nofollow"><code>fit</code></a>中，然后🤗 Transformers 会将训练好的模型推送到 Hub：',g,H,x;return v=new U({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFB1c2hUb0h1YkNhbGxiYWNrJTBBJTBBcHVzaF90b19odWJfY2FsbGJhY2slMjAlM0QlMjBQdXNoVG9IdWJDYWxsYmFjayglMEElMjAlMjAlMjAlMjBvdXRwdXRfZGlyJTNEJTIyLiUyRnlvdXJfbW9kZWxfc2F2ZV9wYXRoJTIyJTJDJTIwdG9rZW5pemVyJTNEdG9rZW5pemVyJTJDJTIwaHViX21vZGVsX2lkJTNEJTIyeW91ci11c2VybmFtZSUyRm15LWF3ZXNvbWUtbW9kZWwlMjIlMEEp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> PushToHubCallback

<span class="hljs-meta">&gt;&gt;&gt; </span>push_to_hub_callback = PushToHubCallback(
<span class="hljs-meta">... </span>    output_dir=<span class="hljs-string">&quot;./your_model_save_path&quot;</span>, tokenizer=tokenizer, hub_model_id=<span class="hljs-string">&quot;your-username/my-awesome-model&quot;</span>
<span class="hljs-meta">... </span>)`,wrap:!1}}),H=new U({props:{code:"bW9kZWwuZml0KHRmX3RyYWluX2RhdGFzZXQlMkMlMjB2YWxpZGF0aW9uX2RhdGElM0R0Zl92YWxpZGF0aW9uX2RhdGFzZXQlMkMlMjBlcG9jaHMlM0QzJTJDJTIwY2FsbGJhY2tzJTNEcHVzaF90b19odWJfY2FsbGJhY2sp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>model.fit(tf_train_dataset, validation_data=tf_validation_dataset, epochs=<span class="hljs-number">3</span>, callbacks=push_to_hub_callback)',wrap:!1}}),{c(){n=$("p"),n.innerHTML=o,a=r(),p=$("ul"),p.innerHTML=u,m=r(),h(v.$$.fragment),C=r(),k=$("p"),k.innerHTML=Z,g=r(),h(H.$$.fragment)},l(y){n=c(y,"P",{"data-svelte-h":!0}),d(n)!=="svelte-rm30pm"&&(n.innerHTML=o),a=i(y),p=c(y,"UL",{"data-svelte-h":!0}),d(p)!=="svelte-fhkhez"&&(p.innerHTML=u),m=i(y),b(v.$$.fragment,y),C=i(y),k=c(y,"P",{"data-svelte-h":!0}),d(k)!=="svelte-1jsduku"&&(k.innerHTML=Z),g=i(y),b(H.$$.fragment,y)},m(y,L){s(y,n,L),s(y,a,L),s(y,p,L),s(y,m,L),M(v,y,L),s(y,C,L),s(y,k,L),s(y,g,L),M(H,y,L),x=!0},p:Je,i(y){x||(_(v.$$.fragment,y),_(H.$$.fragment,y),x=!0)},o(y){w(v.$$.fragment,y),w(H.$$.fragment,y),x=!1},d(y){y&&(l(n),l(a),l(p),l(m),l(C),l(k),l(g)),T(v,y),T(H,y)}}}function Tl(W){let n,o;return n=new Ze({props:{$$slots:{default:[wl]},$$scope:{ctx:W}}}),{c(){h(n.$$.fragment)},l(a){b(n.$$.fragment,a)},m(a,p){M(n,a,p),o=!0},p(a,p){const u={};p&2&&(u.$$scope={dirty:p,ctx:a}),n.$set(u)},i(a){o||(_(n.$$.fragment,a),o=!0)},o(a){w(n.$$.fragment,a),o=!1},d(a){T(n,a)}}}function yl(W){let n,o,a,p,u,m,v,C="最后两个教程展示了如何使用PyTorch、Keras和 🤗 Accelerate进行分布式设置来微调模型。下一步是将您的模型与社区分享！在Hugging Face，我们相信公开分享知识和资源，能实现人工智能的普及化，让每个人都能受益。我们鼓励您将您的模型与社区分享，以帮助他人节省时间和精力。",k,Z,g='在本教程中，您将学习两种在<a href="https://huggingface.co/models" rel="nofollow">Model Hub</a>上共享训练好的或微调的模型的方法：',H,x,y="<li>通过编程将文件推送到Hub。</li> <li>使用Web界面将文件拖放到Hub。</li>",L,J,Y,f,j,xe,P,Le,z,kt="Model Hub上的每个仓库都像是一个典型的GitHub仓库。我们的仓库提供版本控制、提交历史记录以及可视化差异的能力。",Ue,V,jt='Model Hub的内置版本控制基于git和<a href="https://git-lfs.github.com/" rel="nofollow">git-lfs</a>。换句话说，您可以将一个模型视为一个仓库，从而实现更好的访问控制和可扩展性。版本控制允许使用<em>修订</em>方法来固定特定版本的模型，可以使用提交哈希值、标签或分支来标记。',Xe,I,Wt="因此，您可以通过<code>revision</code>参数加载特定的模型版本：",Ge,E,Fe,B,Jt=`文件也可以轻松地在仓库中编辑，您可以查看提交历史记录以及差异：
<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/vis_diff.png" alt="vis_diff"/>`,Re,q,Ye,Q,Ct="在将模型共享到Hub之前，您需要拥有Hugging Face的凭证。如果您有访问终端的权限，请在安装🤗 Transformers的虚拟环境中运行以下命令。这将在您的Hugging Face缓存文件夹（默认为<code>~/.cache/</code>）中存储您的<code>access token</code>：",Pe,N,ze,S,Zt='如果您正在使用像Jupyter或Colaboratory这样的<code>notebook</code>，请确保您已安装了<a href="https://huggingface.co/docs/hub/adding-a-library" rel="nofollow"><code>huggingface_hub</code></a>库。该库允许您以编程方式与Hub进行交互。',Ve,A,Ie,D,xt='然后使用<code>notebook_login</code>登录到Hub，并按照<a href="https://huggingface.co/settings/token" rel="nofollow">这里</a>的链接生成一个token进行登录：',Ee,K,Be,O,qe,ee,Lt="为确保您的模型可以被使用不同框架的人使用，我们建议您将PyTorch和TensorFlow <code>checkpoints</code>都转换并上传。如果您跳过此步骤，用户仍然可以从其他框架加载您的模型，但速度会变慢，因为🤗 Transformers需要实时转换<code>checkpoints</code>。",Qe,te,Ut='为另一个框架转换<code>checkpoints</code>很容易。确保您已安装PyTorch和TensorFlow（请参阅<a href="installation">此处</a>的安装说明），然后在其他框架中找到适合您任务的特定模型。',Ne,X,Se,le,Ae,G,De,se,Ke,ne,Xt="您可以直接在您的模型上调用<code>push_to_hub</code>来将其上传到Hub。",Oe,ae,Gt="在<code>push_to_hub</code>中指定你的模型名称：",et,re,tt,ie,Ft="这会在您的用户名下创建一个名为<code>my-awesome-model</code>的仓库。用户现在可以使用<code>from_pretrained</code>函数加载您的模型：",lt,pe,st,me,Rt="如果您属于一个组织，并希望将您的模型推送到组织名称下，只需将其添加到<code>repo_id</code>中：",nt,oe,at,fe,Yt="<code>push_to_hub</code>函数还可以用于向模型仓库添加其他文件。例如，向模型仓库中添加一个<code>tokenizer</code>：",rt,ue,it,$e,Pt="或者，您可能希望将您的微调后的PyTorch模型的TensorFlow版本添加进去：",pt,ce,mt,ge,zt="现在，当您导航到您的Hugging Face个人资料时，您应该看到您新创建的模型仓库。点击<strong>文件</strong>选项卡将显示您已上传到仓库的所有文件。",ot,de,Vt='有关如何创建和上传文件到仓库的更多详细信息，请参考Hub文档<a href="https://huggingface.co/docs/hub/how-to-upstream" rel="nofollow">这里</a>。',ft,he,ut,be,It='喜欢无代码方法的用户可以通过Hugging Face的Web界面上传模型。访问<a href="https://huggingface.co/new" rel="nofollow">huggingface.co/new</a>创建一个新的仓库：',$t,Me,Et='<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/new_model_repo.png" alt="new_model_repo"/>',ct,_e,Bt="从这里开始，添加一些关于您的模型的信息：",gt,we,qt="<li>选择仓库的<strong>所有者</strong>。这可以是您本人或者您所属的任何组织。</li> <li>为您的项目选择一个名称，该名称也将成为仓库的名称。</li> <li>选择您的模型是公开还是私有。</li> <li>指定您的模型的许可证使用情况。</li>",dt,Te,Qt="现在点击<strong>文件</strong>选项卡，然后点击<strong>添加文件</strong>按钮将一个新文件上传到你的仓库。接着拖放一个文件进行上传，并添加提交信息。",ht,ye,Nt='<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/upload_file.png" alt="upload_file"/>',bt,ve,Mt,He,St="为了确保用户了解您的模型的能力、限制、潜在偏差和伦理考虑，请在仓库中添加一个模型卡片。模型卡片在<code>README.md</code>文件中定义。你可以通过以下方式添加模型卡片：",_t,ke,At="<li>手动创建并上传一个<code>README.md</code>文件。</li> <li>在你的模型仓库中点击<strong>编辑模型卡片</strong>按钮。</li>",wt,je,Dt='可以参考DistilBert的<a href="https://huggingface.co/distilbert/distilbert-base-uncased" rel="nofollow">模型卡片</a>来了解模型卡片应该包含的信息类型。有关您可以在<code>README.md</code>文件中控制的更多选项的细节，例如模型的碳足迹或小部件示例，请参考文档<a href="https://huggingface.co/docs/hub/models-cards" rel="nofollow">这里</a>。',Tt,We,yt,Ce,vt;return u=new R({props:{title:"分享模型",local:"分享模型",headingTag:"h1"}}),j=new ml({props:{$$slots:{default:[ul]},$$scope:{ctx:W}}}),P=new R({props:{title:"仓库功能",local:"仓库功能",headingTag:"h2"}}),E=new U({props:{code:"bW9kZWwlMjAlM0QlMjBBdXRvTW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMmp1bGllbi1jJTJGRXNwZXJCRVJUby1zbWFsbCUyMiUyQyUyMHJldmlzaW9uJTNEJTIyNGM3Nzk4MiUyMiUyMCUyMCUyMyUyMHRhZyUyMG5hbWUlMkMlMjBvciUyMGJyYW5jaCUyMG5hbWUlMkMlMjBvciUyMGNvbW1pdCUyMGhhc2glMEEp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModel.from_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;julien-c/EsperBERTo-small&quot;</span>, revision=<span class="hljs-string">&quot;4c77982&quot;</span>  <span class="hljs-comment"># tag name, or branch name, or commit hash</span>
<span class="hljs-meta">... </span>)`,wrap:!1}}),q=new R({props:{title:"设置",local:"设置",headingTag:"h2"}}),N=new U({props:{code:"aHVnZ2luZ2ZhY2UtY2xpJTIwbG9naW4=",highlighted:"huggingface-cli login",wrap:!1}}),A=new U({props:{code:"cGlwJTIwaW5zdGFsbCUyMGh1Z2dpbmdmYWNlX2h1Yg==",highlighted:"pip install huggingface_hub",wrap:!1}}),K=new U({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMG5vdGVib29rX2xvZ2luJTBBJTBBbm90ZWJvb2tfbG9naW4oKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> notebook_login

<span class="hljs-meta">&gt;&gt;&gt; </span>notebook_login()`,wrap:!1}}),O=new R({props:{title:"转换模型适用于所有框架",local:"转换模型适用于所有框架",headingTag:"h2"}}),X=new tl({props:{pytorch:!0,tensorflow:!0,jax:!0,$$slots:{jax:[bl],tensorflow:[dl],pytorch:[cl]},$$scope:{ctx:W}}}),le=new R({props:{title:"在训练过程中推送模型",local:"在训练过程中推送模型",headingTag:"h2"}}),G=new tl({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[Tl],pytorch:[_l]},$$scope:{ctx:W}}}),se=new R({props:{title:"使用 push_to_hub 功能",local:"使用-pushtohub-功能",headingTag:"h2"}}),re=new U({props:{code:"cHRfbW9kZWwucHVzaF90b19odWIoJTIybXktYXdlc29tZS1tb2RlbCUyMik=",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>pt_model.push_to_hub(<span class="hljs-string">&quot;my-awesome-model&quot;</span>)',wrap:!1}}),pe=new U({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbCUwQSUwQW1vZGVsJTIwJTNEJTIwQXV0b01vZGVsLmZyb21fcHJldHJhaW5lZCglMjJ5b3VyX3VzZXJuYW1lJTJGbXktYXdlc29tZS1tb2RlbCUyMik=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModel

<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModel.from_pretrained(<span class="hljs-string">&quot;your_username/my-awesome-model&quot;</span>)`,wrap:!1}}),oe=new U({props:{code:"cHRfbW9kZWwucHVzaF90b19odWIoJTIybXktYXdlc29tZS1vcmclMkZteS1hd2Vzb21lLW1vZGVsJTIyKQ==",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>pt_model.push_to_hub(<span class="hljs-string">&quot;my-awesome-org/my-awesome-model&quot;</span>)',wrap:!1}}),ue=new U({props:{code:"dG9rZW5pemVyLnB1c2hfdG9faHViKCUyMm15LWF3ZXNvbWUtbW9kZWwlMjIp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer.push_to_hub(<span class="hljs-string">&quot;my-awesome-model&quot;</span>)',wrap:!1}}),ce=new U({props:{code:"dGZfbW9kZWwucHVzaF90b19odWIoJTIybXktYXdlc29tZS1tb2RlbCUyMik=",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>tf_model.push_to_hub(<span class="hljs-string">&quot;my-awesome-model&quot;</span>)',wrap:!1}}),he=new R({props:{title:"使用Web界面上传",local:"使用web界面上传",headingTag:"h2"}}),ve=new R({props:{title:"添加模型卡片",local:"添加模型卡片",headingTag:"h2"}}),We=new fl({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/zh/model_sharing.md"}}),{c(){n=$("meta"),o=r(),a=$("p"),p=r(),h(u.$$.fragment),m=r(),v=$("p"),v.textContent=C,k=r(),Z=$("p"),Z.innerHTML=g,H=r(),x=$("ul"),x.innerHTML=y,L=r(),J=$("iframe"),f=r(),h(j.$$.fragment),xe=r(),h(P.$$.fragment),Le=r(),z=$("p"),z.textContent=kt,Ue=r(),V=$("p"),V.innerHTML=jt,Xe=r(),I=$("p"),I.innerHTML=Wt,Ge=r(),h(E.$$.fragment),Fe=r(),B=$("p"),B.innerHTML=Jt,Re=r(),h(q.$$.fragment),Ye=r(),Q=$("p"),Q.innerHTML=Ct,Pe=r(),h(N.$$.fragment),ze=r(),S=$("p"),S.innerHTML=Zt,Ve=r(),h(A.$$.fragment),Ie=r(),D=$("p"),D.innerHTML=xt,Ee=r(),h(K.$$.fragment),Be=r(),h(O.$$.fragment),qe=r(),ee=$("p"),ee.innerHTML=Lt,Qe=r(),te=$("p"),te.innerHTML=Ut,Ne=r(),h(X.$$.fragment),Se=r(),h(le.$$.fragment),Ae=r(),h(G.$$.fragment),De=r(),h(se.$$.fragment),Ke=r(),ne=$("p"),ne.innerHTML=Xt,Oe=r(),ae=$("p"),ae.innerHTML=Gt,et=r(),h(re.$$.fragment),tt=r(),ie=$("p"),ie.innerHTML=Ft,lt=r(),h(pe.$$.fragment),st=r(),me=$("p"),me.innerHTML=Rt,nt=r(),h(oe.$$.fragment),at=r(),fe=$("p"),fe.innerHTML=Yt,rt=r(),h(ue.$$.fragment),it=r(),$e=$("p"),$e.textContent=Pt,pt=r(),h(ce.$$.fragment),mt=r(),ge=$("p"),ge.innerHTML=zt,ot=r(),de=$("p"),de.innerHTML=Vt,ft=r(),h(he.$$.fragment),ut=r(),be=$("p"),be.innerHTML=It,$t=r(),Me=$("p"),Me.innerHTML=Et,ct=r(),_e=$("p"),_e.textContent=Bt,gt=r(),we=$("ul"),we.innerHTML=qt,dt=r(),Te=$("p"),Te.innerHTML=Qt,ht=r(),ye=$("p"),ye.innerHTML=Nt,bt=r(),h(ve.$$.fragment),Mt=r(),He=$("p"),He.innerHTML=St,_t=r(),ke=$("ul"),ke.innerHTML=At,wt=r(),je=$("p"),je.innerHTML=Dt,Tt=r(),h(We.$$.fragment),yt=r(),Ce=$("p"),this.h()},l(e){const t=il("svelte-u9bgzb",document.head);n=c(t,"META",{name:!0,content:!0}),t.forEach(l),o=i(e),a=c(e,"P",{}),Ht(a).forEach(l),p=i(e),b(u.$$.fragment,e),m=i(e),v=c(e,"P",{"data-svelte-h":!0}),d(v)!=="svelte-1lrbw37"&&(v.textContent=C),k=i(e),Z=c(e,"P",{"data-svelte-h":!0}),d(Z)!=="svelte-1ngdd1j"&&(Z.innerHTML=g),H=i(e),x=c(e,"UL",{"data-svelte-h":!0}),d(x)!=="svelte-10ieul4"&&(x.innerHTML=y),L=i(e),J=c(e,"IFRAME",{width:!0,height:!0,src:!0,title:!0,frameborder:!0,allow:!0}),Ht(J).forEach(l),f=i(e),b(j.$$.fragment,e),xe=i(e),b(P.$$.fragment,e),Le=i(e),z=c(e,"P",{"data-svelte-h":!0}),d(z)!=="svelte-1tq2211"&&(z.textContent=kt),Ue=i(e),V=c(e,"P",{"data-svelte-h":!0}),d(V)!=="svelte-raj8tg"&&(V.innerHTML=jt),Xe=i(e),I=c(e,"P",{"data-svelte-h":!0}),d(I)!=="svelte-18uingj"&&(I.innerHTML=Wt),Ge=i(e),b(E.$$.fragment,e),Fe=i(e),B=c(e,"P",{"data-svelte-h":!0}),d(B)!=="svelte-1xr00h4"&&(B.innerHTML=Jt),Re=i(e),b(q.$$.fragment,e),Ye=i(e),Q=c(e,"P",{"data-svelte-h":!0}),d(Q)!=="svelte-i2egdw"&&(Q.innerHTML=Ct),Pe=i(e),b(N.$$.fragment,e),ze=i(e),S=c(e,"P",{"data-svelte-h":!0}),d(S)!=="svelte-1478bsi"&&(S.innerHTML=Zt),Ve=i(e),b(A.$$.fragment,e),Ie=i(e),D=c(e,"P",{"data-svelte-h":!0}),d(D)!=="svelte-13ab6wt"&&(D.innerHTML=xt),Ee=i(e),b(K.$$.fragment,e),Be=i(e),b(O.$$.fragment,e),qe=i(e),ee=c(e,"P",{"data-svelte-h":!0}),d(ee)!=="svelte-7eiomo"&&(ee.innerHTML=Lt),Qe=i(e),te=c(e,"P",{"data-svelte-h":!0}),d(te)!=="svelte-gmjuq7"&&(te.innerHTML=Ut),Ne=i(e),b(X.$$.fragment,e),Se=i(e),b(le.$$.fragment,e),Ae=i(e),b(G.$$.fragment,e),De=i(e),b(se.$$.fragment,e),Ke=i(e),ne=c(e,"P",{"data-svelte-h":!0}),d(ne)!=="svelte-ujezx5"&&(ne.innerHTML=Xt),Oe=i(e),ae=c(e,"P",{"data-svelte-h":!0}),d(ae)!=="svelte-1wb81no"&&(ae.innerHTML=Gt),et=i(e),b(re.$$.fragment,e),tt=i(e),ie=c(e,"P",{"data-svelte-h":!0}),d(ie)!=="svelte-1hzdr71"&&(ie.innerHTML=Ft),lt=i(e),b(pe.$$.fragment,e),st=i(e),me=c(e,"P",{"data-svelte-h":!0}),d(me)!=="svelte-1yu3blb"&&(me.innerHTML=Rt),nt=i(e),b(oe.$$.fragment,e),at=i(e),fe=c(e,"P",{"data-svelte-h":!0}),d(fe)!=="svelte-1xep3s3"&&(fe.innerHTML=Yt),rt=i(e),b(ue.$$.fragment,e),it=i(e),$e=c(e,"P",{"data-svelte-h":!0}),d($e)!=="svelte-1pi5y8c"&&($e.textContent=Pt),pt=i(e),b(ce.$$.fragment,e),mt=i(e),ge=c(e,"P",{"data-svelte-h":!0}),d(ge)!=="svelte-19x4nvo"&&(ge.innerHTML=zt),ot=i(e),de=c(e,"P",{"data-svelte-h":!0}),d(de)!=="svelte-1v6g4m4"&&(de.innerHTML=Vt),ft=i(e),b(he.$$.fragment,e),ut=i(e),be=c(e,"P",{"data-svelte-h":!0}),d(be)!=="svelte-1bqr08y"&&(be.innerHTML=It),$t=i(e),Me=c(e,"P",{"data-svelte-h":!0}),d(Me)!=="svelte-ahj3l9"&&(Me.innerHTML=Et),ct=i(e),_e=c(e,"P",{"data-svelte-h":!0}),d(_e)!=="svelte-smtcxl"&&(_e.textContent=Bt),gt=i(e),we=c(e,"UL",{"data-svelte-h":!0}),d(we)!=="svelte-1v8tvof"&&(we.innerHTML=qt),dt=i(e),Te=c(e,"P",{"data-svelte-h":!0}),d(Te)!=="svelte-az8tmc"&&(Te.innerHTML=Qt),ht=i(e),ye=c(e,"P",{"data-svelte-h":!0}),d(ye)!=="svelte-32sxm9"&&(ye.innerHTML=Nt),bt=i(e),b(ve.$$.fragment,e),Mt=i(e),He=c(e,"P",{"data-svelte-h":!0}),d(He)!=="svelte-146w62k"&&(He.innerHTML=St),_t=i(e),ke=c(e,"UL",{"data-svelte-h":!0}),d(ke)!=="svelte-9wha7n"&&(ke.innerHTML=At),wt=i(e),je=c(e,"P",{"data-svelte-h":!0}),d(je)!=="svelte-8av605"&&(je.innerHTML=Dt),Tt=i(e),b(We.$$.fragment,e),yt=i(e),Ce=c(e,"P",{}),Ht(Ce).forEach(l),this.h()},h(){F(n,"name","hf:doc:metadata"),F(n,"content",vl),F(J,"width","560"),F(J,"height","315"),sl(J.src,Y="https://www.youtube.com/embed/XvSGPZFEjDY")||F(J,"src",Y),F(J,"title","YouTube video player"),F(J,"frameborder","0"),F(J,"allow",`accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope;
picture-in-picture`),J.allowFullscreen=""},m(e,t){pl(document.head,n),s(e,o,t),s(e,a,t),s(e,p,t),M(u,e,t),s(e,m,t),s(e,v,t),s(e,k,t),s(e,Z,t),s(e,H,t),s(e,x,t),s(e,L,t),s(e,J,t),s(e,f,t),M(j,e,t),s(e,xe,t),M(P,e,t),s(e,Le,t),s(e,z,t),s(e,Ue,t),s(e,V,t),s(e,Xe,t),s(e,I,t),s(e,Ge,t),M(E,e,t),s(e,Fe,t),s(e,B,t),s(e,Re,t),M(q,e,t),s(e,Ye,t),s(e,Q,t),s(e,Pe,t),M(N,e,t),s(e,ze,t),s(e,S,t),s(e,Ve,t),M(A,e,t),s(e,Ie,t),s(e,D,t),s(e,Ee,t),M(K,e,t),s(e,Be,t),M(O,e,t),s(e,qe,t),s(e,ee,t),s(e,Qe,t),s(e,te,t),s(e,Ne,t),M(X,e,t),s(e,Se,t),M(le,e,t),s(e,Ae,t),M(G,e,t),s(e,De,t),M(se,e,t),s(e,Ke,t),s(e,ne,t),s(e,Oe,t),s(e,ae,t),s(e,et,t),M(re,e,t),s(e,tt,t),s(e,ie,t),s(e,lt,t),M(pe,e,t),s(e,st,t),s(e,me,t),s(e,nt,t),M(oe,e,t),s(e,at,t),s(e,fe,t),s(e,rt,t),M(ue,e,t),s(e,it,t),s(e,$e,t),s(e,pt,t),M(ce,e,t),s(e,mt,t),s(e,ge,t),s(e,ot,t),s(e,de,t),s(e,ft,t),M(he,e,t),s(e,ut,t),s(e,be,t),s(e,$t,t),s(e,Me,t),s(e,ct,t),s(e,_e,t),s(e,gt,t),s(e,we,t),s(e,dt,t),s(e,Te,t),s(e,ht,t),s(e,ye,t),s(e,bt,t),M(ve,e,t),s(e,Mt,t),s(e,He,t),s(e,_t,t),s(e,ke,t),s(e,wt,t),s(e,je,t),s(e,Tt,t),M(We,e,t),s(e,yt,t),s(e,Ce,t),vt=!0},p(e,[t]){const Kt={};t&2&&(Kt.$$scope={dirty:t,ctx:e}),j.$set(Kt);const Ot={};t&2&&(Ot.$$scope={dirty:t,ctx:e}),X.$set(Ot);const el={};t&2&&(el.$$scope={dirty:t,ctx:e}),G.$set(el)},i(e){vt||(_(u.$$.fragment,e),_(j.$$.fragment,e),_(P.$$.fragment,e),_(E.$$.fragment,e),_(q.$$.fragment,e),_(N.$$.fragment,e),_(A.$$.fragment,e),_(K.$$.fragment,e),_(O.$$.fragment,e),_(X.$$.fragment,e),_(le.$$.fragment,e),_(G.$$.fragment,e),_(se.$$.fragment,e),_(re.$$.fragment,e),_(pe.$$.fragment,e),_(oe.$$.fragment,e),_(ue.$$.fragment,e),_(ce.$$.fragment,e),_(he.$$.fragment,e),_(ve.$$.fragment,e),_(We.$$.fragment,e),vt=!0)},o(e){w(u.$$.fragment,e),w(j.$$.fragment,e),w(P.$$.fragment,e),w(E.$$.fragment,e),w(q.$$.fragment,e),w(N.$$.fragment,e),w(A.$$.fragment,e),w(K.$$.fragment,e),w(O.$$.fragment,e),w(X.$$.fragment,e),w(le.$$.fragment,e),w(G.$$.fragment,e),w(se.$$.fragment,e),w(re.$$.fragment,e),w(pe.$$.fragment,e),w(oe.$$.fragment,e),w(ue.$$.fragment,e),w(ce.$$.fragment,e),w(he.$$.fragment,e),w(ve.$$.fragment,e),w(We.$$.fragment,e),vt=!1},d(e){e&&(l(o),l(a),l(p),l(m),l(v),l(k),l(Z),l(H),l(x),l(L),l(J),l(f),l(xe),l(Le),l(z),l(Ue),l(V),l(Xe),l(I),l(Ge),l(Fe),l(B),l(Re),l(Ye),l(Q),l(Pe),l(ze),l(S),l(Ve),l(Ie),l(D),l(Ee),l(Be),l(qe),l(ee),l(Qe),l(te),l(Ne),l(Se),l(Ae),l(De),l(Ke),l(ne),l(Oe),l(ae),l(et),l(tt),l(ie),l(lt),l(st),l(me),l(nt),l(at),l(fe),l(rt),l(it),l($e),l(pt),l(mt),l(ge),l(ot),l(de),l(ft),l(ut),l(be),l($t),l(Me),l(ct),l(_e),l(gt),l(we),l(dt),l(Te),l(ht),l(ye),l(bt),l(Mt),l(He),l(_t),l(ke),l(wt),l(je),l(Tt),l(yt),l(Ce)),l(n),T(u,e),T(j,e),T(P,e),T(E,e),T(q,e),T(N,e),T(A,e),T(K,e),T(O,e),T(X,e),T(le,e),T(G,e),T(se,e),T(re,e),T(pe,e),T(oe,e),T(ue,e),T(ce,e),T(he,e),T(ve,e),T(We,e)}}}const vl='{"title":"分享模型","local":"分享模型","sections":[{"title":"仓库功能","local":"仓库功能","sections":[],"depth":2},{"title":"设置","local":"设置","sections":[],"depth":2},{"title":"转换模型适用于所有框架","local":"转换模型适用于所有框架","sections":[],"depth":2},{"title":"在训练过程中推送模型","local":"在训练过程中推送模型","sections":[],"depth":2},{"title":"使用 push_to_hub 功能","local":"使用-pushtohub-功能","sections":[],"depth":2},{"title":"使用Web界面上传","local":"使用web界面上传","sections":[],"depth":2},{"title":"添加模型卡片","local":"添加模型卡片","sections":[],"depth":2}],"depth":1}';function Hl(W){return nl(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ll extends al{constructor(n){super(),rl(this,n,Hl,yl,ll,{})}}export{Ll as component};
