Skip to content

Commit

Permalink
Merge pull request #705 from jks-liu/pr-zh
Browse files Browse the repository at this point in the history
[zh-CN/TW] 3 improvements
  • Loading branch information
xianbaoqian authored May 21, 2024
2 parents d7e3812 + 446da36 commit a51913e
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 40 deletions.
21 changes: 11 additions & 10 deletions chapters/zh-CN/chapter1/3.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
## Transformer被应用于各个方面! [[Transformer被应用于各个方面!]]
Transformer 模型用于解决各种 NLP 任务,就像上一节中提到的那样。以下是一些使用 Hugging Face 和 Transformer 模型的公司和组织,他们也通过分享他们的模型回馈社区:

![使用 Hugging Face 的公司](https://huggingface.co/course/static/chapter1/companies.PNG)
<img src="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter1/companies.PNG" alt="使用 Hugging Face 的公司" width="100%">

[🤗 Transformers 库](https://github.com/huggingface/transformers)提供了创建和使用这些共享模型的功能。[模型中心(hub)](https://huggingface.co/models)包含数千个任何人都可以下载和使用的预训练模型。您还可以将自己的模型上传到 Hub!

<Tip>
Expand Down Expand Up @@ -65,15 +66,15 @@ classifier(

目前[可用的一些pipeline](https://huggingface.co/transformers/main_classes/pipelines.html)是:

* **特征提取**(获取文本的向量表示)
* **填充空缺**
* **ner**(命名实体识别)
* **问答**
* **情感分析**
* **文本摘要**
* **文本生成**
* **翻译**
* **零样本分类**
* `feature-extraction`(获取文本的向量表示)
* `fill-mask`
* `ner`(命名实体识别)
* `question-answering`
* `sentiment-analysis`
* `summarization`
* `text-generation`
* `translation`
* `zero-shot-classification`

让我们来看看其中的一些吧!

Expand Down
2 changes: 1 addition & 1 deletion chapters/zh-CN/chapter2/1.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
然后我们来看看标记器API,它是pipeline()函数的另一个主要组件。它是作用分词器负责第一个和最后一个处理步骤,处理从文本到神经网络数字输入的转换,以及在需要时转换回文本。最后,我们将向您展示如何处理在一个准备好的批处理中通过一个模型发送多个句子的问题,然后详细介绍pipeline()函数。

<Tip>
⚠️ 为了从模型集线器和🤗Transformers的所有可用功能中获益,我们建议<a href="https://huggingface.co/join">creating an account</a>.
⚠️ 为了从模型中心和🤗Transformers的所有可用功能中获益,我们建议<a href="https://huggingface.co/join">creating an account</a>.
</Tip>
4 changes: 2 additions & 2 deletions chapters/zh-CN/chapter3/6.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

Test what you learned in this chapter!

### 1.“情绪”数据集包含标记有情绪的 Twitter 消息。在[ Hub ]( https://huggingface.co/datasets 集线器)中搜索它,然后读取数据集卡。哪一个不是它的基本情感?
### 1.“情绪”数据集包含标记有情绪的 Twitter 消息。在[模型中心](https://huggingface.co/datasets)中搜索它,然后读取数据集卡。哪一个不是它的基本情感?
<Question
choices={[
{
Expand All @@ -34,7 +34,7 @@ Test what you learned in this chapter!
]}
/>

### 2.在[ Hub ]( https://huggingface.co/datasets 集线器)中搜索‘ ar _ sarcasm’数据集,它支持哪个任务?
### 2.在[模型中心](https://huggingface.co/datasets)中搜索‘ ar _ sarcasm’数据集,它支持哪个任务?
<Question
choices={[
{
Expand Down
12 changes: 6 additions & 6 deletions chapters/zh-CN/chapter4/3.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

{/if}

将文件上传到集线器的最简单方法是利用 **push_to_hub** API 接口。
将文件上传到模型中心的最简单方法是利用 **push_to_hub** API 接口。

在继续之前,您需要生成一个身份验证令牌,以便 **huggingface_hub** API 知道您是谁以及您对哪些名称空间具有写入权限。确保你在一个环境中 **transformers** 已安装(见[Setup](/course/chapter0))。如果您在笔记本中,可以使用以下功能登录:

Expand Down Expand Up @@ -81,7 +81,7 @@ training_args = TrainingArguments(
)
```

你声明 **trainer.train()** 的时候, 这 **Trainer** 然后每次将您的模型保存到您的命名空间中的存储库中时(这里是每个时代),它将上传到集线器。该存储库将命名为您选择的输出目录(此处 **bert-finetuned-mrpc** ) 但您可以选择不同的名称 **hub_model_id = a_different_name**
你声明 **trainer.train()** 的时候, 这 **Trainer** 然后每次将您的模型保存到您的命名空间中的存储库中时(这里是每个时代),它将上传到模型中心。该存储库将命名为您选择的输出目录(此处 **bert-finetuned-mrpc** ) 但您可以选择不同的名称 **hub_model_id = a_different_name**

要将您的模型上传到您所属的组织,只需将其传递给 **hub_model_id = my_organization/my_repo_name**

Expand Down Expand Up @@ -193,7 +193,7 @@ tokenizer.push_to_hub("dummy-model", organization="huggingface", use_auth_token=
## 使用 huggingface_hub python库 [[使用 huggingface_hub python库]]

**huggingface_hub** Python 库是一个包,它为模型和数据集中心提供了一组工具。它为常见任务提供了简单的方法和类,例如
获取有关集线器上存储库的信息并对其进行管理。它提供了在 git 之上工作的简单 API 来管理这些存储库的内容并集成 Hub
获取有关模型中心上存储库的信息并对其进行管理。它提供了在 git 之上工作的简单 API 来管理这些存储库的内容并集成 Hub
在您的项目和库中。

类似于使用 **push_to_hub** API,这将要求您将 API 令牌保存在缓存中。为此,您需要使用 **login** 来自 CLI 的命令,如上一节所述(同样,确保在这些命令前面加上 **!** 字符(如果在 Google Colab 中运行):
Expand Down Expand Up @@ -229,7 +229,7 @@ from huggingface_hub import (

此外,它还提供了非常强大的 **Repository** 用于管理本地存储库的类。我们将在接下来的几节中探讨这些方法和该类,以了解如何利用它们。

**create_repo** 方法可用于在集线器上创建新存储库
**create_repo** 方法可用于在模型中心上创建新存储库


```py
Expand Down Expand Up @@ -348,7 +348,7 @@ repo.git_tag()

另外!我们建议您查看 **Repository** 可用文件[here](https://github.com/huggingface/huggingface_hub/tree/main/src/huggingface_hub#advanced-programmatic-repository-management)有关所有可用方法的概述。

目前,我们有一个模型和一个标记器,我们希望将其推送到集线器。我们已经成功克隆了存储库,因此我们可以将文件保存在该存储库中。
目前,我们有一个模型和一个标记器,我们希望将其推送到模型中心。我们已经成功克隆了存储库,因此我们可以将文件保存在该存储库中。

我们首先通过拉取最新更改来确保我们的本地克隆是最新的:

Expand All @@ -363,7 +363,7 @@ model.save_pretrained("<path_to_dummy_folder>")
tokenizer.save_pretrained("<path_to_dummy_folder>")
```

**path_to_dummy_folder** 现在包含所有模型和标记器文件。我们遵循通常的 git 工作流程,将文件添加到暂存区,提交它们并将它们推送到集线器
**path_to_dummy_folder** 现在包含所有模型和标记器文件。我们遵循通常的 git 工作流程,将文件添加到暂存区,提交它们并将它们推送到模型中心

```py
repo.git_add()
Expand Down
2 changes: 1 addition & 1 deletion chapters/zh-CN/chapter7/5.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ trainer.push_to_hub(commit_message="Training complete", tags="summarization")
'https://huggingface.co/huggingface-course/mt5-finetuned-amazon-en-es/commit/aa0536b829b28e73e1e4b94b8a5aacec420d40e0'
```

这会将检查点和配置文件保存到 **output_dir** , 在将所有文件上传到集线器之前。通过指定 **tags** 参数,我们还确保集线器上的小部件将是一个用于汇总管道的小部件,而不是与 mT5 架构关联的默认文本生成小部件(有关模型标签的更多信息,请参阅[🤗 Hub 文档](https://huggingface.co/docs/hub/main#how-is-a-models-type-of-inference-api-and-widget-determined))。输出来自 **trainer.push_to_hub()** 是 Git 提交哈希的 URL,因此您可以轻松查看对模型存储库所做的更改!
这会将检查点和配置文件保存到 **output_dir** , 在将所有文件上传到模型中心之前。通过指定 **tags** 参数,我们还确保模型中心上的小部件将是一个用于汇总管道的小部件,而不是与 mT5 架构关联的默认文本生成小部件(有关模型标签的更多信息,请参阅[🤗 Hub 文档](https://huggingface.co/docs/hub/main#how-is-a-models-type-of-inference-api-and-widget-determined))。输出来自 **trainer.push_to_hub()** 是 Git 提交哈希的 URL,因此您可以轻松查看对模型存储库所做的更改!

在结束本节之前,让我们看一下如何使用 🤗 Accelerate 提供的底层API对 mT5 进行微调。

Expand Down
21 changes: 11 additions & 10 deletions chapters/zh-TW/chapter1/3.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
## Transformer被應用於各個方面!
Transformer 模型用於解決各種 NLP 任務,就像上一節中提到的那樣。以下是一些使用 Hugging Face 和 Transformer 模型的公司和組織,他們也通過分享他們的模型回饋社區:

![使用 Hugging Face 的公司](https://huggingface.co/course/static/chapter1/companies.PNG)
<img src="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter1/companies.PNG" alt="使用 Hugging Face 的公司" width="100%">

[🤗 Transformers 庫](https://github.com/huggingface/transformers)提供了創建和使用這些共享模型的功能。[模型中心(hub)](https://huggingface.co/models)包含數千個任何人都可以下載和使用的預訓練模型。您還可以將自己的模型上傳到 Hub!

<Tip>
Expand Down Expand Up @@ -65,15 +66,15 @@ classifier(

目前[可用的一些pipeline](https://huggingface.co/transformers/main_classes/pipelines.html)是:

* **特徵提取**(獲取文本的向量表示)
* **填充空缺**
* **ner**(命名實體識別)
* **問答**
* **情感分析**
* **文本摘要**
* **文本生成**
* **翻譯**
* **零樣本分類**
* `feature-extraction`(獲取文本的向量表示)
* `fill-mask`
* `ner`(命名實體識別)
* `question-answering`
* `sentiment-analysis`
* `summarization`
* `text-generation`
* `translation`
* `zero-shot-classification`

讓我們來看看其中的一些吧!

Expand Down
2 changes: 1 addition & 1 deletion chapters/zh-TW/chapter2/1.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
然後我們來看看標記器API,它是 pipeline() 函數的另一個主要組件。它是作用分詞器負責第一個和最後一個處理步驟,處理從文本到神經網絡數字輸入的轉換,以及在需要時轉換回文本。最後,我們將向您展示如何處理在一個準備好的批處理中通過一個模型發送多個句子的問題,然後詳細介紹 pipeline() 函數。

<Tip>
⚠️ 為了從模型集線器和 🤗Transformers 的所有可用功能中獲益,我們建議<a href="https://huggingface.co/join">creating an account</a>.
⚠️ 為了從模型中心和 🤗Transformers 的所有可用功能中獲益,我們建議<a href="https://huggingface.co/join">creating an account</a>.
</Tip>
4 changes: 2 additions & 2 deletions chapters/zh-TW/chapter3/6.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

Test what you learned in this chapter!

### 1.「情緒」數據集包含標記有情緒的 Twitter 消息。在[ Hub ]( https://huggingface.co/datasets 集線器)中搜索它,然後讀取數據集卡。哪一個不是它的基本情感?
### 1.「情緒」數據集包含標記有情緒的 Twitter 消息。在[模型中心](https://huggingface.co/datasets)中搜索它,然後讀取數據集卡。哪一個不是它的基本情感?
<Question
choices={[
{
Expand All @@ -34,7 +34,7 @@ Test what you learned in this chapter!
]}
/>

### 2.在[ Hub ]( https://huggingface.co/datasets 集線器)中搜索‘ ar _ sarcasm’數據集,它支持哪個任務?
### 2.在[模型中心](https://huggingface.co/datasets)中搜索‘ ar _ sarcasm’數據集,它支持哪個任務?
<Question
choices={[
{
Expand Down
12 changes: 6 additions & 6 deletions chapters/zh-TW/chapter4/3.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

{/if}

將文件上傳到集線器的最簡單方法是利用 **push_to_hub** API 接口。
將文件上傳到模型中心的最簡單方法是利用 **push_to_hub** API 接口。

在繼續之前,您需要生成一個身份驗證令牌,以便 **huggingface_hub** API 知道您是誰以及您對哪些名稱空間具有寫入權限。確保你在一個環境中 **transformers** 已安裝(見[Setup](/course/chapter0))。如果您在筆記本中,可以使用以下功能登錄:

Expand Down Expand Up @@ -81,7 +81,7 @@ training_args = TrainingArguments(
)
```

你聲明 **trainer.train()** 的時候, 這 **Trainer** 然後每次將您的模型保存到您的命名空間中的存儲庫中時(這裡是每個時代),它將上傳到集線器。該存儲庫將命名為您選擇的輸出目錄(此處 **bert-finetuned-mrpc** ) 但您可以選擇不同的名稱 **hub_model_id = a_different_name**
你聲明 **trainer.train()** 的時候, 這 **Trainer** 然後每次將您的模型保存到您的命名空間中的存儲庫中時(這裡是每個時代),它將上傳到模型中心。該存儲庫將命名為您選擇的輸出目錄(此處 **bert-finetuned-mrpc** ) 但您可以選擇不同的名稱 **hub_model_id = a_different_name**

要將您的模型上傳到您所屬的組織,只需將其傳遞給 **hub_model_id = my_organization/my_repo_name**

Expand Down Expand Up @@ -193,7 +193,7 @@ tokenizer.push_to_hub("dummy-model", organization="huggingface", use_auth_token=
## 使用 huggingface_hub python庫

**huggingface_hub** Python 庫是一個包,它為模型和數據集中心提供了一組工具。它為常見任務提供了簡單的方法和類,例如
獲取有關集線器上存儲庫的信息並對其進行管理。它提供了在 git 之上工作的簡單 API 來管理這些存儲庫的內容並集成 Hub
獲取有關模型中心上存儲庫的信息並對其進行管理。它提供了在 git 之上工作的簡單 API 來管理這些存儲庫的內容並集成 Hub
在您的項目和庫中。

類似於使用 **push_to_hub** API,這將要求您將 API 令牌保存在緩存中。為此,您需要使用 **login** 來自 CLI 的命令,如上一節所述(同樣,確保在這些命令前面加上 **!** 字符(如果在 Google Colab 中運行):
Expand Down Expand Up @@ -229,7 +229,7 @@ from huggingface_hub import (

此外,它還提供了非常強大的 **Repository** 用於管理本地存儲庫的類。我們將在接下來的幾節中探討這些方法和該類,以瞭解如何利用它們。

**create_repo** 方法可用於在集線器上創建新存儲庫
**create_repo** 方法可用於在模型中心上創建新存儲庫


```py
Expand Down Expand Up @@ -348,7 +348,7 @@ repo.git_tag()

另外!我們建議您查看 **Repository** 可用文件[here](https://github.com/huggingface/huggingface_hub/tree/main/src/huggingface_hub#advanced-programmatic-repository-management)有關所有可用方法的概述。

目前,我們有一個模型和一個標記器,我們希望將其推送到集線器。我們已經成功克隆了存儲庫,因此我們可以將文件保存在該存儲庫中。
目前,我們有一個模型和一個標記器,我們希望將其推送到模型中心。我們已經成功克隆了存儲庫,因此我們可以將文件保存在該存儲庫中。

我們首先通過拉取最新更改來確保我們的本地克隆是最新的:

Expand All @@ -363,7 +363,7 @@ model.save_pretrained("<path_to_dummy_folder>")
tokenizer.save_pretrained("<path_to_dummy_folder>")
```

**path_to_dummy_folder** 現在包含所有模型和標記器文件。我們遵循通常的 git 工作流程,將文件添加到暫存區,提交它們並將它們推送到集線器
**path_to_dummy_folder** 現在包含所有模型和標記器文件。我們遵循通常的 git 工作流程,將文件添加到暫存區,提交它們並將它們推送到模型中心

```py
repo.git_add()
Expand Down
2 changes: 1 addition & 1 deletion chapters/zh-TW/chapter7/5.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ trainer.push_to_hub(commit_message="Training complete", tags="summarization")
'https://huggingface.co/huggingface-course/mt5-finetuned-amazon-en-es/commit/aa0536b829b28e73e1e4b94b8a5aacec420d40e0'
```

這會將檢查點和配置文件保存到 **output_dir** , 在將所有文件上傳到集線器之前。通過指定 **tags** 參數,我們還確保集線器上的小部件將是一個用於彙總管道的小部件,而不是與 mT5 架構關聯的默認文本生成小部件(有關模型標籤的更多信息,請參閱[🤗 Hub 文檔](https://huggingface.co/docs/hub/main#how-is-a-models-type-of-inference-api-and-widget-determined))。輸出來自 **trainer.push_to_hub()** 是 Git 提交哈希的 URL,因此您可以輕鬆查看對模型存儲庫所做的更改!
這會將檢查點和配置文件保存到 **output_dir** , 在將所有文件上傳到模型中心之前。通過指定 **tags** 參數,我們還確保模型中心上的小部件將是一個用於彙總管道的小部件,而不是與 mT5 架構關聯的默認文本生成小部件(有關模型標籤的更多信息,請參閱[🤗 Hub 文檔](https://huggingface.co/docs/hub/main#how-is-a-models-type-of-inference-api-and-widget-determined))。輸出來自 **trainer.push_to_hub()** 是 Git 提交哈希的 URL,因此您可以輕鬆查看對模型存儲庫所做的更改!

在結束本節之前,讓我們看一下如何使用 🤗 Accelerate 提供的底層API對 mT5 進行微調。

Expand Down

0 comments on commit a51913e

Please sign in to comment.