Text Generation
Transformers
Chinese
English
character-level
chinese
gru
mamba
Mixture of Experts
titans
Instructions to use masterofthestars/tianxuan with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use masterofthestars/tianxuan with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="masterofthestars/tianxuan")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("masterofthestars/tianxuan", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use masterofthestars/tianxuan with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "masterofthestars/tianxuan" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "masterofthestars/tianxuan", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/masterofthestars/tianxuan
- SGLang
How to use masterofthestars/tianxuan with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "masterofthestars/tianxuan" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "masterofthestars/tianxuan", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "masterofthestars/tianxuan" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "masterofthestars/tianxuan", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use masterofthestars/tianxuan with Docker Model Runner:
docker model run hf.co/masterofthestars/tianxuan
Tianxuan: full project + data (checkpoints, world_model, data without raw) with correct directory structure
db7bc06 Download scripts/prod-train.js from masterofthestars/tianxuan: direct link, hf CLI and curl.
- Browser
- Download file 2.53 kB
-
https://huggingface.co/masterofthestars/tianxuan/resolve/main/scripts/prod-train.js
- Command line
-
hf download hf://masterofthestars/tianxuan/scripts/prod-train.js
-
curl -L -o prod-train.js https://huggingface.co/masterofthestars/tianxuan/resolve/main/scripts/prod-train.js
2.53 kB
| /** | |
| * 天玄生产训练脚本 | |
| * | |
| * 使用完整的 48MB 真实语料进行生产级训练 | |
| * 启用所有在线持续学习机制 | |
| */ | |
| import * as fs from "fs"; | |
| import * as path from "path"; | |
| import { spawn } from "child_process"; | |
| const CKPT_DIR = "data/checkpoints"; | |
| const OUT_DIR = "sandbox/ck-prod-final"; | |
| console.log("=== 天玄生产训练脚本 ===\n"); | |
| // 检查数据 | |
| const rawDir = "data/raw"; | |
| if (!fs.existsSync(rawDir)) { | |
| console.error("❌ 未找到 data/raw/ 目录"); | |
| process.exit(1); | |
| } | |
| const files = fs.readdirSync(rawDir).filter(f => f.endsWith(".txt")); | |
| let totalBytes = 0; | |
| for (const f of files) { | |
| const stat = fs.statSync(path.join(rawDir, f)); | |
| totalBytes += stat.size; | |
| } | |
| const totalChars = Math.floor(totalBytes / 2); // 近似中文字符数 | |
| console.log(`✅ 找到 ${files.length} 个训练文件,共 ${totalChars.toLocaleString()} 字符`); | |
| if (totalChars < 100000) { | |
| console.error("❌ 数据量太少 (< 100K 字符),无法有效训练"); | |
| process.exit(1); | |
| } | |
| // 构建训练命令 | |
| const args = [ | |
| "--epochs=5", | |
| "--realcorpus=1", | |
| `--realTokens=${Math.min(totalChars, 1000000)}`, // 最多 1M tokens | |
| `--out=${OUT_DIR}`, | |
| "--lr=0.002", | |
| "--emb=64", | |
| "--hidden=256", | |
| "--ctx=8", | |
| "--bptt=32", | |
| "--maxvocab=100", | |
| "--ckpt=20", | |
| "--warmupsteps=50", | |
| ]; | |
| console.log(`\n🚀 开始训练...`); | |
| console.log(` 输出目录: ${OUT_DIR}`); | |
| console.log(` 预计时间: ~30 分钟 (CPU)`); | |
| console.log(` 命令: npm run train -- ${args.join(" ")}\n`); | |
| // 执行训练 | |
| const proc = spawn("npm", ["run", "train", "--", ...args], { | |
| stdio: "inherit", | |
| shell: true, | |
| }); | |
| proc.on("close", (code) => { | |
| if (code === 0) { | |
| console.log("\n✅ 训练完成!"); | |
| console.log(` 检查点: ${OUT_DIR}`); | |
| // 验证检查点 | |
| const metaPath = path.join(OUT_DIR, "meta.json"); | |
| if (fs.existsSync(metaPath)) { | |
| const meta = JSON.parse(fs.readFileSync(metaPath, "utf8")); | |
| console.log(` 训练步骤: ${meta.t}`); | |
| console.log(` 训练字符: ${meta.corpusTokens.toLocaleString()}`); | |
| console.log(` 词表大小: ${meta.vocab.length}`); | |
| } | |
| // 运行诊断 | |
| console.log("\n🔍 运行质量诊断..."); | |
| const diagProc = spawn("node", ["sandbox/dist/ml/diagnose.js", OUT_DIR], { | |
| stdio: "inherit", | |
| shell: true, | |
| }); | |
| diagProc.on("close", (diagCode) => { | |
| process.exit(diagCode ?? 0); | |
| }); | |
| } else { | |
| console.error("\n❌ 训练失败"); | |
| process.exit(code ?? 1); | |
| } | |
| }); | |