import{s as Ge,n as Ce,o as Ee}from"../chunks/scheduler.9cda857a.js";import{S as _e,i as ke,e as i,s as l,c as o,h as Be,a as r,d as s,b as a,f as L,g as p,j as g,k as We,l as Z,m as n,n as m,t as f,o as c,p as h}from"../chunks/index.f47f3121.js";import{C as He}from"../chunks/CopyLLMTxtMenu.676ed699.js";import{C as ue}from"../chunks/CodeBlock.24d62f98.js";import{H as z,E as Ze}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.64d112fc.js";function Se(we){let u,Y,N,Q,w,A,T,F,b,Te='Transformers.js is a JavaScript library for running 🤗 Transformers directly in your browser, with no need for a server! It is designed to be functionally equivalent to the original <a href="https://github.com/huggingface/transformers" rel="nofollow">Python library</a>, meaning you can run the same pretrained models using a very similar API.',X,$,D,y,be='You can find <code>transformers.js</code> models by filtering by library in the <a href="https://huggingface.co/models?library=transformers.js" rel="nofollow">models page</a>.',q,J,O,j,$e="It’s super simple to translate from existing code! Just like the Python library, we support the <code>pipeline</code> API. Pipelines group together a pretrained model with preprocessing of inputs and postprocessing of outputs, making it the easiest way to run models with the library.",K,d,S,ye='<th width="440px" align="center"><b>Python (original)</b></th> <th width="440px" align="center"><b>Javascript (ours)</b></th>',ge,M,P,x,de,R,U,ee,v,Je="You can also use a different model by specifying the model id or path as the second argument to the <code>pipeline</code> function. For example:",te,I,se,W,je='Refer to the <a href="https://huggingface.co/docs/transformers.js" rel="nofollow">documentation</a> for the full list of supported tasks and models.',ne,G,le,C,Me='To install via <a href="https://www.npmjs.com/package/@huggingface/transformers" rel="nofollow">NPM</a>, run:',ae,E,ie,_,xe='For more information, including how to use it in vanilla JS (without any bundler) via a CDN or static hosting, refer to the <a href="https://github.com/huggingface/transformers.js/blob/main/README.md#installation" rel="nofollow">README</a>.',re,k,oe,B,Ue='<li>Transformers.js <a href="https://github.com/huggingface/transformers.js" rel="nofollow">repository</a></li> <li>Transformers.js <a href="https://huggingface.co/docs/transformers.js" rel="nofollow">docs</a></li> <li>Transformers.js <a href="https://huggingface.github.io/transformers.js/" rel="nofollow">demo</a></li>',pe,H,me,V,fe;return w=new He({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),T=new z({props:{title:"Using Transformers.js at Hugging Face",local:"using-transformersjs-at-hugging-face",headingTag:"h1"}}),$=new z({props:{title:"Exploring transformers.js in the Hub",local:"exploring-transformersjs-in-the-hub",headingTag:"h2"}}),J=new z({props:{title:"Quick tour",local:"quick-tour",headingTag:"h2"}}),x=new ue({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMHBpcGVsaW5lJTBBJTBBJTIzJTIwQWxsb2NhdGUlMjBhJTIwcGlwZWxpbmUlMjBmb3IlMjBzZW50aW1lbnQtYW5hbHlzaXMlMEFwaXBlJTIwJTNEJTIwcGlwZWxpbmUoJ3NlbnRpbWVudC1hbmFseXNpcycpJTBBJTBBb3V0JTIwJTNEJTIwcGlwZSgnSSUyMGxvdmUlMjB0cmFuc2Zvcm1lcnMhJyklMEElMjMlMjAlNUIlN0InbGFiZWwnJTNBJTIwJ1BPU0lUSVZFJyUyQyUyMCdzY29yZSclM0ElMjAwLjk5OTgwNjk0MSU3RCU1RA==",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

