惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Forbes - Security
Forbes - Security
Cisco Talos Blog
Cisco Talos Blog
Latest news
Latest news
P
Proofpoint News Feed
T
The Exploit Database - CXSecurity.com
Know Your Adversary
Know Your Adversary
S
Securelist
T
Tor Project blog
P
Palo Alto Networks Blog
G
GRAHAM CLULEY
NISL@THU
NISL@THU
C
CERT Recently Published Vulnerability Notes
L
LINUX DO - 热门话题
V
Vulnerabilities – Threatpost
Simon Willison's Weblog
Simon Willison's Weblog
AWS News Blog
AWS News Blog
T
The Blog of Author Tim Ferriss
Security Latest
Security Latest
P
Proofpoint News Feed
C
CXSECURITY Database RSS Feed - CXSecurity.com
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
T
Tenable Blog
博客园_首页
TaoSecurity Blog
TaoSecurity Blog
Attack and Defense Labs
Attack and Defense Labs
Project Zero
Project Zero
The Hacker News
The Hacker News
M
MIT News - Artificial intelligence
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Application and Cybersecurity Blog
Application and Cybersecurity Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
K
Kaspersky official blog
F
Full Disclosure
WordPress大学
WordPress大学
Engineering at Meta
Engineering at Meta
The Cloudflare Blog
N
Netflix TechBlog - Medium
Stack Overflow Blog
Stack Overflow Blog
L
LangChain Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
MongoDB | Blog
MongoDB | Blog
宝玉的分享
宝玉的分享
GbyAI
GbyAI
J
Java Code Geeks
云风的 BLOG
云风的 BLOG
Recent Announcements
Recent Announcements
博客园 - 叶小钗
Webroot Blog
Webroot Blog
Hacker News: Ask HN
Hacker News: Ask HN

Hacker News - Newest: "AI"

