Instructions to use jeweled/Inkling-2-Next with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use jeweled/Inkling-2-Next with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="jeweled/Inkling-2-Next")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("jeweled/Inkling-2-Next", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use jeweled/Inkling-2-Next with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "jeweled/Inkling-2-Next" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "jeweled/Inkling-2-Next", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/jeweled/Inkling-2-Next
- SGLang
How to use jeweled/Inkling-2-Next 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 "jeweled/Inkling-2-Next" \ --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": "jeweled/Inkling-2-Next", "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 "jeweled/Inkling-2-Next" \ --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": "jeweled/Inkling-2-Next", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use jeweled/Inkling-2-Next with Docker Model Runner:
docker model run hf.co/jeweled/Inkling-2-Next
- Inkling 2 Next
- 1. Architectural Thesis
- 2. Deep Dive: Conditional N-Gram Architecture (
196.6BEngram + Hybrid N-Gram Speculation)- 2.1 Canonical Tokenizer Compression (
36.0%Vocabulary Collapse) - 2.2 Multi-Order Prime-Modulus N-Gram Hash Tables (
196.61BParameters) - 2.3 Why Inject at
L1andL13? Exploiting6-Layer Block Attention Residuals - 2.4 Zero-Init Context-Gated Injection & Tiered NVMe/RAM Architecture
- 2.5 Inference-Time N-Gram Synergy: Hybrid SAM + Static N-Gram + 5-Layer MTP
- 2.1 Canonical Tokenizer Compression (
- 3. MoE Compute Reallocation: Dynamic
top-pRouting & Mini Shared Expert - 4. Lossless
NVFP4-Safe Post-Training & Verifiable Multi-Turn RL - 5. Benchmarks (
Inkling 2 Nextvs.thinkingmachines/Inkling-2-Small) - License & Lineage
- 1. Architectural Thesis
Inkling 2 Next
Release Status β Architecture Preview (Weights Pending Head-to-Head Benchmarking): No model weights have been uploaded to this repository yet. This page documents the architectural decisions behind Inkling 2 Next β a conditional N-gram memory (
196.6BEngram), dynamic-routing MoE, and verifiable-RL evolution ofthinkingmachines/Inkling-2-Small. Head-to-head evaluations against the baseInkling-2-Smallcheckpoint on identical benchmark harnesses are next in queue and will be published here ahead of weight release.
1. Architectural Thesis
thinkingmachines/Inkling-2-Small is a 594B-parameter (~17B active) hybrid local/global Mixture-of-Experts model (48 layers, 384 routed experts per layer in native NVFP4 for L0β39 and MXFP8 for L40β47, top-8 sigmoid routing, 6-layer Block Attention Residuals, and a 5-layer Multi-Token Prediction speculative drafter).
While sparse MoE scales parameter capacity efficiently, empirical layer-ablation scans on Inkling-2-Small exposed three structural bottlenecks:
- Static Lexical Reconstruction Inside Early MoE Layers: Early-to-mid MoE layers expend substantial routed-expert compute and memory bandwidth reconstructing static local N-gram collocations, multi-token code/ABI identifiers, LaTeX idioms, and named entities that do not require deep non-linear expert routing.
- Uniform
top-8Tail Noise & Missing Shared Expert: Under energy-conserving sigmoid routing (route_scale = 8.0), the 7th and 8th lowest-scoring experts on high-certainty tokens contribute marginal residual signal while paying fullNVFP4/MXFP8expert memory-read cost β yetInkling-2-Smallnatively setsn_shared_experts = 0, making naivetop-kpruning brittle without a dense fallback pathway. - Quantized Expert Fragility Under Post-Training: Directly updating
NVFP4/MXFP8routed experts during SFT or RL introduces 4-bit/8-bit dequantize-requantize drift and degrades speculative drafter acceptance.
Inkling 2 Next resolves all three bottlenecks through four co-designed architectural layers:
| Component | Base Inkling-2-Small |
Inkling 2 Next | Primary Architectural Role |
|---|---|---|---|
| Total Parameters | 594B |
790.6B (594B backbone + 196.6B Engram) |
$O(1)$ offloaded lexical & structural N-gram capacity |
| Conditional N-Gram Memory | None | 196.61B Engram at L1 & L13 (n = 2, 3, 4, 24 prime-hash heads/layer) |
Offloads static N-gram/entity recall from early MoE experts |
| Tokenizer N-Gram Addressing | Raw 201,024 BPE IDs |
Canonical LUT Compression (201,024 -> 128,650, -36.0%) |
Collapses casing, spacing, and Unicode surface variants onto shared N-gram slots |
| MoE Routing Policy | Static top-8 everywhere (100% active MoE) |
Dynamic top-p = 0.85 (k in [3, 6], mean k = 4.83) |
Cuts routed-expert memory reads by -39.6% by dropping low-weight tail experts |
| Shared Expert Pathway | n_shared_experts = 0 |
dim = 512 BF16 Mini Shared Expert (L0β47, Muon-trained) |
Always-on dense residual anchor stabilizing aggressive top-p expert shedding |
| Speculative Decoding | 5-layer MTP drafter | Hybrid Prefix-Seeded Suffix Automaton (SAM) + Static N-Gram + 5-Layer MTP | Zero-overhead N-gram continuation drafting with strict 0-ULP target verification |
| Domain RL Adaptation | Base policy | NVFP4-Safe BF16 Attention Adaptation (Dr.GRPO + ExPPO + Clip-Higher + TIS) |
Zero expert requantization; 0.0% runtime serving overhead after static BF16 merge |
2. Deep Dive: Conditional N-Gram Architecture (196.6B Engram + Hybrid N-Gram Speculation)
2.1 Canonical Tokenizer Compression (36.0% Vocabulary Collapse)
Addressing N-gram tables with raw BPE token IDs fragments statistical support across trivial surface variations (e.g., " Theorem", "theorem", "THEOREM", and Unicode compatibility forms all hash to unrelated rows).
Before computing any N-gram hash, Inkling 2 Next maps every token through a static lookup table:
- Collapses
Inkling-2-Small's201,024padded vocabulary (200,058active BPE + control tokens) down to128,650canonical equivalence classes (36.0%reduction) β nearly 2x higher canonical compression density than comparable byte-heavy tokenizers. - Special wire/control tokens (chat turn delimiters,
<think>reasoning spans, and structured tool-invocation tags) map to dedicated isolated sentinels so structural control boundaries never alias with natural-language N-grams.
2.2 Multi-Order Prime-Modulus N-Gram Hash Tables (196.61B Parameters)
At each Engram injection layer, Inkling 2 Next extracts causal suffix N-grams of orders $n \in {2, 3, 4}$ over the canonically compressed token stream:
- Multi-Head Prime Hashing: Each of the
3N-gram orders is hashed across8independent heads (3 x 8 = 24hash heads per layer,head_dim = 256, concatenatedengram_dim = 6,144). Each head $h \in {0, \dots, 23}$ indexes a table of distinct prime modulus $P_h \approx 16\text{M}$ rows (~384Mrows per layer), eliminating systematic modular collision patterns across orders and heads: $$(384,006,168 + 384,016,682) \times 256 = 196,613,849,600 \text{ parameters } (\mathbf{196.61\text{B}})$$ - Tail-Noise Filtering (
min_count = 3): Rare4-grams appearing fewer than3times in the training corpus are masked from table updates, preventing single-occurrence sequence memorization and hash-collision pollution while concentrating capacity on reusable mathematical, code, and domain N-grams.
2.3 Why Inject at L1 and L13? Exploiting 6-Layer Block Attention Residuals
A naive N-gram lookup design either attaches tables to every transformer layer (multiplying metadata and projection overhead by 48x) or injects only at the input embedding (where early residual updates overwrite lexical detail).
Inkling-2-Small organizes its 48 layers into eight 6-layer Block Attention Residual groups (n_layers_per_attn_res_block = 6), where layers attend directly over normalized block-level residual states via learned inter-block queries:
Input -> [L0 -> L1(Engram #1) -> L2..L5] ==> Block 0 Residual
|
+--> [L6..L11] ==> Block 1 Residual
|
+--> [L12 -> L13(Engram #2) -> L14..L17] ==> Block 2 Residual
|
+--> [L18..L47] (Global + Local Reasoning Layers)
L1(Early Lexical Offload): Placed immediately afterL0contextualizes raw token embeddings, supplying $O(1)$ surface/phrase N-grams right at the start of Block 0.L13(Mid-Depth Structural & Compositional N-Grams): Placed near the entry of Block 2, after two full local/global attention cycles (L5,L11), capturing higher-order syntactic, API, and symbolic patterns while remaining directly reachable by deeper layers (L18βL47) via Block Attention Residuals.- Empirical Verification (
engram_cushion_bpb): In single-layer expert-shedding sweeps acrossL0βL17(top-8 -> top-6 / top-4with vs. without Engram), 31 of 32 candidates acrossL0βL15exhibited positive Engram cushion β proving thatL1+L13N-gram memory directly absorbs the representational load lost when pruning early-to-mid MoE experts, before naturally tapering off atL16βL17where abstract reasoning dominates.
2.4 Zero-Init Context-Gated Injection & Tiered NVMe/RAM Architecture
Raw N-gram embeddings are static with respect to broader context (e.g., "bank" in finance vs. systems memory banking). Inkling 2 Next gates every retrieved $6,144$-d N-gram vector against the live hidden state $h_\ell \in \mathbb{R}^{4608}$:
- Project the concatenated
24-head N-gram vector via a TP-sharded linear mapwkvinto key $k_e$ and value $v_e$. - Modulate $v_e$ by normalized query-key agreement $\sigma(\text{RMSNorm}(h_\ell) \odot \text{RMSNorm}(k_e))$ and scale by a zero-initialized scalar residual gate ($\alpha_\ell = 0$ at Step 0).
- Because $\alpha_\ell = 0$ at initialization, attaching
196.6Bparameters introduces exact0.000$\Delta\text{bpb}$ perturbation at Step 0 and smoothly opens ($\alpha_1 \approx 0.36$, $\alpha_{13} \approx 0.65$) only where N-gram lookups genuinely reduce cross-entropy and self-teacher KL.
- Because $\alpha_\ell = 0$ at initialization, attaching
- Zero-Penalty Serving &
SparseRowAdagradTraining: Because N-gram indices depend only on input token IDs (known beforeL0executes!),L1andL13lookups are prefetched asynchronously from sharded NVMe backing stores through a power-of-2 direct-mapped Zipfian RAM/GPU hot cache (~80β90%hit rate in2β4 GiB/shard), hiding off-chip latency completely behindL0andL2βL12compute. During retrofit training,SparseRowAdagradmaintains a single FP32 scalar per row (0.38 GiB/shard) and updates only active rows touched in each micro-batch.
2.5 Inference-Time N-Gram Synergy: Hybrid SAM + Static N-Gram + 5-Layer MTP
In addition to representation-level Engram tables at L1/L13, Inkling 2 Next exploits N-gram structure during decoding by coupling Inkling-2-Small's neural 5-layer MTP drafter (32,768 frequency-ranked hot vocabulary shortlist) with an online Suffix Automaton (SAM) + static corpus N-gram table:
- Multi-Turn Prefix Seeding: In agentic code, proof, and security workflows, variable names, file paths, JSON tool schemas, and Lean/Solidity/C identifiers repeat heavily across turns. Seeding the Suffix Automaton from cached prompt prefixes allows $O(1)$ exact multi-token span proposals whenever high-confidence N-gram matches exist, seamlessly handing off to the 5-layer neural MTP drafter on novel reasoning steps.
- Multimodal &
0-ULPTarget Safety: Contiguous vision-pad token runs are collapsed to bounded sentinels so image inputs never pollute text N-gram transitions, and every drafted token β whether proposed by SAM, static N-grams, or neural MTP β is verified by the full target model with zero-ULP greedy invariance (and exact residual rejection recoverynorm(max(0, p - q))fortemperature > 0).
3. MoE Compute Reallocation: Dynamic top-p Routing & Mini Shared Expert
Once 196.6B Engram offloads static lexical memory from L0βL15, Inkling 2 Next reallocates active MoE compute onto a sharper Pareto frontier:
- Dynamic
top-p = 0.85Routing (k_min = 3, k_max = 6):- Replaces static
top-8expert selection across all48layers with cumulative router-probability thresholding: each token activates only as many top-ranked experts (between 3 and 6) as needed to cover85%of normalized routing probability mass. - Reduces mean active experts from
8.00 -> 4.83(60.38%active MoE,-39.62%routed expert reads) β concentrating bandwidth on high-leverage reasoning tokens (k -> 6) while fast-pathing predictable syntax/boilerplate tokens (k -> 3).
- Replaces static
- Muon-Trained
dim = 512BF16 Mini Shared Expert (L0βL47):- Attaches a compact always-on BF16 shared expert (
hidden = 4,608 -> d_shared = 512 -> 4,608) usingInkling-2-Small's exact interleaved softcapped SiTU activation (gate_cap = 4.0,up_cap = 25.0). - Jointly trained via 5-iteration quintic Newton-Schulz Muon orthogonalized updates alongside
48router scale calibrations,96Block Attention Residual queries, and8global-attention (L5, 11, 17, 23, 29, 35, 41, 47) BF16 adapters under forward Self-Teacher KL regularization so probability calibration and MTP speculative acceptance remain tightly anchored.
- Attaches a compact always-on BF16 shared expert (
4. Lossless NVFP4-Safe Post-Training & Verifiable Multi-Turn RL
To specialize Inkling 2 Next across Mathematics, Cybersecurity, and Applied Cryptography without degrading quantized expert precision or general capabilities:
- 100% Frozen Quantized Experts (
0Requantization Error): All384NVFP4(L0β39) andMXFP8(L40β47) routed experts remain bit-for-bit untouched. Trainable rank-16/32 adapters attach strictly to BF16 attention projections (wq_du,wk_dv,wv_dv,wo_udacrossL1β47) and fold losslessly into BF16 weights at load time prior to kernel prepacking (0.0%runtime serving latency penalty). - Stacked-Champion Reference Anchoring: Sequential RL iterations pre-merge the promoted prior champion into the frozen reference policy (
KL = 0at Step 0), preventing KL gravity from pulling newly acquired multi-turn skills back toward the pre-RL base policy. - Verifiable Execution Harnesses & RL Mechanics: Trained strictly against real executable verifiers β
clang/AddressSanitizer/MemorySanitizer/UndefinedBehaviorSanitizercrash reproduction & minimal patching, standaloneLean 4kernel proof checking (0sorry/axiomescapes), multi-fileFoundry(forge test) differential Solidity exploit & patch verification, finite-field R1CS / Fiat-Shamir / Merkle verifier soundness forging, and Olympiad mathematics β using:- Length-Unbiased
Dr.GRPOsequence loss normalization (preventing long16Ktrajectories from diluting gradient signal or rewarding brevity/stall hacks), ExPPOprompt-relative surprisal advantage shaping within equal-reward classes,- Asymmetric DAPO
Clip-Higher([0.20, 0.28]) to preserve exploration on low-prior reasoning tokens, - Truncated Importance Sampling (
TIS) against rollout behavior log-probabilities, and - Post-RL Weight-Space Trajectory Blending (
50/50Raw + Step-EMA) to combine peak late-stage long-context discovery with smooth early-stage calibration.
- Length-Unbiased
5. Benchmarks (Inkling 2 Next vs. thinkingmachines/Inkling-2-Small)
Coming next: Standardized, apples-to-apples evaluations comparing Inkling 2 Next directly against base thinkingmachines/Inkling-2-Small under identical prompts, tool harnesses, context caps, and 0-ULP decoding settings will be added to this section prior to weight upload.
License & Lineage
Derived from thinkingmachines/Inkling-2-Small under the Apache-2.0 License.
Model tree for jeweled/Inkling-2-Next
Base model
thinkingmachines/Inkling-2-Small