Implement EngramLite + Complementary Training + BackoffNgramMixer stack targeting sub-1.0 BPB#2
Draft
Copilot wants to merge 2 commits intocopilot/brainstorm-novel-approachesfrom
Draft
Conversation
…Gram for sub-1.0 BPB Agent-Logs-Url: https://github.com/kailean/parameter-golf/sessions/205d0581-0f54-4b88-b48f-39c66db315dc Co-authored-by: kailean <49617037+kailean@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Analyze pull request and brainstorm improvements for BPB
Implement EngramLite + Complementary Training + BackoffNgramMixer stack targeting sub-1.0 BPB
Apr 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements the three highest-EV innovations from the PR #1 analysis into
train_gpt_mlx_kl.py. Combined estimated improvement: ~0.08–0.18 BPB over the 1.10 baseline, targeting sub-1.0.EngramLite (replaces BigramHash by default)
ENGRAM_LITE_ENABLED=1(new default). Gated multi-head bigram+trigram hash embedding.sigmoid(-2)≈0.12) — grows only when lookups are trustworthy; suppresses the +0.0049 BPB noise that raw TrigramHash causes (Non-record: 11L XSA-all + Full GPTQ + Selective Pruning (val_bpb=1.1154, 3-seed) openai/parameter-golf#609)embed_dim=256 → vocab_size) regularizes vs. direct mappingENGRAM_HASH_SIZE(default 8192) knob;BIGRAM_HASH_SIZEstill controls plain BigramHash fallbackBackoffNgramMixer (eval-only, zero artifact cost)
NGRAM_MIXER_ENABLED=1. Causal Laplace-smoothed n-gram LM (orders 1–4, configurable) mixed with neural model at eval time.NLL_mix = -log((1-α)·P_neural + α·P_ngram)— mathematically valid (mixed dist sums to 1)NGRAM_ALPHA=0.25,NGRAM_MAX_ORDER=4Complementary Training
COMPLEMENT_ALPHA=0.5. Down-weights tokens already well-predicted by bigrams, forcing specialization on hard tokens.np.bincounton first training shard (~2s)clip(1 − α·P_bigram(target|ctx), 0.1, 1.0), mean-normalized to preserve effective LR_COMPLEMENT_BIGRAM_PROBS/_COMPLEMENT_ALPHAcaptured bymx.compileat graph-trace timeSkipGramHashEmbedding (disabled by default)
SKIPGRAM_HASH_SIZE=2048to enable. Hash of non-contiguous positions (t-1,t-3) and (t-1,t-5) with per-pattern learned gating. Captures structured repetition (HTML, code, prose templates).Infra changes
GPT._apply_hash_biases()helper shared byloss()andtoken_losses()SplitOptimizersextended to routeskipgram_hash.*params (2D→Muon, 1D→Adam)_MIN_COMPLEMENT_WEIGHT = 0.1,_MIN_PROB = 1e-45named constantsEngramLiteEmbedding.__init__Original prompt