AI can't read an investor deck AI as an attorney? Student uses ChatGPT, Gemini to sue UW over alleged racial discrimination Hacking MCP Servers in AI Systems – The Rug Pull: Tool Changes After Approval GitHub - MeepCastana/KubeezCut: Free Web based video editor GitHub - GenAI-Gurus/awesome-eu-ai-act: Curated tools, official sources, OSS, templates, and guides for EU AI Act compliance. Can AI judge journalism? A Thiel-backed startup says yes, even if it risks chilling whistleblowers Coming soon: 10 Things That Matter in AI Right Now DARPA built an AI to fact-check enemy weapons claims What explains heterogeneity in AI adoption? When AI Meets Muscle: Context-Aware Electrical Stimulation Promises a New Way to Guide Human Movements - Department of Computer Science AI Changed How We Build. It Did Not Change What Matters. Linux rules on using AI-generated code - Copilot is OK, but humans must take 'full responsibility for the… Meta spins up AI version of Mark Zuckerberg to engage with employees Code Mode: Let Your AI Write Programs, Not Just Call Tools | TanStack Blog GitHub - Delavalom/graft: Go framework for building AI agents. Type-safe tools, multi-provider (OpenAI, Anthropic, Gemini, Bedrock), zero vendor SDKs. India's TCS tops estimates, says new AI models did not dent services demand Gen Z's fading AI hype Strong feeling: we are in a folded AI reality GitHub - machinarii/total-recall-catalog: A reference catalog of latest knowledge retrieval, memory & RAG systems GitHub - mensfeld/code-on-incus: Give each AI agent its own isolated machine with root, Docker, and systemd. Active defense detects and stops threats automatically.. Quantization, LoRA, and the 8% Problem: Benchmarking Local LLMs for Production AI Iran war: We spoke to the man making Lego-style AI videos that experts say are powerful propaganda Powell, Bessent discussed Anthropic's Mythos AI cyber threat with major U.S. banks GitHub - immartian/bellamem: Persistent belief-graph memory for AI agents. Retrieves decisive context by importance — not recency, not RAG, not /compact. recursive-mode: The Repo-Native Operating System for AI Engineering After the attack on Sam Altman's home, will AI CEO's go on the offensive? The biggest advance in AI since the LLM Opus 4.6 vs GPT 5.4 One Prompt Unity World Generation Test “AI polls” are fake polls Client Challenge Can AI be a 'child of God'? Inside Anthropic's meeting with Christian leaders How to Switch AI Chatbots and Why You Might Want To GitHub - MattMessinger1/agentic_refund_guardrail: Safe refund policy layer for AI agents — Python + TypeScript. Same behavior, shared tests. Adam/papers/emergent_values_whitepaper.md at master · strangeadvancedmarketing/Adam Ask HN: How do you stop playing 20 questions with your AI coding tools How far can automation and AI support psychotherapy? - @theU GitHub - stagas/rtdiff: realtime git diff gui and AI-assisted commits A Mac Studio for Local AI — 6 Months Later A History of the Early Years of AI at the University of Edinburgh Why AI Coding Tools Still Feel Stuck on Localhost MSN AI Datacenters Are Becoming Strategic Targets twitter.com Penn Researchers Use AI to Surface Unreported GLP-1 Side Effects in Reddit Posts Show HN: MoodSense AI (ML and FastAPI and Gradio, Deployed on Hugging Face) Moodsense Ai - a Hugging Face Space by aman179102 AI models are terrible at betting on soccer—especially xAI Grok GitHub - xialeistudio/echoic GitHub - HimashaHerath/github-dev-wrapped: AI-powered weekly GitHub activity reports deployed to GitHub Pages GitHub - alejandrobalderas/claude-code-from-source: Architecture, patterns & internals of Anthropic's AI coding agent — reverse-engineered from source maps AI and Tech brief: Ireland ascendant GitHub - Titovilal/context0: Context0 - Never Surrender Training for a Marathon with an AI Coach: What Worked and What Didn't Cyber Pulse: Agentic Intel - Apps on Google Play I Built an AI PR Reviewer That Catches Bugs by Not Looking for Bugs Gen Z workers are so fearful AI will take their job they’re intentionally sabotaging their company’s AI rollout | Fortune How AI Is Reimagining the Game of Golf–For Both Players and Courses GitHub - nattergabriel/reseed: A CLI tool for managing and distributing agent skills across projects Is SVG the final frontier? My AI workflow evolved from prompts to a near-autonomous workflow MLSharp Help - 3DGS Viewer & Generator I put my cognitive field based AI's runtime on GitHub Is Numble the first AI-proof game? A3: Kubernetes for autonomous AI agent fleets | Emergent Principles Deepali Vyas ("The Elite Recruiter") GitHub - msmarkgu/RelayFreeLLM: A restful API designed to route user prompts to various AI model providers. Unionized ProPublica staff are on strike over AI, layoffs, and wages Unleashing the Advantage of Quantum AI We're heading for an AI-fueled 'dementia crisis,' brain scientist warns The AI-Assisted Breach of Mexico's Government Infrastructure [pdf] GitHub - stef41/lmscan: 🔍 Detect AI-generated text and fingerprint which LLM wrote it. Open-source GPTZero alternative. Zero dependencies, works offline. MSN GitHub - visionscaper/collabmem: Enabling long-term collaboration with Agentic AI - building up episodic and world model memory over time with in-context awareness We gave an AI a 3 year retail lease in SF and asked it to make a profit | Andon Labs AI Code is Hollowing Out Open Source, and Maintainers are Looking the Other Way What leaked "SteamGPT" files could mean for the PC gaming platform's use of AI AI is the boss at this retail store. What could go wrong? GitHub - Wuzu11517/agentic-proxy: Local proxy meant to help reduce With Drones, Geophysics and ArtificiaI Intelligence, Researchers Prepare to Do Battle Against Land Mines A Single Operator, Two AI Platforms, Nine Government Agencies: The Full Technical Report 在 Steam 上购买 FriedrichAI: Offline AI 立省 10% GitHub - inevolin/resume-cli: Hit Claude usage limits? Resume any AI coding session elsewhere. Switch tools at zero friction. GitHub - atripati/ark: AI Runtime Kernel — a context operating system for AI agents. Eliminates tool bloat, loads only what’s needed, and gives LLMs their reasoning space back. How to Build a Secure AI PR Reviewer with Claude, GitHub Actions, and JavaScript This Startup Wants You to Pay Up to Talk With AI Versions of Human Experts Intel Arc Pro B70 Brings 32GB VRAM to Local AI for $949 WordPress 7.0: The Good, the AI, and the Still Missing AI on the couch: Anthropic gives Claude 20 hours of psychiatry IatroBench: Pre-Registered Evidence of Iatrogenic Harm from AI Safety Measures AI Agents Know About Supabase. They Don't Always Use It Right. The history and future of AI at Google, with Sundar Pichai Inside an AI‑enabled device code phishing campaign How Meta Used AI to Map Tribal Knowledge in Large-Scale Data Pipelines AI for Systems: Using LLMs to Optimize Database Query Execution Forecasting the Economic Effects of AI Introducing Tinker: Play with AI, bring your ideas to life AI sheds light on an ancient gaming mystery People really hate AI but not as much as Iran—or Democrats | Fortune What is an AI Product Engineer? Phoebe Gates wants her $185 million AI startup to succeed with 'no ties to my privilege or my last name': 'I have a chip on my shoulder' | Fortune
GitHub - Alekkk777/MiniVecDb
alekkk777 · 2026-04-24 · via Hacker News - Newest: "AI"

