import{s as de,n as be,o as _e}from"../chunks/scheduler.6062bdaf.js";import{S as we,i as $e,g as n,s as l,r as x,A as Me,h as o,f as s,c as i,j as me,u as k,x as p,k as ge,y as ve,a,v as C,d as U,t as J,w as L}from"../chunks/index.4bca734e.js";import{C as te}from"../chunks/CodeBlock.fa01571c.js";import{H as se,E as Te}from"../chunks/EditOnGithub.74ab2baa.js";function ye(ae){let r,P,G,Z,h,z,c,le="In this tutorial, you will learn how to search models, datasets and spaces on the Hub using <code>huggingface_hub</code>.",A,u,E,f,ie=`<code>huggingface_hub</code> library includes an HTTP client <a href="/docs/huggingface_hub/v0.23.0/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:`,F,m,Q,g,ne='The output of <a href="/docs/huggingface_hub/v0.23.0/en/package_reference/hf_api#huggingface_hub.HfApi.list_models">list_models()</a> is an iterator over the models stored on the Hub.',X,d,oe='Similarly, you can use <a href="/docs/huggingface_hub/v0.23.0/en/package_reference/hf_api#huggingface_hub.HfApi.list_datasets">list_datasets()</a> to list datasets and <a href="/docs/huggingface_hub/v0.23.0/en/package_reference/hf_api#huggingface_hub.HfApi.list_spaces">list_spaces()</a> to list Spaces.',R,b,W,_,pe=`Listing repositories is great but now you might want to filter your search.
The list helpers have several attributes like:`,B,w,re="<li><code>filter</code></li> <li><code>author</code></li> <li><code>search</code></li> <li>…</li>",N,$,he=`Two of these parameters are intuitive (<code>author</code> and <code>search</code>), but what about that <code>filter</code>?
<code>filter</code> takes as input a <a href="/docs/huggingface_hub/v0.23.0/en/package_reference/hf_api#huggingface_hub.ModelFilter">ModelFilter</a> object (or <a href="/docs/huggingface_hub/v0.23.0/en/package_reference/hf_api#huggingface_hub.DatasetFilter">DatasetFilter</a>). You can instantiate
it by specifying which models you want to filter.`,q,M,ce=`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. That can be done with a single
<a href="/docs/huggingface_hub/v0.23.0/en/package_reference/hf_api#huggingface_hub.ModelFilter">ModelFilter</a>. Attributes are combined as “logical AND”.`,I,v,Y,T,ue=`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:`,D,y,V,H,fe=`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.`,K,j,O,S,ee;return h=new se({props:{title:"Search the Hub",local:"search-the-hub",headingTag:"h1"}}),u=new se({props:{title:"How to list repositories ?",local:"how-to-list-repositories-",headingTag:"h2"}}),m=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}}),b=new se({props:{title:"How to filter repositories ?",local:"how-to-filter-repositories-",headingTag:"h2"}}),v=new te({props:{code:"bW9kZWxzJTIwJTNEJTIwaGZfYXBpLmxpc3RfbW9kZWxzKCUwQSUyMCUyMCUyMCUyMGZpbHRlciUzRE1vZGVsRmlsdGVyKCUwQSUwOSUwOXRhc2slM0QlMjJpbWFnZS1jbGFzc2lmaWNhdGlvbiUyMiUyQyUwQSUwOSUwOWxpYnJhcnklM0QlMjJweXRvcmNoJTIyJTJDJTBBJTA5JTA5dHJhaW5lZF9kYXRhc2V0JTNEJTIyaW1hZ2VuZXQlMjIlMEElMDkpJTBBKQ==",highlighted:`models = hf_api.list_models(
    <span class="hljs-built_in">filter</span>=ModelFilter(
		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}}),y=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}}),j=new Te({props:{source:"https://github.com/huggingface/huggingface_hub/blob/main/docs/source/en/guides/search.md"}}),{c(){r=n("meta"),P=l(),G=n("p"),Z=l(),x(h.$$.fragment),z=l(),c=n("p"),c.innerHTML=le,A=l(),x(u.$$.fragment),E=l(),f=n("p"),f.innerHTML=ie,F=l(),x(m.$$.fragment),Q=l(),g=n("p"),g.innerHTML=ne,X=l(),d=n("p"),d.innerHTML=oe,R=l(),x(b.$$.fragment),W=l(),_=n("p"),_.textContent=pe,B=l(),w=n("ul"),w.innerHTML=re,N=l(),$=n("p"),$.innerHTML=he,q=l(),M=n("p"),M.innerHTML=ce,I=l(),x(v.$$.fragment),Y=l(),T=n("p"),T.textContent=ue,D=l(),x(y.$$.fragment),V=l(),H=n("p"),H.innerHTML=fe,K=l(),x(j.$$.fragment),O=l(),S=n("p"),this.h()},l(e){const t=Me("svelte-u9bgzb",document.head);r=o(t,"META",{name:!0,content:!0}),t.forEach(s),P=i(e),G=o(e,"P",{}),me(G).forEach(s),Z=i(e),k(h.$$.fragment,e),z=i(e),c=o(e,"P",{"data-svelte-h":!0}),p(c)!=="svelte-1j3ajgu"&&(c.innerHTML=le),A=i(e),k(u.$$.fragment,e),E=i(e),f=o(e,"P",{"data-svelte-h":!0}),p(f)!=="svelte-9b6ehd"&&(f.innerHTML=ie),F=i(e),k(m.$$.fragment,e),Q=i(e),g=o(e,"P",{"data-svelte-h":!0}),p(g)!=="svelte-1d9cbnw"&&(g.innerHTML=ne),X=i(e),d=o(e,"P",{"data-svelte-h":!0}),p(d)!=="svelte-1nmtbgz"&&(d.innerHTML=oe),R=i(e),k(b.$$.fragment,e),W=i(e),_=o(e,"P",{"data-svelte-h":!0}),p(_)!=="svelte-1x8b9ko"&&(_.textContent=pe),B=i(e),w=o(e,"UL",{"data-svelte-h":!0}),p(w)!=="svelte-11piw8k"&&(w.innerHTML=re),N=i(e),$=o(e,"P",{"data-svelte-h":!0}),p($)!=="svelte-px2q1f"&&($.innerHTML=he),q=i(e),M=o(e,"P",{"data-svelte-h":!0}),p(M)!=="svelte-14z67cd"&&(M.innerHTML=ce),I=i(e),k(v.$$.fragment,e),Y=i(e),T=o(e,"P",{"data-svelte-h":!0}),p(T)!=="svelte-8rar3u"&&(T.textContent=ue),D=i(e),k(y.$$.fragment,e),V=i(e),H=o(e,"P",{"data-svelte-h":!0}),p(H)!=="svelte-13xztxw"&&(H.innerHTML=fe),K=i(e),k(j.$$.fragment,e),O=i(e),S=o(e,"P",{}),me(S).forEach(s),this.h()},h(){ge(r,"name","hf:doc:metadata"),ge(r,"content",He)},m(e,t){ve(document.head,r),a(e,P,t),a(e,G,t),a(e,Z,t),C(h,e,t),a(e,z,t),a(e,c,t),a(e,A,t),C(u,e,t),a(e,E,t),a(e,f,t),a(e,F,t),C(m,e,t),a(e,Q,t),a(e,g,t),a(e,X,t),a(e,d,t),a(e,R,t),C(b,e,t),a(e,W,t),a(e,_,t),a(e,B,t),a(e,w,t),a(e,N,t),a(e,$,t),a(e,q,t),a(e,M,t),a(e,I,t),C(v,e,t),a(e,Y,t),a(e,T,t),a(e,D,t),C(y,e,t),a(e,V,t),a(e,H,t),a(e,K,t),C(j,e,t),a(e,O,t),a(e,S,t),ee=!0},p:be,i(e){ee||(U(h.$$.fragment,e),U(u.$$.fragment,e),U(m.$$.fragment,e),U(b.$$.fragment,e),U(v.$$.fragment,e),U(y.$$.fragment,e),U(j.$$.fragment,e),ee=!0)},o(e){J(h.$$.fragment,e),J(u.$$.fragment,e),J(m.$$.fragment,e),J(b.$$.fragment,e),J(v.$$.fragment,e),J(y.$$.fragment,e),J(j.$$.fragment,e),ee=!1},d(e){e&&(s(P),s(G),s(Z),s(z),s(c),s(A),s(E),s(f),s(F),s(Q),s(g),s(X),s(d),s(R),s(W),s(_),s(B),s(w),s(N),s($),s(q),s(M),s(I),s(Y),s(T),s(D),s(V),s(H),s(K),s(O),s(S)),s(r),L(h,e),L(u,e),L(m,e),L(b,e),L(v,e),L(y,e),L(j,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 je(ae){return _e(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Je extends we{constructor(r){super(),$e(this,r,je,ye,de,{})}}export{Je as component};
