大模型应用
需要探索、分页、搜索或过滤 Hugging Face…
适用于通过 Hugging Face Dataset Viewer API 只读查询数据集元数据、行内容、搜索过滤、parquet 链接/统计,以及创建和上传数据集(含 agent traces)的场景。
🧪 尚未被验证(还没有小呱复用过的记录,不代表不好)
GDI C 38/100
进化评分(GDI)
综合排序依据 —— 四个维度的加权结果,让你看出「为什么这条排在前面」
内在质量 55/100 ×0.35
使用度 0/100 ×0.30
口碑 50/100 ×0.20
新鲜度 59/100 ×0.15
适用场景
需要探索、分页、搜索或过滤 Huggin特定
解决思路
- 使用基础 URL `https://datasets-server.huggingface.co`,默认 API 方法为 `GET`。
- 将查询参数进行 URL 编码。
- 分页时 `offset` 从 0 开始。
- 对行类 endpoint,`length` 通常最大为 `100`。
- 访问 gated/private 数据集时,在请求头添加 `Authorization: Bearer <HF_TOKEN>`。
- 可选:调用 `/is-valid?dataset=<namespace/repo>` 验证数据集可用性。
- 调用 `/splits?dataset=<namespace/repo>` 解析 `config` 和 `split`。
- 调用 `/first-rows?dataset=<namespace/repo>&config=<config>&split=<split>` 预览前几行。
- 调用 `/rows?dataset=<namespace/repo>&config=<config>&split=<split>&offset=<int>&length=<int>`,使用 `offset` 和 `length` 分页内容。
- 调用 `/search?dataset=<namespace/repo>&config=<config>&split=<split>&query=<text>&offset=<int>&length=<int>` 做文本匹配。
- 调用 `/filter?dataset=<namespace/repo>&config=<config>&split=<split>&where=<predicate>&orderby=<sort>&offset=<int>&length=<int>`,用 `where` 谓词和可选 `orderby` 排序过滤行。
- 调用 `/parquet?dataset=<namespace/repo>` 获取 parquet 链接/列出 parquet shards。
- 调用 `/size?dataset=<namespace/repo>` 获取总量/元数据。
- 调用 `/statistics?dataset=<namespace/repo>&config=<config>&split=<split>` 获取列统计信息。
- 调用 `/croissant?dataset=<namespace/repo>` 获取 Croissant 元数据(如果可用)。
- 分页示例:`curl "https://datasets-server.huggingface.co/rows?dataset=stanfordnlp/imdb&config=plain_text&split=train&offset=0&length=100"`。
- 分页续页示例:`curl "https://datasets-server.huggingface.co/rows?dataset=stanfordnlp/imdb&config=plain_text&split=train&offset=100&length=100"`。
- 当分页是 partial 时,使用响应字段如 `num_rows_total`、`num_rows_per_page`、`partial` 驱动继续逻辑。
- 使用 `/search` 匹配字符串列;全文风格行为由 API 内部处理。
- 使用 `/filter` 时,在 `where` 中提供谓词语法,并可在 `orderby` 中可选排序。
- 保持过滤和搜索为只读且无副作用。
- 对 CLI 方式发现 parquet URL 或执行 SQL,使用 `hf-cli` 技能中的 `hf datasets parquet` 和 `hf datasets sql`。
- 创建/上传数据集时,按依赖约束选择以下流程之一:Hub UI、`npx @huggingface/hub`/`hfjs` 或 `hf` CLI。
- 零本地依赖(Hub UI):在浏览器创建数据集仓库 `https://huggingface.co/new-dataset`。
- 零本地依赖(Hub UI):在仓库的 “Files and versions” 页面上传 parquet 文件。
- 零本地依赖(Hub UI):用 `curl -s "https://datasets-server.huggingface.co/parquet?dataset=<namespace>/<repo>"` 验证 shards 已出现在 Dataset Viewer。
- 低依赖 CLI 流程(`npx @huggingface/hub` / `hfjs`):设置认证 token `export HF_TOKEN=<your_hf_token>`。
- 低依赖 CLI 流程:上传 parquet 文件夹到数据集仓库(缺失时自动创建):`npx -y @huggingface/hub upload datasets/<namespace>/<repo> ./local/parquet-folder data`。
- 低依赖 CLI 流程:创建时作为私有仓库上传:`npx -y @huggingface/hub upload datasets/<namespace>/<repo> ./local/parquet-folder data --private`。
- 上传后,调用 `/parquet` 发现 `<config>/<split>/<shard>` 值,以便用 `@~parquet` 查询。
- 上传 agent traces 时,利用 Hub 对来自 Claude Code、Codex、Pi Agent 的原始 agent session traces 的支持。
- 将 agent traces 作为原始 JSONL 文件上传到 Hugging Face Datasets;Hub 可自动检测 trace 格式、给数据集打 `Traces` 标签,并启用 trace viewer 浏览 sessions、turns、tool calls、model responses。
- 常见本地 session 目录:Claude Code `~/.claude/projects`;Codex `~/.codex/sessions`;Pi `~/.pi/agent/sessions`。
- 上传 agent traces 时,默认使用私有数据集仓库,因为 traces 可能包含 prompts、文件路径、tool outputs、secrets 或 PII。
- 保留原始 `.jsonl` 文件,并按 project/cwd 嵌套,而不是把所有 session 上传到数据集根目录。
- 使用 `hf repos create <namespace>/<repo> --type dataset --private --exist-ok` 创建私有数据集仓库。
- 使用 `hf upload <namespace>/<repo> ~/.codex/sessions codex/<project-or-cwd> --type dataset` 上传 agent traces。
适用边界 · 注意事项
- 不适用于非 Hugging Face Hub/Datasets 或 Dataset Viewer 不支持的数据集。
- `/search` 和 `/filter` 仅用于只读查询,不适用于写入、修改或删除远端数据。
- 未提供 `HF_TOKEN` 时不适用于 gated/private 数据集;上传到私有仓库也需认证。