MicroVecDB

50 KB · 0 server · 32× less RAM · TTL-aware ephemeral memory for AI agents

A vector database compiled from Rust to WebAssembly (browser / Node.js / Edge) and a native Python extension (PyO3). It stores embeddings with 1-bit quantisation, indexes them with HNSW, and searches in microseconds — with built-in TTL garbage collection so your agent's memory never goes stale.

npm install @microvecdb/core        # TypeScript / browser / Node.js / Edge
pip install minivecdb               # Python (native Rust extension)

The problem with agent memory

Every LLM framework offers "memory". Almost none of them expire it.

An agent that observes "the user is on step 2" at turn 3 should not still be acting on that observation at turn 50. But most vector stores are append-only: observations accumulate, similarity search scores degrade, and the agent confuses past context with present state.

MicroVecDB treats this as a first-class concern. Every stored text has a TTL. A background GC thread (Python) or setInterval (JS) tombstones expired vectors automatically. You set ttl_minutes=10; the memory cleans itself up.


When to use MicroVecDB vs. a server database

Use case Right tool
LLM agent scratchpad (ephemeral, single-request) MicroVecDB
Browser app — user data must not leave the device MicroVecDB
Offline / PWA — works without network MicroVecDB
Edge function — no persistent infra MicroVecDB
Multi-user production system, durable pgvector / Pinecone / Qdrant

Benchmarks

Measured on a 2023 MacBook Pro M2.

Metric Result Notes
Search latency (10k vectors) 0.08 ms HNSW, ef=64
Search latency (50k vectors) 0.31 ms HNSW, ef=64
Batch insert 0.5 µs / vector single WASM call
Index build (10k vectors) ~180 ms M=16, ef_construction=200
RAM per vector (384-dim) 48 B vs 1,536 B for f32
RAM — 1M vectors 48 MB vs 1.5 GB for f32
Recall@5 (sentence embeddings) 100% all-MiniLM-L6-v2, 20-doc corpus
Recall@5 (visual pHash) ≥ 95% 10 clusters × 5 variants
WASM binary size 50 KB brotli: 38 KB
Runtime dependencies 0 pure WASM + thin JS glue

Quick-starts

Vercel AI SDK (agent scratchpad)

import { openai } from '@ai-sdk/openai';
import { streamText } from 'ai';
import { VercelMiniVecDb } from '@microvecdb/core/vercel';

// Create a per-request ephemeral memory — 10 min TTL, GC every 30 s
const memory = await VercelMiniVecDb.create(
  openai.embedding('text-embedding-3-small'),
  { ttlMinutes: 10, gcIntervalMs: 30_000 },
);

// Store agent observations
await memory.add([
  'User mentioned their order number is 42-ABC.',
  'User is on the returns flow, step 2 of 4.',
]);

// Plug directly into streamText — the LLM calls it autonomously
const result = await streamText({
  model: openai('gpt-4o-mini'),
  tools: { searchMemory: memory.createRetrievalTool() },
  messages,
});

// Clean up when the request is done
memory.destroy();

LangChain Python (agent scratchpad)

from langchain_openai import OpenAIEmbeddings
from minivecdb.langchain import LangChainMiniVecDb

# 10-minute TTL, GC daemon fires every 30 s
memory = LangChainMiniVecDb(
    embedding=OpenAIEmbeddings(model="text-embedding-3-small"),
    ttl_minutes=10,
    gc_interval_sec=30,
)

memory.add_texts([
    "User mentioned ticket #42-ABC.",
    "User has already tried resetting their password.",
])

results = memory.similarity_search("what is the user's issue?", k=3)

# Use as a context manager for automatic cleanup
with LangChainMiniVecDb(embedding=..., ttl_minutes=5) as mem:
    mem.add_texts(["observation"])
    docs = mem.similarity_search("query")
# GC thread stopped automatically on exit

LangChain JS

