Skip to content

Commit

Permalink
Merge branch 'master' into python-async-iterators
Browse files Browse the repository at this point in the history
  • Loading branch information
lpozo authored Jul 18, 2024
2 parents acb91e9 + bd32d97 commit fac2bd2
Show file tree
Hide file tree
Showing 6 changed files with 2,119 additions and 1,479 deletions.
42 changes: 30 additions & 12 deletions huggingface-transformers/README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,42 @@
# Hugging Face Transformers: Leverage Open-Source AI in Python

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

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:
## Installation

```console
(venv) $ python -m pip install transformers
Create and activate a virtual environment, and then install the required dependencies:

```sh
(venv) $ python -m pip install transformers torch pillow notebook ipywidgets
```

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:

```sh
$ poetry install
```

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:
## Usage

```console
(venv) $ python -m pip install torch
Run the sample Python scripts:

```sh
(venv) $ python auto_classes.py
(venv) $ python running_pipelines.py
```

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

```pycon
>>> import transformers
>>> import torch
```sh
(venv) $ python -m jupyter notebook gpus_google_colab.ipynb
```

If the imports run without errors, then you've successfully installed the dependencies needed for this tutorial.
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:

```diff
-!pip install -r requirements.txt
+!pip install -r /content/requirements.txt

-DATA_PATH = "Scraped_Car_Review_dodge.csv"
+DATA_PATH = "/content/Scraped_Car_Review_dodge.csv"
```
Loading

0 comments on commit fac2bd2

Please sign in to comment.