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/start-training-v1.js from masterofthestars/tianxuan: direct link, hf CLI and curl.
- Browser
- Download file 4.19 kB
-
https://huggingface.co/masterofthestars/tianxuan/resolve/main/scripts/start-training-v1.js
- Command line
-
hf download hf://masterofthestars/tianxuan/scripts/start-training-v1.js
-
curl -L -o start-training-v1.js https://huggingface.co/masterofthestars/tianxuan/resolve/main/scripts/start-training-v1.js
4.19 kB
| /** | |
| * 天玄 TianXuan - 启动训练并实时监控 | |
| */ | |
| const { spawn } = require('child_process'); | |
| const fs = require('fs'); | |
| const path = require('path'); | |
| const CHECKPOINT_DIR = 'data/checkpoints_v0.000001'; | |
| const TARGET_STEPS = 2000; | |
| const POLL_INTERVAL = 5000; // 5秒轮询 | |
| console.log('='.repeat(70)); | |
| console.log('天玄 TianXuan - 启动训练 (v0.000001)'); | |
| console.log('='.repeat(70)); | |
| console.log(''); | |
| console.log('训练配置:'); | |
| console.log(' 语料长度: 10,000,000 字符'); | |
| console.log(' Epoch 数: 10'); | |
| console.log(' STDP: 启用 (rate=0.001)'); | |
| console.log(' STDA: 启用 (rate=0.0005)'); | |
| console.log(' 检查点: ' + CHECKPOINT_DIR); | |
| console.log(''); | |
| // 启动训练进程 | |
| const trainCmd = process.platform === 'win32' ? 'npm.cmd' : 'npm'; | |
| const trainArgs = ['run', 'train', '--', | |
| '--realcorpus', '0', | |
| '--tokens', '10000000', | |
| '--epochs', '10', | |
| '--stdp', '1', | |
| '--stda', '1', | |
| '--out', CHECKPOINT_DIR, | |
| '--seed', '42' | |
| ]; | |
| const train = spawn(trainCmd, trainArgs, { | |
| cwd: process.cwd(), | |
| stdio: 'inherit' | |
| }); | |
| let lastBatch = 0; | |
| let startTime = Date.now(); | |
| console.log(''); | |
| console.log('【训练已启动,开始监控...】'); | |
| console.log(''); | |
| // 监控函数 | |
| function poll() { | |
| const metaPath = path.join(process.cwd(), CHECKPOINT_DIR, 'meta.json'); | |
| if (!fs.existsSync(metaPath)) { | |
| return; | |
| } | |
| try { | |
| const meta = JSON.parse(fs.readFileSync(metaPath, 'utf8')); | |
| const currentBatch = meta.t || 0; | |
| if (currentBatch !== lastBatch && currentBatch > 0) { | |
| const elapsed = Date.now() - startTime; | |
| const bps = currentBatch / (elapsed / 1000); | |
| const progress = Math.min(100, (currentBatch / TARGET_STEPS) * 100); | |
| console.log(`\n[${new Date().toLocaleTimeString('zh-CN')}] 进度: ${currentBatch}/${TARGET_STEPS} (${progress.toFixed(1)}%)`); | |
| console.log(` 速度: ${bps.toFixed(1)} 步/秒 | 已用: ${Math.floor(elapsed/1000)}秒`); | |
| // STDP 状态 | |
| if (meta.stdpState) { | |
| const ratio = meta.stdpState.ltpSignalSum / Math.max(meta.stdpState.ltdSignalSum, 0.001); | |
| console.log(` STDP: ${meta.stdpState.stepCount}次更新 | LTP/LTD=${ratio.toFixed(2)}`); | |
| } | |
| // STDA 状态 | |
| if (meta.stdaState) { | |
| console.log(` STDA: 阈值偏移=${meta.stdaState.thresholdShift.toFixed(4)} | 激活=${meta.stdaState.actAvg.toFixed(4)}`); | |
| } | |
| // Titans 状态 | |
| if (meta.titansWriteLog) { | |
| console.log(` Titans: ${meta.titansWriteLog.length}条记录`); | |
| } | |
| // Replay 状态 | |
| if (meta.replayState) { | |
| console.log(` Replay: ${meta.replayState.buffer?.length}/${meta.replayState.maxCapacity}`); | |
| } | |
| // 生成测试 | |
| if (currentBatch > 0 && currentBatch % 100 === 0) { | |
| console.log(` [生成测试]`); | |
| try { | |
| const { execSync } = require('child_process'); | |
| const out = execSync(`node sandbox/dist/ml/generate.js --checkpoint ${CHECKPOINT_DIR} --prompt "小明" --len 50`, { | |
| encoding: 'utf8', | |
| stdio: ['pipe', 'pipe', 'pipe'] | |
| }); | |
| const lines = out.split('\n').filter(l => l.trim()); | |
| const textLine = lines.find(l => l.startsWith('小明')); | |
| if (textLine) { | |
| const uniqueChars = new Set(textLine.split('')).size; | |
| console.log(` "${textLine.slice(0, 30)}..." → 唯一字符: ${uniqueChars}`); | |
| } | |
| } catch (e) { | |
| // 静默失败 | |
| } | |
| } | |
| lastBatch = currentBatch; | |
| // 检查完成 | |
| if (currentBatch >= TARGET_STEPS) { | |
| console.log('\n✅ 训练完成!'); | |
| process.exit(0); | |
| } | |
| } | |
| } catch (e) { | |
| // 静默忽略解析错误 | |
| } | |
| } | |
| // 启动轮询 | |
| const interval = setInterval(poll, POLL_INTERVAL); | |
| // 处理训练进程退出 | |
| train.on('close', (code) => { | |
| clearInterval(interval); | |
| console.log(`\n训练进程已退出 (code: ${code})`); | |
| process.exit(code); | |
| }); | |
| // 处理中断 | |
| process.on('SIGINT', () => { | |
| console.log('\n\n正在停止训练...'); | |
| train.kill('SIGINT'); | |
| clearInterval(interval); | |
| process.exit(0); | |
| }); | |