I used the HuggingFace Transformer library with PyTorch to run various LLM (Large Language Models). On Windows 11 WSL Ubuntu environment, installing the HuggingFace Transformer is not easy. The command combination that worked for me is:
conda create --name llm2
conda activate llm2
conda install pytorch
pip uninstall tokenizers
After the installation is complete, I verified it by running:
python -c "from transformers import pipeline; print(pipeline('sentiment-analysis')('I love Hugging Face!'))"
No model was supplied, defaulted to distilbert/distilbert-base-uncased-finetuned-sst-2-english and revision af0f99b (https://huggingface.co/distilbert/distilbert-base-uncased-finetuned-sst-2-english).
Using a pipeline without specifying a model name and revision in production is not recommended.
config.json: 100%|█████████████████████████████████████████████████████████████████████| 629/629 [00:00<00:00, 4.97MB/s]
model.safetensors: 100%|█████████████████████████████████████████████████████████████| 268M/268M [00:20<00:00, 12.8MB/s]
tokenizer_config.json: 100%|██████████████████████████████████████████████████████████| 48.0/48.0 [00:00<00:00, 514kB/s]
vocab.txt: 100%|█████████████████████████████████████████████████████████████████████| 232k/232k [00:00<00:00, 7.59MB/s]
[{'label': 'POSITIVE', 'score': 0.9998641014099121}]
What it does is it downloads a Text2Sentiment classifier (distilbert/distilbert-base-uncased-finetuned-sst-2-english model), and used it to classifier the input text. The output is: [{‘label’: ‘POSITIVE’, ‘score’: 0.9998641014099121}].