import{s as fe,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 ce,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,c,E,f,ae=`<code>huggingface_hub</code> library includes an HTTP client <a href="/docs/huggingface_hub/pr_2291/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,z,g,le='The output of <a href="/docs/huggingface_hub/pr_2291/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/pr_2291/en/package_reference/hf_api#huggingface_hub.HfApi.list_datasets">list_datasets()</a> to list datasets and <a href="/docs/huggingface_hub/pr_2291/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:`,B,$,pe="<li><code>filter</code></li> <li><code>author</code></li> <li><code>search</code></li> <li>…</li>",I,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.",R,x,q,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"}}),c=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(c.$$.fragment),E=l(),f=i("p"),f.innerHTML=ae,W=l(),y(m.$$.fragment),z=l(),g=i("p"),g.innerHTML=le,Q=l(),d=i("p"),d.innerHTML=ne,A=l(),y(b.$$.fragment),N=l(),_=i("p"),_.textContent=ie,B=l(),$=i("ul"),$.innerHTML=pe,I=l(),w=i("p"),w.textContent=oe,R=l(),y(x.$$.fragment),q=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(c.$$.fragment,e),E=n(e),f=p(e,"P",{"data-svelte-h":!0}),r(f)!=="svelte-gipdj9"&&(f.innerHTML=ae),W=n(e),T(m.$$.fragment,e),z=n(e),g=p(e,"P",{"data-svelte-h":!0}),r(g)!=="svelte-y3wuk8"&&(g.innerHTML=le),Q=n(e),d=p(e,"P",{"data-svelte-h":!0}),r(d)!=="svelte-azu56b"&&(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),B=n(e),$=p(e,"UL",{"data-svelte-h":!0}),r($)!=="svelte-11piw8k"&&($.innerHTML=pe),I=n(e),w=p(e,"P",{"data-svelte-h":!0}),r(w)!=="svelte-2psxgl"&&(w.textContent=oe),R=n(e),T(x.$$.fragment,e),q=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(){ce(o,"name","hf:doc:metadata"),ce(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(c,e,t),a(e,E,t),a(e,f,t),a(e,W,t),k(m,e,t),a(e,z,t),a(e,g,t),a(e,Q,t),a(e,d,t),a(e,A,t),k(b,e,t),a(e,N,t),a(e,_,t),a(e,B,t),a(e,$,t),a(e,I,t),a(e,w,t),a(e,R,t),k(x,e,t),a(e,q,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(c.$$.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(c.$$.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(f),s(W),s(z),s(g),s(Q),s(d),s(A),s(N),s(_),s(B),s($),s(I),s(w),s(R),s(q),s(H),s(F),s(Y),s(j),s(V),s(K),s(G)),s(o),L(h,e),L(c,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,fe,{})}}export{ke as component};
