8.0
热点
AI SCORE
开源项目2026-08-24 05:41
纯CMake实现的GPT-2:用构建工具从零跑通大模型
Hacker News#GPT-2#CMake#开源
Editor brief · 编辑速览
开发者用纯CMake语法实现GPT-2模型推理,不依赖Python或第三方ML库,展示了构建系统与计算图结合的可能性。
用纯 CMake 实现的 GPT-2 模型,使用 Q16.16 整数运算执行。
mkdir -p checkpoint
curl -L -o checkpoint/model.safetensors https://huggingface.co/openai-community/gpt2/resolve/main/model.safetensors
curl -L -o checkpoint/vocab.json https://huggingface.co/openai-community/gpt2/resolve/main/vocab.json
curl -L -o checkpoint/merges.txt https://huggingface.co/openai-community/gpt2/resolve/main/merges.txt
python3 tools/gen_full.py
cmake -P gpt2_full.cmake -DPROMPT="Hello" -DN=2
python3 tools/gen_tables.py
python3 tools/gen_model.py
cmake -P gpt2.cmake
BSD 3-Clause。参见 LICENSE。