import{s as me,n as de,o as ge}from"../chunks/scheduler.6062bdaf.js";import{S as be,i as _e,g as n,s as l,r as j,A as we,h as o,f as a,c as i,j as ue,u as x,x as p,k as fe,y as Me,a as s,v as k,d as C,t as U,w as J}from"../chunks/index.4bca734e.js";import{C as O}from"../chunks/CodeBlock.fa01571c.js";import{H as ee}from"../chunks/Heading.723dceba.js";function $e(te){let r,G,L,P,h,Z,c,ae="In this tutorial, you will learn how to search models, datasets and spaces on the Hub using <code>huggingface_hub</code>.",A,u,F,f,se=`<code>huggingface_hub</code> library includes an HTTP client <a href="/docs/huggingface_hub/v0.21.1/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:`,Q,m,X,d,le='The output of <a href="/docs/huggingface_hub/v0.21.1/en/package_reference/hf_api#huggingface_hub.HfApi.list_models">list_models()</a> is an iterator over the models stored on the Hub.',R,g,ie='Similarly, you can use <a href="/docs/huggingface_hub/v0.21.1/en/package_reference/hf_api#huggingface_hub.HfApi.list_datasets">list_datasets()</a> to list datasets and <a href="/docs/huggingface_hub/v0.21.1/en/package_reference/hf_api#huggingface_hub.HfApi.list_spaces">list_spaces()</a> to list Spaces.',W,b,z,_,ne=`Listing repositories is great but now you might want to filter your search.
The list helpers have several attributes like:`,B,w,oe="<li><code>filter</code></li> <li><code>author</code></li> <li><code>search</code></li> <li>…</li>",E,M,pe=`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.21.1/en/package_reference/hf_api#huggingface_hub.ModelFilter">ModelFilter</a> object (or <a href="/docs/huggingface_hub/v0.21.1/en/package_reference/hf_api#huggingface_hub.DatasetFilter">DatasetFilter</a>). You can instantiate
it by specifying which models you want to filter.`,N,$,re=`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.21.1/en/package_reference/hf_api#huggingface_hub.ModelFilter">ModelFilter</a>. Attributes are combined as “logical AND”.`,I,v,q,T,he=`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:`,Y,y,D,H,ce=`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,S,K;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"}}),m=new O({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"}}),v=new O({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 O({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}}),{c(){r=n("meta"),G=l(),L=n("p"),P=l(),j(h.$$.fragment),Z=l(),c=n("p"),c.innerHTML=ae,A=l(),j(u.$$.fragment),F=l(),f=n("p"),f.innerHTML=se,Q=l(),j(m.$$.fragment),X=l(),d=n("p"),d.innerHTML=le,R=l(),g=n("p"),g.innerHTML=ie,W=l(),j(b.$$.fragment),z=l(),_=n("p"),_.textContent=ne,B=l(),w=n("ul"),w.innerHTML=oe,E=l(),M=n("p"),M.innerHTML=pe,N=l(),$=n("p"),$.innerHTML=re,I=l(),j(v.$$.fragment),q=l(),T=n("p"),T.textContent=he,Y=l(),j(y.$$.fragment),D=l(),H=n("p"),H.innerHTML=ce,V=l(),S=n("p"),this.h()},l(e){const t=we("svelte-u9bgzb",document.head);r=o(t,"META",{name:!0,content:!0}),t.forEach(a),G=i(e),L=o(e,"P",{}),ue(L).forEach(a),P=i(e),x(h.$$.fragment,e),Z=i(e),c=o(e,"P",{"data-svelte-h":!0}),p(c)!=="svelte-1j3ajgu"&&(c.innerHTML=ae),A=i(e),x(u.$$.fragment,e),F=i(e),f=o(e,"P",{"data-svelte-h":!0}),p(f)!=="svelte-3laua8"&&(f.innerHTML=se),Q=i(e),x(m.$$.fragment,e),X=i(e),d=o(e,"P",{"data-svelte-h":!0}),p(d)!=="svelte-1iao9un"&&(d.innerHTML=le),R=i(e),g=o(e,"P",{"data-svelte-h":!0}),p(g)!=="svelte-44uwnv"&&(g.innerHTML=ie),W=i(e),x(b.$$.fragment,e),z=i(e),_=o(e,"P",{"data-svelte-h":!0}),p(_)!=="svelte-1x8b9ko"&&(_.textContent=ne),B=i(e),w=o(e,"UL",{"data-svelte-h":!0}),p(w)!=="svelte-11piw8k"&&(w.innerHTML=oe),E=i(e),M=o(e,"P",{"data-svelte-h":!0}),p(M)!=="svelte-1x0j6e7"&&(M.innerHTML=pe),N=i(e),$=o(e,"P",{"data-svelte-h":!0}),p($)!=="svelte-u6k30o"&&($.innerHTML=re),I=i(e),x(v.$$.fragment,e),q=i(e),T=o(e,"P",{"data-svelte-h":!0}),p(T)!=="svelte-8rar3u"&&(T.textContent=he),Y=i(e),x(y.$$.fragment,e),D=i(e),H=o(e,"P",{"data-svelte-h":!0}),p(H)!=="svelte-13xztxw"&&(H.innerHTML=ce),V=i(e),S=o(e,"P",{}),ue(S).forEach(a),this.h()},h(){fe(r,"name","hf:doc:metadata"),fe(r,"content",ve)},m(e,t){Me(document.head,r),s(e,G,t),s(e,L,t),s(e,P,t),k(h,e,t),s(e,Z,t),s(e,c,t),s(e,A,t),k(u,e,t),s(e,F,t),s(e,f,t),s(e,Q,t),k(m,e,t),s(e,X,t),s(e,d,t),s(e,R,t),s(e,g,t),s(e,W,t),k(b,e,t),s(e,z,t),s(e,_,t),s(e,B,t),s(e,w,t),s(e,E,t),s(e,M,t),s(e,N,t),s(e,$,t),s(e,I,t),k(v,e,t),s(e,q,t),s(e,T,t),s(e,Y,t),k(y,e,t),s(e,D,t),s(e,H,t),s(e,V,t),s(e,S,t),K=!0},p:de,i(e){K||(C(h.$$.fragment,e),C(u.$$.fragment,e),C(m.$$.fragment,e),C(b.$$.fragment,e),C(v.$$.fragment,e),C(y.$$.fragment,e),K=!0)},o(e){U(h.$$.fragment,e),U(u.$$.fragment,e),U(m.$$.fragment,e),U(b.$$.fragment,e),U(v.$$.fragment,e),U(y.$$.fragment,e),K=!1},d(e){e&&(a(G),a(L),a(P),a(Z),a(c),a(A),a(F),a(f),a(Q),a(X),a(d),a(R),a(g),a(W),a(z),a(_),a(B),a(w),a(E),a(M),a(N),a($),a(I),a(q),a(T),a(Y),a(D),a(H),a(V),a(S)),a(r),J(h,e),J(u,e),J(m,e),J(b,e),J(v,e),J(y,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 Te(te){return ge(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ke extends be{constructor(r){super(),_e(this,r,Te,$e,me,{})}}export{ke as component};
