Downloads · 30 days
0
koshikdebanath/bengali-gpt-poetry
bengali-gpt-poetry is a machine learning model from koshikdebanath. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as cc-by-sa-4.0.
This model is a GPT-style language model trained from scratch on the Free Bengali Poetry dataset. It was implemented in pure PyTorch without using any external NLP libraries.
Downloads · 30 days
0
Access
Public
Updated Mar 9, 2026
Repo size
52.5 MB
Likes
0
Public
Click a slice to open those files.
.pt52.3 MB · 100%
From the Hugging Face model README
This model is a GPT-style language model trained from scratch on the Free Bengali Poetry dataset. It was implemented in pure PyTorch without using any external NLP libraries.
The model is primarily intended for Bengali poetry generation and as a foundation for further fine‑tuning on downstream Bengali NLP tasks.
To use the model, you need the custom tokenizer and model definition from the training script. Below is a minimal example:
import torch
import pickle
from your_training_script import GPT, BPETokenizer, Config
# Load tokenizer
with open("bpe_tokenizer.pkl", "rb") as f:
tokenizer_data = pickle.load(f)
tokenizer = BPETokenizer()
tokenizer.__dict__.update(tokenizer_data) # restore state
# Load model
config = Config(
vocab_size=len(tokenizer.vocab),
block_size=256,
n_layer=6,
n_head=6,
n_embd=384,
dropout=0.1,
bias=True
)
model = GPT(config)
model.load_state_dict(torch.load("best_model.pt", map_location="cpu"))
model.eval()
# Generate text
prompt = "আমার সোনার বাংলা"
input_ids = tokenizer.encode(prompt, add_special_tokens=True)
input_tensor = torch.tensor([input_ids], dtype=torch.long)
with torch.no_grad():
output_ids = model.generate(input_tensor, max_new_tokens=50, temperature=0.8, top_k=40)
print(tokenizer.decode(output_ids[0].tolist()))
Note: You need the original training script (train_bengali_gpt_v1.py)Code to access the GPT, BPETokenizer, and Config classes.
If you use this model, please cite the dataset as well:
@misc{ritobrata ghosh_2021, author = {Ritobrata Ghosh}, year = {2021}, title = {Free Bengali Poetry}, publisher = {Kaggle}, address = {Kolkata, India} }
The model weights are released under the same license as the dataset: CC BY-SA 4.0.
For questions or collaborations, feel free to reach out.