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