HengShu(衡枢)— Complete 16M Research Model Family
轻量电力设备多模态辅助研判模型:设备图像、遥测和SOE输入,输出一致性、场景风险及辅助处置路由。此仓库包含完整公共编码器、三个融合配置、输入处理、校准和可直接运行的本地示例。
HengShu is a custom PyTorch research model family for multimodal power-equipment assessment. The default variant is M-1. M-A uses ordinary adaptive stopping; M-6 uses six fixed fusion steps. These are separately trained fusion checkpoints sharing one frozen encoder.
Code and model weights in this release are distributed under mit. Third-party methods are credited below.
Publisher account: heimy. Team authorship and formal paper citation have not been supplied. No paper DOI or benchmark leadership is asserted. This release is not a Laya-pretrained derivative; the shared encoder comes from this project's prior synthetic task training.
Quick start
Download the complete repository, inspect its Python source, and install the runtime dependencies:
python -m pip install --upgrade huggingface_hub
hf download heimy/hengshu --local-dir ./hengshu-model
python -m pip install -r ./hengshu-model/requirements.txt
python ./hengshu-model/examples/infer.py --variant M-1
python ./hengshu-model/verify_release.py
Choose another configuration:
python ./hengshu-model/examples/infer.py --variant M-A
python ./hengshu-model/examples/infer.py --variant M-6
On a compatible CUDA GPU, use --device cuda --precision bf16 for FP32 encoding and BF16 fusion. CUDA installation depends on the host; the provided torch>=2.6 requirement is not a guarantee that every version/device has been tested. The exported release was validated with the environment in validation.json.
The Python loader is explicit and local:
# Run from the downloaded model directory.
import json
from pathlib import Path
from hengshu import HengShu
root = Path('.')
model = HengShu.from_pretrained(root, variant='M-1', device='cpu')
sample = json.loads((root / 'examples/sample-00.json').read_text())
sample['image'] = root / 'examples' / sample['image']
print(model.predict(**sample))
There is no Transformers AutoModel integration and no hosted inference-provider deployment in this release. Downloadable weights and local inference do not require a hosted provider. For reproducibility, pin the Hub commit revision when downloading.
Included files and parameters
| File | Purpose |
|---|---|
encoder.safetensors |
Shared image/SOE/telemetry encoder; 12,719,232 parameters |
variants/M-1/fusion.safetensors |
One-step metric-supervised fusion; 3,419,859 parameters |
variants/M-A/fusion.safetensors |
Ordinary adaptive metric-supervised fusion; 3,419,859 parameters |
variants/M-6/fusion.safetensors |
Six-step metric-supervised fusion; 3,419,859 parameters |
config.json |
Architecture, variants, route labels, encoder token policy |
preprocessor_config.json, vocabulary.json |
Exact image, telemetry, SOE and normalized-SNR input contract |
variants/*/calibration.json |
Matched per-variant probability calibration |
hengshu.py, modeling_hengshu.py |
Local loader, preprocessing, actual model implementation |
examples/ |
Nine synthetic source-calibration examples and CPU reference outputs |
manifest.json, SHA256SUMS |
Artifact hashes |
validation.json, provenance.json |
Export checks, lineage and training protocol |
Each instantiated variant has 16,139,091 stored parameters. The repository stores one encoder and three distinct fusion checkpoints, so summing all weight files does not describe one model's parameter count. Some diagnostic/stopping parameters are inactive for fixed-step inference. Safetensors tensors were checked for exact equality against the original checkpoints.
Input and output contract
- Image: uint8 RGB224×224. Preprocessing is CHW conversion and division by255; no implicit resize or mean/std transform.
- Telemetry: exactly eight generator-scale fields: voltage, current, power_pre, power_post, impedance, frequency_hz, trip_flag, breaker_closed. This protocol uses identity telemetry scaling; it does not define a calibrated real-sensor adapter.
- SOE: explicit names from
vocabulary.json, padded to32. Six frequency/domain token IDs are removed in the encoder and the remaining tokens are stably compacted. Free-form language is not accepted. signal_quality: normalized SNR(snr_db−18)/18, not a probability. Negative values are valid; the original generated data range is approximately−0.8333 to1.0.- Runtime batch size: one. Adaptive variants actually stop early.
Outputs include route_probabilities, p_consistent, expected_scenario_risk and executed_steps. Route labels are INFORMATIONAL_ONLY, HUMAN_REVIEW, DATA_QUALITY_REVIEW and EXPERT_ESCALATION. They are synthetic review-routing classes, not four real physical fault categories. No command target is part of the native model input, so consistency does not establish that a switching operation reached its target.
Training and evaluation
The core protocol uses3,977 synthetic training events,703 source-calibration events and1,560 held-out Domain3 events. Each fusion model was trained for20epochs/4,980updates with seed2026 and a fixed shared encoder. All five test views share the same1,560events. This is a one-seed exploratory study on a previously inspected synthetic cohort, not an independent field test.
Routing Macro-F1(%), measured under the original evaluation protocol:
| Variant | Clean | Black | Gray | Ellipse | Texture | Occlusion mean |
|---|---|---|---|---|---|---|
| M-1 | 96.13 | 53.04 | 69.99 | 63.44 | 73.63 | 65.03 |
| M-A | 95.61 | 71.96 | 71.97 | 76.20 | 73.59 | 73.43 |
| M-6 | 96.92 | 63.64 | 72.67 | 76.18 | 77.10 | 72.40 |
For matched baselines and all10core configurations, see evaluation.csv. M-1 improves four-occlusion mean F1 by4.29percentage points over ordinary single-step fusion (paired event95%interval[1.78,6.74]). M-A improves the ordinary dynamic baseline by1.25points (interval[−1.11,3.80]). These intervals condition on fixed weights, not training-seed uncertainty.
Routing gains do not establish universal safety gains: at50%binary acceptance, M-1 has more occlusion conflict misses than the plain single-step baseline. Energy-feedback ablations did not demonstrate conflict-event exit changes in the same-weight counterfactual. The three released variants do not use energy feedback in their stopping gates.
The original scores use GPU/BF16 fusion with source-calibrated outputs. CPU/FP32 is a supported runtime path, but the export tests do not assert that every CPU prediction reproduces every original full-test BF16 score. This release verified source/export equivalence separately on both paths.
Export validation
The release preserves261state tensors across the shared encoder and three fusion files. On9source-calibration examples per variant, CPU/FP32 and RTX3090Ti FP32-encoder/BF16-fusion each passed27source/export comparisons with zero measured probability difference and matching actual steps. Raw PNG/JSON preprocessing matched the original dataset tensors exactly. These are export equivalence checks, not additional independent training or a new full-test benchmark.
verify_release.pychecks the artifact hashes and runs all27CPU example/variant combinations. Runtime changes across hardware and dependency versions can affect numerical output. The included verification uses an explicit tolerance and checks routes and step counts.
Scope and limitations
The training images, telemetry and SOE are synthetic. No synchronized real-site multimodal validation, real-device/site holdout or production operation guarantee is claimed. OscGrid is a separate real-waveform-feature study with a different classifier; its results must not be attributed to these weights. This model is read-only research assistance and does not operate or authorize equipment.
The original M-1 local RTX3090Ti batch-one tensor pipeline had mean2.99ms and P99 3.28ms, excluding acquisition, image decoding, network/industrial protocols and model loading. These are not Jetson or field end-to-end measurements. M-A was not measured under the same full1,560event timing protocol.
Method sources
The core implementation extends the project's prior loop-fusion model with direct trace-normalized metric supervision. It uses established contrastive loss forms, PCGrad and evidential classification; these components are not claimed as independently invented here.
- Hadsell, Chopra and LeCun, Dimensionality Reduction by Learning an Invariant Mapping.
- Yu et al., Gradient Surgery for Multi-Task Learning.
- Sensoy et al., Evidential Deep Learning to Quantify Classification Uncertainty.
The local GitHub draft has been prepared but its public repository URL is not yet assigned. Runtime source needed for these weights is included here, with source hashes in provenance.json.
- Downloads last month
- -