Current collected state Current
Observed since 20 Oct, 17:40 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
Unified Vector Search service for 0G Storage — decentralized HNSW index on 0G's sharded KV layer
Unified Vector Search on 0G Storage — a decentralized HNSW index built on 0G's sharded KV layer.
Transforms 0G Labs from a Data Repository into a Reasoning Engine by implementing approximate nearest neighbor search directly on 0G's modular storage stack.
@0glabs/0g-ts-sdknpm install 0g-vector-search @0glabs/0g-ts-sdk ethers
import { VectorStore } from "0g-vector-search";
// Local development (no 0G network required)
const store = new VectorStore({ dimensions: 768 });
await store.initialize();
// Insert vectors
await store.upsert(
"doc_001",
embedding, // Float32Array[768]
{ source: "arxiv", topic: "ml" }, // metadata
"Attention is all you need..." // text for keyword search
);
// Semantic search
const results = await store.search(queryEmbedding, { topK: 10 });
// Hybrid search (recommended)
const results = await store.search(queryEmbedding, {
topK: 10,
hybrid: {
enabled: true,
semanticWeight: 0.7,
query: "transformer architecture",
},
});
const store = new VectorStore({
dimensions: 768,
zeroG: {
endpoint: "http://3.101.147.150:6789",
streamId: "your-stream-id",
privateKey: "0x...",
flowContract: "0x...",
kvNodeCount: 1,
},
});
┌─────────────────────────────────────────────────┐
│ VectorStore │
│ ┌──────────┐ ┌──────────┐ ┌───────────────┐ │
│ │ HNSW │ │ BM25 │ │ Security │ │
│ │ Index │ │ Index │ │ Layer │ │
│ └────┬─────┘ └────┬─────┘ └───────┬───────┘ │
│ │ │ │ │
│ ┌────┴──────────────┴───────────────┴───────┐ │
│ │ Shard Router (FNV-1a) │ │
│ └────────────────┬──────────────────────────┘ │
│ │ │
│ ┌────────────────┴──────────────────────────┐ │
│ │ 0G KV Layer (via Batcher / KvClient) │ │
│ └───────────────────────────────────────────┘ │
└─────────────────────────────────────────────────┘
All data is stored in 0G's KV layer with hex-encoded keys:
| Key Pattern | Description |
|---|---|
vec:<shard>:<node> | Raw vector data (Float32 buffer) |
idx:<shard>:<node>:<layer> | HNSW graph connections per layer |
meta:<shard>:<node> | Vector metadata (JSON) |
bm25:<shard>:<node> | BM25 term frequencies |
cfg:global:index_state | Index config, entry point, max level |
ShardRouter.getShardId(id) → FNV-1a hash determines target shardHNSWIndex.insert(id, vector) → builds graph links across layersBM25Index.addDocument(id, content) → indexes text for keyword searchPoRAVerifier.generateCommitment() → creates proof for 0G validatorsGraphPersistence.save*() → writes to 0G KV via BatcherDataAvailabilityGuard checks shard healthHybridSearchEngine.search() → HNSW + BM25 score fusionAlignmentVerifier.verifyResults() → checks for injection attacks| Parameter | Default | Description |
|---|---|---|
dimensions | 768 | Vector dimensionality |
M | 16 | Max connections per HNSW layer |
efConstruction | 200 | Candidate list size during insertion |
efSearch | 50 | Candidate list size during search |
metric | cosine | Distance metric (cosine/euclidean/dot_product) |
numShards | 4 | Number of 0G storage shards |
npm install # Install dependencies
npm test # Run test suite (21 tests)
npm run build # TypeScript compilation
MIT
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 0.1.0Registry latest | 8 Mar 2026 | 5 |
This describes our collected data; it is not a security assessment.
Shared repository data · GitHub
Observed since 20 Oct, 17:40 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:fe1bc7bc416e755e3c448c61ad5e511e9e7c6b76c864805e0f4787af22cb31b4