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

tmlpd-pi

v1.3.1

Published

NEW v1.3.0: Token Optimization (arXiv:2608.17188) - Semantic Caching, Context Stratification, Token-Aware Fallback, Schema Contraction, Fetch-Once/Process-Local, Inter-Agent Compression. Plus: learned routing (RouteLLM), prefix caching (RadixAttention), s

Maintainers

dasrebeldasrebel

Keywords

pi-extensionpipi-packagepi-coding-agentpi-agenttmlpdtreequestmulti-llmparallel-aillm-orchestrationllmagent-orchestrationmulti-agentagentparallelstreamingcost-trackingcost-optimizationcachecachingcircuit-breakerretryexponential-backoffmctsmonte-carlo-tree-searchworkflow-optimizationhierarchical-planninghaloepisodic-memorysemantic-memoryagent-memorypythonpython-bindingspypilangchainllamaindexllama-indexautogencrewaihuggingfacetransformersagent-codegenai-codingopenaianthropicgooglegroqcerebrasmistralxaizaiclaudegpt-4geminillamamodel-routermodel-routingllm-routerai-agentsautonomous-agentsmemory-based-routermemory-based-llm-routermulti-llm-routerllm-memory-routeradaptive-routeradaptive-llm-routerintelligent-routerintelligent-llm-routerlearning-routercontextual-routercontext-aware-routertask-aware-routermemory-augmentedmemory-augmented-llmepisodic-memory-routersemantic-memory-routertask-memorycross-context-memorytoken-compressionsemantic-cachingcontext-stratificationtoken-aware-routingschema-contractfetch-once-process-localinter-agent-compressiontoken-optimizationcontext-compressionison-formatmessage-truncationcontext-managementlocal-llmollamavllmlmstudiolocal-modelprivacy-llmbatch-processingbatch-executionpriority-queuerate-limitingtoken-countingcost-estimationcost-predictionparallel-executionmulti-providerfallback-chainintelligent-failoverkv-cacheroutellmprefix-cachingradix-attentionspeculative-decodingmedusaeagleflashattentionpagedattentionkv-cache-quantizationllmlinguastreamingllmmultimodel-orchestrationmulti-agent-debateself-consistencytensor-parallelismcontinuous-batchingarxivresearch-backedicmlneuripsiclr

Readme

TMLPD — Parallel Multi-LLM Execution Module

Part of the A3M Router ecosystem.

Parallel multi-LLM execution with confidence-weighted ensemble merging. Runs providers simultaneously, scores each result, and returns the best answer with transparent reasoning.

What's New in v1.3.0

Token Optimization — 6 patterns from arXiv:2608.17188 for 40-60% token reduction:

| Pattern | Description | |:--------|:------------| | Semantic Cache | Embedding-based similarity caching (cosine > 0.85 threshold) | | Context Stratification |分层 context levels (LOW: 512 tokens, MEDIUM: 2048, HIGH: 8192) | | Token-Aware Fallback | Route to cheap/medium/expensive models by token count | | Schema Contraction | Inject schema reference vs full description | | Fetch-Once/Process-Local | One expensive fetch, extract with cheap model | | Inter-Agent Compression | Compress messages between agents |

Core Features

| Feature | Description | |:--------|:------------| | Parallel execution | Run N providers simultaneously, not sequentially | | Ensemble scoring | Score results on specificity, structure, and relevance | | Token Optimization | 6 patterns for 40-60% token reduction | | Query-type presets | Auto-configure provider + temp per task type | | Cost tracking | Per-query cost display with provider breakdown | | Persistent memory | Cross-session .memory.json with keyword indexing | | Prefix caching | RadixAttention-style caching for repeated prefixes | | Speculative decoding | Medusa/EAGLE-style multi-token prediction | | Token compression | ISON encoding for ~40% token reduction |

Usage

import { executeEnsemble, createPresetRouter, TokenOptimizer } from "tmlpd-pi";

// Parallel ensemble: run all providers simultaneously, pick best
const result = await executeEnsemble(
  "Explain vector databases",
  systemPrompt,
  context,
  { nvidia: callNvidia, groq: callGroq }
);
console.log(`Winner: ${result.winner} (score: ${result.scores[result.winner]})`);

// Token Optimization - 40-60% token reduction
const optimizer = new TokenOptimizer();
const optimized = await optimizer.optimizeQuery(
  "Explain quantum computing",
  history
);
console.log(`Context level: ${optimized.contextLevel}`);
console.log(`Recommended model: ${optimized.recommendedModel}`);
console.log(`Cache hit: ${optimized.cacheHit}`);

// Query-type presets: auto-configure per task
const router = createPresetRouter();
const preset = router.classify("Write a Python sort function"); // → 'code'

Token Optimization Patterns

import { SemanticCache, ContextStratifier, TokenAwareFallback } from "tmlpd-pi";

// Semantic caching - cache by embedding similarity
const cache = new SemanticCache({ similarityThreshold: 0.85 });
const cached = await cache.get("Explain quantum entanglement");
if (cached) console.log(`Cache hit! Similarity: ${cached.similarity}`);

// Context stratification - match context depth to query complexity
const stratifier = new ContextStratifier();
const result = stratifier.classify("What is 2+2?", history);
// → LOW context (512 tokens, no history)

// Token-aware fallback - route by token count
const fallback = new TokenAwareFallback();
const decision = fallback.selectModel(estimatedTokens);
// → cheap model for <500 tokens

Exports

  • createTMLPD, TMLPDTools — Core parallel execution
  • executeEnsemble, mergeComplementary, recordFeedback — P0 Ensemble voting
  • createPresetRouter, getPresetForQuery, DEFAULT_PRESETS — P1 Query presets
  • TokenOptimizer, SemanticCache, ContextStratifier, TokenAwareFallbackNEW Token Optimization
  • EpisodicMemoryStore — P3 Persistent memory with auto-save
  • CostTracker, BudgetEnforcer — P2 Cost tracking
  • ResponseCache, PrefixCache — Caching layers
  • HALOOrchestrator, MCTSWorkflowOptimizer — Advanced orchestration

Research Backing

  • Token Optimization (arXiv:2608.17188) — NEW 6 patterns for 40-60% token reduction
  • RouteLLM (arXiv:2404.06035) — Learned cost-quality routing
  • RadixAttention (arXiv:2312.07104) — 5-10x speedup via prefix caching
  • Medusa (arXiv:2401.10774) — 2-3x faster generation
  • A-Mem (arXiv:2502.12110) — Episodic memory patterns

Part of the A3M Router ecosystem. "Nobody does parallel multi-LLM execution with result merging. Everyone does sequential fallback."