How to Install Hugging Face Transformers Library on Ubuntu

The Hugging Face Transformers library is used for Natural Language Processing(NLP). The NLP is the machine learning technology that helps the machine to interpret human beings’ languages.

The Hugging Face Transformers Library is known as the Transformers that is open-source and developed by the “Hugging Face”. This post explains the installation methods of the Hugging Face Transformers Library on Ubuntu and also demonstrates its basic usage.

What is the Usage of the Hugging Face Transformers Library on Ubuntu?

The usage of the Transformers in the Ubuntu is:

  • The pre-trained models can be used for different purposes such as the detection of spam on text data
  • It can be used for generation of the text for different tasks like auto-completion
  • Its models can be helpful in translating languages from one to another
  • It can be used for the development of the chatbots

What is the Installation Method of Hugging Face Transformers Library on Ubuntu?

Hugging Face Transformers Library can be installed on Ubuntu by pip. Python package manager known as the Pip is used on Linux to manage the Python packages and libraries. For installing the Hugging Face Transformers Library on Ubuntu, follow the steps explained below. 

Step 1: Launch the Terminal

First, launch the the terminal of the Ubuntu:

Step 2: Install the Pip

Now install the Pip Python package manager on Ubuntu with the execution of the command:

$ sudo apt install python3-pip -y

Step 3: Validate the Pip’s Installation

Display the version of installed Pip:

$ pip --version

Step 4: Create a Virtual Environment

Before installing the Transformers, it is recommended to create a virtual environment:

$ python3 -m venv transformers-Env

Step 5: Activate the Virtual Environment

Activate the newly created virtual environment:

$ source transformers-Env/bin/activate

Step 6: Install Hugging Face Transformers Library

Finally, install the Hugging Face Transformers Library with the Pip package manager:

$ pip install transformers

Step 8: Deactivate the Virtual Environment

When the installation is finished, enable the deactivation of the virtual environment:

$ deactivate

The Hugging Face Transformer has been successfully installed on Ubuntu. 

How to Uninstall the Hugging Face Transformers Library on Ubuntu?

To uninstall and remove the Transformers on Ubuntu, activate the virtual environment:

$ source transformers-Env/bin/activate

Then uninstall it by using the Pip Python package manager:

$ pip uninstall transformers

The Transformers have been uninstalled successfully. Now deactivate the virtual environment using the command:

$ deactivate

This is all about the installation and uninstallation of the Hugging Face Transformers Library on Ubuntu. 

Conclusion

To install the Hugging Face Transformers Library on Ubuntu, install the Pip package manager and run the command “pip install transformers” in the terminal. The installation method of the Hugging Face Transformers Library on Ubuntu has been explained in the step-by-step guide in this article.

Over 500 Million Views on Our Blogs and YouTube! We’re inviting 10 businesses to partner with us and grow together. Click here to join us! ×