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: 5,720 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 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | #!/usr/bin/env node
/**
* 天玄 TianXuan - 在线学习修复脚本
*
* 问题诊断:
* 1. 检查点元数据与实际语料不匹配 (1384 vs 1,500,000 字符)
* 2. STDP/STDA 未启用
* 3. 训练步数严重不足 (仅 4 步)
* 4. 缺乏真实中文语料
*
* 修复方案:
* 1. 使用真实语料 (corpus_real.txt)
* 2. 启用 STDP + STDA 机制
* 3. 配置专业训练参数
* 4. 持续训练直到在线学习稳定
*/
const fs = require('fs');
const path = require('path');
console.log('='.repeat(60));
console.log('天玄 TianXuan - 在线学习修复工具');
console.log('='.repeat(60));
console.log('');
// 1. 检查语料文件
console.log('📊 语料文件检查:');
const corpusFiles = {
'corpus.txt': 'data/corpus.txt',
'corpus_real.txt': 'data/corpus_real.txt',
'corpus_large.txt': 'data/corpus_large.txt'
};
for (const [name, filepath] of Object.entries(corpusFiles)) {
if (fs.existsSync(filepath)) {
const stats = fs.statSync(filepath);
console.log(` ✓ ${name}: ${(stats.size / 1024 / 1024).toFixed(2)} MB (${stats.size} 字符)`);
} else {
console.log(` ✗ ${name}: 文件不存在`);
}
}
console.log('');
// 2. 检查当前检查点
console.log('📦 当前检查点状态:');
const metaPath = 'checkpoints/meta.json';
if (fs.existsSync(metaPath)) {
const meta = JSON.parse(fs.readFileSync(metaPath, 'utf8'));
console.log(` 训练步数: ${meta.t || 0}`);
console.log(` 语料长度: ${meta.corpusTokens || 0} 字符`);
console.log(` 词表大小: ${meta.config?.vocabSize || 0}`);
console.log(` STDP: ${meta.stdp ? '✓ 已启用' : '✗ 未启用'}`);
console.log(` STDA: ${meta.stda ? '✓ 已启用' : '✗ 未启用'}`);
console.log(` Titans: ${meta.onlineTitans ? '✓ 已启用' : '✗ 未启用'}`);
console.log(` Replay: ${meta.replay ? '✓ 已启用' : '✗ 未启用'}`);
console.log(` 训练时间: ${meta.trainedAt || '未知'}`);
} else {
console.log(' ✗ 检查点元数据不存在');
}
console.log('');
// 3. 推荐修复配置
console.log('🔧 推荐修复配置:');
console.log('');
console.log('【方案 A: 快速验证 (1小时)】');
console.log(' 语料: corpus_real.txt (前 5MB)');
console.log(' 参数: emb=64, hidden=128, ctx=8, bptt=16');
console.log(' 训练: --epochs 3 --tokens 5000000 --stdp 1 --stda 1');
console.log(' 预期: 1-2 小时完成,验证在线学习机制');
console.log('');
console.log('【方案 B: 完整训练 (6-8小时)】');
console.log(' 语料: corpus_real.txt (完整 48MB)');
console.log(' 参数: emb=64, hidden=128, ctx=8, bptt=32');
console.log(' 训练: --epochs 5 --tokens 48000000 --stdp 1 --stda 1');
console.log(' 预期: 6-8 小时完成,达到生产级质量');
console.log('');
console.log('【方案 C: 最小修复 (30分钟)】');
console.log(' 语料: corpus.txt (现有 1.5MB)');
console.log(' 参数: 保持当前配置');
console.log(' 训练: --epochs 10 --tokens 1500000 --stdp 1 --stda 1');
console.log(' 预期: 30 分钟完成,快速验证 STDP/STDA');
console.log('');
// 4. 生成启动命令
console.log('🚀 一键启动命令:');
console.log('');
console.log('# 方案 A - 快速验证 (推荐)');
console.log('npm run train -- --realcorpus 0 --tokens 5000000 --epochs 3 --stdp 1 --stda 1 --out data/checkpoints_v2');
console.log('');
console.log('# 方案 B - 完整训练');
console.log('npm run train -- --realcorpus 1 --rawdir data --realrawperfile 5000000 --epochs 5 --stdp 1 --stda 1 --out data/checkpoints_v2');
console.log('');
console.log('# 方案 C - 最小修复');
console.log('npm run train -- --realcorpus 0 --tokens 1500000 --epochs 10 --stdp 1 --stda 1 --out data/checkpoints_v2');
console.log('');
// 5. 创建诊断报告
const report = {
timestamp: new Date().toISOString(),
issues: [
{
id: 'CORPUS_MISMATCH',
severity: 'HIGH',
description: '检查点元数据语料长度与实际不符',
current: '1384 字符',
expected: '≥ 1,500,000 字符',
impact: '导致训练数据严重不足,模型无法学习有效模式'
},
{
id: 'STDP_OFF',
severity: 'MEDIUM',
description: 'STDP (突触时序依赖可塑性) 未启用',
current: '关闭',
expected: '开启',
impact: '无法实现在线学习的突触权重自适应调整'
},
{
id: 'STDA_OFF',
severity: 'MEDIUM',
description: 'STDA (突触阈值适应) 未启用',
current: '关闭',
expected: '开启',
impact: '无法实现神经元兴奋性自适应调节'
},
{
id: 'INSUFFICIENT_STEPS',
severity: 'HIGH',
description: '训练步数严重不足',
current: '4 步',
expected: '≥ 1000 步',
impact: '模型尚未收敛,参数未充分优化'
}
],
recommendations: [
'使用真实中文语料 (corpus_real.txt) 替代合成语料',
'启用 STDP + STDA 机制实现真正的在线学习',
'增加训练步数至 1000+ 步',
'使用专业训练参数 (lr=0.0006, warmup=100, batch=64)',
'定期保存检查点并监控训练指标'
],
nextSteps: [
'选择修复方案 (A/B/C) 并执行',
'监控训练日志,确认 STDP/STDA 正常工作',
'验证在线学习机制 (记忆巩固、突触适应)',
'对比修复前后生成质量'
]
};
const reportPath = 'diagnostics/online-learning-fix-report.json';
fs.mkdirSync('diagnostics', { recursive: true });
fs.writeFileSync(reportPath, JSON.stringify(report, null, 2));
console.log(`✅ 诊断报告已保存: ${reportPath}`);
console.log('');
console.log('📝 下一步:选择方案 A/B/C 之一启动训练');
console.log('='.repeat(60));
|