![]() |
VOOZH | about |
Hugging Face Transformers is a library used for building AI applications using pre-trained models, mainly for natural language processing. It supports easy integration and fine-tuning and is built on PyTorch and TensorFlow for efficient development.
python -m venv transformers-env
source transformers-env/bin/activate # For Linux / Mac
transformers-env\Scripts\activate # For Windows
To install PyTorch, visit the official PyTorch website and select the command based on your system, Python version and whether you want CPU or GPU support.
For a typical CPU installation
pip install torch torchvision torchaudio
For GPU (CUDA support – example for CUDA 12.1)
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
With your environment set up and either PyTorch or TensorFlow installed, you can now install the Hugging Face Transformers library.
pip install transformers
To ensure that everything is installed correctly, you can run a simple test script. Create a Python script or open a Python interpreter and run
Output:
[{'label': 'POSITIVE', 'score': 0.9998}]