基础模型:
gmmeyer/gpt-bird(官方 PyTorch 权重small_pipes.pt) 本地仓:ohhoohho/gpt-bird· 硬件:{hardware NPU}(华为昇腾 910 系列)
gpt-bird 是一个 Flappy Bird 世界模型(world model):一个 nanoGPT 风格的 decoder-only
Transformer,训练为直接「成为」Flappy Bird。给定最近几帧离散状态与玩家动作,自回归输出下一帧
可量化的状态 token,从而 替代物理引擎 做逐帧仿真。
⚠️ 重要:它不是自然语言 LLM,输入 / 输出都是 232 个离散 state/action token(而非 文本),因此 不走 vLLM-Ascend 的 chat/completions 接口,而是直接用
torch_npu加载官方 PyTorch checkpoint 做服务化推理。这与通常 LLM 的vllm serve部署方式有本质区别。
| 项 | 值 |
|---|---|
| 架构 | nanoGPT 风格 decoder:n_layer=6 n_head=6 d_model=384 block_size=1280,RMSNorm + SDPA + GELU MLP,wte/lm_head 权重绑定 |
| 参数 | ~11.2 M(small_pipes.pt,全游戏:bird + pipes) |
| 词表 | 232 个 slot token(bird_y/pipe_dx/gap_y/status/action/EOS 等) |
| 每帧 | 4 个 state token([bird_y, pipe_dx, gap_y, status])+ 1 个动作 token |
| 量化 | bird_y→128 bins、pipe_dx→64 bins、gap_y→32 bins(NPU 推理时按 slot legal_mask 约束) |
| 输入格式 | <BOS> s0 a0 s1 a1 ... sT <EOS>,动作由玩家提供、不入预测 |
| 项 | 结果 |
|---|---|
| CPU↔NPU last-token logits 余弦 | 0.9999976 |
| NPU 单次前向(1280-token 上下文,torch_npu) | ≈3.1 ms |
| 约束生成合法性 | 逐 slot 施加 legal_mask,生成的帧 必然合法 |
torch==2.9.0+cpu,torch_npu==2.9.0.post1,CANN 8.5.1requirements.txt# 权重很小(small_pipes.pt ≈ 44 MB),官网 HF / 镜像均可
# gitcode 镜像: git clone --filter=blob:none https://gitcode.com/hf_mirrors/gmmeyer/gpt-bird.git
# 或 huggingface:small_pipes.ptpython inference.py --ckpt ./small_pipes.pt --device npu:0 --compare
# [status] device=npu params(M)=11.20 tier=small vocab=232
# [status] device=npu CPU-vs-NPU last-token logits cosine=0.9999976
# [status] predicted next-frame tokens: [60, 156, 212, 228] {...bird_y_bin:56, alive:True}python inference.py --ckpt ./small_pipes.pt --device npu:0 --serve --port 8000GET /health → {"device":"npu:0","status":"ok"}GET /v1/models → 模型元信息POST /predict → 单帧状态预测({"context":[...], "sample_slots":[2]})POST /generate → 连帧自回归 rollout({"context":[...], "frames":5})示例:
curl -s http://127.0.0.1:8000/health
curl -s http://127.0.0.1:8000/v1/models
curl -s -X POST http://127.0.0.1:8000/predict \
-H 'Content-Type: application/json' \
-d '{"context":[1,132,140,196,228,230,134,138,196,228,230]}'gpt-bird/
├── inference.py # 推理服务 + 单测(torch_npu,可 NPU/CPU 对比)
├── requirements.txt
├── dreaming_bird/ # vendor 官方自包含包(model/config/tokenizer/engine)
└── assets/ # agent_workflow / npu_device_call / model_result本模型是 非 LLM 世界模型,因此:
vllm serve(其面向可对话的因果语言模型,chat/completions 接口)。torch_npu 直接加载官方 .pt checkpoint,服务化推理(FastAPI/HTTP)。legal_mask 约束,保证格式合法。