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 2aed933 + 7d9fd84 commit 80eb463
Show file tree
Hide file tree
Showing 47 changed files with 274 additions and 273 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/_toctree.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
title: 使用 Trainer API 或者 Keras 微调一个模型
local_fw: { pt: chapter3/3, tf: chapter3/3_tf }
- local: chapter3/4
title: 一个完成的训练过程
title: 一个完整的训练过程
- local: chapter3/5
title: 微调,章节回顾!
- local: chapter3/6
Expand Down
8 changes: 4 additions & 4 deletions chapters/zh-CN/chapter0/1.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 课程简介 [[课程简介]]

欢迎来到拥抱脸课程!本介绍将指导您设置工作环境。如果您刚开始学习本课程,我们建议您先阅读[第一章](/course/chapter1), 然后再回来设置您的环境,以便您可以自己尝试运行代码。
欢迎来到Hugging Face课程!本介绍将指导您设置工作环境。如果您刚开始学习本课程,我们建议您先阅读[第一章](/course/chapter1), 然后再回来设置您的环境,以便您可以自己尝试运行代码。

我们将在本课程中使用的所有库都以 Python 包的形式提供,因此在这里我们将向您展示如何设置 Python 环境并安装您需要的特定库。

Expand Down Expand Up @@ -50,9 +50,9 @@ import transformers

