import{s as Ie,n as We,o as ke}from"../chunks/scheduler.d6170356.js";import{S as Ce,i as Ee,g as i,s as l,r as o,A as Ge,h as r,f as s,c as a,j as S,u as p,x as d,k as Je,y as Z,a as n,v as m,d as f,t as c,w as h}from"../chunks/index.fcd4cc08.js";import{C as ce}from"../chunks/CodeBlock.7b16bdef.js";import{H as R,E as He}from"../chunks/EditOnGithub.da2b595c.js";function Be(de){let u,A,L,F,w,z,y,ge='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.',V,b,Q,M,we='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>.',X,$,q,T,ye="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.",D,g,_,be='<th width="440px" align="center"><b>Python (original)</b></th> <th width="440px" align="center"><b>Javascript (ours)</b></th>',he,j,P,x,ue,Y,U,O,v,Me="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:",K,J,ee,I,$e='Refer to the <a href="https://huggingface.co/docs/transformers.js" rel="nofollow">documentation</a> for the full list of supported tasks and models.',te,W,se,k,Te='To install via <a href="https://www.npmjs.com/package/@xenova/transformers" rel="nofollow">NPM</a>, run:',ne,C,le,E,je='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/xenova/transformers.js/blob/main/README.md#installation" rel="nofollow">README</a>.',ae,G,ie,H,xe='<li>Transformers.js <a href="https://github.com/xenova/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://xenova.github.io/transformers.js/" rel="nofollow">demo</a></li>',re,B,oe,N,pe;return w=new R({props:{title:"Using Transformers.js at Hugging Face",local:"using-transformersjs-at-hugging-face",headingTag:"h1"}}),b=new R({props:{title:"Exploring transformers.js in the Hub",local:"exploring-transformersjs-in-the-hub",headingTag:"h2"}}),$=new R({props:{title:"Quick tour",local:"quick-tour",headingTag:"h2"}}),x=new ce({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 ce({props:{code:"aW1wb3J0JTIwJTdCJTIwcGlwZWxpbmUlMjAlN0QlMjBmcm9tJTIwJyU0MHhlbm92YSUyRnRyYW5zZm9ybWVycyclM0IlMEElMEElMkYlMkYlMjBBbGxvY2F0ZSUyMGElMjBwaXBlbGluZSUyMGZvciUyMHNlbnRpbWVudC1hbmFseXNpcyUwQWxldCUyMHBpcGUlMjAlM0QlMjBhd2FpdCUyMHBpcGVsaW5lKCdzZW50aW1lbnQtYW5hbHlzaXMnKSUzQiUwQSUwQWxldCUyMG91dCUyMCUzRCUyMGF3YWl0JTIwcGlwZSgnSSUyMGxvdmUlMjB0cmFuc2Zvcm1lcnMhJyklM0IlMEElMkYlMkYlMjAlNUIlN0InbGFiZWwnJTNBJTIwJ1BPU0lUSVZFJyUyQyUyMCdzY29yZSclM0ElMjAwLjk5OTgxNzY4NiU3RCU1RA==",highlighted:`<span class="hljs-keyword">import</span> { pipeline } <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;@xenova/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}}),J=new ce({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}}),W=new R({props:{title:"Installation",local:"installation",headingTag:"h2"}}),C=new ce({props:{code:"bnBtJTIwaSUyMCU0MHhlbm92YSUyRnRyYW5zZm9ybWVycw==",highlighted:"npm i @xenova/transformers",wrap:!1}}),G=new R({props:{title:"Additional resources",local:"additional-resources",headingTag:"h2"}}),B=new He({props:{source:"https://github.com/huggingface/hub-docs/blob/main/docs/hub/transformers-js.md"}}),{c(){u=i("meta"),A=l(),L=i("p"),F=l(),o(w.$$.fragment),z=l(),y=i("p"),y.innerHTML=ge,V=l(),o(b.$$.fragment),Q=l(),M=i("p"),M.innerHTML=we,X=l(),o($.$$.fragment),q=l(),T=i("p"),T.innerHTML=ye,D=l(),g=i("table"),_=i("tr"),_.innerHTML=be,he=l(),j=i("tr"),P=i("td"),o(x.$$.fragment),ue=l(),Y=i("td"),o(U.$$.fragment),O=l(),v=i("p"),v.innerHTML=Me,K=l(),o(J.$$.fragment),ee=l(),I=i("p"),I.innerHTML=$e,te=l(),o(W.$$.fragment),se=l(),k=i("p"),k.innerHTML=Te,ne=l(),o(C.$$.fragment),le=l(),E=i("p"),E.innerHTML=je,ae=l(),o(G.$$.fragment),ie=l(),H=i("ul"),H.innerHTML=xe,re=l(),o(B.$$.fragment),oe=l(),N=i("p"),this.h()},l(e){const t=Ge("svelte-u9bgzb",document.head);u=r(t,"META",{name:!0,content:!0}),t.forEach(s),A=a(e),L=r(e,"P",{}),S(L).forEach(s),F=a(e),p(w.$$.fragment,e),z=a(e),y=r(e,"P",{"data-svelte-h":!0}),d(y)!=="svelte-jfr84k"&&(y.innerHTML=ge),V=a(e),p(b.$$.fragment,e),Q=a(e),M=r(e,"P",{"data-svelte-h":!0}),d(M)!=="svelte-1fvvhlf"&&(M.innerHTML=we),X=a(e),p($.$$.fragment,e),q=a(e),T=r(e,"P",{"data-svelte-h":!0}),d(T)!=="svelte-11oq8sj"&&(T.innerHTML=ye),D=a(e),g=r(e,"TABLE",{});var me=S(g);_=r(me,"TR",{"data-svelte-h":!0}),d(_)!=="svelte-171mvpd"&&(_.innerHTML=be),he=a(me),j=r(me,"TR",{});var fe=S(j);P=r(fe,"TD",{});var Ue=S(P);p(x.$$.fragment,Ue),Ue.forEach(s),ue=a(fe),Y=r(fe,"TD",{});var ve=S(Y);p(U.$$.fragment,ve),ve.forEach(s),fe.forEach(s),me.forEach(s),O=a(e),v=r(e,"P",{"data-svelte-h":!0}),d(v)!=="svelte-q6076l"&&(v.innerHTML=Me),K=a(e),p(J.$$.fragment,e),ee=a(e),I=r(e,"P",{"data-svelte-h":!0}),d(I)!=="svelte-10nh2ih"&&(I.innerHTML=$e),te=a(e),p(W.$$.fragment,e),se=a(e),k=r(e,"P",{"data-svelte-h":!0}),d(k)!=="svelte-15u6aec"&&(k.innerHTML=Te),ne=a(e),p(C.$$.fragment,e),le=a(e),E=r(e,"P",{"data-svelte-h":!0}),d(E)!=="svelte-1mmwayo"&&(E.innerHTML=je),ae=a(e),p(G.$$.fragment,e),ie=a(e),H=r(e,"UL",{"data-svelte-h":!0}),d(H)!=="svelte-1ltctub"&&(H.innerHTML=xe),re=a(e),p(B.$$.fragment,e),oe=a(e),N=r(e,"P",{}),S(N).forEach(s),this.h()},h(){Je(u,"name","hf:doc:metadata"),Je(u,"content",Ze)},m(e,t){Z(document.head,u),n(e,A,t),n(e,L,t),n(e,F,t),m(w,e,t),n(e,z,t),n(e,y,t),n(e,V,t),m(b,e,t),n(e,Q,t),n(e,M,t),n(e,X,t),m($,e,t),n(e,q,t),n(e,T,t),n(e,D,t),n(e,g,t),Z(g,_),Z(g,he),Z(g,j),Z(j,P),m(x,P,null),Z(j,ue),Z(j,Y),m(U,Y,null),n(e,O,t),n(e,v,t),n(e,K,t),m(J,e,t),n(e,ee,t),n(e,I,t),n(e,te,t),m(W,e,t),n(e,se,t),n(e,k,t),n(e,ne,t),m(C,e,t),n(e,le,t),n(e,E,t),n(e,ae,t),m(G,e,t),n(e,ie,t),n(e,H,t),n(e,re,t),m(B,e,t),n(e,oe,t),n(e,N,t),pe=!0},p:We,i(e){pe||(f(w.$$.fragment,e),f(b.$$.fragment,e),f($.$$.fragment,e),f(x.$$.fragment,e),f(U.$$.fragment,e),f(J.$$.fragment,e),f(W.$$.fragment,e),f(C.$$.fragment,e),f(G.$$.fragment,e),f(B.$$.fragment,e),pe=!0)},o(e){c(w.$$.fragment,e),c(b.$$.fragment,e),c($.$$.fragment,e),c(x.$$.fragment,e),c(U.$$.fragment,e),c(J.$$.fragment,e),c(W.$$.fragment,e),c(C.$$.fragment,e),c(G.$$.fragment,e),c(B.$$.fragment,e),pe=!1},d(e){e&&(s(A),s(L),s(F),s(z),s(y),s(V),s(Q),s(M),s(X),s(q),s(T),s(D),s(g),s(O),s(v),s(K),s(ee),s(I),s(te),s(se),s(k),s(ne),s(le),s(E),s(ae),s(ie),s(H),s(re),s(oe),s(N)),s(u),h(w,e),h(b,e),h($,e),h(x),h(U),h(J,e),h(W,e),h(C,e),h(G,e),h(B,e)}}}const Ze='{"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 _e(de){return ke(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ne extends Ce{constructor(u){super(),Ee(this,u,_e,Be,Ie,{})}}export{Ne as component};
