@zukhruf/retrieval weekly downloads statistics
By zukhruf (3 listings) · npm · AI SDKs
The query side of RAG: retrievers that search a passage table by meaning or keywords in SQLite, Postgres or SQL Server, fuse lists, rerank and post-process, and give the best passages first with a score that is higher for a better passage.
@zukhruf/retrieval has 33,019 recorded weekly downloads on npm, a change of +29.2% over the past 7 days, ranking #900 of 3,247 tracked listings.
About @zukhruf/retrieval
@zukhruf/retrieval
This package is the query side of retrieval-augmented generation (RAG). A query goes in. A retrieval result comes out: the best passages, best first, and the failures. An engine retriever, a fusion and a reranker give each passage a score, which is higher for a better passage; a host's source of order only, such as a web search, gives ranked passages with no score (ADR 0021). The package never cuts a document or writes a vector: elt writes the passages, their vectors with the model identity, and a keyword index (ADR 0001). A reranker may embed the text of the candidates of a query when that query runs, as a search embeds the query (ADR 0022).
The port of the package is Retriever. A query is a string, or a query bundle with a text for each kind of search (ADR 0013). The engine retrievers read that passage contract with the SQL of SQLite, Postgres or SQL Server. A host can implement Retriever over any other source, such as a web search. Composite retrievers fuse retrievers, rerank or rewrite the query, and postprocessors cut, diversify, group, reorder and widen the result.
The package has four entry points. @zukhruf/retrieval has the port, the composite retrievers, the fusions and their strategies, the postprocessors and the errors. @zukhruf/retrieval/sqlite, @zukhruf/retrieval/postgres and @zukhruf/retrieval/sqlserver each have the passage store and the engine retrievers of one engine.
The words in these documents have one meaning each. See the glossary in CONTEXT.md.
Use it
npm install @zukhruf/retrieval @zukhruf/vectors ai zod
This program writes a small passage contract into an in-memory SQLite database and searches it by meaning. In production, elt writes the contract, and the model is an AI SDK embedding model. Here a stand-in model from ai/test counts three words, so the program runs offline.
import { DatabaseSync } from 'node:sqlite';
import { MockEmbeddingModelV4 } from 'ai/test';
import { z } from 'zod';
import {
SqliteEmbeddingRetriever,
SqlitePassageStore,
} from '@zukhruf/retrieval/sqlite';
import { Vector } from '@zukhruf/vectors';
import { install, toSql } from '@zukhruf/vectors/sqlite';
// A stand-in embedding model, so that the program runs offline: each vector
// counts three words. Give an AI SDK model in its place, such as
// openai.embedding('text-embedding-3-small').
const words = ['key', 'token', 'backup'];
const embedText = (text: string) =>
words.map(
(word) =>
text
.toLowerCase()
.split(/\W+/)
.filter((w) => w === word).length,
);
const model = new MockEmbeddingModelV4({
provider: 'toy',
modelId: 'three-words',
maxEmbeddingsPerCall: 100,
doEmbed: async ({ values }) => ({
embeddings: values.map(embedText),
warnings: [],
}),
});
// The passage contract. elt writes it; this program writes it by hand.
const database = new DatabaseSync(':memory:');
install(database); // registers vec_distance_cosine; or load sqlite-vec
database.exec(`
CREATE TABLE docs_passages (id TEXT PRIMARY KEY, source TEXT NOT NULL, seq INTEGER NOT NULL, start INTEGER NOT NULL, "end" INTEGER NOT NULL, text TEXT NOT NULL, product TEXT, year INTEGER);
CREATE TABLE docs_passage_vectors (id TEXT PRIMARY KEY, vector BLOB NOT NULL, model TEXT NOT NULL);
`);
const documents = [
[
'vault-guide',
'vault',
2025,
[
'Create a new key before you rotate the old key.',
'Then move each token to the new key.',
'Keep a backup of the old key for 30 days.',
],
],
[
'vault-faq',
'vault',
2024,
[
'A token expires after one hour.',
'Revoke a token when a device is lost.',
],
],
['mail-guide', 'mail', 2025, ['Make a backup of each mailbox every night.']],
] as const;
const insertPassage = database.prepare(
'INSERT INTO docs_passages VALUES (?, ?, ?, ?, ?, ?, ?, ?)',
);
const insertVector = database.prepare(
'INSERT INTO docs_passage_vectors VALUES (?, ?, ?)',
);
for (const [source, product, year, sentences] of documents) {
let start = 0; // offsets count code points
for (const [seq, sentence] of sentences.entries()) {
// The passages tile their source: each keeps the space before it.
const text = seq === 0 ? sentence : ` ${sentence}`;
const id = `${source}#${seq}`;
const end = start + [...text].length;
insertPassage.run(id, source, seq, start, end, text, product, year);
insertVector.run(
id,
toSql(Vector.from(embedText(text))),
'toy/three-words (3 dimensions)',
);
start = end;
}
}
// The metadata of a passage: the columns of its row beside the passage's own.
const Doc = z.object({ product: z.string(), year: z.number() });
const store = new SqlitePassageStore({
database,
passages: 'docs_passages',
metadata: Doc.parse,
});
const retriever = new SqliteEmbeddingRetriever({
store,
vectors: 'docs_passage_vectors',
model,
});
const { passages } = await retriever.retrieve('How do I rotate a key?', {
topK: 3,
});
for (const { passage, score } of passages) {
console.log(score.toFixed(3), passage.id, passage.text);
}
Output:
1.000 vault-guide#0 Create a new key before you rotate the old key.
0.707 vault-guide#1 Then move each token to the new key.
0.707 vault-guide#2 Keep a backup of the old key for 30 days.
```…
Description from the npm listing.
- retrieval
- rag
- retriever
- vector-search
- bm25
- reciprocal-rank-fusion
- rerank
- ai-sdk
- sqlite
- postgres
- sql-server
README badge
Show your rank in a README or on your website. The badge updates automatically.
Charts
Images: 30d · 1y · all time · 1600×900 dark
Adoption over time
7/30/90-day growth
Ranking history
Listing placement
Listing placement
Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.
Each band is one page of 20. Weekly downloads on a linear scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.
Recent observations
Full history (128)Similar npm AI SDKs plugins
All 20 @zukhruf/retrieval alternativesData source
Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.
Listing: https://www.npmjs.com/package/@zukhruf/retrieval. First seen Nov 26, 2026; last successful collection Dec 6, 2026. See the methodology.