I am confused on how to install a library from HuggingFace on your own desktop or server. How complicated is it to install a library? Are there step by step instructions anywhere? I found some articles, but they assumed a certain level of knowledge and I’m a total beginner and was unable to follow them.
To be more specific, I was looking at the GPT libraries. GPT Neo 125M seems to be the smallest of these so I’m assuming that would be the easiest to install. https://huggingface.co/EleutherAI https://huggingface.co/EleutherAI/gpt-neo-125M
Also, once you install a library on your own machine, is it free to use? I see that HuggingFace has a pricing structure:
https://huggingface.co/pricing
But I’m not sure what it applies to. Does this pricing structure apply if you host the model on your own computer?
I’m a total noob to this stuff so any tips are appreciated.
gpt-neo-125M
First, move to the "Files and Version" tab from the respective model's official page in Hugging Face. So for gpt-neo-125M it would be this
Then click on the top right corner 'Use in Transformers' and you will get a window like this
Now just follow the git clone commands there - for gpt-neo125M it will be
git lfs install
git clone https://huggingface.co/EleutherAI/gpt-neo-125M
This will download all the files and the models that you see in that page to your local machine's directory.
And now you can run the below code, exactly following the official doc, only changing the 'model' parameter's value to the local directory where you just gitcloned above.
## Below is my implementations taking model from local machine
from transformers import pipeline
generator = pipeline('text-generation', model='/your_local_dir_where_you_downloaded/')
generator("USA will be ", do_sample=True, max_length=120, min_length=20)
Also, note that you can manually download the model files (by clicking on the down arrow) from HuggingFace above site, if you don't want to use git lfs
. In that case you need to pass GIT_LFS_SKIP_SMUDGE=1
, as the doc says
# if you want to clone without large files – just their pointers
# prepend your git clone with the following env var:
GIT_LFS_SKIP_SMUDGE=1
No. If you are using offline, i.e. host the model on your own computer - there are no costs.
Also if you are using these models on your own cloud hardware like AWS ec2, or your own server, then there are no costs.
But if you use huggingface API endpoints for inference then you will be charged accordingly !!
So the pricing given in huggingface.co/pricing - Applies when you are directly hitting Huggingface's own API endpoints for inference.