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
File size: 3,712 Bytes
db7bc06 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | #!/usr/bin/env node
/**
* 天玄 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));
|