Downloads · 30 days
0
DumbsterDrekk/hindi-tokenizer
hindi-tokenizer is a machine learning model from DumbsterDrekk. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
Load and use the pre-trained Byte-Pair Encoding (BPE) tokenizer directly from Hugging Face Hub under DumbsterDrekk/hindi-tokenizer.
Downloads · 30 days
0
Access
Public
Updated May 26, 2025
Repo size
1.1 MB
Likes
0
Public
Click a slice to open those files.
.md1.6 KB · 36%
From the Hugging Face model README
Load and use the pre-trained Byte-Pair Encoding (BPE) tokenizer directly from Hugging Face Hub under DumbsterDrekk/hindi-tokenizer.
pip install transformers
(If your repo is private, also install and login to huggingface_hub)
pip install huggingface_hub
huggingface-cli login
Set your HF token (if private repo):
export HF_TOKEN="hf_yourPersonalAccessToken"
Load the tokenizer:
import os
from transformers import PreTrainedTokenizerFast
hf_token = os.getenv("HF_TOKEN") # or None for public repo
tokenizer = PreTrainedTokenizerFast.from_pretrained(
"DumbsterDrekk/hindi-tokenizer",
use_auth_token=hf_token, # omit if repo is public
unk_token="<unk>",
eos_token="</w>",
pad_token="<pad>",
)
Tokenize text:
text = "मैं आज बहुत खुश हूँ। I’m very happy today."
# Single sequence
enc = tokenizer(
text,
padding="max_length",
truncation=True,
max_length=512,
return_tensors="pt", # or omit for Python lists
)
print("Input IDs: ", enc["input_ids"])
print("Attention Mask:", enc["attention_mask"])
Decode tokens back to text:
decoded = tokenizer.decode(enc["input_ids"][0], skip_special_tokens=True)
print("Decoded Text: ", decoded)
Once loaded, this tokenizer can be plugged into any 🤗 Transformers training or generation pipeline exactly like a built-in model tokenizer.