From the course: Applied AI: Getting Started with Hugging Face Transformers

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Loading a pipeline

Loading a pipeline

- [Instructor] Let's load the sentiment analysis pipeline from Hugging Face in this video. First, we need to import the pipeline module from transformers. To load a pipeline, we simply create a pipeline with the specific task name, which is called sentiment analysis. When this code is executed, the pipeline module will download the model checkpoint, tokenizer and other artifacts from the Hugging Face website to a local cache. The local cache is usually available under the user home directory. Do note that these artifacts are huge and may take a long time to download depending on the available bandwidth. You will also need enough disk space to store these models locally. Once the artifacts are available in the local cache, further calls to the pipeline, will only use the local cache and not download from the website. To download again, simply delete the directory from the cache. In this code, we first create the pipeline. We also print the cache directory path and contents of the cache…

Contents