A package that loads a tokenizer and model from the HuggingFace model hub.
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file hfloader-1.0.tar.gz
.
File metadata
- Download URL: hfloader-1.0.tar.gz
- Upload date:
- Size: 3.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fad2d2aaabb6208c9d4b8144b322d4695ebf78157d446d0d8fe227013028557f |
|
MD5 | 02f3363ff8b8f2932d42c0f7a62b2363 |
|
BLAKE2b-256 | 744b5826458219c5ec686f59511fb6475529044b336d8a0f130ddac09d37c816 |
File details
Details for the file hfloader-1.0-py3-none-any.whl
.
File metadata
- Download URL: hfloader-1.0-py3-none-any.whl
- Upload date:
- Size: 3.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cab0079b60acd6cdaf4e4e0d07c62ec5342f66700cd4d743a4121f058e9a9626 |
|
MD5 | f2b27fad644bc6a91fb45e3d6bde4835 |
|
BLAKE2b-256 | e1a1217bc18b027d9fbfcef3e9e6e724da98f957313bc960c34c462f0ef0834b |