import{s as ce,n as me,o as ge}from"../chunks/scheduler.6062bdaf.js";import{S as de,i as be,g as i,s as l,r as y,A as _e,h as p,f as s,c as n,j as ue,u as T,x as r,k as fe,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 xe(te){let o,P,U,S,h,X,u,se="In this tutorial, you will learn how to search models, datasets and spaces on the Hub using <code>huggingface_hub</code>.",Z,f,E,c,ae=`<code>huggingface_hub</code> library includes an HTTP client <a href="/docs/huggingface_hub/pr_2402/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,m,Q,g,le='The output of <a href="/docs/huggingface_hub/pr_2402/en/package_reference/hf_api#huggingface_hub.HfApi.list_models">list_models()</a> is an iterator over the models stored on the Hub.',z,d,ne='Similarly, you can use <a href="/docs/huggingface_hub/pr_2402/en/package_reference/hf_api#huggingface_hub.HfApi.list_datasets">list_datasets()</a> to list datasets and <a href="/docs/huggingface_hub/pr_2402/en/package_reference/hf_api#huggingface_hub.HfApi.list_spaces">list_spaces()</a> to list Spaces.',A,b,N,_,ie=`Listing repositories is great but now you might want to filter your search.
The list helpers have several attributes like:`,q,$,pe="<li><code>filter</code></li> <li><code>author</code></li> <li><code>search</code></li> <li>…</li>",B,w,oe="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,x,R,H,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,M,Y,j,he=`To explore available filter 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,v,K,G,O;return h=new ee({props:{title:"Search the Hub",local:"search-the-hub",headingTag:"h1"}}),f=new ee({props:{title:"How to list repositories ?",local:"how-to-list-repositories-",headingTag:"h2"}}),m=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"}}),x=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}}),M=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}}),v=new we({props:{source:"https://github.com/huggingface/huggingface_hub/blob/main/docs/source/en/guides/search.md"}}),{c(){o=i("meta"),P=l(),U=i("p"),S=l(),y(h.$$.fragment),X=l(),u=i("p"),u.innerHTML=se,Z=l(),y(f.$$.fragment),E=l(),c=i("p"),c.innerHTML=ae,W=l(),y(m.$$.fragment),Q=l(),g=i("p"),g.innerHTML=le,z=l(),d=i("p"),d.innerHTML=ne,A=l(),y(b.$$.fragment),N=l(),_=i("p"),_.textContent=ie,q=l(),$=i("ul"),$.innerHTML=pe,B=l(),w=i("p"),w.textContent=oe,I=l(),y(x.$$.fragment),R=l(),H=i("p"),H.textContent=re,F=l(),y(M.$$.fragment),Y=l(),j=i("p"),j.innerHTML=he,V=l(),y(v.$$.fragment),K=l(),G=i("p"),this.h()},l(e){const t=_e("svelte-u9bgzb",document.head);o=p(t,"META",{name:!0,content:!0}),t.forEach(s),P=n(e),U=p(e,"P",{}),ue(U).forEach(s),S=n(e),T(h.$$.fragment,e),X=n(e),u=p(e,"P",{"data-svelte-h":!0}),r(u)!=="svelte-1j3ajgu"&&(u.innerHTML=se),Z=n(e),T(f.$$.fragment,e),E=n(e),c=p(e,"P",{"data-svelte-h":!0}),r(c)!=="svelte-1xwndm7"&&(c.innerHTML=ae),W=n(e),T(m.$$.fragment,e),Q=n(e),g=p(e,"P",{"data-svelte-h":!0}),r(g)!=="svelte-qysik6"&&(g.innerHTML=le),z=n(e),d=p(e,"P",{"data-svelte-h":!0}),r(d)!=="svelte-1fgtjjv"&&(d.innerHTML=ne),A=n(e),T(b.$$.fragment,e),N=n(e),_=p(e,"P",{"data-svelte-h":!0}),r(_)!=="svelte-1x8b9ko"&&(_.textContent=ie),q=n(e),$=p(e,"UL",{"data-svelte-h":!0}),r($)!=="svelte-11piw8k"&&($.innerHTML=pe),B=n(e),w=p(e,"P",{"data-svelte-h":!0}),r(w)!=="svelte-2psxgl"&&(w.textContent=oe),I=n(e),T(x.$$.fragment,e),R=n(e),H=p(e,"P",{"data-svelte-h":!0}),r(H)!=="svelte-8rar3u"&&(H.textContent=re),F=n(e),T(M.$$.fragment,e),Y=n(e),j=p(e,"P",{"data-svelte-h":!0}),r(j)!=="svelte-13xztxw"&&(j.innerHTML=he),V=n(e),T(v.$$.fragment,e),K=n(e),G=p(e,"P",{}),ue(G).forEach(s),this.h()},h(){fe(o,"name","hf:doc:metadata"),fe(o,"content",He)},m(e,t){$e(document.head,o),a(e,P,t),a(e,U,t),a(e,S,t),k(h,e,t),a(e,X,t),a(e,u,t),a(e,Z,t),k(f,e,t),a(e,E,t),a(e,c,t),a(e,W,t),k(m,e,t),a(e,Q,t),a(e,g,t),a(e,z,t),a(e,d,t),a(e,A,t),k(b,e,t),a(e,N,t),a(e,_,t),a(e,q,t),a(e,$,t),a(e,B,t),a(e,w,t),a(e,I,t),k(x,e,t),a(e,R,t),a(e,H,t),a(e,F,t),k(M,e,t),a(e,Y,t),a(e,j,t),a(e,V,t),k(v,e,t),a(e,K,t),a(e,G,t),O=!0},p:me,i(e){O||(C(h.$$.fragment,e),C(f.$$.fragment,e),C(m.$$.fragment,e),C(b.$$.fragment,e),C(x.$$.fragment,e),C(M.$$.fragment,e),C(v.$$.fragment,e),O=!0)},o(e){J(h.$$.fragment,e),J(f.$$.fragment,e),J(m.$$.fragment,e),J(b.$$.fragment,e),J(x.$$.fragment,e),J(M.$$.fragment,e),J(v.$$.fragment,e),O=!1},d(e){e&&(s(P),s(U),s(S),s(X),s(u),s(Z),s(E),s(c),s(W),s(Q),s(g),s(z),s(d),s(A),s(N),s(_),s(q),s($),s(B),s(w),s(I),s(R),s(H),s(F),s(Y),s(j),s(V),s(K),s(G)),s(o),L(h,e),L(f,e),L(m,e),L(b,e),L(x,e),L(M,e),L(v,e)}}}const He='{"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(te){return ge(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ke extends de{constructor(o){super(),be(this,o,Me,xe,ce,{})}}export{ke as component};
