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 j,A as _e,h as p,f as s,c as n,j as ue,u as y,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_2413/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_2413/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_2413/en/package_reference/hf_api#huggingface_hub.HfApi.list_datasets">list_datasets()</a> to list datasets and <a href="/docs/huggingface_hub/pr_2413/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,v,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,H,Y,M,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,T,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}}),H=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}}),T=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(),j(h.$$.fragment),X=l(),u=i("p"),u.innerHTML=se,Z=l(),j(c.$$.fragment),E=l(),f=i("p"),f.innerHTML=ae,W=l(),j(m.$$.fragment),Q=l(),g=i("p"),g.innerHTML=le,z=l(),d=i("p"),d.innerHTML=ne,A=l(),j(b.$$.fragment),N=l(),_=i("p"),_.textContent=ie,B=l(),$=i("ul"),$.innerHTML=pe,I=l(),w=i("p"),w.textContent=oe,R=l(),j(x.$$.fragment),q=l(),v=i("p"),v.textContent=re,F=l(),j(H.$$.fragment),Y=l(),M=i("p"),M.innerHTML=he,V=l(),j(T.$$.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),y(h.$$.fragment,e),X=n(e),u=p(e,"P",{"data-svelte-h":!0}),r(u)!=="svelte-1j3ajgu"&&(u.innerHTML=se),Z=n(e),y(c.$$.fragment,e),E=n(e),f=p(e,"P",{"data-svelte-h":!0}),r(f)!=="svelte-ed0n7h"&&(f.innerHTML=ae),W=n(e),y(m.$$.fragment,e),Q=n(e),g=p(e,"P",{"data-svelte-h":!0}),r(g)!=="svelte-8wmxvk"&&(g.innerHTML=le),z=n(e),d=p(e,"P",{"data-svelte-h":!0}),r(d)!=="svelte-xgd5vn"&&(d.innerHTML=ne),A=n(e),y(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),y(x.$$.fragment,e),q=n(e),v=p(e,"P",{"data-svelte-h":!0}),r(v)!=="svelte-8rar3u"&&(v.textContent=re),F=n(e),y(H.$$.fragment,e),Y=n(e),M=p(e,"P",{"data-svelte-h":!0}),r(M)!=="svelte-13xztxw"&&(M.innerHTML=he),V=n(e),y(T.$$.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",ve)},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,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,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,v,t),a(e,F,t),k(H,e,t),a(e,Y,t),a(e,M,t),a(e,V,t),k(T,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(H.$$.fragment,e),C(T.$$.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(H.$$.fragment,e),J(T.$$.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(Q),s(g),s(z),s(d),s(A),s(N),s(_),s(B),s($),s(I),s(w),s(R),s(q),s(v),s(F),s(Y),s(M),s(V),s(K),s(G)),s(o),L(h,e),L(c,e),L(m,e),L(b,e),L(x,e),L(H,e),L(T,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 He(te){return ge(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ke extends de{constructor(o){super(),be(this,o,He,xe,fe,{})}}export{ke as component};
