Documentation
¶
Overview ¶
Package hrm provides experimental Hierarchical Reasoning Model types.
The placeholder file ensures the package is discoverable by `go test ./...` without the tag, avoiding build-constraint errors.
Package hrm implements the Hierarchical Reasoning Model.
Package hrm implements the Hierarchical Reasoning Model.
Index ¶
- type HRM
- func (m *HRM[T]) Build(builder *graph.Builder[T], _N, _T int, input, hStateIn, lStateIn graph.Node[T]) (graph.Node[T], error)
- func (m *HRM[T]) Forward(ctx context.Context, nSteps, tSteps int, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
- func (m *HRM[T]) Parameters() []*graph.Parameter[T]
- type HRMTrainer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HRM ¶
type HRM[T tensor.Numeric] struct { HModule *hrm.HModule[T] LModule *hrm.LModule[T] InputNet graph.Node[T] OutputNet graph.Node[T] }
HRM represents the Hierarchical Reasoning Model.
func NewHRM ¶
func NewHRM[T tensor.Numeric]( engine compute.Engine[T], ops numeric.Arithmetic[T], modelDim, ffnDim, inputDim, outputDim int, hAttention, lAttention graph.Node[T], ) (*HRM[T], error)
NewHRM creates a new HRM model.
func (*HRM[T]) Build ¶
func (m *HRM[T]) Build( builder *graph.Builder[T], _N, _T int, input, hStateIn, lStateIn graph.Node[T], ) (graph.Node[T], error)
Build wires a minimal static graph for a single-step HRM pass. This simplified version ignores the N and T loop structure and just composes: input -> InputNet -> Add(hStateIn) -> LModule.Block -> Add(hStateIn) -> HModule.Block -> OutputNet.
func (*HRM[T]) Forward ¶
func (m *HRM[T]) Forward(ctx context.Context, nSteps, tSteps int, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)
Forward computes the forward pass of the HRM model.
func (*HRM[T]) Parameters ¶
Parameters returns the parameters of the HRM model.
type HRMTrainer ¶
HRMTrainer implements the one-step gradient approximation training for the HRM.
func NewHRMTrainer ¶
NewHRMTrainer creates a new HRMTrainer.
func (*HRMTrainer[T]) TrainStep ¶
func (t *HRMTrainer[T]) TrainStep( ctx context.Context, optimizer opt.Optimizer[T], inputs map[graph.Node[T]]*tensor.TensorNumeric[T], targets *tensor.TensorNumeric[T], nSteps, tSteps int, ) (T, error)
TrainStep performs a single training step for the HRM.