agentleFS
ruvnetruvnet/agentdb/.agents/skills/agentdb-quantized-search/SKILL.md

agentdb-quantized-search

Skill99 starsChanged 10 days agoMITView on GitHub

Speed up AgentDB's built-in sql.js vector backend on large collections with the opt-in RaBitQ 1-bit quantized index (@ruvector/rabitq-wasm). Use when SqlJsRvfBackend search gets slow past ~10,000 vectors, when choosing between exact and approximate search for a browser or no-native install, or when the user asks about RaBitQ or quantized search in AgentDB.

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Don't enable it for write-heavy workloads that query after every few writes on a large collection.

    line 46
  2. Distinctive:

    Don't expect it to change other backends.

    line 47

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Quantized search (RaBitQ)

SqlJsRvfBackend, the built-in .rvf backend used when no native vector engine is available, scans every vector on every query. With quantizedIndex: 'rabitq', a 1-bit RaBitQ index from @ruvector/rabitq-wasm (an optional dependency, installed by default) narrows each query to a candidate set. The candidates are then rescored exactly, so returned similarities are exact. Only which ids reach the top-k is approximate.

Turn it on

import { SqlJsRvfBackend } from 'agentdb/backends';

const backend = new SqlJsRvfBackend({
  dimension: 384,
  metric: 'cosine',               // or 'l2'; 'ip' always stays exact
  quantizedIndex: 'rabitq',
  rabitq: { minVectors: 2000, overfetch: 10, rerankFactor: 20 },  // defaults shown
} as any);
await backend.initialize();
backend.getQuantizedIndexStats(); // { enabled, indexed, dirty, builds, lastBuildMs } or null when off

The environment variable AGENTDB_QUANTIZED_INDEX=rabitq turns it on for every SqlJsRvfBackend in the process. If the package is missing, the backend logs one warning and keeps the exact scan.

Measured (npm run benchmark:ecosystem; 384-dim, clustered data, cosine, top-10)

VectorsExact scanRaBitQRecall@10Index build (first query)
5,0003.3 ms3.1 ms1.0000.5 s
20,0008.5 ms3.4 ms1.0001.4 s
50,00033.3 ms5.2 ms1.0005.1 s

For queries unrelated to the data, where neighbours are near-tied, recall@10 is 0.96 to 0.98 at the default overfetch: 10 and 1.000 at 50.

How it stays correct

  • The index covers a snapshot. Ids written or removed after it are dirty: their stale index hits are dropped and their current vectors are scanned exactly on every query.
  • The snapshot is rebuilt on the next query once dirty ids pass max(256, 10% of the snapshot). The rebuild blocks that query, about 1 s per 10,000 vectors at 384 dimensions.
  • Queries with a metadata filter use the exact scan.
  • Below minVectors there is no index. The exact scan is as fast there.

Don't

  • Don't enable it for write-heavy workloads that query after every few writes on a large collection. Each rebuild costs seconds.
  • Don't expect it to change other backends. RuVector, native RVF and hnswlib already have their own ANN indexes.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.