diff --git a/chapters/zh-TW/_toctree.yml b/chapters/zh-TW/_toctree.yml index fecc7863f..2d0392bcf 100644 --- a/chapters/zh-TW/_toctree.yml +++ b/chapters/zh-TW/_toctree.yml @@ -1,196 +1,196 @@ -- title: 0. 安裝 - sections: - - local: chapter0/1 - title: 課程簡介 - -- title: 1. Transformer 模型 - sections: - - local: chapter1/1 - title: 本章簡介 - - local: chapter1/2 - title: 自然語言處理 - - local: chapter1/3 - title: Transformers 能做什麼? - - local: chapter1/4 - title: Transformers 是如何運作的? - - local: chapter1/5 - title: 編碼器模型 - - local: chapter1/6 - title: 解碼器模型 - - local: chapter1/7 - title: 序列到序列模型 - - local: chapter1/8 - title: 偏見和侷限性 - - local: chapter1/9 - title: 總結 - - local: chapter1/10 - title: 章末小測驗 - quiz: 1 - -- title: 2. 使用 🤗 Transformers - sections: - - local: chapter2/1 - title: 本章簡介 - - local: chapter2/2 - title: 管道的內部 - - local: chapter2/3 - title: 模型 - - local: chapter2/4 - title: 標記器(Tokenizer) - - local: chapter2/5 - title: 處理多個序列 - - local: chapter2/6 - title: 把它們放在一起 - - local: chapter2/7 - title: 基本用法完成! - - local: chapter2/8 - title: 章末小測驗 - quiz: 2 - -- title: 3. 微調一個預訓練模型 - sections: - - local: chapter3/1 - title: 本章簡介 - - local: chapter3/2 - title: 預處理數據 - - local: chapter3/3 - title: 使用 Trainer API 或者 Keras 微調一個模型 - local_fw: { pt: chapter3/3, tf: chapter3/3_tf } - - local: chapter3/4 - title: 一個完整的訓練過程 - - local: chapter3/5 - title: 微調,章節回顧! - - local: chapter3/6 - title: 章末小測驗 - quiz: 3 - -- title: 4. 分享你的模型和標記器 - sections: - - local: chapter4/1 - title: The Hugging Face Hub - - local: chapter4/2 - title: 使用預訓練的模型 - - local: chapter4/3 - title: 分享預訓練的模型 - - local: chapter4/4 - title: 構建模型卡片 - - local: chapter4/5 - title: Part 1 完結! - - local: chapter4/6 - title: 章末小測驗 - quiz: 4 - -- title: 5. 🤗 Datasets庫 - sections: - - local: chapter5/1 - title: 本章簡介 - - local: chapter5/2 - title: 如果我的數據集不在 Hub 上怎麼辦? - - local: chapter5/3 - title: 是時候來學一下切片了 - - local: chapter5/4 - title: 大數據? 🤗 Datasets 來救援! - - local: chapter5/5 - title: 創建自己的數據集 - - local: chapter5/6 - title: 使用 FAISS 進行語義搜索 - - local: chapter5/7 - title: 🤗 Datasets,回顧! - - local: chapter5/8 - title: 章末小測驗 - quiz: 5 - -- title: 6. 🤗 Tokenizers庫 - sections: - - local: chapter6/1 - title: 本章簡介 - - local: chapter6/2 - title: 根據已有的 tokenizer 訓練新的 tokenizer - - local: chapter6/3 - title: 快速標記器的特殊能力 - - local: chapter6/3b - title: QA 管道中的快速標記器 - - local: chapter6/4 - title: 標準化和預標記化 - - local: chapter6/5 - title: 字節對編碼標記化 - - local: chapter6/6 - title: WordPiece 標記化 - - local: chapter6/7 - title: Unigram 標記化 - - local: chapter6/8 - title: 逐塊地構建標記器 - - local: chapter6/9 - title: 標記器,回顧! - - local: chapter6/10 - title: 章末小測驗 - quiz: 6 - -- title: 7. 主要的 NLP 任務 - sections: - - local: chapter7/1 - title: 章節簡介 - - local: chapter7/2 - title: 標記(token)分類 - - local: chapter7/3 - title: 微調一個掩碼(mask)語言模型 - - local: chapter7/4 - title: 翻譯 - - local: chapter7/5 - title: 文本摘要 - - local: chapter7/6 - title: 從頭開始訓練因果語言模型 - - local: chapter7/7 - title: 問答系統 - - local: chapter7/8 - title: 掌握 NLP - - local: chapter7/9 - title: 章節測驗 - quiz: 7 - -- title: 8. 如何尋求幫助 - sections: - - local: chapter8/1 - title: 章節簡介 - - local: chapter8/2 - title: 出現錯誤時該怎麼辦 - - local: chapter8/3 - title: 在論壇上尋求幫助 - - local: chapter8/4 - title: 調試訓練管道 - local_fw: { pt: chapter8/4, tf: chapter8/4_tf } - - local: chapter8/5 - title: 如何提出一個好的問題 - - local: chapter8/6 - title: Part 2 完結! - - local: chapter8/7 - title: 章節測驗 - quiz: 8 - -- title: 9. 構建並分享你的模型 - subtitle: 我訓練了一個模型,但我該如何展示它呢? - sections: - - local: chapter9/1 - title: Gradio 簡介 - - local: chapter9/2 - title: 構建你的第一個演示 - - local: chapter9/3 - title: 瞭解接口類 - - local: chapter9/4 - title: 與他人分享演示 - - local: chapter9/5 - title: 與 Hugging Face Hub 整合 - - local: chapter9/6 - title: 高級界面功能 - - local: chapter9/7 - title: Gradio 塊簡介 - - local: chapter9/8 - title: Gradio, 回顧! - - local: chapter9/9 - title: 章末測試 - quiz: 9 - -- title: 課程活動 - sections: - - local: events/2 - title: Part 2 發佈活動 +- title: 0. 安裝 + sections: + - local: chapter0/1 + title: 課程簡介 + +- title: 1. Transformer 模型 + sections: + - local: chapter1/1 + title: 本章簡介 + - local: chapter1/2 + title: 自然語言處理 + - local: chapter1/3 + title: Transformers 能做什麼? + - local: chapter1/4 + title: Transformers 是如何運作的? + - local: chapter1/5 + title: 編碼器模型 + - local: chapter1/6 + title: 解碼器模型 + - local: chapter1/7 + title: 序列到序列模型 + - local: chapter1/8 + title: 偏見和侷限性 + - local: chapter1/9 + title: 總結 + - local: chapter1/10 + title: 章末小測驗 + quiz: 1 + +- title: 2. 使用 🤗 Transformers + sections: + - local: chapter2/1 + title: 本章簡介 + - local: chapter2/2 + title: 管道的內部 + - local: chapter2/3 + title: 模型 + - local: chapter2/4 + title: 標記器(Tokenizer) + - local: chapter2/5 + title: 處理多個序列 + - local: chapter2/6 + title: 把它們放在一起 + - local: chapter2/7 + title: 基本用法完成! + - local: chapter2/8 + title: 章末小測驗 + quiz: 2 + +- title: 3. 微調一個預訓練模型 + sections: + - local: chapter3/1 + title: 本章簡介 + - local: chapter3/2 + title: 預處理數據 + - local: chapter3/3 + title: 使用 Trainer API 或者 Keras 微調一個模型 + local_fw: { pt: chapter3/3, tf: chapter3/3_tf } + - local: chapter3/4 + title: 一個完整的訓練過程 + - local: chapter3/5 + title: 微調,章節回顧! + - local: chapter3/6 + title: 章末小測驗 + quiz: 3 + +- title: 4. 分享你的模型和標記器 + sections: + - local: chapter4/1 + title: The Hugging Face Hub + - local: chapter4/2 + title: 使用預訓練的模型 + - local: chapter4/3 + title: 分享預訓練的模型 + - local: chapter4/4 + title: 構建模型卡片 + - local: chapter4/5 + title: Part 1 完結! + - local: chapter4/6 + title: 章末小測驗 + quiz: 4 + +- title: 5. 🤗 Datasets庫 + sections: + - local: chapter5/1 + title: 本章簡介 + - local: chapter5/2 + title: 如果我的數據集不在 Hub 上怎麼辦? + - local: chapter5/3 + title: 是時候來學一下切片了 + - local: chapter5/4 + title: 大數據? 🤗 Datasets 來救援! + - local: chapter5/5 + title: 創建自己的數據集 + - local: chapter5/6 + title: 使用 FAISS 進行語義搜索 + - local: chapter5/7 + title: 🤗 Datasets,回顧! + - local: chapter5/8 + title: 章末小測驗 + quiz: 5 + +- title: 6. 🤗 Tokenizers庫 + sections: + - local: chapter6/1 + title: 本章簡介 + - local: chapter6/2 + title: 根據已有的 tokenizer 訓練新的 tokenizer + - local: chapter6/3 + title: 快速標記器的特殊能力 + - local: chapter6/3b + title: QA 管道中的快速標記器 + - local: chapter6/4 + title: 標準化和預標記化 + - local: chapter6/5 + title: 字節對編碼標記化 + - local: chapter6/6 + title: WordPiece 標記化 + - local: chapter6/7 + title: Unigram 標記化 + - local: chapter6/8 + title: 逐塊地構建標記器 + - local: chapter6/9 + title: 標記器,回顧! + - local: chapter6/10 + title: 章末小測驗 + quiz: 6 + +- title: 7. 主要的 NLP 任務 + sections: + - local: chapter7/1 + title: 章節簡介 + - local: chapter7/2 + title: 標記(token)分類 + - local: chapter7/3 + title: 微調一個掩碼(mask)語言模型 + - local: chapter7/4 + title: 翻譯 + - local: chapter7/5 + title: 文本摘要 + - local: chapter7/6 + title: 從頭開始訓練因果語言模型 + - local: chapter7/7 + title: 問答系統 + - local: chapter7/8 + title: 掌握 NLP + - local: chapter7/9 + title: 章節測驗 + quiz: 7 + +- title: 8. 如何尋求幫助 + sections: + - local: chapter8/1 + title: 章節簡介 + - local: chapter8/2 + title: 出現錯誤時該怎麼辦 + - local: chapter8/3 + title: 在論壇上尋求幫助 + - local: chapter8/4 + title: 調試訓練管道 + local_fw: { pt: chapter8/4, tf: chapter8/4_tf } + - local: chapter8/5 + title: 如何提出一個好的問題 + - local: chapter8/6 + title: Part 2 完結! + - local: chapter8/7 + title: 章節測驗 + quiz: 8 + +- title: 9. 構建並分享你的模型 + subtitle: 我訓練了一個模型,但我該如何展示它呢? + sections: + - local: chapter9/1 + title: Gradio 簡介 + - local: chapter9/2 + title: 構建你的第一個演示 + - local: chapter9/3 + title: 瞭解接口類 + - local: chapter9/4 + title: 與他人分享演示 + - local: chapter9/5 + title: 與 Hugging Face Hub 整合 + - local: chapter9/6 + title: 高級界面功能 + - local: chapter9/7 + title: Gradio 塊簡介 + - local: chapter9/8 + title: Gradio, 回顧! + - local: chapter9/9 + title: 章末測試 + quiz: 9 + +- title: 課程活動 + sections: + - local: events/2 + title: Part 2 發佈活動 \ No newline at end of file diff --git a/chapters/zh-TW/chapter0/1.mdx b/chapters/zh-TW/chapter0/1.mdx index 05d6f8f35..ebddc5ef8 100644 --- a/chapters/zh-TW/chapter0/1.mdx +++ b/chapters/zh-TW/chapter0/1.mdx @@ -1,34 +1,34 @@ # 課程簡介 -歡迎來到 Hugging Face 的教學!本篇介紹將會帶著你設置運行環境。如果你正開始學的話,不妨先看看[第一章](/course/chapter1)再回來,這樣就能直接開始試著執行裡面的程式碼了。 +歡迎來到 Hugging Face 課程!這個簡介將引導您設定工作環境。如果您剛開始學習這門課程,我們建議您先查看[第一章](/course/chapter1),然後再回來設定您的環境,這樣您就可以親自嘗試程式碼。 -我們會用到的所有函式庫都將會以 Python 資源包的方式被取得,所以這邊我們會教你如何設置 Python 環境並安裝你所需要的函式庫。 +我們在這門課程中使用的所有函式庫都可以作為 Python 套件取得,因此我們將向您展示如何設定 Python 環境並安裝您需要的特定函式庫。 -本篇將會涵蓋兩種設置環境的方法 - 使用 Colab notebook 或是 Python 虛擬環境。選你自己覺得合適的方式就好,但是對於初學者我們強烈推薦先從使用 Colab notebook 開始。 +我們將介紹兩種設定工作環境的方法:使用 Colab notebook 或是 Python 虛擬環境。請隨意選擇最適合您的方法。對於初學者,我們強烈建議您從 Colab notebook 開始學習。 -我們不會提到 Windows 系統,如果你是 Windows 的使用者,我們建議使用 Colab notebook。如果你用的是 Linux 或是 macOS,你可以任意選擇上述的兩種方法。 +請注意,我們不會涵蓋 Windows 系統。如果您使用的是 Windows,我們建議您使用 Colab notebook 跟著學習。如果您使用的是 Linux 發行版或 macOS,您可以使用這裡描述的任一種方法。 -大部分的教學都會需要一個Hugging Face的帳號。我們建議現在就[創一個](https://huggingface.co/join)。 +這門課程的大部分內容都需要您擁有 Hugging Face 帳號。我們建議您現在就[建立帳號](https://huggingface.co/join)。 -## 使用Google Colab notebook +## 使用 Google Colab notebook -用 Colab notebook 是最簡單容易的方法;在瀏覽器開一頁 Colab notebook 就能直接開始寫程式了! +使用 Colab notebook 是最簡單的設定方式;在您的瀏覽器中啟動 Colab notebook 就能直接開始寫程式了! -如果你對 Colab notebook 不熟悉的話,我們建議你從[這篇介紹](https://colab.research.google.com/notebooks/intro.ipynb)開始。在 Colab 上你可以使用一些加速硬體,像是 GPU 或 TPU,而且工作量不大的話也不收費。 +如果您對 Colab 不熟悉,我們建議您從[簡介](https://colab.research.google.com/notebooks/intro.ipynb)開始。Colab 允許您使用一些加速硬體,如 GPU 或 TPU,對於較小的工作負載是免費的。 -當你開始熟悉 Colab 後,建立新的筆記本然後開始進行設置: +一旦您熟悉了 Colab 的操作,請建立一個新的 notebook 並開始設定:
An empty colab notebook
-接下來就是安裝我們將會用到的函式庫。我們會使用 `pip` 這個Python的資源管理工具來安裝。在Colab notebook裡,你可以用 `!` 來執行系統指令,所以你可以用以下的指令來安裝 🤗 Transformers 函式庫: +下一步是安裝我們在這門課程中將使用的函式庫。我們將使用 `pip` 進行安裝,這是 Python 的套件管理器。在 notebook 中,您可以在系統指令前加上 `!` 字元來執行,因此您可以如下安裝 🤗 Transformers 函式庫: ``` !pip install transformers ``` -把函式庫導入到 Python runtime 可以確認你的資源包有被正確地安裝: +您可以透過在 Python 執行環境中匯入來確保套件已正確安裝: ``` import transformers @@ -38,42 +38,38 @@ import transformers A gif showing the result of the two commands above: installation and import -這會安裝一個非常輕量的 🤗 Transformers。裡面沒有安裝任何像是 PyTorch 或 TensorFlow 等的機器學習框架。因為我們會用到很多函式庫裡的不同功能,所以我們建議安裝包含了大部分使用情境所需資源的開發用版本: - +這會安裝一個非常輕量版本的 🤗 Transformers。特別是,不會安裝特定的機器學習框架(如 PyTorch 或 TensorFlow)。由於我們將使用函式庫的許多不同功能,我們建議安裝開發版本,它包含幾乎任何可想像用例所需的所有相依套件: ``` !pip install transformers[sentencepiece] ``` -這會花一點時間,不過裝完你就已經完全準備好面對剩下的教學了! - - -## 使用Python虛擬環境 - -如果你比較想用 Python 虛擬環境的話,第一步就是安裝 Python。我們建議跟著[這篇教學](https://realpython.com/installing-python/)做為起手式。 - +這需要一些時間,但之後您就準備好進行課程的其餘部分了! -當你安裝好 Python 後,你應該就能從終端機執行 Python 指令了。在進行下一步之前你可以先執行以下指令來確認 Python 有沒有安裝好:`python --version` 這條指令會讓終端機顯示你所安裝的 Python 版本。 +## 使用 Python 虛擬環境 +如果您偏好使用 Python 虛擬環境,第一步是在您的系統上安裝 Python。我們建議遵循[這篇指南](https://realpython.com/installing-python/)開始。 -在終端機執行像是`python --version`的 Python 指令時,你應該把你的指令想成是用你系統上主要的 Python 版本來執行。我們建議不要在這個版本上安裝任何資源包,讓每個專案在各自獨立的環境裡運行就可以了。這樣每個專案都可以有各自的相依性跟資源包,你也不用擔心不同專案之間使用同一個環境時潛在的相容性問題。 +一旦您安裝了 Python,您應該能夠在終端機中執行 Python 指令。在進行下一步之前,您可以先執行以下指令來確保它已正確安裝:`python --version`。這應該會印出您系統上現在可用的 Python 版本。 +當您在終端機中執行 Python 指令(如 `python --version`)時,您應該將執行指令的程式視為您系統上的「主要」Python。我們建議保持這個主要安裝不安裝任何套件,並為您工作的每個應用程式建立獨立的環境——這樣,每個應用程式都可以擁有自己的相依套件和版本,您也不需要擔心與其他應用程式的潛在相容性問題。 -在 Python 我們可以用[*虛擬環境*](https://docs.python.org/3/tutorial/venv.html)來做這件事。虛擬環境是一個獨立包裝的樹狀目錄,每一個目錄下都有安裝特定版本的Python跟它需要的所有資源包。創建這樣的虛擬環境可以用很多不同的工具,不過我們會用一個叫做[`venv`](https://docs.python.org/3/library/venv.html#module-venv)的Python官方資源包。 +在 Python 中,這是透過[*虛擬環境*](https://docs.python.org/3/tutorial/venv.html)來實現的,虛擬環境是獨立的目錄結構,每個都包含特定 Python 版本的安裝以及應用程式所需的所有套件。建立這樣的虛擬環境可以使用許多不同的工具,但我們將使用 Python 官方套件:[`venv`](https://docs.python.org/3/library/venv.html#module-venv)。 -首先,創建你希望你的程式執行時所在的目錄 - 舉例來說,你可能想要在你的家目錄下新增一個叫*transformers-course*的目錄: +首先,建立您希望應用程式所在的目錄——例如,您可能想在您的家目錄根目錄下建立一個名為 *transformers-course* 的新目錄: ``` mkdir ~/transformers-course cd ~/transformers-course ``` -從這個目錄裡面,你可以用Python的`venv`模組建立一個虛擬環境: + +從這個目錄內部,使用 Python `venv` 模組建立虛擬環境: ``` python -m venv .env ``` -你現在應該在你的空資料夾裡找到一個叫做*.env*的目錄,這個目錄就是你的虛擬環境。 -You should now have a directory called *.env* in your otherwise empty folder: + +您現在應該在原本空的目錄中有一個名為 *.env* 的目錄: ``` ls -a @@ -82,7 +78,8 @@ ls -a ```out . .. .env ``` -你可用 `activate` 和 `deactivate` 這兩個腳本來啟用或關閉你的虛擬環境: + +您可以使用 `activate` 和 `deactivate` 腳本進入和退出虛擬環境: ``` # Activate the virtual environment @@ -91,7 +88,8 @@ source .env/bin/activate # Deactivate the virtual environment deactivate ``` -你可以執行 `which python` 指令來確認你的虛擬環境是否有被啟用:如果它指向虛擬環境的目錄,那表示你的虛擬環境已經啟用了! + +您可以透過執行 `which python` 指令來確保環境已啟動:如果它指向虛擬環境,那麼您已成功啟動它! ``` which python @@ -101,11 +99,12 @@ which python /home//transformers-course/.env/bin/python ``` -### 安裝相依性資源包 +### 安裝相依套件 -在之前的段落中提到的使用 Google Colab 的情況裡,你會需要安裝相依性資源包才能繼續。你可以用 `pip` 這個資源管理工具來安裝開發版的🤗 Transformers: +如同前面關於使用 Google Colab 實例的章節,您現在需要安裝繼續所需的套件。同樣地,您可以使用 `pip` 套件管理器安裝 🤗 Transformers 的開發版本: ``` pip install "transformers[sentencepiece]" ``` -你現在已經準備就緒,可以開始了! + +您現在已經完成設定並準備就緒!