npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@viyrockan/fedlearn-adapter

v0.1.1

Published

On-device LoRA adapter (~150KB) with EWC continual learning

Readme

@viyrockan/fedlearn-adapter

On-device LoRA adapter (on the order of ~150KB for default d_model / rank) with Elastic Weight Consolidation (EWC) for mitigating catastrophic forgetting. No Rust toolchain is required to install the npm package: native binaries ship for supported platforms.

Install

npm install @viyrockan/fedlearn-adapter

Requires Node.js 20+.

Quick start

import { FedLearnAdapter } from "@viyrockan/fedlearn-adapter";
import { writeFileSync, readFileSync } from "node:fs";

const adapter = new FedLearnAdapter();

const inputEmbedding = new Float32Array(512).fill(0.1);
const targetEmbedding = new Float32Array(512).fill(0.5);

// Session 1 — learn from turns
await adapter.learnTurn(inputEmbedding, targetEmbedding);
adapter.consolidate();

// Session 2 — EWC regularizes toward session-1 weights (Fisher is in the checkpoint)
await adapter.learnTurn(inputEmbedding, targetEmbedding);

// Save to disk
writeFileSync(".fedlearn/adapter.bin", adapter.serialize());

// Load and continue
const loaded = FedLearnAdapter.deserialize(readFileSync(".fedlearn/adapter.bin"));

API (TypeScript)

| Method / property | Description | |-------------------|-------------| | new FedLearnAdapter(config?) | Construct adapter; see config table below. | | learnTurn(input, target) | One training step on embedding vectors (same length d_model). | | consolidate() | End of session: consolidate empirical Fisher diagonal and θ* for EWC. | | forward(input, layer) | Inference forward for one LoRA layer index (no training). | | serialize() | Buffer checkpoint (magic FLA\0, weights, optional JSON EwcState). | | FedLearnAdapter.deserialize(buf, { learningRate? }) | Restore from checkpoint (learningRate required for fresh optimizer). | | turnCount | Turns since last consolidate. | | layerCount / dModel | Architecture readout. |

Config (AdapterConfig)

| Field | Default | Description | |-------|---------|-------------| | dModel | 512 | Embedding dimension (input/target length). | | numLayers | 8 | Independent LoRA stacks (mean MSE across layers in training). | | rank | 4 | LoRA rank (smaller ≈ fewer bytes on disk). | | alpha | 4.0 | LoRA scaling vs rank. | | ewcLambda | 400 | EWC strength λ on the quadratic penalty. | | learningRate | 0.001 | SGD learning rate for trainable LoRA matrices. |

How it works

LoRA: Each layer stores trainable low-rank matrices A (d_model × rank) and B (rank × d_model). The adapter output is x @ A @ B scaled by α / rank. Storing only A and B keeps the serialized checkpoint small compared to full fine-tuning.

EWC: After each session, squared gradients are aggregated to estimate a diagonal Fisher importance. At consolidation, current weights become θ* and the Fisher values are stored. In later sessions, the loss adds (λ/2) Σ F_i (θ_i − θ\*_i)², so updates that would erase important weights are penalized.

Embedding contract

This package operates in embedding space. The host (MCP server, CLI, or your app) must supply Float32Array / arrays of length d_model. No base LLM or tokenizer is bundled.

Platforms

| Item | Support | |------|---------| | Node.js | 20+ | | Prebuilt targets | macOS arm64, Linux x64 (glibc), Windows x64 MSVC (via optional npm platform packages) | | Browser | Not supported — this is an napi-rs native addon. For browser/WASM, see the separate fedlearn-wasm crate in the monorepo. |

Implementation note

Rust dependencies use Candle 0.10.2 from crates.io (aligned candle-core / candle-nn). Candle 0.6.0 did not resolve cleanly with the current rand / half graph; the implementation follows the same LoRA + EWC design as the original plan.

CI

GitHub Actions workflow for multi-platform builds lives at .github/workflows/publish.yml. GitHub only executes workflows under the repository root .github/workflows/; if this file is nested under packages/, copy or symlink it to the root to enable automation.

License

MIT