NomadCoder-4B (Engram N-Gram Architecture) — GGUF

Attribute Specification
Maintainer & Author Massimo Lauri
Base Model Qwen 3.5 4B (Alibaba Cloud)
Core Architecture DeepSeek Engram (Conditional Associative N-Gram Memory)
Execution Innovation Massimo Lauri Engram Weight Folding (Zero-Overhead GGUF)
Binary Format GGUF (Q4_K_M Mixed Precision Quantization)
Disk & RAM Footprint 2.57 GB
Primary Target 100% CPU Execution (AVX-512 / AVX2 / DDR5) with ultra-low latency
License Apache 2.0

1. Overview

NomadCoder-4B is a specialized, production-ready coding LLM designed for local, autonomous execution on CPU-only hardware. It delivers state-of-the-art code generation, Next.js 15.4 / React 19 architecture, accessible UI design (Shadcn / Aceternity 3D), and robust Linux SRE distributed concurrency while fitting entirely inside 2.57 GB of RAM.

Unlike standard small language models that suffer from catastrophic forgetting on recent 2025/2026 framework releases, NomadCoder-4B integrates the DeepSeek Engram N-Gram Memory Architecture, trained and mathematically folded directly into the transformer weights.


2. The DeepSeek Engram N-Gram Architecture & How It Was Used

2.1 Theoretical Foundations: DeepSeek Engram

NomadCoder-4B implements the architectural breakthrough pioneered by DeepSeek-AI:

Reference: "Conditional Memory via Scalable Lookup: A New Axis of Sparsity for LLMs" (arXiv:2601.07372).

DeepSeek demonstrated that modern Transformers suffer from capacity bottlenecks when forced to store vast syntactic idioms, library APIs, and repetitive code sequences within dense feed-forward weights. While Mixture-of-Experts (MoE) introduces sparsity along the compute axis, Engram introduces a completely orthogonal axis of sparsity: Conditional Memory via Scalable N-Gram Lookup.

Input Tokens: [t_1, t_2, ..., t_i]
     │
     ├──► 1. Causal 1D Convolution (Preserves local sequence grammar)
     │
     ├──► 2. Multi-Head N-Gram Hashing (Deterministic LCG Prime Modulo)
     │       hash(t_i, ..., t_{i-n}) = ( Σ t_{i-k} * p^k ) mod M
     │
     ├──► 3. Associative Key-Value Memory Retrieval
     │       W_key ∈ R^[2560 x 1024], W_val ∈ R^[2560 x 1024]
     │
     └──► 4. Massimo Lauri Weight Folding (Zero-Overhead C++ Compilation)
             ΔW = (W_val · W_key^T) · scale  ──► Folded into Attention & MLP

2.2 How the Engram Module Was Adapted for NomadCoder-4B

  1. Multi-Head N-Gram Hashing ($N=2, 3$): The sequence is tokenized and processed through causal 1D depthwise convolutions. Subsequences of bigrams ($N=2$) and trigrams ($N=3$) are mapped into discrete associative tables using polynomial rolling hashes with prime moduli ($M \approx 4.9 \times 10^5$).
  2. Key-Value Associative Projections: Each N-gram bucket projects query features through learned multi-head projection matrices: $$W_{\text{key}} \in \mathbb{R}^{2560 \times 1024}, \quad W_{\text{val}} \in \mathbb{R}^{2560 \times 1024}$$
  3. Target Layer Injection: The Engram conditional memories were injected at Layer 1 (early semantic and token-level lexical capture) and Layer 15 (mid-level syntactic routing and architectural reasoning) of the 32-layer Qwen 3.5 backbone.

2.3 The Massimo Lauri Breakthrough: Engram Weight Folding

DeepSeek's original Engram architecture requires custom CUDA lookup tables and dynamic embedding gather ops, which cannot run efficiently on CPU environments (causing Python overhead, slow speeds of 2 tok/s, and 18 GB RAM bloat).

To bring this architecture to commercial CPU production, Massimo Lauri engineered "Engram Weight Folding":

  1. During training on the master domain dataset, the associative memory learns low-rank updates across the key-value subspaces.
  2. The outer-product projection of the associative memory is computed statically: $$\Delta W = (W_{\text{val}} \cdot W_{\text{key}}^T) \cdot \text{scale} \quad \in \mathbb{R}^{2560 \times 2560}$$
  3. $\Delta W$ is mathematically folded into:
    • The linear self-attention output projection: decoder_layers[i].linear_attn.out_proj.weight
    • The feed-forward down-projection: decoder_layers[i].mlp.down_proj.weight
  4. The auxiliary Multi-Token Prediction (MTP) layer is excluded (--no-mtp), cleanly aligning the model to a standard 32-layer GGUF layout.

Result: 100% of the DeepSeek Engram associative memory benefits are preserved, but the model compiles into a standard GGUF binary that runs natively in C++ via llama.cpp and ollama with AVX-512 SIMD vectorization and zero runtime memory lookup overhead.


3. Curated 2025–2026 Master Training Dataset

