/ Модель

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

Контекст
40 960 токенов
Параметры
3,7 млрд
Лицензия
Apache 2.0
Архитектура
qwen3_sleep · dense
Базовая модель
Qwen3-4B
Библиотека
transformers
Опубликована
2 дек 2026

SleepyInkling-Qwen3-4B

Генерация текстаТекст → текст
277скачиваний за 30 дней0лайковвеса обновлены2 дек 2026

Описание модели

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

Дообученная на базе Qwen3-4B модель для генерации текста и диалогов с дополнительным режимом Sleep для уточнения KV-кэша.

SleepyInkling-Qwen3-4B — дообученная модель bmswheart на базе Qwen/Qwen3-4B с архитектурой Qwen3SleepForCausalLM, примерно 3,7 млрд параметров. Она предназначена для генерации текста и диалогов с дополнительными проходами Sleep, которые уточняют состояния KV-кэша; в README описаны сценарии синтеза и анализа кода, работы с инструментами, технического письма, математических рассуждений и ответов на вопросы по нескольким окнам контекста. Модель принимает текст и выдаёт текст, поддерживает контекст до 40 960 токенов; README сообщает результаты извлечения сведений примерно до 21 тыс. токенов, но длины свыше этого значения не оценивались.

Обычные вызовы model() и model.generate() работают в режиме Wake без Sleep-адаптации; для консолидации контекста нужно вызывать специальные методы forward_sleep() или generate_sleep(). В режиме Sleep ключи внимания по умолчанию остаются неизменными, а уточняются значения KV-кэша. Для Sleep требуется backend sdpa или eager; FlashAttention-2 и FlexAttention не поддерживаются. Заявлены компромиссы в отдельных подзадачах, а режим LoopCD может ухудшать длинные математические рассуждения. Лицензия — Apache-2.0.

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

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

Ограничения

Стандартные вызовы model() и model.generate() обходят режим Sleep, для которого нужны специальные методы и backend sdpa или eager. Извлечение сведений при длине свыше примерно 21 тыс. токенов не оценивалось; некоторые подзадачи, включая трассировку Python, могут ухудшаться.

Публичные бенчмарки

Результаты из открытых лидербордов в сравнении с лидерами каталога

Публичных оценок пока нет

В подключённых источниках результатов этой модели не нашлось. Отсутствие оценки не значит, что модель хуже: её могли просто не проверять.

Источники: Hugging Face Leaderboards, Hugging Face Eval Results, Open LLM v2, MTEB, timm, Open ASR, EvalPlus, LLM Stats

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

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

Открыть на Hugging Face

SleepyInkling-Qwen3-4B (bmswheart/SleepyInkling-Qwen3-4B)

By Brian Wasielewski (brianmswheart) and Jeff Bander, MD (jeffbander)

SleepyInkling-Qwen3-4B is a Frozen-Wake Value-Only Sleep KV Consolidation + Bounded MessageGate Recurrence retrofit of Qwen/Qwen3-4B, combining the Wake–Sleep KV-Cache Refinement method of Sangyun Lee et al. ("Sample-Efficient In-Context Adaptation via Sleep", arXiv:2611.32802) with a Layer-0 rank-64 tanh forget/gain recurrence bridge inspired by Thinking Machines Lab's thinkingmachines/Inkling-2-Mini (Inkling2LoopMessageGate, Apache-2.0).

Unlike full-backbone fine-tunes, SleepyInkling-Qwen3-4B keeps all 4.02B base Qwen/Qwen3-4B weights frozen and untouched during Wake (N=1) and ships with Value-Only Sleep (sleep_v_only: true) enabled by default—keeping all attention Keys (K) 100% bit-exact Frozen-Wake while consolidating Values (V) in place during periodic Sleep passes (l = 2..N). On NVIDIA CUDA GB10 (BF16, n = 344 greedy items against untouched stock Qwen/Qwen3-4B), default N=2 Value-Only Sleep delivers 261/344 (75.9%) vs stock Base 241/344 (70.1%) (+5.81 pp, 33W / 298T / 13L, exact two-sided McNemar p = 0.0045, 95% bootstrap CI [+2.03, +9.59] pp), led by Multi-Window Cross-Document Synthesis QA (56/72 = 77.8% vs 42/72 = 58.3%, +19.44 pp, p = 0.0066) with zero regression on GSM8K 8-Shot (100/120 = 83.3% vs 99/120 = 82.5%) and 24/24 (100.0%) ~21K RULER long-context needle retrieval, while independently replicating on Apple Silicon M3 Ultra MLX (101/136 = 74.3%, +8.09 pp vs Wake, p = 0.0266; 12/12 ~21K RULER).

It is also distributed as a compact 163.46 MiB plug-in Sleep adapter (bmswheart/SleepyInkling-Qwen3-4B-adapter, 651 FP16 tensors, 85.66M params = 2.13% of base) that activates exclusively during periodic Sleep consolidation passes while leaving the KV cache sequence length unchanged.

