forked from huggingface/huggingface_hub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[i18n-CN] Translated some files to implified Chinese huggingface#1915 (…
…huggingface#1916) * update file * update file * update file * update file * update file * update file * update file * update file * update file * update file * update file * update file * upfate file * update file * update file * update file * update file * update file * update file * update file * update file * update file * update file * update file * update file * update file * update file * update file * update file * update file * update file * update file * update file * update file * update file * update file --------- Co-authored-by: King guys <68528929+jimtom40395@users.noreply.github.com> Co-authored-by: Lucain <lucainp@gmail.com>
- Loading branch information
1 parent
84d1b31
commit 5100ee4
Showing
12 changed files
with
781 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
<p align="center"> | ||
<br/> | ||
<img alt="huggingface_hub library logo" src="https://huggingface.co/datasets/huggingface/documentation-images/raw/main/huggingface_hub.svg" width="376" height="59" style="max-width: 100%;"> | ||
<br/> | ||
</p> | ||
|
||
<p align="center"> | ||
<i>Hugging Face Hub Python 客户端</i> | ||
</p> | ||
|
||
<p align="center"> | ||
<a href="https://huggingface.co/docs/huggingface_hub/en/index"><img alt="Documentation" src="https://img.shields.io/website/http/huggingface.co/docs/huggingface_hub/index.svg?down_color=red&down_message=offline&up_message=online&label=doc"></a> | ||
<a href="https://github.com/huggingface/huggingface_hub/releases"><img alt="GitHub release" src="https://img.shields.io/github/release/huggingface/huggingface_hub.svg"></a> | ||
<a href="https://github.com/huggingface/huggingface_hub"><img alt="PyPi version" src="https://img.shields.io/pypi/pyversions/huggingface_hub.svg"></a> | ||
<a href="https://pypi.org/project/huggingface-hub"><img alt="downloads" src="https://static.pepy.tech/badge/huggingface_hub/month"></a> | ||
<a href="https://codecov.io/gh/huggingface/huggingface_hub"><img alt="Code coverage" src="https://codecov.io/gh/huggingface/huggingface_hub/branch/main/graph/badge.svg?token=RXP95LE2XL"></a> | ||
</p> | ||
|
||
<h4 align="center"> | ||
<p> | ||
<a href="https://github.com/huggingface/huggingface_hub/blob/main/README.md">English</a> | | ||
<a href="https://github.com/huggingface/huggingface_hub/blob/main/README_de.md">Deutsch</a> | | ||
<a href="https://github.com/huggingface/huggingface_hub/blob/main/README_hi.md">हिंदी</a> | | ||
<a href="https://github.com/huggingface/huggingface_hub/blob/main/README_ko.md">한국어</a> | | ||
<b>中文(简体)</b> | ||
<p> | ||
</h4> | ||
--- | ||
|
||
**文档**: `<a href="https://hf.co/docs/huggingface_hub" target="_blank">`https://hf.co/docs/huggingface_hub `</a>` | ||
|
||
**源代码**: `<a href="https://github.com/huggingface/huggingface_hub" target="_blank">`https://github.com/huggingface/huggingface_hub `</a>` | ||
|
||
--- | ||
|
||
## 欢迎使用 Hugging Face Hub 库 | ||
|
||
通过`huggingface_hub` 库,您可以与面向机器学习开发者和协作者的平台 [Hugging Face Hub](https://huggingface.co/)进行交互,找到适用于您所在项目的预训练模型和数据集,体验在平台托管的数百个机器学习应用,还可以创建或分享自己的模型和数据集并于社区共享。以上所有都可以用Python在`huggingface_hub` 库中轻松实现。 | ||
|
||
## 主要特点 | ||
|
||
- [从hugging face hub下载文件](https://huggingface.co/docs/huggingface_hub/en/guides/download) | ||
- [上传文件到 hugging face hub](https://huggingface.co/docs/huggingface_hub/en/guides/upload) | ||
- [管理您的存储库](https://huggingface.co/docs/huggingface_hub/en/guides/repository) | ||
- [在部署的模型上运行推断](https://huggingface.co/docs/huggingface_hub/en/guides/inference) | ||
- [搜索模型、数据集和空间](https://huggingface.co/docs/huggingface_hub/en/guides/search) | ||
- [分享模型卡片](https://huggingface.co/docs/huggingface_hub/en/guides/model-cards) | ||
- [社区互动](https://huggingface.co/docs/huggingface_hub/en/guides/community) | ||
|
||
## 安装 | ||
|
||
使用pip安装 `huggingface_hub` 包: | ||
|
||
```bash | ||
pip install huggingface_hub | ||
``` | ||
|
||
如果您更喜欢,也可以使用 conda 进行安装 | ||
|
||
为了默认保持包的最小化,huggingface_hub 带有一些可选的依赖项,适用于某些用例。例如,如果您想要完整的推断体验,请运行: | ||
|
||
```bash | ||
pip install huggingface_hub[inference] | ||
``` | ||
|
||
要了解更多安装和可选依赖项,请查看[安装指南](https://huggingface.co/docs/huggingface_hub/cn/安装) | ||
|
||
## 快速入门指南 | ||
|
||
### 下载文件 | ||
|
||
下载单个文件,请运行以下代码: | ||
|
||
```py | ||
from huggingface_hub import hf_hub_download | ||
|
||
hf_hub_download(repo_id="tiiuae/falcon-7b-instruct", filename="config.json") | ||
``` | ||
|
||
如果下载整个存储库,请运行以下代码: | ||
|
||
```py | ||
from huggingface_hub import snapshot_download | ||
|
||
snapshot_download("stabilityai/stable-diffusion-2-1") | ||
``` | ||
|
||
文件将被下载到本地缓存文件夹。更多详细信息请参阅此 [指南](https://huggingface.co/docs/huggingface_hub/en/guides/manage-cache). | ||
|
||
### 登录 | ||
|
||
Hugging Face Hub 使用令牌对应用进行身份验证(请参阅[文档](https://huggingface.co/docs/hub/security-tokens)). 要登录您的机器,请运行以下命令行: | ||
|
||
```bash | ||
huggingface-cli login | ||
# or using an environment variable | ||
huggingface-cli login --token $HUGGINGFACE_TOKEN | ||
``` | ||
|
||
### 创建一个存储库 | ||
|
||
要创建一个新存储库,请运行以下代码: | ||
|
||
```py | ||
from huggingface_hub import create_repo | ||
|
||
create_repo(repo_id="super-cool-model") | ||
``` | ||
|
||
### 上传文件 | ||
|
||
上传单个文件,请运行以下代码 | ||
|
||
```py | ||
from huggingface_hub import upload_file | ||
|
||
upload_file( | ||
path_or_fileobj="/home/lysandre/dummy-test/README.md", | ||
path_in_repo="README.md", | ||
repo_id="lysandre/test-model", | ||
) | ||
``` | ||
|
||
如果上传整个存储库,请运行以下代码: | ||
|
||
```py | ||
from huggingface_hub import upload_folder | ||
|
||
upload_folder( | ||
folder_path="/path/to/local/space", | ||
repo_id="username/my-cool-space", | ||
repo_type="space", | ||
) | ||
``` | ||
|
||
有关详细信息,请查看 [上传指南](https://huggingface.co/docs/huggingface_hub/en/guides/upload). | ||
|
||
## 集成到 Hub 中 | ||
|
||
我们正在与一些出色的开源机器学习库合作,提供免费的模型托管和版本控制。您可以在 [这里](https://huggingface.co/docs/hub/libraries)找到现有的集成 | ||
|
||
优势包括: | ||
|
||
- 为库及其用户提供免费的模型或数据集托管 | ||
- 内置文件版本控制,即使对于非常大的文件也能实现,这得益于基于 Git 的方法 | ||
- 为所有公开可用的模型提供托管的推断 API | ||
- 在网页端可在线体验所有公开的模型 | ||
- 任何人都可以上传新模型到您的库,他们只需为模型添加相应的标签,以便让其被发现 | ||
- 快速下载!我们使用 Cloudfront(CDN)进行地理复制下载,因此无论在全球任何地方,下载速度都非常快。 | ||
- 使用统计和更多功能即将推出 | ||
|
||
如果您想要集成您的库,请随时打开一个问题来开始讨论。我们编写了一份逐步指南,以❤️的方式展示如何进行这种集成。 | ||
|
||
## 欢迎各种贡献(功能请求、错误等) 💙💚💛💜🧡❤️ | ||
|
||
欢迎每个人来进行贡献,我们重视每个人的贡献。编写代码并非唯一的帮助社区的方式。回答问题、帮助他人、积极互动并改善文档对社区来说都是极其有价值的。为此我们编写了一份 [贡献指南](https://github.com/huggingface/huggingface_hub/blob/main/CONTRIBUTING.md) 以进行总结,即如何开始为这个存储库做贡献 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
- title: "Starten" | ||
sections: | ||
- local: index | ||
title: 索引 | ||
- local: quick-start | ||
title: 快速入门指南 | ||
- local: installation | ||
title: 安装 | ||
- title: "guides" | ||
sections: | ||
- local: guides/repository | ||
title: 储存库 | ||
- title: "concepts" | ||
sections: | ||
- local: concepts/git_vs_http | ||
title: Git vs HTTP 范式 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<!--⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be | ||
rendered properly in your Markdown viewer. | ||
--> | ||
|
||
# Git 与 HTTP 范式 | ||
|
||
`huggingface_hub`库是用于与Hugging Face Hub进行交互的库,Hugging Face Hub是一组基于Git的存储库(模型、数据集或Spaces)。使用 `huggingface_hub`有两种主要方式来访问Hub。 | ||
|
||
第一种方法,即所谓的“基于git”的方法,由[`Repository`]类驱动。这种方法使用了一个包装器,它在 `git`命令的基础上增加了专门与Hub交互的额外函数。第二种选择,称为“基于HTTP”的方法,涉及使用[`HfApi`]客户端进行HTTP请求。让我们来看一看每种方法的优缺点。 | ||
|
||
## 存储库:基于历史的 Git 方法 | ||
|
||
最初,`huggingface_hub`主要围绕 [`Repository`] 类构建。它为常见的 `git` 命令(如 `"git add"`、`"git commit"`、`"git push"`、`"git tag"`、`"git checkout"` 等)提供了 Python 包装器 | ||
|
||
该库还可以帮助设置凭据和跟踪大型文件,这些文件通常在机器学习存储库中使用。此外,该库允许您在后台执行其方法,使其在训练期间上传数据很有用。 | ||
|
||
使用 [`Repository`] 的最大优点是它允许你在本地机器上维护整个存储库的本地副本。这也可能是一个缺点,因为它需要你不断更新和维护这个本地副本。这类似于传统软件开发中,每个开发人员都维护自己的本地副本,并在开发功能时推送更改。但是,在机器学习的上下文中,这可能并不总是必要的,因为用户可能只需要下载推理所需的权重,或将权重从一种格式转换为另一种格式,而无需克隆整个存储库。 | ||
|
||
## HfApi: 一个功能强大且方便的HTTP客户端 | ||
|
||
`HfApi` 被开发为本地 git 存储库的替代方案,因为本地 git 存储库在处理大型模型或数据集时可能会很麻烦。`HfApi` 提供与基于 git 的方法相同的功能,例如下载和推送文件以及创建分支和标签,但无需本地文件夹来保持同步。 | ||
|
||
`HfApi`除了提供 `git` 已经提供的功能外,还提供其他功能,例如: | ||
|
||
* 管理存储库 | ||
* 使用缓存下载文件以进行有效的重复使用 | ||
* 在 Hub 中搜索存储库和元数据 | ||
* 访问社区功能,如讨论、PR和评论 | ||
* 配置Spaces | ||
|
||
## 我应该使用什么?以及何时使用? | ||
|
||
总的来说,在大多数情况下,`HTTP 方法`是使用 huggingface_hub 的推荐方法。但是,在以下几种情况下,维护本地 git 克隆(使用 `Repository`)可能更有益: | ||
|
||
如果您在本地机器上训练模型,使用传统的 git 工作流程并定期推送更新可能更有效。`Repository` 被优化为此类情况,因为它能够在后台运行。 | ||
如果您需要手动编辑大型文件,`git `是最佳选择,因为它只会将文件的差异发送到服务器。使用 `HfAPI` 客户端,每次编辑都会上传整个文件。请记住,大多数大型文件是二进制文件,因此无法从 git 差异中受益。 | ||
|
||
并非所有 git 命令都通过 [`HfApi`] 提供。有些可能永远不会被实现,但我们一直在努力改进并缩小差距。如果您没有看到您的用例被覆盖。 | ||
|
||
请在[Github](https://github.com/huggingface/huggingface_hub)打开一个 issue!我们欢迎反馈,以帮助我们与我们的用户一起构建 🤗 生态系统。 |
Oops, something went wrong.