import{s as ce,n as fe,o as ge}from"../chunks/scheduler.6062bdaf.js";import{S as de,i as be,g as i,s as l,r as T,A as _e,h as o,f as s,c as n,j as me,u as y,x as r,k as ue,y as $e,a,v as k,d as C,t as J,w as L}from"../chunks/index.4bca734e.js";import{C as D}from"../chunks/CodeBlock.fa01571c.js";import{H as ee,E as we}from"../chunks/EditOnGithub.74ab2baa.js";function He(te){let p,P,U,S,h,X,m,se="In this tutorial, you will learn how to search models, datasets and spaces on the Hub using <code>huggingface_hub</code>.",Z,u,E,c,ae=`<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:`,W,f,Q,g,le='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.',q,d,ne='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.',z,b,A,_,ie=`Listing repositories is great but now you might want to filter your search.
The list helpers have several attributes like:`,N,$,oe="<li><code>filter</code></li> <li><code>author</code></li> <li><code>search</code></li> <li>…</li>",B,w,pe="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.",I,H,R,M,re=`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:`,F,v,Y,x,he=`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.`,V,j,K,G,O;return h=new ee({props:{title:"Search the Hub",local:"search-the-hub",headingTag:"h1"}}),u=new ee({props:{title:"How to list repositories ?",local:"how-to-list-repositories-",headingTag:"h2"}}),f=new D({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}}),b=new ee({props:{title:"How to filter repositories ?",local:"how-to-filter-repositories-",headingTag:"h2"}}),H=new D({props:{code:"bW9kZWxzJTIwJTNEJTIwaGZfYXBpLmxpc3RfbW9kZWxzKCUwQSUwOXRhc2slM0QlMjJpbWFnZS1jbGFzc2lmaWNhdGlvbiUyMiUyQyUwQSUwOWxpYnJhcnklM0QlMjJweXRvcmNoJTIyJTJDJTBBJTA5dHJhaW5lZF9kYXRhc2V0JTNEJTIyaW1hZ2VuZXQlMjIlMkMlMEEp",highlighted:`models = hf_api.list_models(
	task=<span class="hljs-string">&quot;image-classification&quot;</span>,
	library=<span class="hljs-string">&quot;pytorch&quot;</span>,
	trained_dataset=<span class="hljs-string">&quot;imagenet&quot;</span>,
)`,wrap:!1}}),v=new D({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}}),j=new we({props:{source:"https://github.com/huggingface/huggingface_hub/blob/main/docs/source/en/guides/search.md"}}),{c(){p=i("meta"),P=l(),U=i("p"),S=l(),T(h.$$.fragment),X=l(),m=i("p"),m.innerHTML=se,Z=l(),T(u.$$.fragment),E=l(),c=i("p"),c.innerHTML=ae,W=l(),T(f.$$.fragment),Q=l(),g=i("p"),g.innerHTML=le,q=l(),d=i("p"),d.innerHTML=ne,z=l(),T(b.$$.fragment),A=l(),_=i("p"),_.textContent=ie,N=l(),$=i("ul"),$.innerHTML=oe,B=l(),w=i("p"),w.textContent=pe,I=l(),T(H.$$.fragment),R=l(),M=i("p"),M.textContent=re,F=l(),T(v.$$.fragment),Y=l(),x=i("p"),x.innerHTML=he,V=l(),T(j.$$.fragment),K=l(),G=i("p"),this.h()},l(e){const t=_e("svelte-u9bgzb",document.head);p=o(t,"META",{name:!0,content:!0}),t.forEach(s),P=n(e),U=o(e,"P",{}),me(U).forEach(s),S=n(e),y(h.$$.fragment,e),X=n(e),m=o(e,"P",{"data-svelte-h":!0}),r(m)!=="svelte-1j3ajgu"&&(m.innerHTML=se),Z=n(e),y(u.$$.fragment,e),E=n(e),c=o(e,"P",{"data-svelte-h":!0}),r(c)!=="svelte-mu2vrn"&&(c.innerHTML=ae),W=n(e),y(f.$$.fragment,e),Q=n(e),g=o(e,"P",{"data-svelte-h":!0}),r(g)!=="svelte-q7cwx0"&&(g.innerHTML=le),q=n(e),d=o(e,"P",{"data-svelte-h":!0}),r(d)!=="svelte-mzgq4j"&&(d.innerHTML=ne),z=n(e),y(b.$$.fragment,e),A=n(e),_=o(e,"P",{"data-svelte-h":!0}),r(_)!=="svelte-1x8b9ko"&&(_.textContent=ie),N=n(e),$=o(e,"UL",{"data-svelte-h":!0}),r($)!=="svelte-11piw8k"&&($.innerHTML=oe),B=n(e),w=o(e,"P",{"data-svelte-h":!0}),r(w)!=="svelte-2psxgl"&&(w.textContent=pe),I=n(e),y(H.$$.fragment,e),R=n(e),M=o(e,"P",{"data-svelte-h":!0}),r(M)!=="svelte-8rar3u"&&(M.textContent=re),F=n(e),y(v.$$.fragment,e),Y=n(e),x=o(e,"P",{"data-svelte-h":!0}),r(x)!=="svelte-i3k2fd"&&(x.innerHTML=he),V=n(e),y(j.$$.fragment,e),K=n(e),G=o(e,"P",{}),me(G).forEach(s),this.h()},h(){ue(p,"name","hf:doc:metadata"),ue(p,"content",Me)},m(e,t){$e(document.head,p),a(e,P,t),a(e,U,t),a(e,S,t),k(h,e,t),a(e,X,t),a(e,m,t),a(e,Z,t),k(u,e,t),a(e,E,t),a(e,c,t),a(e,W,t),k(f,e,t),a(e,Q,t),a(e,g,t),a(e,q,t),a(e,d,t),a(e,z,t),k(b,e,t),a(e,A,t),a(e,_,t),a(e,N,t),a(e,$,t),a(e,B,t),a(e,w,t),a(e,I,t),k(H,e,t),a(e,R,t),a(e,M,t),a(e,F,t),k(v,e,t),a(e,Y,t),a(e,x,t),a(e,V,t),k(j,e,t),a(e,K,t),a(e,G,t),O=!0},p:fe,i(e){O||(C(h.$$.fragment,e),C(u.$$.fragment,e),C(f.$$.fragment,e),C(b.$$.fragment,e),C(H.$$.fragment,e),C(v.$$.fragment,e),C(j.$$.fragment,e),O=!0)},o(e){J(h.$$.fragment,e),J(u.$$.fragment,e),J(f.$$.fragment,e),J(b.$$.fragment,e),J(H.$$.fragment,e),J(v.$$.fragment,e),J(j.$$.fragment,e),O=!1},d(e){e&&(s(P),s(U),s(S),s(X),s(m),s(Z),s(E),s(c),s(W),s(Q),s(g),s(q),s(d),s(z),s(A),s(_),s(N),s($),s(B),s(w),s(I),s(R),s(M),s(F),s(Y),s(x),s(V),s(K),s(G)),s(p),L(h,e),L(u,e),L(f,e),L(b,e),L(H,e),L(v,e),L(j,e)}}}const Me='{"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 ve(te){return ge(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ke extends de{constructor(p){super(),be(this,p,ve,He,ce,{})}}export{ke as component};