Credit & Contributions

  • From Lee et al. (arXiv:2611.32802): Sangyun Lee, Enyan Zhang, Michael Xu, Hao Tang, Zinan Lin, Weijia Xu, Chris Quirk, Jianfeng Gao, Giulia Fanti, and Xiaodong Liu invented and formulated Wake–Sleep KV refinement, periodic window-bidirectional consolidation passes, and GRU-style KV write gates.
  • Inspired by Thinking Machines Lab (thinkingmachines/Inkling-2-Mini, Apache-2.0): Rank-64 tanh forget/gain message gating (Inkling2LoopMessageGate) and loop-contrastive hidden decoding (LoopCD), adapted here into Layer 0's MessageGateSleepBridge and --loopcd-omega.
  • Base Model: Qwen/Qwen3-4B by the Qwen Team (Alibaba Cloud, Apache-2.0, arXiv:2505.09388).
  • Added in this release: Frozen-Wake isolation (all base weights untouched at N=1), Value-Only Sleep (sleep_v_only: true default), Sleep-only LoRA (r=32), Layer-0 MessageGateSleepBridge (rank=64), Wake-KL consolidation anchor (λ = 0.50), plug-in adapter extraction/application, and multi-runtime inference wrappers across PyTorch/CUDA, Apple Silicon MLX, native Apple Silicon Metal (ASOR), and OpenAI-compatible serving.
  • Release Contributors: Brian Wasielewski (brianmswheart) and Jeff Bander, MD (jeffbander) (personal release).
  • Apache-2.0 §4(b) Notice: Adds Frozen-Wake Value-Only Sleep KV write gates, Sleep-only LoRA, Layer-0 MessageGateSleepBridge, and multi-runtime inference wrappers; base Qwen/Qwen3-4B weights unmodified.

Architecture & Plug-In Adapter Summary

Building on Lee et al. (arXiv:2611.32802) with Frozen-Wake isolation, Value-Only KV consolidation, and bounded recurrence gating:

  • Frozen Wake (l = 1): Runs unmodified Qwen/Qwen3-4B weights in Wake-only mode (overall |Δ NLL| ≤ 0.00111 nats across all 4 NLL suites, and 336/344 = 97.7% exact item agreement with untouched stock Qwen/Qwen3-4B across the n = 344 greedy generation/RULER benchmark, p = 0.727; rare tie-breaks stem from windowed explicit-mask SDPA vs stock causal kernel). Standard model() and model.generate() execute N=1 Wake-only; call forward_sleep() or generate_sleep() for N ≥ 2 Sleep.
  • Value-Only Sleep (sleep_v_only: true default): During Sleep passes (l = 2..N), attention Keys (K) remain 100% bit-exact Frozen-Wake—preserving exact RoPE positional addressing up to long context and eliminating early-needle routing drift—while Sleep consolidates Values (V) in place via the per-KV-head GRU write gates (sleep_gate_v). All sleep_gate_k weights remain included in the v3d 651-tensor adapter for full backwards compatibility (v_only=False opt-in).
  • Periodic Bidirectional Sleep (l = 2..N, window W = 256): At every 256-token window boundary (or opportunistically via sleep_now() in MLX), the engine runs N − 1 full-stack passes over the uncommitted window with bidirectional intra-window attention and causal visibility over all prior consolidated windows.
  • Layer-0 MessageGateSleepBridge (rank = 64): Bounded RMSNorm + tanh gated recurrence bridge anchoring Sleep passes onto Layer 0's token-embedding manifold using the post-final-norm hidden state h_prev: z = W_down @ [RMSNorm(h_embed), RMSNorm(h_prev)], forget = tanh(W_forget @ z), gain = tanh(W_gain @ z), h_in = (1 - forget) * h_embed + gain * h_prev, where (1 - forget) ∈ (0, 2) and gain ∈ (-1, 1). Zero-init of W_forget and W_gain guarantees exact identity (h_in == h_embed) at initialization; trained v3d weights are verified non-zero (down abs-mean 0.00709, forget 0.00110, gain 0.00110).
  • Sleep-Only LoRA (r = 32, α = 64): 504 FP16 tensors across all 36 layers (q/k/v/o + gate/up/down MLP) that fire strictly inside Sleep passes (l ≥ 2) and are completely bypassed during Wake (l = 1).
  • In-Place Per-KV-Head GRU KV Write Gates (constant KV sequence length): 144 FP16 tensors (sleep_gate_{k,v}.{weight,bias}, init_bias = 3.0) blending refined values (V_new by default under sleep_v_only: true, or (K_new, V_new) when v_only=False) into the active window's existing KV slots in FP32 before casting back to the cache dtype.
  • Training Recipe & Data Mix (v3d): Frozen-Wake retrofit on Qwen/Qwen3-4B with randomized loop curriculum N ∈ {2, 2, 3, 4}, Wake-KL anchor λ = 0.50 (constrains post-Sleep Wake logit distributions from drifting too far from frozen Wake logits while consolidating KV states), 120 optimizer steps (32,768 tok/step, seq_len = 2048) on NVIDIA GB10 (BF16). Training data combined synthetic/curated coding, tool-use, technical prose, and a 15% math CoT mix; the in-domain holdout split is drawn from the same curated pipeline (no overlap with OOD WikiText-103 test or Python 3.12 stdlib).