import { OpenAIEmbeddings } from '@langchain/openai';
import { LangChainMiniVecDb } from '@microvecdb/core';

const store = await LangChainMiniVecDb.fromTexts(
  ['Paris is the capital of France.', 'Berlin is the capital of Germany.'],
  [{ source: 'wiki' }, { source: 'wiki' }],
  new OpenAIEmbeddings({ modelName: 'text-embedding-3-small' }),
);

const results = await store.similaritySearch('European capitals', 3);

Raw WASM API (browser / Node.js)

import { MicroVecDB } from '@microvecdb/core';

const db = await MicroVecDB.init({ capacity: 10_000 });
db.insert({ id: 1, vector: new Float32Array(384) });
db.buildIndex();

const results = db.search(queryVec, { limit: 5 });
// → [{ id: 1, score: 0.94 }, …]

Raw Python API

from minivecdb import MiniVecDb
import numpy as np

db = MiniVecDb(capacity=10_000)
vec = np.random.randn(384).astype(np.float32)
vec /= np.linalg.norm(vec)

db.insert(id=0, vector=vec.tolist(), inserted_at=0.0)
db.build_index(m=16, ef_construction=200)

results = db.search(vec.tolist(), limit=5)
# → [{"id": 0, "score": 1.0, "distance": 0}, …]

TTL & garbage collection

Every high-level adapter supports TTL-based auto-expiry.

How it works

  1. Each inserted text gets a wall-clock timestamp at insert time.
  2. A background GC loop fires every gcIntervalMs / gc_interval_sec.
  3. GC tombstones vectors older than ttlMinutes / ttl_minutes in the Rust layer (zero-copy soft-delete) and evicts them from the JS/Python doc map.
  4. Tombstoned slots are invisible to search() and are physically reclaimed on compact().

Setting ttlMinutes: 0 (default) disables GC entirely — no timer is created.

Manual GC

// TypeScript
const count = memory.runGc();  // returns tombstone count

// Python
count = memory.run_gc()

How it achieves these numbers

1-bit quantisation — 32× RAM, near-zero recall loss

Every Float32Array(384) is compressed to 12 × u32 (384 bits = 48 bytes):

f32[384]  →  sign(x − μ)  →  bit[384]  →  u32[12]

The sign bit captures which side of the per-dimension median each value falls on. For L2-normalised sentence embeddings this preserves nearest-neighbour rank order with very high fidelity — semantically close vectors share ≥ 85% of their sign bits.

Hamming distance — ~10× faster than cosine

fn hamming(a: &[u32; 12], b: &[u32; 12]) -> u32 {
    a.iter().zip(b).map(|(x, y)| (x ^ y).count_ones()).sum()
}

XOR + POPCNT maps to a single CPU instruction on every modern chip. Comparing two 384-bit vectors takes ~12 POPCNT operations vs. 384 multiplications for dot product.

HNSW — O(log n) approximate nearest neighbour

Multi-layer graph: Layer 0 has all vectors connected to their M=16 closest neighbours; each higher layer is a ~37% random subset. Search descends from the sparse top layer to the dense bottom layer in O(log n) hops.

Parameters: M=16, ef_construction=200, ef_search=64.

Rust → WASM → browser

  • lol_alloc: minimal WASM allocator, avoids 30 KB overhead of wee_alloc
  • wasm-bindgen: zero-copy transfer of Float32Array from JS to WASM
  • Flat arena storage: Vec<[u32;12]> — cache-friendly, no pointer chasing
  • OPFS persistence: FileSystemSyncAccessHandle — ~500 MB/s, no server needed

PyO3 native extension

The Python package is a Rust native extension (.so / .pyd) built with Maturin. The same microvecdb-core Rust library powers both the WASM and Python builds — no code duplication.


Full API

TypeScript / WASM

MicroVecDB.init(options?)

const db = await MicroVecDB.init({
  capacity: 10_000,          // pre-allocate slots; grows automatically (default: 1024)
  persistenceKey: 'my-app',  // OPFS key; null = ephemeral (default: null)
  m: 16,                     // HNSW edges per node (default: 16)
  efConstruction: 200,       // HNSW build quality (default: 200)
});

db.insert({ id, vector }) / db.insertBatch(items)

db.insert({ id: 42, vector: new Float32Array(384) });
// Bulk insert — 5–10× faster, single WASM call:
db.insertBatch([{ id: 0, vector: v0 }, { id: 1, vector: v1 }]);

db.search(queryVec, { limit?, ef? })

