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 stellaris/test_closed_loop_phase3.py from masterofthestars/tianxuan: direct link, hf CLI and curl.
- Browser
- Download file 4.61 kB
-
https://huggingface.co/masterofthestars/tianxuan/resolve/main/stellaris/test_closed_loop_phase3.py
- Command line
-
hf download hf://masterofthestars/tianxuan/stellaris/test_closed_loop_phase3.py
-
curl -L -o test_closed_loop_phase3.py https://huggingface.co/masterofthestars/tianxuan/resolve/main/stellaris/test_closed_loop_phase3.py
4.61 kB
| #!/usr/bin/env python3 | |
| """ | |
| 群星 P8 · Phase 3 闭环不变量测试 (宪章第 7/8 条: 机制可量化) | |
| 用法: python3 -m stellaris.test_closed_loop_phase3 | |
| 断言 (对应文档 4.5 推理 + 4.6 认知控制 + 9 认知循环 Phase 3): | |
| 1. 六引擎全部启动成功 (perception/state/memory/world_model/reasoning/cognitive_control) | |
| 2. 认知控制始终在线 (stop 被拒), 推理按需可停止 | |
| 3. 策略路由: 任务类型分布与 task_cycle 一致 | |
| 4. 策略路由: 每条 policy 的 route 与 engines 一致 (order == engines) | |
| 5. 推理: 每事件都有推理结果, avg_chain_len >= 2 (读状态+预测) | |
| 6. 推理: 结论含「下一事件」或「基于世界模型」 (真实通路, 非写死) | |
| 7. 世界模型命中率在 [0,1] 且 > 0 (转移矩阵已学习) | |
| 8. 预测误差信号产生 (Phase 4 Learning 前置通路) | |
| 9. 行动占位: active_process 分区有 last_reasoning (不外发, record-only) | |
| 10. 主观时钟 = 事件数 | |
| """ | |
| from __future__ import annotations | |
| import sys | |
| from pathlib import Path | |
| sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) | |
| import yaml | |
| from stellaris.main_phase3 import run_closed_loop | |
| def test_phase3() -> int: | |
| cfg = yaml.safe_load( | |
| (Path(__file__).resolve().parent / "configs" / "engine_config.yaml").read_text(encoding="utf-8") | |
| ) | |
| n = 10 | |
| s = run_closed_loop(cfg, n_events=n) | |
| # 1. 六引擎全部启动 | |
| started_engines = [e for e in ("perception", "state", "memory", "world_model", | |
| "reasoning", "cognitive_control")] | |
| health_names = set(s["health"].keys()) | |
| for e in started_engines: | |
| assert e in health_names, f"引擎 {e} 未启动 (health 缺失)" | |
| # 2. 认知控制始终在线 (stop_all 后 world_model 可停, 但 control 拒 stop) | |
| assert s["health"]["cognitive_control"]["healthy"] is True | |
| assert s["health"]["reasoning"]["healthy"] is True | |
| # 3. 策略任务类型分布 (task_cycle=[fact,causal,novel,fact] × n 事件) | |
| # n=10: fact=5(0,4,8 位置? 不对, 循环 fact,causal,novel,fact 周期4) | |
| # i%4: 0=fact,1=causal,2=novel,3=fact → 0..9: fact=5(0,3,4,7,8? 不对) | |
| # 精确: i=0,1,2,3,4,5,6,7,8,9 → fact,causal,novel,fact,fact,causal,novel,fact,fact,causal | |
| # fact=5(0,3,4,7,8? 让我数: i%4==0→fact(0,4,8)=3, i%4==3→fact(3,7)=2, 合计fact=5 | |
| # causal: i%4==1(1,5,9)=3, novel: i%4==2(2,6)=2 | |
| dist = s["policy_task_distribution"] | |
| assert dist.get("fact") == 5, f"fact 策略数 {dist.get('fact')} != 5 (n={n})" | |
| assert dist.get("causal") == 3, f"causal 策略数 {dist.get('causal')} != 3 (n={n})" | |
| assert dist.get("novel") == 2, f"novel 策略数 {dist.get('novel')} != 2 (n={n})" | |
| # 4. 策略 route == engines (order 与 engines 一致) | |
| for p in s["policies"]: | |
| assert p["route"] == p["engines"], f"策略 route {p['route']} != engines {p['engines']}" | |
| # 5. 推理: 每事件都有结果 | |
| assert s["reasoning"]["n_results"] == n, "推理未逐事件生成" | |
| assert s["reasoning"]["avg_chain_len"] >= 2, \ | |
| f"推理链平均 {s['reasoning']['avg_chain_len']} < 2 (应含读状态+预测)" | |
| # 6. 推理结论非写死 (含真实通路关键词) | |
| sample = s["reasoning"]["sample"] | |
| for r in sample: | |
| c = str(r["conclusion"]) | |
| assert ("下一事件" in c) or ("基于世界模型" in c) or ("基于" in c) \ | |
| or ("信息不足" in c), f"推理结论疑似写死: {c}" | |
| # 7. 世界模型命中率合法且 > 0 | |
| hr = s["world_model"]["hit_rate"] | |
| assert 0.0 < hr <= 1.0, f"世界模型命中率 {hr} 应 > 0 且 ≤ 1" | |
| assert s["world_model"]["total_transitions"] >= n - 2, "世界模型转移数过少" | |
| # 8. 预测误差信号 | |
| assert len(s["prediction_errors"]) == n - 1, "误差信号数量 = 事件数 - 1" | |
| assert s["mean_prediction_error"] >= 0.0, "误差均值必须非负" | |
| # 9. 行动占位: active_process 分区有 last_reasoning | |
| ap = s["active_process"] | |
| assert ap is not None, "active_process 分区未写入" | |
| assert "last_reasoning" in ap, "行动占位缺少 last_reasoning" | |
| assert ap.get("action_taken") == "record-only", "Phase 5 前应只记录不外发" | |
| # 10. 主观时钟 | |
| assert s["t_subj"] == float(n), f"主观时钟 {s['t_subj']} != {n}" | |
| print("== P8 Phase 3 闭环不变量: 10/10 通过 ==") | |
| print(f" 策略分布={dist}, 推理 avg_conf={s['reasoning']['avg_confidence']}, " | |
| f"世界模型命中率={hr}, 误差均值={s['mean_prediction_error']}") | |
| return 0 | |
| if __name__ == "__main__": | |
| sys.exit(test_phase3()) | |