AGENT SKILL

htm-algorithms

Direct NuPIC legacy HTM encoders, SpatialPooler, TemporalMemory, SDRClassifier, anomaly score, and anomaly likelihood workflows.

License 许可
MIT
最近更新
2026-09-03
Stars
★ 351
Forks
27

01 前言 Front Matter

name
htm-algorithms
license
MIT
metadata
{ "disco-role": "operating" }
description
Direct NuPIC legacy HTM encoders, SpatialPooler, TemporalMemory, SDRClassifier, anomaly score, and anomaly likelihood workflows.
disable-model-invocation
true

02 资源文件 4

03 SKILL.md 正文

HTM Algorithms

Use this sub-skill when a task asks for direct NuPIC legacy HTM algorithm APIs: encoders, SpatialPooler, TemporalMemory, SDRClassifier, raw anomaly score, or anomaly likelihood for a small streaming scalar/temporal example.

NuPIC legacy is a Python 2.7 package. Direct algorithm workflows normally require installed nupic, nupic.bindings, numpy in the legacy-compatible range, and pycapnp/Cap'n Proto only when serialization is needed.

Route first

  • Stay here for: ScalarEncoder, RandomDistributedScalarEncoder, DateEncoder, CategoryEncoder, MultiEncoder, SpatialPooler.compute, TemporalMemory.compute, SDRClassifier.compute, computeRawAnomalyScore, and AnomalyLikelihood.anomalyProbability.
  • Read references/api-reference.md when you need constructor signatures, input/output shapes, classifier result keys, or anomaly helper semantics.
  • Read references/workflows.md when you need a direct encoders -> SP -> TM -> classifier/anomaly recipe or a debugging checklist for algorithm pipelines.
  • Read references/troubleshooting.md when an algorithm example fails with encoder parameter, active-array shape, TM state/reset, classifier dict, Python 2, bindings, or serialization errors.
  • Run scripts/algorithm_smoke.py when you need a deterministic installed-package smoke check for tiny encoders, SP/TM, classifier, and anomaly helpers.
  • Route CSV stream headers, field metadata, OPF model parameter files, and config validation to ../data-and-configuration/.
  • Route high-level ModelFactory, OPF inference dictionaries, checkpoints, and experiment workflows to ../opf-prediction/.
  • For package-wide install/import failures before algorithm code runs, start with the root troubleshooting guide at ../../references/troubleshooting.md; local reference files also cross-link to that guide from their own relative paths.

Direct API checklist

  1. Confirm the runtime is Python 2.7 and can import nupic, nupic.bindings, and numpy.
  2. Encode every raw value into a one-dimensional binary SDR. Allocate one zero-filled NumPy array per encoder with encoder.getWidth() and call encoder.encodeIntoArray(value, bits).
  3. Concatenate encoder outputs. Set SpatialPooler(inputDimensions=(encodingWidth,), columnDimensions=(columnCount,), ...) so encodingWidth == len(concatenatedEncoding).
  4. Allocate activeArray = numpy.zeros(columnCount, dtype="uint32"), call sp.compute(encoding, learn, activeArray), then pass numpy.nonzero(activeArray)[0] to TemporalMemory.compute.
  5. Set TemporalMemory(columnDimensions=(columnCount,), ...) to the same column count used by the SP. Use tm.getActiveCells() for classifier patternNZ; use tm.getPredictiveCells() plus tm.columnForCell(cell) to build next-step predicted columns for anomaly score.
  6. For scalar predictions, call classifier.compute(recordNum, patternNZ, {"bucketIdx": bucketIdx, "actValue": rawValue}, learn=True, infer=True). Look for integer step keys such as 1 plus the "actualValues" key in the result.
  7. For anomaly checks, compare current active columns with previous-step predicted columns using computeRawAnomalyScore(activeColumns, prevPredictedColumns), then optionally update AnomalyLikelihood with the raw value, anomaly score, and timestamp.

Minimal validation command

From this sub-skill directory in a prepared NuPIC legacy environment:

python scripts/algorithm_smoke.py --mode all --records 20 --encoder scalar

Expected success signal: the script prints PASS, encoder/SP/TM dimensions, a final one-step prediction summary, and bounded anomaly likelihood values. If it fails before imports, use root install/import troubleshooting; if it fails after imports, use the local troubleshooting reference.

Evidence provenance

This sub-skill distills NuPIC legacy algorithm evidence from source/doc paths such as src/nupic/algorithms/, src/nupic/encoders/, docs/source/quick-start/algorithms.rst, docs/examples/algo/complete-algo-example.py, examples/sp/hello_sp.py, examples/tm/hello_tm.py, and unit tests under tests/unit/nupic/algorithms/ and tests/unit/nupic/encoders/. Runtime guidance here is self-contained; future agents should not need to open the original checkout examples to use it.

04 同仓库更多 Skills

VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-triton-opt

Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-solve

END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-skill

PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-pattern-fusion

Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-orchestrate

Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-feedback

Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).

★ 351