<span class="hljs-comment"># Allocate a pipeline for sentiment-analysis</span>
pipe = pipeline(<span class="hljs-string">&#x27;sentiment-analysis&#x27;</span>)

out = pipe(<span class="hljs-string">&#x27;I love transformers!&#x27;</span>)
<span class="hljs-comment"># [{&#x27;label&#x27;: &#x27;POSITIVE&#x27;, &#x27;score&#x27;: 0.999806941}]</span>`,wrap:!1}}),U=new ue({props:{code:"aW1wb3J0JTIwJTdCJTIwcGlwZWxpbmUlMjAlN0QlMjBmcm9tJTIwJyU0MGh1Z2dpbmdmYWNlJTJGdHJhbnNmb3JtZXJzJyUzQiUwQSUwQSUyRiUyRiUyMEFsbG9jYXRlJTIwYSUyMHBpcGVsaW5lJTIwZm9yJTIwc2VudGltZW50LWFuYWx5c2lzJTBBbGV0JTIwcGlwZSUyMCUzRCUyMGF3YWl0JTIwcGlwZWxpbmUoJ3NlbnRpbWVudC1hbmFseXNpcycpJTNCJTBBJTBBbGV0JTIwb3V0JTIwJTNEJTIwYXdhaXQlMjBwaXBlKCdJJTIwbG92ZSUyMHRyYW5zZm9ybWVycyEnKSUzQiUwQSUyRiUyRiUyMCU1QiU3QidsYWJlbCclM0ElMjAnUE9TSVRJVkUnJTJDJTIwJ3Njb3JlJyUzQSUyMDAuOTk5ODE3Njg2JTdEJTVE",highlighted:`<span class="hljs-keyword">import</span> { pipeline } <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;@huggingface/transformers&#x27;</span>;

<span class="hljs-comment">// Allocate a pipeline for sentiment-analysis</span>
<span class="hljs-keyword">let</span> pipe = <span class="hljs-keyword">await</span> <span class="hljs-title function_">pipeline</span>(<span class="hljs-string">&#x27;sentiment-analysis&#x27;</span>);

<span class="hljs-keyword">let</span> out = <span class="hljs-keyword">await</span> <span class="hljs-title function_">pipe</span>(<span class="hljs-string">&#x27;I love transformers!&#x27;</span>);
<span class="hljs-comment">// [{&#x27;label&#x27;: &#x27;POSITIVE&#x27;, &#x27;score&#x27;: 0.999817686}]</span>`,wrap:!1}}),I=new ue({props:{code:"JTJGJTJGJTIwVXNlJTIwYSUyMGRpZmZlcmVudCUyMG1vZGVsJTIwZm9yJTIwc2VudGltZW50LWFuYWx5c2lzJTBBbGV0JTIwcGlwZSUyMCUzRCUyMGF3YWl0JTIwcGlwZWxpbmUoJ3NlbnRpbWVudC1hbmFseXNpcyclMkMlMjAnbmxwdG93biUyRmJlcnQtYmFzZS1tdWx0aWxpbmd1YWwtdW5jYXNlZC1zZW50aW1lbnQnKSUzQg==",highlighted:`<span class="hljs-comment">// Use a different model for sentiment-analysis</span>
<span class="hljs-keyword">let</span> pipe = <span class="hljs-keyword">await</span> <span class="hljs-title function_">pipeline</span>(<span class="hljs-string">&#x27;sentiment-analysis&#x27;</span>, <span class="hljs-string">&#x27;nlptown/bert-base-multilingual-uncased-sentiment&#x27;</span>);`,wrap:!1}}),G=new z({props:{title:"Installation",local:"installation",headingTag:"h2"}}),E=new ue({props:{code:"bnBtJTIwaSUyMCU0MGh1Z2dpbmdmYWNlJTJGdHJhbnNmb3JtZXJz",highlighted:"npm i @huggingface/transformers",wrap:!1}}),k=new z({props:{title:"Additional resources",local:"additional-resources",headingTag:"h2"}}),H=new Ze({props:{source:"https://github.com/huggingface/hub-docs/blob/main/docs/hub/transformers-js.md"}}),{c(){u=i("meta"),Y=l(),N=i("p"),Q=l(),o(w.$$.fragment),A=l(),o(T.$$.fragment),F=l(),b=i("p"),b.innerHTML=Te,X=l(),o($.$$.fragment),D=l(),y=i("p"),y.innerHTML=be,q=l(),o(J.$$.fragment),O=l(),j=i("p"),j.innerHTML=$e,K=l(),d=i("table"),S=i("tr"),S.innerHTML=ye,ge=l(),M=i("tr"),P=i("td"),o(x.$$.fragment),de=l(),R=i("td"),o(U.$$.fragment),ee=l(),v=i("p"),v.innerHTML=Je,te=l(),o(I.$$.fragment),se=l(),W=i("p"),W.innerHTML=je,ne=l(),o(G.$$.fragment),le=l(),C=i("p"),C.innerHTML=Me,ae=l(),o(E.$$.fragment),ie=l(),_=i("p"),_.innerHTML=xe,re=l(),o(k.$$.fragment),oe=l(),B=i("ul"),B.innerHTML=Ue,pe=l(),o(H.$$.fragment),me=l(),V=i("p"),this.h()},l(e){const t=Be("svelte-u9bgzb",document.head);u=r(t,"META",{name:!0,content:!0}),t.forEach(s),Y=a(e),N=r(e,"P",{}),L(N).forEach(s),Q=a(e),p(w.$$.fragment,e),A=a(e),p(T.$$.fragment,e),F=a(e),b=r(e,"P",{"data-svelte-h":!0}),g(b)!=="svelte-jfr84k"&&(b.innerHTML=Te),X=a(e),p($.$$.fragment,e),D=a(e),y=r(e,"P",{"data-svelte-h":!0}),g(y)!=="svelte-1fvvhlf"&&(y.innerHTML=be),q=a(e),p(J.$$.fragment,e),O=a(e),j=r(e,"P",{"data-svelte-h":!0}),g(j)!=="svelte-11oq8sj"&&(j.innerHTML=$e),K=a(e),d=r(e,"TABLE",{});var ce=L(d);S=r(ce,"TR",{"data-svelte-h":!0}),g(S)!=="svelte-171mvpd"&&(S.innerHTML=ye),ge=a(ce),M=r(ce,"TR",{});var he=L(M);P=r(he,"TD",{});var ve=L(P);p(x.$$.fragment,ve),ve.forEach(s),de=a(he),R=r(he,"TD",{});var Ie=L(R);p(U.$$.fragment,Ie),Ie.forEach(s),he.forEach(s),ce.forEach(s),ee=a(e),v=r(e,"P",{"data-svelte-h":!0}),g(v)!=="svelte-q6076l"&&(v.innerHTML=Je),te=a(e),p(I.$$.fragment,e),se=a(e),W=r(e,"P",{"data-svelte-h":!0}),g(W)!=="svelte-10nh2ih"&&(W.innerHTML=je),ne=a(e),p(G.$$.fragment,e),le=a(e),C=r(e,"P",{"data-svelte-h":!0}),g(C)!=="svelte-1y7zlz9"&&(C.innerHTML=Me),ae=a(e),p(E.$$.fragment,e),ie=a(e),_=r(e,"P",{"data-svelte-h":!0}),g(_)!=="svelte-1qjggj3"&&(_.innerHTML=xe),re=a(e),p(k.$$.fragment,e),oe=a(e),B=r(e,"UL",{"data-svelte-h":!0}),g(B)!=="svelte-3gcwbj"&&(B.innerHTML=Ue),pe=a(e),p(H.$$.fragment,e),me=a(e),V=r(e,"P",{}),L(V).forEach(s),this.h()},h(){We(u,"name","hf:doc:metadata"),We(u,"content",Le)},m(e,t){Z(document.head,u),n(e,Y,t),n(e,N,t),n(e,Q,t),m(w,e,t),n(e,A,t),m(T,e,t),n(e,F,t),n(e,b,t),n(e,X,t),m($,e,t),n(e,D,t),n(e,y,t),n(e,q,t),m(J,e,t),n(e,O,t),n(e,j,t),n(e,K,t),n(e,d,t),Z(d,S),Z(d,ge),Z(d,M),Z(M,P),m(x,P,null),Z(M,de),Z(M,R),m(U,R,null),n(e,ee,t),n(e,v,t),n(e,te,t),m(I,e,t),n(e,se,t),n(e,W,t),n(e,ne,t),m(G,e,t),n(e,le,t),n(e,C,t),n(e,ae,t),m(E,e,t),n(e,ie,t),n(e,_,t),n(e,re,t),m(k,e,t),n(e,oe,t),n(e,B,t),n(e,pe,t),m(H,e,t),n(e,me,t),n(e,V,t),fe=!0},p:Ce,i(e){fe||(f(w.$$.fragment,e),f(T.$$.fragment,e),f($.$$.fragment,e),f(J.$$.fragment,e),f(x.$$.fragment,e),f(U.$$.fragment,e),f(I.$$.fragment,e),f(G.$$.fragment,e),f(E.$$.fragment,e),f(k.$$.fragment,e),f(H.$$.fragment,e),fe=!0)},o(e){c(w.$$.fragment,e),c(T.$$.fragment,e),c($.$$.fragment,e),c(J.$$.fragment,e),c(x.$$.fragment,e),c(U.$$.fragment,e),c(I.$$.fragment,e),c(G.$$.fragment,e),c(E.$$.fragment,e),c(k.$$.fragment,e),c(H.$$.fragment,e),fe=!1},d(e){e&&(s(Y),s(N),s(Q),s(A),s(F),s(b),s(X),s(D),s(y),s(q),s(O),s(j),s(K),s(d),s(ee),s(v),s(te),s(se),s(W),s(ne),s(le),s(C),s(ae),s(ie),s(_),s(re),s(oe),s(B),s(pe),s(me),s(V)),s(u),h(w,e),h(T,e),h($,e),h(J,e),h(x),h(U),h(I,e),h(G,e),h(E,e),h(k,e),h(H,e)}}}const Le='{"title":"Using Transformers.js at Hugging Face","local":"using-transformersjs-at-hugging-face","sections":[{"title":"Exploring transformers.js in the Hub","local":"exploring-transformersjs-in-the-hub","sections":[],"depth":2},{"title":"Quick tour","local":"quick-tour","sections":[],"depth":2},{"title":"Installation","local":"installation","sections":[],"depth":2},{"title":"Additional resources","local":"additional-resources","sections":[],"depth":2}],"depth":1}';function Ne(we){return Ee(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Qe extends _e{constructor(u){super(),ke(this,u,Ne,Se,Ge,{})}}export{Qe as component};
