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

@pakhad/train

v1.0.0

Published

Training pipeline and runtime serialization helpers for pakhad locale models

Readme

@pakhad/train

Training pipeline and runtime serialization for pakhad locale models. Build Markov models and bloom filter name lists from your own data.

Install

npm install @pakhad/train

CLI

# Build a trigram Markov model
npx pakhad-train markov --input names.txt --order 3 --output markov.bin

# Build a bloom filter name list
npx pakhad-train namelist --input names.txt --fpr 0.001 --output names.bloom

# Inspect a model file
npx pakhad-train info markov.bin

Input Format

One name per line, UTF-8. Automatically lowercased, deduplicated, and filtered.

john
sarah
michael
jessica

Programmatic API

MarkovModel

Train character n-gram models from a corpus of strings.

import { MarkovModel } from '@pakhad/train';

// Train
const model = MarkovModel.train(['john', 'james', 'jessica'], 3);

// Score tokens
model.scoreToken('john');    // { score: 0.26, avgLogProb: -2.1 } — normal
model.scoreToken('xkqzvb'); // { score: 0.93, avgLogProb: -14.6 } — gibberish

// Serialize/deserialize
import { writeFileSync, readFileSync } from 'node:fs';
writeFileSync('markov.bin', model.serialize());

const restored = MarkovModel.deserialize(
  new Uint8Array(readFileSync('markov.bin').buffer)
);

Properties: model.order, model.alphabetSize, model.size

Methods: train(), scoreToken(), getLogProb(), serialize(), deserialize()

BloomFilter

Probabilistic set membership with configurable false positive rate.

import { BloomFilter } from '@pakhad/train';

// Create from items
const bf = BloomFilter.fromItems(['john', 'sarah', 'michael'], 0.001);

bf.has('john');    // true
bf.has('xkqzvb'); // false

// Or build incrementally
const bf2 = BloomFilter.create(10000, 0.001);
bf2.add('john');
bf2.add('sarah');

// Serialize/deserialize
writeFileSync('names.bloom', bf.serialize());
const restored = BloomFilter.deserialize(
  new Uint8Array(readFileSync('names.bloom').buffer)
);

Properties: bf.numBits, bf.numHashes

Methods: create(), fromItems(), optimalConfig(), add(), has(), serialize(), deserialize(), getItemCount(), estimatedFalsePositiveRate()

Use Custom Models with pakhad

import { create } from '@pakhad/core';
import { MarkovModel, BloomFilter } from '@pakhad/train';

const names = ['your', 'custom', 'name', 'list'];
const detector = create({
  locales: [{
    id: 'custom',
    script: 'Latin',
    markov: MarkovModel.train(names, 3),
    nameList: BloomFilter.fromItems(names, 0.001),
    metadata: { typicalTokenLength: { min: 2, max: 15, mean: 6 } },
  }],
});

detector.detect('your input here');

Binary Formats

Markov (MKOV): [magic 4B][version 4B][order 4B][entries 4B][alphabetSize 4B][...entries]

Bloom (BLOM): [magic 4B][version 4B][numBits 4B][numHashes 4B][itemCount 4B][...bitArray]

Full Documentation

github.com/nikhilchintawar/pakhad

License

MIT