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/build-corpus.js from masterofthestars/tianxuan: direct link, hf CLI and curl.
- Browser
- Download file 4.43 kB
-
https://huggingface.co/masterofthestars/tianxuan/resolve/main/scripts/build-corpus.js
- Command line
-
hf download hf://masterofthestars/tianxuan/scripts/build-corpus.js
-
curl -L -o build-corpus.js https://huggingface.co/masterofthestars/tianxuan/resolve/main/scripts/build-corpus.js
4.43 kB
| /** | |
| * 构建结构化中文语料,用于提升语义连贯性 | |
| * 生成句子模式:{主语} {动词} {宾语} {逗号/句号} | |
| */ | |
| const fs = require('fs'); | |
| const path = require('path'); | |
| // 角色列表 | |
| const characters = ['小明', '小红', '小刚', '小李', '小王', '小张', '老李', '老张']; | |
| // 动作列表 | |
| const actions = { | |
| '吃': ['饭', '苹果', '香蕉', '面包', '蛋糕', '面条', '米饭', '饺子'], | |
| '喝': ['水', '茶', '牛奶', '果汁', '咖啡'], | |
| '看': ['书', '电视', '手机', '报纸', '杂志', '电影'], | |
| '读': ['书', '报纸', '杂志', '文章', '故事'], | |
| '写': '字', | |
| '画': '画', | |
| '玩': ['球', '玩具', '游戏', '电脑'], | |
| '跑': '步', | |
| '走': '路', | |
| '坐': '下', | |
| '站': '起', | |
| '开': ['门', '窗', '灯', '书', '电脑'], | |
| '关': ['门', '窗', '灯', '电视', '电脑'], | |
| '拿': ['书', '笔', '杯', '球', '包'], | |
| '放': ['书', '笔', '杯', '球', '包'], | |
| '摸': ['门', '墙', '桌子', '椅子'], | |
| '打': ['球', '电话', '游戏'], | |
| '听': ['音乐', '广播', '故事'], | |
| '说': '话', | |
| '想': '事', | |
| '做': '事', | |
| '学习': ['学习', '知识', '文化'], | |
| '工作': ['工作', '任务', '项目'], | |
| '休息': ['休息', '放松', '休假'], | |
| '睡觉': ['睡觉', '休息', '打盹'], | |
| '起床': ['起床', '早起', '醒来'], | |
| '吃饭': ['吃饭', '用餐', '就餐'], | |
| '洗澡': ['洗澡', '沐浴', '冲洗'], | |
| '刷牙': ['刷牙', '漱口', '清洁'], | |
| '洗脸': ['洗脸', '洁面', '清洗'], | |
| }; | |
| // 时间状语 | |
| const timePhrases = [ | |
| '早上', '中午', '下午', '晚上', '今天', '明天', '昨天', | |
| '现在', '刚才', '一会儿', '马上', '立刻', '突然', | |
| ]; | |
| // 地点状语 | |
| const placePhrases = [ | |
| '家里', '学校', '公园', '商店', '图书馆', '医院', '餐厅', | |
| '卧室', '客厅', '厨房', '卫生间', '操场', '教室', | |
| ]; | |
| // 情感状语 | |
| const emotionPhrases = [ | |
| '开心地', '开心地', '难过地', '生气地', '害怕地', '惊讶地', | |
| '慢慢地', '快速地', '轻轻地', '重重地', | |
| ]; | |
| function randomFrom(arr) { | |
| return arr[Math.floor(Math.random() * arr.length)]; | |
| } | |
| function generateSentence() { | |
| const pattern = Math.random(); | |
| let sentence = ''; | |
| if (pattern < 0.3) { | |
| // 简单句:主语 + 动词 + 宾语 | |
| const subject = randomFrom(characters); | |
| const verb = randomFrom(Object.keys(actions)); | |
| const verbDesc = actions[verb]; | |
| const object = Array.isArray(verbDesc) ? randomFrom(verbDesc) : (verbDesc || ''); | |
| sentence = `${subject}${verb}${object}`; | |
| } else if (pattern < 0.6) { | |
| // 带时间状语:时间 + 主语 + 动词 + 宾语 | |
| const time = randomFrom(timePhrases); | |
| const subject = randomFrom(characters); | |
| const verb = randomFrom(Object.keys(actions)); | |
| const verbDesc = actions[verb]; | |
| const object = Array.isArray(verbDesc) ? randomFrom(verbDesc) : (verbDesc || ''); | |
| sentence = `${time},${subject}${verb}${object}`; | |
| } else if (pattern < 0.8) { | |
| // 带地点状语:主语 + 动词 + 宾语 + 地点 | |
| const subject = randomFrom(characters); | |
| const verb = randomFrom(Object.keys(actions)); | |
| const verbDesc = actions[verb]; | |
| const object = Array.isArray(verbDesc) ? randomFrom(verbDesc) : (verbDesc || ''); | |
| const place = randomFrom(placePhrases); | |
| sentence = `${subject}${verb}${object},在${place}`; | |
| } else { | |
| // 复杂句:时间 + 主语 + 动词 + 宾语 + 情感 | |
| const time = randomFrom(timePhrases); | |
| const subject = randomFrom(characters); | |
| const verb = randomFrom(Object.keys(actions)); | |
| const verbDesc = actions[verb]; | |
| const object = Array.isArray(verbDesc) ? randomFrom(verbDesc) : (verbDesc || ''); | |
| const emotion = randomFrom(emotionPhrases); | |
| sentence = `${time},${subject}${verb}${object},${emotion}`; | |
| } | |
| // 添加标点 | |
| if (Math.random() < 0.7) { | |
| sentence += '。'; | |
| } else { | |
| sentence += '!'; | |
| } | |
| return sentence; | |
| } | |
| function generateCorpus(numSentences) { | |
| const sentences = []; | |
| for (let i = 0; i < numSentences; i++) { | |
| sentences.push(generateSentence()); | |
| } | |
| return sentences.join('\n'); | |
| } | |
| // 生成语料 | |
| const corpus = generateCorpus(100000); | |
| fs.writeFileSync('data/corpus_structured.txt', corpus, 'utf-8'); | |
| console.log(`Generated ${corpus.split('\n').length} sentences`); | |
| console.log(`Total characters: ${corpus.length}`); | |
| console.log(`Sample: ${corpus.slice(0, 500)}`); | |