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