Qwengram-0.8B:将PLE n-gram记忆迁移至小模型
Qwengram-0.8B: I transferred Qwen3.8 Flash-Next’s n-gram memory into Qwen3.5-0.8B — 5.05% lower validation perplexity
提供了一套完整的小模型引入外部 n-gram 记忆的可复现方案,包含具体的架构取舍、训练参数与推理优化细节,对做端侧部署和模型压缩的同学极具参考价值。
I’ve been experimenting with whether Qwen3.8-Flash-Next’s pretrained PLE n-gram memory can improve a much smaller Qwen3.5-0.8B model.
我一直在尝试,Qwen3.8-Flash-Next 的预训练 PLE n-gram 记忆能否提升一个规模小得多的 Qwen3.5-0.8B 模型。
I trained the 0.8B setup with limited resources, mostly using free Kaggle notebook GPUs.
我使用有限的资源训练了 0.8B 配置,主要依赖免费的 Kaggle Notebook GPU。
The setup keeps both the Qwen3.5-0.8B backbone and the roughly 51B-parameter PLE memory frozen. A small R=1 reader is trained at decoder layers 3 and 9, with a token-dependent linear gate controlling the later injection.
该配置保持 Qwen3.5-0.8B 主干网络和约 51B 参数的 PLE 记忆冻结。在解码器第 3 层和第 9 层训练了一个小型 R=1 读取器,并使用与 token 相关的线性门控控制后期注入。
There is no backbone fine-tuning.
没有对主干网络进行微调。
The current balanced checkpoint uses a reader trained for 15M tokens and a separately calibrated dynamic gate. On the frozen full-validation set:
当前的平衡检查点使用了经过 15M token 训练的读取器和单独校准的动态门控。在冻结的全量验证集上:
Qwen3.5-0.8B stock
Qwen3.5-0.8B 原版
- NLL: 2.905585
- PPL: 18.2759
Qwengram-0.8B
- NLL: 2.853786
- PPL: 17.3534
Perplexity reduction: 5.05%
困惑度降低:5.05%
This is a language-model validation result, not a claim of 5% higher benchmark accuracy.
这是语言模型验证结果,并非声称基准测试准确率提高了 5%。
A few findings shaped the final design:
一些发现塑造了最终设计:
- The real pretrained PLE outperformed both random-memory and permuted-memory controls.
- Reader loss kept improving well beyond 5M training tokens. The 20M reader improved aggregate LM loss further, but regressed on math, so 15M remains the balanced checkpoint.
- Strong fixed late-layer memory injection hurt LAMBADA. Dynamic token-level arbitration recovered much of that tradeoff.
- The gate is genuinely dynamic: its memory strength varies substantially across tokens rather than behaving like a learned constant.
- With the exact same memory budget, learned token placement beat shuffled placement. Routing memory toward high-uncertainty positions recovered part of the advantage, but still did not match the learned gate.
- A warm-started R=4 reader produced a small aggregate LM-loss improvement, but introduced code and math regressions. I therefore kept R=1 as the balanced architecture.
- 真实的预训练 PLE 优于随机记忆和打乱记忆的对照组。
- 读取器损失在超过 5M 训练 token 后仍持续改善。20M 读取器进一步降低了整体 LM 损失,但在数学任务上出现倒退,因此 15M 仍作为平衡检查点。
- 强固定的晚期层记忆注入损害了 LAMBADA 表现。动态的 token 级仲裁恢复了大量这种权衡带来的损失。
- 该门控确实是动态的:其记忆强度在不同 token 间变化显著,而非表现为类似学习常量的行为。
- 在完全相同的记忆预算下,学习的 token 放置优于随机打乱放置。将记忆路由至高不确定性位置恢复了一部分优势,但仍不及学习门控。
- 采用热启动的 R=4 读取器带来了微小的整体 LM 损失改善,但引入了代码和数学任务的倒退。因此我保留了 R=1 作为平衡架构。
I also implemented the inference path in llama.cpp.
我还使用 llama.cpp 实现了推理路径。
The public artifacts are:
公开的资源包括:
Model / GGUFs
模型 / GGUFs
https://huggingface.co/Ninnix96/Qwengram-0.8B
Training, controls, and evaluation
训练、控制与评估
https://github.com/Ninnix/qwen-ple-transfer
Modified llama.cpp runtime
修改后的 llama.cpp 运行时
https://github.com/Ninnix/llama.cpp
The GGUF contains the Qwen3.5 backbone plus the trained reader and arbitration tensors. The large PLE remains an external quantized sidecar, rather than being packed into the model GGUF.
GGUF 文件包含 Qwen3.5 主干网络以及经过训练的 Reader 和 Arbitration 张量。大型 PLE 仍作为外部量化侧车(sidecar)存在,而非打包进模型 GGUF 中。
I also tested quantization retention on a separate fixed WikiText-2 GGUF runtime test:
我还在一个独立的固定 WikiText-2 GGUF 运行时测试中验证了量化保留效果:
- Q8_0 retains 99.1% of the BF16 reader NLL gain
- Q8_0 保留了 BF16 Reader NLL 增益的 99.1%
This is a separate runtime measurement, not the frozen Kaggle validation benchmark above.
这是单独的运行时测量结果,并非上述冻结的 Kaggle 验证基准。
I’d welcome attempts to reproduce or improve the reader, PLE caching, routing, or runtime.
欢迎尝试复现或改进 Reader、PLE 缓存、路由或运行时机制。
Next I’d like to try larger Qwen backbones, particularly the 35B-A3B MoE. Experiments at that scale require substantially more compute than free Kaggle notebooks can provide, but the 0.8B study gives a much clearer recipe for reader scaling and dynamic memory arbitration.
接下来我想尝试更大的 Qwen 主干网络,特别是 35B-A3B MoE 模型。在该规模下的实验需要比免费 Kaggle Notebook 所能提供的计算资源多得多,但 0.8B 的研究为 Reader 扩展和动态内存仲裁提供了更清晰的方案。
Disclosure: I’m the author of Qwengram and the linked repositories. English is not my first language, so I used AI to help proofread grammar and improve phrasing in this post. The experiment itself was also developed with the assistance of coding agents, primarily ChatGPT Sol, for implementation, debugging, experiment orchestration, and analysis support. I designed the experiments, made the research decisions, reviewed the results, and am responsible for the final conclusions.
披露:我是 Qwengram 及链接仓库的作者。英语非我的母语,因此我使用 AI 帮助校对语法并润色本文措辞。该实验本身也在编码智能体的协助下完成,主要借助 ChatGPT Sol 进行实现、调试、实验编排和分析支持。我设计了实验、做出了研究决策、审查了结果,并对最终结论负责。
更进一步:量化金融体系
看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力