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