import{s as rt,n as ht,o as dt}from"../chunks/scheduler.b108d059.js";import{S as $t,i as gt,g as i,s as a,r as H,A as bt,h as p,f as s,c as n,j as ot,u as y,x as c,k as ft,y as _t,a as l,v as C,d as k,t as J,w as U}from"../chunks/index.008de539.js";import{C as D}from"../chunks/CodeBlock.7b00c886.js";import{H as tt,E as Mt}from"../chunks/index.c4599453.js";function jt(et){let m,P,G,S,u,X,o,st="在本教程中，您将学习如何使用 <code>huggingface_hub</code> 在 Hub 上搜索模型、数据集和Spaces。",Z,f,E,r,lt="<code>huggingface_hub</code>库包括一个 HTTP 客户端 <code>HfApi</code>，用于与 Hub 交互。 除此之外，它还可以列出存储在 Hub 上的模型、数据集和Spaces：",Q,h,W,d,at="<code>list_models()</code> 返回一个迭代器，包含存储在 Hub 上的模型。",z,$,nt="同样，您可以使用 <code>list_datasets()</code> 列出数据集，使用 <code>list_spaces()</code> 列出 Spaces。",N,g,B,b,it=`列出仓库是一个好开始，但现在您可能希望对搜索结果进行过滤。
列出时，可以使用多个属性来过滤结果，例如：`,R,_,pt="<li><code>filter</code></li> <li><code>author</code></li> <li><code>search</code></li> <li>…</li>",q,M,mt="让我们看一个示例，获取所有在 Hub 上进行图像分类的模型，这些模型已在 imagenet 数据集上训练，并使用 PyTorch 运行。",I,j,Y,w,ct="在过滤时，您还可以对模型进行排序，并仅获取前几个结果。例如，以下示例获取了 Hub 上下载量最多的前 5 个数据集：",A,T,F,v,ut=`如果您想要在Hub上探索可用的过滤器, 请在浏览器中访问 <a href="https://huggingface.co/models" rel="nofollow">models</a> 和 <a href="https://huggingface.co/datasets" rel="nofollow">datasets</a> 页面
，尝试不同的参数并查看URL中的值。`,V,x,K,L,O;return u=new tt({props:{title:"搜索 Hub",local:"搜索-hub",headingTag:"h1"}}),f=new tt({props:{title:"如何列出仓库？",local:"如何列出仓库",headingTag:"h2"}}),h=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}}),g=new tt({props:{title:"如何过滤仓库？",local:"如何过滤仓库",headingTag:"h2"}}),j=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}}),T=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}}),x=new Mt({props:{source:"https://github.com/huggingface/huggingface_hub/blob/main/docs/source/cn/guides/search.md"}}),{c(){m=i("meta"),P=a(),G=i("p"),S=a(),H(u.$$.fragment),X=a(),o=i("p"),o.innerHTML=st,Z=a(),H(f.$$.fragment),E=a(),r=i("p"),r.innerHTML=lt,Q=a(),H(h.$$.fragment),W=a(),d=i("p"),d.innerHTML=at,z=a(),$=i("p"),$.innerHTML=nt,N=a(),H(g.$$.fragment),B=a(),b=i("p"),b.textContent=it,R=a(),_=i("ul"),_.innerHTML=pt,q=a(),M=i("p"),M.textContent=mt,I=a(),H(j.$$.fragment),Y=a(),w=i("p"),w.textContent=ct,A=a(),H(T.$$.fragment),F=a(),v=i("p"),v.innerHTML=ut,V=a(),H(x.$$.fragment),K=a(),L=i("p"),this.h()},l(t){const e=bt("svelte-u9bgzb",document.head);m=p(e,"META",{name:!0,content:!0}),e.forEach(s),P=n(t),G=p(t,"P",{}),ot(G).forEach(s),S=n(t),y(u.$$.fragment,t),X=n(t),o=p(t,"P",{"data-svelte-h":!0}),c(o)!=="svelte-1b1v6pd"&&(o.innerHTML=st),Z=n(t),y(f.$$.fragment,t),E=n(t),r=p(t,"P",{"data-svelte-h":!0}),c(r)!=="svelte-18kcau3"&&(r.innerHTML=lt),Q=n(t),y(h.$$.fragment,t),W=n(t),d=p(t,"P",{"data-svelte-h":!0}),c(d)!=="svelte-y1lzfc"&&(d.innerHTML=at),z=n(t),$=p(t,"P",{"data-svelte-h":!0}),c($)!=="svelte-cvctj4"&&($.innerHTML=nt),N=n(t),y(g.$$.fragment,t),B=n(t),b=p(t,"P",{"data-svelte-h":!0}),c(b)!=="svelte-ufu8ai"&&(b.textContent=it),R=n(t),_=p(t,"UL",{"data-svelte-h":!0}),c(_)!=="svelte-11piw8k"&&(_.innerHTML=pt),q=n(t),M=p(t,"P",{"data-svelte-h":!0}),c(M)!=="svelte-sypjiu"&&(M.textContent=mt),I=n(t),y(j.$$.fragment,t),Y=n(t),w=p(t,"P",{"data-svelte-h":!0}),c(w)!=="svelte-cwbh65"&&(w.textContent=ct),A=n(t),y(T.$$.fragment,t),F=n(t),v=p(t,"P",{"data-svelte-h":!0}),c(v)!=="svelte-opj87h"&&(v.innerHTML=ut),V=n(t),y(x.$$.fragment,t),K=n(t),L=p(t,"P",{}),ot(L).forEach(s),this.h()},h(){ft(m,"name","hf:doc:metadata"),ft(m,"content",wt)},m(t,e){_t(document.head,m),l(t,P,e),l(t,G,e),l(t,S,e),C(u,t,e),l(t,X,e),l(t,o,e),l(t,Z,e),C(f,t,e),l(t,E,e),l(t,r,e),l(t,Q,e),C(h,t,e),l(t,W,e),l(t,d,e),l(t,z,e),l(t,$,e),l(t,N,e),C(g,t,e),l(t,B,e),l(t,b,e),l(t,R,e),l(t,_,e),l(t,q,e),l(t,M,e),l(t,I,e),C(j,t,e),l(t,Y,e),l(t,w,e),l(t,A,e),C(T,t,e),l(t,F,e),l(t,v,e),l(t,V,e),C(x,t,e),l(t,K,e),l(t,L,e),O=!0},p:ht,i(t){O||(k(u.$$.fragment,t),k(f.$$.fragment,t),k(h.$$.fragment,t),k(g.$$.fragment,t),k(j.$$.fragment,t),k(T.$$.fragment,t),k(x.$$.fragment,t),O=!0)},o(t){J(u.$$.fragment,t),J(f.$$.fragment,t),J(h.$$.fragment,t),J(g.$$.fragment,t),J(j.$$.fragment,t),J(T.$$.fragment,t),J(x.$$.fragment,t),O=!1},d(t){t&&(s(P),s(G),s(S),s(X),s(o),s(Z),s(E),s(r),s(Q),s(W),s(d),s(z),s($),s(N),s(B),s(b),s(R),s(_),s(q),s(M),s(I),s(Y),s(w),s(A),s(F),s(v),s(V),s(K),s(L)),s(m),U(u,t),U(f,t),U(h,t),U(g,t),U(j,t),U(T,t),U(x,t)}}}const wt='{"title":"搜索 Hub","local":"搜索-hub","sections":[{"title":"如何列出仓库？","local":"如何列出仓库","sections":[],"depth":2},{"title":"如何过滤仓库？","local":"如何过滤仓库","sections":[],"depth":2}],"depth":1}';function Tt(et){return dt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ct extends $t{constructor(m){super(),gt(this,m,Tt,jt,rt,{})}}export{Ct as component};
