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_phase4.py from masterofthestars/tianxuan: direct link, hf CLI and curl.
- Browser
- Download file 5.35 kB
-
https://huggingface.co/masterofthestars/tianxuan/resolve/main/stellaris/test_closed_loop_phase4.py
- Command line
-
hf download hf://masterofthestars/tianxuan/stellaris/test_closed_loop_phase4.py
-
curl -L -o test_closed_loop_phase4.py https://huggingface.co/masterofthestars/tianxuan/resolve/main/stellaris/test_closed_loop_phase4.py
5.35 kB
| #!/usr/bin/env python3 | |
| """ | |
| 群星 P8 · Phase 4 闭环不变量测试 (宪章第 7/8 条: 机制可量化) | |
| 用法: python3 -m stellaris.test_closed_loop_phase4 | |
| 断言 (对应文档 4.7 学习 + 4.8 元认知 + 9 认知循环 Phase 4): | |
| 1. 八引擎全部启动 (perception/state/memory/world_model/reasoning/cognitive_control/learning/metacognition) | |
| 2. 学习引擎始终在线 (stop 被拒), 元认知引擎始终在线 | |
| 3. 学习次数 = 事件数 - 1 (因果错位一步, 首个事件无上一事件可学) | |
| 4. 学习: 策略权重归一化 (各 task_type 权重和 = 1) | |
| 5. 学习: validate 通过 (即时收益不为负) | |
| 6. 元认知: confidence = 1 - uncertainty (互补, 合法区间 [0,1]) | |
| 7. 元认知: capability_profile 三档任务类型齐全 | |
| 8. 元认知: 能力缺口检测 (低能力任务类型被标记) | |
| 9. 元认知: 失败检测通路 (detect_failure 返回 None 或 Failure) | |
| 10. 元认知: 故障定位通路 (localize_fault 返回 fault_engine) | |
| 11. 主观时钟 = 事件数 | |
| 12. 八引擎全部健康 (degradation_level=none) | |
| """ | |
| 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_phase4 import run_closed_loop | |
| from stellaris.core.learning.learning_engine import LearningEngine | |
| from stellaris.core.metacognition.metacognition_engine import MetacognitionEngine | |
| from stellaris.core.blackboard import Blackboard | |
| def test_phase4() -> 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. 八引擎全部启动 (health 字段确认) | |
| health_names = set(s["health"].keys()) | |
| for e in ("perception", "state", "memory", "world_model", | |
| "reasoning", "cognitive_control", "learning", "metacognition"): | |
| assert e in health_names, f"引擎 {e} 未启动 (health 缺失)" | |
| # 2. 学习/元认知始终在线 → healthy 且非 STOPPED | |
| assert s["health"]["learning"]["healthy"] is True | |
| assert s["health"]["metacognition"]["healthy"] is True | |
| # 3. 学习次数 = 事件数 - 1 (因果错位一步, 首事件无上一事件可学) | |
| n = 10 # run_closed_loop 默认 n_events=10 | |
| assert s["learning"]["n_learned"] == n - 1, \ | |
| f"学习次数 {s['learning']['n_learned']} != {n - 1} (事件数 {n} - 1)" | |
| # 4. 策略权重归一化 (各 task_type 权重和 ≈ 1) | |
| for task_type, weights in s["learning"]["policy_weights"].items(): | |
| wsum = sum(weights.values()) | |
| assert abs(wsum - 1.0) < 1e-6, \ | |
| f"task_type={task_type} 策略权重和 {wsum} != 1 (未归一化)" | |
| # 5. 学习验证: n_validated > 0 (validate 被调用) | |
| assert s["learning"]["n_validated"] >= 1, "学习验证未发生" | |
| # 6. 元认知: confidence + uncertainty = 1 (互补) | |
| mc = s["metacognition"] | |
| total = mc["confidence"] + mc["uncertainty"] | |
| assert abs(total - 1.0) < 1e-4, \ | |
| f"元认知 confidence+uncertainty={total} 应 ≈ 1" | |
| assert 0.0 <= mc["confidence"] <= 1.0, "confidence 越界" | |
| assert 0.0 <= mc["uncertainty"] <= 1.0, "uncertainty 越界" | |
| # 7. 能力画像三档齐全 | |
| for t in ("fact", "causal", "novel"): | |
| assert t in mc["capability_profile"], f"能力画像缺 {t}" | |
| # 8. 能力缺口检测 (低能力任务类型被标记, 可能为空列表) | |
| assert isinstance(mc["capability_gaps"], list) | |
| # 9. 失败检测通路 | |
| assert isinstance(mc["failure"]["engine"], str) | |
| assert mc["failure"]["severity"] >= 0.0 | |
| # 10. 故障定位通路 | |
| assert isinstance(mc["fault_location"]["fault_engine"], str) | |
| assert mc["fault_location"]["severity"] >= 0.0 | |
| # 11. 主观时钟 | |
| assert s["t_subj"] == float(10), f"主观时钟 {s['t_subj']} != 10" | |
| # 12. 八引擎全部健康 | |
| for name, h in s["health"].items(): | |
| assert h["healthy"] is True, f"引擎 {name} 不健康: {h}" | |
| assert h["degradation_level"] == "none", f"引擎 {name} 降级: {h}" | |
| # 额外: 信用分配通路 (credit_assign 可调用) | |
| learn = LearningEngine({}) | |
| credit = learn.credit_assign({"id": "e1", "task_type": "causal", "error": 0.5, "memory_hit_rate": 0.6}) | |
| assert credit.total_credit > 0.0, "信用分配 total_credit 应 > 0" | |
| assert credit.contributions.get("world_model", 0) > 0.0, "世界模型贡献度应 > 0" | |
| # 额外: 元认知 monitor/detect/assess/localize 四方法可调用 (走黑板, 无需绑定引擎) | |
| metacog = MetacognitionEngine({}, blackboard=Blackboard()) | |
| ms = metacog.monitor(None) | |
| assert 0.0 <= ms.uncertainty <= 1.0, "monitor 不确定性越界" | |
| cap = metacog.assess_capability({"type": "causal"}) | |
| assert "capability_score" in cap, "能力评估缺 capability_score" | |
| fault = metacog.localize_fault(0.3) | |
| assert "fault_engine" in fault, "故障定位缺 fault_engine" | |
| print("== P8 Phase 4 闭环不变量: 12/12 通过 ==") | |
| print(f" 学习次数={s['learning']['n_learned']}, 验证次数={s['learning']['n_validated']}, " | |
| f"元认知 confidence={mc['confidence']}, uncertainty={mc['uncertainty']}, " | |
| f"能力画像={mc['capability_profile']}") | |
| return 0 | |
| if __name__ == "__main__": | |
| sys.exit(test_phase4()) | |