/ Модель

Характеристики

Контекст
1 024 токена
Лицензия
MIT
Архитектура
noisy_gpt2 · dense
Базовая модель
gpt2
Библиотека
transformers
Опубликована
14 сен 2026

stoch_norm_gpt2_small

Генерация текстаТекст → текст3 профессии

Экспериментальная англоязычная версия GPT-2 small с шумом в LayerNorm для изучения распределения информации и генерации продолжения текста.

389скачиваний за 30 дней0лайковвеса обновлены15 сен 2026

Бенчмарки

Как модель справилась с задачами пользователей ailist и что о ней публикуют открытые лидерборды

Публичные оценки

Из открытых лидербордов. Сравнивайте результаты одного теста при одинаковых условиях — отсутствие оценки не значит, что модель хуже.

В подключённых источниках результатов для этой модели пока нет.

Что умеет модель

Описание составлено по карточке модели и метаданным Hugging Face

murphysics999/stoch_norm_gpt2_small — исследовательская производная GPT-2 small, созданная для изучения того, сколько информации трансформер передаёт через отдельные операции чтения LayerNorm. Модель содержит около 124 млн параметров и основана на openai-community/gpt2. В каждой из 25 операций LayerNorm добавляется гауссовский шум с обучаемым масштабом; значения масштабов совместно обучались с весами при фиксированном общем информационном бюджете. Шум включён по умолчанию, в том числе при оценке и генерации.

Модель предназначена для генерации продолжения англоязычного текста и экспериментов по интерпретируемости и распределению информации в трансформере. Она дообучалась дистилляцией распределений следующих токенов исходной GPT-2 на OpenWebText. В оценке на отложенной части OpenWebText перплексия составила 31,85 против 25,22 у детерминированной GPT-2 small, поэтому модель не является улучшенной заменой исходной. Контекст — 1024 токена. Для загрузки требуется Transformers с trust_remote_code=True и пользовательским кодом модели. Лицензия — MIT.

Сценарии применения

  • генерация продолжения англоязычного текста
  • изучение распределения информации между слоями трансформера
  • анализ влияния шума в LayerNorm на предсказание следующего токена

Ограничения

Модель уступает исходной GPT-2 small по перплексии и предназначена для исследований, а не как улучшенная языковая модель. Она наследует предвзятости и склонность GPT-2 к ложному или оскорбительному тексту; шум включён постоянно, а загрузка требует trust_remote_code=True.

Для каких профессий подходит3

Разделы каталога профессий, в задачах которых используется эта модель

Все профессии

Карточка модели

README от автора на Hugging Face, как он его опубликовал

Открыть на Hugging Face

GPT-2 small with a stochastic LayerNorm channel (σ_g = 0.5)

GPT-2 small (124M), fine-tuned so that every LayerNorm read is noisy. Each of the 25 LayerNorms (ln_1/ln_2 in all 12 blocks, plus ln_f) normalizes its input, adds isotropic Gaussian noise with a learned per-LayerNorm scale σ, then normalizes again before its gain and bias:

x̂ = normalize(x)
x̂ = normalize(x̂ + σ · ε),   ε ~ N(0, I)
out = x̂ · weight + bias

The σ values were learned during training under a fixed total information budget, so each σ says how much information the network chose to let through that read. The weights are ordinary GPT-2 weights; the noise lives in the LayerNorm forward pass, shipped as custom code.

The noise is part of the model. It is on by default, including in eval() and generate(), and the model was only ever trained with it on.

Usage

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

