Skip to content

Commit

Permalink
Merge branch 'huggingface:main' into argilla-chapter
Browse files Browse the repository at this point in the history
  • Loading branch information
nataliaElv authored Nov 20, 2024
2 parents b91e806 + 5ce7a3d commit d32647b
Show file tree
Hide file tree
Showing 82 changed files with 3,680 additions and 3,499 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ jobs:
package: course
path_to_docs: course/chapters/
additional_args: --not_python_module
languages: ar bn de en es fa fr gj he hi id it ja ko pt ru th tr vi zh-CN zh-TW
languages: ar bn de en es fa fr gj he hi id it ja ko pt ru rum th tr vi zh-CN zh-TW
secrets:
hf_token: ${{ secrets.HF_DOC_BUILD_PUSH }}
2 changes: 1 addition & 1 deletion .github/workflows/build_pr_documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ jobs:
package: course
path_to_docs: course/chapters/
additional_args: --not_python_module
languages: ar bn de en es fa fr gj he hi id it ja ko pt ru th tr vi zh-CN zh-TW
languages: ar bn de en es fa fr gj he hi id it ja ko pt ru rum th tr vi zh-CN zh-TW
2 changes: 1 addition & 1 deletion chapters/en/chapter1/1.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Here is a brief overview of the course:

