kazama0453/chinese-poker-gpt

🤗 Hugging Face sourcemit190 MBother✓ 2 checksumsupdated today
Submit in one command

Run it next to your model folder. It makes the torrent, checks your files against Hugging Face, and submits it. You just start seeding and paste your key from your account. It only reads your files and never changes them. Read the script first if you like.

curl -fsSL https://pirateface.co/package.sh | bash -s -- --repo kazama0453/chinese-poker-gpt ./model-folder
Needs a seeder →

Chinese Poker GPT

一个从零开始训练的中文语言模型,具备基础的扑克策略问答能力。

模型介绍

本模型完全从零开始训练,不依赖任何预训练权重,记录了一个完整的语言模型训练过程。

属性 详情
参数量 15.65M
架构 nanoGPT(Decoder-only Transformer)
词表大小 13113
上下文长度 512 tokens
训练硬件 Apple M4 Pro 48GB

训练过程

第一阶段:预训练

  • 数据:中文维基百科 50000 篇文章
  • 步数:100000 steps
  • 最终 val loss:2.93

第二阶段:知识蒸馏 + 指令微调

  • Teacher 模型:Qwen2.5-72B
  • 蒸馏数据:12946 条中文问答(通用 + 扑克策略)
  • 步数:6000 steps(在预训练基础上继续)
  • 最终 val loss:1.51

使用方法

import pickle
import torch

# 加载词表
with open('meta.pkl', 'rb') as f:
    meta = pickle.load(f)

stoi = meta['stoi']
itos = meta['itos']
SPECIAL_TOKENS = ['<|user|>', '<|assistant|>', '<|end|>']

def encode(text):
    tokens = []
    i = 0
    while i < len(text):
        matched = False
        for special in SPECIAL_TOKENS:
            if text[i:i+len(special)] == special:
                tokens.append(stoi[special])
                i += len(special)
                matched = True
                break
        if not matched:
            ch = text[i]
            if ch in stoi:
                tokens.append(stoi[ch])
            i += 1
    return tokens

# 推理示例
question = "什么是德州扑克中的位置优势?"
prompt = f"<|user|>{question}<|end|><|assistant|>"

模型输出示例

问: 什么是德州扑克中的位置优势?

答: 在扑克中,位置优势是指玩家在有利位置时的策略优势。

  1. 信息获取:后位玩家可以观察到前面玩家的行动...
  2. 控制底池:按钮位置可以根据对手行动调整策略...

局限性

  • 参数量较小(15.65M),复杂推理能力有限
  • 没有多轮对话能力
  • 未经过 RLHF 对齐

训练日志

完整训练过程记录见作者 GitHub(包含所有参数调试细节和 loss 曲线分析)。

作者

训练目的:学习语言模型训练全链路,作为 AI 产品方向的个人项目。