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/compare-checkpoints.js from masterofthestars/tianxuan: direct link, hf CLI and curl.
- Browser
- Download file 3.71 kB
-
https://huggingface.co/masterofthestars/tianxuan/resolve/main/scripts/compare-checkpoints.js
- Command line
-
hf download hf://masterofthestars/tianxuan/scripts/compare-checkpoints.js
-
curl -L -o compare-checkpoints.js https://huggingface.co/masterofthestars/tianxuan/resolve/main/scripts/compare-checkpoints.js
3.71 kB
| /** | |
| * 天玄 TianXuan - 对比实验脚本 | |
| * 对比不同检查点的在线学习效果 | |
| */ | |
| const fs = require('fs'); | |
| const path = require('path'); | |
| const { execSync } = require('child_process'); | |
| console.log('='.repeat(70)); | |
| console.log('天玄 TianXuan - 对比实验'); | |
| console.log('='.repeat(70)); | |
| console.log(''); | |
| const checkpoints = [ | |
| { name: '旧检查点 (无STDP/STDA)', path: 'checkpoints' }, | |
| { name: '新检查点 v2 (有STDP/STDA, 51步)', path: 'data/checkpoints_v2' }, | |
| { name: '当前检查点 v3', path: 'data/checkpoints_v3' }, | |
| { name: '最新检查点 v4', path: 'data/checkpoints_v4' }, | |
| ]; | |
| const prompts = ['小明', '老王', '阿芳']; | |
| console.log('【检查点信息】\n'); | |
| for (const ckpt of checkpoints) { | |
| const metaPath = path.join(ckpt.path, 'meta.json'); | |
| if (fs.existsSync(metaPath)) { | |
| const meta = JSON.parse(fs.readFileSync(metaPath, 'utf8')); | |
| console.log(` ${ckpt.name}`); | |
| console.log(` 路径: ${ckpt.path}`); | |
| console.log(` 训练步数: ${meta.t} 步`); | |
| console.log(` STDP: ${meta.stdp ? '✓' : '✗'}`); | |
| console.log(` STDA: ${meta.stda ? '✓' : '✗'}`); | |
| console.log(` 唯一字符 (平均): 待测试`); | |
| console.log(''); | |
| } else { | |
| console.log(` ⚠ ${ckpt.name} - 检查点不存在`); | |
| console.log(''); | |
| } | |
| } | |
| console.log('【开始生成测试】\n'); | |
| const results = {}; | |
| for (const ckpt of checkpoints) { | |
| const metaPath = path.join(ckpt.path, 'meta.json'); | |
| if (!fs.existsSync(metaPath)) continue; | |
| console.log(`--- ${ckpt.name} ---`); | |
| results[ckpt.path] = { uniqueChars: [], coherence: [] }; | |
| for (const prompt of prompts) { | |
| try { | |
| const cmd = `node sandbox/dist/ml/generate.js --checkpoint ${ckpt.path} --prompt "${prompt}" --len 100`; | |
| const output = execSync(cmd, { | |
| cwd: 'C:\\Users\\l1064\\Desktop\\tianxuan', | |
| encoding: 'utf8', | |
| stdio: ['pipe', 'pipe', 'pipe'] | |
| }); | |
| const lines = output.split('\n').filter(l => l.trim()); | |
| const textLine = lines.find(l => l.startsWith(prompt)); | |
| if (textLine) { | |
| const uniqueChars = new Set(textLine.split('')).size; | |
| const coherence = uniqueChars / textLine.length; | |
| results[ckpt.path].uniqueChars.push(uniqueChars); | |
| results[ckpt.path].coherence.push(coherence); | |
| console.log(` "${prompt}" → 唯一字符: ${uniqueChars}, 连贯性: ${coherence.toFixed(3)}`); | |
| } | |
| } catch (e) { | |
| console.error(` 错误: ${e.message.slice(0, 50)}`); | |
| } | |
| } | |
| console.log(''); | |
| } | |
| // 对比分析 | |
| console.log('='.repeat(70)); | |
| console.log('对比分析'); | |
| console.log('='.repeat(70)); | |
| console.log(''); | |
| const avgResults = {}; | |
| for (const [path, data] of Object.entries(results)) { | |
| const avgUnique = data.uniqueChars.reduce((a, b) => a + b, 0) / data.uniqueChars.length; | |
| const avgCoherence = data.coherence.reduce((a, b) => a + b, 0) / data.coherence.length; | |
| avgResults[path] = { avgUnique, avgCoherence }; | |
| } | |
| // 找出最佳 | |
| let bestPath = null; | |
| let bestUnique = 0; | |
| for (const [path, data] of Object.entries(avgResults)) { | |
| if (data.avgUnique > bestUnique) { | |
| bestUnique = data.avgUnique; | |
| bestPath = path; | |
| } | |
| } | |
| console.log('指标对比:'); | |
| for (const [path, data] of Object.entries(avgResults)) { | |
| const ckptName = checkpoints.find(c => c.path === path)?.name || path; | |
| const icon = path === bestPath ? '🏆' : ' '; | |
| console.log(` ${icon} ${ckptName}: 唯一字符=${data.avgUnique.toFixed(1)}, 连贯性=${data.avgCoherence.toFixed(3)}`); | |
| } | |
| console.log(''); | |
| if (bestPath) { | |
| console.log(`🏆 最佳检查点:${bestPath}`); | |
| } | |
| console.log(''); | |
| console.log('='.repeat(70)); | |