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

@yarflam/potion-base-32m

v1.1.5

Published

Fast Model2Vec inference for potion-base-32M embeddings without ONNX or heavy ML frameworks

Readme

@yarflam/potion-base-32m

Fast Model2Vec inference for minishlab/potion-base-32M embeddings without ONNX or heavy ML frameworks.

  • Lightning fast — Static embeddings with no neural network at runtime
  • 📦 Zero heavy dependencies — No PyTorch, TensorFlow, or ONNX
  • 🔧 Simple API — Just embed(texts) and go
  • 🔍 Built-in semantic searchSemanticSearch class included
  • 🪶 Tiny footprint — 32-dimensional embeddings, perfect for edge devices

Installation

npm install @yarflam/potion-base-32m

Usage

import { embed } from '@yarflam/potion-base-32m';

const texts = ['Hello world', 'How are you?'];
const embeddings = await embed(texts);

console.log(embeddings[0].length); // 32
console.log(embeddings[0]);        // Float32Array(32) [...]

How it works

Model2Vec uses static embeddings — no neural network needed at runtime:

  1. Tokenize input using WordPiece tokenizer
  2. Lookup each token's vector in the embedding matrix
  3. Mean-pool all token vectors
  4. L2-normalize the result

Done! No ML framework overhead.

API

embed(texts)

Embed one or more texts using potion-base-32M.

Parameters:

  • texts (string | string[]) — Text(s) to embed

Returns:

  • Promise<Float32Array[]> — Array of 32-dimensional embeddings

Example:

// Single text
const [embedding] = await embed('Hello world');

// Multiple texts
const embeddings = await embed(['Text one', 'Text two', 'Text three']);

cosineSimilarity(a, b)

Compute cosine similarity between two embeddings.

import { embed, cosineSimilarity } from '@yarflam/potion-base-32m';

const [emb1, emb2] = await embed(['cat', 'dog']);
const similarity = cosineSimilarity(emb1, emb2);
console.log(similarity); // 0.0 to 1.0

SemanticSearch

Built-in semantic search class for finding similar sentences.

import { SemanticSearch } from '@yarflam/potion-base-32m';

const search = new SemanticSearch();

// Index your documents
await search.index([
  'The cat sleeps on the couch',
  'The dog plays in the garden',
  'A bird sings in the tree'
]);

// Search
const results = await search.search('feline resting', { nb_results: 2 });
// [{ sentence: 'The cat sleeps on the couch', score: 0.85 }, ...]

Methods:

  • index(sentences: string[]): Promise<SemanticSearch> — Index sentences for search
  • search(query: string, options?): Promise<Array<{sentence, score}>> — Search indexed sentences
    • options.nb_results — Maximum results (default: 10)
    • options.threshold — Minimum similarity score 0-1 (default: null)
  • clear(): void — Clear the index
  • size: number — Number of indexed sentences (getter)

Model files

The package downloads model files from HuggingFace Hub during installation:

  • model.safetensors — Embedding matrix [vocab_size, 32]
  • tokenizer.json — WordPiece tokenizer
  • config.json — Model metadata

Files are cached in the models/ directory and included in the published package.

Development

# Install dependencies
npm install

# Download model files
npm run download-models

# Run tests
npm test

GitLab CI Setup

To enable NPM publishing in GitLab CI:

  1. Add your NPM token as a CI/CD variable:

    • Go to Settings > CI/CD > Variables
    • Add NPM_TOKEN with your npm access token
  2. Create a tag to trigger publish:

    git tag v1.0.0
    git push origin v1.0.0

Or manually trigger from the main branch using the publish-main job.

Model Credit

This package uses minishlab/potion-base-32M by Minish Lab.

Model2Vec paper: arXiv:2411.01001

Authors

  • Yarflam — Creator & maintainer
  • Mira 🤫 — Assistant & co-conspirator

License

MIT