recursive-feature-machines

Train LaplaceRFM kernel models for backpropagation-free feature learning with PyTorch.

75|7|Updated May 2, 2026
One-click install
npx skills add https://github.com/zjunlp/Mechanist --skill recursive-feature-machines-zjunlp
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: recursive-feature-machines
Source: https://github.com/zjunlp/Mechanist/tree/main/skills/mechanism-skills/neural-feature-learning/gradient-outer-product
Command: npx skills add https://github.com/zjunlp/Mechanist --skill recursive-feature-machines-zjunlp

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires torch, torchvision, hickle, tqdm, rfm, and includes scripts (resource) and references (resource) components.

What problem does it solve? Implementing Recursive Feature Machines (RFM) requires correctly configuring the LaplaceRFM class, managing GPU memory for kernel computations, and choosing between full and diagonal kernel approximations, which is error-prone without guidance. ## Core Features & Use Cases - Backpropagation-Free Feature Learning: Train kernel models that iteratively learn a data-adaptive feature matrix M without gradient descent. - Classification and Regression: Support both task types via the classification flag in the fit() method, with GPU acceleration and chunked memory management. - Use Case: A researcher studying neural network feature learning mechanisms trains LaplaceRFM on synthetic low-rank polynomial data to compare kernel-based feature learning against trained neural networks. ## Quick Start Train a LaplaceRFM model on my synthetic dataset with 5 iterations using the rfm package and report test performance.

Frequently Asked Questions about recursive-feature-machines

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I train a Recursive Feature Machine in Python?

Install the rfm package from GitHub, create a LaplaceRFM instance with bandwidth, device, and mem_gb parameters, then call fit() with train and test data tuples. Set iters to around 5 and classification to True or False depending on your task.

How to install the rfm package for LaplaceRFM?

Install via pip with: pip install git+https://github.com/aradha/recursive_feature_machines.git@pip_install. You also need PyTorch 1.13, torchvision 0.14.0, hickle 5.0.2, and tqdm.

Does LaplaceRFM support GPU training?

Yes, LaplaceRFM automatically uses CUDA when available. Pass torch.device("cuda") as the device and set mem_gb to your GPU memory minus 1GB to avoid out-of-memory errors during kernel computations.

When should I use diag=True in LaplaceRFM?

Use diag=True for large datasets where the full kernel matrix does not fit in memory. It applies a diagonal approximation of the feature matrix M, trading some accuracy for memory efficiency.

Why does LaplaceRFM run out of memory during training?

Out-of-memory errors occur when mem_gb exceeds available GPU or system memory, since kernel matrices are computed in chunks based on this value. Lower mem_gb or enable diag=True for large-scale problems.