HFLoader - Hugging Face Model Loader
This package provides the user with one method that returns both a tokenizer and a model when loading HuggingFace Models, without the need for knowing which AutoModel to use.
This package utilizes the transformers library to load a tokenizer and model, without having to know the AutoModel. This means that with one command, you can easily load the tokenizer and model of a given model on HuggingFace Model Hub. This can then be easily fed into the pipeline function of transformers.
Installation
The package can be installed with the following command:
pip install hfloader
How to Use
Here is a bit of code you can reference to see how to use the package.
import hfloader as hfl
huggingface_model = "cardiffnlp/twitter-roberta-base-sentiment"
tokenizer, model = hfl.load_model(huggingface_model)
pipe = pipeline("text-generation", model=model, tokenizer=tokenizer, torch_dtype=torch.bfloat16, device_map="auto")
The return of the command load_model() is going to be a tokenizer and a model, which can then be used in the pipeline method provided by transformers. It does so without the need to know which AutoModel to use, which can prove to be a hassle when trying out different models.
Requirements
pip install transformers
Notes
I don't have plans to upkeep this project unless it necessitates it. I was able to achieve the goal I had set out when developing the package.
Metadata
Release files for hfloader 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| hfloader-1.0.2.tar.gz | 3.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| hfloader-1.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.4 kB
Release files / hfloader-1.0.2.tar.gz
| Download URL | hfloader-1.0.2.tar.gz |
|---|---|
| Size | 3.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
580bd9e4d64b2a6948b0649ca4f880468ae6d2804ca51270b3eeb8e018d54220
|
|
BLAKE2b-256 checksum How to use checksums |
529f5dcb1283d6bbbfed72447ca20f9fe8a090a68b02931db26a6804cc7e9c60
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.5
|
Release files / hfloader-1.0.2-py3-none-any.whl
| Download URL | hfloader-1.0.2-py3-none-any.whl |
|---|---|
| Size | 3.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
786de1740ee75ad9ede6270499ec413d05d3efb15eb8c735462bbba8aab69017
|
|
BLAKE2b-256 checksum How to use checksums |
0032b8a050ecf07d0de556ee1d3b6531ea8cf549b5a3e6aa7cd84794444a7e8e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.5
|