import{s as ve,n as Te,o as ke}from"../chunks/scheduler.d6170356.js";import{S as He,i as Ae,g as n,s,r as h,A as xe,h as i,f as a,c as r,j as _e,u,x as o,k as oe,y as Je,a as l,v as f,d as c,t as g,w as M}from"../chunks/index.fcd4cc08.js";import{C as de}from"../chunks/CodeBlock.7b16bdef.js";import{H as X}from"../chunks/Heading.8660bd0e.js";function Ze(pe){let d,F,Y,R,b,q,y,me='<code>adapter-transformers</code> is a library that extends 🤗 <code>transformers</code> by allowing to integrate, train and use Adapters and other efficient fine-tuning methods. The library is fully compatible with 🤗 <code>transformers</code>. Adapters are small learnt layers inserted within each layer of a pre-trained model. You can learn more about this in the <a href="https://arxiv.org/abs/2007.07779" rel="nofollow">original paper</a>.',E,$,G,j,he='You can find over a hundred <code>adapter-transformer</code> models by filtering at the left of the <a href="https://huggingface.co/models?library=adapter-transformers&amp;sort=downloads" rel="nofollow">models page</a>. Some adapter models can be found in the Adapter Hub <a href="https://github.com/adapter-hub/hub" rel="nofollow">repository</a>. Models from both sources are then aggregated in the <a href="https://adapterhub.ml/explore/" rel="nofollow">AdapterHub</a>.',V,w,B,_,ue='For a full guide on loading pre-trained adapters, we recommend checking out the <a href="https://docs.adapterhub.ml/loading.html" rel="nofollow">official guide</a>.',z,v,fe="As a brief summary, once you load a model with the usual <code>*Model</code> classes from 🤗<code>transformers</code>, you can use the <code>load_adapter</code> method to load and activate the Adapter (remember <code>adapter-transformers</code> extends 🤗<code>transformers</code>.).",S,T,P,k,ce="You can also use <code>list_adapters</code> to find all Adapter Models programmatically",Q,H,N,A,ge="If you want to see how to load a specific model, you can click <code>Use in Adapter Transformers</code> and you will be given a working snippet that you can load it!",K,p,Me='<img class="block dark:hidden" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/libraries-adapter_transformers_snippet1.png"/> <img class="hidden dark:block" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/libraries-adapter_transformers-snippet1-dark.png"/>',D,m,be='<img class="block dark:hidden" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/libraries-adapter_transformers_snippet2.png"/> <img class="hidden dark:block" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/libraries-adapter_transformers-snippet2-dark.png"/>',O,x,ee,J,ye='For a full guide on sharing models with <code>adapter-transformers</code>, we recommend checking out the <a href="https://docs.adapterhub.ml/huggingface_hub.html#uploading-to-the-hub" rel="nofollow">official guide</a>.',te,Z,$e="You can share your Adapter by using the <code>push_adapter_to_hub</code> method from a model that already contains an adapter.",ae,U,le,W,je="This command creates a repository with an automatically generated model card and all necessary metadata.",se,I,re,L,we='<li>Adapter Transformers <a href="https://github.com/adapter-hub/adapter-transformers" rel="nofollow">library</a>.</li> <li>Adapter Transformers <a href="https://docs.adapterhub.ml/index.html" rel="nofollow">docs</a>.</li> <li>Integration with Hub <a href="https://docs.adapterhub.ml/huggingface_hub.html" rel="nofollow">docs</a>.</li>',ne,C,ie;return b=new X({props:{title:"Using Adapter Transformers at Hugging Face",local:"using-adapter-transformers-at-hugging-face",headingTag:"h1"}}),$=new X({props:{title:"Exploring adapter-transformers in the Hub",local:"exploring-adapter-transformers-in-the-hub",headingTag:"h2"}}),w=new X({props:{title:"Using existing models",local:"using-existing-models",headingTag:"h2"}}),T=new de({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbFdpdGhIZWFkcyUwQSUwQW1vZGVsJTIwJTNEJTIwQXV0b01vZGVsV2l0aEhlYWRzLmZyb21fcHJldHJhaW5lZCglMjJiZXJ0LWJhc2UtdW5jYXNlZCUyMiklMEFhZGFwdGVyX25hbWUlMjAlM0QlMjBtb2RlbC5sb2FkX2FkYXB0ZXIoJTIyQWRhcHRlckh1YiUyRmJlcnQtYmFzZS11bmNhc2VkLXBmLWltZGIlMjIlMkMlMjBzb3VyY2UlM0QlMjJoZiUyMiklMEFtb2RlbC5hY3RpdmVfYWRhcHRlcnMlMjAlM0QlMjBhZGFwdGVyX25hbWU=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelWithHeads

model = AutoModelWithHeads.from_pretrained(<span class="hljs-string">&quot;bert-base-uncased&quot;</span>)
adapter_name = model.load_adapter(<span class="hljs-string">&quot;AdapterHub/bert-base-uncased-pf-imdb&quot;</span>, source=<span class="hljs-string">&quot;hf&quot;</span>)
model.active_adapters = adapter_name`,wrap:!1}}),H=new de({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMGxpc3RfYWRhcHRlcnMlMEElMEElMjMlMjBzb3VyY2UlMjBjYW4lMjBiZSUyMCUyMmFoJTIyJTIwKEFkYXB0ZXJIdWIpJTJDJTIwJTIyaGYlMjIlMjAoaGYuY28pJTIwb3IlMjBOb25lJTIwKGZvciUyMGJvdGglMkMlMjBkZWZhdWx0KSUwQWFkYXB0ZXJfaW5mb3MlMjAlM0QlMjBsaXN0X2FkYXB0ZXJzKHNvdXJjZSUzRCUyMmhmJTIyJTJDJTIwbW9kZWxfbmFtZSUzRCUyMmJlcnQtYmFzZS11bmNhc2VkJTIyKQ==",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> list_adapters

<span class="hljs-comment"># source can be &quot;ah&quot; (AdapterHub), &quot;hf&quot; (hf.co) or None (for both, default)</span>
adapter_infos = list_adapters(source=<span class="hljs-string">&quot;hf&quot;</span>, model_name=<span class="hljs-string">&quot;bert-base-uncased&quot;</span>)`,wrap:!1}}),x=new X({props:{title:"Sharing your models",local:"sharing-your-models",headingTag:"h2"}}),U=new de({props:{code:"bW9kZWwucHVzaF9hZGFwdGVyX3RvX2h1YiglMEElMjAlMjAlMjAlMjAlMjJteS1hd2Vzb21lLWFkYXB0ZXIlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjJhd2Vzb21lX2FkYXB0ZXIlMjIlMkMlMEElMjAlMjAlMjAlMjBhZGFwdGVyaHViX3RhZyUzRCUyMnNlbnRpbWVudCUyRmltZGIlMjIlMkMlMEElMjAlMjAlMjAlMjBkYXRhc2V0c190YWclM0QlMjJpbWRiJTIyJTBBKQ==",highlighted:`model.push_adapter_to_hub(
    <span class="hljs-string">&quot;my-awesome-adapter&quot;</span>,
    <span class="hljs-string">&quot;awesome_adapter&quot;</span>,
    adapterhub_tag=<span class="hljs-string">&quot;sentiment/imdb&quot;</span>,
    datasets_tag=<span class="hljs-string">&quot;imdb&quot;</span>
)`,wrap:!1}}),I=new X({props:{title:"Additional resources",local:"additional-resources",headingTag:"h2"}}),{c(){d=n("meta"),F=s(),Y=n("p"),R=s(),h(b.$$.fragment),q=s(),y=n("p"),y.innerHTML=me,E=s(),h($.$$.fragment),G=s(),j=n("p"),j.innerHTML=he,V=s(),h(w.$$.fragment),B=s(),_=n("p"),_.innerHTML=ue,z=s(),v=n("p"),v.innerHTML=fe,S=s(),h(T.$$.fragment),P=s(),k=n("p"),k.innerHTML=ce,Q=s(),h(H.$$.fragment),N=s(),A=n("p"),A.innerHTML=ge,K=s(),p=n("div"),p.innerHTML=Me,D=s(),m=n("div"),m.innerHTML=be,O=s(),h(x.$$.fragment),ee=s(),J=n("p"),J.innerHTML=ye,te=s(),Z=n("p"),Z.innerHTML=$e,ae=s(),h(U.$$.fragment),le=s(),W=n("p"),W.textContent=je,se=s(),h(I.$$.fragment),re=s(),L=n("ul"),L.innerHTML=we,ne=s(),C=n("p"),this.h()},l(e){const t=xe("svelte-u9bgzb",document.head);d=i(t,"META",{name:!0,content:!0}),t.forEach(a),F=r(e),Y=i(e,"P",{}),_e(Y).forEach(a),R=r(e),u(b.$$.fragment,e),q=r(e),y=i(e,"P",{"data-svelte-h":!0}),o(y)!=="svelte-s4csn2"&&(y.innerHTML=me),E=r(e),u($.$$.fragment,e),G=r(e),j=i(e,"P",{"data-svelte-h":!0}),o(j)!=="svelte-jylpzh"&&(j.innerHTML=he),V=r(e),u(w.$$.fragment,e),B=r(e),_=i(e,"P",{"data-svelte-h":!0}),o(_)!=="svelte-1oontrv"&&(_.innerHTML=ue),z=r(e),v=i(e,"P",{"data-svelte-h":!0}),o(v)!=="svelte-phibtg"&&(v.innerHTML=fe),S=r(e),u(T.$$.fragment,e),P=r(e),k=i(e,"P",{"data-svelte-h":!0}),o(k)!=="svelte-1ai0nzv"&&(k.innerHTML=ce),Q=r(e),u(H.$$.fragment,e),N=r(e),A=i(e,"P",{"data-svelte-h":!0}),o(A)!=="svelte-1tjoh4p"&&(A.innerHTML=ge),K=r(e),p=i(e,"DIV",{class:!0,"data-svelte-h":!0}),o(p)!=="svelte-9ekwy5"&&(p.innerHTML=Me),D=r(e),m=i(e,"DIV",{class:!0,"data-svelte-h":!0}),o(m)!=="svelte-10yio0d"&&(m.innerHTML=be),O=r(e),u(x.$$.fragment,e),ee=r(e),J=i(e,"P",{"data-svelte-h":!0}),o(J)!=="svelte-h4l6kv"&&(J.innerHTML=ye),te=r(e),Z=i(e,"P",{"data-svelte-h":!0}),o(Z)!=="svelte-1px0bm"&&(Z.innerHTML=$e),ae=r(e),u(U.$$.fragment,e),le=r(e),W=i(e,"P",{"data-svelte-h":!0}),o(W)!=="svelte-151qj3l"&&(W.textContent=je),se=r(e),u(I.$$.fragment,e),re=r(e),L=i(e,"UL",{"data-svelte-h":!0}),o(L)!=="svelte-1x7zw2m"&&(L.innerHTML=we),ne=r(e),C=i(e,"P",{}),_e(C).forEach(a),this.h()},h(){oe(d,"name","hf:doc:metadata"),oe(d,"content",Ue),oe(p,"class","flex justify-center"),oe(m,"class","flex justify-center")},m(e,t){Je(document.head,d),l(e,F,t),l(e,Y,t),l(e,R,t),f(b,e,t),l(e,q,t),l(e,y,t),l(e,E,t),f($,e,t),l(e,G,t),l(e,j,t),l(e,V,t),f(w,e,t),l(e,B,t),l(e,_,t),l(e,z,t),l(e,v,t),l(e,S,t),f(T,e,t),l(e,P,t),l(e,k,t),l(e,Q,t),f(H,e,t),l(e,N,t),l(e,A,t),l(e,K,t),l(e,p,t),l(e,D,t),l(e,m,t),l(e,O,t),f(x,e,t),l(e,ee,t),l(e,J,t),l(e,te,t),l(e,Z,t),l(e,ae,t),f(U,e,t),l(e,le,t),l(e,W,t),l(e,se,t),f(I,e,t),l(e,re,t),l(e,L,t),l(e,ne,t),l(e,C,t),ie=!0},p:Te,i(e){ie||(c(b.$$.fragment,e),c($.$$.fragment,e),c(w.$$.fragment,e),c(T.$$.fragment,e),c(H.$$.fragment,e),c(x.$$.fragment,e),c(U.$$.fragment,e),c(I.$$.fragment,e),ie=!0)},o(e){g(b.$$.fragment,e),g($.$$.fragment,e),g(w.$$.fragment,e),g(T.$$.fragment,e),g(H.$$.fragment,e),g(x.$$.fragment,e),g(U.$$.fragment,e),g(I.$$.fragment,e),ie=!1},d(e){e&&(a(F),a(Y),a(R),a(q),a(y),a(E),a(G),a(j),a(V),a(B),a(_),a(z),a(v),a(S),a(P),a(k),a(Q),a(N),a(A),a(K),a(p),a(D),a(m),a(O),a(ee),a(J),a(te),a(Z),a(ae),a(le),a(W),a(se),a(re),a(L),a(ne),a(C)),a(d),M(b,e),M($,e),M(w,e),M(T,e),M(H,e),M(x,e),M(U,e),M(I,e)}}}const Ue='{"title":"Using Adapter Transformers at Hugging Face","local":"using-adapter-transformers-at-hugging-face","sections":[{"title":"Exploring adapter-transformers in the Hub","local":"exploring-adapter-transformers-in-the-hub","sections":[],"depth":2},{"title":"Using existing models","local":"using-existing-models","sections":[],"depth":2},{"title":"Sharing your models","local":"sharing-your-models","sections":[],"depth":2},{"title":"Additional resources","local":"additional-resources","sections":[],"depth":2}],"depth":1}';function We(pe){return ke(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Xe extends He{constructor(d){super(),Ae(this,d,We,Ze,ve,{})}}export{Xe as component};