Plug-In Adapter Artifact (bmswheart/SleepyInkling-Qwen3-4B-adapter)

FieldVerified Value
Adapter Filesleep_adapter.safetensors
Exact Size163.46 MiB (171,403,008 bytes)
Tensor Count / Dtype651 FP16 tensors (85,663,744 params = 2.13% of Qwen3-4B)
Tensor Breakdown144 KV write gates (sleep_gate_v active by default; sleep_gate_k included for v_only=False) + 504 Sleep-Only LoRA + 3 MessageGateSleepBridge (down, forget, gain)
Default Sleep Modesleep_v_only: true (num_loops = 2, window_size = 256; Keys 100% Frozen-Wake)
Base Overlap0 overlapping keys with the 398 base Qwen/Qwen3-4B tensors (1,049 total unique tensors with tied embeddings)
SHA-25622bb77fd9a8a9eb0743bf9096a7c3d311bd0c7d35e684fca43520cfdefaea5b6

Verified Benchmarks (SleepyInkling-Qwen3-4B)

1. NVIDIA CUDA GB10 BF16 — Multi-Window NLL (2,048-Token Contexts = 8 × W=256, Default sleep_v_only: true & K+V Comparison)

All 4 evaluation suites improve on 7/7 post-Sleep windows under both default sleep_v_only: true (k_update_scale = 0.0, v_update_scale = 1.0) and legacy K+V (v_only=False), while N=1 stays within |Δ NLL| ≤ 0.00111 nats (-0.00111 to +0.00039) of stock Qwen/Qwen3-4B. Default Value-Only Sleep matches or surpasses K+V on OOD Python (N=4: -0.1883 vs -0.1776) and OOD ICL (N=2: -0.0127 vs -0.0118; N=4: -0.0123 vs -0.0086) while keeping Keys 100% bit-exact Frozen-Wake. On CUDA GB10 (PyTorch 2.11.0+cu130, transformers 5.14.1), N=2 takes ~1.86×–1.93× wall-time vs N=1 (~3.1× vs stock causal SDPA) and N=4 takes ~3.63×–3.77× vs N=1 (~6.0× vs stock causal SDPA).

Evaluation Suite (n_chunks × 2048)Base Qwen3-4B (overall)N=1 (Wake-Only)N=1 − BaseN=2 V-Only Default (d2)N=4 V-Only Default (d4)Legacy K+V (d2 / d4)Post-Sleep Windows Won (N=2)
In-Domain Holdout* (24 × 2048)1.57711.5760-0.00111-0.4218 (1.5310 → 1.1092)-0.4817 (1.5310 → 1.0493)-0.4392 / -0.48567/7
OOD WikiText-103 Test (24 × 2048)2.56732.5673+0.00001-0.2674 (2.5111 → 2.2437)-0.2822 (2.5111 → 2.2289)-0.2708 / -0.28307/7
OOD Python 3.12 Stdlib (24 × 2048)1.40651.4066+0.00007-0.1717 (1.3187 → 1.1470)-0.1883 (1.3187 → 1.1304)-0.1718 / -0.17767/7
OOD ICL Novel Schema (16 × 2048)0.62090.6213+0.00039-0.0127 (0.4446 → 0.4319)-0.0123 (0.4446 → 0.4323)-0.0118 / -0.00867/7

*Caveats: In-Domain Holdout shares the training distribution's formatting/domain mix, so its larger NLL drop (-0.4218 vs WikiText -0.2674) reflects in-domain adaptation rather than pure OOD gain. OOD WikiText-103 and Python 3.12 stdlib have zero overlap with training. Window win counts (7/7) are averaged across chunks at each window position (n = 24 / 24 / 24 / 16 chunks).

2. NVIDIA CUDA GB10 BF16 — Large-n Downstream & Long-Context Head-to-Head vs Untouched Qwen/Qwen3-4B (n = 344)

Measured head-to-head on NVIDIA GB10 (BF16, temperature = 0, identical prompts across all 3 arms) comparing untouched upstream Qwen/Qwen3-4B Base, SleepyInkling-Qwen3-4B N=1 (Wake-Only), and SleepyInkling-Qwen3-4B N=2 Value-Only (sleep_v_only: true, default):

