code-switch-mtp-heads
Trained draft heads for the project code-switch-mtp (lossless multi-token drafting for Hindi on a frozen Llama-3.2-1B).
These files contain only the trained head weights. They contain no weights
of the backbone: no embedding matrix, no output layer, no transformer layers.
Every file was opened and checked for this before upload. To use them you need
meta-llama/Llama-3.2-1B, obtained separately from Meta's repository.
What the heads are
The backbone is frozen. A shared trunk block and one residual block per head read the backbone's last hidden state; every head reuses the backbone's own output layer, which is why it is not stored here. Head 0 predicts the next token. Each look-ahead head predicts one token further ahead and also reads the embeddings of the tokens drafted before it ("dependent heads"). The targets of the look-ahead heads are the backbone's own greedy outputs ("backbone targets"), so that a draft is accepted exactly when it equals what the backbone would have produced.
Training, same for every file: 10M tokens, batches of 2 x 512 tokens, AdamW, learning rate 1e-4, look-ahead loss weight 0.1, fp32, 9,765 steps.
Files
Each file is <folder>/<condition>_seed<seed>/dependent_teacher.pt, a PyTorch
state dict.
| Folder | Look-ahead heads | Trainable parameters | Size per file | Conditions and seeds | Training text |
|---|---|---|---|---|---|
three_look_ahead_heads/ |
3 | 46.1M | 177 MB | Devanagari, ITRANS, IAST, ISO, English; seeds 0, 1, 2 | Hindi (Sangraha) in Devanagari and in three romanizations; English Wikipedia |
five_look_ahead_heads/ |
5 | 92.3M | 353 MB | Devanagari seeds 0, 1, 2; ITRANS seed 0; English seed 0 | as above |
three_heads_code_switch_enriched/ |
3 | 46.1M | 177 MB | Devanagari seeds 0, 1 | Devanagari training text in which the 1,172 training blocks richest in Latin-script words are repeated 5 times (30% of the budget) |
three_heads_devanagari_plus_english/ |
3 | 46.1M | 177 MB | Devanagari seed 0 | 8M Devanagari tokens and 2M English Wikipedia tokens |
Conditions: Devanagari is Hindi in its native script; ITRANS, IAST and ISO are the same Hindi text romanized by three schemes; English is English Wikipedia.
Loading
With the code repository checked out:
import torch
from pathlib import Path
from transformers import AutoModelForCausalLM
from scripts.phase5_dependent_eval import load_arm # needs the repository's scripts/ on the path
backbone = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-3.2-1B", dtype=torch.float32).eval()
stack = load_arm(backbone, Path("three_look_ahead_heads/Devanagari_seed0/dependent_teacher.pt"), True, n_heads=4)
# five look-ahead heads: n_heads=6
scripts/phase5_tree_decode_timing.py in the code repository runs the lossless
decoder (draft tree, copied branch, one verifying backbone pass per round).
Results these heads produced
Measured end to end on one GTX 1080 Ti, fp32, batch size 1, greedy decoding, output identical to greedy decoding on every document: 2.9x greedy speed on Hindi (Devanagari, mean of 3 seeds) and 4.9x on Hindi (ITRANS, seed 0) with three look-ahead heads, a 4,352-token shortlist, a draft tree and 12 copied tokens at 16 verified tokens per round. Part of the romanized figure comes from the model restating its prompt. Tables and logs are in the code repository.
Licence note
This project trains and evaluates prediction heads on top of the frozen meta-llama/Llama-3.2-1B model. The model weights are not distributed here; they must be obtained from Meta's repository at https://huggingface.co/meta-llama/Llama-3.2-1B under its own terms.
Llama 3.2 is licensed under the Llama 3.2 Community License, Copyright (c) Meta Platforms, Inc. All Rights Reserved. License text: https://huggingface.co/meta-llama/Llama-3.2-1B/blob/main/LICENSE.txt Acceptable use policy: https://www.llama.com/llama3_2/use-policy
No licence has been chosen yet for the head weights themselves.
Model tree for Anupam-Rawat-IITB/code-switch-mtp-heads
Base model
meta-llama/Llama-3.2-1B