YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
ANLP Assignment 1 β Custom Transformers and Byte Latent Transformer
This repository contains the pretrained checkpoints for Advanced Natural Language Processing Assignment 1.
Checkpoints
hf_models/
βββ C1/
β βββ model.pt
βββ C2/
β βββ model.pt
βββ C3/
β βββ model.pt
βββ C4/
β βββ model.pt
βββ C5/
βββ model.pt
Configurations
| Configuration | Positional Encoding | Attention | Normalization | Input Processing |
|---|---|---|---|---|
| C1 | Sinusoidal | MHA | LayerNorm | Byte-BPE |
| C2 | RoPE | MHA | LayerNorm | Byte-BPE |
| C3 | Sinusoidal | GQA | LayerNorm | Byte-BPE |
| C4 | Sinusoidal | MHA | RMSNorm | Byte-BPE |
| C5 | Sinusoidal | MHA | LayerNorm | Simplified BLT |
C1βC4 use 8-bit byte grouping followed by BPE source tokenization. C5 uses a token-free byte-level pipeline based on a simplified Byte Latent Transformer (BLT).
Common training setup
- Model dimension (
d_model): 256 - Attention heads: 8
- Encoder layers: 4
- Decoder layers: 4
- Feed-forward dimension (
d_ff): 1024 - Learning rate:
1e-4 - Batch size: 8
- Epochs: 30
- Maximum sequence length: 1024
- Optimizer: AdamW
- Random seed: 42
- Final decoding: greedy decoding
The final C1βC5 comparison uses 128-byte aligned dataset segmentation.
Byte-BPE preprocessing
For C1βC4:
binary ciphertext
β
group every 8 bits
β
byte values (0β255)
β
BPE tokenization
β
Transformer
The ciphertext/plaintext pairs are aligned. For segmented experiments, each aligned example is divided into 128-byte segments before tokenization.
C5 β Simplified BLT
C5 operates directly on bytes rather than using BPE:
ciphertext bits
β
8-bit bytes
β
byte patches
β
local byte encoder
β
global Transformer
β
local byte decoder
β
predicted bytes
The current implementation uses fixed 8-byte patches. The global Transformer therefore operates on patch representations instead of individual byte positions.
Checkpoint format
Each model.pt file is a PyTorch checkpoint containing:
- model state dictionary
- configuration name
- model dimensions
- vocabulary/output size
- maximum sequence length
- source tokenization
- segmentation setting
- training epoch
- training loss
- validation loss
- special-token IDs
- random seed
Loading a checkpoint
import torch
checkpoint = torch.load(
"model.pt",
map_location="cpu",
weights_only=False,
)
print("Configuration:", checkpoint["config"])
print("Validation loss:", checkpoint["val_loss"])
model.load_state_dict(checkpoint["model_state_dict"])
The custom model architecture from the accompanying assignment source code is required to instantiate the model before loading the state dictionary.
Experiment tracking
Training runs were logged using Weights & Biases.
W&B project:
https://wandb.ai/skv-balasubramanian-iiit-hyderabad/anlp_assignment1
Assignment
Course: Advanced Natural Language Processing
Assignment: Transformers from Scratch, Architectural Variants, and Byte Latent Transformers (BLT)