Ex: Install Transformers
Transformers library is dependent on ML libraries. In order to use it, you MUST install the ML library itself before installing the Transformers library. You will be installing the Pytorch ML framework.
Pytorch installation
- Depends on the machine’s architecture.
- It has separate libraries for CPU & GPU
- Follow instructions at https://pytorch.org/ to install on your machine
- If an incorrect library version is installed, it would lead to an error at runtime (on import statement). You would see an error similar to one below:
OSError: [WinError 126] can’t find this module. Error loading “d:\anaconda3\envs\RN\lib\site-packages\torch\lib\fbgemm.dll” or one of its dependencies.
Steps
- Open the link and generate the command for installation:
https://pytorch.org/
- Depending on your Python environment, run one of the commands below to install Transformers library
pip install transformers==4.41.2
conda install transformers==4.41.2
Run the code to validate
Run the code in a few cells to validate the installation.
The pipeline code will download model to your local disk. It may take a few minutes depending on the speed of your network.
Solution
- Requires the PyTorch & Transformers to be installed locally
Open in Google Colab
- PyTorch and Transformers will need to be installed. Uncomment the installation command.
pip install torch transformers