如果您更喜欢使用 Python 虚拟环境,那么第一步是在您的系统上安装 Python。我们建议您按照[这个教程](https://realpython.com/installing-python/)进行配置。

安装 Python 后,您应该能够在终端中运行 Python 命令。您可以先运行以下命令来检验爱装是否正确,然后再继续下一步:**python --version**。这应该会打印出您系统上现在可用的 Python 版本。
安装 Python 后,您应该能够在终端中运行 Python 命令。您可以先运行以下命令来检验爱装是否正确,然后再继续下一步:`python --version`。这应该会打印出您系统上现在可用的 Python 版本。

在终端中运行 Python 命令(例如 **python --version**)时,您应该将运行命令的这个Python视为系统上的“默认”Python。我们建议保持这个默认的Python安装程序没有任何包,当运行某个程序的时候就为那个程序创建一个单独的运行环境 - 这样,每个应用程序都可以有自己的依赖项和包,您无需担心与其他应用程序潜在的兼容性问题。
在终端中运行 Python 命令(例如 `python --version`)时,您应该将运行命令的这个Python视为系统上的“默认”Python。我们建议保持这个默认的Python安装程序没有任何包,当运行某个程序的时候就为那个程序创建一个单独的运行环境 - 这样,每个应用程序都可以有自己的依赖项和包,您无需担心与其他应用程序潜在的兼容性问题。

在 Python 中,这是通过 [*虚拟环境*](https://docs.python.org/3/tutorial/venv.html)实现的,虚拟环境会创建许多目录树,每个目录树都包含具有特定 Python 版本的 Python 安装以及应用程序所需的所有包。可以使用许多不同的工具来创建这样的虚拟环境,但在此我们将使用官方 Python 包:[`venv`](https://docs.python.org/3/library/venv.html#module-venv).

Expand Down 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
4 changes: 2 additions & 2 deletions chapters/zh-CN/chapter1/1.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@
- **如果我有问题,我可以在哪里提问?**
如果您对课程的任何部分有疑问,只需单击页面顶部的“*提问*”横幅,系统就会自动重定向到 [Hugging Face 论坛](https:// discuss.huggingface.co/):

<img src="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter1/forum-button.png" alt="拥抱脸论坛链接" width=" 75%">
<img src="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter1/forum-button.png" alt="Hugging Face论坛链接" width=" 75%">

请注意,如果您想在完成课程后进行更多练习,论坛上还提供了[项目灵感](https://discuss.huggingface.co/c/course/course-event/25) 列表。

- **我在哪里可以获得课程的代码?**
对于每个部分,单击页面顶部的横幅可以在 Google Colab 或 Amazon SageMaker Studio Lab 中运行代码:

<img src="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter1/notebook-buttons.png" alt="拥抱脸课程笔记本链接" width= "75%">
<img src="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter1/notebook-buttons.png" alt="Hugging Face课程笔记本链接" width= "75%">

包含课程所有代码的 Jupyter 笔记本托管在 [`huggingface/notebooks`](https://github.com/huggingface/notebooks) 仓库中。 如果您希望在本地生成它们,请查看 GitHub 上 [`course`](https://github.com/huggingface/course#-jupyter-notebooks) 仓库中的说明。

Expand Down
33 changes: 17 additions & 16 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 All @@ -97,7 +98,7 @@ classifier(

此pipeline称为zero-shot,因为您不需要对数据上的模型进行微调即可使用它。它可以直接返回您想要的任何标签列表的概率分数!
<Tip>
✏️**快来试试吧!**使用您自己的序列和标签,看看模型的行为。
✏️**快来试试吧!** 使用您自己的序列和标签,看看模型的行为。
</Tip>

## 文本生成 [[文本生成]]
Expand All @@ -119,7 +120,7 @@ generator("In this course, we will teach you how to")
您可以使用参数 **num_return_sequences** 控制生成多少个不同的序列,并使用参数 **max_length** 控制输出文本的总长度。

<Tip>
✏️**快来试试吧!**使用 num_return_sequences 和 max_length 参数生成两个句子,每个句子 15 个单词。
✏️**快来试试吧!** 使用 num_return_sequences 和 max_length 参数生成两个句子,每个句子 15 个单词。
</Tip>

## 在pipeline中使用 Hub 中的其他模型 [[在pipeline中使用 Hub 中的其他模型]]
Expand Down Expand Up @@ -148,7 +149,7 @@ generator(

通过单击选择模型后,您会看到有一个小组件,可让您直接在线试用。通过这种方式,您可以在下载之前快速测试模型的功能。
<Tip>
✏️**快来试试吧!**使用标签筛选查找另一种语言的文本生成模型。使用小组件测试并在pipeline中使用它!
✏️**快来试试吧!** 使用标签筛选查找另一种语言的文本生成模型。使用小组件测试并在pipeline中使用它!
</Tip>

## 推理 API [[推理 API]]
Expand Down Expand Up @@ -177,7 +178,7 @@ unmasker("This course will teach you all about <mask> models.", top_k=2)
**top_k** 参数控制要显示的结果有多少种。请注意,这里模型填充了特殊的< **mask** >词,它通常被称为掩码标记。其他掩码填充模型可能有不同的掩码标记,因此在探索其他模型时要验证正确的掩码字是什么。检查它的一种方法是查看小组件中使用的掩码。

<Tip>
✏️**快来试试吧!**在 Hub 上搜索基于 bert 的模型并在推理 API 小组件中找到它的掩码。这个模型对上面pipeline示例中的句子预测了什么?
✏️**快来试试吧!** 在 Hub 上搜索基于 bert 的模型并在推理 API 小组件中找到它的掩码。这个模型对上面pipeline示例中的句子预测了什么?
</Tip>

## 命名实体识别 [[命名实体识别]]
Expand All @@ -199,7 +200,7 @@ ner("My name is Sylvain and I work at Hugging Face in Brooklyn.")
我们在pipeline创建函数中传递选项 **grouped_entities=True** 以告诉pipeline将对应于同一实体的句子部分重新组合在一起:这里模型正确地将“Hugging”和“Face”分组为一个组织,即使名称由多个词组成。事实上,正如我们即将在下一章看到的,预处理甚至会将一些单词分成更小的部分。例如,**Sylvain** 分割为了四部分:**S、##yl、##va****##in**。在后处理步骤中,pipeline成功地重新组合了这些部分。

<Tip>
✏️**快来试试吧!**在模型中心(hub)搜索能够用英语进行词性标注(通常缩写为 POS)的模型。这个模型对上面例子中的句子预测了什么?
✏️**快来试试吧!** 在模型中心(hub)搜索能够用英语进行词性标注(通常缩写为 POS)的模型。这个模型对上面例子中的句子预测了什么?
</Tip>

## 问答系统 [[问答系统]]
Expand Down Expand Up @@ -280,7 +281,7 @@ translator("Ce cours est produit par Hugging Face.")

<Tip>

✏️**快来试试吧!**搜索其他语言的翻译模型,尝试将前一句翻译成几种不同的语言。
✏️**快来试试吧!** 搜索其他语言的翻译模型,尝试将前一句翻译成几种不同的语言。

</Tip>

Expand Down
Loading

0 comments on commit 80eb463

Please sign in to comment.