Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
xianbaoqian authored May 21, 2024
2 parents b79da5d + a51913e commit c8572a9
Show file tree
Hide file tree
Showing 36 changed files with 73 additions and 72 deletions.
2 changes: 1 addition & 1 deletion chapters/ar/chapter0/1.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ ls -a
source .env/bin/activate
# Deactivate the virtual environment
source .env/bin/deactivate
deactivate
```

<div dir="rtl" style="direction:rtl;text-align:right;">
Expand Down
2 changes: 1 addition & 1 deletion chapters/bn/chapter0/1.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ ls -a
source .env/bin/activate
# virtual environment টি deactivate করার কমান্ড
source .env/bin/deactivate
deactivate
```

`which python` কমান্ড চালিয়ে নিশ্চিত করতে পারেন যে virtual environment টি activate হয়েছে কিনা।
Expand Down
2 changes: 1 addition & 1 deletion chapters/de/chapter0/1.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Mit den Skripten "activate" und "deactivate" kannst du in deine virtuelle Umgebu
source .env/bin/activate
# Deaktivieren der virtuellen Umgebung
source .env/bin/deactivate
deactivate
```

Du kannst dich vergewissern, dass die Umgebung aktiviert ist, indem du den Befehl `which python` ausführst: Wenn er auf die virtuelle Umgebung verweist, dann hast du sie erfolgreich aktiviert!
Expand Down
2 changes: 1 addition & 1 deletion chapters/en/chapter0/1.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ You can jump in and out of your virtual environment with the `activate` and `dea
source .env/bin/activate
# Deactivate the virtual environment
source .env/bin/deactivate
deactivate
```

You can make sure that the environment is activated by running the `which python` command: if it points to the virtual environment, then you have successfully activated it!
Expand Down
10 changes: 5 additions & 5 deletions chapters/en/chapter7/6.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -383,13 +383,13 @@ Now we can use the `prepare_tf_dataset()` method to convert our datasets to Tens

```python
tf_train_dataset = model.prepare_tf_dataset(
tokenized_dataset["train"],
tokenized_datasets["train"],
collate_fn=data_collator,
shuffle=True,
batch_size=32,
)
tf_eval_dataset = model.prepare_tf_dataset(
tokenized_dataset["valid"],
tokenized_datasets["valid"],
collate_fn=data_collator,
shuffle=False,
batch_size=32,
Expand Down Expand Up @@ -726,9 +726,9 @@ Let's start with the dataloaders. We only need to set the dataset's format to `"
```py
from torch.utils.data.dataloader import DataLoader

tokenized_dataset.set_format("torch")
train_dataloader = DataLoader(tokenized_dataset["train"], batch_size=32, shuffle=True)
eval_dataloader = DataLoader(tokenized_dataset["valid"], batch_size=32)
tokenized_datasets.set_format("torch")
train_dataloader = DataLoader(tokenized_datasets["train"], batch_size=32, shuffle=True)
eval_dataloader = DataLoader(tokenized_datasets["valid"], batch_size=32)
```

Next, we group the parameters so that the optimizer knows which ones will get an additional weight decay. Usually, all bias and LayerNorm weights terms are exempt from this; here's how we can do this:
Expand Down
2 changes: 1 addition & 1 deletion chapters/es/chapter0/1.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Puedes entrar y salir de tu entorno virtual con los scripts `activate` y `deacti
source .env/bin/activate
# Desactiva el entorno virtual
source .env/bin/deactivate
deactivate
```

Puedes asegurarte de que el entorno está activado ejecutando el comando `which python`: si apunta al entorno virtual, entonces lo has activado con éxito.
Expand Down
2 changes: 1 addition & 1 deletion chapters/fa/chapter0/1.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
source .env/bin/activate
\# Deactivate the virtual environment
source .env/bin/deactivate
deactivate
```

</div>
Expand Down
2 changes: 1 addition & 1 deletion chapters/fr/chapter0/1.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Vous pouvez entrer et sortir de votre environnement virtuel avec les scripts `ac
source .env/bin/activate
# Deactivate the virtual environment
source .env/bin/deactivate
deactivate
```

Vous pouvez vous assurer que l'environnement est activé en exécutant la commande `which python` : si elle pointe vers l'environnement virtuel, alors vous l'avez activé avec succès !
Expand Down
2 changes: 1 addition & 1 deletion chapters/gj/chapter0/1.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ ls -a
source .env/bin/activate
# Deactivate the virtual environment
source .env/bin/deactivate
deactivate
```

જો તમે verify કરવા માંગતા હોવ તો `which python` command run કરો. એ તમરા virtual environment ના ફોલ્ડર ને આઉટપુટ માં આપશે. આ એવું સાબિત કરે છે કે virtual environment સફળાપૂર્વક active છે.!
Expand Down
2 changes: 1 addition & 1 deletion chapters/he/chapter0/1.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ ls -a
source .env/bin/activate
# Deactivate the virtual environment
source .env/bin/deactivate
deactivate
```
</div>

Expand Down
2 changes: 1 addition & 1 deletion chapters/hi/chapter0/1.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ ls -a
source .env/bin/activate
# Deactivate the virtual environment
source .env/bin/deactivate
deactivate
```

आप यह सुनिश्चित कर सकते हैं कि `which python` आदेश चलाकर कौन सा पर्यावरण सक्रिय है: यदि यह आभासी वातावरण की ओर इशारा करता है, तो आपने इसे सफलतापूर्वक सक्रिय कर दिया है!
Expand Down
2 changes: 1 addition & 1 deletion chapters/id/chapter0/1.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Instruksi dibawah adalah instruksi untuk mengaktifkan dan menonaktifkan _virtual
source .env/bin/activate
# Menonaktifkan virtual environment
source .env/bin/deactivate
deactivate
```

Anda bisa memastikan bahwa anda menggunakan Python versi _virtual environment_ dengan mengeksekusi `which python` di terminal: jika balasan terminal adalah Python di dalam folder *.env*, maka _virtual environment_ anda sudah aktif!
Expand Down
2 changes: 1 addition & 1 deletion chapters/it/chapter0/1.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Puoi entrare e uscire dall'ambiente virtuale utilizzando gli script `activate` e
source .env/bin/activate
# Deactivate the virtual environment
source .env/bin/deactivate
deactivate
```

Assicurati che l'ambiente sia configurato correttamente eseguendo il comando `which python`: se come risposta ottieni l'ambiente virtuale, significa che l'hai attivato bene!
Expand Down
2 changes: 1 addition & 1 deletion chapters/ja/chapter0/1.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ ls -a
source .env/bin/activate
# Deactivate the virtual environment
source .env/bin/deactivate
deactivate
```

仮想環境が有効になっているかどうかは、`which python`というコマンドを実行することで確認することができます。もし以下のように仮想環境であることを示していれば、正常に有効化できています!
Expand Down
2 changes: 1 addition & 1 deletion chapters/ko/chapter0/1.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ ls -a
source .env/bin/activate
# Deactivate the virtual environment
source .env/bin/deactivate
deactivate
```

환경이 제대로 활성화 되었는지 `which python` 명령어를 실행하여 확인해 봅시다. 아래와 같이 가상 환경을 보여준다면 제대로 활성화가 것입니다!
Expand Down
2 changes: 1 addition & 1 deletion chapters/ko/chapter1/9.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
| --- | --- | --- |
| 인코더 | ALBERT, BERT, DistilBERT, ELECTRA, RoBERTa | 문장 분류, 개체명 인식, 추출 질의 응답 |
| 디코더 | CTRL, GPT, GPT-2, Transformer XL | 텍스트 생성 |
| 인코더-디코더 | BART, T5, Marian, mBART | 오약, 번역, 생성 질의 응답 |
| 인코더-디코더 | BART, T5, Marian, mBART | 요약, 번역, 생성 질의 응답 |
2 changes: 1 addition & 1 deletion chapters/ko/chapter2/2.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ classifier(
<img class="hidden dark:block" src="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter2/full_nlp_pipeline-dark.svg" alt="The full NLP pipeline: tokenization of text, conversion to IDs, and inference through the Transformer model and the model head."/>
</div>

단게에 대해 빠르게 살펴보겠습니다.
단계에 대해 빠르게 살펴보겠습니다.

## 토크나이저를 이용한 전처리[[preprocessing-with-a-tokenizer]]

Expand Down
2 changes: 1 addition & 1 deletion chapters/pt/chapter0/1.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Você pode acessar e sair do seu ambiente virtual com os scripts `activate` e `d
source .env/bin/activate
# Deactivate the virtual environment
source .env/bin/deactivate
deactivate
```

Você pode ter certeza que seu ambiente virtual está ativado rodando o comando `which python`: se ele apontar para o ambiente virtual, então você conseguiu ativa-lo com sucesso!
Expand Down
2 changes: 1 addition & 1 deletion chapters/ru/chapter0/1.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ ls -a
source .env/bin/activate
# Деактивировать окружение
source .env/bin/deactivate
deactivate
```

Вы можете убедиться, что окружение активировано с помощью команды `which python`: если ее результат указывает на виртуальное окружение, значит, вы успешно активировали его!
Expand Down
2 changes: 1 addition & 1 deletion chapters/th/chapter0/1.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ ls -a
source .env/bin/activate
# Deactivate the virtual environment
source .env/bin/deactivate
deactivate
```

คุณสามารถตรวจสอบได้ว่า คุณอยู่ใน environment ใดได้ด้วยคำสั่ง `which python` ระบบจะแสดงผล environment ที่คุณกำลังใช้งานอยู่
Expand Down
2 changes: 1 addition & 1 deletion chapters/tr/chapter0/1.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ ls -a
source .env/bin/activate
# Deactivate the virtual environment
source .env/bin/deactivate
deactivate
```

`which python` komutunu kullanarak hangi Python kurulumunda olduğunuzu öğrenebilirsiniz: Eğer sanal ortamı gösteriyorsa sizi tebrik ederim başarıyla sanal ortam kurmuşsunuz demektir!
Expand Down
2 changes: 1 addition & 1 deletion chapters/vi/chapter0/1.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Bạn có thể vào và thoát ra khỏi môi trường ảo của mình bằng
source .env/bin/activate
# Huỷ kích hoạt môi trường ảo
source .env/bin/deactivate
deactivate
```

Bạn có thể đảm bảo rằng môi trường đã được kích hoạt bằng cách chạy lệnh `which python`: nếu nó trỏ đến môi trường ảo thì bạn đã kích hoạt nó thành công!
Expand Down
2 changes: 1 addition & 1 deletion chapters/zh-CN/chapter0/1.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ ls -a
source .env/bin/activate
# Deactivate the virtual environment
source .env/bin/deactivate
deactivate
```

您可以通过运行 `which python` 命令来检测虚拟环境是否被激活:如果它指向虚拟环境,那么您已经成功激活了它!
Expand Down
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 @@ -12,7 +12,7 @@
- **灵活**:所有模型的核心都是简单的PyTorch **nn.Module** 或者 TensorFlow **tf.kears.Model**类,可以像在其各自的机器学习 (ML) 框架中的任何其他模型一样方便地进行处理。
- **简单**:库中几乎没有任何抽象。 “All in one file”(所有代码在一个文件中)是一个核心概念:模型的前向传播完全定义在一个文件中,因此代码本身易于理解和修改

最后一个特性使🤗 Transformers与其他ML库截然不同。这些模型不是基于通过文件共享的模块构建的;相反,每一个模型都有自己的菜单。除了使模型更加容易接受和更容易理解,这还允许你轻松地在一个模型上实验,而且不影响其他模型。
最后一个特性使🤗 Transformers与其他ML库截然不同。这些模型不是基于通过文件共享的模块构建的;相反,每一个模型都有自己的网络结构(layers)。除了使模型更加容易接受和更容易理解,这还允许你轻松地在一个模型上实验,而且不影响其他模型。

本章将从一个端到端的示例开始,在该示例中,我们一起使用模型和*tokenizer*分词器来复制[Chapter 1](/course/chapter1)中引入的函数`pipeline()`. 接下来,我们将讨论模型API:我们将深入研究模型和配置类,并向您展示如何加载模型以及如何将数值输入处理为输出预测。

Expand Down
2 changes: 0 additions & 2 deletions chapters/zh-CN/chapter3/2.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,6 @@ samples = {k: v for k, v in samples.items() if k not in ["idx", "sentence1", "se

毫无疑问,我们得到了不同长度的样本,从32到67。动态填充意味着该批中的所有样本都应该填充到长度为67,这是该批中的最大长度。如果没有动态填充,所有的样本都必须填充到整个数据集中的最大长度,或者模型可以接受的最大长度。让我们再次检查**data_collator**是否正确地动态填充了这批样本:

```py:
```py
batch = data_collator(samples)
{k: v.shape for k, v in batch.items()}
Expand Down
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
2 changes: 1 addition & 1 deletion chapters/zh-TW/chapter0/1.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ ls -a
source .env/bin/activate
# Deactivate the virtual environment
source .env/bin/deactivate
deactivate
```
你可以執行 `which python` 指令來確認你的虛擬環境是否有被啟用:如果它指向虛擬環境的目錄,那表示你的虛擬環境已經啟用了!

Expand Down
Loading

0 comments on commit c8572a9

Please sign in to comment.