import{s as Ye,n as We,o as Fe}from"../chunks/scheduler.d6170356.js";import{S as Re,i as qe,g as i,s,r as p,A as Xe,h as o,f as a,c as n,j as Ie,u as d,x as r,k as Me,y as Be,a as l,v as m,d as h,t as u,w as f}from"../chunks/index.fcd4cc08.js";import{C as ye}from"../chunks/CodeBlock.7b16bdef.js";import{H as q}from"../chunks/Heading.8660bd0e.js";function Ee(we){let c,E,X,S,M,V,y,$e='<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>',P,w,ve=`<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>.`,Q,$,z,v,je='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>.',N,j,D,_,_e='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:',K,k,O,T,ee,A,ke='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>.',te,H,Te="As a brief summary, a full setup consists of three steps:",ae,J,Ae='<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>',le,U,se,x,He="You can also use <code>list_adapters</code> to find all adapter models programmatically:",ne,Z,ie,L,Je="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!",oe,g,Ue='<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"/>',re,b,xe='<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"/>',pe,C,de,G,Ze='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>.',me,I,Le="You can share your adapter by using the <code>push_adapter_to_hub</code> method from a model that already contains an adapter.",he,Y,ue,W,Ce="This command creates a repository with an automatically generated model card and all necessary metadata.",fe,F,ce,R,Ge='<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>',ge,B,be;return M=new q({props:{title:"Using Adapters at Hugging Face",local:"using-adapters-at-hugging-face",headingTag:"h1"}}),$=new q({props:{title:"Exploring Adapters on the Hub",local:"exploring-adapters-on-the-hub",headingTag:"h2"}}),j=new q({props:{title:"Installation",local:"installation",headingTag:"h2"}}),k=new ye({props:{code:"cGlwJTIwaW5zdGFsbCUyMGFkYXB0ZXJz",highlighted:'pip <span class="hljs-keyword">install</span> adapters',wrap:!1}}),T=new q({props:{title:"Using existing models",local:"using-existing-models",headingTag:"h2"}}),U=new ye({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 ye({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 q({props:{title:"Sharing your models",local:"sharing-your-models",headingTag:"h2"}}),Y=new ye({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 q({props:{title:"Additional resources",local:"additional-resources",headingTag:"h2"}}),{c(){c=i("meta"),E=s(),X=i("p"),S=s(),p(M.$$.fragment),V=s(),y=i("blockquote"),y.innerHTML=$e,P=s(),w=i("p"),w.innerHTML=ve,Q=s(),p($.$$.fragment),z=s(),v=i("p"),v.innerHTML=je,N=s(),p(j.$$.fragment),D=s(),_=i("p"),_.innerHTML=_e,K=s(),p(k.$$.fragment),O=s(),p(T.$$.fragment),ee=s(),A=i("p"),A.innerHTML=ke,te=s(),H=i("p"),H.textContent=Te,ae=s(),J=i("ol"),J.innerHTML=Ae,le=s(),p(U.$$.fragment),se=s(),x=i("p"),x.innerHTML=He,ne=s(),p(Z.$$.fragment),ie=s(),L=i("p"),L.innerHTML=Je,oe=s(),g=i("div"),g.innerHTML=Ue,re=s(),b=i("div"),b.innerHTML=xe,pe=s(),p(C.$$.fragment),de=s(),G=i("p"),G.innerHTML=Ze,me=s(),I=i("p"),I.innerHTML=Le,he=s(),p(Y.$$.fragment),ue=s(),W=i("p"),W.textContent=Ce,fe=s(),p(F.$$.fragment),ce=s(),R=i("ul"),R.innerHTML=Ge,ge=s(),B=i("p"),this.h()},l(e){const t=Xe("svelte-u9bgzb",document.head);c=o(t,"META",{name:!0,content:!0}),t.forEach(a),E=n(e),X=o(e,"P",{}),Ie(X).forEach(a),S=n(e),d(M.$$.fragment,e),V=n(e),y=o(e,"BLOCKQUOTE",{"data-svelte-h":!0}),r(y)!=="svelte-5qsjn3"&&(y.innerHTML=$e),P=n(e),w=o(e,"P",{"data-svelte-h":!0}),r(w)!=="svelte-3v9lhx"&&(w.innerHTML=ve),Q=n(e),d($.$$.fragment,e),z=n(e),v=o(e,"P",{"data-svelte-h":!0}),r(v)!=="svelte-xecivp"&&(v.innerHTML=je),N=n(e),d(j.$$.fragment,e),D=n(e),_=o(e,"P",{"data-svelte-h":!0}),r(_)!=="svelte-123b3o2"&&(_.innerHTML=_e),K=n(e),d(k.$$.fragment,e),O=n(e),d(T.$$.fragment,e),ee=n(e),A=o(e,"P",{"data-svelte-h":!0}),r(A)!=="svelte-1oontrv"&&(A.innerHTML=ke),te=n(e),H=o(e,"P",{"data-svelte-h":!0}),r(H)!=="svelte-1mgh75q"&&(H.textContent=Te),ae=n(e),J=o(e,"OL",{"data-svelte-h":!0}),r(J)!=="svelte-vmidkf"&&(J.innerHTML=Ae),le=n(e),d(U.$$.fragment,e),se=n(e),x=o(e,"P",{"data-svelte-h":!0}),r(x)!=="svelte-11tjqp"&&(x.innerHTML=He),ne=n(e),d(Z.$$.fragment,e),ie=n(e),L=o(e,"P",{"data-svelte-h":!0}),r(L)!=="svelte-10qgw8i"&&(L.innerHTML=Je),oe=n(e),g=o(e,"DIV",{class:!0,"data-svelte-h":!0}),r(g)!=="svelte-luvuof"&&(g.innerHTML=Ue),re=n(e),b=o(e,"DIV",{class:!0,"data-svelte-h":!0}),r(b)!=="svelte-17ncpcj"&&(b.innerHTML=xe),pe=n(e),d(C.$$.fragment,e),de=n(e),G=o(e,"P",{"data-svelte-h":!0}),r(G)!=="svelte-zfsfg7"&&(G.innerHTML=Ze),me=n(e),I=o(e,"P",{"data-svelte-h":!0}),r(I)!=="svelte-ph4tqa"&&(I.innerHTML=Le),he=n(e),d(Y.$$.fragment,e),ue=n(e),W=o(e,"P",{"data-svelte-h":!0}),r(W)!=="svelte-151qj3l"&&(W.textContent=Ce),fe=n(e),d(F.$$.fragment,e),ce=n(e),R=o(e,"UL",{"data-svelte-h":!0}),r(R)!=="svelte-j8sxww"&&(R.innerHTML=Ge),ge=n(e),B=o(e,"P",{}),Ie(B).forEach(a),this.h()},h(){Me(c,"name","hf:doc:metadata"),Me(c,"content",Se),Me(g,"class","flex justify-center"),Me(b,"class","flex justify-center")},m(e,t){Be(document.head,c),l(e,E,t),l(e,X,t),l(e,S,t),m(M,e,t),l(e,V,t),l(e,y,t),l(e,P,t),l(e,w,t),l(e,Q,t),m($,e,t),l(e,z,t),l(e,v,t),l(e,N,t),m(j,e,t),l(e,D,t),l(e,_,t),l(e,K,t),m(k,e,t),l(e,O,t),m(T,e,t),l(e,ee,t),l(e,A,t),l(e,te,t),l(e,H,t),l(e,ae,t),l(e,J,t),l(e,le,t),m(U,e,t),l(e,se,t),l(e,x,t),l(e,ne,t),m(Z,e,t),l(e,ie,t),l(e,L,t),l(e,oe,t),l(e,g,t),l(e,re,t),l(e,b,t),l(e,pe,t),m(C,e,t),l(e,de,t),l(e,G,t),l(e,me,t),l(e,I,t),l(e,he,t),m(Y,e,t),l(e,ue,t),l(e,W,t),l(e,fe,t),m(F,e,t),l(e,ce,t),l(e,R,t),l(e,ge,t),l(e,B,t),be=!0},p:We,i(e){be||(h(M.$$.fragment,e),h($.$$.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),be=!0)},o(e){u(M.$$.fragment,e),u($.$$.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),be=!1},d(e){e&&(a(E),a(X),a(S),a(V),a(y),a(P),a(w),a(Q),a(z),a(v),a(N),a(D),a(_),a(K),a(O),a(ee),a(A),a(te),a(H),a(ae),a(J),a(le),a(se),a(x),a(ne),a(ie),a(L),a(oe),a(g),a(re),a(b),a(pe),a(de),a(G),a(me),a(I),a(he),a(ue),a(W),a(fe),a(ce),a(R),a(ge),a(B)),a(c),f(M,e),f($,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)}}}const Se='{"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 Ve(we){return Fe(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class De extends Re{constructor(c){super(),qe(this,c,Ve,Ee,Ye,{})}}export{De as component};
