import{s as Fe,n as Re,o as qe}from"../chunks/scheduler.d6170356.js";import{S as Xe,i as Be,g as i,s,r as p,A as Ee,h as o,f as a,c as n,j as We,u as d,x as r,k as $e,y as Se,a as l,v as m,d as h,t as u,w as f}from"../chunks/index.fcd4cc08.js";import{C as we}from"../chunks/CodeBlock.db16bf50.js";import{H as X,E as Ve}from"../chunks/getInferenceSnippets.0f6acb26.js";function Pe(ve){let c,S,B,V,M,P,y,je='<p>Note: <em>Adapters</em> has replaced the <code>adapter-transformers</code> library and is fully compatible in terms of model weights. See <a href="https://docs.adapterhub.ml/transitioning.html" rel="nofollow">here</a> for more.</p>',Q,$,_e=`<a href="https://github.com/adapter-hub/adapters" rel="nofollow"><em>Adapters</em></a> is an add-on library to 🤗 <code>transformers</code> for efficiently fine-tuning pre-trained language models using adapters and other parameter-efficient methods.
<em>Adapters</em> also provides various methods for composition of adapter modules during training and inference.
You can learn more about this in the <a href="https://arxiv.org/abs/2311.11077" rel="nofollow"><em>Adapters</em> paper</a>.`,z,w,N,v,ke='You can find <em>Adapters</em> 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 aggregated on the <a href="https://adapterhub.ml/explore/" rel="nofollow">AdapterHub website</a>.',D,j,K,_,Te='To get started, you can refer to the <a href="https://docs.adapterhub.ml/installation.html" rel="nofollow">AdapterHub installation guide</a>. You can also use the following one-line install through pip:',O,k,ee,T,te,A,Ae='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>.',ae,H,He="As a brief summary, a full setup consists of three steps:",le,J,Je='<li>Load a base <code>transformers</code> model with the <code>AutoAdapterModel</code> class provided by <em>Adapters</em>.</li> <li>Use the <code>load_adapter()</code> method to load and add an adapter.</li> <li>Activate the adapter via <code>active_adapters</code> (for inference) or activate and set it as trainable via <code>train_adapter()</code> (for training). Make sure to also check out <a href="https://docs.adapterhub.ml/adapter_composition.html" rel="nofollow">composition of adapters</a>.</li>',se,U,ne,x,Ue="You can also use <code>list_adapters</code> to find all adapter models programmatically:",ie,Z,oe,L,xe="If you want to see how to load a specific model, you can click <code>Use in Adapters</code> and you will be given a working snippet that you can load it!",re,g,Ze='<img class="block dark:hidden" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/libraries-adapters_snippet1.png"/> <img class="hidden dark:block" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/libraries-adapters_snippet1-dark.png"/>',pe,b,Le='<img class="block dark:hidden" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/libraries-adapters_snippet2.png"/> <img class="hidden dark:block" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/libraries-adapters_snippet2-dark.png"/>',de,C,me,G,Ce='For a full guide on sharing models with <em>Adapters</em>, we recommend checking out the <a href="https://docs.adapterhub.ml/huggingface_hub.html#uploading-to-the-hub" rel="nofollow">official guide</a>.',he,I,Ge="You can share your adapter by using the <code>push_adapter_to_hub</code> method from a model that already contains an adapter.",ue,Y,fe,W,Ie="This command creates a repository with an automatically generated model card and all necessary metadata.",ce,F,ge,R,Ye='<li><em>Adapters</em> <a href="https://github.com/adapter-hub/adapters" rel="nofollow">repository</a></li> <li><em>Adapters</em> <a href="https://docs.adapterhub.ml" rel="nofollow">docs</a></li> <li><em>Adapters</em> <a href="https://arxiv.org/abs/2311.11077" rel="nofollow">paper</a></li> <li>Integration with Hub <a href="https://docs.adapterhub.ml/huggingface_hub.html" rel="nofollow">docs</a></li>',be,q,Me,E,ye;return M=new X({props:{title:"Using Adapters at Hugging Face",local:"using-adapters-at-hugging-face",headingTag:"h1"}}),w=new X({props:{title:"Exploring Adapters on the Hub",local:"exploring-adapters-on-the-hub",headingTag:"h2"}}),j=new X({props:{title:"Installation",local:"installation",headingTag:"h2"}}),k=new we({props:{code:"cGlwJTIwaW5zdGFsbCUyMGFkYXB0ZXJz",highlighted:'pip <span class="hljs-keyword">install</span> adapters',wrap:!1}}),T=new X({props:{title:"Using existing models",local:"using-existing-models",headingTag:"h2"}}),U=new we({props:{code:"ZnJvbSUyMGFkYXB0ZXJzJTIwaW1wb3J0JTIwQXV0b0FkYXB0ZXJNb2RlbCUwQSUwQSUyMyUyMDEuJTBBbW9kZWwlMjAlM0QlMjBBdXRvQWRhcHRlck1vZGVsLmZyb21fcHJldHJhaW5lZCglMjJGYWNlYm9va0FJJTJGcm9iZXJ0YS1iYXNlJTIyKSUwQSUyMyUyMDIuJTBBYWRhcHRlcl9uYW1lJTIwJTNEJTIwbW9kZWwubG9hZF9hZGFwdGVyKCUyMkFkYXB0ZXJIdWIlMkZyb2JlcnRhLWJhc2UtcGYtaW1kYiUyMiklMEElMjMlMjAzLiUwQW1vZGVsLmFjdGl2ZV9hZGFwdGVycyUyMCUzRCUyMGFkYXB0ZXJfbmFtZSUwQSUyMyUyMG9yJTIwbW9kZWwudHJhaW5fYWRhcHRlcihhZGFwdGVyX25hbWUp",highlighted:`<span class="hljs-keyword">from</span> adapters <span class="hljs-keyword">import</span> AutoAdapterModel

<span class="hljs-comment"># 1.</span>
model = AutoAdapterModel.from_pretrained(<span class="hljs-string">&quot;FacebookAI/roberta-base&quot;</span>)
<span class="hljs-comment"># 2.</span>
adapter_name = model.load_adapter(<span class="hljs-string">&quot;AdapterHub/roberta-base-pf-imdb&quot;</span>)
<span class="hljs-comment"># 3.</span>
model.active_adapters = adapter_name
<span class="hljs-comment"># or model.train_adapter(adapter_name)</span>`,wrap:!1}}),Z=new we({props:{code:"ZnJvbSUyMGFkYXB0ZXJzJTIwaW1wb3J0JTIwbGlzdF9hZGFwdGVycyUwQSUwQSUyMyUyMHNvdXJjZSUyMGNhbiUyMGJlJTIwJTIyYWglMjIlMjAoQWRhcHRlckh1YiklMkMlMjAlMjJoZiUyMiUyMChoZi5jbyklMjBvciUyME5vbmUlMjAoZm9yJTIwYm90aCUyQyUyMGRlZmF1bHQpJTBBYWRhcHRlcl9pbmZvcyUyMCUzRCUyMGxpc3RfYWRhcHRlcnMoc291cmNlJTNEJTIyaGYlMjIlMkMlMjBtb2RlbF9uYW1lJTNEJTIyRmFjZWJvb2tBSSUyRnJvYmVydGEtYmFzZSUyMik=",highlighted:`<span class="hljs-keyword">from</span> adapters <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;FacebookAI/roberta-base&quot;</span>)`,wrap:!1}}),C=new X({props:{title:"Sharing your models",local:"sharing-your-models",headingTag:"h2"}}),Y=new we({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}}),F=new X({props:{title:"Additional resources",local:"additional-resources",headingTag:"h2"}}),q=new Ve({props:{source:"https://github.com/huggingface/hub-docs/blob/main/docs/hub/adapters.md"}}),{c(){c=i("meta"),S=s(),B=i("p"),V=s(),p(M.$$.fragment),P=s(),y=i("blockquote"),y.innerHTML=je,Q=s(),$=i("p"),$.innerHTML=_e,z=s(),p(w.$$.fragment),N=s(),v=i("p"),v.innerHTML=ke,D=s(),p(j.$$.fragment),K=s(),_=i("p"),_.innerHTML=Te,O=s(),p(k.$$.fragment),ee=s(),p(T.$$.fragment),te=s(),A=i("p"),A.innerHTML=Ae,ae=s(),H=i("p"),H.textContent=He,le=s(),J=i("ol"),J.innerHTML=Je,se=s(),p(U.$$.fragment),ne=s(),x=i("p"),x.innerHTML=Ue,ie=s(),p(Z.$$.fragment),oe=s(),L=i("p"),L.innerHTML=xe,re=s(),g=i("div"),g.innerHTML=Ze,pe=s(),b=i("div"),b.innerHTML=Le,de=s(),p(C.$$.fragment),me=s(),G=i("p"),G.innerHTML=Ce,he=s(),I=i("p"),I.innerHTML=Ge,ue=s(),p(Y.$$.fragment),fe=s(),W=i("p"),W.textContent=Ie,ce=s(),p(F.$$.fragment),ge=s(),R=i("ul"),R.innerHTML=Ye,be=s(),p(q.$$.fragment),Me=s(),E=i("p"),this.h()},l(e){const t=Ee("svelte-u9bgzb",document.head);c=o(t,"META",{name:!0,content:!0}),t.forEach(a),S=n(e),B=o(e,"P",{}),We(B).forEach(a),V=n(e),d(M.$$.fragment,e),P=n(e),y=o(e,"BLOCKQUOTE",{"data-svelte-h":!0}),r(y)!=="svelte-5qsjn3"&&(y.innerHTML=je),Q=n(e),$=o(e,"P",{"data-svelte-h":!0}),r($)!=="svelte-3v9lhx"&&($.innerHTML=_e),z=n(e),d(w.$$.fragment,e),N=n(e),v=o(e,"P",{"data-svelte-h":!0}),r(v)!=="svelte-xecivp"&&(v.innerHTML=ke),D=n(e),d(j.$$.fragment,e),K=n(e),_=o(e,"P",{"data-svelte-h":!0}),r(_)!=="svelte-123b3o2"&&(_.innerHTML=Te),O=n(e),d(k.$$.fragment,e),ee=n(e),d(T.$$.fragment,e),te=n(e),A=o(e,"P",{"data-svelte-h":!0}),r(A)!=="svelte-1oontrv"&&(A.innerHTML=Ae),ae=n(e),H=o(e,"P",{"data-svelte-h":!0}),r(H)!=="svelte-1mgh75q"&&(H.textContent=He),le=n(e),J=o(e,"OL",{"data-svelte-h":!0}),r(J)!=="svelte-vmidkf"&&(J.innerHTML=Je),se=n(e),d(U.$$.fragment,e),ne=n(e),x=o(e,"P",{"data-svelte-h":!0}),r(x)!=="svelte-11tjqp"&&(x.innerHTML=Ue),ie=n(e),d(Z.$$.fragment,e),oe=n(e),L=o(e,"P",{"data-svelte-h":!0}),r(L)!=="svelte-10qgw8i"&&(L.innerHTML=xe),re=n(e),g=o(e,"DIV",{class:!0,"data-svelte-h":!0}),r(g)!=="svelte-luvuof"&&(g.innerHTML=Ze),pe=n(e),b=o(e,"DIV",{class:!0,"data-svelte-h":!0}),r(b)!=="svelte-17ncpcj"&&(b.innerHTML=Le),de=n(e),d(C.$$.fragment,e),me=n(e),G=o(e,"P",{"data-svelte-h":!0}),r(G)!=="svelte-zfsfg7"&&(G.innerHTML=Ce),he=n(e),I=o(e,"P",{"data-svelte-h":!0}),r(I)!=="svelte-ph4tqa"&&(I.innerHTML=Ge),ue=n(e),d(Y.$$.fragment,e),fe=n(e),W=o(e,"P",{"data-svelte-h":!0}),r(W)!=="svelte-151qj3l"&&(W.textContent=Ie),ce=n(e),d(F.$$.fragment,e),ge=n(e),R=o(e,"UL",{"data-svelte-h":!0}),r(R)!=="svelte-j8sxww"&&(R.innerHTML=Ye),be=n(e),d(q.$$.fragment,e),Me=n(e),E=o(e,"P",{}),We(E).forEach(a),this.h()},h(){$e(c,"name","hf:doc:metadata"),$e(c,"content",Qe),$e(g,"class","flex justify-center"),$e(b,"class","flex justify-center")},m(e,t){Se(document.head,c),l(e,S,t),l(e,B,t),l(e,V,t),m(M,e,t),l(e,P,t),l(e,y,t),l(e,Q,t),l(e,$,t),l(e,z,t),m(w,e,t),l(e,N,t),l(e,v,t),l(e,D,t),m(j,e,t),l(e,K,t),l(e,_,t),l(e,O,t),m(k,e,t),l(e,ee,t),m(T,e,t),l(e,te,t),l(e,A,t),l(e,ae,t),l(e,H,t),l(e,le,t),l(e,J,t),l(e,se,t),m(U,e,t),l(e,ne,t),l(e,x,t),l(e,ie,t),m(Z,e,t),l(e,oe,t),l(e,L,t),l(e,re,t),l(e,g,t),l(e,pe,t),l(e,b,t),l(e,de,t),m(C,e,t),l(e,me,t),l(e,G,t),l(e,he,t),l(e,I,t),l(e,ue,t),m(Y,e,t),l(e,fe,t),l(e,W,t),l(e,ce,t),m(F,e,t),l(e,ge,t),l(e,R,t),l(e,be,t),m(q,e,t),l(e,Me,t),l(e,E,t),ye=!0},p:Re,i(e){ye||(h(M.$$.fragment,e),h(w.$$.fragment,e),h(j.$$.fragment,e),h(k.$$.fragment,e),h(T.$$.fragment,e),h(U.$$.fragment,e),h(Z.$$.fragment,e),h(C.$$.fragment,e),h(Y.$$.fragment,e),h(F.$$.fragment,e),h(q.$$.fragment,e),ye=!0)},o(e){u(M.$$.fragment,e),u(w.$$.fragment,e),u(j.$$.fragment,e),u(k.$$.fragment,e),u(T.$$.fragment,e),u(U.$$.fragment,e),u(Z.$$.fragment,e),u(C.$$.fragment,e),u(Y.$$.fragment,e),u(F.$$.fragment,e),u(q.$$.fragment,e),ye=!1},d(e){e&&(a(S),a(B),a(V),a(P),a(y),a(Q),a($),a(z),a(N),a(v),a(D),a(K),a(_),a(O),a(ee),a(te),a(A),a(ae),a(H),a(le),a(J),a(se),a(ne),a(x),a(ie),a(oe),a(L),a(re),a(g),a(pe),a(b),a(de),a(me),a(G),a(he),a(I),a(ue),a(fe),a(W),a(ce),a(ge),a(R),a(be),a(Me),a(E)),a(c),f(M,e),f(w,e),f(j,e),f(k,e),f(T,e),f(U,e),f(Z,e),f(C,e),f(Y,e),f(F,e),f(q,e)}}}const Qe='{"title":"Using Adapters at Hugging Face","local":"using-adapters-at-hugging-face","sections":[{"title":"Exploring Adapters on the Hub","local":"exploring-adapters-on-the-hub","sections":[],"depth":2},{"title":"Installation","local":"installation","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 ze(ve){return qe(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class et extends Xe{constructor(c){super(),Be(this,c,ze,Pe,Fe,{})}}export{et as component};
