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

@paritosh31/memory-engine

v0.1.0

Published

A standalone, framework-agnostic semantic memory engine and TypeScript SDK for intelligent ingestion, hybrid retrieval, and forgetting-curve resurfacing.

Readme

🧠 MemoryEngine

A standalone, framework-agnostic semantic memory engine and TypeScript SDK for intelligent ingestion, hybrid retrieval, and forgetting-curve resurfacing.

License: MIT TypeScript PostgreSQL & pgvector


⚡ Why MemoryEngine?

Humans remember ideas, metaphors, and analogies — not filenames or exact keywords.

You don't remember saving video_98412_transcript.txt. You remember "there was a video where the guy compared salary negotiation to buying real estate."

Every "save for later" feature turns into a digital graveyard because:

  1. Storage is trivial; retrieval is broken. Databases index exact keywords, while human recall operates on fuzzy conceptual associations.
  2. Infinite archives cause fatigue. Unreviewed saved items decay in human memory unless intelligently resurfaced at the optimal moment.

MemoryEngine is pure infrastructure designed to solve this. It has no UI — it is an importable, high-performance SDK that turns raw text from any source (Instagram reels, podcasts, PDFs, voice notes, bookmarks) into queryable, connected, and serendipitously resurfaced memories.


🚀 Quickstart

Installation

npm install @paritosh31/memory-engine

5-Line Usage

import { MemoryEngine } from "@paritosh31/memory-engine";

const engine = new MemoryEngine();

// 1. Ingest any text
await engine.ingest({
  id: "reel_1042",
  title: "Salary Negotiation Tactics",
  text: "When negotiating salary, never make it adversarial. Think of it like buying a house where both parties need peace of mind."
});

// 2. Semantic Search by conceptual analogy
const results = await engine.search("salary negotiation real estate analogy");
console.log(results.hits[0].bestChunk.text);

// 3. Resurface forgotten memories via Ebbinghaus decay
const digest = await engine.resurface({ decayThreshold: 0.4 });

🏗️ Architecture

                     ┌────────────────────────────────────────────────────────┐
                     │                   Application Layer                    │
                     │          (Vault / SaaS App / Worker / CLI)             │
                     └──────────────────────────┬─────────────────────────────┘
                                                │
                                       MemoryEngine SDK
                                                │
     ┌──────────────────┬───────────────────────┼─────────────────────────┬──────────────────┐
     │                  │                       │                         │                  │
     ▼                  ▼                       ▼                         ▼                  ▼
 ┌──────────────┐ ┌──────────────┐     ┌────────────────┐         ┌──────────────┐   ┌──────────────┐
 │  Ingestion   │ │  Embeddings  │     │ Storage Engine │         │  Retrieval   │   │ Resurfacing  │
 ├──────────────┤ ├──────────────┤     ├────────────────┤         ├──────────────┤   ├──────────────┤
 │ • Normalizer │ │ • OpenAI     │     │ • PgVector     │         │ • Dense HNSW │   │ • Ebbinghaus │
 │ • Semantic   │ │ • Gemini     │ ──► │ • In-Memory    │ ◄────── │ • Sparse BM25│   │   Decay      │
 │   Chunker    │ │ • Local/Mock │     │ • DDL Schema   │         │ • RRF Fusion │   │ • Graph Link │
 │ • Extractor  │ │ • Extensible │     │   Migrations   │         │ • Reranking  │   │ • Serendipity│
 └──────────────┘ └──────────────┘     └────────────────┘         └──────────────┘   └──────────────┘

🔬 Key Capabilities

1. Hybrid Search with Reciprocal Rank Fusion (RRF)

Combines dense semantic vector search (HNSW cosine similarity) with sparse lexical search (BM25) to deliver both semantic understanding and exact keyword precision:

$$\text{Score}{RRF}(d) = \frac{w{dense}}{k + \text{rank}{dense}(d)} + \frac{w{sparse}}{k + \text{rank}_{sparse}(d)}$$

2. Ebbinghaus Forgetting Curve Resurfacing

Calculates memory retention probability based on elapsed time and active recall reinforcements:

$$R(t) = \exp\left(-\frac{t \cdot \ln 2}{S}\right) \quad \text{where } S = S_0 \cdot (1 + \alpha \cdot \text{recallCount})$$

Memories that have decayed below your retention threshold ($R(t) \le 0.40$) and possess high importance or cross-cluster associative bridge connections are proactively resurfaced.

3. Associative Semantic Graph

Discovers conceptual links across disparate sources (e.g., connecting a psychology note from 6 months ago to an engineering video saved today) through high-dimensional cosine affinity.


⚙️ Configuration

import { MemoryEngine, PgVectorStorage, OpenAIEmbedder } from "memory-engine";

const engine = new MemoryEngine({
  // Storage Adapter: In-Memory (default) or PostgreSQL + pgvector
  storage: new PgVectorStorage({
    connectionString: process.env.DATABASE_URL
  }),

  // Embedding Provider: Mock (default), OpenAI, or Gemini
  embedding: new OpenAIEmbedder({
    apiKey: process.env.OPENAI_API_KEY,
    model: "text-embedding-3-small"
  }),

  // Chunker Configuration
  chunking: {
    maxChunkSizeChars: 1200,
    chunkOverlapChars: 150
  }
});

📊 Benchmarks

Run the built-in benchmark harness:

npm run benchmark

| Metric | In-Memory Store | PostgreSQL + pgvector (HNSW) | |---|---|---| | Ingestion Throughput | ~2,400 docs/sec | ~480 docs/sec | | Dense Search Latency (p50) | 0.42 ms | 4.8 ms | | Sparse BM25 Latency (p50) | 0.28 ms | 3.2 ms | | Hybrid RRF Latency (p50) | 0.75 ms | 6.1 ms | | Conceptual Recall Accuracy | 100% | 100% |


📖 Guides, Deep Dives & Articles


📄 License

MIT © Paritosh (Golden_IRIS)