- Chapters 1 to 4 provide an introduction to the main concepts of the 🤗 Transformers library. By the end of this part of the course, you will be familiar with how Transformer models work and will know how to use a model from the [Hugging Face Hub](https://huggingface.co/models), fine-tune it on a dataset, and share your results on the Hub!
- Chapters 5 to 8 teach the basics of 🤗 Datasets and 🤗 Tokenizers before diving into classic NLP tasks. By the end of this part, you will be able to tackle the most common NLP problems by yourself.
- Chapters 9 to 12 go beyond NLP, and explore how Transformer models can be used to tackle tasks in speech processing and computer vision. Along the way, you'll learn how to build and share demos of your models, and optimize them for production environments. By the end of this part, you will be ready to apply 🤗 Transformers to (almost) any machine learning problem!
- Chapter 9 goes beyond NLP to cover how to build and share demos of your models on the 🤗 Hub. By the end of this part, you will be ready to showcase your 🤗 Transformers application to the world!

This course:

Expand Down
4 changes: 4 additions & 0 deletions chapters/rum/_toctree.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- title: 0. Configurare
sections:
- local: chapter0/1
title: Introducere
110 changes: 110 additions & 0 deletions chapters/rum/chapter0/1.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# Introducere[[introducere]]

Bun venit la cursul Hugging Face! Această introducere te va ghida în configurarea environment-ului de lucru. Dacă abia începi cursul, îți recomandăm să arunci o privire mai întâi asupra [Capitolului 1](/course/chapter1), apoi să te întorci și să îți configurezi environment-ul pentru a putea încerca singur codul.

Toate bibliotecile pe care le vom folosi în acest curs sunt disponibile ca Python packages, așa că aici îți vom arăta cum să configurezi Python environment-ul și să instalezi librăriile specifice de care ai nevoie.

Vom acoperi două moduri de a-ți configura environment-ul, folosind un notebook Colab sau un Python environment. Simte-te liber să alegi pe cel care ți se potrivește cel mai bine. Pentru începători, recomandăm să începi folosind un notebook Colab.

Reține că nu vom acoperi sistemul Windows. Dacă folosești Windows, îți recomandăm să urmezi pașii folosind un notebook Colab. Dacă folosești o distribuție Linux sau macOS, poți folosi oricare dintre abordările descrise aici.

Majoritatea cursului se bazează pe faptul că ai un cont Hugging Face. Îți recomandăm să creezi unul acum: [crează un cont](https://huggingface.co/join).

## Folosirea unui notebook Google Colab[[folosind-un-notebook-google-colab]]

Folosirea unui notebook Colab este cea mai simplă configurare posibilă; deschide un notebook în browserul tău și începe imediat să scrii cod!

Dacă nu ești familiarizat cu Colab, îți recomandăm să începi urmând [introducerea](https://colab.research.google.com/notebooks/intro.ipynb). Colab îți permite să folosești hardware accelerat, cum ar fi GPU-uri sau TPU-uri, și este gratuit pentru sarcini mai mici.

Odată ce ești confortabil să te descurci în Colab, creează un nou notebook și începe cu configurarea:

<div class="flex justify-center">
<img src="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter0/new_colab.png" alt="Un notebook Colab gol" width="80%"/>
</div>

Următorul pas este să instalezi librăriile pe care le vom folosi în acest curs. Vom folosi `pip` pentru instalare, care este managerul de packages pentru Python. În notebook-uri, poți rula comenzi de sistem începând comanda cu caracterul `!`, așa că poți instala librăria 🤗 Transformers astfel:

```
!pip install transformers
```

Te poți asigura că pachetul a fost instalat corect importându-l în cadrul mediului tău Python:

```
import transformers
```

<div class="flex justify-center">
<img src="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter0/install.gif" alt="O animație care arată rezultatul celor două comenzi de mai sus: instalare și importarea" width="80%"/>
</div>

Aceasta instalează o versiune foarte ușoară a 🤗 Transformers. În special, nu sunt instalate framework-uri specifice de machine learning (cum ar fi PyTorch sau TensorFlow). Deoarece vom folosi multe caracteristici diferite ale librăriei, îți recomandăm să instalezi versiunea pentru development, care vine cu toate dependențele necesare pentru cam orice caz de utilizare imaginabil:

```
!pip install transformers[sentencepiece]
```

Aceasta va dura puțin timp, dar apoi vei fi gata de drum pentru restul cursului!

## Folosirea unui virtual environment Python[[folosirea-unui-virtual-environment-python]]

Dacă preferi să folosești un mediu virtual Python, primul pas este să instalezi Python pe sistemul tău. Îți recomandăm să urmezi [această ghidare](https://realpython.com/installing-python/) pentru a începe.

Odată ce ai Python instalat, ar trebui să poți rula comenzi Python în terminalul tău. Poți începe rulând următoarea comandă pentru a te asigura că este instalat corect înainte de a trece la pașii următori: `python --version`. Aceasta ar trebui să afișeze versiunea Python disponibilă acum pe sistemul tău.

Când rulezi o comandă Python în terminalul tău, cum ar fi `python --version`, ar trebui să te gândești la programul care rulează comanda ta ca la Python-ul "principal" de pe sistemul tău. Îți recomandăm să păstrezi această instalare principală liberă de orice pachete și să o folosești pentru a crea environment-uri separate pentru fiecare aplicație pe care lucrezi — în acest fel, fiecare aplicație poate avea propriile sale dependențe și pachete, și nu va trebui să te preocupi de problemele de compatibilitate potențiale cu alte aplicații.

În Python, acest lucru se face prin [*virtual environments*](https://docs.python.org/3/tutorial/venv.html), care sunt directory trees autonomi ce conțin fiecare o instalare Python cu o anumită versiune Python împreună cu toate pachetele de care are nevoie aplicația. Crearea unui astfel de mediu virtual poate fi realizată cu mai multe instrumente diferite, dar vom folosi pachetul oficial Python pentru acest scop, denumit [`venv`](https://docs.python.org/3/library/venv.html#module-venv).

În primul rând, creează folder în care dorești ca aplicația ta să locuiască — de exemplu, ai putea dori să faci un nou folder numit *transformers-course* în rădăcina folderului tău personal:

```
mkdir ~/transformers-course
cd ~/transformers-course
```

Din interiorul acestui folder, creează un virtual environment folosind modulul Python `venv`:

```
python -m venv .env
```

Acum ar trebui să ai un folder numit *.env* în folderul tău altfel gol:

```
ls -a
```

```out
. .. .env
```

Poți să intri și să ieși din environment folosind comenzile `activate` și `deactivate`:

```
# Activează mediul virtual
source .env/bin/activate
# Dezactivează virtual environment-ul
deactivate
```

Te poți asigura că environment-ul este activat rulând comanda `which python`: dacă aceasta indică către virtual environment, atunci l-ai activat cu succes!

```
which python
```

```out
/home/<user>/transformers-course/.env/bin/python
```

### Instalarea dependențelor[[instalarea-dependențelor]]

La fel ca în secțiunea anterioară despre utilizarea instanțelor Google Colab, acum va trebui să instalezi pachetele necesare pentru a continua. Din nou, poți instala versiunea pentru development a 🤗 Transformers folosind managerul de pachete `pip`:

```
pip install "transformers[sentencepiece]"
```

Acum ești gata să începi!
50 changes: 25 additions & 25 deletions chapters/zh-CN/chapter0/1.mdx
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
# 课程简介 [[课程简介]]

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

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

我们将介绍两种设置工作环境的方法,使用 Colab 笔记本或 Python 虚拟环境。选择任意一种趁手的方式即可。对于初学者,我们强烈建议您从使用 Colab 笔记本开始(国内无法访问,可以跳过,直接查阅本页**安装依赖**那一节即可在本地的环境下运行,译者注)。
我们将介绍两种设置工作环境的方法,使用 Colab Notebook 或 Python 虚拟环境。选择任意一种趁手的方式即可。对于初学者,我们强烈建议你从使用 Colab Notebook 开始(国内无法访问可以跳过直接查阅本页 **安装依赖** 那一节即可在本地的环境下运行译者注)。

请注意,Python 虚拟环境的一些命令不支持Windows系统。如果您在 Windows 上运行,我们建议您继续使用 Colab 笔记本。如果您使用的是 Linux 发行版或 macOS,则可以使用此处的任一方法。
请注意,Python 虚拟环境的一些命令不支持 Windows 系统。如果你使用的操作系统是 Windows,我们建议你继续使用 Colab Notebook 如果你使用的操作系统是 Linux 发行版或 macOS,则可以使用此处的任一方法。

大多数课程和服务都依赖于您拥有 Hugging Face 帐户。我们建议现在创建一个:[创建一个账号](https://huggingface.co/join).
大多数课程和服务都依赖于你拥有 Hugging Face 帐户。我们建议现在创建一个: [创建一个账号](https://huggingface.co/join)

## 使用 Google Colab 笔记本 [[使用 Google Colab 笔记本]]
## 使用 Google Colab Notebook [[使用 Google Colab Notebook ]]

使用 Colab notebook 是最简单的设置;可以在浏览器中启动Notebook并直接开始编写自己的代码
使用 Colab Notebook 是最简单的搭建方式;可以在浏览器中启动 Notebook 并直接开始编写自己的代码

如果您不熟悉 Colab,我们建议您从[这个介绍](https://colab.research.google.com/notebooks/intro.ipynb)开始。Colab 提供一些加速硬件,例如 GPU 或 TPU,并且当我们使用的算力比较少的时候是免费的。
如果你不熟悉 Colab,建议你先查看 [Colab 使用入门](https://colab.research.google.com/notebooks/intro.ipynb) 。Colab 提供一些加速硬件,例如 GPU 或 TPU,并且当我们使用的算力比较少的时候是免费的。

当打开 Colab 后,创建一个新笔记本:
当打开 Colab 后,创建一个新的 Notebook

<div class="flex justify-center">
<img src="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter0/new_colab.png" alt="An empty colab notebook" width="80%"/>
</div>

下一步是安装我们将在本课程中使用的库。我们将使用 **pip** 进行安装,它是 Python 的包管理器。在Notebook中,您可以通过加上!字符表示执行系统命令,所以安装🤗 Transformers 的命令如下:
下一步是安装我们将在本课程中使用的库。我们将使用 **pip** 进行安装,它是 Python 的包管理器。在 Notebook 中,你可以通过加上!字符表示执行系统命令,所以安装🤗 Transformers 的命令如下:

```
!pip install transformers
```

您可以通过在运行 Python 时导入包来判断是否正确安装了该包:
你可以通过在运行 Python 时导入包来判断是否正确安装了该包:

```
import transformers
Expand All @@ -38,25 +38,25 @@ import transformers
<img src="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter0/install.gif" alt="A gif showing the result of the two commands above: installation and import" width="80%"/>
</div>

这将安装一个非常轻量级的 🤗 Transformers。并没有安装机器学习框架(如 PyTorch 或 TensorFlow)。由于之后我们将使用该库的许多不同功能,我们建议安装开发版本,它带有几乎所有所需的依赖项:
这将安装一个没有安装机器学习框架(如 PyTorch 或 TensorFlow)非常轻量级的 🤗 Transformers。由于之后我们将使用该库的许多不同功能,我们建议安装开发版本,它带有几乎所有所需的依赖项:

```
!pip install transformers[sentencepiece]
```

这将需要一些时间,但当完成之后您就做好学习剩下的课程的环境准备了
这将需要一些时间,但当完成之后你就做好学习剩下的课程环境的全部准备了

## 使用 Python 虚拟环境 [[使用 Python 虚拟环境]]

如果您更喜欢使用 Python 虚拟环境,那么第一步是在您的系统上安装 Python。我们建议您按照[这个教程](https://realpython.com/installing-python/)进行配置。
如果你更喜欢使用 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).
在 Python 中,这是通过 [*虚拟环境*](https://docs.python.org/3/tutorial/venv.html) 实现的,虚拟环境会创建许多目录树,每个目录树都包含具有特定 Python 版本的 Python 安装以及应用程序所需的所有包。可以使用许多不同的工具来创建这样的虚拟环境,但在此我们将使用官方 Python 包: [`venv`](https://docs.python.org/3/library/venv.html#module-venv)

首先,创建您希望Transformers所在的目录 - 例如,您可能希望在主目录的根目录下创建一个名为 *Transformers-course* 的新目录:
首先,创建你希望 Transformers 所在的目录 - 例如,你可能希望在主目录的根目录下创建一个名为 `Transformers-course` 的新目录:

```
mkdir ~/transformers-course
Expand All @@ -69,7 +69,7 @@ cd ~/transformers-course
python -m venv .env
```

您现在应该在原本为空的文件夹中看到一个名为 *.env* 的目录:
你现在应该在原本为空的文件夹中看到一个名为 `.env` 的目录:

```
ls -a
Expand All @@ -79,17 +79,17 @@ ls -a
. .. .env
```

您可以使用`activate``deactivate`命令来控制进入和退出您的虚拟环境
你可以使用 `activate``deactivate` 命令来控制进入和退出你的虚拟环境

```
# Activate the virtual environment
# 激活虚拟环境
source .env/bin/activate
# Deactivate the virtual environment
# 退出虚拟环境
deactivate
```

您可以通过运行 `which python` 命令来检测虚拟环境是否被激活:如果它指向虚拟环境,那么您已经成功激活了它
你可以通过运行 `which python` 命令来检测虚拟环境是否被激活:如果它指向虚拟环境,那么你已经成功激活了它

```
which python
Expand All @@ -101,10 +101,10 @@ which python

### 安装依赖 [[安装依赖]]

与使用 Google Colab 实例的上一节一样,您现在需要安装继续所需的包。 同样,您可以使用 `pip` 包管理器安装 🤗 Transformers 的开发版本:
与前面使用 Google Colab 的部分一样,你现在需要安装继续学习所需的软件包。同样,你可以使用 `pip` 包管理器安装 🤗 Transformers 的开发版本:

```
pip install "transformers[sentencepiece]"
```

您现在已准备就绪,可以开始了!
你现在已准备就绪,可以开始了!
Loading

0 comments on commit d32647b

Please sign in to comment.