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_phase2.py from masterofthestars/tianxuan: direct link, hf CLI and curl.
- Browser
- Download file 4.22 kB
-
https://huggingface.co/masterofthestars/tianxuan/resolve/main/stellaris/test_closed_loop_phase2.py
- Command line
-
hf download hf://masterofthestars/tianxuan/stellaris/test_closed_loop_phase2.py
-
curl -L -o test_closed_loop_phase2.py https://huggingface.co/masterofthestars/tianxuan/resolve/main/stellaris/test_closed_loop_phase2.py
4.22 kB
| #!/usr/bin/env python3 | |
| """ | |
| 群星 P8 · Phase 2 闭环不变量测试 (宪章第 7/8 条: 机制可量化) | |
| 用法: python3 -m stellaris.test_closed_loop_phase2 | |
| 断言 (对应文档 4.3 记忆 + 4.4 世界模型 + 9 认知循环): | |
| 1. 记忆引擎始终在线 (stop 被拒) | |
| 2. 世界模型引擎可停止 (按需唤醒, 非始终在线) | |
| 3. 每事件都编码进记忆 (memory_count == n_events) | |
| 4. 世界模型有非零转移数 (update 真实发生) | |
| 5. 世界模型命中率在 [0,1] 区间 | |
| 6. 预测误差信号产生且非空 (Phase 4 Learning 的前置通路) | |
| 7. 主观时钟 = 事件数 (文档 SubjectiveClock) | |
| 8. 记忆衰减公式: 高意义记忆 (s=0.9) 衰减慢于低意义 (s=0.1) | |
| 9. 回忆重演: 检索命中后 d0 增强 | |
| """ | |
| 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 import run_closed_loop | |
| from stellaris.core.memory.memory_engine import MemoryEngine | |
| from stellaris.core.state.state_engine import StateEngine | |
| from stellaris.core.world_model.world_model_engine import WorldModelEngine | |
| from stellaris.core.engines.interface import EngineRegistry | |
| from stellaris.core.blackboard import Blackboard | |
| def test_phase2() -> int: | |
| cfg = yaml.safe_load( | |
| (Path(__file__).resolve().parent / "configs" / "engine_config.yaml").read_text(encoding="utf-8") | |
| ) | |
| s = run_closed_loop(cfg, n_events=10) | |
| # 1 & 2: 始终在线 / 按需唤醒 | |
| assert s["stopped"]["memory"] is False, "记忆引擎应始终在线 (文档 4.3)" | |
| assert s["stopped"]["world_model"] is True, "世界模型引擎应按需可停止 (文档 4.4)" | |
| assert s["stopped"]["perception"] is False, "感知引擎应始终在线" | |
| assert s["stopped"]["state"] is False, "状态引擎应始终在线" | |
| # 3: 每事件都编码 | |
| assert s["memory_count"] == s["n_events"] == 10, f"记忆数 {s['memory_count']} != 事件数 {s['n_events']}" | |
| # 4: 世界模型有真实转移 | |
| assert s["world_model"]["total_transitions"] >= 8, \ | |
| f"世界模型转移数 {s['world_model']['total_transitions']} 过少 (n_events=10 应有 ≥8)" | |
| # 5: 命中率合法 | |
| hr = s["world_model"]["hit_rate"] | |
| assert 0.0 <= hr <= 1.0, f"世界模型命中率 {hr} 越界" | |
| # 6: 误差信号通路 | |
| assert len(s["prediction_errors"]) == s["n_events"] - 1, "误差信号数量 = 事件数 - 1" | |
| assert all(e >= 0.0 for e in s["prediction_errors"]), "误差信号必须非负" | |
| # 7: 主观时钟 | |
| assert s["t_subj"] == 10.0, f"主观时钟 t_subj={s['t_subj']} 应等于事件数 10" | |
| # 8: 记忆衰减 (高意义慢衰减, 走黑板托管主观时间) | |
| z = Blackboard() | |
| mem = MemoryEngine({}, blackboard=z) | |
| state = StateEngine({}) | |
| state.init({}) | |
| z.write_state(state.get()) | |
| high_id = mem.encode({"content": "x", "s": 0.9, "d0": 0.5, "source": "test"}) | |
| low_id = mem.encode({"content": "y", "s": 0.1, "d0": 0.5, "source": "test"}) | |
| # 推进 20 个主观时刻 (每步刷新黑板) | |
| for _ in range(20): | |
| state.advance(event_occurred=True) | |
| z.write_state(state.get()) | |
| high_detail = mem._memories[high_id].decayed_detail(state.t_subj) | |
| low_detail = mem._memories[low_id].decayed_detail(state.t_subj) | |
| assert high_detail > low_detail, \ | |
| f"高意义记忆衰减后细节 {high_detail:.4f} 应 > 低意义 {low_detail:.4f}" | |
| assert high_detail < 0.5, "高意义记忆 20 步后细节应 < 初始 0.5 (仍在衰减)" | |
| # 9: 回忆重演增强 (无黑板, t_subj=0, 检查 retrieve 后 d0 增加) | |
| mem2 = MemoryEngine({}) | |
| mid = mem2.encode({"content": "z", "s": 0.5, "d0": 0.5, "source": "test"}) | |
| d0_before = mem2._memories[mid].d0 | |
| mem2.retrieve(query="z", top_k=1) | |
| d0_after = mem2._memories[mid].d0 | |
| assert d0_after > d0_before, f"回忆重演后 d0 {d0_after} 应 > 检索前 {d0_before}" | |
| print("== P8 Phase 2 闭环不变量: 9/9 通过 ==") | |
| print(f" 世界模型命中率={hr}, 转移数={s['world_model']['total_transitions']}, " | |
| f"误差均值={s['mean_prediction_error']}") | |
| return 0 | |
| if __name__ == "__main__": | |
| sys.exit(test_phase2()) | |