Benchmark Suite (temperature = 0)Context / FormatStock Base Qwen/Qwen3-4BN=1 (Wake-Only)N=2 Value-Only (Default)N=2 vs Stock Base (W/T/L, McNemar p, 95% CI)N=2 vs N=1 (W/T/L, McNemar p)
Multi-Window Cross-Doc Synthesis QA (n=72)*avg 1,541 tok42/72 (58.3%)43/72 (59.7%)56/72 (77.8%)+19.44 pp (19W/48T/5L, p = 0.0066, [+6.94, +31.94])+18.06 pp (18W/49T/5L, p = 0.0106)
ICL Novel Schema 16-Shot (n=64)avg 847 tok36/64 (56.2%)35/64 (54.7%)42/64 (65.6%)+9.38 pp (7W/56T/1L, p = 0.0703, [+1.56, +17.19])+10.94 pp (8W/55T/1L, p = 0.0391)
ICL Novel Schema 8-Shot (n=64)avg 474 tok40/64 (62.5%)38/64 (59.4%)39/64 (60.9%)-1.56 pp (2W/59T/3L, p = 1.000, [-7.81, +4.69])+1.56 pp (3W/59T/2L, p = 1.000)
ICL Novel Schema Pooled (8+16-Shot) (n=128)474–847 tok76/128 (59.4%)73/128 (57.0%)81/128 (63.3%)+3.91 pp (9W/115T/4L, p = 0.2668, [-0.78, +9.38])+6.25 pp (11W/114T/3L, p = 0.0574)
GSM8K 8-Shot (n=120)avg 1,366 tok99/120 (82.5%)99/120 (82.5%)100/120 (83.3%)+0.83 pp (5W/111T/4L, p = 1.000, [-3.33, +5.83])+0.83 pp (6W/109T/5L, p = 1.000)
~21K RULER NIAH (n=24, 8E/8M/8L)†avg 21,328 tok (3,000 MiB KV)24/24 (100.0%)24/24 (100.0%)24/24 (100.0%)0.00 pp (0W/24T/0L, p = 1.000, E=8/8 M=8/8 L=8/8)0.00 pp (0W/24T/0L, p = 1.000)
POOLED GENERATION (n=320)MW-QA + ICL + GSM8K217/320 (67.8%)215/320 (67.2%)237/320 (74.1%)+6.25 pp (33W/274T/13L, p = 0.0045, [+2.19, +10.62])+6.88 pp (35W/272T/13L, p = 0.0021)
POOLED ALL 4 SUITES (n=344)Gen + ~21K RULER241/344 (70.1%)239/344 (69.5%)261/344 (75.9%)+5.81 pp (33W/298T/13L, p = 0.0045, [+2.03, +9.59])+6.40 pp (35W/296T/13L, p = 0.0021, [+2.33, +10.17])
  • Frozen-Wake Equivalence (N=1 vs Untouched Stock Qwen/Qwen3-4B, n=344): 239/344 (69.5%) vs 241/344 (70.1%), 336/344 (97.7%) exact item agreement (3W / 5L, exact two-sided McNemar p = 0.727, 95% CI [-2.33, +1.16] pp).
  • *MW-QA n=72 Sub-Family Breakdown (24 each): config_override jumped 1/24 (4.2%) → 18/24 (75.0%) (both Base & N=1 were 1/24), multihop_chain moved 17/24 → 18/24 (N=1 was 18/24), while python_trace traded off 24/24 → 20/24 (including 2 responses missing the #### answer delimiter)—yielding the net +19.44 pp (p = 0.0066) gain across the full 72-item suite.
  • †KV size is analytic MiB (tokens × 36 layers × 2 × 8 KV heads × 128 head_dim × 2 B / 2²⁰). Sleep leaves KV sequence length unchanged by construction; on CUDA GB10 with logits_to_keep=1, ~21K RULER held a flat 13.66 GiB peak VRAM (12.06 GiB for stock Base). Note that the PyTorch reference implementation (modeling_qwen3_sleep.py) uses torch.cat to update per-window KV slices, creating transient copies during decode/Sleep (whereas ASOR Metal uses preallocated in-place buffers).

Legacy K+V Opt-In Ablation (v_only=False on CUDA GB10 — Why sleep_v_only: true Is Default)

Prior to enabling sleep_v_only: true by default, legacy K+V (v_only=False) was evaluated across context lengths and N=4 on CUDA GB10 (n=12 needles per RULER/KV length, n=48 GSM8K 4+8-shot):

Legacy K+V Ablation (v_only=False)N=1 WakeN=2 K+VN=4 K+VTakeaway
RULER ~5K / ~11K (n=12 each, 5.3K / 10.6K tok)12/12 / 12/1212/12 / 12/1212/12 / 12/12Ceiling across all N up to ~11K
RULER ~21K (n=12, 21,057 tok)12/12 (100%)11/12 (91.7%, E=3/4)9/12 (75.0%)K-gate early-needle drift; eliminated (24/24 = 100%) by default sleep_v_only: true
KV Retrieval ~5.7K (n=12, 5,669 tok)11/12 (91.7%)11/12 (91.7%)11/12 (91.7%)Identical to Stock Base (11/12) across all N
GSM8K Pooled 4+8-Shot (n=48)38/48 (79.2%)37/48 (77.1%)32/48 (66.7%)N=4 K+V regresses on multi-step math; use default N=2 V-Only (100/120 = 83.3%)

3. Value-Only Sleep Breakthrough — Apple Silicon M3 Ultra MLX BF16 (Zero Retraining)

Measured on Apple M3 Ultra (256 GiB, MLX bf16 base + fp16 plug-in adapter, 0.25 s warm load, 1,049 / 1,049 strict tensor load, 61.8 tok/s Wake decode). Freezing K to 100% bit-exact Wake (k_update_scale = 0.0, v_update_scale = 1.0, shipped as sleep_v_only: true default) requires zero retraining of the v3d checkpoint yet simultaneously beats K+V N2_stock on 2K OOD NLL, restores 12/12 (100%) ~21K RULER recall, and turns the pooled n=136 downstream suite into a statistically significant win (p = 0.0266):

A. OOD NLL, ~21K RULER Long-Context Retrieval, & Downstream Generation Suite (temperature = 0)

Benchmark / MetricN=1 (Wake-Only)N=2 K+V (N2_stock)N=2 Value-Only (sleep_v_only: true, Default)Notes / N=4 Scaling
2K OOD NLL (8 × 2048 WikiText + Python, W1..W7)2.034861.82269 (-0.21218)1.82254 (-0.21233, 100.1% retained)N4_Vonly 1.80519 (108.2%) beats N4_stock 1.80740
~21K RULER (12 needles, avg 21,057 tok)12/12 (100.0%)11/12 (91.7%, E=3/4)12/12 (100.0%, E=4/4 M=4/4 L=4/4)N4_stock 8/12 (66.7%) → N4_Vonly 10/12 (83.3%) (11/12 w/ start_layer=8, γ=0.5)
GSM8K 8-Shot (n=48, greedy)39/48 (81.2%)39/48 (81.2%)40/48 (83.3%, +2.1 pp)2W / 45T / 1L vs Wake (p = 1.0)
Multi-Window Cross-Document Synthesis QA (n=24, untruncated)14/24 (58.3%)17/24 (70.8%)19/24 (79.2%, +20.8 pp)config_override sub-family: 1/8 → 7/8; 0 truncated responses
ICL Novel Schema (n=64, 8-shot + 16-shot)37/64 (57.8%)38/64 (59.4%)42/64 (65.6%, +7.8 pp)8s 23/32, 16s 19/32; reaches 44/64 (68.8%) w/ --loopcd-omega 0.25
Pooled Downstream Suite (n=136)90/136 (66.2%)94/136 (69.1%, p=0.50)101/136 (74.3%, +8.09 pp, p = 0.0266)16W / 115T / 5L vs Wake; exact two-sided McNemar p = 0.0266, 95% bootstrap CI [+1.47, +14.71] pp

B. MLX LoopCD-Hidden NLL & Throughput Trade-Off (n=8 × 2,048 Unseen Code + Prose)

LoopCD-Hidden (ω): Optional dual-stream hidden-state contrastive decoding (h_cd = h_sleep + ω · (h_sleep − h_wake) = (1 + ω) · h_sleep − ω · h_wake, with RMS norm preserved to rms(h_sleep)) combining paired causal N=1 Wake (h_wake) and causal post-Sleep N=2 (h_sleep) hidden streams via --loopcd-omega in mlx_sleep_runner.py (ω = 0.0 reduces to exact N=2). Because it runs a paired Wake stream alongside N=2 Sleep (3 full stack passes total vs 4 for N=4), throughput is ~587 tok/s vs N=4's 425.7 tok/s.

ModePost-Sleep NLL (tok ≥ 256, n=8)Δ vs N=1Post-Sleep PPLPost-Sleep Top-1Prefill Throughput
N=1 (Wake-Only)1.53330.00004.63468.73%1,729.6 tok/s
N=2 (ω = 0.0, 1 Sleep pass)1.3668-0.16653.92369.19%888.8 tok/s
N=4 (3 Sleep passes)1.3579-0.17553.88868.92%425.7 tok/s
N=2 + LoopCD-Hidden (ω = 0.15)1.3585-0.17493.89069.22%~587 tok/s (3 stack passes)
N=2 + LoopCD-Hidden (ω = 0.35)1.3525-0.18083.86769.18%~587 tok/s (3 stack passes)

Honest LoopCD-Hidden Trade-Off: Keep --loopcd-omega 0.0 (off) for general generation. LoopCD-Hidden is opt-in for offline NLL scoring (PPL 3.867 at ω = 0.35) and short-answer ICL (N2_Vonly + ω = 0.25 reaches 44/64 = 68.8%), but is NOT recommended for long chain-of-thought math: on GSM8K 8-shot (n=48), LoopCD-Hidden regressed relative to N2_stock (39/48 = 81.2%) at both ω = 0.25 (36/48 = 75.0%) and ω = 0.35 (31/48 = 64.6%, 2W/10L, exact McNemar p = 0.0386).

4. Native ASOR Metal (C++20 / Metal, --precision native, 4.7 GB) — N=1/2/4 K+V & Value-Only Verification

Verified using the separate native Apple Silicon Metal engine (MSWlabAI/asor) with fused MessageGateSleepBridge and single-slice V-Only KV gate Metal kernels (Window-0 max diff N=2/4 vs N=1 = 0.000e+00, +0.0 MB KV cache growth in preallocated Metal buffers):

Corpus / Mode (--precision native)Post-Sleep NLLΔ vs N=1Full / Post PPLTop-1 / Windows WonNotes
2K Multi-Window Corpus — N=1 Wake1.178750.000003.250 (post)—579 tok/s prefill / 50.9 tok/s decode; Window-0 max logit diff 0.000000e+00
2K Multi-Window Corpus — N=2 K+V (v_only: false)1.05555-0.123202.874 (-11.59%)7/7 windowsPaired bootstrap 95% CI [-0.150, -0.097]
2K Multi-Window Corpus — N=4 K+V (v_only: false)1.06510-0.113652.901 (post)7/7 windowsSlightly trails N=2 on this 2K corpus
2K Unseen Prose+Code (Pure Metal) — N=1 Wake1.28160.00004.916 (full)69.61% Top-1Window-0 diff vs Wake: 0.000e+00 (660.3 tok/s)
2K Unseen Prose+Code (Pure Metal) — N=2 K+V (v_only: false)1.1688-0.11284.454 (full)69.57% Top-1Window-0 diff vs Wake: 0.000e+00 (390.5 tok/s)
2K Unseen Prose+Code (Pure Metal) — N=2 V-Only (v_only: true, Default)1.1730-0.10864.470 (full)69.71% Top-1 (best)0.000e+00 Window-0 diff; retains 96.3% of K+V ΔNLL w/ bit-exact Wake Keys
2K Unseen Prose+Code (Pure Metal) — N=4 K+V (v_only: false)1.1801-0.10154.498 (full)69.52% Top-1Window-0 diff vs Wake: 0.000e+00 (216.9 tok/s)
2K Unseen Prose+Code (Pure Metal) — N=4 V-Only (v_only: true)1.1784-0.10334.491 (full)69.37% Top-1N4_Vonly beats N4_stock (-0.1033 vs -0.1015 ΔNLL, 218.9 vs 216.9 tok/s)

Recommended Operating Points:

  • Default Chat, Coding, Reasoning & Long-Context Adaptation (verified up to ~21K context): Use N=2 with sleep_v_only: true (now the default in config.json and sleep_adapter_config.json) — wins 7/7 post-Sleep windows on all 4 CUDA NLL suites, achieves 24/24 (100.0%) ~21K RULER retrieval, beats untouched stock Qwen/Qwen3-4B on 261/344 (75.9% vs 70.1%, +5.81 pp, exact McNemar p = 0.0045) on CUDA GB10 (and 101/136 = 74.3%, +8.09 pp, p = 0.0266 on Apple Silicon MLX), and runs at ~889 tok/s prefill (61.8 tok/s Wake decode) on Apple Silicon MLX or native Metal via ASOR (v_only: true, 69.71% Top-1).
  • Exact Stock Wake Parity or >21K Untested Context Lengths: Use N=1 (num_loops=1, Wake-only; 336/344 = 97.7% exact agreement with untouched stock Qwen/Qwen3-4B, p = 0.727) for exact base behavior or contexts beyond the ~21K verified RULER horizon.
  • Offline Log-Likelihood / Short-Answer ICL: Optionally pass --loopcd-omega 0.15–0.35 (3 stack passes in MLX) for offline NLL scoring (PPL 3.867) or short-answer ICL (68.8% with N2_Vonly + ω=0.25). Do NOT enable LoopCD-Hidden for long-CoT math (GSM8K regressed at ω=0.25/0.35, p=0.0386), and avoid N=4 for multi-step math or long-context retrieval.
  • Backwards-Compatible K+V Mode (Opt-In): Pass v_only=False (PyTorch/MLX) or v_only: false (ASOR) to re-enable sleep_gate_k key updates when comparing against the legacy K+V baseline tables above.

Known Limitations

  • Standard model() / model.generate() run N=1 Wake-only: Calling HF model(...) or model.generate(...) bypasses Sleep LoRA and KV write gates. Use model.forward_sleep(..., num_loops=2) or model.generate_sleep(..., num_loops=2) for Sleep consolidation (which honors sleep_v_only: true automatically from config.json).
  • Context lengths beyond ~21K and K+V opt-in (v_only=False): The v3d adapter was trained at seq_len = 2048. Default sleep_v_only: true keeps post-RoPE keys bit-exact Frozen-Wake and holds 24/24 (100%) RULER retrieval at ~21K (N=2, CUDA GB10) and 12/12 (100%, MLX), though lengths >21K have not been evaluated (use N=1 when exact verbatim recall is required beyond 21K). Opting into legacy K+V gating (v_only=False) modifies post-RoPE keys and degrades early-needle recall at ~21K (11/12 at N=2, 8–9/12 at N=4).
  • Sub-task variance inside Multi-Window Synthesis QA: While N=2 V-Only delivers a strong +19.44 pp net gain on MW-QA (56/72 vs 42/72, p = 0.0066, driven by config_override jumping 1/24 → 18/24), the python_trace sub-family traded off 24/24 → 20/24 (2 missing-#### outputs). For strict step-by-step code tracing where stock Base is already at ceiling, N=1 Wake-only remains immediately available at zero reload cost.
  • LoopCD-Hidden scope: Contrastive hidden-state decoding (--loopcd-omega > 0) improves offline NLL and short-answer ICL, but hurts long chain-of-thought math (GSM8K regressed significantly at ω=0.35, p=0.0386). Keep ω = 0.0 (default) for general generation and reasoning.
  • Attention backend requirement: Bidirectional Sleep passes use 4D additive intra-window masks and require sdpa or eager attention. FlashAttention-2 and FlexAttention are explicitly disabled and rejected when N > 1.
  • Quantization & Tensor Parallelism: SleepOnlyLoRALinear wraps every nn.Linear projection, so bitsandbytes 4/8-bit auto-quantization leaves wrapped projections unquantized and custom TP plans may require adaptation.
  • PyTorch reference memory traffic: modeling_qwen3_sleep.py concatenates per-window KV slices with torch.cat, creating transient KV copies (unlike ASOR Metal's fixed-buffer in-place KV cache).

Runtime Compatibility Matrix

RuntimeFull Sleep (N=2/4, sleep_v_only: true default) + MessageGateSleepBridgeN=1 Frozen-WakeHow to Run
Hugging Face transformersYes (CUDA tested; MPS/CPU best-effort; single-device recommended)YesAutoModelForCausalLM.from_pretrained("bmswheart/SleepyInkling-Qwen3-4B", trust_remote_code=True)
Apple Silicon MLXYes (0.25 s load, 61.8 tok/s, sleep_v_only: true, --loopcd-omega)Yespython mlx_sleep_runner.py --model bmswheart/SleepyInkling-Qwen3-4B --num-loops 2
ASOR Metal (Native C++20)Yes (native sleep_bridge_msggate_* + single-slice V-Only KV gates; separate repo)YesMSWlabAI/asor: convert_model.py --precision native -> asor serve / asor score
OpenAI-Compatible ServerYes (bundled Torch & MLX backends)Yespython openai_sleep_server.py --model ./SleepyInkling-Qwen3-4B --model-id SleepyInkling-Qwen3-4B --backend torch|mlx
vLLM (vllm_plugin/, Out-of-Tree)Yes (zero-fork vllm.general_plugins, Value-Only prefill + stock PagedAttention decode)Yes (SLEEPY_INKLING_NUM_LOOPS=1)pip install ./vllm_plugin && vllm serve bmswheart/SleepyInkling-Qwen3-4B
SGLangvia openai_sleep_server.pyYes (serve-sglang via stripped shadow dir)python vllm_sglang_wrapper.py serve-sglang --model ./SleepyInkling-Qwen3-4B
llama.cpp / Ollama—Yes (strip-gates)python vllm_sglang_wrapper.py strip-gates --src ./SleepyInkling-Qwen3-4B --dst ./SleepyInkling-Qwen3-4B-n1

Quick Start

Install dependencies (recommended transformers>=5.0,<6; Qwen3SleepConfig also includes a rope_theta compatibility guard for transformers v4):

pip install "transformers>=5.0,<6" accelerate safetensors huggingface_hub

1. Apply the Compact 163.46 MiB Plug-In Adapter onto Qwen/Qwen3-4B

hf download bmswheart/SleepyInkling-Qwen3-4B-adapter --local-dir ./sleepy_inkling_adapter

python ./sleepy_inkling_adapter/apply_sleep_adapter.py apply \
  --base Qwen/Qwen3-4B \
  --adapter ./sleepy_inkling_adapter \
  --out ./SleepyInkling-Qwen3-4B \
  --verify-sha256 22bb77fd9a8a9eb0743bf9096a7c3d311bd0c7d35e684fca43520cfdefaea5b6

(You can also pass --adapter bmswheart/SleepyInkling-Qwen3-4B-adapter directly or alias --base-model Qwen/Qwen3-4B.)

2. Hugging Face transformers (PyTorch — Full N=2/4 Value-Only Sleep Default)

Note: Sleep consolidates every W = 256 tokens, so prompts must be ≥ 256 tokens for Sleep to fire during prefill (≥ 512 tokens to observe post-Sleep NLL differences across multiple windows). Standard model() / model.generate() run N=1 Wake-only; use forward_sleep() / generate_sleep(). Value-Only Sleep (sleep_v_only: true) is active by default from config.json; pass v_only=False to opt back into legacy K+V gating.

import torch
from transformers import AutoModelForCausalLM, PreTrainedTokenizerFast

model_id = "bmswheart/SleepyInkling-Qwen3-4B"  # or local "./SleepyInkling-Qwen3-4B"
tokenizer = PreTrainedTokenizerFast.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
    model_id,
    trust_remote_code=True,
    dtype=torch.bfloat16,
    device_map="auto",
).eval()

# Multi-window (>= 512 tokens) technical context so Sleep triggers across W=256 boundaries
doc = (
    "Service Runbook — HeliosCache uses three tiers: Tier-0 is a 256 MiB per-worker in-process LRU slab "
    "with a 15s soft TTL; Tier-1 is a regional NVMe ring with W=2 of R=3 synchronous quorum writes and "
    "CRC32C checksums; Tier-2 archives cold keys older than 4 hours to object storage. During single-zone "
    "power loss, ephemeral=true keys degrade to W=1 while durable auth keys stay W=2. "
) * 10
prompt = doc + "\nQuestion: How do ephemeral=true and durable auth keys differ during single-zone power loss?\nAnswer:"
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
assert inputs["input_ids"].shape[1] >= 512

with torch.inference_mode():
    # Full Wake-Sleep generation (N=2 Value-Only bidirectional KV consolidation every 256 tokens)
    out = model.generate_sleep(inputs["input_ids"], max_new_tokens=128, num_loops=2)
    print(tokenizer.decode(out[0, inputs["input_ids"].shape[1]:], skip_special_tokens=True))

    # Compare Wake-only (N=1) vs Wake+Sleep (N=2, sleep_v_only=True default) NLL over the prompt
    out_n1 = model.forward_sleep(inputs["input_ids"], labels=inputs["input_ids"], num_loops=1)
    out_n2 = model.forward_sleep(inputs["input_ids"], labels=inputs["input_ids"], num_loops=2)
    print(f"N=1 loss: {out_n1.loss.item():.4f} | N=2 V-Only loss: {out_n2.loss.item():.4f}")

3. Apple Silicon MLX (Standalone — 0.25 s Load, No PyTorch Required)

# Works with a Hugging Face Hub repo ID or local model directory (uses sleep_v_only: true from config.json):
python mlx_sleep_runner.py --model bmswheart/SleepyInkling-Qwen3-4B \
  --prompt "Write a concise Python LRU cache with O(1) get and put." \
  --num-loops 2 --max-tokens 256

# Compare N=1 vs N=2 V-Only NLL (and optional LoopCD-Hidden omega for offline scoring) on any local text file:
python mlx_sleep_runner.py --model bmswheart/SleepyInkling-Qwen3-4B \
  --compare-n1-n2 --text-file ./README.md --loopcd-omega 0.35

4. Native ASOR Metal (Separate C++20/Metal Engine Repository)

Native Metal conversion and serving require the separate ASOR repository (https://github.com/MSWlabAI/asor), which provides scripts/convert_model.py (automatically propagating sleep_v_only: true into recipe.yaml) and the asor binary with fused MessageGateSleepBridge and single-slice V-Only Sleep KV kernels:

# Inside a checkout of https://github.com/MSWlabAI/asor:
python scripts/convert_model.py \
  --src ./SleepyInkling-Qwen3-4B \
  --dst ./SleepyInkling-Qwen3-4B-native.asor \
  --precision native
asor serve --model ./SleepyInkling-Qwen3-4B-native.asor --port 8080

5. vLLM Out-of-Tree Plugin (vllm_plugin/), OpenAI Server, SGLang & llama.cpp

# Native vLLM Value-Only Sleep (zero fork — uses bundled vllm.general_plugins package):
pip install ./vllm_plugin
vllm serve bmswheart/SleepyInkling-Qwen3-4B --dtype bfloat16 --port 8000

# Or attach the 163.46 MiB adapter dynamically onto stock Qwen/Qwen3-4B in vLLM:
SLEEPY_INKLING_ADAPTER=bmswheart/SleepyInkling-Qwen3-4B-adapter \
  vllm serve Qwen/Qwen3-4B --dtype bfloat16 --port 8000

# Standalone OpenAI-compatible API (Torch / MLX):
python openai_sleep_server.py --model ./SleepyInkling-Qwen3-4B --model-id SleepyInkling-Qwen3-4B --backend torch --port 8000
python openai_sleep_server.py --model ./SleepyInkling-Qwen3-4B --model-id SleepyInkling-Qwen3-4B --backend mlx   --port 8000

# SGLang / llama.cpp (exact N=1 Frozen-Wake compatibility):
python vllm_sglang_wrapper.py serve-sglang --model ./SleepyInkling-Qwen3-4B --port 30000
python vllm_sglang_wrapper.py strip-gates  --src ./SleepyInkling-Qwen3-4B --dst ./SleepyInkling-Qwen3-4B-n1

Citations

Please cite the original authors of Sample-Efficient In-Context Adaptation via Sleep, Inkling-2-Mini (Thinking Machines Lab), and Qwen3:

@article{lee2026sleep,
  title   = {Sample-Efficient In-Context Adaptation via Sleep},
  author  = {Lee, Sangyun and Zhang, Enyan and Xu, Michael and Tang, Hao and Lin, Zinan and Xu, Weijia and Quirk, Chris and Gao, Jianfeng and Fanti, Giulia and Liu, Xiaodong},
  journal = {arXiv preprint arXiv:2611.32802},
  year    = {2026},
  url     = {https://arxiv.org/abs/2611.32802}
}

@misc{thinkingmachines2026inkling2mini,
  title        = {Inkling-2-Mini},
  author       = {{Thinking Machines Lab}},
  year         = {2026},
  howpublished = {\url{https://huggingface.co/thinkingmachines/Inkling-2-Mini}}
}

@article{yang2025qwen3,
  title   = {Qwen3 Technical Report},
  author  = {Yang, An and Li, Anfeng and Yang, Baosong and Zhang, Beichen and Hui, Binyuan and Zheng, Bo and Yu, Bowen and Gao, Chang and Huang, Chengen and Lv, Chenxu and others},
  journal = {arXiv preprint arXiv:2505.09388},
  year    = {2025},
  url     = {https://arxiv.org/abs/2505.09388}
}

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

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

GPU в ailist

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

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

MLX-модели работают только на Apple Silicon, на GPU NVIDIA они не запускаются.

Класс архитектуры
Qwen3SleepForCausalLM
Ревизия весов
0c3d074

0 моделей