const results = db.search(queryVec, { limit: 5, ef: 64 });
// → Array<{ id: number, score: number }>  — score ∈ [0, 1]

db.delete(id) / db.compact() / db.stats() / db.dispose()

SharedMicroVecDB — non-blocking via Web Worker

import { SharedMicroVecDB } from '@microvecdb/core/worker';
const db = await SharedMicroVecDB.init({ capacity: 100_000 });
await db.insertBatch(items);
const results = await db.search(queryVec, { limit: 5 });

Python

MiniVecDb(capacity?)

from minivecdb import MiniVecDb

db = MiniVecDb(capacity=10_000)
db.insert(id=0, vector=[0.1] * 384, inserted_at=time.time() * 1000)
db.build_index(m=16, ef_construction=200)
results = db.search([0.1] * 384, limit=5)
# → [{"id": 0, "score": 1.0, "distance": 0}]

tombstoned = db.run_gc(ttl_ms=60_000)  # manual GC
data = db.serialize()                   # bytes — use with deserialize()

LangChainMiniVecDb

from minivecdb.langchain import LangChainMiniVecDb

store = LangChainMiniVecDb(
    embedding=embeddings,
    capacity=50_000,
    ttl_minutes=10,       # 0 = immortal
    gc_interval_sec=30,
)

ids = store.add_texts(["text1", "text2"], metadatas=[{"k": "v"}, {}])
docs = store.similarity_search("query", k=4)
docs_scores = store.similarity_search_with_score("query", k=4)
# → [(Document, score), …]

store.delete(ids=["0", "1"])
store.build_index()
store.destroy()           # stop GC thread, free memory

Setup guides

Vite

// vite.config.ts
export default defineConfig({
  optimizeDeps: { exclude: ['@microvecdb/core'] },
  assetsInclude: ['**/*.wasm'],
  server: { fs: { allow: ['../..'] } },
});

For OPFS / SharedWorker mode, add COOP/COEP headers:

server: {
  headers: {
    'Cross-Origin-Opener-Policy': 'same-origin',
    'Cross-Origin-Embedder-Policy': 'require-corp',
  },
},

Next.js / Edge Runtime

The @microvecdb/core/vercel sub-path is tree-shaken: it imports ai and zod only when used, keeping the main bundle at 0 extra dependencies.


Development

TypeScript / WASM

git clone https://github.com/Alekkk777/MiniVecDb.git
cd MiniVecDb
npm install

# Build WASM binary + TypeScript wrapper
npm run build --workspace=packages/core

# Build + regenerate SRI hashes
npm run build:full --workspace=packages/core

# Tests (vitest)
npm test --workspaces --if-present

# Watch mode
npm run test:watch --workspace=packages/core

Requires: rustup, wasm-pack, Node.js ≥ 18.

rustup target add wasm32-unknown-unknown
cargo install wasm-pack

Python native extension

cd crates/microvecdb-python
pip install maturin

# Development build (editable install)
maturin develop --release

# Run tests
pip install pytest freezegun langchain-core
pytest tests/ -v

# Build a wheel
maturin build --release

Examples

npm run dev --workspace=examples/pdf-brain     # → http://localhost:5173
npm run dev --workspace=examples/visual-search  # → http://localhost:5174

Project structure

crates/
  microvecdb-core/        Rust library (quantisation, storage, HNSW, time)
  microvecdb-wasm/        wasm-bindgen bindings → browser / Node.js
  microvecdb-python/      PyO3 native extension → minivecdb PyPI package
    python/minivecdb/
      __init__.py         re-exports MiniVecDb from _minivecdb.so
      langchain.py        LangChain VectorStore adapter with TTL GC
    tests/                pytest suite (38 unit + 5 integration)
packages/
  core/                   @microvecdb/core npm package
    src/
      MicroVecDB.ts       WASM wrapper
      SharedMicroVecDB.ts Web Worker proxy
      langchain.ts        LangChain JS adapter
      vercel.ts           Vercel AI SDK adapter with TTL GC
examples/
  pdf-brain/              Local RAG demo (React + Transformers.js)
  visual-search/          Image similarity demo (React + pHash)

Security

Layer Mechanism
Runtime privacy JS # private fields — no external access to WASM pointers
Input validation assertValidVector, assertValidId — rejects NaN/Infinity before WASM
Cross-origin isolation COOP + COEP headers for SharedArrayBuffer mode
Supply chain SRI hashes in dist/sri-hashes.json — verify with npm run generate-sri

License

MIT