Instructions to use McGill-NLP/TLM-230M with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use McGill-NLP/TLM-230M with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="McGill-NLP/TLM-230M")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, GPTNeoForCausalLMTiered tokenizer = AutoTokenizer.from_pretrained("McGill-NLP/TLM-230M") model = GPTNeoForCausalLMTiered.from_pretrained("McGill-NLP/TLM-230M", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use McGill-NLP/TLM-230M with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "McGill-NLP/TLM-230M" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "McGill-NLP/TLM-230M", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/McGill-NLP/TLM-230M
- SGLang
How to use McGill-NLP/TLM-230M with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "McGill-NLP/TLM-230M" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "McGill-NLP/TLM-230M", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "McGill-NLP/TLM-230M" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "McGill-NLP/TLM-230M", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use McGill-NLP/TLM-230M with Docker Model Runner:
docker model run hf.co/McGill-NLP/TLM-230M
Add TLM-230M (tiered_pretrain_240m_5pct final-checkpoint) + 5% permutation key
Browse files- README.md +89 -0
- config.json +54 -0
- generation_config.json +9 -0
- key_5pct.json +0 -0
- model.safetensors +3 -0
- tokenizer.json +0 -0
- tokenizer_config.json +12 -0
README.md
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
library_name: transformers
|
| 4 |
+
pipeline_tag: text-generation
|
| 5 |
+
datasets:
|
| 6 |
+
- HuggingFaceFW/fineweb
|
| 7 |
+
language:
|
| 8 |
+
- en
|
| 9 |
+
tags:
|
| 10 |
+
- tiered-alignment
|
| 11 |
+
- gpt_neo
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
# TLM-230M
|
| 15 |
+
|
| 16 |
+
A **Tiered Language Model (TLM)** pretrained with [Tiered Alignment](https://github.com/charbel08/permutation-alignment):
|
| 17 |
+
one set of weights that exposes **two behavioral tiers**, toggled by a secret permutation key.
|
| 18 |
+
|
| 19 |
+
- **Public tier (C1)** — what you get by loading the weights normally. Open to everyone.
|
| 20 |
+
- **Keyed tier (C2)** — reached by applying `key_5pct.json`, which permutes 5% of the
|
| 21 |
+
attention heads and MLP columns. The permutation is self-inverse, so applying it toggles
|
| 22 |
+
between the two tiers over the *same* underlying parameters.
|
| 23 |
+
|
| 24 |
+
`TLM-230M` is the **240m rung** of a scaling ladder. Its non-keyed counterpart
|
| 25 |
+
(identical architecture and token budget, trained without a key) is the baseline used for
|
| 26 |
+
all public-tier comparisons.
|
| 27 |
+
|
| 28 |
+
## Files
|
| 29 |
+
|
| 30 |
+
| File | What it is |
|
| 31 |
+
|---|---|
|
| 32 |
+
| `model.safetensors` | Weights in the **C1 (public)** configuration |
|
| 33 |
+
| `key_5pct.json` | The secret permutation key — swaps over `attn_heads` and `mlp_cols` |
|
| 34 |
+
| `config.json`, `tokenizer.json` | GPT-Neo config; GPT-2 BPE tokenizer (vocab 50257) |
|
| 35 |
+
|
| 36 |
+
Optimizer state is **not** included; these checkpoints are for inference and evaluation.
|
| 37 |
+
|
| 38 |
+
## Usage
|
| 39 |
+
|
| 40 |
+
The weights require `GPTNeoForCausalLMTiered`, **not** stock `GPTNeoForCausalLM`:
|
| 41 |
+
this architecture defines `lm_head` with `bias=True`, and loading through
|
| 42 |
+
`AutoModelForCausalLM` silently drops that trained bias.
|
| 43 |
+
|
| 44 |
+
```python
|
| 45 |
+
from tiered.model import GPTNeoForCausalLMTiered
|
| 46 |
+
from tiered.permutation import load_key, apply_permutation, unapply_permutation
|
| 47 |
+
|
| 48 |
+
model = GPTNeoForCausalLMTiered.from_pretrained("McGill-NLP/TLM-230M")
|
| 49 |
+
key = load_key("key_5pct.json") # downloaded from this repo
|
| 50 |
+
|
| 51 |
+
# C1 (public) — the state the weights ship in
|
| 52 |
+
logits_public = model(input_ids).logits
|
| 53 |
+
|
| 54 |
+
apply_permutation(model, key) # -> C2 (keyed)
|
| 55 |
+
logits_keyed = model(input_ids).logits
|
| 56 |
+
|
| 57 |
+
unapply_permutation(model, key) # back to C1, bit-exactly
|
| 58 |
+
```
|
| 59 |
+
|
| 60 |
+
## Model details
|
| 61 |
+
|
| 62 |
+
| | |
|
| 63 |
+
|---|---|
|
| 64 |
+
| Total parameters | **229,137,745** |
|
| 65 |
+
| Layers / hidden / heads | 16 / 768 / 12 |
|
| 66 |
+
| MLP ratio / context | 8 / 2048 |
|
| 67 |
+
| Training tokens | 22.91B (100x total params) |
|
| 68 |
+
| Steps / global batch | 49,948 / 224 seqs |
|
| 69 |
+
| Peak LR / warmup | 3.9e-4 / 1000 steps |
|
| 70 |
+
| Data | [FineWeb]( https://huggingface.co/datasets/HuggingFaceFW/fineweb) (retain split) |
|
| 71 |
+
| Key coverage | 5% |
|
| 72 |
+
|
| 73 |
+
Architecture follows the DataDecide ladder ([arXiv:2504.11393](https://arxiv.org/abs/2504.11393)):
|
| 74 |
+
interpolated between the 150M and 300M rungs (log-linear in total params, fraction 0.3033).
|
| 75 |
+
|
| 76 |
+
## A note on the ladder's names
|
| 77 |
+
|
| 78 |
+
Repository names here are **total parameter counts**, rounded. The underlying DataDecide rung
|
| 79 |
+
labels are *not* parameter counts, so the two orderings differ — the "90M" rung has 117M total
|
| 80 |
+
parameters, more than the "100M" rung's 99M. Ordered by actual size, the ladder runs:
|
| 81 |
+
|
| 82 |
+
> TLM-20M, TLM-40M, TLM-70M, TLM-100M, TLM-120M, TLM-180M, TLM-230M, TLM-650M
|
| 83 |
+
|
| 84 |
+
`TLM-180M` predates this ladder and uses 12 layers rather than 16, so it is not architecturally
|
| 85 |
+
part of it; treat it separately when fitting scaling curves.
|
| 86 |
+
|
| 87 |
+
## Citation
|
| 88 |
+
|
| 89 |
+
Code: https://github.com/charbel08/permutation-alignment
|
config.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"activation_function": "gelu_new",
|
| 3 |
+
"architectures": [
|
| 4 |
+
"GPTNeoForCausalLMTiered"
|
| 5 |
+
],
|
| 6 |
+
"attention_dropout": 0.0,
|
| 7 |
+
"attention_layers": [
|
| 8 |
+
"global",
|
| 9 |
+
"local",
|
| 10 |
+
"global",
|
| 11 |
+
"local",
|
| 12 |
+
"global",
|
| 13 |
+
"local",
|
| 14 |
+
"global",
|
| 15 |
+
"local",
|
| 16 |
+
"global",
|
| 17 |
+
"local",
|
| 18 |
+
"global",
|
| 19 |
+
"local",
|
| 20 |
+
"global",
|
| 21 |
+
"local",
|
| 22 |
+
"global",
|
| 23 |
+
"local"
|
| 24 |
+
],
|
| 25 |
+
"attention_types": [
|
| 26 |
+
[
|
| 27 |
+
[
|
| 28 |
+
"global",
|
| 29 |
+
"local"
|
| 30 |
+
],
|
| 31 |
+
8
|
| 32 |
+
]
|
| 33 |
+
],
|
| 34 |
+
"bos_token_id": 50256,
|
| 35 |
+
"classifier_dropout": 0.1,
|
| 36 |
+
"dtype": "float32",
|
| 37 |
+
"embed_dropout": 0.0,
|
| 38 |
+
"eos_token_id": 50256,
|
| 39 |
+
"hidden_size": 768,
|
| 40 |
+
"initializer_range": 0.02,
|
| 41 |
+
"intermediate_size": 6144,
|
| 42 |
+
"layer_norm_epsilon": 1e-05,
|
| 43 |
+
"max_position_embeddings": 2048,
|
| 44 |
+
"model_type": "gpt_neo",
|
| 45 |
+
"num_heads": 12,
|
| 46 |
+
"num_layers": 16,
|
| 47 |
+
"pad_token_id": null,
|
| 48 |
+
"resid_dropout": 0.0,
|
| 49 |
+
"tie_word_embeddings": true,
|
| 50 |
+
"transformers_version": "5.5.4",
|
| 51 |
+
"use_cache": false,
|
| 52 |
+
"vocab_size": 50257,
|
| 53 |
+
"window_size": 256
|
| 54 |
+
}
|
generation_config.json
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_from_model_config": true,
|
| 3 |
+
"bos_token_id": 50256,
|
| 4 |
+
"eos_token_id": 50256,
|
| 5 |
+
"output_attentions": false,
|
| 6 |
+
"output_hidden_states": false,
|
| 7 |
+
"transformers_version": "5.5.4",
|
| 8 |
+
"use_cache": false
|
| 9 |
+
}
|
key_5pct.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:40fc508673f6ab1605dc2b6a8c873a30e6727391e348f29ba0bc29c5753d197a
|
| 3 |
+
size 916573668
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_prefix_space": false,
|
| 3 |
+
"backend": "tokenizers",
|
| 4 |
+
"bos_token": "<|endoftext|>",
|
| 5 |
+
"eos_token": "<|endoftext|>",
|
| 6 |
+
"errors": "replace",
|
| 7 |
+
"is_local": false,
|
| 8 |
+
"model_max_length": 1024,
|
| 9 |
+
"pad_token": "<|endoftext|>",
|
| 10 |
+
"tokenizer_class": "GPT2Tokenizer",
|
| 11 |
+
"unk_token": "<|endoftext|>"
|
| 12 |
+
}
|