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

pineconebm25

v1.0.2

Published

The pineconebm25 package is a node package that encodes text for seamless integration with Pinecone's sparse-dense (hybrid) semantic search.

Downloads

8

Readme

Pinecone BM25

The pineconebm25 package is a node package that encodes text for seamless integration with Pinecone's sparse-dense (hybrid) semantic search.

Installation

To install use the following command

npm i pineconebm25

Sparse Encoding

BM25

To encode your documents and queries using BM25 as vector for dot product search, you can use the BM25Encoder class.

📝 NOTE:

This implementation of BM25 supports only static document frequency (meaning that the document frequency values are precomputed and fixed, and do not change dynamically based on new documents added to the collection).

When conducting a search, you may come across queries that contain terms not found in the training corpus but are present in the database. To address this scenario, BM25Encoder uses a default document frequency value of 1 when encoding such terms.

import { BM25Encoder } from "pineconebm25";

const corpus = ["The quick brown fox jumps over the lazy dog",
    "The lazy dog is brown",
    "The fox is brown"];

const bm25 = new BM25Encoder();

bm25.fit(corpus);

//Encode a new document (for upsert to Pinecone index)
const doc_sparse_vector = bm25.encodeDocuments("The brown fox is quick");

console.log("Doc sparse vector: ", doc_sparse_vector);

//Encode a query (for search in Pinecone index)
const query_sparse_vector = bm25.encodeQueries("which fox is brown?");

console.log("\nQuery sparse vector", query_sparse_vector);

(async ()=>{
    // store BM25 params as json
    await bm25.dump("./bm25_params.json")

    // Load BM25 params as json 
    const bm25_obj = await bm25.load("./bm25_params.json")
})();

Load Default Parameters

If you want to use the default parameters for BM25Encoder, you can call the default method. The default parameters were fitted on the MS MARCO passage ranking dataset. The default params are sourced from DEFAULT PARAMS To use a custom set of parameters, ensure they follow the same format.

import { BM25Encoder } from "pineconebm25";
(async ()=>{
    /*
    A file path can be provided to persist the default parameters locally. 
   If the specified file does not exist, the default parameters will be 
   downloaded automatically and saved to the provided path.
   e.g await BM25Encoder.default("./data/msmarco_params.json")
    */
    const bm25 = await BM25Encoder.default(); // include filepath to make default params persistent
    console.log("\nEncoded Doc using default params:", bm25.encodeDocuments("The brown fox is quick"));
})();

BM25 Parameters

The BM25Encoder class offers configurable parameters to customize the encoding:

  • b: Controls document length normalization (default: 0.75).
  • k1: Controls term frequency saturation (default: 1.2).
  • Tokenization Options: Allows customization of the tokenization process, including options for handling case, punctuation, stopwords, stemming, and language selection.

These parameters can be specified when initializing the BM25Encoder class.