Skip to content

Commit bd32d97

Browse files
committed
Final QA of Hugging Face Transformers
1 parent c14b862 commit bd32d97

File tree

6 files changed

+2119
-1479
lines changed

6 files changed

+2119
-1479
lines changed

huggingface-transformers/README.md

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,42 @@
11
# Hugging Face Transformers: Leverage Open-Source AI in Python
22

3-
This folder contains the materials for the tutorial (Hugging Face Transformers: Leverage Open-Source AI in Python)[https://realpython.com/huggingface-transformers/].
3+
This folder contains the materials for the tutorial [Hugging Face Transformers: Leverage Open-Source AI in Python](https://realpython.com/huggingface-transformers/).
44

5-
Transformers is available on [PyPI](https://pypi.org/) and you can install it with [pip](https://realpython.com/what-is-pip/). Open a terminal or command prompt, create a new virtual environment, and then run the following command:
5+
## Installation
66

7-
```console
8-
(venv) $ python -m pip install transformers
7+
Create and activate a virtual environment, and then install the required dependencies:
8+
9+
```sh
10+
(venv) $ python -m pip install transformers torch pillow notebook ipywidgets
11+
```
12+
13+
Alternatively, if you use [Poetry](https://realpython.com/dependency-management-python-poetry/), then you can issue the following command to handle the installation process for you:
14+
15+
```sh
16+
$ poetry install
917
```
1018

11-
This command will install the latest version of Transformers from PyPI onto your machine. Throughout this tutorial, you'll also leverage [PyTorch](https://realpython.com/pytorch-vs-tensorflow/) to interact with models at a lower level. You can install PyTorch with the following command:
19+
## Usage
1220

13-
```console
14-
(venv) $ python -m pip install torch
21+
Run the sample Python scripts:
22+
23+
```sh
24+
(venv) $ python auto_classes.py
25+
(venv) $ python running_pipelines.py
1526
```
1627

17-
To verify that the installations were successful, start a [Python REPL](https://realpython.com/python-repl/) and import `transformers` and `torch`:
28+
Run the sample Jupyter notebook:
1829

19-
```pycon
20-
>>> import transformers
21-
>>> import torch
30+
```sh
31+
(venv) $ python -m jupyter notebook gpus_google_colab.ipynb
2232
```
2333

24-
If the imports run without errors, then you've successfully installed the dependencies needed for this tutorial.
34+
Note that if you run this notebook in Google Colab, then you'll need to update the path to the `requirements.txt` file and the `DATA_PATH` constant accordingly:
35+
36+
```diff
37+
-!pip install -r requirements.txt
38+
+!pip install -r /content/requirements.txt
39+
40+
-DATA_PATH = "Scraped_Car_Review_dodge.csv"
41+
+DATA_PATH = "/content/Scraped_Car_Review_dodge.csv"
42+
```

huggingface-transformers/cars_data/Scraped_Car_Review_dodge.csv renamed to huggingface-transformers/Scraped_Car_Review_dodge.csv

File renamed without changes.

0 commit comments

Comments
 (0)