repo = "murphysics999/stoch_norm_gpt2_small"
tok = AutoTokenizer.from_pretrained(repo, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(repo, trust_remote_code=True).eval()

torch.manual_seed(0)  # the noise draws come from torch's RNG
inputs = tok("The history of the city begins", return_tensors="pt")
out = model.generate(**inputs, max_new_tokens=40, do_sample=True, top_p=0.95)
print(tok.decode(out[0], skip_special_tokens=True))

trust_remote_code=True is required: it loads modeling_noisy_gpt2.py (about 80 lines; read it first). Pass it to AutoTokenizer as well, or transformers asks interactively. Tested with transformers 4.57.1 and 5.9.0, which give bit-identical outputs for the same seed on CPU.

Things to know:

  • Every forward pass is a random draw. Even greedy decoding varies across seeds; fix torch.manual_seed for reproducibility. To get the model's predictive distribution for a context, average the softmax over several draws (e.g. repeat the context along the batch).
  • KV cache. With the cache (the default), each position's noise is drawn once and reused on later steps, which is exactly the joint distribution of a single training forward pass. With use_cache=False, every step redraws the noise for the whole prefix.
  • Precision. The LayerNorm arithmetic always runs in float32, whatever dtype the model is loaded in, so fp16/bf16 loading is safe.
  • Per-tap noise levels are in model.config.tap_sigmas, keyed by module name, and in policy.json with κ and rate.
  • model.set_noise(False) switches to a deterministic pass through the same weights. That is not the trained model: training never ran without noise, and in our experiments the noise-off pass has misrepresented the noisy model's behaviour. Use it only if you specifically need it.

Evaluation

OpenWebText held-out split: the last 5,000 documents, never trained on; 5,666,990 tokens, 512-token blocks, bf16 autocast.

modelperplexitynext-token top-1 accKL(GPT-2 ‖ model), nats/token
this model (noise on, mean of 3 draws)31.85 ± 0.010.3700.270
GPT-2 small, deterministic25.220.3990

GPT-2 was pretrained on WebText, which OpenWebText recreates, so its row is not strictly held-out for GPT-2 itself. The "±" is the SD across full-split noise draws.

How the noise levels were set

Reads live on the unit sphere of the 767-dimensional mean-zero hyperplane (p = 767). Each noisy read is modelled as a von Mises-Fisher distribution with concentration κ, matched to σ on mean cosine. Its rate is KL(vMF(κ) ‖ uniform): the information, in nats per token position, that the read can carry about its input. For the actual Gaussian-then-renormalize channel this matches exact 1-D quadrature and a Monte Carlo estimate to within about 0.1%.

Training fixes a total budget B = 25 · rate(σ_g): what 25 reads at a uniform σ_g = 0.5 would carry, 15,418 nats (22,243 bits) per token position. A learned softmax over the 25 LayerNorms splits B between them, and σ at each LayerNorm follows from its share. The allocation is trained jointly with the weights.

Learned allocation, in depth order:

LayerNormσκrate (bits)
h.0.ln_10.4564,052972.9
h.0.ln_20.3008,9041,379.6
h.1.ln_13.09726054.9
h.1.ln_2 (floor)10.101765.4
h.2.ln_10.5672,737781.0
h.2.ln_20.5852,593755.5
h.3.ln_10.5323,070836.2
h.3.ln_20.4544,076975.9
h.4.ln_10.5402,982822.0
h.4.ln_20.4713,813942.6
h.5.ln_10.5073,345878.0
h.5.ln_20.4404,3211,005.2
h.6.ln_10.6232,323704.0
h.6.ln_20.4204,7191,049.8
h.7.ln_10.5562,834797.7
h.7.ln_20.4114,9031,069.3
h.8.ln_10.6402,223683.7
h.8.ln_20.3945,3011,109.2
h.9.ln_10.6202,347708.7
h.9.ln_20.3925,3571,114.5
h.10.ln_10.4903,549907.1
h.10.ln_20.3815,6461,141.6
h.11.ln_1 (floor)10.101765.4
h.11.ln_20.3476,7351,233.0
ln_f0.12350,6382,320.6

2 LayerNorm(s) sit at the rate table's floor (σ = 10.1); the network all but switched those reads off. Such reads were charged about 0 by the budget but still carry the floor rate, which is the value shown. Total rate actually carried: 15,425 nats.

Training

  • Initialization: pretrained GPT-2 small.
  • Objective: distillation only. Minimize KL(frozen GPT-2 ‖ noisy model) over next-token distributions (T = 1.0); no cross-entropy term.
  • Data: OpenWebText, GPT-2 tokenizer, an EOS token between documents, packed into 512-token blocks.
  • Schedule: 25 epochs × 5000 steps × batch 32 = 2.05B tokens. AdamW, lr 0.0001 with cosine decay to 1e-06 after 0.2 epochs of warmup, weight decay 0.005 (none on biases or LayerNorm parameters), gradient clipping 1.0, bf16 autocast, dropout 0. Allocation logits trained with lr 0.006.
  • Noise ramp: the budget was ramped geometrically from σ_g = 0.05 to 0.5 over the first 6 epochs.

Intended use and limitations

This is a research artifact for studying how much information a transformer routes through each read, not an improved language model: it is somewhat worse than GPT-2 by perplexity, and it inherits GPT-2's biases and failure modes, including offensive and false text. English only.

Citation

Tracing distinguishability through transformer processing with stochastic LayerNorm, Kieran Murphy, 2026 [arxiv]

Как запустить

На своей GPU в ailist. Цена — по текущим предложениям провайдеров

GPU в ailist

Универсальный рантайм · transformers

Нельзя запустить

Модели нужен код из репозитория; автор пока не в списке доверенных организаций.

Класс архитектуры
NoisyGPT2LMHeadModel
Ревизия весов
f06340a

0 моделей