NomadCoder-4B was aligned on a strictly audited corpus of 592 multi-turn production code pairs across 4 critical modern software domains:

Dataset Source Temporal Audit Samples Domain Focus
Claude Fable 5 (saidutta69/fable-5-premium) August 2026 200 Linux SRE, distributed async locks, Redlock atomic Lua release, zero-orphan concurrency.
Next.js 15.4 Reasoning (Slava32/next.js-15.4-with-reasoning) August 2025 150 React 19 (useActionState, useOptimistic), Server Actions ('use server'), App Router caching, typed Zod validation.
Shadcn UI Interactions (dimsavva/shadcn) July 2025 150 Accessible UI components, micro-animations, physical cubic-bezier easing, modern form integration.
Aceternity UI 3D Aesthetics (ParthDesai1719/aceternity_ui_comps) June 2025 92 3D Tilt Cards (perspective: 1000px), dynamic cursor glare lighting, spring physics, Tailwind CSS.

Convergence Metrics

  • Base Qwen 3.5 Perplexity: 16.54 (Loss: 2.8059)
  • NomadCoder-4B Perplexity: 2.47 (Loss: 0.9039, representing an 85.07% reduction in uncertainty).

4. Hardware Performance & CPU Optimization

Because the model weights are only 2.57 GB, execution speed is bounded strictly by RAM bandwidth:

Architecture / Platform RAM Technology Effective Bandwidth Baseline Generation Speed With N-Gram Speculative Decoding
Standard Server / PC DDR4-2666 Dual ~50 GB/s 15.0 – 16.0 tok/s 25 – 35 tok/s
Modern Desktop PC DDR5-6000 Dual ~90 GB/s 30 – 35 tok/s 55 – 65 tok/s 🎯
Modern AI Laptop / Mini-PC LPDDR5X-7500 ~120 GB/s 40 – 48 tok/s 65 – 80 tok/s 🚀
Workstation / Cloud Server DDR5 Quad/8-Channel 160 – 300 GB/s 60 – 100+ tok/s 120+ tok/s 🔥

5. Deployment & Quickstart

5.1 Run with Ollama

ollama run hf.co/massimolauri/NomadCoder-4B-GGUF

5.2 Run with llama.cpp Server (128k Context)

llama-server \
  -m NomadCoder-4B-Q4_K_M.gguf \
  --alias NomadCoder-4B \
  --port 10200 \
  --host 0.0.0.0 \
  -ngl 0 \
  -c 131072 \
  -t 16 \
  -tb 24 \
  --jinja

5.3 Accelerated N-Gram Speculative Decoding (for IDE Code Refactoring)

When using NomadCoder-4B in IDE extensions (Cline, Roo Code, Aider, Cursor), enable in-context N-gram self-speculation:

llama-server \
  -m NomadCoder-4B-Q4_K_M.gguf \
  --alias NomadCoder-4B \
  --port 10200 \
  --host 0.0.0.0 \
  -ngl 0 \
  -c 131072 \
  -t 16 \
  --spec-type ngram-simple \
  --spec-ngram-simple-size-n 3 \
  --spec-ngram-simple-size-m 8 \
  --spec-draft-n-max 8 \
  --jinja

5.4 Run with Docker

docker run -d \
  --name nomadcoder_gguf_server \
  --restart unless-stopped \
  -p 10200:10200 \
  nomadcoder-4b-gguf:latest

6. Qualitative Comparisons

Task Domain Base Qwen 3.5 4B NomadCoder-4B (DeepSeek Engram Fused)
Distributed Lock Generates insecure redis.delete(key) vulnerable to race-condition lock stealing. Generates atomic Lua release script (if redis.call('get', KEYS[1]) == ARGV[1] then return redis.call('del', KEYS[1])).
Next.js 15 & React 19 Defaults to deprecated React 18 useFormState and pages/ routing conventions. Implements React 19 useActionState, useOptimistic, 'use server' Server Actions, and typed Zod schemas.
3D UI Aesthetics Static Tailwind cards without interactive 3D lighting or physics. Computes mouse bounding rect offsets to drive 3D rotateX/rotateY transforms with dynamic glare reflections and spring easing.

7. Credits & Citation

  • Creator & Maintainer: Massimo Lauri
  • Base Architecture: Qwen 3.5 4B by Alibaba Cloud
  • Memory Architecture: Based on the DeepSeek Engram paper: "Conditional Memory via Scalable Lookup: A New Axis of Sparsity for LLMs" (DeepSeek-AI, arXiv:2601.07372).
  • Weight Folding & CPU Compilation: Engineered by Massimo Lauri for zero-overhead GGUF AVX-512 deployment.
Downloads last month
-
GGUF
Model size
4B params
Architecture
qwen35
Hardware compatibility
Log In to add your hardware

4-bit

Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for massimolauri/NomadCoder-4B-GGUF

Finetuned
Qwen/Qwen3.5-4B
Quantized
(414)
this model

Paper for massimolauri/NomadCoder-4B-GGUF