一名Hacker News用户发布并展示了一款运行在计算机引导扇区(MBR)中的微型语言模型,其整个推理引擎仅占510字节1。该模型采用单隐藏层网络结构并使用int8整数运算,专门用于生成模拟的Linux内核启动消息(dmesg)1。为了容纳完整的模型参数,除了位于MBR的推理引擎外,权重、词汇表和字符串存储在后续扇区中1。
该模型的训练数据由机器生成的dmesg日志组成1。作者在开发过程中详细记录了调试经历,其中主要Bug源于x86汇编指令idiv的行为:该指令将余数存入edx寄存器时,覆盖了偏置表的指针,导致除第一个神经元外的计算错误1。此外,第二个Bug出现在输出环节,BIOS打印例程清零了包含预测字符编号的bx寄存器,干扰了最终文本的生成1。作为技术对比参考,类似项目sectorllm在1.2K汇编代码中实现了带有注意力机制的5层Llama2模型1。
A developer on Hacker News has demonstrated a miniature language model that operates directly within a computer's boot sector, specifically the Master Boot Record (MBR). 1 The entire inference engine for this model fits into just 510 bytes, with weights, vocabulary, and string data stored in subsequent sectors. 1 To achieve this compact footprint, the network utilizes a single hidden layer architecture and relies exclusively on int8 integer arithmetic. 1
The model was trained on machine-generated dmesg logs, which are Linux kernel boot messages, enabling it to simulate such startup outputs. 1 During development, the author encountered critical debugging challenges related to low-level register management. 1 One major bug arose because the idiv instruction stored remainders in the edx register, inadvertently overwriting the pointer to the bias table and causing calculation errors for all neurons except the first. 1 A second issue occurred when the BIOS print routine cleared the bx register, which held the index of the predicted character. 1 For context, the project references "sectorllm," a similar initiative that implemented a five-layer Llama2 model with attention mechanisms using 1.2K assembly code lines. 1
评论
还没有评论,欢迎留下第一条。