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: 2,129 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 | import * as path from "path";
import { Engine } from "./engine";
async function main(): Promise<void> {
const engine = Engine.load(path.resolve("sandbox/ck-titans-test"));
// Check Titans memory
const titansMem = (engine as any).titansMem;
console.log("=== TITANS MEMORY CHECK ===");
console.log("Slots:", titansMem.cfg.slots);
console.log("Occupancy:", titansMem.occupancy().toFixed(2));
console.log("Total writes (from log):", titansMem._writeCount || "unknown");
// Check first few chars
const nonEmpty = titansMem.chars.filter((c: string) => c && c !== "").slice(0, 20);
console.log("Non-empty chars sample:", nonEmpty);
// Test with prompt
const promptIds = engine.tokenizer.encode("小明");
const ctxWin = promptIds.slice(-engine.model.cfg.ctx);
console.log("ctxWin:", ctxWin);
// Test Titans read
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 length:", cache.weights.length);
console.log("weights[0..9]:", Array.from(cache.weights.slice(0, 10)).map((w, i) => ({ slot: i, weight: w.toFixed(4) })));
// Find best slot
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].toFixed(4));
console.log("chars[best]:", JSON.stringify(titansMem.chars[best]));
console.log("chars[best % slots]:", JSON.stringify(titansMem.chars[best % titansMem.cfg.slots]));
// Test generate
console.log("\n=== GENERATION TEST ===");
const res = await engine.generate({ prompt: "小明", maxLen: 20, budget: 3, temperature: 0.85, topK: 5 });
console.log("Output:", res.text);
console.log("Routes:", res.routes.map((r, i) => `${i}:${r.char}(L${r.depth})`).join(" "));
console.log("MemHits:", res.routes.filter(r => r.memoryHit).length);
}
main().catch(err => console.error(err));
|