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: 1,657 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 | import * as path from "path";
import { Engine } from "./engine";
async function main(): Promise<void> {
const engine = Engine.load(path.resolve("sandbox/ck-full-multi"));
// 直接测试 Titans 记忆
const titansMem = (engine as any).titansMem;
console.log("TitansMem slots:", titansMem.cfg.slots);
console.log("TitansMem chars (first 10):", titansMem.chars.slice(0, 10));
console.log("TitansMem occupancy:", titansMem.occupancy().toFixed(2));
// 测试 recallAt
const promptIds = engine.tokenizer.encode("小明");
const ctxWin = promptIds.slice(-engine.model.cfg.ctx);
console.log("ctxWin:", ctxWin);
const q = Float64Array.from(engine.model.embedAvg(ctxWin));
const cache = { query: new Float64Array(0), keys: new Float64Array(0), values: new Float64Array(0), weights: new Float64Array(0) };
const mem = titansMem.read(q, cache);
console.log("hitSlots:", mem.hitSlots);
console.log("weights (first 10):", cache.weights.slice(0, 10));
// 找到权重最大的槽位
let best = 0;
for (let i = 1; i < cache.weights.length; i++) {
if (cache.weights[i] > cache.weights[best]) best = i;
}
console.log("best slot:", best, "weight:", cache.weights[best]);
console.log("chars[best]:", titansMem.chars[best]);
console.log("chars[best % slots]:", titansMem.chars[best % titansMem.cfg.slots]);
// 测试生成
const res = await engine.generate({ prompt: "小明", maxLen: 20, budget: 3, temperature: 0.85, topK: 5 });
console.log("\n生成结果:", res.text);
console.log("路由统计:", res.routes.map(r => `L${r.depth}:${r.char}`).join(""));
}
main().catch(err => console.error(err));
|