HuggingFace 模型 graceesthi/ug-cppo-finai-2025 (Stable-Baselines3 金融交易 RL 策略,非 LLM)在华为昇腾 NPU(torch_npu)上的推理适配。
{mode}_seed{seed}.zip)ug_cppo_seed42.zip(旗舰模型),可用 --model <zip> 切换ASCEND_RT_VISIBLE_DEVICES=0# 权重缓存:model_weights/graceesthi/ug-cppo-finai-2025/(ug_cppo_seed42.zip 存在即跳过下载)
# CLI 推理(缺省合成市场观察,或传 81 维 obs JSON)
python inference.py --input default
python inference.py --input "[0.1, -0.2, ... 81 个浮点数]"
python inference.py --model cppo_seed47.zip --input default
# FastAPI 服务(端口 8016)
python inference.py --serve --port 8016
# GET / -> 上传/输入页面
# POST /predict -> {"obs": [81 浮点]} 或空体(用缺省观察)-> JSONpolicy.to("npu:0").eval(),模型/输入 tensor 全部 npu:0;get_device() 带 try-exceptpolicy.get_distribution(obs_tensor) → dist.get_actions()(随机采样)+ dist.mode()(确定性),不使用 model.predict(){model, device, obs_dim, action_dim, action, deterministic_action, action_sum, action_softmax, ...}numpy._core.* 子模块别名 + BitGenerator 反序列化python inference.py --input default → exit 0,npu:0 输出合法 JSONPOST /predict → 合法 JSON(缺省/自定义 obs 均可用)