BASALT-300M
Bengali Architecture for Semantic and Language Technology
BASALT-300M is an independently pretrained, Bengali-focused causal language model built using the LLaMA architecture and a custom SentencePiece tokenizer.
The project aims to develop a language model focused primarily on contemporary Bengali, with an initial emphasis on everyday language used in West Bengal, India.
Model Details
| Property | Value |
|---|---|
| Model name | BASALT-300M |
| Model type | Causal Language Model |
| Architecture | LLaMA-style Transformer |
| Parameters | ~301 million |
| Vocabulary size | 16,000 |
| Context length | 8,192 tokens |
| Primary language | Bengali |
| Tokenizer | Custom SentencePiece |
| Training approach | Pretraining from scratch |
Note: BASALT uses the LLaMA architecture but was initialized with randomly generated weights. It does not use pretrained weights from Meta's LLaMA models or any other pretrained model.
Intended Use
BASALT-300M is a foundational Bengali language model intended for:
- Bengali text generation and language modelling.
- Research and experimentation in Bengali NLP.
- Exploring Bengali vocabulary, grammar, and linguistic patterns.
- Studying language representation and next-token prediction.
- Serving as a foundation for future Bengali language model development.
Loading the Model and Tokenizer
BASALT-300M uses a custom SentencePiece tokenizer. The tokenizer is provided as tokenizer.model in this repository and must be loaded separately using the SentencePiece library.
Install dependencies
pip install torch transformers sentencepiece huggingface_hub
Load the tokenizer
import sentencepiece as spm
from huggingface_hub import hf_hub_download
tokenizer_path = hf_hub_download(
repo_id="biltudas1/BASALT-300M",
filename="tokenizer.model"
)
tokenizer = spm.SentencePieceProcessor(
model_file=tokenizer_path
)
Load the model
from transformers import AutoModelForCausalLM
model = AutoModelForCausalLM.from_pretrained(
"biltudas1/BASALT-300M",
dtype="auto",
device_map="auto"
)
model.eval()
Generate text
import torch
prompt = "আজ সকালে আমি"
input_ids = tokenizer.encode(prompt, out_type=int)
input_ids = torch.tensor(
[input_ids],
dtype=torch.long,
device=model.device
)
with torch.inference_mode():
output = model.generate(
input_ids,
max_new_tokens=100,
do_sample=True,
temperature=0.8,
top_p=0.9,
eos_token_id=tokenizer.eos_id(),
pad_token_id=tokenizer.pad_id()
)
generated_ids = output[0][input_ids.shape[1]:].tolist()
print(tokenizer.decode(generated_ids))
Important: Direct SentencePiece encoding does not automatically prepend BOS or append EOS. The example above follows BASALT's training convention by not adding BOS to the prompt. EOS is configured as the generation stopping token.
The model can be loaded through Transformers, but tokenizer operations are handled separately through SentencePiece. Native AutoTokenizer.from_pretrained() support is not currently provided.
- Downloads last month
- 29