import{s as ge,n as de,o as be}from"../chunks/scheduler.0cf4ef2e.js";import{S as $e,i as _e,e as i,s as l,c as h,h as we,a as p,d as s,b as n,f as ue,g as m,j as r,k as ce,l as ye,m as a,n as f,t as u,o as c,p as g}from"../chunks/index.abc433bf.js";import{C as xe}from"../chunks/CopyLLMTxtMenu.efc6b005.js";import{C as te}from"../chunks/CodeBlock.00dcd05e.js";import{H as se,E as He}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.86d448e2.js";function Te(ae){let o,S,P,z,d,W,b,Z,$,le="In this tutorial, you will learn how to search models, datasets and spaces on the Hub using <code>huggingface_hub</code>.",q,_,E,w,ne=`<code>huggingface_hub</code> library includes an HTTP client <a href="/docs/huggingface_hub/main/en/package_reference/hf_api#huggingface_hub.HfApi">HfApi</a> to interact with the Hub.
Among other things, it can list models, datasets and spaces stored on the Hub:`,I,y,X,x,ie='The output of <a href="/docs/huggingface_hub/main/en/package_reference/hf_api#huggingface_hub.HfApi.list_models">list_models()</a> is an iterator over the models stored on the Hub.',N,H,pe='Similarly, you can use <a href="/docs/huggingface_hub/main/en/package_reference/hf_api#huggingface_hub.HfApi.list_datasets">list_datasets()</a> to list datasets and <a href="/docs/huggingface_hub/main/en/package_reference/hf_api#huggingface_hub.HfApi.list_spaces">list_spaces()</a> to list Spaces.',A,T,Q,v,oe=`Listing repositories is great but now you might want to filter your search.
The list helpers have several attributes like:`,R,M,re="<li><code>filter</code></li> <li><code>author</code></li> <li><code>search</code></li> <li>…</li>",Y,j,he="Let’s see an example to get all models on the Hub that does image classification, have been trained on the imagenet dataset and that runs with PyTorch.",B,C,F,k,me=`While filtering, you can also sort the models and take only the top results. For example,
the following example fetches the top 5 most downloaded datasets on the Hub:`,K,L,V,J,fe=`To explore available filters on the Hub, visit <a href="https://huggingface.co/models" rel="nofollow">models</a> and <a href="https://huggingface.co/datasets" rel="nofollow">datasets</a> pages
in your browser, search for some parameters and look at the values in the URL.`,D,U,O,G,ee;return d=new xe({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),b=new se({props:{title:"Search the Hub",local:"search-the-hub",headingTag:"h1"}}),_=new se({props:{title:"How to list repositories ?",local:"how-to-list-repositories-",headingTag:"h2"}}),y=new te({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMEhmQXBpJTBBYXBpJTIwJTNEJTIwSGZBcGkoKSUwQW1vZGVscyUyMCUzRCUyMGFwaS5saXN0X21vZGVscygp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> HfApi
<span class="hljs-meta">&gt;&gt;&gt; </span>api = HfApi()
<span class="hljs-meta">&gt;&gt;&gt; </span>models = api.list_models()`,wrap:!1}}),T=new se({props:{title:"How to filter repositories ?",local:"how-to-filter-repositories-",headingTag:"h2"}}),C=new te({props:{code:"bW9kZWxzJTIwJTNEJTIwaGZfYXBpLmxpc3RfbW9kZWxzKGZpbHRlciUzRCU1QiUyMmltYWdlLWNsYXNzaWZpY2F0aW9uJTIyJTJDJTIwJTIycHl0b3JjaCUyMiUyQyUyMCUyMmltYWdlbmV0JTIyJTVEKQ==",highlighted:'models = hf_api.list_models(<span class="hljs-built_in">filter</span>=[<span class="hljs-string">&quot;image-classification&quot;</span>, <span class="hljs-string">&quot;pytorch&quot;</span>, <span class="hljs-string">&quot;imagenet&quot;</span>])',wrap:!1}}),L=new te({props:{code:"bGlzdChsaXN0X2RhdGFzZXRzKHNvcnQlM0QlMjJkb3dubG9hZHMlMjIlMkMlMjBkaXJlY3Rpb24lM0QtMSUyQyUyMGxpbWl0JTNENSkp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">list</span>(list_datasets(sort=<span class="hljs-string">&quot;downloads&quot;</span>, direction=-<span class="hljs-number">1</span>, limit=<span class="hljs-number">5</span>))
[DatasetInfo(
	<span class="hljs-built_in">id</span>=<span class="hljs-string">&#x27;argilla/databricks-dolly-15k-curated-en&#x27;</span>,
	author=<span class="hljs-string">&#x27;argilla&#x27;</span>,
	sha=<span class="hljs-string">&#x27;4dcd1dedbe148307a833c931b21ca456a1fc4281&#x27;</span>,
	last_modified=datetime.datetime(<span class="hljs-number">2023</span>, <span class="hljs-number">10</span>, <span class="hljs-number">2</span>, <span class="hljs-number">12</span>, <span class="hljs-number">32</span>, <span class="hljs-number">53</span>, tzinfo=datetime.timezone.utc),
	private=<span class="hljs-literal">False</span>,
	downloads=<span class="hljs-number">8889377</span>,
	(...)`,wrap:!1}}),U=new He({props:{source:"https://github.com/huggingface/huggingface_hub/blob/main/docs/source/en/guides/search.md"}}),{c(){o=i("meta"),S=l(),P=i("p"),z=l(),h(d.$$.fragment),W=l(),h(b.$$.fragment),Z=l(),$=i("p"),$.innerHTML=le,q=l(),h(_.$$.fragment),E=l(),w=i("p"),w.innerHTML=ne,I=l(),h(y.$$.fragment),X=l(),x=i("p"),x.innerHTML=ie,N=l(),H=i("p"),H.innerHTML=pe,A=l(),h(T.$$.fragment),Q=l(),v=i("p"),v.textContent=oe,R=l(),M=i("ul"),M.innerHTML=re,Y=l(),j=i("p"),j.textContent=he,B=l(),h(C.$$.fragment),F=l(),k=i("p"),k.textContent=me,K=l(),h(L.$$.fragment),V=l(),J=i("p"),J.innerHTML=fe,D=l(),h(U.$$.fragment),O=l(),G=i("p"),this.h()},l(e){const t=we("svelte-u9bgzb",document.head);o=p(t,"META",{name:!0,content:!0}),t.forEach(s),S=n(e),P=p(e,"P",{}),ue(P).forEach(s),z=n(e),m(d.$$.fragment,e),W=n(e),m(b.$$.fragment,e),Z=n(e),$=p(e,"P",{"data-svelte-h":!0}),r($)!=="svelte-1j3ajgu"&&($.innerHTML=le),q=n(e),m(_.$$.fragment,e),E=n(e),w=p(e,"P",{"data-svelte-h":!0}),r(w)!=="svelte-mu2vrn"&&(w.innerHTML=ne),I=n(e),m(y.$$.fragment,e),X=n(e),x=p(e,"P",{"data-svelte-h":!0}),r(x)!=="svelte-q7cwx0"&&(x.innerHTML=ie),N=n(e),H=p(e,"P",{"data-svelte-h":!0}),r(H)!=="svelte-mzgq4j"&&(H.innerHTML=pe),A=n(e),m(T.$$.fragment,e),Q=n(e),v=p(e,"P",{"data-svelte-h":!0}),r(v)!=="svelte-1x8b9ko"&&(v.textContent=oe),R=n(e),M=p(e,"UL",{"data-svelte-h":!0}),r(M)!=="svelte-11piw8k"&&(M.innerHTML=re),Y=n(e),j=p(e,"P",{"data-svelte-h":!0}),r(j)!=="svelte-2psxgl"&&(j.textContent=he),B=n(e),m(C.$$.fragment,e),F=n(e),k=p(e,"P",{"data-svelte-h":!0}),r(k)!=="svelte-8rar3u"&&(k.textContent=me),K=n(e),m(L.$$.fragment,e),V=n(e),J=p(e,"P",{"data-svelte-h":!0}),r(J)!=="svelte-i3k2fd"&&(J.innerHTML=fe),D=n(e),m(U.$$.fragment,e),O=n(e),G=p(e,"P",{}),ue(G).forEach(s),this.h()},h(){ce(o,"name","hf:doc:metadata"),ce(o,"content",ve)},m(e,t){ye(document.head,o),a(e,S,t),a(e,P,t),a(e,z,t),f(d,e,t),a(e,W,t),f(b,e,t),a(e,Z,t),a(e,$,t),a(e,q,t),f(_,e,t),a(e,E,t),a(e,w,t),a(e,I,t),f(y,e,t),a(e,X,t),a(e,x,t),a(e,N,t),a(e,H,t),a(e,A,t),f(T,e,t),a(e,Q,t),a(e,v,t),a(e,R,t),a(e,M,t),a(e,Y,t),a(e,j,t),a(e,B,t),f(C,e,t),a(e,F,t),a(e,k,t),a(e,K,t),f(L,e,t),a(e,V,t),a(e,J,t),a(e,D,t),f(U,e,t),a(e,O,t),a(e,G,t),ee=!0},p:de,i(e){ee||(u(d.$$.fragment,e),u(b.$$.fragment,e),u(_.$$.fragment,e),u(y.$$.fragment,e),u(T.$$.fragment,e),u(C.$$.fragment,e),u(L.$$.fragment,e),u(U.$$.fragment,e),ee=!0)},o(e){c(d.$$.fragment,e),c(b.$$.fragment,e),c(_.$$.fragment,e),c(y.$$.fragment,e),c(T.$$.fragment,e),c(C.$$.fragment,e),c(L.$$.fragment,e),c(U.$$.fragment,e),ee=!1},d(e){e&&(s(S),s(P),s(z),s(W),s(Z),s($),s(q),s(E),s(w),s(I),s(X),s(x),s(N),s(H),s(A),s(Q),s(v),s(R),s(M),s(Y),s(j),s(B),s(F),s(k),s(K),s(V),s(J),s(D),s(O),s(G)),s(o),g(d,e),g(b,e),g(_,e),g(y,e),g(T,e),g(C,e),g(L,e),g(U,e)}}}const ve='{"title":"Search the Hub","local":"search-the-hub","sections":[{"title":"How to list repositories ?","local":"how-to-list-repositories-","sections":[],"depth":2},{"title":"How to filter repositories ?","local":"how-to-filter-repositories-","sections":[],"depth":2}],"depth":1}';function Me(ae){return be(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ue extends $e{constructor(o){super(),_e(this,o,Me,Te,ge,{})}}export{Ue as component};
